Entities

Untitled

Aug 3rd, 2021
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. package minecore.captcha;
  2.  
  3. import minecore.MineCore;
  4. import net.minecraft.server.v1_16_R3.*;
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Location;
  7. import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
  8. import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11.  
  12. import java.util.ArrayList;
  13. import java.util.List;
  14.  
  15. public class Hologram {
  16.  
  17. private static MineCore plugin = JavaPlugin.getPlugin(MineCore.class);
  18. private List<EntityArmorStand> entitylist = new ArrayList<EntityArmorStand>();
  19. private String[] Text;
  20. private Location location;
  21. private double DISTANCE = 0.25D;
  22. int count;
  23.  
  24. public Hologram(String[] Text, Location location) {
  25. this.Text = Text;
  26. this.location = location;
  27. create();
  28. }
  29.  
  30. public void hidePlayer(Player player) {
  31. for (EntityArmorStand armor : entitylist) {
  32. PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(armor.getId());
  33. ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
  34. }
  35. }
  36.  
  37. public void showPlayer(Player player) {
  38. for (EntityArmorStand armor : entitylist) {
  39. armor.setInvisible(false);
  40. armor.setNoGravity(false);
  41. armor.setSmall(true);
  42. armor.setCustomNameVisible(true);
  43. PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armor);
  44. ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
  45. Bukkit.broadcastMessage(" A " + armor.getCustomNameVisible());
  46. }
  47. }
  48.  
  49. public void showPlayerTemp(final Player player, int time) {
  50. showPlayer(player);
  51. Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
  52. @Override
  53. public void run() {
  54. hidePlayer(player);
  55. }
  56. }, time);
  57. }
  58.  
  59. private void create() {
  60. for (String Text : this.Text) {
  61. EntityArmorStand entity = new EntityArmorStand(((CraftWorld) this.location.getWorld()).getHandle(),this.location.getX(), this.location.getY(),this.location.getZ());
  62. entity.setCustomName(new ChatComponentText(Text));
  63. entity.setCustomNameVisible(true);
  64. entity.setInvisible(true);
  65. entity.setNoGravity(true);
  66. entitylist.add(entity);
  67. this.location.subtract(0, this.DISTANCE, 0);
  68. count++;
  69. }
  70. this.count = 0;
  71.  
  72.  
  73. }
  74. }
  75.  
Add Comment
Please, Sign In to add comment