Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FakeArmorStand {
- private volatile static int start = 500000;
- private WrapperPlayServerSpawnEntity spawn;
- private WrapperPlayServerEntityMetadata meta;
- private WrapperPlayServerEntityDestroy destroy;
- private String name;
- public FakeArmorStand(Plugin plugin, Location location, String name) {
- this.spawn = new WrapperPlayServerSpawnEntity();
- this.meta = new WrapperPlayServerEntityMetadata();
- this.destroy = new WrapperPlayServerEntityDestroy();
- this.spawn.setType(EntityType.ARMOR_STAND.getTypeId());
- this.spawn.setEntityID(start);
- this.spawn.setUniqueId(UUID.randomUUID());
- WrappedChatComponent nick = WrappedChatComponent.fromText(ChatColor.translateAlternateColorCodes('&', name));
- List<WrappedWatchableObject> obj = Util.asList(
- new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject(14, WrappedDataWatcher.Registry.get(Byte.class)), (byte)0x01),
- //new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20),
- new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject(3, WrappedDataWatcher.Registry.get(Boolean.class)), true),
- new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.get(String.class)), name));
- this.meta = new WrapperPlayServerEntityMetadata();
- this.meta.setEntityID(start);
- this.meta.setMetadata(obj);
- List<Integer> list = new ArrayList<>();
- list.add(start);
- this.destroy.setEntityIds(list.stream().mapToInt(i->i).toArray());
- this.name = name;
- start++;
- }
- public void setName(String name) {
- this.name = name;
- this.meta.getMetadata().get(2).setValue(name);
- }
- public void setLocation(Location loc) {
- this.spawn.setX(loc.getX());
- this.spawn.setY(loc.getY());
- this.spawn.setZ(loc.getZ());
- }
- public void sendSpawnPacket(Player player) {
- this.spawn.sendPacket(player);
- String temp = this.name;
- if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
- temp = PlaceholderAPI.setPlaceholders(player, this.name);
- WrappedChatComponent nick = WrappedChatComponent
- .fromText(ChatColor.translateAlternateColorCodes('&', temp));
- this.meta.getMetadata().get(1).setValue(Optional.of(nick.getHandle()));
- }
- this.meta.sendPacket(player);
- }
- public void sendDestroyPacket(Player player) {
- this.destroy.sendPacket(player);
- }
Advertisement
Add Comment
Please, Sign In to add comment