From 92a85194fb379f153c18e6ba4f507ee2cd980677 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 13 Nov 2019 11:07:53 +1300 Subject: [PATCH] Add missing Villager.Type parameter, rename methods to setBiome and deprecate old. --- .../disguisetypes/watchers/VillagerWatcher.java | 10 ++++++++++ .../disguisetypes/watchers/ZombieVillagerWatcher.java | 10 ++++++++++ .../disguise/utilities/DisguiseUtilities.java | 6 ++++-- .../utilities/parser/params/ParamInfoTypes.java | 4 +++- 4 files changed, 27 insertions(+), 3 deletions(-) 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 d5d6132d..375d3f4d 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java @@ -28,10 +28,19 @@ public class VillagerWatcher extends AbstractVillagerWatcher { return getVillagerData().getProfession(); } + @Deprecated public Villager.Type getType() { return getVillagerData().getType(); } + public Villager.Type getBiome() { + return getType(); + } + + public void setBiome(Villager.Type type) { + setType(type); + } + public int getLevel() { return getVillagerData().getLevel(); } @@ -40,6 +49,7 @@ public class VillagerWatcher extends AbstractVillagerWatcher { setVillagerData(new VillagerData(getType(), profession, getLevel())); } + @Deprecated public void setType(Villager.Type type) { setVillagerData(new VillagerData(type, getProfession(), getLevel())); } 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 31310067..1e87cb94 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java @@ -59,11 +59,21 @@ public class ZombieVillagerWatcher extends ZombieWatcher { setVillagerData(new VillagerData(getType(), profession, getLevel())); } + @Deprecated public void setType(Villager.Type type) { setVillagerData(new VillagerData(type, getProfession(), getLevel())); } + @Deprecated public void setLevel(int level) { setVillagerData(new VillagerData(getType(), getProfession(), getLevel())); } + + public Villager.Type getBiome() { + return getType(); + } + + public void setBiome(Villager.Type type) { + setType(type); + } } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 5eabdcb6..0016b813 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -1546,8 +1546,10 @@ public class DisguiseUtilities { ((Set) trackedPlayersObj).add(ReflectionManager.getNmsEntity(player)); } else { - ((Map) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap") - .get(entityTrackerEntry)).put(ReflectionManager.getNmsEntity(player), true); + Field field = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap"); + Object nmsEntity = ReflectionManager.getNmsEntity(player); + Map map = ((Map) field.get(entityTrackerEntry)); + map.put(nmsEntity, true); } ProtocolManager manager = ProtocolLibrary.getProtocolManager(); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/parser/params/ParamInfoTypes.java b/src/main/java/me/libraryaddict/disguise/utilities/parser/params/ParamInfoTypes.java index 8ba18259..f8a1d639 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/parser/params/ParamInfoTypes.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/parser/params/ParamInfoTypes.java @@ -40,7 +40,9 @@ public class ParamInfoTypes { "View all the colors you can use for a horses color")); paramInfos.add(new ParamInfoEnum(Villager.Profession.class, "Villager Profession", - "View all the professions you can set on a Zombie and Normal Villager")); + "View all the professions you can set on a Villager and Zombie Villager")); + paramInfos.add(new ParamInfoEnum(Villager.Type.class, "Villager Biome", + "View all the biomes you can set on a Villager and Zombie Villager")); paramInfos.add(new ParamInfoEnum(BlockFace.class, "Direction", "Direction (North, East, South, West, Up, Down)", "View the directions usable on player setSleeping and shulker direction", Arrays.copyOf(BlockFace.values(), 6)));