Guest User

Untitled

a guest
Nov 30th, 2021
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. public class FakeArmorStand {
  2.  
  3. private volatile static int start = 500000;
  4. private WrapperPlayServerSpawnEntity spawn;
  5. private WrapperPlayServerEntityMetadata meta;
  6. private WrapperPlayServerEntityDestroy destroy;
  7. private String name;
  8.  
  9. public FakeArmorStand(Plugin plugin, Location location, String name) {
  10. this.spawn = new WrapperPlayServerSpawnEntity();
  11. this.meta = new WrapperPlayServerEntityMetadata();
  12. this.destroy = new WrapperPlayServerEntityDestroy();
  13. this.spawn.setType(EntityType.ARMOR_STAND.getTypeId());
  14. this.spawn.setEntityID(start);
  15. this.spawn.setUniqueId(UUID.randomUUID());
  16. WrappedChatComponent nick = WrappedChatComponent.fromText(ChatColor.translateAlternateColorCodes('&', name));
  17. List<WrappedWatchableObject> obj = Util.asList(
  18. new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject(14, WrappedDataWatcher.Registry.get(Byte.class)), (byte)0x01),
  19. //new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20),
  20. new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject(3, WrappedDataWatcher.Registry.get(Boolean.class)), true),
  21. new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.get(String.class)), name));
  22. this.meta = new WrapperPlayServerEntityMetadata();
  23. this.meta.setEntityID(start);
  24. this.meta.setMetadata(obj);
  25. List<Integer> list = new ArrayList<>();
  26. list.add(start);
  27. this.destroy.setEntityIds(list.stream().mapToInt(i->i).toArray());
  28. this.name = name;
  29. start++;
  30. }
  31.  
  32. public void setName(String name) {
  33. this.name = name;
  34. this.meta.getMetadata().get(2).setValue(name);
  35. }
  36.  
  37. public void setLocation(Location loc) {
  38. this.spawn.setX(loc.getX());
  39. this.spawn.setY(loc.getY());
  40. this.spawn.setZ(loc.getZ());
  41. }
  42.  
  43. public void sendSpawnPacket(Player player) {
  44. this.spawn.sendPacket(player);
  45. String temp = this.name;
  46. if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
  47. temp = PlaceholderAPI.setPlaceholders(player, this.name);
  48. WrappedChatComponent nick = WrappedChatComponent
  49. .fromText(ChatColor.translateAlternateColorCodes('&', temp));
  50. this.meta.getMetadata().get(1).setValue(Optional.of(nick.getHandle()));
  51. }
  52. this.meta.sendPacket(player);
  53. }
  54.  
  55. public void sendDestroyPacket(Player player) {
  56. this.destroy.sendPacket(player);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment