Entities

Untitled

Aug 3rd, 2021
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. public class Hologram {
  2.  
  3. private static MineCore plugin = JavaPlugin.getPlugin(MineCore.class);
  4. private List<EntityArmorStand> entitylist = new ArrayList<EntityArmorStand>();
  5. private String[] Text;
  6. private Location location;
  7. private double DISTANCE = 0.25D;
  8. int count;
  9.  
  10. public Hologram(String[] Text, Location location) {
  11. this.Text = Text;
  12. this.location = location;
  13. create();
  14. }
  15.  
  16. public void hidePlayer(Player player) {
  17. for (EntityArmorStand armor : entitylist) {
  18. PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(armor.getId());
  19. ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
  20. }
  21. }
  22.  
  23. public void showPlayer(Player player) {
  24. for (EntityArmorStand armor : entitylist) {
  25. PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armor);
  26. ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
  27. }
  28. }
  29.  
  30. public void showPlayerTemp(final Player player, int time) {
  31. showPlayer(player);
  32. Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
  33. @Override
  34. public void run() {
  35. hidePlayer(player);
  36. }
  37. }, time);
  38. }
  39.  
  40. private void create() {
  41. for (String Text : this.Text) {
  42. EntityArmorStand entity = new EntityArmorStand(((CraftWorld) this.location.getWorld()).getHandle(),this.location.getX(), this.location.getY(),this.location.getZ());
  43. entity.setCustomName(new ChatComponentText(Text));
  44. entity.setCustomNameVisible(true);
  45. entity.setInvisible(true);
  46. entity.setNoGravity(true);
  47. entitylist.add(entity);
  48. this.location.subtract(0, this.DISTANCE, 0);
  49. count++;
  50. }
  51. this.count = 0;
  52. }
  53. }
Add Comment
Please, Sign In to add comment