diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java index b95220dc..6c05a793 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/DisguiseType.java @@ -17,13 +17,13 @@ public enum DisguiseType { BAT, - @NmsAddedIn(val = NmsVersion.v1_15) BEE, + @NmsAddedIn(value = NmsVersion.v1_15) BEE, BLAZE, BOAT(1), - @NmsAddedIn(val = NmsVersion.v1_14) CAT, + @NmsAddedIn(value = NmsVersion.v1_14) CAT, CAVE_SPIDER, @@ -75,7 +75,7 @@ public enum DisguiseType { FISHING_HOOK(90), - @NmsAddedIn(val = NmsVersion.v1_14) FOX, + @NmsAddedIn(value = NmsVersion.v1_14) FOX, GHAST, @@ -83,7 +83,7 @@ public enum DisguiseType { GUARDIAN, - @NmsAddedIn(val = NmsVersion.v1_16) HOGLIN, + @NmsAddedIn(value = NmsVersion.v1_16) HOGLIN, HORSE, @@ -129,7 +129,7 @@ public enum DisguiseType { PAINTING, - @NmsAddedIn(val = NmsVersion.v1_14) PANDA, + @NmsAddedIn(value = NmsVersion.v1_14) PANDA, PARROT, @@ -139,9 +139,9 @@ public enum DisguiseType { @NmsRemovedIn(val = NmsVersion.v1_16) PIG_ZOMBIE, - @NmsAddedIn(val = NmsVersion.v1_16) PIGLIN, + @NmsAddedIn(value = NmsVersion.v1_16) PIGLIN, - @NmsAddedIn(val = NmsVersion.v1_14) PILLAGER, + @NmsAddedIn(value = NmsVersion.v1_14) PILLAGER, PLAYER, @@ -153,7 +153,7 @@ public enum DisguiseType { RABBIT, - @NmsAddedIn(val = NmsVersion.v1_14) RAVAGER, + @NmsAddedIn(value = NmsVersion.v1_14) RAVAGER, SALMON, @@ -187,7 +187,7 @@ public enum DisguiseType { STRAY, - @NmsAddedIn(val = NmsVersion.v1_16) STRIDER, + @NmsAddedIn(value = NmsVersion.v1_16) STRIDER, THROWN_EXP_BOTTLE(75), @@ -195,7 +195,7 @@ public enum DisguiseType { TRIDENT(94, 0), - @NmsAddedIn(val = NmsVersion.v1_14) TRADER_LLAMA, + @NmsAddedIn(value = NmsVersion.v1_14) TRADER_LLAMA, TROPICAL_FISH, @@ -209,7 +209,7 @@ public enum DisguiseType { VINDICATOR, - @NmsAddedIn(val = NmsVersion.v1_14) WANDERING_TRADER, + @NmsAddedIn(value = NmsVersion.v1_14) WANDERING_TRADER, WITCH, @@ -221,7 +221,7 @@ public enum DisguiseType { WOLF, - @NmsAddedIn(val = NmsVersion.v1_16) ZOGLIN, + @NmsAddedIn(value = NmsVersion.v1_16) ZOGLIN, ZOMBIE, @@ -229,7 +229,7 @@ public enum DisguiseType { ZOMBIE_VILLAGER, - @NmsAddedIn(val = NmsVersion.v1_16) ZOMBIFIED_PIGLIN; + @NmsAddedIn(value = NmsVersion.v1_16) ZOMBIFIED_PIGLIN; public static DisguiseType getType(Entity entity) { DisguiseType disguiseType = getType(entity.getType()); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index 6f34acc1..8ed1fcf5 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -282,12 +282,12 @@ public class FlagWatcher { updateNameHeight(); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public EntityPose getEntityPose() { return getData(MetaIndex.ENTITY_POSE); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setEntityPose(EntityPose entityPose) { setData(MetaIndex.ENTITY_POSE, entityPose); sendData(MetaIndex.ENTITY_POSE); @@ -760,12 +760,12 @@ public class FlagWatcher { } } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public boolean isSleeping() { return sleeping; } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setSleeping(boolean sleeping) { if (isSleeping() == sleeping) { return; @@ -776,12 +776,12 @@ public class FlagWatcher { updatePose(); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public boolean isSwimming() { return getEntityFlag(4); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setSwimming(boolean swimming) { if (isSwimming() == swimming) { return; @@ -792,7 +792,7 @@ public class FlagWatcher { updatePose(); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) protected void updatePose() { if (isSleeping()) { setEntityPose(EntityPose.SLEEPING); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java index a64fa964..35a6845b 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/MetaIndex.java @@ -45,7 +45,7 @@ public class MetaIndex { /** * The type of particle to display */ - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public static MetaIndex AREA_EFFECT_PARTICLE = new MetaIndex<>(AreaEffectCloudWatcher.class, 3, NmsVersion.v1_13.isSupported() ? WrappedParticle.create(Particle.SPELL_MOB, null) : null); @@ -114,11 +114,11 @@ public class MetaIndex { /** * The shooter of the arrow, no visible effect if set */ - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) @NmsRemovedIn(val = NmsVersion.v1_16) public static MetaIndex> ARROW_UUID = new MetaIndex<>(ArrowWatcher.class, 1, Optional.empty()); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex ARROW_PIERCE_LEVEL = new MetaIndex<>(ArrowWatcher.class, 2, (byte) 0); /** @@ -126,10 +126,10 @@ public class MetaIndex { */ public static MetaIndex BAT_HANGING = new MetaIndex<>(BatWatcher.class, 0, (byte) 1); - @NmsAddedIn(val = NmsVersion.v1_15) + @NmsAddedIn(value = NmsVersion.v1_15) public static MetaIndex BEE_META = new MetaIndex<>(BeeWatcher.class, 0, (byte) 0); - @NmsAddedIn(val = NmsVersion.v1_15) + @NmsAddedIn(value = NmsVersion.v1_15) public static MetaIndex BEE_ANGER = new MetaIndex<>(BeeWatcher.class, 1, 0); /** @@ -155,19 +155,19 @@ public class MetaIndex { */ public static MetaIndex BOAT_TYPE = new MetaIndex<>(BoatWatcher.class, 3, 0); - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public static MetaIndex BOAT_SHAKE = new MetaIndex<>(BoatWatcher.class, 6, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex CAT_TYPE = new MetaIndex<>(CatWatcher.class, 0, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex CAT_LYING_DOWN = new MetaIndex<>(CatWatcher.class, 1, false); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex CAT_LOOKING_UP = new MetaIndex<>(CatWatcher.class, 2, false); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex CAT_COLLAR = new MetaIndex<>(CatWatcher.class, 3, AnimalColor.RED.ordinal()); /** @@ -216,7 +216,7 @@ public class MetaIndex { public static MetaIndex ENDER_DRAGON_PHASE = new MetaIndex<>(EnderDragonWatcher.class, 0, 10); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex ENDER_SIGNAL_ITEM = new MetaIndex<>(EnderSignalWatcher.class, 0, new ItemStack(Material.AIR)); @@ -225,7 +225,7 @@ public class MetaIndex { */ public static MetaIndex ENDERMAN_AGRESSIVE = new MetaIndex<>(EndermanWatcher.class, 1, false); - @NmsAddedIn(val = NmsVersion.v1_15) + @NmsAddedIn(value = NmsVersion.v1_15) public static MetaIndex ENDERMAN_UNKNOWN = new MetaIndex<>(EndermanWatcher.class, 2, false); /** @@ -239,7 +239,7 @@ public class MetaIndex { /** * The custom name of the entity, empty if not set */ - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public static MetaIndex> ENTITY_CUSTOM_NAME = new MetaIndex<>(FlagWatcher.class, 2, Optional.empty()); /** @@ -272,13 +272,13 @@ public class MetaIndex { * If entity can make sounds, no noticable effects */ - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex ENTITY_POSE = new MetaIndex<>(FlagWatcher.class, 6, EntityPose.STANDING); public static MetaIndex FALLING_BLOCK_POSITION = new MetaIndex<>(FallingBlockWatcher.class, 0, BlockPosition.ORIGIN); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex FIREBALL_ITEM = new MetaIndex<>(FireballWatcher.class, 0, new ItemStack(Material.AIR)); @@ -290,31 +290,31 @@ public class MetaIndex { @NmsRemovedIn(val = NmsVersion.v1_14) public static MetaIndex FIREWORK_ATTACHED_ENTITY_OLD = new MetaIndex<>(FireworkWatcher.class, 1, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex FIREWORK_ATTACHED_ENTITY = new MetaIndex<>(FireworkWatcher.class, 1, OptionalInt.empty()); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex FIREWORK_SHOT_AT_ANGLE = new MetaIndex<>(FireworkWatcher.class, 2, false); public static MetaIndex FISHING_HOOK_HOOKED_ID = new MetaIndex<>(FishingHookWatcher.class, 0, 0); - @NmsAddedIn(val = NmsVersion.v1_16) + @NmsAddedIn(value = NmsVersion.v1_16) public static MetaIndex FISHING_HOOK_HOOKED = new MetaIndex<>(FishingHookWatcher.class, 1, false); /** * The type of fox, its coloring */ - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex FOX_TYPE = new MetaIndex<>(FoxWatcher.class, 0, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex FOX_META = new MetaIndex<>(FoxWatcher.class, 1, (byte) 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex> FOX_TRUSTED_1 = new MetaIndex<>(FoxWatcher.class, 2, Optional.empty()); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex> FOX_TRUSTED_2 = new MetaIndex<>(FoxWatcher.class, 3, Optional.empty()); /** @@ -332,7 +332,7 @@ public class MetaIndex { */ public static MetaIndex GUARDIAN_TARGET = new MetaIndex<>(GuardianWatcher.class, 1, 0); - @NmsAddedIn(val = NmsVersion.v1_16) + @NmsAddedIn(value = NmsVersion.v1_16) public static MetaIndex HOGLIN_SHAKING = new MetaIndex<>(HoglinWatcher.class, 0, false); /** @@ -359,7 +359,7 @@ public class MetaIndex { public static MetaIndex> HORSE_OWNER = new MetaIndex<>(AbstractHorseWatcher.class, 1, Optional.empty()); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex ILLAGER_SPELL = new MetaIndex<>(IllagerWizardWatcher.class, 0, (byte) 0); @NmsRemovedIn(val = NmsVersion.v1_14) @@ -411,10 +411,10 @@ public class MetaIndex { /** * How many bee stings does the entity have */ - @NmsAddedIn(val = NmsVersion.v1_15) + @NmsAddedIn(value = NmsVersion.v1_15) public static MetaIndex LIVING_STINGS = new MetaIndex<>(LivingWatcher.class, 5, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex> LIVING_BED_POSITION = new MetaIndex<>(LivingWatcher.class, 6, Optional.empty()); @@ -464,31 +464,31 @@ public class MetaIndex { */ public static MetaIndex MINECART_FURANCE_FUELED = new MetaIndex<>(MinecartFurnaceWatcher.class, 0, false); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex MUSHROOM_COW_TYPE = new MetaIndex<>(MushroomCowWatcher.class, 0, "RED"); @NmsRemovedIn(val = NmsVersion.v1_14) public static MetaIndex OCELOT_TYPE = new MetaIndex<>(OcelotWatcher.class, 0, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex OCELOT_TRUST = new MetaIndex<>(OcelotWatcher.class, 0, false); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex PANDA_HEAD_SHAKING = new MetaIndex<>(PandaWatcher.class, 0, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex PANDA_UNKNOWN_1 = new MetaIndex<>(PandaWatcher.class, 1, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex PANDA_UNKNOWN_2 = new MetaIndex<>(PandaWatcher.class, 2, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex PANDA_MAIN_GENE = new MetaIndex<>(PandaWatcher.class, 3, (byte) 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex PANDA_HIDDEN_GENE = new MetaIndex<>(PandaWatcher.class, 4, (byte) 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex PANDA_META = new MetaIndex<>(PandaWatcher.class, 5, (byte) 0); public static MetaIndex PARROT_VARIANT = new MetaIndex<>(ParrotWatcher.class, 0, 0); @@ -502,19 +502,19 @@ public class MetaIndex { */ public static MetaIndex PIG_BOOST = new MetaIndex<>(PigWatcher.class, 1, 0); - @NmsAddedIn(val = NmsVersion.v1_16) + @NmsAddedIn(value = NmsVersion.v1_16) public static MetaIndex PIGLIN_BABY = new MetaIndex<>(PiglinWatcher.class, 0, false); - @NmsAddedIn(val = NmsVersion.v1_16) + @NmsAddedIn(value = NmsVersion.v1_16) public static MetaIndex PIGLIN_SHAKING = new MetaIndex<>(PiglinWatcher.class, 1, false); - @NmsAddedIn(val = NmsVersion.v1_16) + @NmsAddedIn(value = NmsVersion.v1_16) public static MetaIndex PIGLIN_CROSSBOW = new MetaIndex<>(PiglinWatcher.class, 2, false); - @NmsAddedIn(val = NmsVersion.v1_16) + @NmsAddedIn(value = NmsVersion.v1_16) public static MetaIndex PIGLIN_DANCING = new MetaIndex<>(PiglinWatcher.class, 3, false); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex PILLAGER_AIMING_BOW = new MetaIndex<>(PillagerWatcher.class, 0, false); public static MetaIndex PLAYER_ABSORPTION = new MetaIndex<>(PlayerWatcher.class, 0, 0F); @@ -537,7 +537,7 @@ public class MetaIndex { public static MetaIndex RABBIT_TYPE = new MetaIndex<>(RabbitWatcher.class, 0, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex RAIDER_CASTING_SPELL = new MetaIndex<>(RaiderWatcher.class, 0, false); public static MetaIndex SHEEP_WOOL = new MetaIndex<>(SheepWatcher.class, 0, (byte) 0); @@ -558,13 +558,13 @@ public class MetaIndex { public static MetaIndex SNOWMAN_DERP = new MetaIndex<>(SnowmanWatcher.class, 0, (byte) 16); - @NmsAddedIn(val = NmsVersion.v1_16) + @NmsAddedIn(value = NmsVersion.v1_16) public static MetaIndex STRIDER_SADDLE_UNKNOWN = new MetaIndex<>(StriderWatcher.class, 0, 0); - @NmsAddedIn(val = NmsVersion.v1_16) + @NmsAddedIn(value = NmsVersion.v1_16) public static MetaIndex STRIDER_WARM = new MetaIndex<>(StriderWatcher.class, 1, false); - @NmsAddedIn(val = NmsVersion.v1_16) + @NmsAddedIn(value = NmsVersion.v1_16) public static MetaIndex STRIDER_SADDLED = new MetaIndex<>(StriderWatcher.class, 2, false); public static MetaIndex SPIDER_CLIMB = new MetaIndex<>(SpiderWatcher.class, 0, (byte) 0); @@ -577,7 +577,7 @@ public class MetaIndex { public static MetaIndex> TAMEABLE_OWNER = new MetaIndex<>(TameableWatcher.class, 1, Optional.empty()); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex THROWABLE_ITEM = new MetaIndex<>(ThrowableWatcher.class, 0, new ItemStack(Material.AIR)); @@ -587,7 +587,7 @@ public class MetaIndex { public static MetaIndex TRIDENT_ENCHANTS = new MetaIndex<>(TridentWatcher.class, 0, (byte) 0); - @NmsAddedIn(val = NmsVersion.v1_15) + @NmsAddedIn(value = NmsVersion.v1_15) public static MetaIndex TRIDENT_ENCHANTED = new MetaIndex<>(TridentWatcher.class, 1, false); public static MetaIndex TROPICAL_FISH_VARIANT = new MetaIndex<>(TropicalFishWatcher.class, 0, 0); @@ -611,10 +611,10 @@ public class MetaIndex { @NmsRemovedIn(val = NmsVersion.v1_14) public static MetaIndex VILLAGER_PROFESSION = new MetaIndex<>(VillagerWatcher.class, 0, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex ABSTRACT_VILLAGER_ANGRY = new MetaIndex<>(AbstractVillagerWatcher.class, 0, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex VILLAGER_DATA = new MetaIndex<>(VillagerWatcher.class, 0, NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null); @@ -638,10 +638,10 @@ public class MetaIndex { public static MetaIndex WOLF_COLLAR = new MetaIndex<>(WolfWatcher.class, 2, 14); - @NmsAddedIn(val = NmsVersion.v1_16) + @NmsAddedIn(value = NmsVersion.v1_16) public static MetaIndex WOLF_ANGER = new MetaIndex<>(WolfWatcher.class, 3, 0); - @NmsAddedIn(val = NmsVersion.v1_16) + @NmsAddedIn(value = NmsVersion.v1_16) public static MetaIndex ZOGLIN_BABY = new MetaIndex<>(ZoglinWatcher.class, 0, false); @NmsRemovedIn(val = NmsVersion.v1_14) @@ -649,7 +649,7 @@ public class MetaIndex { public static MetaIndex ZOMBIE_BABY = new MetaIndex<>(ZombieWatcher.class, 0, false); - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public static MetaIndex ZOMBIE_CONVERTING_DROWNED = new MetaIndex<>(ZombieWatcher.class, 2, false); public static MetaIndex ZOMBIE_PLACEHOLDER = new MetaIndex<>(ZombieWatcher.class, 1, 0); @@ -658,7 +658,7 @@ public class MetaIndex { public static MetaIndex ZOMBIE_VILLAGER_PROFESSION_OLD = new MetaIndex<>(ZombieVillagerWatcher.class, 1, 0); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public static MetaIndex ZOMBIE_VILLAGER_PROFESSION = new MetaIndex<>(ZombieVillagerWatcher.class, 1, NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AbstractVillagerWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AbstractVillagerWatcher.java index 2c3fdb96..6005dca0 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AbstractVillagerWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AbstractVillagerWatcher.java @@ -13,17 +13,17 @@ public class AbstractVillagerWatcher extends AgeableWatcher { super(disguise); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public int getAngry() { return getData(MetaIndex.ABSTRACT_VILLAGER_ANGRY); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public boolean isAngry() { return getAngry() > 0; } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setAngry(int ticks) { setData(MetaIndex.ABSTRACT_VILLAGER_ANGRY, ticks); sendData(MetaIndex.ABSTRACT_VILLAGER_ANGRY); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java index 6db80661..564142ba 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java @@ -57,12 +57,12 @@ public class AreaEffectCloudWatcher extends FlagWatcher { sendData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS); } - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public void setParticle(Particle particle, T particleData) { setParticle(WrappedParticle.create(particle, particleData)); } - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public WrappedParticle getParticle() { if (NmsVersion.v1_13.isSupported()) { return getData(MetaIndex.AREA_EFFECT_PARTICLE); @@ -75,7 +75,7 @@ public class AreaEffectCloudWatcher extends FlagWatcher { } } - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public void setParticle(WrappedParticle particle) { if (NmsVersion.v1_13.isSupported()) { setData(MetaIndex.AREA_EFFECT_PARTICLE, particle); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java index 6d7853f7..b0d08b2d 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java @@ -20,12 +20,12 @@ public class ArrowWatcher extends FlagWatcher { sendData(MetaIndex.ARROW_CRITICAL); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public int getPierceLevel() { return getData(MetaIndex.ARROW_PIERCE_LEVEL); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setPierceLevel(int pierceLevel) { setData(MetaIndex.ARROW_PIERCE_LEVEL, (byte) pierceLevel); sendData(MetaIndex.ARROW_PIERCE_LEVEL); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BeeWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BeeWatcher.java index 4acfaacf..cc179bfa 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BeeWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BeeWatcher.java @@ -8,7 +8,7 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion; /** * Created by libraryaddict on 14/12/2019. */ -@NmsAddedIn(val = NmsVersion.v1_15) +@NmsAddedIn(value = NmsVersion.v1_15) public class BeeWatcher extends AgeableWatcher { public BeeWatcher(Disguise disguise) { super(disguise); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java index bbf4598c..a8048340 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java @@ -41,12 +41,12 @@ public class BoatWatcher extends FlagWatcher { sendData(MetaIndex.BOAT_LEFT_PADDLING); } - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public int getBoatShake() { return getData(MetaIndex.BOAT_SHAKE); } - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public void setBoatShake(int number) { setData(MetaIndex.BOAT_SHAKE, number); sendData(MetaIndex.BOAT_SHAKE); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java index 8121e75c..15ce1c69 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java @@ -15,7 +15,7 @@ import java.util.Random; /** * Created by libraryaddict on 6/05/2019. */ -@NmsAddedIn(val = NmsVersion.v1_14) +@NmsAddedIn(value = NmsVersion.v1_14) public class CatWatcher extends TameableWatcher { public CatWatcher(Disguise disguise) { super(disguise); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderSignalWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderSignalWatcher.java index 81dde603..3e9dd1e2 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderSignalWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/EnderSignalWatcher.java @@ -20,12 +20,12 @@ public class EnderSignalWatcher extends FlagWatcher { } } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public ItemStack getItemStack() { return getData(MetaIndex.ENDER_SIGNAL_ITEM); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setItemStack(ItemStack item) { setData(MetaIndex.ENDER_SIGNAL_ITEM, item); sendData(MetaIndex.ENDER_SIGNAL_ITEM); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java index b5c6706b..27d1a291 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FallingBlockWatcher.java @@ -8,10 +8,13 @@ import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.utilities.DisguiseUtilities; +import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn; +import me.libraryaddict.disguise.utilities.reflection.NmsVersion; import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; import me.libraryaddict.disguise.utilities.translations.TranslateType; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -19,6 +22,7 @@ import java.lang.reflect.InvocationTargetException; public class FallingBlockWatcher extends FlagWatcher { private ItemStack block = new ItemStack(Material.STONE); + private BlockData blockData; private boolean gridLocked; public FallingBlockWatcher(Disguise disguise) { @@ -28,7 +32,12 @@ public class FallingBlockWatcher extends FlagWatcher { @Override public FallingBlockWatcher clone(Disguise disguise) { FallingBlockWatcher watcher = (FallingBlockWatcher) super.clone(disguise); - watcher.setBlock(getBlock().clone()); + + if (NmsVersion.v1_13.isSupported()) { + watcher.setBlockData(getBlockData().clone()); + } else { + watcher.setBlock(getBlock().clone()); + } return watcher; } @@ -98,4 +107,34 @@ public class FallingBlockWatcher extends FlagWatcher { DisguiseUtilities.refreshTrackers(getDisguise()); } } + + @NmsAddedIn(NmsVersion.v1_13) + public BlockData getBlockData() { + if (block != null && blockData == null) { + return block.getType().createBlockData(); + } + + return blockData; + } + + @NmsAddedIn(NmsVersion.v1_13) + public void setBlockData(BlockData data) { + if (data == null || data.getMaterial() == Material.AIR && data.getMaterial().isBlock()) { + setBlock(null); + return; + } + + this.block = new ItemStack(data.getMaterial()); + this.blockData = data; + + if (!getDisguise().isCustomDisguiseName()) { + getDisguise().setDisguiseName(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("Block") + " " + + TranslateType.DISGUISE_OPTIONS_PARAMETERS + .get(ReflectionManager.toReadable(block.getType().name()))); + } + + if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) { + DisguiseUtilities.refreshTrackers(getDisguise()); + } + } } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FireballWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FireballWatcher.java index 1d2734d7..09e2fe0b 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FireballWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FireballWatcher.java @@ -20,12 +20,12 @@ public class FireballWatcher extends FlagWatcher { } } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public ItemStack getItemStack() { return getData(MetaIndex.FIREBALL_ITEM); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setItemStack(ItemStack item) { setData(MetaIndex.FIREBALL_ITEM, item); sendData(MetaIndex.FIREBALL_ITEM); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FireworkWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FireworkWatcher.java index 6d0ca486..e8d87518 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FireworkWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FireworkWatcher.java @@ -35,18 +35,18 @@ public class FireworkWatcher extends FlagWatcher { sendData(MetaIndex.FIREWORK_ITEM); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public boolean isShotAtAngle() { return getData(MetaIndex.FIREWORK_SHOT_AT_ANGLE); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setShotAtAngle(boolean shotAtAngle) { setData(MetaIndex.FIREWORK_SHOT_AT_ANGLE, shotAtAngle); sendData(MetaIndex.FIREWORK_SHOT_AT_ANGLE); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public OptionalInt getAttachedEntityOpt() { return getData(MetaIndex.FIREWORK_ATTACHED_ENTITY); } @@ -59,7 +59,7 @@ public class FireworkWatcher extends FlagWatcher { setAttachedEntity(entityId == 0 ? OptionalInt.empty() : OptionalInt.of(entityId)); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setAttachedEntity(OptionalInt entityId) { if (NmsVersion.v1_14.isSupported()) { setData(MetaIndex.FIREWORK_ATTACHED_ENTITY, entityId); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java index cb9c113d..5c4de826 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java @@ -13,7 +13,7 @@ import java.util.Random; /** * Created by libraryaddict on 6/05/2019. */ -@NmsAddedIn(val = NmsVersion.v1_14) +@NmsAddedIn(value = NmsVersion.v1_14) public class FoxWatcher extends AgeableWatcher { public FoxWatcher(Disguise disguise) { super(disguise); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/IllagerWizardWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/IllagerWizardWatcher.java index 70488b02..84c0e7f0 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/IllagerWizardWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/IllagerWizardWatcher.java @@ -12,12 +12,12 @@ public class IllagerWizardWatcher extends IllagerWatcher { super(disguise); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public Spellcaster.Spell getSpell() { return Spellcaster.Spell.values()[getData(MetaIndex.ILLAGER_SPELL)]; } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setSpell(Spellcaster.Spell spell) { setData(MetaIndex.ILLAGER_SPELL, (byte) spell.ordinal()); sendData(MetaIndex.ILLAGER_SPELL); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/InsentientWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/InsentientWatcher.java index 5c72fb47..ad5f20c7 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/InsentientWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/InsentientWatcher.java @@ -43,12 +43,12 @@ public class InsentientWatcher extends LivingWatcher { return (getData(MetaIndex.INSENTIENT_META) & i) != 0; } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public boolean isEnraged() { return getInsentientFlag(4); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setEnraged(boolean enraged) { setInsentientFlag(4, enraged); } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java index 5b481466..17ef86b9 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java @@ -40,12 +40,12 @@ public class LivingWatcher extends FlagWatcher { return clone; } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public BlockPosition getBedPosition() { return getData(MetaIndex.LIVING_BED_POSITION).orElse(null); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setBedPosition(BlockPosition blockPosition) { Optional optional; @@ -94,22 +94,22 @@ public class LivingWatcher extends FlagWatcher { sendData(MetaIndex.LIVING_HAND); } - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public boolean isRightClicking() { return getHandFlag(0); } - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public void setRightClicking(boolean setRightClicking) { setHandFlag(0, setRightClicking); } - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public boolean isSpinning() { return getHandFlag(2); } - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public void setSpinning(boolean setSpinning) { setHandFlag(2, setSpinning); } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MushroomCowWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MushroomCowWatcher.java index 9e3690ea..10711bff 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MushroomCowWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/MushroomCowWatcher.java @@ -14,12 +14,12 @@ public class MushroomCowWatcher extends AgeableWatcher { super(disguise); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public MushroomCow.Variant getVariant() { return MushroomCow.Variant.valueOf(getData(MetaIndex.MUSHROOM_COW_TYPE).toUpperCase()); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setVariant(MushroomCow.Variant variant) { setData(MetaIndex.MUSHROOM_COW_TYPE, variant.name().toLowerCase()); sendData(MetaIndex.MUSHROOM_COW_TYPE); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java index 2dea7977..d021df71 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java @@ -16,12 +16,12 @@ public class OcelotWatcher extends AgeableWatcher { super(disguise); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public boolean isTrusting() { return getData(MetaIndex.OCELOT_TRUST); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setTrusting(boolean trusting) { setData(MetaIndex.OCELOT_TRUST, trusting); sendData(MetaIndex.OCELOT_TRUST); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PandaWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PandaWatcher.java index 11277284..81a66fd4 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PandaWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PandaWatcher.java @@ -13,7 +13,7 @@ import java.util.Random; /** * Created by libraryaddict on 6/05/2019. */ -@NmsAddedIn(val = NmsVersion.v1_14) +@NmsAddedIn(value = NmsVersion.v1_14) public class PandaWatcher extends AgeableWatcher { public PandaWatcher(Disguise disguise) { super(disguise); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PillagerWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PillagerWatcher.java index 066c54c1..907d466f 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PillagerWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PillagerWatcher.java @@ -8,7 +8,7 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion; /** * Created by libraryaddict on 6/05/2019. */ -@NmsAddedIn(val = NmsVersion.v1_14) +@NmsAddedIn(value = NmsVersion.v1_14) public class PillagerWatcher extends IllagerWatcher { public PillagerWatcher(Disguise disguise) { super(disguise); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RavagerWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RavagerWatcher.java index 9d7b03ae..36916ad3 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RavagerWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RavagerWatcher.java @@ -7,7 +7,7 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion; /** * Created by libraryaddict on 6/05/2019. */ -@NmsAddedIn(val = NmsVersion.v1_14) +@NmsAddedIn(value = NmsVersion.v1_14) public class RavagerWatcher extends RaiderWatcher { public RavagerWatcher(Disguise disguise) { super(disguise); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ThrowableWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ThrowableWatcher.java index 287292f1..2127f163 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ThrowableWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ThrowableWatcher.java @@ -22,13 +22,13 @@ public abstract class ThrowableWatcher extends FlagWatcher { protected abstract ItemStack getDefaultItemStack(); - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public ItemStack getItemStack() { return getData(MetaIndex.THROWABLE_ITEM); } @RandomDefaultValue - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setItemStack(ItemStack item) { setData(MetaIndex.THROWABLE_ITEM, item); sendData(MetaIndex.THROWABLE_ITEM); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TraderLlamaWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TraderLlamaWatcher.java index e5aca0cb..458edf26 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TraderLlamaWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TraderLlamaWatcher.java @@ -7,7 +7,7 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion; /** * Created by libraryaddict on 6/05/2019. */ -@NmsAddedIn(val = NmsVersion.v1_14) +@NmsAddedIn(value = NmsVersion.v1_14) public class TraderLlamaWatcher extends LlamaWatcher { public TraderLlamaWatcher(Disguise disguise) { super(disguise); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TridentWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TridentWatcher.java index 1be1f9bd..0b3ad69c 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TridentWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TridentWatcher.java @@ -13,12 +13,12 @@ public class TridentWatcher extends ArrowWatcher { super(disguise); } - @NmsAddedIn(val = NmsVersion.v1_15) + @NmsAddedIn(value = NmsVersion.v1_15) public boolean isEnchanted() { return getData(MetaIndex.TRIDENT_ENCHANTED); } - @NmsAddedIn(val = NmsVersion.v1_15) + @NmsAddedIn(value = NmsVersion.v1_15) public void setEnchanted(boolean enchanted) { setData(MetaIndex.TRIDENT_ENCHANTED, enchanted); sendData(MetaIndex.TRIDENT_ENCHANTED); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java index 6363ee8a..67dae613 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java @@ -21,12 +21,12 @@ public class VillagerWatcher extends AbstractVillagerWatcher { } } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public VillagerData getVillagerData() { return getData(MetaIndex.VILLAGER_DATA); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setVillagerData(VillagerData villagerData) { setData(MetaIndex.VILLAGER_DATA, villagerData); sendData(MetaIndex.VILLAGER_DATA); @@ -51,33 +51,33 @@ public class VillagerWatcher extends AbstractVillagerWatcher { } @Deprecated - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public Villager.Type getType() { return getVillagerData().getType(); } @Deprecated - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setType(Villager.Type type) { setVillagerData(new VillagerData(type, getProfession(), getLevel())); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public Villager.Type getBiome() { return getType(); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setBiome(Villager.Type type) { setType(type); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public int getLevel() { return getVillagerData().getLevel(); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setLevel(int level) { setVillagerData(new VillagerData(getType(), getProfession(), level)); } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java index 2886fed7..ec141cfc 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java @@ -44,12 +44,12 @@ public class ZombieVillagerWatcher extends ZombieWatcher { } } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public VillagerData getVillagerData() { return getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setVillagerData(VillagerData villagerData) { setData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION, villagerData); sendData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION); @@ -69,34 +69,34 @@ public class ZombieVillagerWatcher extends ZombieWatcher { } } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public Villager.Type getType() { return getVillagerData().getType(); } @Deprecated - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setType(Villager.Type type) { setVillagerData(new VillagerData(type, getProfession(), getLevel())); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public int getLevel() { return getVillagerData().getLevel(); } @Deprecated - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setLevel(int level) { setVillagerData(new VillagerData(getType(), getProfession(), getLevel())); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public Villager.Type getBiome() { return getType(); } - @NmsAddedIn(val = NmsVersion.v1_14) + @NmsAddedIn(value = NmsVersion.v1_14) public void setBiome(Villager.Type type) { setType(type); } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java index 9d520be9..24214a9b 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java @@ -33,12 +33,12 @@ public class ZombieWatcher extends InsentientWatcher { setBaby(true); } - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public boolean isConverting() { return getData(MetaIndex.ZOMBIE_CONVERTING_DROWNED); } - @NmsAddedIn(val = NmsVersion.v1_13) + @NmsAddedIn(value = NmsVersion.v1_13) public void setConverting(boolean converting) { setData(MetaIndex.ZOMBIE_CONVERTING_DROWNED, converting); sendData(MetaIndex.ZOMBIE_CONVERTING_DROWNED); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index ce352c46..827fb7f0 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -43,6 +43,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.RandomUtils; import org.apache.logging.log4j.util.Strings; import org.bukkit.*; +import org.bukkit.block.data.BlockData; import org.bukkit.boss.KeyedBossBar; import org.bukkit.command.CommandSender; import org.bukkit.entity.*; @@ -1112,6 +1113,10 @@ public class DisguiseUtilities { gsonBuilder.registerTypeAdapter(FlagWatcher.class, new SerializerFlagWatcher(gsonBuilder.create())); gsonBuilder.registerTypeAdapter(Disguise.class, new SerializerDisguise()); + if (NmsVersion.v1_13.isSupported()) { + gsonBuilder.registerTypeAdapter(BlockData.class, new SerializerBlockData()); + } + gson = gsonBuilder.create(); if (!profileCache.exists()) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerBlockData.java b/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerBlockData.java new file mode 100644 index 00000000..73dcd547 --- /dev/null +++ b/src/main/java/me/libraryaddict/disguise/utilities/json/SerializerBlockData.java @@ -0,0 +1,25 @@ +package me.libraryaddict.disguise.utilities.json; + +import com.comphenix.protocol.wrappers.WrappedChatComponent; +import com.google.gson.*; +import org.bukkit.Bukkit; +import org.bukkit.block.data.BlockData; + +import java.lang.reflect.Type; + +/** + * Created by libraryaddict on 27/11/2018. + */ +public class SerializerBlockData implements JsonDeserializer, + JsonSerializer { + @Override + public BlockData deserialize(JsonElement json, Type typeOfT, + JsonDeserializationContext context) throws JsonParseException { + return Bukkit.createBlockData(json.getAsString()); + } + + @Override + public JsonElement serialize(BlockData src, Type typeOfSrc, JsonSerializationContext context) { + return context.serialize(src.getAsString()); + } +} diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java index 3fd92465..6d452c1e 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java @@ -304,9 +304,13 @@ public class PacketHandlerSpawn implements IPacketHandler { double z = loc.getZ(); if (disguise.getType() == DisguiseType.FALLING_BLOCK) { - ItemStack block = ((FallingBlockWatcher) disguise.getWatcher()).getBlock(); + if (NmsVersion.v1_13.isSupported()) { + + } else { + ItemStack block = ((FallingBlockWatcher) disguise.getWatcher()).getBlock(); + data = ReflectionManager.getCombinedIdByItemStack(block); + } - data = ReflectionManager.getCombinedIdByItemStack(block); if (((FallingBlockWatcher) disguise.getWatcher()).isGridLocked()) { // Center the block diff --git a/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java b/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java index 397f297c..d45e5a31 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java @@ -13,6 +13,7 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion; import org.apache.commons.lang.StringUtils; import org.bukkit.*; import org.bukkit.block.BlockFace; +import org.bukkit.block.data.BlockData; import org.bukkit.boss.BarColor; import org.bukkit.boss.BarStyle; import org.bukkit.entity.*; @@ -77,6 +78,8 @@ public class ParamInfoTypes { paramInfos.add(new ParamInfoParticle(WrappedParticle.class, "Particle", "The different particles of Minecraft", Particle.values(), getMaterials())); paramInfos.add(new ParamInfoEnum(TropicalFish.Pattern.class, "Pattern", "Patterns of a tropical fish")); + paramInfos.add(new ParamInfoBlockData(BlockData.class, "BlockData", + "The block data states, barrel[facing=north,open=false] as example")); } else { paramInfos.add(new ParamInfoEnum(Particle.class, "Particle", "The different particles of Minecraft")); } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoBlockData.java b/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoBlockData.java new file mode 100644 index 00000000..8096b2cd --- /dev/null +++ b/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoBlockData.java @@ -0,0 +1,38 @@ +package me.libraryaddict.disguise.utilities.params.types.custom; + +import me.libraryaddict.disguise.utilities.params.ParamInfo; +import me.libraryaddict.disguise.utilities.parser.DisguiseParseException; +import org.bukkit.Bukkit; +import org.bukkit.block.data.BlockData; + +/** + * Created by libraryaddict on 12/08/2020. + */ +public class ParamInfoBlockData extends ParamInfo { + public ParamInfoBlockData(Class paramClass, String name, String description) { + super(paramClass, name, description); + } + + @Override + protected Object fromString(String string) throws DisguiseParseException { + if (string == null || string.equals("null")) { + return null; + } + + return Bukkit.createBlockData(string); + } + + @Override + public String toString(Object object) { + if (object == null) { + return "null"; + } + + return ((BlockData) object).getAsString(); + } + + @Override + public boolean isParam(Class paramClass) { + return getParamClass().isAssignableFrom(paramClass); + } +} diff --git a/src/main/java/me/libraryaddict/disguise/utilities/reflection/NmsAddedIn.java b/src/main/java/me/libraryaddict/disguise/utilities/reflection/NmsAddedIn.java index bfcbb42d..320af668 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/reflection/NmsAddedIn.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/reflection/NmsAddedIn.java @@ -8,5 +8,5 @@ import java.lang.annotation.RetentionPolicy; */ @Retention(RetentionPolicy.RUNTIME) public @interface NmsAddedIn { - NmsVersion val(); + NmsVersion value(); } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java b/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java index a0a79ffb..893f1f45 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java @@ -16,6 +16,8 @@ import me.libraryaddict.disguise.utilities.sounds.SoundGroup; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.bukkit.*; +import org.bukkit.block.BlockState; +import org.bukkit.block.data.BlockData; import org.bukkit.command.Command; import org.bukkit.command.CommandMap; import org.bukkit.command.SimpleCommandMap; @@ -131,7 +133,7 @@ public class ReflectionManager { NmsAddedIn added = obj.getAnnotation(NmsAddedIn.class); // If it was added after this version - if (!added.val().isSupported()) { + if (!added.value().isSupported()) { return false; } } @@ -1463,6 +1465,19 @@ public class ReflectionManager { return new WrappedWatchableObject(watcherItem); } + public static int getCombinedIdByBlockData(BlockData data) { + try { + Object iBlockData = getCraftMethod("block.data.type.CraftBlockData", "getState").invoke(data); + + return (int) getNmsMethod("Block", "getCombinedId", getNmsClass("IBlockData")).invoke(null, iBlockData); + } + catch (Exception ex) { + ex.printStackTrace(); + } + + return 0; + } + public static int getCombinedIdByItemStack(ItemStack itemStack) { try { Object nmsBlock; diff --git a/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java b/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java index d05dce3f..b1ffdb98 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java @@ -116,9 +116,9 @@ public class CompileMethods { int removed = -1; if (method.isAnnotationPresent(NmsAddedIn.class)) { - added = method.getAnnotation(NmsAddedIn.class).val().ordinal(); + added = method.getAnnotation(NmsAddedIn.class).value().ordinal(); } else if (method.getDeclaringClass().isAnnotationPresent(NmsAddedIn.class)) { - added = method.getDeclaringClass().getAnnotation(NmsAddedIn.class).val().ordinal(); + added = method.getDeclaringClass().getAnnotation(NmsAddedIn.class).value().ordinal(); } if (method.isAnnotationPresent(NmsRemovedIn.class)) {