diff --git a/nms/pom.xml b/nms/pom.xml
index 7fbfb9c9..ba9d242e 100644
--- a/nms/pom.xml
+++ b/nms/pom.xml
@@ -16,6 +16,7 @@
v1_17_R1
v1_18_R1
v1_18_R2
+ v1_19_R1
diff --git a/nms/v1_18_R1/pom.xml b/nms/v1_18_R1/pom.xml
index 9e5e20f1..244de1ff 100644
--- a/nms/v1_18_R1/pom.xml
+++ b/nms/v1_18_R1/pom.xml
@@ -44,6 +44,13 @@
com.comphenix.protocol
ProtocolLib
+
+
+ com.mojang
+ authlib
+ 3.5.41
+ provided
+
diff --git a/nms/v1_18_R2/pom.xml b/nms/v1_18_R2/pom.xml
index 61289701..64ffd3d9 100644
--- a/nms/v1_18_R2/pom.xml
+++ b/nms/v1_18_R2/pom.xml
@@ -48,19 +48,7 @@
com.mojang
authlib
- 3.3.39
- provided
-
-
- it.unimi.dsi
- fastutil
- 8.5.6
- provided
-
-
- com.mojang
- datafixerupper
- 4.1.27
+ 3.5.41
provided
diff --git a/nms/v1_19_R1/pom.xml b/nms/v1_19_R1/pom.xml
new file mode 100644
index 00000000..e857616d
--- /dev/null
+++ b/nms/v1_19_R1/pom.xml
@@ -0,0 +1,95 @@
+
+
+
+ nms
+ LibsDisguises
+ 1.0-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ v1_19_R1
+ 1.0-SNAPSHOT
+
+
+ 1.8
+ 1.8
+ UTF-8
+
+ 1.19-R0.1-SNAPSHOT
+
+
+
+
+ org.spigotmc
+ spigot
+ ${spigot.version}
+ remapped-mojang
+ provided
+
+
+ org.spigotmc
+ spigot-api
+ ${spigot.version}
+ provided
+
+
+ LibsDisguises
+ shared
+ 1.0-SNAPSHOT
+
+
+ com.comphenix.protocol
+ ProtocolLib
+
+
+
+ com.mojang
+ authlib
+ 3.5.41
+ provided
+
+
+
+
+
+
+ net.md-5
+ specialsource-maven-plugin
+ 1.2.4
+
+
+ package
+
+ remap
+
+ remap-obf
+
+ org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang
+ true
+ org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang
+ remapped-mojang
+ true
+
+
+
+ package
+
+ remap
+
+ remap-spigot
+
+ target/${project.build.finalName}-remapped-mojang.jar
+ org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot
+ org.spigotmc:spigot:${spigot.version}:jar:remapped-obf
+ remapped-spigot
+ true
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nms/v1_19_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19/ReflectionManager.java b/nms/v1_19_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19/ReflectionManager.java
new file mode 100644
index 00000000..5686ff6b
--- /dev/null
+++ b/nms/v1_19_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19/ReflectionManager.java
@@ -0,0 +1,599 @@
+package me.libraryaddict.disguise.utilities.reflection.v1_19;
+
+import com.comphenix.protocol.wrappers.BlockPosition;
+import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
+import com.comphenix.protocol.wrappers.Vector3F;
+import com.comphenix.protocol.wrappers.WrappedBlockData;
+import com.comphenix.protocol.wrappers.WrappedChatComponent;
+import com.comphenix.protocol.wrappers.WrappedDataWatcher;
+import com.comphenix.protocol.wrappers.WrappedGameProfile;
+import com.mojang.authlib.Agent;
+import com.mojang.authlib.GameProfile;
+import com.mojang.authlib.ProfileLookupCallback;
+import com.mojang.authlib.minecraft.MinecraftSessionService;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
+import net.minecraft.core.BlockPos;
+import net.minecraft.core.Registry;
+import net.minecraft.core.Vector3f;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
+import net.minecraft.network.syncher.EntityDataAccessor;
+import net.minecraft.network.syncher.SynchedEntityData;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.dedicated.DedicatedServer;
+import net.minecraft.server.level.ChunkMap;
+import net.minecraft.server.level.ServerChunkCache;
+import net.minecraft.server.level.ServerEntity;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.server.network.ServerGamePacketListenerImpl;
+import net.minecraft.server.network.ServerPlayerConnection;
+import net.minecraft.sounds.SoundEvent;
+import net.minecraft.sounds.SoundSource;
+import net.minecraft.world.damagesource.DamageSource;
+import net.minecraft.world.effect.MobEffect;
+import net.minecraft.world.effect.MobEffectInstance;
+import net.minecraft.world.entity.EntityDimensions;
+import net.minecraft.world.entity.animal.CatVariant;
+import net.minecraft.world.entity.animal.FrogVariant;
+import net.minecraft.world.entity.decoration.PaintingVariant;
+import net.minecraft.world.entity.decoration.PaintingVariants;
+import net.minecraft.world.entity.npc.VillagerData;
+import net.minecraft.world.entity.npc.VillagerProfession;
+import net.minecraft.world.entity.npc.VillagerType;
+import net.minecraft.world.level.GameType;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.phys.AABB;
+import net.minecraft.world.phys.Vec3;
+import org.bukkit.Art;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.NamespacedKey;
+import org.bukkit.Sound;
+import org.bukkit.World;
+import org.bukkit.block.data.BlockData;
+import org.bukkit.craftbukkit.v1_19_R1.CraftArt;
+import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
+import org.bukkit.craftbukkit.v1_19_R1.CraftSound;
+import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
+import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData;
+import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity;
+import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
+import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.v1_19_R1.util.CraftMagicNumbers;
+import org.bukkit.craftbukkit.v1_19_R1.util.CraftNamespacedKey;
+import org.bukkit.entity.Cat;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Frog;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.Villager;
+import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.util.EulerAngle;
+import org.bukkit.util.Vector;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class ReflectionManager implements ReflectionManagerAbstract {
+ public boolean hasInvul(Entity entity) {
+ net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
+
+ if (nmsEntity instanceof net.minecraft.world.entity.LivingEntity) {
+ return nmsEntity.invulnerableTime > 0;
+ } else {
+ return nmsEntity.isInvulnerableTo(DamageSource.GENERIC);
+ }
+ }
+
+ public int getIncrementedStateId(Player player) {
+ ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
+ return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
+ }
+
+ public int getNewEntityId() {
+ return getNewEntityId(true);
+ }
+
+ public int getNewEntityId(boolean increment) {
+ try {
+ Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("c");
+ entityCounter.setAccessible(true);
+ AtomicInteger atomicInteger = (AtomicInteger) entityCounter.get(null);
+ if (increment) {
+ return atomicInteger.incrementAndGet();
+ } else {
+ return atomicInteger.get();
+ }
+ } catch (ReflectiveOperationException e) {
+ e.printStackTrace();
+ }
+
+ return -1;
+ }
+
+ public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
+ return ((CraftPlayer) player).getHandle().connection;
+ }
+
+ public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
+ Optional> optional = net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
+ if (optional.isPresent()) {
+ net.minecraft.world.entity.EntityType> entityType = optional.get();
+ ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
+ net.minecraft.world.entity.Entity entity;
+ if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
+ WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
+ entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle(), null);
+ }/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
+ entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
+ } else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
+ entity = new FishingHook((net.minecraft.world.entity.player.Player) createEntityInstance("player"), world, 0, 0);
+ }*/ else {
+ entity = entityType.create(world);
+ }
+
+ // Workaround for paper being 2 smart 4 me
+ entity.setPos(1.0, 1.0, 1.0);
+ entity.setPos(0.0, 0.0, 0.0);
+ return entity;
+ }
+
+ return null;
+ }
+
+ public MobEffect getMobEffectList(int id) {
+ return MobEffect.byId(id);
+ }
+
+ public MobEffectInstance createMobEffect(PotionEffect effect) {
+ return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles());
+ }
+
+ public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
+ return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
+ }
+
+ public AABB getBoundingBox(Entity entity) {
+ return ((CraftEntity) entity).getHandle().getBoundingBox();
+ }
+
+ public double getXBoundingBox(Entity entity) {
+ return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
+ }
+
+ public double getYBoundingBox(Entity entity) {
+ return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
+ }
+
+ public double getZBoundingBox(Entity entity) {
+ return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
+ }
+
+ public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
+ return ((ServerPlayerConnection) nmsEntity).getPlayer();
+ }
+
+ public Entity getBukkitEntity(Object nmsEntity) {
+ return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
+ }
+
+ public ItemStack getBukkitItem(Object nmsItem) {
+ return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
+ }
+
+ public ItemStack getCraftItem(ItemStack bukkitItem) {
+ return CraftItemStack.asCraftCopy(bukkitItem);
+ }
+
+ public SoundEvent getCraftSound(Sound sound) {
+ return CraftSound.getSoundEffect(sound);
+ }
+
+ public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
+ ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
+ ServerChunkCache chunkSource = world.getChunkSource();
+ ChunkMap chunkMap = chunkSource.chunkMap;
+ Int2ObjectMap entityMap = chunkMap.entityMap;
+ ChunkMap.TrackedEntity trackedEntity = entityMap.get(target.getEntityId());
+ if (trackedEntity == null) {
+ return null;
+ }
+
+ Field field = ChunkMap.TrackedEntity.class.getDeclaredField("b");
+ field.setAccessible(true);
+
+ return (ServerEntity) field.get(trackedEntity);
+ }
+
+ public DedicatedServer getMinecraftServer() {
+ return ((CraftServer) Bukkit.getServer()).getServer();
+ }
+
+ public String getEnumArt(Art art) {
+ return Registry.PAINTING_VARIANT.getKey(CraftArt.BukkitToNotch(art).value()).getPath();
+ }
+
+ public BlockPos getBlockPosition(int x, int y, int z) {
+ return new BlockPos(x, y, z);
+ }
+
+ public net.minecraft.core.Direction getEnumDirection(int direction) {
+ return net.minecraft.core.Direction.from2DDataValue(direction);
+ }
+
+ public ClientboundPlayerInfoPacket.Action getEnumPlayerInfoAction(int action) {
+ return ClientboundPlayerInfoPacket.Action.values()[action];
+ }
+
+ public ClientboundPlayerInfoPacket.PlayerUpdate getPlayerInfoData(WrappedGameProfile gameProfile) {
+ return new ClientboundPlayerInfoPacket.PlayerUpdate((GameProfile) gameProfile.getHandle(), 0, GameType.SURVIVAL,
+ Component.literal(gameProfile.getName()), null);
+ }
+
+ public Object getNmsEntity(Entity entity) {
+ return ((CraftEntity) entity).getHandle();
+ }
+
+ public double getPing(Player player) {
+ return player.getPing();
+ }
+
+ public float[] getSize(Entity entity) {
+ net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
+ EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
+ return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
+ }
+
+ public WrappedGameProfile getSkullBlob(WrappedGameProfile gameProfile) {
+ DedicatedServer minecraftServer = getMinecraftServer();
+ MinecraftSessionService sessionService = minecraftServer.getSessionService();
+ return WrappedGameProfile.fromHandle(sessionService.fillProfileProperties((GameProfile) gameProfile.getHandle(), true));
+ }
+
+ public Float getSoundModifier(Object entity) {
+ if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
+ return 0.0f;
+ } else {
+ try {
+ Method method = net.minecraft.world.entity.LivingEntity.class.getDeclaredMethod("eu");
+ method.setAccessible(true);
+
+ return (Float) method.invoke(entity);
+ } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ return 0f;
+ }
+
+ public void injectCallback(String playername, ProfileLookupCallback callback) {
+ Agent agent = Agent.MINECRAFT;
+ getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
+ }
+
+ public void setBoundingBox(Entity entity, double x, double y, double z) {
+ Location loc = entity.getLocation();
+ ((CraftEntity) entity).getHandle()
+ .setBoundingBox(new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, loc.getZ() + z / 2));
+ }
+
+ public Enum getSoundCategory(String category) {
+ return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
+ }
+
+ /**
+ * Creates the NMS object EnumItemSlot from an EquipmentSlot.
+ *
+ * @param slot
+ * @return null if the equipment slot is null
+ */
+ public Enum createEnumItemSlot(EquipmentSlot slot) {
+ switch (slot) {
+ case HAND:
+ return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
+ case OFF_HAND:
+ return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
+ case FEET:
+ return net.minecraft.world.entity.EquipmentSlot.FEET;
+ case LEGS:
+ return net.minecraft.world.entity.EquipmentSlot.LEGS;
+ case CHEST:
+ return net.minecraft.world.entity.EquipmentSlot.CHEST;
+ case HEAD:
+ return net.minecraft.world.entity.EquipmentSlot.HEAD;
+ default:
+ return null;
+ }
+ }
+
+ public Object getSoundString(Sound sound) {
+ return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
+ }
+
+ public Optional> convertOptional(Object val) {
+ if (val instanceof BlockPosition) {
+ BlockPosition pos = (BlockPosition) val;
+ return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
+ } else if (val instanceof WrappedBlockData) {
+ Object obj = ((WrappedBlockData) val).getHandle();
+ return Optional.of(obj);
+ } else if (val instanceof ItemStack) {
+ Object obj = getNmsItem((ItemStack) val);
+ return Optional.of(obj);
+ } else if (val instanceof WrappedChatComponent) {
+ Object obj = ((WrappedChatComponent) val).getHandle();
+ return Optional.of(obj);
+ }
+
+ return Optional.of(val);
+ }
+
+ public Vector3f convertVec3(Object object) {
+ if (object instanceof Vector3F) {
+ Vector3F vector3F = (Vector3F) object;
+ return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
+ } else if (object instanceof EulerAngle) {
+ EulerAngle eulerAngle = (EulerAngle) object;
+ return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
+ }
+
+ return null;
+ }
+
+ public net.minecraft.core.Direction convertDirection(Direction direction) {
+ return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
+ }
+
+ public Material getMaterial(String name) {
+ return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
+ }
+
+ public String getItemName(Material material) {
+ return Registry.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
+ }
+
+ public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
+ return CraftItemStack.asNMSCopy(itemStack);
+ }
+
+ public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession) {
+ VillagerType nmsVillagerType = Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
+ VillagerProfession nmsVillagerProfession = Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
+
+ return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, 1);
+ }
+
+ public VillagerType getVillagerType(Villager.Type type) {
+ return Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
+ }
+
+ public VillagerProfession getVillagerProfession(Villager.Profession profession) {
+ return Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
+ }
+
+ public SynchedEntityData.DataItem createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject, T metaItem) {
+ return new SynchedEntityData.DataItem<>((EntityDataAccessor) wrappedDataWatcherObject.getHandle(), metaItem);
+ }
+
+ @Deprecated
+ public SoundEvent createSoundEffect(String minecraftKey) {
+ return new SoundEvent(new ResourceLocation(minecraftKey));
+ }
+
+ @Override
+ public ResourceLocation createMinecraftKey(String name) {
+ return new ResourceLocation(name);
+ }
+
+ public Vec3 getVec3D(Vector vector) {
+ return new Vec3(vector.getX(), vector.getY(), vector.getZ());
+ }
+
+ public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
+ return net.minecraft.world.entity.EntityType.byString(
+ entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
+ }
+
+ public Object registerEntityType(NamespacedKey key) {
+ net.minecraft.world.entity.EntityType newEntity =
+ new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0);
+ Registry.register(Registry.ENTITY_TYPE, CraftNamespacedKey.toMinecraft(key), newEntity);
+ newEntity.getDescriptionId();
+ return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
+ }
+
+ public int getEntityTypeId(Object entityTypes) {
+ net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
+ return Registry.ENTITY_TYPE.getId(entityType);
+ }
+
+ public int getEntityTypeId(EntityType entityType) {
+ return getEntityTypeId(getEntityType(entityType));
+ }
+
+ public Object getEntityType(NamespacedKey name) {
+ return Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
+ }
+
+ public Object getNmsEntityPose(String enumPose) {
+ return net.minecraft.world.entity.Pose.valueOf(enumPose);
+ }
+
+ public int getCombinedIdByBlockData(BlockData data) {
+ BlockState state = ((CraftBlockData) data).getState();
+ return Block.getId(state);
+ }
+
+ public int getCombinedIdByItemStack(ItemStack itemStack) {
+ Block block = CraftMagicNumbers.getBlock(itemStack.getType());
+ return Block.getId(block.defaultBlockState());
+ }
+
+ public BlockData getBlockDataByCombinedId(int id) {
+ return CraftBlockData.fromData(Block.stateById(id));
+ }
+
+ public ItemStack getItemStackByCombinedId(int id) {
+ return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
+ }
+
+ public ServerLevel getWorldServer(World w) {
+ return ((CraftWorld) w).getHandle();
+ }
+
+ public ItemMeta getDeserializedItemMeta(Map meta) {
+ try {
+ Class> aClass = Class.forName("org.bukkit.craftbukkit.v1_19_R1.inventory.CraftMetaItem$SerializableMeta");
+ Method deserialize = aClass.getDeclaredMethod("deserialize", Map.class);
+ Object itemMeta = deserialize.invoke(null, meta);
+
+ return (ItemMeta) itemMeta;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ @Override
+ public Object convertInvalidMeta(Object value) {
+ if (value instanceof Frog.Variant) {
+ return getFrogVariant((Frog.Variant) value);
+ }
+
+ if (value instanceof Cat.Type) {
+ return getCatVariant((Cat.Type) value);
+ }
+
+ if (value instanceof Art) {
+ return Registry.PAINTING_VARIANT.getHolderOrThrow(getArtVariant((Art) value));
+ }
+
+ return value;
+ }
+
+ private FrogVariant getFrogVariant(Frog.Variant variant) {
+ switch (variant) {
+ case COLD:
+ return FrogVariant.COLD;
+ case WARM:
+ return FrogVariant.WARM;
+ case TEMPERATE:
+ return FrogVariant.TEMPERATE;
+ }
+
+ return null;
+ }
+
+ private CatVariant getCatVariant(Cat.Type type) {
+ switch (type) {
+ case TABBY:
+ return CatVariant.TABBY;
+ case BLACK:
+ return CatVariant.BLACK;
+ case RED:
+ return CatVariant.RED;
+ case SIAMESE:
+ return CatVariant.SIAMESE;
+ case BRITISH_SHORTHAIR:
+ return CatVariant.BRITISH_SHORTHAIR;
+ case CALICO:
+ return CatVariant.CALICO;
+ case PERSIAN:
+ return CatVariant.PERSIAN;
+ case RAGDOLL:
+ return CatVariant.RAGDOLL;
+ case WHITE:
+ return CatVariant.WHITE;
+ case JELLIE:
+ return CatVariant.JELLIE;
+ case ALL_BLACK:
+ return CatVariant.ALL_BLACK;
+ }
+
+ return null;
+ }
+
+ private ResourceKey getArtVariant(Art art) {
+ switch (art) {
+ case KEBAB:
+ return PaintingVariants.KEBAB;
+ case AZTEC:
+ return PaintingVariants.AZTEC;
+ case ALBAN:
+ return PaintingVariants.ALBAN;
+ case AZTEC2:
+ return PaintingVariants.AZTEC2;
+ case BOMB:
+ return PaintingVariants.BOMB;
+ case PLANT:
+ return PaintingVariants.PLANT;
+ case WASTELAND:
+ return PaintingVariants.WASTELAND;
+ case POOL:
+ return PaintingVariants.POOL;
+ case COURBET:
+ return PaintingVariants.COURBET;
+ case SEA:
+ return PaintingVariants.SEA;
+ case SUNSET:
+ return PaintingVariants.SUNSET;
+ case CREEBET:
+ return PaintingVariants.CREEBET;
+ case WANDERER:
+ return PaintingVariants.WANDERER;
+ case GRAHAM:
+ return PaintingVariants.GRAHAM;
+ case MATCH:
+ return PaintingVariants.MATCH;
+ case BUST:
+ return PaintingVariants.BUST;
+ case STAGE:
+ return PaintingVariants.STAGE;
+ case VOID:
+ return PaintingVariants.VOID;
+ case SKULL_AND_ROSES:
+ return PaintingVariants.SKULL_AND_ROSES;
+ case WITHER:
+ return PaintingVariants.WITHER;
+ case FIGHTERS:
+ return PaintingVariants.FIGHTERS;
+ case POINTER:
+ return PaintingVariants.POINTER;
+ case PIGSCENE:
+ return PaintingVariants.PIGSCENE;
+ case BURNING_SKULL:
+ return PaintingVariants.BURNING_SKULL;
+ case SKELETON:
+ return PaintingVariants.SKELETON;
+ case DONKEY_KONG:
+ return PaintingVariants.DONKEY_KONG;
+ case EARTH:
+ return PaintingVariants.EARTH;
+ case WIND:
+ return PaintingVariants.WIND;
+ case WATER:
+ return PaintingVariants.WATER;
+ case FIRE:
+ return PaintingVariants.FIRE;
+ }
+
+ return null;
+ }
+}
diff --git a/plugin/pom.xml b/plugin/pom.xml
index 45700261..fd22625f 100644
--- a/plugin/pom.xml
+++ b/plugin/pom.xml
@@ -210,6 +210,14 @@
compile
true
+
+ LibsDisguises
+ v1_19_R1
+ 1.0-SNAPSHOT
+ remapped-spigot
+ compile
+ true
+
\ No newline at end of file
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java
index a923d4ea..318b5eaa 100644
--- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java
+++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java
@@ -1,8 +1,8 @@
package me.libraryaddict.disguise.disguisetypes;
+import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
-import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import me.libraryaddict.disguise.utilities.translations.TranslateType;
import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Entity;
@@ -11,6 +11,8 @@ import org.bukkit.entity.EntityType;
import java.util.Locale;
public enum DisguiseType {
+ @NmsAddedIn(NmsVersion.v1_19) ALLAY,
+
AREA_EFFECT_CLOUD(3, 0),
ARMOR_STAND(78),
@@ -33,6 +35,8 @@ public enum DisguiseType {
CHICKEN,
+ @NmsAddedIn(NmsVersion.v1_19) CHEST_BOAT,
+
COD,
COW,
@@ -79,6 +83,8 @@ public enum DisguiseType {
FISHING_HOOK(90),
+ @NmsAddedIn(NmsVersion.v1_19) FROG,
+
@NmsAddedIn(NmsVersion.v1_14) FOX,
GHAST,
@@ -203,6 +209,8 @@ public enum DisguiseType {
@NmsAddedIn(NmsVersion.v1_16) STRIDER,
+ @NmsAddedIn(NmsVersion.v1_19) TADPOLE,
+
THROWN_EXP_BOTTLE(75),
@NmsRemovedIn(NmsVersion.v1_14) TIPPED_ARROW(60),
@@ -225,6 +233,8 @@ public enum DisguiseType {
@NmsAddedIn(NmsVersion.v1_14) WANDERING_TRADER,
+ @NmsAddedIn(NmsVersion.v1_19) WARDEN,
+
WITCH,
WITHER,
@@ -265,6 +275,7 @@ public enum DisguiseType {
private EntityType entityType;
+ private Object nmsType;
private int objectId = -1, defaultData = 0;
private int typeId;
@@ -299,6 +310,10 @@ public enum DisguiseType {
}
}
+ public Object getNmsEntityType() {
+ return this.nmsType;
+ }
+
public int getDefaultData() {
return defaultData;
}
@@ -337,7 +352,8 @@ public enum DisguiseType {
return typeId;
}
- public void setTypeId(int typeId) {
+ public void setTypeId(Object nmsType, int typeId) {
+ this.nmsType = nmsType;
this.typeId = typeId;
}
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java
index 58854f23..83febcfb 100644
--- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java
+++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java
@@ -37,6 +37,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.FireworkWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.FishWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.FishingHookWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.FoxWatcher;
+import me.libraryaddict.disguise.disguisetypes.watchers.FrogWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.GhastWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.GlowSquidWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.GoatWatcher;
@@ -55,6 +56,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.MinecartFurnaceWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.MushroomCowWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.OcelotWatcher;
+import me.libraryaddict.disguise.disguisetypes.watchers.PaintingWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.PandaWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.ParrotWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.PhantomWatcher;
@@ -84,6 +86,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.TropicalFishWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.TurtleWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.VexWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.VillagerWatcher;
+import me.libraryaddict.disguise.disguisetypes.watchers.WardenWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.WitchWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.WitherSkullWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.WitherWatcher;
@@ -97,9 +100,12 @@ import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
+import org.bukkit.Art;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Particle;
+import org.bukkit.entity.Cat;
+import org.bukkit.entity.Frog;
import org.bukkit.entity.Villager;
import org.bukkit.inventory.ItemStack;
@@ -250,8 +256,12 @@ public class MetaIndex {
public static MetaIndex BOAT_SHAKE = new MetaIndex<>(BoatWatcher.class, 6, 0);
@NmsAddedIn(NmsVersion.v1_14)
+ @NmsRemovedIn(NmsVersion.v1_19)
public static MetaIndex CAT_TYPE = new MetaIndex<>(CatWatcher.class, 0, 0);
+ @NmsAddedIn(NmsVersion.v1_19)
+ public static MetaIndex CAT_TYPE_NEW = new MetaIndex<>(CatWatcher.class, 0, Cat.Type.BLACK);
+
@NmsAddedIn(NmsVersion.v1_14)
public static MetaIndex CAT_LYING_DOWN = new MetaIndex<>(CatWatcher.class, 1, false);
@@ -402,6 +412,11 @@ public class MetaIndex {
@NmsAddedIn(NmsVersion.v1_14)
public static MetaIndex> FOX_TRUSTED_2 = new MetaIndex<>(FoxWatcher.class, 3, Optional.empty());
+ @NmsAddedIn(NmsVersion.v1_19)
+ public static MetaIndex FROG_VARIANT = new MetaIndex<>(FrogWatcher.class, 0, Frog.Variant.TEMPERATE);
+
+ @NmsAddedIn(NmsVersion.v1_19)
+ public static MetaIndex FROG_TONGUE_TARGET = new MetaIndex<>(FrogWatcher.class, 1, OptionalInt.empty());
/**
* Changes the face of the ghast
*/
@@ -413,6 +428,12 @@ public class MetaIndex {
@NmsAddedIn(NmsVersion.v1_17)
public static MetaIndex GOAT_SCREAMING = new MetaIndex<>(GoatWatcher.class, 0, false);
+ @NmsAddedIn(NmsVersion.v1_19)
+ public static MetaIndex GOAT_HAS_LEFT_HORN = new MetaIndex<>(GoatWatcher.class, 1, true);
+
+ @NmsAddedIn(NmsVersion.v1_19)
+ public static MetaIndex GOAT_HAS_RIGHT_HORN = new MetaIndex<>(GoatWatcher.class, 2, true);
+
/**
* Switch between the guardian spikes enabled/disabled
*/
@@ -560,6 +581,9 @@ public class MetaIndex {
@NmsAddedIn(NmsVersion.v1_14)
public static MetaIndex OCELOT_TRUST = new MetaIndex<>(OcelotWatcher.class, 0, false);
+ @NmsAddedIn(NmsVersion.v1_19)
+ public static MetaIndex PAINTING = new MetaIndex<>(PaintingWatcher.class, 0, Art.KEBAB);
+
@NmsAddedIn(NmsVersion.v1_14)
public static MetaIndex PANDA_HEAD_SHAKING = new MetaIndex<>(PandaWatcher.class, 0, 0);
@@ -701,6 +725,8 @@ public class MetaIndex {
public static MetaIndex VILLAGER_DATA =
new MetaIndex<>(VillagerWatcher.class, 0, NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
+ public static MetaIndex WARDEN_ANGER = new MetaIndex<>(WardenWatcher.class, 0, 0);
+
public static MetaIndex WITCH_AGGRESSIVE = new MetaIndex<>(WitchWatcher.class, 0, false);
public static MetaIndex WITHER_INVUL = new MetaIndex<>(WitherWatcher.class, 3, 0);
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java
index 4dfe7e1a..8f4340f3 100644
--- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java
+++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java
@@ -5,6 +5,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.PaintingWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.SplashPotionWatcher;
import me.libraryaddict.disguise.utilities.DisguiseValues;
+import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.Art;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
@@ -134,7 +135,11 @@ public class MiscDisguise extends TargetedDisguise {
case FALLING_BLOCK:
return ((FallingBlockWatcher) getWatcher()).getBlock().getDurability();
case PAINTING:
- return ((PaintingWatcher) getWatcher()).getArt().getId();
+ if (!NmsVersion.v1_19.isSupported()) {
+ return ((PaintingWatcher) getWatcher()).getArt().getId();
+ }
+
+ return data;
case SPLASH_POTION:
return ((SplashPotionWatcher) getWatcher()).getPotionId();
default:
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java
index a2a59af9..c06243f6 100644
--- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java
+++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java
@@ -26,13 +26,23 @@ public class CatWatcher extends TameableWatcher {
}
public Cat.Type getType() {
- return Cat.Type.values()[getData(MetaIndex.CAT_TYPE)];
+ if (!NmsVersion.v1_19.isSupported()) {
+ return Cat.Type.values()[getData(MetaIndex.CAT_TYPE)];
+ }
+
+ return getData(MetaIndex.CAT_TYPE_NEW);
}
@RandomDefaultValue
public void setType(Cat.Type type) {
- setData(MetaIndex.CAT_TYPE, type.ordinal());
- sendData(MetaIndex.CAT_TYPE);
+ if (NmsVersion.v1_19.isSupported()) {
+ setData(MetaIndex.CAT_TYPE_NEW, type);
+ sendData(MetaIndex.CAT_TYPE_NEW);
+ } else {
+ setData(MetaIndex.CAT_TYPE, type.ordinal());
+ sendData(MetaIndex.CAT_TYPE);
+ }
+
}
public DyeColor getCollarColor() {
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ChestBoatWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ChestBoatWatcher.java
new file mode 100644
index 00000000..4816c8f2
--- /dev/null
+++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ChestBoatWatcher.java
@@ -0,0 +1,9 @@
+package me.libraryaddict.disguise.disguisetypes.watchers;
+
+import me.libraryaddict.disguise.disguisetypes.Disguise;
+
+public class ChestBoatWatcher extends BoatWatcher {
+ public ChestBoatWatcher(Disguise disguise) {
+ super(disguise);
+ }
+}
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FrogWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FrogWatcher.java
new file mode 100644
index 00000000..bccf2743
--- /dev/null
+++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FrogWatcher.java
@@ -0,0 +1,30 @@
+package me.libraryaddict.disguise.disguisetypes.watchers;
+
+import me.libraryaddict.disguise.DisguiseConfig;
+import me.libraryaddict.disguise.disguisetypes.Disguise;
+import me.libraryaddict.disguise.disguisetypes.MetaIndex;
+import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
+import org.bukkit.entity.Cat;
+import org.bukkit.entity.Frog;
+
+import java.util.Random;
+
+public class FrogWatcher extends AgeableWatcher {
+ public FrogWatcher(Disguise disguise) {
+ super(disguise);
+
+ if (DisguiseConfig.isRandomDisguises()) {
+ setVariant(Frog.Variant.values()[new Random().nextInt(Frog.Variant.values().length)]);
+ }
+ }
+
+ @RandomDefaultValue
+ public void setVariant(Frog.Variant variant) {
+ setData(MetaIndex.FROG_VARIANT, variant);
+ sendData(MetaIndex.FROG_VARIANT);
+ }
+
+ public Frog.Variant getVariant() {
+ return getData(MetaIndex.FROG_VARIANT);
+ }
+}
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GoatWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GoatWatcher.java
index 35844440..16acbf81 100644
--- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GoatWatcher.java
+++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/GoatWatcher.java
@@ -2,6 +2,8 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
+import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
+import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
/**
* Created by libraryaddict on 15/06/2021.
@@ -19,4 +21,24 @@ public class GoatWatcher extends AgeableWatcher {
setData(MetaIndex.GOAT_SCREAMING, screaming);
sendData(MetaIndex.GOAT_SCREAMING);
}
+
+ public boolean hasLeftHorn() {
+ return getData(MetaIndex.GOAT_HAS_LEFT_HORN);
+ }
+
+ @NmsAddedIn(NmsVersion.v1_19)
+ public void setHasLeftHorn(boolean hasHorn) {
+ setData(MetaIndex.GOAT_HAS_LEFT_HORN, hasHorn);
+ sendData(MetaIndex.GOAT_HAS_LEFT_HORN);
+ }
+
+ public boolean hasRightHorn() {
+ return getData(MetaIndex.GOAT_HAS_RIGHT_HORN);
+ }
+
+ @NmsAddedIn(NmsVersion.v1_19)
+ public void setHasRightHorn(boolean hasHorn) {
+ setData(MetaIndex.GOAT_HAS_RIGHT_HORN, hasHorn);
+ sendData(MetaIndex.GOAT_HAS_RIGHT_HORN);
+ }
}
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java
index a7ca25f0..c886489a 100644
--- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java
+++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java
@@ -2,11 +2,12 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
+import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
+import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.Art;
public class PaintingWatcher extends FlagWatcher {
-
private Art painting;
public PaintingWatcher(Disguise disguise) {
@@ -22,14 +23,23 @@ public class PaintingWatcher extends FlagWatcher {
}
public Art getArt() {
- return painting;
+ if (!NmsVersion.v1_19.isSupported()) {
+ return painting;
+ }
+
+ return getData(MetaIndex.PAINTING);
}
public void setArt(Art newPainting) {
- this.painting = newPainting;
+ if (NmsVersion.v1_19.isSupported()) {
+ setData(MetaIndex.PAINTING, newPainting);
+ sendData(MetaIndex.PAINTING);
+ } else {
+ this.painting = newPainting;
- if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this) {
- DisguiseUtilities.refreshTrackers(getDisguise());
+ if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this) {
+ DisguiseUtilities.refreshTrackers(getDisguise());
+ }
}
}
}
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TadpoleWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TadpoleWatcher.java
new file mode 100644
index 00000000..269804d6
--- /dev/null
+++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TadpoleWatcher.java
@@ -0,0 +1,9 @@
+package me.libraryaddict.disguise.disguisetypes.watchers;
+
+import me.libraryaddict.disguise.disguisetypes.Disguise;
+
+public class TadpoleWatcher extends FishWatcher {
+ public TadpoleWatcher(Disguise disguise) {
+ super(disguise);
+ }
+}
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WardenWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WardenWatcher.java
new file mode 100644
index 00000000..ae580769
--- /dev/null
+++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/WardenWatcher.java
@@ -0,0 +1,19 @@
+package me.libraryaddict.disguise.disguisetypes.watchers;
+
+import me.libraryaddict.disguise.disguisetypes.Disguise;
+import me.libraryaddict.disguise.disguisetypes.MetaIndex;
+
+public class WardenWatcher extends InsentientWatcher {
+ public WardenWatcher(Disguise disguise) {
+ super(disguise);
+ }
+
+ public void setAnger(int anger) {
+ setData(MetaIndex.WARDEN_ANGER, anger);
+ sendData(MetaIndex.WARDEN_ANGER);
+ }
+
+ public int getAnger() {
+ return getData(MetaIndex.WARDEN_ANGER);
+ }
+}
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java
index 9739c64d..824f800e 100644
--- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java
+++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java
@@ -424,7 +424,8 @@ public class DisguiseUtilities {
}
public static void sendInvisibleSlime(Player player, int horseId) {
- PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.SPAWN_ENTITY_LIVING, player).createPacket(player);
+ PacketContainer packet = ProtocolLibrary.getProtocolManager()
+ .createPacketConstructor(NmsVersion.v1_19.isSupported() ? Server.SPAWN_ENTITY : Server.SPAWN_ENTITY_LIVING, player).createPacket(player);
packet.getModifier().write(0, DisguiseAPI.getEntityAttachmentId());
packet.getModifier().write(1, UUID.randomUUID());
@@ -552,7 +553,11 @@ public class DisguiseUtilities {
}
// If you're on 1.18..
- return new String[]{"4.8.0"};
+ if (!NmsVersion.v1_19.isSupported()) {
+ return new String[]{"4.8.0"};
+ }
+
+ return new String[]{"5.0.1", "568"};
}
public static boolean isProtocolLibOutdated() {
@@ -2497,8 +2502,8 @@ public class DisguiseUtilities {
try {
// TODO Store the field
- Field field = ReflectionManager.getNmsClass("EntityTrackerEntry")
- .getDeclaredField(NmsVersion.v1_17.isSupported() ? "r" : NmsVersion.v1_14.isSupported() ? "q" : "isMoving");
+ Field field = ReflectionManager.getNmsClass("EntityTrackerEntry").getDeclaredField(
+ NmsVersion.v1_19.isSupported() ? "p" : NmsVersion.v1_17.isSupported() ? "r" : NmsVersion.v1_14.isSupported() ? "q" : "isMoving");
field.setAccessible(true);
isMoving = field.getBoolean(entityTrackerEntry);
} catch (Exception ex) {
@@ -3057,7 +3062,7 @@ public class DisguiseUtilities {
destroyIds = Arrays.copyOf(destroyIds, destroyIds.length + 1);
destroyIds[destroyIds.length - 1] = standIds[i];
} else {
- PacketContainer packet = new PacketContainer(Server.SPAWN_ENTITY_LIVING);
+ PacketContainer packet = new PacketContainer(NmsVersion.v1_19.isSupported() ? Server.SPAWN_ENTITY : Server.SPAWN_ENTITY_LIVING);
packet.getIntegers().write(0, standIds[i]);
packet.getIntegers().write(1, DisguiseType.ARMOR_STAND.getTypeId());
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsManager.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsManager.java
index 29d8021e..c0212be2 100644
--- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsManager.java
+++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsManager.java
@@ -129,8 +129,11 @@ public class PacketsManager {
packetsToListen.add(Server.NAMED_ENTITY_SPAWN);
packetsToListen.add(Server.SPAWN_ENTITY_EXPERIENCE_ORB);
packetsToListen.add(Server.SPAWN_ENTITY);
- packetsToListen.add(Server.SPAWN_ENTITY_LIVING);
- packetsToListen.add(Server.SPAWN_ENTITY_PAINTING);
+
+ if (!NmsVersion.v1_19.isSupported()) {
+ packetsToListen.add(Server.SPAWN_ENTITY_LIVING);
+ packetsToListen.add(Server.SPAWN_ENTITY_PAINTING);
+ }
}
// Add packets that always need to be enabled to ensure safety
diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java
index 4b428c49..379c7838 100644
--- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java
+++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java
@@ -38,6 +38,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -53,8 +54,16 @@ public class PacketHandlerSpawn implements IPacketHandler {
@Override
public PacketType[] getHandledPackets() {
- return new PacketType[]{PacketType.Play.Server.NAMED_ENTITY_SPAWN, PacketType.Play.Server.SPAWN_ENTITY_LIVING,
- PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB, PacketType.Play.Server.SPAWN_ENTITY, PacketType.Play.Server.SPAWN_ENTITY_PAINTING};
+ PacketType[] packets = new PacketType[]{PacketType.Play.Server.NAMED_ENTITY_SPAWN, PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB,
+ PacketType.Play.Server.SPAWN_ENTITY};
+
+ if (!NmsVersion.v1_19.isSupported()) {
+ packets = Arrays.copyOf(packets, packets.length + 2);
+ packets[packets.length - 2] = PacketType.Play.Server.SPAWN_ENTITY_LIVING;
+ packets[packets.length - 1] = PacketType.Play.Server.SPAWN_ENTITY_PAINTING;
+ }
+
+ return packets;
}
@Override
@@ -109,7 +118,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
mods.write(2, loc.getY() + 0.06);
mods.write(3, loc.getZ());
mods.write(4, 1);
- } else if (disguise.getType() == DisguiseType.PAINTING) {
+ } else if (!NmsVersion.v1_19.isSupported() && disguise.getType() == DisguiseType.PAINTING) {
PacketContainer spawnPainting = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_PAINTING);
packets.addPacket(spawnPainting);
@@ -228,7 +237,8 @@ public class PacketHandlerSpawn implements IPacketHandler {
vec = new Vector();
}
- PacketContainer spawnEntity = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
+ PacketContainer spawnEntity =
+ new PacketContainer(NmsVersion.v1_19.isSupported() ? PacketType.Play.Server.SPAWN_ENTITY : PacketType.Play.Server.SPAWN_ENTITY_LIVING);
packets.addPacket(spawnEntity);
StructureModifier