From 26c560e8e860137274906fd83cc07ef20e5b7484 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 13 Jun 2016 06:05:45 +1200 Subject: [PATCH] Add the new disguises --- .../disguise/disguisetypes/Disguise.java | 16 ++++++- .../disguise/disguisetypes/DisguiseType.java | 38 +++++++++------- .../disguise/disguisetypes/FlagType.java | 45 ++----------------- .../watchers/PolarBearWatcher.java | 23 ++++++++++ 4 files changed, 62 insertions(+), 60 deletions(-) create mode 100644 src/me/libraryaddict/disguise/disguisetypes/watchers/PolarBearWatcher.java diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java index 72a6a550..8ca0c4fa 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -122,11 +122,23 @@ public abstract class Disguise if (getType() == DisguiseType.WITHER_SKELETON) { ((SkeletonWatcher) getWatcher()).setType(SkeletonType.WITHER); + } + else if (getType() == DisguiseType.STRAY) + { + ((SkeletonWatcher) getWatcher()).setType(SkeletonType.STRAY); } // Else if its a zombie, but the disguise type is a zombie villager. Set the value. else if (getType() == DisguiseType.ZOMBIE_VILLAGER) { - ((ZombieWatcher) getWatcher()) - .setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]); + Profession profession = null; + + while (profession == null || profession == Profession.NORMAL || profession == Profession.HUSK) + profession = Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]; + + ((ZombieWatcher) getWatcher()).setProfession(profession); + } + else if (getType() == DisguiseType.HUSK) + { + ((ZombieWatcher) getWatcher()).setProfession(Profession.HUSK); } else if (getType() == DisguiseType.ELDER_GUARDIAN) { diff --git a/src/me/libraryaddict/disguise/disguisetypes/DisguiseType.java b/src/me/libraryaddict/disguise/disguisetypes/DisguiseType.java index 2bdd0069..95104250 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/DisguiseType.java +++ b/src/me/libraryaddict/disguise/disguisetypes/DisguiseType.java @@ -71,6 +71,8 @@ public enum DisguiseType HORSE, + HUSK, + IRON_GOLEM, ITEM_FRAME(71), @@ -107,6 +109,8 @@ public enum DisguiseType PLAYER, + POLAR_BEAR, + PRIMED_TNT(50), RABBIT, @@ -139,12 +143,16 @@ public enum DisguiseType SQUID, - TIPPED_ARROW(92), + STRAY, THROWN_EXP_BOTTLE(75), + TIPPED_ARROW(92), + UNDEAD_HORSE, + UNKNOWN, + VILLAGER, WITCH, @@ -159,9 +167,7 @@ public enum DisguiseType ZOMBIE, - ZOMBIE_VILLAGER, - - UNKNOWN; + ZOMBIE_VILLAGER; static { @@ -269,10 +275,10 @@ public enum DisguiseType } } - private int objectId = -1, defaultData = 0; - private EntityType entityType; + private int objectId = -1, defaultData = 0; + private Class watcherClass; DisguiseType(int... ints) @@ -317,16 +323,6 @@ public enum DisguiseType return entityType; } - /** - * The TYPE id of this entity. Different from the Object Id send in spawn packets when spawning miscs. - * - * @return - */ - public int getTypeId() - { - return (int) getEntityType().getTypeId(); - } - /** * The object type send in packets when spawning a misc entity. Otherwise, -1. * @@ -337,6 +333,16 @@ public enum DisguiseType return objectId; } + /** + * The TYPE id of this entity. Different from the Object Id send in spawn packets when spawning miscs. + * + * @return + */ + public int getTypeId() + { + return (int) getEntityType().getTypeId(); + } + public Class getWatcherClass() { return watcherClass; diff --git a/src/me/libraryaddict/disguise/disguisetypes/FlagType.java b/src/me/libraryaddict/disguise/disguisetypes/FlagType.java index b75dda29..fdb113e8 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/FlagType.java +++ b/src/me/libraryaddict/disguise/disguisetypes/FlagType.java @@ -15,48 +15,7 @@ import org.bukkit.util.Vector; import com.comphenix.protocol.wrappers.BlockPosition; import com.google.common.base.Optional; -import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.AreaEffectCloudWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.ArmorStandWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.ArrowWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.BlazeWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.BoatWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.CreeperWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.EnderCrystalWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.EnderDragonWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.EndermanWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.FireworkWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.FishingHookWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.GhastWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.InsentientWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.IronGolemWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.ItemFrameWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.OcelotWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.PigWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.RabbitWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.ShulkerWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.SkeletonWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.SlimeWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.SnowmanWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.SpiderWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.SplashPotionWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.TNTWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.TameableWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.VillagerWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.WitchWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.WitherSkullWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.WitherWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.*; public class FlagType { @@ -209,6 +168,8 @@ public class FlagType public static FlagType PLAYER_SKIN = new FlagType(PlayerWatcher.class, 2, (byte) 0); + public static FlagType POLAR_BEAR_STANDING = new FlagType(PolarBearWatcher.class, 0, false); + public static FlagType RABBIT_TYPE = new FlagType(RabbitWatcher.class, 0, 0); public static FlagType SHEEP_WOOL = new FlagType(SheepWatcher.class, 0, (byte) 0); diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/PolarBearWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/PolarBearWatcher.java new file mode 100644 index 00000000..42f4ab1f --- /dev/null +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/PolarBearWatcher.java @@ -0,0 +1,23 @@ +package me.libraryaddict.disguise.disguisetypes.watchers; + +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.disguisetypes.FlagType; + +public class PolarBearWatcher extends AgeableWatcher +{ + public PolarBearWatcher(Disguise disguise) + { + super(disguise); + } + + public void setStanding(boolean standing) + { + setValue(FlagType.POLAR_BEAR_STANDING, standing); + sendData(FlagType.POLAR_BEAR_STANDING); + } + + public boolean isStanding() + { + return getValue(FlagType.POLAR_BEAR_STANDING); + } +}