Add support for 1.19, fixes #658, #657

This commit is contained in:
libraryaddict 2022-06-15 00:29:54 +12:00
parent 4acb185abe
commit c8ab93f1cd
28 changed files with 1063 additions and 67 deletions

View File

@ -16,6 +16,7 @@
<module>v1_17_R1</module>
<module>v1_18_R1</module>
<module>v1_18_R2</module>
<module>v1_19_R1</module>
</modules>
</project>

View File

@ -44,6 +44,13 @@
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>3.5.41</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>

View File

@ -48,19 +48,7 @@
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>3.3.39</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.5.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>datafixerupper</artifactId>
<version>4.1.27</version>
<version>3.5.41</version>
<scope>provided</scope>
</dependency>
</dependencies>

95
nms/v1_19_R1/pom.xml Normal file
View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>nms</artifactId>
<groupId>LibsDisguises</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>v1_19_R1</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spigot.version>1.19-R0.1-SNAPSHOT</spigot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${spigot.version}</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>LibsDisguises</groupId>
<artifactId>shared</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>3.5.41</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang</remappedDependencies>
<remappedClassifierName>remapped-mojang</remappedClassifierName>
<remappedArtifactAttached>true</remappedArtifactAttached>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>target/${project.build.finalName}-remapped-mojang.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-obf</remappedDependencies>
<remappedClassifierName>remapped-spigot</remappedClassifierName>
<remappedArtifactAttached>true</remappedArtifactAttached>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -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<net.minecraft.world.entity.EntityType<?>> 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<ChunkMap.TrackedEntity> 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 <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject, T metaItem) {
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) 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<net.minecraft.world.entity.Entity> 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<String, Object> 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<PaintingVariant> 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;
}
}

View File

@ -210,6 +210,14 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>LibsDisguises</groupId>
<artifactId>v1_19_R1</artifactId>
<version>1.0-SNAPSHOT</version>
<classifier>remapped-spigot</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@ -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;
}

View File

@ -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<Y> {
public static MetaIndex<Integer> BOAT_SHAKE = new MetaIndex<>(BoatWatcher.class, 6, 0);
@NmsAddedIn(NmsVersion.v1_14)
@NmsRemovedIn(NmsVersion.v1_19)
public static MetaIndex<Integer> CAT_TYPE = new MetaIndex<>(CatWatcher.class, 0, 0);
@NmsAddedIn(NmsVersion.v1_19)
public static MetaIndex<Cat.Type> CAT_TYPE_NEW = new MetaIndex<>(CatWatcher.class, 0, Cat.Type.BLACK);
@NmsAddedIn(NmsVersion.v1_14)
public static MetaIndex<Boolean> CAT_LYING_DOWN = new MetaIndex<>(CatWatcher.class, 1, false);
@ -402,6 +412,11 @@ public class MetaIndex<Y> {
@NmsAddedIn(NmsVersion.v1_14)
public static MetaIndex<Optional<UUID>> FOX_TRUSTED_2 = new MetaIndex<>(FoxWatcher.class, 3, Optional.empty());
@NmsAddedIn(NmsVersion.v1_19)
public static MetaIndex<Frog.Variant> FROG_VARIANT = new MetaIndex<>(FrogWatcher.class, 0, Frog.Variant.TEMPERATE);
@NmsAddedIn(NmsVersion.v1_19)
public static MetaIndex<OptionalInt> FROG_TONGUE_TARGET = new MetaIndex<>(FrogWatcher.class, 1, OptionalInt.empty());
/**
* Changes the face of the ghast
*/
@ -413,6 +428,12 @@ public class MetaIndex<Y> {
@NmsAddedIn(NmsVersion.v1_17)
public static MetaIndex<Boolean> GOAT_SCREAMING = new MetaIndex<>(GoatWatcher.class, 0, false);
@NmsAddedIn(NmsVersion.v1_19)
public static MetaIndex<Boolean> GOAT_HAS_LEFT_HORN = new MetaIndex<>(GoatWatcher.class, 1, true);
@NmsAddedIn(NmsVersion.v1_19)
public static MetaIndex<Boolean> GOAT_HAS_RIGHT_HORN = new MetaIndex<>(GoatWatcher.class, 2, true);
/**
* Switch between the guardian spikes enabled/disabled
*/
@ -560,6 +581,9 @@ public class MetaIndex<Y> {
@NmsAddedIn(NmsVersion.v1_14)
public static MetaIndex<Boolean> OCELOT_TRUST = new MetaIndex<>(OcelotWatcher.class, 0, false);
@NmsAddedIn(NmsVersion.v1_19)
public static MetaIndex<Art> PAINTING = new MetaIndex<>(PaintingWatcher.class, 0, Art.KEBAB);
@NmsAddedIn(NmsVersion.v1_14)
public static MetaIndex<Integer> PANDA_HEAD_SHAKING = new MetaIndex<>(PandaWatcher.class, 0, 0);
@ -701,6 +725,8 @@ public class MetaIndex<Y> {
public static MetaIndex<VillagerData> VILLAGER_DATA =
new MetaIndex<>(VillagerWatcher.class, 0, NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
public static MetaIndex<Integer> WARDEN_ANGER = new MetaIndex<>(WardenWatcher.class, 0, 0);
public static MetaIndex<Boolean> WITCH_AGGRESSIVE = new MetaIndex<>(WitchWatcher.class, 0, false);
public static MetaIndex<Integer> WITHER_INVUL = new MetaIndex<>(WitherWatcher.class, 3, 0);

View File

@ -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:

View File

@ -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() {

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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());
}
}
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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());

View File

@ -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

View File

@ -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<Object> mods = spawnEntity.getModifier();
@ -236,10 +246,18 @@ public class PacketHandlerSpawn implements IPacketHandler {
mods.write(0, disguisedEntity.getEntityId());
mods.write(1, disguise.getUUID());
if (!disguise.getType().isCustom()) {
mods.write(2, disguise.getType().getTypeId());
if (NmsVersion.v1_19.isSupported()) {
if (!disguise.getType().isCustom()) {
mods.write(2, disguise.getType().getNmsEntityType());
} else {
mods.write(2, ((ModdedDisguise) disguise).getModdedEntity().getEntityType());
}
} else {
mods.write(2, ((ModdedDisguise) disguise).getModdedEntity().getTypeId());
if (!disguise.getType().isCustom()) {
mods.write(2, disguise.getType().getTypeId());
} else {
mods.write(2, ((ModdedDisguise) disguise).getModdedEntity().getTypeId());
}
}
// region Vector calculations

View File

@ -43,6 +43,7 @@ import org.bukkit.boss.BarStyle;
import org.bukkit.entity.Axolotl;
import org.bukkit.entity.Cat;
import org.bukkit.entity.Fox;
import org.bukkit.entity.Frog;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Llama;
import org.bukkit.entity.MushroomCow;
@ -121,6 +122,10 @@ public class ParamInfoTypes {
if (NmsVersion.v1_17.isSupported()) {
paramInfos.add(new ParamInfoEnum(Axolotl.Variant.class, "Axolotl Variant", "The variant of Axolotl"));
if (NmsVersion.v1_19.isSupported()) {
paramInfos.add(new ParamInfoEnum(Frog.Variant.class, "Frog Variant", "The variant of Frog"));
}
}
} else {
paramInfos.add(new ParamInfoEnum(Ocelot.Type.class, "Ocelot Type", "The type of ocelot"));

View File

@ -105,6 +105,8 @@ public class DisguiseParser {
getName = "hasNectar";
} else if (getName.equals("HasStung")) {
getName = "hasStung";
} else if (getName.matches("^Has((Left)|(Right))Horn$")) {
getName = "has" + getName.substring(3);
} else if (setMethod.getParam().isAssignableFrom(boolean.class)) {
getName = "is" + getName;
} else {

View File

@ -10,7 +10,8 @@ public enum NmsVersion {
v1_15,
v1_16,
v1_17,
v1_18;
v1_18,
v1_19;
/**
* If this nms version isn't newer than the running version

View File

@ -44,6 +44,7 @@ import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
import me.libraryaddict.disguise.utilities.sounds.SoundGroup;
import net.minecraft.world.entity.animal.FrogVariant;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Art;
@ -61,11 +62,13 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Ambient;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Cat;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Damageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fish;
import org.bukkit.entity.Frog;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
@ -1377,6 +1380,18 @@ public class ReflectionManager {
return entityPoseClass;
} else if (NbtWrapper.class.isAssignableFrom(cl)) {
return getNmsClass("NBTTagCompound");
} else if (NmsVersion.v1_19.isSupported()) {
if (Frog.Variant.class.isAssignableFrom(cl)) {
return getNmsClass("FrogVariant");
}
if (Cat.Type.class.isAssignableFrom(cl)) {
return getNmsClass("CatVariant");
}
if (Art.class.isAssignableFrom(cl)) {
return getNmsClass("PaintingVariant");
}
}
return cl;
@ -1489,6 +1504,10 @@ public class ReflectionManager {
return ((WrappedChatComponent) value).getHandle();
}
if (nmsReflection != null) {
return nmsReflection.convertInvalidMeta(value);
}
return value;
}
@ -2142,20 +2161,17 @@ public class ReflectionManager {
if (nmsEntityName == null) {
switch (disguiseType) {
case ALLAY:
case AXOLOTL:
nmsEntityName = "Axolotl";
break;
case GOAT:
nmsEntityName = "Goat";
break;
case CHEST_BOAT:
case FROG:
case GLOW_ITEM_FRAME:
nmsEntityName = "GlowItemFrame";
break;
case GLOW_SQUID:
nmsEntityName = "GlowSquid";
break;
case GOAT:
case MARKER:
nmsEntityName = "Marker";
case TADPOLE:
case WARDEN:
nmsEntityName = disguiseType.toReadable().replace(" ", "");
break;
case DONKEY:
nmsEntityName = "HorseDonkey";
@ -2208,15 +2224,15 @@ public class ReflectionManager {
case STRAY:
nmsEntityName = "SkeletonStray";
break;
case TRADER_LLAMA:
nmsEntityName = "LLamaTrader"; // Interesting capitalization
break;
case TRIDENT:
nmsEntityName = "ThrownTrident";
break;
case WANDERING_TRADER:
nmsEntityName = "VillagerTrader";
break;
case TRADER_LLAMA:
nmsEntityName = "LLamaTrader"; // Interesting capitalization
break;
case ZOMBIFIED_PIGLIN:
nmsEntityName = "PigZombie";
break;
@ -2253,7 +2269,8 @@ public class ReflectionManager {
return;
}
disguiseType.setTypeId(ReflectionManager.getEntityTypeId(disguiseType.getEntityType()));
disguiseType.setTypeId(ReflectionManager.getEntityType(disguiseType.getEntityType()),
ReflectionManager.getEntityTypeId(disguiseType.getEntityType()));
Entity bukkitEntity = ReflectionManager.getBukkitEntity(nmsEntity);

View File

@ -12,6 +12,9 @@ import java.util.HashMap;
* Only living disguises go in here!
*/
public enum DisguiseSoundEnums {
ALLAY(Sound.ENTITY_ALLAY_HURT, null, Sound.ENTITY_ALLAY_DEATH, new Sound[]{Sound.ENTITY_ALLAY_AMBIENT_WITHOUT_ITEM, Sound.ENTITY_ALLAY_AMBIENT_WITH_ITEM},
Sound.ENTITY_ALLAY_ITEM_GIVEN, Sound.ENTITY_ALLAY_ITEM_TAKEN, Sound.ENTITY_ALLAY_ITEM_THROWN),
ARMOR_STAND(Sound.ENTITY_ARMOR_STAND_HIT, null, Sound.ENTITY_ARMOR_STAND_BREAK, Sound.ENTITY_ARMOR_STAND_FALL, Sound.ENTITY_ARMOR_STAND_PLACE),
ARROW(null, null, null, null, Sound.ENTITY_ARROW_HIT, Sound.ENTITY_ARROW_SHOOT),
@ -30,8 +33,12 @@ public enum DisguiseSoundEnums {
BOAT(null, Sound.ENTITY_BOAT_PADDLE_WATER, null, null, Sound.ENTITY_BOAT_PADDLE_LAND),
CAT(Sound.ENTITY_CAT_HURT, null, Sound.ENTITY_CAT_DEATH, Sound.ENTITY_CAT_AMBIENT, Sound.ENTITY_CAT_PURR, Sound.ENTITY_CAT_PURREOW, Sound.ENTITY_CAT_HISS),
CAVE_SPIDER(Sound.ENTITY_SPIDER_HURT, Sound.ENTITY_SPIDER_STEP, Sound.ENTITY_SPIDER_DEATH, Sound.ENTITY_SPIDER_AMBIENT),
CHEST_BOAT(null, Sound.ENTITY_BOAT_PADDLE_WATER, null, null, Sound.ENTITY_BOAT_PADDLE_LAND),
CHICKEN(Sound.ENTITY_CHICKEN_HURT, Sound.ENTITY_CHICKEN_STEP, Sound.ENTITY_CHICKEN_DEATH, Sound.ENTITY_CHICKEN_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL,
Sound.ENTITY_CHICKEN_EGG, Sound.ENTITY_PLAYER_BIG_FALL),
@ -70,6 +77,12 @@ public enum DisguiseSoundEnums {
EVOKER_FANGS(null, null, null, null, Sound.ENTITY_EVOKER_FANGS_ATTACK),
FOX(Sound.ENTITY_FOX_HURT, null, Sound.ENTITY_FOX_DEATH, Sound.ENTITY_FOX_AMBIENT, Sound.ENTITY_FOX_AGGRO, Sound.ENTITY_FOX_BITE,
Sound.ENTITY_FOX_EAT, Sound.ENTITY_FOX_SCREECH, Sound.ENTITY_FOX_SLEEP, Sound.ENTITY_FOX_SPIT, Sound.ENTITY_FOX_SNIFF, Sound.ENTITY_FOX_TELEPORT),
FROG(Sound.ENTITY_FROG_HURT, Sound.ENTITY_FROG_STEP, Sound.ENTITY_FROG_DEATH, Sound.ENTITY_FROG_AMBIENT, Sound.ENTITY_FROG_EAT, Sound.ENTITY_FROG_LAY_SPAWN,
Sound.ENTITY_FROG_LONG_JUMP, Sound.ENTITY_FROG_TONGUE),
GHAST(Sound.ENTITY_GHAST_HURT, null, Sound.ENTITY_GHAST_DEATH, Sound.ENTITY_GHAST_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_GHAST_SHOOT,
Sound.ENTITY_PLAYER_BIG_FALL, Sound.ENTITY_GHAST_SCREAM, Sound.ENTITY_GHAST_WARN),
@ -84,9 +97,11 @@ public enum DisguiseSoundEnums {
Sound.ENTITY_GOAT_SCREAMING_RAM_IMPACT, Sound.ENTITY_GOAT_SCREAMING_PREPARE_RAM, Sound.ENTITY_GOAT_SCREAMING_LONG_JUMP,
Sound.ENTITY_GOAT_SCREAMING_HURT),
GUARDIAN(new Sound[]{Sound.ENTITY_GUARDIAN_HURT, Sound.ENTITY_GUARDIAN_HURT_LAND}, null,
new Sound[]{Sound.ENTITY_GUARDIAN_DEATH, Sound.ENTITY_GUARDIAN_DEATH_LAND},
new Sound[]{Sound.ENTITY_GUARDIAN_AMBIENT, Sound.ENTITY_GUARDIAN_AMBIENT_LAND}, Sound.ENTITY_GUARDIAN_FLOP),
GUARDIAN(new Sound[]{Sound.ENTITY_GUARDIAN_HURT, Sound.ENTITY_GUARDIAN_HURT_LAND}, null, new Sound[]
{Sound.ENTITY_GUARDIAN_DEATH, Sound.ENTITY_GUARDIAN_DEATH_LAND}, new Sound[]
{Sound.ENTITY_GUARDIAN_AMBIENT, Sound.ENTITY_GUARDIAN_AMBIENT_LAND}, Sound.ENTITY_GUARDIAN_FLOP),
HOGLIN(Sound.ENTITY_HOGLIN_HURT, Sound.ENTITY_HOGLIN_STEP, Sound.ENTITY_HOGLIN_DEATH, Sound.ENTITY_HOGLIN_AMBIENT,
Sound.ENTITY_HOGLIN_CONVERTED_TO_ZOMBIFIED, Sound.ENTITY_HOGLIN_ANGRY, Sound.ENTITY_HOGLIN_RETREAT),
@ -108,7 +123,19 @@ public enum DisguiseSoundEnums {
MAGMA_CUBE(Sound.ENTITY_MAGMA_CUBE_HURT, Sound.ENTITY_MAGMA_CUBE_JUMP, new Sound[]{Sound.ENTITY_MAGMA_CUBE_DEATH, Sound.ENTITY_MAGMA_CUBE_DEATH_SMALL},
null, Sound.ENTITY_MAGMA_CUBE_SQUISH, Sound.ENTITY_MAGMA_CUBE_SQUISH_SMALL),
MINECART(null, Sound.ENTITY_MINECART_RIDING, null, null, Sound.ENTITY_MINECART_INSIDE),
MINECART(null, Sound.ENTITY_MINECART_RIDING, null, null, Sound.ENTITY_MINECART_INSIDE, Sound.ENTITY_MINECART_INSIDE_UNDERWATER),
MINECART_CHEST(null, Sound.ENTITY_MINECART_RIDING, null, null, Sound.ENTITY_MINECART_INSIDE, Sound.ENTITY_MINECART_INSIDE_UNDERWATER),
MINECART_COMMAND(null, Sound.ENTITY_MINECART_RIDING, null, null, Sound.ENTITY_MINECART_INSIDE, Sound.ENTITY_MINECART_INSIDE_UNDERWATER),
MINECART_FURNACE(null, Sound.ENTITY_MINECART_RIDING, null, null, Sound.ENTITY_MINECART_INSIDE, Sound.ENTITY_MINECART_INSIDE_UNDERWATER),
MINECART_HOPPER(null, Sound.ENTITY_MINECART_RIDING, null, null, Sound.ENTITY_MINECART_INSIDE, Sound.ENTITY_MINECART_INSIDE_UNDERWATER),
MINECART_MOB_SPAWNER(null, Sound.ENTITY_MINECART_RIDING, null, null, Sound.ENTITY_MINECART_INSIDE, Sound.ENTITY_MINECART_INSIDE_UNDERWATER),
MINECART_TNT(null, Sound.ENTITY_MINECART_RIDING, null, null, Sound.ENTITY_MINECART_INSIDE, Sound.ENTITY_MINECART_INSIDE_UNDERWATER),
MULE(Sound.ENTITY_MULE_HURT, Sound.BLOCK_GRASS_STEP, Sound.ENTITY_MULE_DEATH, Sound.ENTITY_MULE_AMBIENT, Sound.ENTITY_MULE_CHEST),
@ -117,9 +144,17 @@ public enum DisguiseSoundEnums {
OCELOT(Sound.ENTITY_CAT_HURT, Sound.BLOCK_GRASS_STEP, Sound.ENTITY_CAT_DEATH,
new Sound[]{Sound.ENTITY_CAT_AMBIENT, Sound.ENTITY_CAT_PURR, Sound.ENTITY_CAT_PURREOW}, Sound.ENTITY_CAT_HISS),
PARROT(Sound.ENTITY_PARROT_HURT, Sound.ENTITY_PARROT_STEP, Sound.ENTITY_PARROT_DEATH, Sound.ENTITY_PARROT_AMBIENT, Arrays.stream(Sound.values())
.filter(sound -> sound.name().contains("PARROT_IMITATE") || sound == Sound.ENTITY_PARROT_EAT || sound == Sound.ENTITY_PARROT_FLY)
.toArray(Sound[]::new)),
PANDA(Sound.ENTITY_PANDA_HURT, Sound.ENTITY_PANDA_STEP, Sound.ENTITY_PANDA_DEATH,
new Sound[]{Sound.ENTITY_PANDA_AMBIENT, Sound.ENTITY_PANDA_AGGRESSIVE_AMBIENT, Sound.ENTITY_PANDA_WORRIED_AMBIENT}, Sound.ENTITY_PANDA_BITE,
Sound.ENTITY_PANDA_CANT_BREED, Sound.ENTITY_PANDA_EAT, Sound.ENTITY_PANDA_PRE_SNEEZE, Sound.ENTITY_PANDA_SNEEZE),
PARROT(Sound.ENTITY_PARROT_HURT, Sound.ENTITY_PARROT_STEP, Sound.ENTITY_PARROT_DEATH, Sound.ENTITY_PARROT_AMBIENT, Arrays.stream(Sound.values()).
filter(sound -> sound.name().
contains("PARROT_IMITATE") || sound == Sound.ENTITY_PARROT_EAT || sound == Sound.ENTITY_PARROT_FLY).
toArray(Sound[]::new)),
PIG(Sound.ENTITY_PIG_HURT, Sound.ENTITY_PIG_STEP, Sound.ENTITY_PIG_DEATH, Sound.ENTITY_PIG_AMBIENT),
@ -133,8 +168,16 @@ public enum DisguiseSoundEnums {
PILLAGER(Sound.ENTITY_PILLAGER_HURT, Sound.BLOCK_GRASS_STEP, Sound.ENTITY_PILLAGER_DEATH, Sound.ENTITY_PILLAGER_AMBIENT, Sound.ENTITY_PILLAGER_CELEBRATE),
PLAYER(Sound.ENTITY_PLAYER_HURT,
Arrays.stream(Sound.values()).filter(sound -> sound.name().startsWith("BLOCK_") && sound.name().endsWith("_STEP")).toArray(Sound[]::new),
PLAYER(Sound.ENTITY_PLAYER_HURT, Arrays.stream(Sound.values()).
filter(sound -> sound.name().
startsWith("BLOCK_") && sound.name().
endsWith("_STEP")).
toArray(Sound[]::new),
Sound.ENTITY_PLAYER_DEATH, null),
PHANTOM(Sound.ENTITY_PHANTOM_HURT, new Sound[]{Sound.ENTITY_PHANTOM_FLAP, Sound.ENTITY_PHANTOM_SWOOP}, Sound.ENTITY_PHANTOM_DEATH,
@ -163,12 +206,17 @@ public enum DisguiseSoundEnums {
SKELETON(Sound.ENTITY_SKELETON_HURT, Sound.ENTITY_SKELETON_STEP, Sound.ENTITY_SKELETON_DEATH, Sound.ENTITY_SKELETON_AMBIENT),
SKELETON_HORSE(Sound.ENTITY_SKELETON_HORSE_HURT, new Sound[]{Sound.BLOCK_GRASS_STEP, Sound.ENTITY_HORSE_STEP_WOOD}, Sound.ENTITY_SKELETON_HORSE_DEATH,
new Sound[]{Sound.ENTITY_SKELETON_HORSE_AMBIENT, Sound.ENTITY_SKELETON_HORSE_AMBIENT_WATER}, Sound.ENTITY_HORSE_GALLOP, Sound.ENTITY_HORSE_SADDLE,
new Sound[]
{Sound.ENTITY_SKELETON_HORSE_AMBIENT, Sound.ENTITY_SKELETON_HORSE_AMBIENT_WATER}, Sound.ENTITY_HORSE_GALLOP, Sound.ENTITY_HORSE_SADDLE,
Sound.ENTITY_HORSE_ARMOR, Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP, Sound.ENTITY_SKELETON_HORSE_GALLOP_WATER,
Sound.ENTITY_SKELETON_HORSE_JUMP_WATER, Sound.ENTITY_SKELETON_HORSE_SWIM, Sound.ENTITY_SKELETON_HORSE_STEP_WATER),
SLIME(new Sound[]{Sound.ENTITY_SLIME_HURT, Sound.ENTITY_SLIME_HURT_SMALL}, new Sound[]{Sound.ENTITY_SLIME_JUMP, Sound.ENTITY_SLIME_JUMP_SMALL},
new Sound[]{Sound.ENTITY_SLIME_DEATH, Sound.ENTITY_SLIME_DEATH_SMALL}, null, Sound.ENTITY_SLIME_ATTACK, Sound.ENTITY_SLIME_SQUISH,
SLIME(new Sound[]{Sound.ENTITY_SLIME_HURT, Sound.ENTITY_SLIME_HURT_SMALL}, new Sound[]
{Sound.ENTITY_SLIME_JUMP, Sound.ENTITY_SLIME_JUMP_SMALL}, new Sound[]
{Sound.ENTITY_SLIME_DEATH, Sound.ENTITY_SLIME_DEATH_SMALL}, null, Sound.ENTITY_SLIME_ATTACK, Sound.ENTITY_SLIME_SQUISH,
Sound.ENTITY_SLIME_SQUISH_SMALL),
SNOWMAN(Sound.ENTITY_SNOW_GOLEM_HURT, null, Sound.ENTITY_SNOW_GOLEM_DEATH, Sound.ENTITY_SNOW_GOLEM_AMBIENT, Sound.ENTITY_SNOW_GOLEM_SHOOT),
@ -182,6 +230,12 @@ public enum DisguiseSoundEnums {
SQUID(Sound.ENTITY_SQUID_HURT, null, Sound.ENTITY_SQUID_DEATH, Sound.ENTITY_SQUID_AMBIENT, Sound.ENTITY_SQUID_SQUIRT, Sound.ENTITY_FISH_SWIM),
TADPOLE(Sound.ENTITY_TADPOLE_HURT, null, Sound.ENTITY_TADPOLE_DEATH, null, Sound.ENTITY_TADPOLE_FLOP, Sound.ITEM_BUCKET_EMPTY_TADPOLE,
Sound.ITEM_BUCKET_FILL_TADPOLE),
TRADER_LLAMA(Sound.ENTITY_LLAMA_HURT, Sound.ENTITY_LLAMA_STEP, Sound.ENTITY_LLAMA_DEATH, Sound.ENTITY_LLAMA_AMBIENT, Sound.ENTITY_LLAMA_ANGRY,
Sound.ENTITY_LLAMA_CHEST, Sound.ENTITY_LLAMA_EAT, Sound.ENTITY_LLAMA_SWAG),
TROPICAL_FISH(Sound.ENTITY_TROPICAL_FISH_HURT, null, Sound.ENTITY_TROPICAL_FISH_DEATH, Sound.ENTITY_TROPICAL_FISH_AMBIENT, Sound.ENTITY_TROPICAL_FISH_FLOP,
Sound.ENTITY_FISH_SWIM),
@ -198,6 +252,17 @@ public enum DisguiseSoundEnums {
VINDICATOR(Sound.ENTITY_VINDICATOR_HURT, null, Sound.ENTITY_VINDICATOR_DEATH, Sound.ENTITY_VINDICATOR_AMBIENT),
WANDERING_TRADER(Sound.ENTITY_WANDERING_TRADER_HURT, null, Sound.ENTITY_WANDERING_TRADER_DEATH, Sound.ENTITY_WANDERING_TRADER_AMBIENT,
Sound.ENTITY_WANDERING_TRADER_NO, Sound.ENTITY_WANDERING_TRADER_YES, Sound.ENTITY_WANDERING_TRADER_TRADE, Sound.ENTITY_WANDERING_TRADER_TRADE,
Sound.ENTITY_WANDERING_TRADER_REAPPEARED, Sound.ENTITY_WANDERING_TRADER_DRINK_POTION, Sound.ENTITY_WANDERING_TRADER_DRINK_MILK,
Sound.ENTITY_WANDERING_TRADER_DISAPPEARED),
WARDEN(Sound.ENTITY_WARDEN_HURT, Sound.ENTITY_WARDEN_STEP, Sound.ENTITY_WARDEN_DEATH, Sound.ENTITY_WARDEN_AMBIENT, Sound.ENTITY_WARDEN_AGITATED,
Sound.ENTITY_WARDEN_ANGRY, Sound.ENTITY_WARDEN_ATTACK_IMPACT, Sound.ENTITY_WARDEN_DIG, Sound.ENTITY_WARDEN_EMERGE, Sound.ENTITY_WARDEN_HEARTBEAT,
Sound.ENTITY_WARDEN_TENDRIL_CLICKS, Sound.ENTITY_WARDEN_LISTENING, Sound.ENTITY_WARDEN_LISTENING_ANGRY, Sound.ENTITY_WARDEN_NEARBY_CLOSE,
Sound.ENTITY_WARDEN_NEARBY_CLOSER, Sound.ENTITY_WARDEN_NEARBY_CLOSEST, Sound.ENTITY_WARDEN_SONIC_BOOM, Sound.ENTITY_WARDEN_SONIC_CHARGE,
Sound.ENTITY_WARDEN_ROAR, Sound.ENTITY_WARDEN_SNIFF),
WITCH(Sound.ENTITY_WITCH_HURT, null, Sound.ENTITY_WITCH_DEATH, Sound.ENTITY_WITCH_AMBIENT),
WITHER(Sound.ENTITY_WITHER_HURT, null, Sound.ENTITY_WITHER_DEATH, Sound.ENTITY_WITHER_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL, Sound.ENTITY_WITHER_SPAWN,

View File

@ -109,7 +109,7 @@ public class DisguiseMethods {
methods.add(m);
if (m.getName().startsWith("get") || m.getName().startsWith("has") || param == null || param == Void.TYPE ||
if (m.getName().startsWith("get") || m.getName().equals("hasPotionEffect") || param == null || param == Void.TYPE ||
ParamInfoManager.getParamInfo(m) == null) {
continue;
}

View File

@ -1,6 +1,7 @@
package me.libraryaddict.disguise.utilities;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.sounds.DisguiseSoundEnums;
import org.bukkit.entity.EntityType;
import org.junit.Assert;
import org.junit.Test;
@ -23,4 +24,22 @@ public class DisguiseTypesTest {
Assert.assertSame(entityType.name() + " has no DisguiseType registered!", disguiseType.name(), entityType.name());
}
}
@Test
public void testDisguiseSounds() {
for (DisguiseType type : DisguiseType.values()) {
if (!type.isMob() || type.isUnknown() || type.isCustom()) {
continue;
}
DisguiseSoundEnums enums = null;
try {
enums = DisguiseSoundEnums.valueOf(type.name());
} catch (Exception ignored) {
}
Assert.assertNotNull(type.name() + " has no sound group registered!", enums);
}
}
}

View File

@ -24,7 +24,7 @@
<lombok.version>1.18.22</lombok.version>
<protocollib.version>4.7.0</protocollib.version>
<spigot.version>1.18.1-R0.1-SNAPSHOT</spigot.version>
<spigot.version>1.19-R0.1-SNAPSHOT</spigot.version>
<junit.version>4.13.2</junit.version>
<paper-api.version>1.16.5-R0.1-SNAPSHOT</paper-api.version>
<bungeecord-chat.version>1.12-SNAPSHOT</bungeecord-chat.version>

View File

@ -146,6 +146,13 @@ public interface ReflectionManagerAbstract {
ItemMeta getDeserializedItemMeta(Map<String, Object> meta);
/**
* Implement this for custom metadata values that are not backwards compatible
*/
default Object convertInvalidMeta(Object value) {
return value;
}
static WrappedGameProfile getGameProfile(UUID uuid, String playerName) {
try {
return new WrappedGameProfile(uuid, playerName == null || playerName.length() < 17 ? playerName : playerName.substring(0, 16));