From 57613dba372657aec027a32bb109341e65789ea8 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 7 Feb 2017 06:12:00 +1300 Subject: [PATCH] Renamed FlagType to MetaIndex which makes more sense --- .../libraryaddict/disguise/LibsDisguises.java | 4 +- .../disguise/disguisetypes/Disguise.java | 1780 ++++++++--------- .../disguise/disguisetypes/FlagType.java | 437 ---- .../disguise/disguisetypes/FlagWatcher.java | 58 +- .../disguise/disguisetypes/MetaIndex.java | 437 ++++ .../watchers/AbstractHorseWatcher.java | 18 +- .../watchers/AgeableWatcher.java | 8 +- .../watchers/AreaEffectCloudWatcher.java | 18 +- .../watchers/ArmorStandWatcher.java | 48 +- .../disguisetypes/watchers/ArrowWatcher.java | 8 +- .../disguisetypes/watchers/BatWatcher.java | 8 +- .../disguisetypes/watchers/BlazeWatcher.java | 8 +- .../disguisetypes/watchers/BoatWatcher.java | 26 +- .../watchers/ChestedHorseWatcher.java | 8 +- .../watchers/CreeperWatcher.java | 14 +- .../watchers/DroppedItemWatcher.java | 8 +- .../watchers/EnderCrystalWatcher.java | 14 +- .../watchers/EnderDragonWatcher.java | 8 +- .../watchers/EndermanWatcher.java | 12 +- .../disguisetypes/watchers/EvokerWatcher.java | 8 +- .../watchers/FireworkWatcher.java | 16 +- .../watchers/FishingHookWatcher.java | 8 +- .../disguisetypes/watchers/GhastWatcher.java | 8 +- .../watchers/GuardianWatcher.java | 18 +- .../disguisetypes/watchers/HorseWatcher.java | 20 +- .../watchers/InsentientWatcher.java | 14 +- .../watchers/ItemFrameWatcher.java | 16 +- .../disguisetypes/watchers/LivingWatcher.java | 24 +- .../disguisetypes/watchers/LlamaWatcher.java | 20 +- .../watchers/MinecartWatcher.java | 24 +- .../disguisetypes/watchers/OcelotWatcher.java | 8 +- .../disguisetypes/watchers/PigWatcher.java | 8 +- .../disguisetypes/watchers/PlayerWatcher.java | 32 +- .../watchers/PolarBearWatcher.java | 8 +- .../disguisetypes/watchers/RabbitWatcher.java | 8 +- .../disguisetypes/watchers/SheepWatcher.java | 22 +- .../watchers/ShulkerWatcher.java | 24 +- .../watchers/SkeletonWatcher.java | 8 +- .../disguisetypes/watchers/SlimeWatcher.java | 8 +- .../watchers/SnowmanWatcher.java | 8 +- .../disguisetypes/watchers/SpiderWatcher.java | 8 +- .../watchers/SplashPotionWatcher.java | 8 +- .../watchers/TameableWatcher.java | 18 +- .../watchers/TippedArrowWatcher.java | 8 +- .../disguisetypes/watchers/VexWatcher.java | 8 +- .../watchers/VillagerWatcher.java | 8 +- .../watchers/VindicatorWatcher.java | 6 +- .../disguisetypes/watchers/WitchWatcher.java | 8 +- .../watchers/WitherSkullWatcher.java | 8 +- .../disguisetypes/watchers/WitherWatcher.java | 18 +- .../disguisetypes/watchers/WolfWatcher.java | 20 +- .../watchers/ZombieVillagerWatcher.java | 20 +- .../disguisetypes/watchers/ZombieWatcher.java | 14 +- .../disguise/utilities/PacketsManager.java | 4 +- 54 files changed, 1694 insertions(+), 1694 deletions(-) delete mode 100644 src/me/libraryaddict/disguise/disguisetypes/FlagType.java create mode 100644 src/me/libraryaddict/disguise/disguisetypes/MetaIndex.java diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index f339d551..d7e28fd1 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -35,7 +35,7 @@ import me.libraryaddict.disguise.commands.UndisguiseEntityCommand; import me.libraryaddict.disguise.commands.UndisguisePlayerCommand; import me.libraryaddict.disguise.commands.UndisguiseRadiusCommand; import me.libraryaddict.disguise.disguisetypes.DisguiseType; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.ArrowWatcher; @@ -326,7 +326,7 @@ public class LibsDisguises extends JavaPlugin { WrappedDataWatcher watcher = WrappedDataWatcher.getEntityWatcher(bukkitEntity); for (WrappedWatchableObject watch : watcher.getWatchableObjects()) { - FlagType flagType = FlagType.getFlag(watcherClass, watch.getIndex()); + MetaIndex flagType = MetaIndex.getFlag(watcherClass, watch.getIndex()); if (flagType == null) { System.err.println("Error finding the FlagType for " + disguiseType.name() + "! Index " + watch.getIndex() diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java index f8392fbf..a935a067 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -1,890 +1,890 @@ -package me.libraryaddict.disguise.disguisetypes; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitTask; -import org.bukkit.util.Vector; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.PacketType.Play.Server; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.reflect.StructureModifier; -import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode; -import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction; -import com.comphenix.protocol.wrappers.PlayerInfoData; -import com.comphenix.protocol.wrappers.WrappedChatComponent; - -import me.libraryaddict.disguise.DisguiseAPI; -import me.libraryaddict.disguise.DisguiseConfig; -import me.libraryaddict.disguise.LibsDisguises; -import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType; -import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; -import me.libraryaddict.disguise.events.DisguiseEvent; -import me.libraryaddict.disguise.events.UndisguiseEvent; -import me.libraryaddict.disguise.utilities.DisguiseUtilities; -import me.libraryaddict.disguise.utilities.PacketsManager; -import me.libraryaddict.disguise.utilities.ReflectionManager; - -public abstract class Disguise { - private static List viewSelf = new ArrayList<>(); - - /** - * Returns the list of people who have /disguiseViewSelf toggled on - * - * @return - */ - public static List getViewSelf() { - return viewSelf; - } - - private boolean disguiseInUse; - private DisguiseType disguiseType; - private Entity entity; - private boolean hearSelfDisguise = DisguiseConfig.isSelfDisguisesSoundsReplaced(); - private boolean hideArmorFromSelf = DisguiseConfig.isHidingArmorFromSelf(); - private boolean hideHeldItemFromSelf = DisguiseConfig.isHidingHeldItemFromSelf(); - private boolean keepDisguiseEntityDespawn = DisguiseConfig.isKeepDisguiseOnEntityDespawn(); - private boolean keepDisguisePlayerDeath = DisguiseConfig.isKeepDisguiseOnPlayerDeath(); - private boolean keepDisguisePlayerLogout = DisguiseConfig.isKeepDisguiseOnPlayerLogout(); - private boolean modifyBoundingBox = DisguiseConfig.isModifyBoundingBox(); - private boolean playerHiddenFromTab = DisguiseConfig.isHideDisguisedPlayers(); - private boolean replaceSounds = DisguiseConfig.isSoundEnabled(); - private boolean showName; - private BukkitTask task; - private Runnable velocityRunnable; - private boolean velocitySent = DisguiseConfig.isVelocitySent(); - private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises(); - private FlagWatcher watcher; - - public Disguise(DisguiseType disguiseType) { - this.disguiseType = disguiseType; - } - - @Override - public abstract Disguise clone(); - - /** - * Seems I do this method so I can make cleaner constructors on disguises.. - * - * @param newType - * The disguise - */ - protected void createDisguise() { - if (getType().getEntityType() == null) { - throw new RuntimeException("DisguiseType " + getType() - + " was used in a futile attempt to construct a disguise, but this Minecraft version does not have that entity"); - } - - // Get if they are a adult now.. - - boolean isAdult = true; - - if (isMobDisguise()) { - isAdult = ((MobDisguise) this).isAdult(); - } - - if (getWatcher() == null) { - try { - // Construct the FlagWatcher from the stored class - setWatcher((FlagWatcher) getType().getWatcherClass().getConstructor(Disguise.class).newInstance(this)); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - // Set the disguise if its a baby or not - if (!isAdult) { - if (getWatcher() instanceof AgeableWatcher) { - ((AgeableWatcher) getWatcher()).setBaby(true); - } - else if (getWatcher() instanceof ZombieWatcher) { - ((ZombieWatcher) getWatcher()).setBaby(true); - } - } - - final boolean alwaysSendVelocity; - - switch (getType()) { - case EGG: - case ENDER_PEARL: - case BAT: - case EXPERIENCE_ORB: - case FIREBALL: - case SMALL_FIREBALL: - case SNOWBALL: - case SPLASH_POTION: - case THROWN_EXP_BOTTLE: - case WITHER_SKULL: - case FIREWORK: - alwaysSendVelocity = true; - break; - default: - alwaysSendVelocity = false; - break; - } - - double velocitySpeed = 0.0005; - - switch (getType()) { - case FIREWORK: - velocitySpeed = -0.040; - break; - case WITHER_SKULL: - velocitySpeed = 0.000001D; - break; - case ARROW: - case TIPPED_ARROW: - case SPECTRAL_ARROW: - case BOAT: - case ENDER_CRYSTAL: - case ENDER_DRAGON: - case GHAST: - case ITEM_FRAME: - case MINECART: - case MINECART_CHEST: - case MINECART_COMMAND: - case MINECART_FURNACE: - case MINECART_HOPPER: - case MINECART_MOB_SPAWNER: - case MINECART_TNT: - case PAINTING: - case PLAYER: - case SQUID: - velocitySpeed = 0; - break; - case DROPPED_ITEM: - case PRIMED_TNT: - case WITHER: - case FALLING_BLOCK: - velocitySpeed = 0.04; - break; - case EXPERIENCE_ORB: - velocitySpeed = 0.0221; - break; - case SPIDER: - case BAT: - case CAVE_SPIDER: - velocitySpeed = 0.004; - break; - default: - break; - } - - final double vectorY = velocitySpeed; - - final TargetedDisguise disguise = (TargetedDisguise) this; - - // A scheduler to clean up any unused disguises. - velocityRunnable = new Runnable() { - private int blockX, blockY, blockZ, facing; - private int deadTicks = 0; - private int refreshDisguise = 0; - - @Override - public void run() { - // If entity is no longer valid. Remove it. - if (!getEntity().isValid()) { - // If it has been dead for 30+ ticks - // This is to ensure that this disguise isn't removed while clients think its the real entity - // The delay is because if it sends the destroy entity packets straight away, then it means no death animation - // This is probably still a problem for wither and enderdragon deaths. - if (deadTicks++ > (getType() == DisguiseType.ENDER_DRAGON ? 200 : 20)) { - deadTicks = 0; - - if (isRemoveDisguiseOnDeath()) { - removeDisguise(); - } - else { - entity = null; - watcher = getWatcher().clone(disguise); - task.cancel(); - task = null; - } - } - } - else { - deadTicks = 0; - - // If the disguise type is tnt, we need to resend the entity packet else it will turn invisible - if (getType() == DisguiseType.FIREWORK) { - refreshDisguise++; - - if (refreshDisguise == 40) { - refreshDisguise = 0; - - DisguiseUtilities.refreshTrackers(disguise); - } - } - else if (getType() == DisguiseType.EVOKER_FANGS) { - refreshDisguise++; - - if (refreshDisguise == 23) { - refreshDisguise = 0; - - DisguiseUtilities.refreshTrackers(disguise); - } - } - else if (getType() == DisguiseType.ITEM_FRAME) { - Location loc = getEntity().getLocation(); - - int newFacing = (((int) loc.getYaw() + 720 + 45) / 90) % 4; - - if (loc.getBlockX() != blockX || loc.getBlockY() != blockY || loc.getBlockZ() != blockZ - || newFacing != facing) { - blockX = loc.getBlockX(); - blockY = loc.getBlockY(); - blockZ = loc.getBlockZ(); - facing = newFacing; - - DisguiseUtilities.refreshTrackers(disguise); - } - } - - if (isModifyBoundingBox()) { - DisguiseUtilities.doBoundingBox(disguise); - } - - if (getType() == DisguiseType.BAT && !((BatWatcher) getWatcher()).isHanging()) { - return; - } - - // If the vectorY isn't 0. Cos if it is. Then it doesn't want to send any vectors. - // If this disguise has velocity sending enabled and the entity is flying. - if (isVelocitySent() && vectorY != 0 && (alwaysSendVelocity || !getEntity().isOnGround())) { - Vector vector = getEntity().getVelocity(); - - // If the entity doesn't have velocity changes already - You know. I really can't wrap my head about the - // if statement. - // But it doesn't seem to do anything wrong.. - if (vector.getY() != 0 && !(vector.getY() < 0 && alwaysSendVelocity && getEntity().isOnGround())) { - return; - } - - // If disguise isn't a experience orb, or the entity isn't standing on the ground - if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround()) { - PacketContainer lookPacket = null; - - if (getType() == DisguiseType.WITHER_SKULL && DisguiseConfig.isWitherSkullPacketsEnabled()) { - lookPacket = new PacketContainer(Server.ENTITY_LOOK); - - StructureModifier mods = lookPacket.getModifier(); - lookPacket.getIntegers().write(0, getEntity().getEntityId()); - Location loc = getEntity().getLocation(); - - mods.write(4, PacketsManager.getYaw(getType(), getEntity().getType(), - (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F))); - mods.write(5, PacketsManager.getPitch(getType(), DisguiseType.getType(getEntity().getType()), - (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F))); - - if (isSelfDisguiseVisible() && getEntity() instanceof Player) { - PacketContainer selfLookPacket = lookPacket.shallowClone(); - - selfLookPacket.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId()); - - try { - ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), - selfLookPacket, false); - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - - try { - PacketContainer velocityPacket = new PacketContainer(Server.ENTITY_VELOCITY); - - StructureModifier mods = velocityPacket.getIntegers(); - - mods.write(1, (int) (vector.getX() * 8000)); - mods.write(3, (int) (vector.getZ() * 8000)); - - for (Player player : DisguiseUtilities.getPerverts(disguise)) { - if (getEntity() == player) { - if (!isSelfDisguiseVisible()) { - continue; - } - - mods.write(0, DisguiseAPI.getSelfDisguiseId()); - } - else { - mods.write(0, getEntity().getEntityId()); - } - - mods.write(2, (int) (8000D * (vectorY * ReflectionManager.getPing(player)) * 0.069D)); - - if (lookPacket != null && player != getEntity()) { - ProtocolLibrary.getProtocolManager().sendServerPacket(player, lookPacket, false); - } - - ProtocolLibrary.getProtocolManager().sendServerPacket(player, velocityPacket.shallowClone(), - false); - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - // If we need to send a packet to update the exp position as it likes to gravitate client sided to - // players. - } - if (getType() == DisguiseType.EXPERIENCE_ORB) { - PacketContainer packet = new PacketContainer(Server.REL_ENTITY_MOVE); - - packet.getIntegers().write(0, getEntity().getEntityId()); - try { - for (Player player : DisguiseUtilities.getPerverts(disguise)) { - if (getEntity() != player) { - ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); - } - else if (isSelfDisguiseVisible()) { - PacketContainer selfPacket = packet.shallowClone(); - - selfPacket.getModifier().write(0, DisguiseAPI.getSelfDisguiseId()); - - try { - ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), selfPacket, - false); - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - } - }; - } - - /** - * Get the disguised entity - * - * @return entity - */ - public Entity getEntity() { - return entity; - } - - /** - * Get the disguise type - * - * @return disguiseType - */ - public DisguiseType getType() { - return disguiseType; - } - - /** - * Get the flag watcher - * - * @return flagWatcher - */ - public FlagWatcher getWatcher() { - return watcher; - } - - /** - * In use doesn't mean that this disguise is active. It means that Lib's Disguises still stores a reference to the disguise. - * getEntity() can still return null if this disguise is active after despawn, logout, etc. - * - * @return isDisguiseInUse - */ - public boolean isDisguiseInUse() { - return disguiseInUse; - } - - /** - * Will a disguised player appear in tab - */ - public boolean isHidePlayer() { - return playerHiddenFromTab; - } - - public boolean isHidingArmorFromSelf() { - return hideArmorFromSelf; - } - - public boolean isHidingHeldItemFromSelf() { - return hideHeldItemFromSelf; - } - - public boolean isKeepDisguiseOnEntityDespawn() { - return this.keepDisguiseEntityDespawn; - } - - public boolean isKeepDisguiseOnPlayerDeath() { - return this.keepDisguisePlayerDeath; - } - - public boolean isKeepDisguiseOnPlayerLogout() { - return this.keepDisguisePlayerLogout; - } - - public boolean isMiscDisguise() { - return false; - } - - public boolean isMobDisguise() { - return false; - } - - public boolean isModifyBoundingBox() { - return modifyBoundingBox; - } - - public boolean isPlayerDisguise() { - return false; - } - - /** - * Internal use - */ - public boolean isRemoveDisguiseOnDeath() { - return getEntity() == null || (getEntity() instanceof Player - ? (!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath()) - : (!isKeepDisguiseOnEntityDespawn() || getEntity().isDead())); - } - - public boolean isSelfDisguiseSoundsReplaced() { - return hearSelfDisguise; - } - - /** - * Can the disguised view himself as the disguise - * - * @return viewSelfDisguise - */ - public boolean isSelfDisguiseVisible() { - return viewSelfDisguise; - } - - /** - * Returns true if the entity's name is showing through the disguise - * - * @return - */ - public boolean isShowName() { - return showName; - } - - public boolean isSoundsReplaced() { - return replaceSounds; - } - - public boolean isVelocitySent() { - return velocitySent; - } - - /** - * Removes the disguise and undisguises the entity if its using this disguise. - * - * @return removeDiguise - */ - public boolean removeDisguise() { - if (disguiseInUse) { - UndisguiseEvent event = new UndisguiseEvent(entity, this); - - Bukkit.getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - disguiseInUse = false; - - if (task != null) { - task.cancel(); - task = null; - } - - HashMap> disguises = DisguiseUtilities.getDisguises(); - - // If this disguise has a entity set - if (getEntity() != null) { - if (this instanceof PlayerDisguise) { - PlayerDisguise disguise = (PlayerDisguise) this; - - if (disguise.isDisplayedInTab()) { - PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); - deleteTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER); - deleteTab.getPlayerInfoDataLists().write(0, - Arrays.asList(new PlayerInfoData(disguise.getGameProfile(), 0, NativeGameMode.SURVIVAL, - WrappedChatComponent.fromText(disguise.getName())))); - - try { - for (Player player : Bukkit.getOnlinePlayers()) { - if (!((TargetedDisguise) this).canSee(player)) - continue; - - ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab); - } - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - - if (isHidePlayer() && getEntity() instanceof Player) { - PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); - deleteTab.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER); - deleteTab.getPlayerInfoDataLists().write(0, - Arrays.asList(new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, - NativeGameMode.SURVIVAL, - WrappedChatComponent.fromText(((Player) getEntity()).getDisplayName())))); - - try { - for (Player player : Bukkit.getOnlinePlayers()) { - if (!((TargetedDisguise) this).canSee(player)) - continue; - - ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab); - } - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - - // If this disguise is active - // Remove the disguise from the current disguises. - if (DisguiseUtilities.removeDisguise((TargetedDisguise) this)) { - if (getEntity() instanceof Player) { - DisguiseUtilities.removeSelfDisguise((Player) getEntity()); - } - - // Better refresh the entity to undisguise it - if (getEntity().isValid()) { - DisguiseUtilities.refreshTrackers((TargetedDisguise) this); - } - else { - DisguiseUtilities.destroyEntity((TargetedDisguise) this); - } - } - } - else { - // Loop through the disguises because it could be used with a unknown entity id. - HashMap> future = DisguiseUtilities.getFutureDisguises(); - - Iterator itel = DisguiseUtilities.getFutureDisguises().keySet().iterator(); - - while (itel.hasNext()) { - int id = itel.next(); - - if (future.get(id).remove(this) && future.get(id).isEmpty()) { - itel.remove(); - } - } - } - - if (isPlayerDisguise()) { - String name = ((PlayerDisguise) this).getName(); - - if (!DisguiseUtilities.getAddedByPlugins().contains(name.toLowerCase())) { - for (HashSet disguise : disguises.values()) { - for (Disguise d : disguise) { - if (d.isPlayerDisguise() && ((PlayerDisguise) d).getName().equals(name)) { - return true; - } - } - } - - DisguiseUtilities.getGameProfiles().remove(name.toLowerCase()); - } - } - - return true; - } - } - - return false; - } - - /** - * Set the entity of the disguise. Only used for internal things. - * - * @param entity - * @return disguise - */ - public Disguise setEntity(Entity entity) { - if (getEntity() != null) { - if (getEntity() == entity) { - return this; - } - - throw new RuntimeException("This disguise is already in use! Try .clone()"); - } - - if (isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) { - throw new RuntimeException( - "Cannot disguise a living entity with a misc disguise. Reenable MiscDisguisesForLiving in the config to do this"); - } - - this.entity = entity; - - setupWatcher(); - - return this; - } - - public Disguise setHearSelfDisguise(boolean hearSelfDisguise) { - this.hearSelfDisguise = hearSelfDisguise; - - return this; - } - - public Disguise setHideArmorFromSelf(boolean hideArmor) { - this.hideArmorFromSelf = hideArmor; - - if (getEntity() instanceof Player) { - ((Player) getEntity()).updateInventory(); - } - - return this; - } - - public Disguise setHideHeldItemFromSelf(boolean hideHeldItem) { - this.hideHeldItemFromSelf = hideHeldItem; - - if (getEntity() instanceof Player) { - ((Player) getEntity()).updateInventory(); - } - - return this; - } - - public void setHidePlayer(boolean hidePlayerInTab) { - if (isDisguiseInUse()) - throw new IllegalStateException("Cannot set this while disguise is in use!"); // Cos I'm lazy - - playerHiddenFromTab = hidePlayerInTab; - } - - public Disguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { - this.keepDisguiseEntityDespawn = keepDisguise; - - return this; - } - - public Disguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { - this.keepDisguisePlayerDeath = keepDisguise; - - return this; - } - - public Disguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { - this.keepDisguisePlayerLogout = keepDisguise; - - return this; - } - - public Disguise setModifyBoundingBox(boolean modifyBox) { - if (((TargetedDisguise) this).getDisguiseTarget() != TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { - throw new RuntimeException( - "Cannot modify the bounding box of a disguise which is not TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS"); - } - - if (isModifyBoundingBox() != modifyBox) { - this.modifyBoundingBox = modifyBox; - - if (DisguiseUtilities.isDisguiseInUse(this)) { - DisguiseUtilities.doBoundingBox((TargetedDisguise) this); - } - } - - return this; - } - - public Disguise setReplaceSounds(boolean areSoundsReplaced) { - replaceSounds = areSoundsReplaced; - - return this; - } - - public Disguise setShowName(boolean showName) { - this.showName = showName; - - return this; - } - - /** - * Sets up the FlagWatcher with the entityclass, it creates all the data it needs to prevent conflicts when sending the - * datawatcher. - */ - private void setupWatcher() { - ArrayList disguiseFlags = FlagType.getFlags(getType().getWatcherClass()); - ArrayList entityFlags = FlagType.getFlags(DisguiseType.getType(getEntity().getType()).getWatcherClass()); - - for (FlagType flag : entityFlags) { - if (disguiseFlags.contains(flag)) - continue; - - FlagType backup = null; - - for (FlagType flagType : disguiseFlags) { - if (flagType.getIndex() == flag.getIndex()) - backup = flagType; - } - - getWatcher().setBackupValue(flag, backup == null ? null : backup.getDefault()); - } - - getWatcher().setNoGravity(true); - } - - public Disguise setVelocitySent(boolean sendVelocity) { - this.velocitySent = sendVelocity; - - return this; - } - - /** - * Can the disguised view himself as the disguise - * - * @param viewSelfDisguise - * @return - */ - public Disguise setViewSelfDisguise(boolean viewSelfDisguise) { - if (isSelfDisguiseVisible() != viewSelfDisguise) { - this.viewSelfDisguise = viewSelfDisguise; - - if (getEntity() != null && getEntity() instanceof Player) { - if (DisguiseAPI.getDisguise((Player) getEntity(), getEntity()) == this) { - if (isSelfDisguiseVisible()) { - DisguiseUtilities.setupFakeDisguise(this); - } - else { - DisguiseUtilities.removeSelfDisguise((Player) getEntity()); - } - } - } - } - - return this; - } - - public Disguise setWatcher(FlagWatcher newWatcher) { - if (!getType().getWatcherClass().isInstance(newWatcher)) { - throw new IllegalArgumentException(newWatcher.getClass().getSimpleName() + " is not a instance of " - + getType().getWatcherClass().getSimpleName() + " for DisguiseType " + getType().name()); - } - - watcher = newWatcher; - - if (getEntity() != null) { - setupWatcher(); - } - - return this; - } - - public boolean startDisguise() { - if (!isDisguiseInUse()) { - if (getEntity() == null) { - throw new RuntimeException("No entity is assigned to this disguise!"); - } - - // Fire a disguise event - DisguiseEvent event = new DisguiseEvent(entity, this); - - Bukkit.getPluginManager().callEvent(event); - - // If they cancelled this disguise event. No idea why. - // Just return. - if (event.isCancelled()) { - return false; - } - - disguiseInUse = true; - - task = Bukkit.getScheduler().runTaskTimer(LibsDisguises.getInstance(), velocityRunnable, 1, 1); - - if (this instanceof PlayerDisguise) { - PlayerDisguise disguise = (PlayerDisguise) this; - - if (disguise.isDisplayedInTab()) { - PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); - addTab.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER); - addTab.getPlayerInfoDataLists().write(0, Arrays.asList(new PlayerInfoData(disguise.getGameProfile(), 0, - NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(disguise.getName())))); - - try { - for (Player player : Bukkit.getOnlinePlayers()) { - if (!((TargetedDisguise) this).canSee(player)) - continue; - - ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab); - } - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - - // Stick the disguise in the disguises bin - DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) this); - - if (isSelfDisguiseVisible() && getEntity() instanceof Player) { - DisguiseUtilities.removeSelfDisguise((Player) getEntity()); - } - - // Resend the disguised entity's packet - DisguiseUtilities.refreshTrackers((TargetedDisguise) this); - - // If he is a player, then self disguise himself - Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable() { - @Override - public void run() { - DisguiseUtilities.setupFakeDisguise(Disguise.this); - } - }, 2); - - if (isHidePlayer() && getEntity() instanceof Player) { - PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); - addTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER); - addTab.getPlayerInfoDataLists().write(0, - Arrays.asList(new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, - NativeGameMode.SURVIVAL, WrappedChatComponent.fromText("")))); - - try { - for (Player player : Bukkit.getOnlinePlayers()) { - if (!((TargetedDisguise) this).canSee(player)) - continue; - - ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab); - } - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - - return true; - } - - return false; - } - - public boolean stopDisguise() { - return removeDisguise(); - } -} +package me.libraryaddict.disguise.disguisetypes; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitTask; +import org.bukkit.util.Vector; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.PacketType.Play.Server; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.reflect.StructureModifier; +import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode; +import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction; +import com.comphenix.protocol.wrappers.PlayerInfoData; +import com.comphenix.protocol.wrappers.WrappedChatComponent; + +import me.libraryaddict.disguise.DisguiseAPI; +import me.libraryaddict.disguise.DisguiseConfig; +import me.libraryaddict.disguise.LibsDisguises; +import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType; +import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; +import me.libraryaddict.disguise.events.DisguiseEvent; +import me.libraryaddict.disguise.events.UndisguiseEvent; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; +import me.libraryaddict.disguise.utilities.PacketsManager; +import me.libraryaddict.disguise.utilities.ReflectionManager; + +public abstract class Disguise { + private static List viewSelf = new ArrayList<>(); + + /** + * Returns the list of people who have /disguiseViewSelf toggled on + * + * @return + */ + public static List getViewSelf() { + return viewSelf; + } + + private boolean disguiseInUse; + private DisguiseType disguiseType; + private Entity entity; + private boolean hearSelfDisguise = DisguiseConfig.isSelfDisguisesSoundsReplaced(); + private boolean hideArmorFromSelf = DisguiseConfig.isHidingArmorFromSelf(); + private boolean hideHeldItemFromSelf = DisguiseConfig.isHidingHeldItemFromSelf(); + private boolean keepDisguiseEntityDespawn = DisguiseConfig.isKeepDisguiseOnEntityDespawn(); + private boolean keepDisguisePlayerDeath = DisguiseConfig.isKeepDisguiseOnPlayerDeath(); + private boolean keepDisguisePlayerLogout = DisguiseConfig.isKeepDisguiseOnPlayerLogout(); + private boolean modifyBoundingBox = DisguiseConfig.isModifyBoundingBox(); + private boolean playerHiddenFromTab = DisguiseConfig.isHideDisguisedPlayers(); + private boolean replaceSounds = DisguiseConfig.isSoundEnabled(); + private boolean showName; + private BukkitTask task; + private Runnable velocityRunnable; + private boolean velocitySent = DisguiseConfig.isVelocitySent(); + private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises(); + private FlagWatcher watcher; + + public Disguise(DisguiseType disguiseType) { + this.disguiseType = disguiseType; + } + + @Override + public abstract Disguise clone(); + + /** + * Seems I do this method so I can make cleaner constructors on disguises.. + * + * @param newType + * The disguise + */ + protected void createDisguise() { + if (getType().getEntityType() == null) { + throw new RuntimeException("DisguiseType " + getType() + + " was used in a futile attempt to construct a disguise, but this Minecraft version does not have that entity"); + } + + // Get if they are a adult now.. + + boolean isAdult = true; + + if (isMobDisguise()) { + isAdult = ((MobDisguise) this).isAdult(); + } + + if (getWatcher() == null) { + try { + // Construct the FlagWatcher from the stored class + setWatcher((FlagWatcher) getType().getWatcherClass().getConstructor(Disguise.class).newInstance(this)); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + // Set the disguise if its a baby or not + if (!isAdult) { + if (getWatcher() instanceof AgeableWatcher) { + ((AgeableWatcher) getWatcher()).setBaby(true); + } + else if (getWatcher() instanceof ZombieWatcher) { + ((ZombieWatcher) getWatcher()).setBaby(true); + } + } + + final boolean alwaysSendVelocity; + + switch (getType()) { + case EGG: + case ENDER_PEARL: + case BAT: + case EXPERIENCE_ORB: + case FIREBALL: + case SMALL_FIREBALL: + case SNOWBALL: + case SPLASH_POTION: + case THROWN_EXP_BOTTLE: + case WITHER_SKULL: + case FIREWORK: + alwaysSendVelocity = true; + break; + default: + alwaysSendVelocity = false; + break; + } + + double velocitySpeed = 0.0005; + + switch (getType()) { + case FIREWORK: + velocitySpeed = -0.040; + break; + case WITHER_SKULL: + velocitySpeed = 0.000001D; + break; + case ARROW: + case TIPPED_ARROW: + case SPECTRAL_ARROW: + case BOAT: + case ENDER_CRYSTAL: + case ENDER_DRAGON: + case GHAST: + case ITEM_FRAME: + case MINECART: + case MINECART_CHEST: + case MINECART_COMMAND: + case MINECART_FURNACE: + case MINECART_HOPPER: + case MINECART_MOB_SPAWNER: + case MINECART_TNT: + case PAINTING: + case PLAYER: + case SQUID: + velocitySpeed = 0; + break; + case DROPPED_ITEM: + case PRIMED_TNT: + case WITHER: + case FALLING_BLOCK: + velocitySpeed = 0.04; + break; + case EXPERIENCE_ORB: + velocitySpeed = 0.0221; + break; + case SPIDER: + case BAT: + case CAVE_SPIDER: + velocitySpeed = 0.004; + break; + default: + break; + } + + final double vectorY = velocitySpeed; + + final TargetedDisguise disguise = (TargetedDisguise) this; + + // A scheduler to clean up any unused disguises. + velocityRunnable = new Runnable() { + private int blockX, blockY, blockZ, facing; + private int deadTicks = 0; + private int refreshDisguise = 0; + + @Override + public void run() { + // If entity is no longer valid. Remove it. + if (!getEntity().isValid()) { + // If it has been dead for 30+ ticks + // This is to ensure that this disguise isn't removed while clients think its the real entity + // The delay is because if it sends the destroy entity packets straight away, then it means no death animation + // This is probably still a problem for wither and enderdragon deaths. + if (deadTicks++ > (getType() == DisguiseType.ENDER_DRAGON ? 200 : 20)) { + deadTicks = 0; + + if (isRemoveDisguiseOnDeath()) { + removeDisguise(); + } + else { + entity = null; + watcher = getWatcher().clone(disguise); + task.cancel(); + task = null; + } + } + } + else { + deadTicks = 0; + + // If the disguise type is tnt, we need to resend the entity packet else it will turn invisible + if (getType() == DisguiseType.FIREWORK) { + refreshDisguise++; + + if (refreshDisguise == 40) { + refreshDisguise = 0; + + DisguiseUtilities.refreshTrackers(disguise); + } + } + else if (getType() == DisguiseType.EVOKER_FANGS) { + refreshDisguise++; + + if (refreshDisguise == 23) { + refreshDisguise = 0; + + DisguiseUtilities.refreshTrackers(disguise); + } + } + else if (getType() == DisguiseType.ITEM_FRAME) { + Location loc = getEntity().getLocation(); + + int newFacing = (((int) loc.getYaw() + 720 + 45) / 90) % 4; + + if (loc.getBlockX() != blockX || loc.getBlockY() != blockY || loc.getBlockZ() != blockZ + || newFacing != facing) { + blockX = loc.getBlockX(); + blockY = loc.getBlockY(); + blockZ = loc.getBlockZ(); + facing = newFacing; + + DisguiseUtilities.refreshTrackers(disguise); + } + } + + if (isModifyBoundingBox()) { + DisguiseUtilities.doBoundingBox(disguise); + } + + if (getType() == DisguiseType.BAT && !((BatWatcher) getWatcher()).isHanging()) { + return; + } + + // If the vectorY isn't 0. Cos if it is. Then it doesn't want to send any vectors. + // If this disguise has velocity sending enabled and the entity is flying. + if (isVelocitySent() && vectorY != 0 && (alwaysSendVelocity || !getEntity().isOnGround())) { + Vector vector = getEntity().getVelocity(); + + // If the entity doesn't have velocity changes already - You know. I really can't wrap my head about the + // if statement. + // But it doesn't seem to do anything wrong.. + if (vector.getY() != 0 && !(vector.getY() < 0 && alwaysSendVelocity && getEntity().isOnGround())) { + return; + } + + // If disguise isn't a experience orb, or the entity isn't standing on the ground + if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround()) { + PacketContainer lookPacket = null; + + if (getType() == DisguiseType.WITHER_SKULL && DisguiseConfig.isWitherSkullPacketsEnabled()) { + lookPacket = new PacketContainer(Server.ENTITY_LOOK); + + StructureModifier mods = lookPacket.getModifier(); + lookPacket.getIntegers().write(0, getEntity().getEntityId()); + Location loc = getEntity().getLocation(); + + mods.write(4, PacketsManager.getYaw(getType(), getEntity().getType(), + (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F))); + mods.write(5, PacketsManager.getPitch(getType(), DisguiseType.getType(getEntity().getType()), + (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F))); + + if (isSelfDisguiseVisible() && getEntity() instanceof Player) { + PacketContainer selfLookPacket = lookPacket.shallowClone(); + + selfLookPacket.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId()); + + try { + ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), + selfLookPacket, false); + } + catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + } + + try { + PacketContainer velocityPacket = new PacketContainer(Server.ENTITY_VELOCITY); + + StructureModifier mods = velocityPacket.getIntegers(); + + mods.write(1, (int) (vector.getX() * 8000)); + mods.write(3, (int) (vector.getZ() * 8000)); + + for (Player player : DisguiseUtilities.getPerverts(disguise)) { + if (getEntity() == player) { + if (!isSelfDisguiseVisible()) { + continue; + } + + mods.write(0, DisguiseAPI.getSelfDisguiseId()); + } + else { + mods.write(0, getEntity().getEntityId()); + } + + mods.write(2, (int) (8000D * (vectorY * ReflectionManager.getPing(player)) * 0.069D)); + + if (lookPacket != null && player != getEntity()) { + ProtocolLibrary.getProtocolManager().sendServerPacket(player, lookPacket, false); + } + + ProtocolLibrary.getProtocolManager().sendServerPacket(player, velocityPacket.shallowClone(), + false); + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + // If we need to send a packet to update the exp position as it likes to gravitate client sided to + // players. + } + if (getType() == DisguiseType.EXPERIENCE_ORB) { + PacketContainer packet = new PacketContainer(Server.REL_ENTITY_MOVE); + + packet.getIntegers().write(0, getEntity().getEntityId()); + try { + for (Player player : DisguiseUtilities.getPerverts(disguise)) { + if (getEntity() != player) { + ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); + } + else if (isSelfDisguiseVisible()) { + PacketContainer selfPacket = packet.shallowClone(); + + selfPacket.getModifier().write(0, DisguiseAPI.getSelfDisguiseId()); + + try { + ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), selfPacket, + false); + } + catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + } + } + catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + } + } + }; + } + + /** + * Get the disguised entity + * + * @return entity + */ + public Entity getEntity() { + return entity; + } + + /** + * Get the disguise type + * + * @return disguiseType + */ + public DisguiseType getType() { + return disguiseType; + } + + /** + * Get the flag watcher + * + * @return flagWatcher + */ + public FlagWatcher getWatcher() { + return watcher; + } + + /** + * In use doesn't mean that this disguise is active. It means that Lib's Disguises still stores a reference to the disguise. + * getEntity() can still return null if this disguise is active after despawn, logout, etc. + * + * @return isDisguiseInUse + */ + public boolean isDisguiseInUse() { + return disguiseInUse; + } + + /** + * Will a disguised player appear in tab + */ + public boolean isHidePlayer() { + return playerHiddenFromTab; + } + + public boolean isHidingArmorFromSelf() { + return hideArmorFromSelf; + } + + public boolean isHidingHeldItemFromSelf() { + return hideHeldItemFromSelf; + } + + public boolean isKeepDisguiseOnEntityDespawn() { + return this.keepDisguiseEntityDespawn; + } + + public boolean isKeepDisguiseOnPlayerDeath() { + return this.keepDisguisePlayerDeath; + } + + public boolean isKeepDisguiseOnPlayerLogout() { + return this.keepDisguisePlayerLogout; + } + + public boolean isMiscDisguise() { + return false; + } + + public boolean isMobDisguise() { + return false; + } + + public boolean isModifyBoundingBox() { + return modifyBoundingBox; + } + + public boolean isPlayerDisguise() { + return false; + } + + /** + * Internal use + */ + public boolean isRemoveDisguiseOnDeath() { + return getEntity() == null || (getEntity() instanceof Player + ? (!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath()) + : (!isKeepDisguiseOnEntityDespawn() || getEntity().isDead())); + } + + public boolean isSelfDisguiseSoundsReplaced() { + return hearSelfDisguise; + } + + /** + * Can the disguised view himself as the disguise + * + * @return viewSelfDisguise + */ + public boolean isSelfDisguiseVisible() { + return viewSelfDisguise; + } + + /** + * Returns true if the entity's name is showing through the disguise + * + * @return + */ + public boolean isShowName() { + return showName; + } + + public boolean isSoundsReplaced() { + return replaceSounds; + } + + public boolean isVelocitySent() { + return velocitySent; + } + + /** + * Removes the disguise and undisguises the entity if its using this disguise. + * + * @return removeDiguise + */ + public boolean removeDisguise() { + if (disguiseInUse) { + UndisguiseEvent event = new UndisguiseEvent(entity, this); + + Bukkit.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + disguiseInUse = false; + + if (task != null) { + task.cancel(); + task = null; + } + + HashMap> disguises = DisguiseUtilities.getDisguises(); + + // If this disguise has a entity set + if (getEntity() != null) { + if (this instanceof PlayerDisguise) { + PlayerDisguise disguise = (PlayerDisguise) this; + + if (disguise.isDisplayedInTab()) { + PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); + deleteTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER); + deleteTab.getPlayerInfoDataLists().write(0, + Arrays.asList(new PlayerInfoData(disguise.getGameProfile(), 0, NativeGameMode.SURVIVAL, + WrappedChatComponent.fromText(disguise.getName())))); + + try { + for (Player player : Bukkit.getOnlinePlayers()) { + if (!((TargetedDisguise) this).canSee(player)) + continue; + + ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab); + } + } + catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + } + + if (isHidePlayer() && getEntity() instanceof Player) { + PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); + deleteTab.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER); + deleteTab.getPlayerInfoDataLists().write(0, + Arrays.asList(new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, + NativeGameMode.SURVIVAL, + WrappedChatComponent.fromText(((Player) getEntity()).getDisplayName())))); + + try { + for (Player player : Bukkit.getOnlinePlayers()) { + if (!((TargetedDisguise) this).canSee(player)) + continue; + + ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab); + } + } + catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + + // If this disguise is active + // Remove the disguise from the current disguises. + if (DisguiseUtilities.removeDisguise((TargetedDisguise) this)) { + if (getEntity() instanceof Player) { + DisguiseUtilities.removeSelfDisguise((Player) getEntity()); + } + + // Better refresh the entity to undisguise it + if (getEntity().isValid()) { + DisguiseUtilities.refreshTrackers((TargetedDisguise) this); + } + else { + DisguiseUtilities.destroyEntity((TargetedDisguise) this); + } + } + } + else { + // Loop through the disguises because it could be used with a unknown entity id. + HashMap> future = DisguiseUtilities.getFutureDisguises(); + + Iterator itel = DisguiseUtilities.getFutureDisguises().keySet().iterator(); + + while (itel.hasNext()) { + int id = itel.next(); + + if (future.get(id).remove(this) && future.get(id).isEmpty()) { + itel.remove(); + } + } + } + + if (isPlayerDisguise()) { + String name = ((PlayerDisguise) this).getName(); + + if (!DisguiseUtilities.getAddedByPlugins().contains(name.toLowerCase())) { + for (HashSet disguise : disguises.values()) { + for (Disguise d : disguise) { + if (d.isPlayerDisguise() && ((PlayerDisguise) d).getName().equals(name)) { + return true; + } + } + } + + DisguiseUtilities.getGameProfiles().remove(name.toLowerCase()); + } + } + + return true; + } + } + + return false; + } + + /** + * Set the entity of the disguise. Only used for internal things. + * + * @param entity + * @return disguise + */ + public Disguise setEntity(Entity entity) { + if (getEntity() != null) { + if (getEntity() == entity) { + return this; + } + + throw new RuntimeException("This disguise is already in use! Try .clone()"); + } + + if (isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) { + throw new RuntimeException( + "Cannot disguise a living entity with a misc disguise. Reenable MiscDisguisesForLiving in the config to do this"); + } + + this.entity = entity; + + setupWatcher(); + + return this; + } + + public Disguise setHearSelfDisguise(boolean hearSelfDisguise) { + this.hearSelfDisguise = hearSelfDisguise; + + return this; + } + + public Disguise setHideArmorFromSelf(boolean hideArmor) { + this.hideArmorFromSelf = hideArmor; + + if (getEntity() instanceof Player) { + ((Player) getEntity()).updateInventory(); + } + + return this; + } + + public Disguise setHideHeldItemFromSelf(boolean hideHeldItem) { + this.hideHeldItemFromSelf = hideHeldItem; + + if (getEntity() instanceof Player) { + ((Player) getEntity()).updateInventory(); + } + + return this; + } + + public void setHidePlayer(boolean hidePlayerInTab) { + if (isDisguiseInUse()) + throw new IllegalStateException("Cannot set this while disguise is in use!"); // Cos I'm lazy + + playerHiddenFromTab = hidePlayerInTab; + } + + public Disguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { + this.keepDisguiseEntityDespawn = keepDisguise; + + return this; + } + + public Disguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { + this.keepDisguisePlayerDeath = keepDisguise; + + return this; + } + + public Disguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { + this.keepDisguisePlayerLogout = keepDisguise; + + return this; + } + + public Disguise setModifyBoundingBox(boolean modifyBox) { + if (((TargetedDisguise) this).getDisguiseTarget() != TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { + throw new RuntimeException( + "Cannot modify the bounding box of a disguise which is not TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS"); + } + + if (isModifyBoundingBox() != modifyBox) { + this.modifyBoundingBox = modifyBox; + + if (DisguiseUtilities.isDisguiseInUse(this)) { + DisguiseUtilities.doBoundingBox((TargetedDisguise) this); + } + } + + return this; + } + + public Disguise setReplaceSounds(boolean areSoundsReplaced) { + replaceSounds = areSoundsReplaced; + + return this; + } + + public Disguise setShowName(boolean showName) { + this.showName = showName; + + return this; + } + + /** + * Sets up the FlagWatcher with the entityclass, it creates all the data it needs to prevent conflicts when sending the + * datawatcher. + */ + private void setupWatcher() { + ArrayList disguiseFlags = MetaIndex.getFlags(getType().getWatcherClass()); + ArrayList entityFlags = MetaIndex.getFlags(DisguiseType.getType(getEntity().getType()).getWatcherClass()); + + for (MetaIndex flag : entityFlags) { + if (disguiseFlags.contains(flag)) + continue; + + MetaIndex backup = null; + + for (MetaIndex flagType : disguiseFlags) { + if (flagType.getIndex() == flag.getIndex()) + backup = flagType; + } + + getWatcher().setBackupValue(flag, backup == null ? null : backup.getDefault()); + } + + getWatcher().setNoGravity(true); + } + + public Disguise setVelocitySent(boolean sendVelocity) { + this.velocitySent = sendVelocity; + + return this; + } + + /** + * Can the disguised view himself as the disguise + * + * @param viewSelfDisguise + * @return + */ + public Disguise setViewSelfDisguise(boolean viewSelfDisguise) { + if (isSelfDisguiseVisible() != viewSelfDisguise) { + this.viewSelfDisguise = viewSelfDisguise; + + if (getEntity() != null && getEntity() instanceof Player) { + if (DisguiseAPI.getDisguise((Player) getEntity(), getEntity()) == this) { + if (isSelfDisguiseVisible()) { + DisguiseUtilities.setupFakeDisguise(this); + } + else { + DisguiseUtilities.removeSelfDisguise((Player) getEntity()); + } + } + } + } + + return this; + } + + public Disguise setWatcher(FlagWatcher newWatcher) { + if (!getType().getWatcherClass().isInstance(newWatcher)) { + throw new IllegalArgumentException(newWatcher.getClass().getSimpleName() + " is not a instance of " + + getType().getWatcherClass().getSimpleName() + " for DisguiseType " + getType().name()); + } + + watcher = newWatcher; + + if (getEntity() != null) { + setupWatcher(); + } + + return this; + } + + public boolean startDisguise() { + if (!isDisguiseInUse()) { + if (getEntity() == null) { + throw new RuntimeException("No entity is assigned to this disguise!"); + } + + // Fire a disguise event + DisguiseEvent event = new DisguiseEvent(entity, this); + + Bukkit.getPluginManager().callEvent(event); + + // If they cancelled this disguise event. No idea why. + // Just return. + if (event.isCancelled()) { + return false; + } + + disguiseInUse = true; + + task = Bukkit.getScheduler().runTaskTimer(LibsDisguises.getInstance(), velocityRunnable, 1, 1); + + if (this instanceof PlayerDisguise) { + PlayerDisguise disguise = (PlayerDisguise) this; + + if (disguise.isDisplayedInTab()) { + PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); + addTab.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER); + addTab.getPlayerInfoDataLists().write(0, Arrays.asList(new PlayerInfoData(disguise.getGameProfile(), 0, + NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(disguise.getName())))); + + try { + for (Player player : Bukkit.getOnlinePlayers()) { + if (!((TargetedDisguise) this).canSee(player)) + continue; + + ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab); + } + } + catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + } + + // Stick the disguise in the disguises bin + DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) this); + + if (isSelfDisguiseVisible() && getEntity() instanceof Player) { + DisguiseUtilities.removeSelfDisguise((Player) getEntity()); + } + + // Resend the disguised entity's packet + DisguiseUtilities.refreshTrackers((TargetedDisguise) this); + + // If he is a player, then self disguise himself + Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable() { + @Override + public void run() { + DisguiseUtilities.setupFakeDisguise(Disguise.this); + } + }, 2); + + if (isHidePlayer() && getEntity() instanceof Player) { + PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); + addTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER); + addTab.getPlayerInfoDataLists().write(0, + Arrays.asList(new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, + NativeGameMode.SURVIVAL, WrappedChatComponent.fromText("")))); + + try { + for (Player player : Bukkit.getOnlinePlayers()) { + if (!((TargetedDisguise) this).canSee(player)) + continue; + + ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab); + } + } + catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + + return true; + } + + return false; + } + + public boolean stopDisguise() { + return removeDisguise(); + } +} diff --git a/src/me/libraryaddict/disguise/disguisetypes/FlagType.java b/src/me/libraryaddict/disguise/disguisetypes/FlagType.java deleted file mode 100644 index ef11875a..00000000 --- a/src/me/libraryaddict/disguise/disguisetypes/FlagType.java +++ /dev/null @@ -1,437 +0,0 @@ -package me.libraryaddict.disguise.disguisetypes; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map.Entry; -import java.util.UUID; - -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -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.google.common.base.Optional; - -import me.libraryaddict.disguise.disguisetypes.watchers.AbstractHorseWatcher; -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.ChestedHorseWatcher; -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.EvokerWatcher; -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.LlamaWatcher; -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.PolarBearWatcher; -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.VexWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.VillagerWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.VindicatorWatcher; -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.ZombieVillagerWatcher; -import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; - -public class FlagType { - private static FlagType[] _values = new FlagType[0]; - - public static FlagType AGEABLE_BABY = new FlagType(AgeableWatcher.class, 0, false); - - public static FlagType AREA_EFFECT_CLOUD_COLOR = new FlagType(AreaEffectCloudWatcher.class, 1, - Color.BLACK.asRGB()); - - public static FlagType AREA_EFFECT_IGNORE_RADIUS = new FlagType(AreaEffectCloudWatcher.class, 2, false); - - public static FlagType AREA_EFFECT_PARTICLE = new FlagType(AreaEffectCloudWatcher.class, 3, 0); - - public static FlagType AREA_EFFECT_PARTICLE_PARAM_1 = new FlagType(AreaEffectCloudWatcher.class, 4, 0); - - public static FlagType AREA_EFFECT_PARTICLE_PARAM_2 = new FlagType(AreaEffectCloudWatcher.class, 5, 0); - - public static FlagType AREA_EFFECT_RADIUS = new FlagType(AreaEffectCloudWatcher.class, 0, 0F); - - public static FlagType ARMORSTAND_BODY = new FlagType(ArmorStandWatcher.class, 2, new Vector3F(0, 0, 0)); - - public static FlagType ARMORSTAND_HEAD = new FlagType(ArmorStandWatcher.class, 1, new Vector3F(0, 0, 0)); - - public static FlagType ARMORSTAND_LEFT_ARM = new FlagType(ArmorStandWatcher.class, 3, - new Vector3F(0, 0, 0)); - - public static FlagType ARMORSTAND_LEFT_LEG = new FlagType(ArmorStandWatcher.class, 5, - new Vector3F(0, 0, 0)); - - public static FlagType ARMORSTAND_META = new FlagType(ArmorStandWatcher.class, 0, (byte) 0); - - public static FlagType ARMORSTAND_RIGHT_ARM = new FlagType(ArmorStandWatcher.class, 4, - new Vector3F(0, 0, 0)); - - public static FlagType ARMORSTAND_RIGHT_LEG = new FlagType(ArmorStandWatcher.class, 6, - new Vector3F(0, 0, 0)); - - public static FlagType ARROW_CRITICAL = new FlagType(ArrowWatcher.class, 0, (byte) 0); - - public static FlagType BAT_HANGING = new FlagType(BatWatcher.class, 0, (byte) 1); - - public static FlagType BLAZE_BLAZING = new FlagType(BlazeWatcher.class, 0, (byte) 0); - - public static FlagType BOAT_DAMAGE = new FlagType(BoatWatcher.class, 2, 40F); - - public static FlagType BOAT_DIRECTION = new FlagType(BoatWatcher.class, 1, 0); - - public static FlagType BOAT_LAST_HIT = new FlagType(BoatWatcher.class, 0, 0); - - public static FlagType BOAT_LEFT_PADDLING = new FlagType(BoatWatcher.class, 5, false); - - public static FlagType BOAT_RIGHT_PADDLING = new FlagType(BoatWatcher.class, 4, false); - - public static FlagType BOAT_TYPE = new FlagType(BoatWatcher.class, 3, 0); - - public static FlagType CREEPER_IGNITED = new FlagType(CreeperWatcher.class, 2, false); - - public static FlagType CREEPER_POWERED = new FlagType(CreeperWatcher.class, 1, false); - - public static FlagType CREEPER_STATE = new FlagType(CreeperWatcher.class, 0, -1); - - public static FlagType DROPPED_ITEM = new FlagType(DroppedItemWatcher.class, 0, - new ItemStack(Material.STONE)); - - public static FlagType> ENDER_CRYSTAL_BEAM = new FlagType>( - EnderCrystalWatcher.class, 0, Optional. absent()); - - public static FlagType ENDER_CRYSTAL_PLATE = new FlagType(EnderCrystalWatcher.class, 1, false); - - public static FlagType ENDERD_RAGON_PHASE = new FlagType(EnderDragonWatcher.class, 0, 0); - - public static FlagType ENDERMAN_AGRESSIVE = new FlagType(EndermanWatcher.class, 1, false); - - public static FlagType> ENDERMAN_ITEM = new FlagType>( - EndermanWatcher.class, 0, Optional. absent()); - - public static FlagType ENTITY_AIR_TICKS = new FlagType(FlagWatcher.class, 1, 0); - - public static FlagType ENTITY_CUSTOM_NAME = new FlagType(FlagWatcher.class, 2, ""); - - public static FlagType ENTITY_CUSTOM_NAME_VISIBLE = new FlagType(FlagWatcher.class, 3, false); - - public static FlagType ENTITY_META = new FlagType(FlagWatcher.class, 0, (byte) 0); - - public static FlagType ENTITY_NO_GRAVITY = new FlagType(FlagWatcher.class, 5, false); - - public static FlagType ENTITY_SILENT = new FlagType(FlagWatcher.class, 4, false); - - public static FlagType EVOKER_SPELL_TICKS = new FlagType(EvokerWatcher.class, 0, (byte) 0); - - public static FlagType FALLING_BLOCK_POSITION = new FlagType(FallingBlockWatcher.class, 0, - BlockPosition.ORIGIN); - - public static FlagType FIREWORK_ITEM = new FlagType(FireworkWatcher.class, 0, - new ItemStack(Material.AIR)); - - public static FlagType FIREWORK_ATTACHED_ENTITY = new FlagType(FireworkWatcher.class, 1, 0); - - public static FlagType FISHING_HOOK_HOOKED = new FlagType(FishingHookWatcher.class, 0, 0); - - public static FlagType GHAST_AGRESSIVE = new FlagType(GhastWatcher.class, 0, false); - - public static FlagType GUARDIAN_RETRACT_SPIKES = new FlagType(GuardianWatcher.class, 0, false); - - public static FlagType GUARDIAN_TARGET = new FlagType(GuardianWatcher.class, 1, 0); - - public static FlagType HORSE_ARMOR = new FlagType(HorseWatcher.class, 1, 0); - - public static FlagType HORSE_CHESTED_CARRYING_CHEST = new FlagType(ChestedHorseWatcher.class, 0, false); - - public static FlagType HORSE_COLOR = new FlagType(HorseWatcher.class, 0, 0); - - public static FlagType HORSE_META = new FlagType(AbstractHorseWatcher.class, 0, (byte) 0); - - public static FlagType> HORSE_OWNER = new FlagType>(AbstractHorseWatcher.class, 1, - Optional. absent()); - - public static FlagType INSENTIENT_META = new FlagType(InsentientWatcher.class, 0, (byte) 0); - - public static FlagType IRON_GOLEM_PLAYER_CREATED = new FlagType(IronGolemWatcher.class, 0, (byte) 0); - - public static FlagType ITEMFRAME_ITEM = new FlagType(ItemFrameWatcher.class, 0, - new ItemStack(Material.AIR)); - - public static FlagType ITEMFRAME_ROTATION = new FlagType(ItemFrameWatcher.class, 1, 0); - - public static FlagType LIVING_ARROWS = new FlagType(LivingWatcher.class, 4, 0); - - public static FlagType LIVING_HAND = new FlagType(LivingWatcher.class, 0, (byte) 0); - - public static FlagType LIVING_HEALTH = new FlagType(LivingWatcher.class, 1, 1F); - - public static FlagType LIVING_POTION_AMBIENT = new FlagType(LivingWatcher.class, 3, false); - - public static FlagType LIVING_POTIONS = new FlagType(LivingWatcher.class, 2, 0); - - public static FlagType LLAMA_CARPET = new FlagType(LlamaWatcher.class, 1, 0); - - public static FlagType LLAMA_COLOR = new FlagType(LlamaWatcher.class, 2, -1); - - public static FlagType LLAMA_STRENGTH = new FlagType(LlamaWatcher.class, 0, 0); - - public static FlagType MINECART_BLOCK = new FlagType(MinecartWatcher.class, 3, 0); - - public static FlagType MINECART_BLOCK_VISIBLE = new FlagType(MinecartWatcher.class, 5, false); - - public static FlagType MINECART_BLOCK_Y = new FlagType(MinecartWatcher.class, 4, 0); - - public static FlagType MINECART_SHAKING_DIRECTION = new FlagType(MinecartWatcher.class, 1, 1); - - public static FlagType MINECART_SHAKING_MULITPLIER = new FlagType(MinecartWatcher.class, 2, 0F); - - public static FlagType MINECART_SHAKING_POWER = new FlagType(MinecartWatcher.class, 0, 0); - - public static FlagType OCELOT_TYPE = new FlagType(OcelotWatcher.class, 0, 0); - - public static FlagType PIG_SADDLED = new FlagType(PigWatcher.class, 0, false); - - public static FlagType PIG_UNKNOWN = new FlagType(PigWatcher.class, 1, 0); - - public static FlagType PLAYER_ABSORPTION = new FlagType(PlayerWatcher.class, 0, 0F); - - public static FlagType PLAYER_HAND = new FlagType(PlayerWatcher.class, 3, (byte) 0); - - public static FlagType PLAYER_SCORE = new FlagType(PlayerWatcher.class, 1, 0); - - public static FlagType PLAYER_SKIN = new FlagType(PlayerWatcher.class, 2, (byte) 127); - - 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); - - public static FlagType> SHULKER_ATTACHED = new FlagType>(ShulkerWatcher.class, - 1, Optional. absent()); - - public static FlagType SHULKER_COLOR = new FlagType(ShulkerWatcher.class, 3, (byte) 10); - - public static FlagType SHULKER_FACING = new FlagType(ShulkerWatcher.class, 0, Direction.DOWN); - - public static FlagType SHULKER_PEEKING = new FlagType(ShulkerWatcher.class, 2, (byte) 0); - - public static FlagType SKELETON_SWING_ARMS = new FlagType(SkeletonWatcher.class, 0, false); - - public static FlagType SLIME_SIZE = new FlagType(SlimeWatcher.class, 0, 0); - - public static FlagType SNOWMAN_DERP = new FlagType(SnowmanWatcher.class, 0, (byte) 0); - - public static FlagType SPIDER_CLIMB = new FlagType(SpiderWatcher.class, 0, (byte) 0); - - public static FlagType SPLASH_POTION_ITEM = new FlagType(SplashPotionWatcher.class, 1, - new ItemStack(Material.SPLASH_POTION)); // Yeah, the '1' isn't a bug. No idea why but MC thinks - // there's a '0' already. - - public static FlagType SPLASH_POTION_ITEM_BAD = new FlagType(SplashPotionWatcher.class, 0, - new ItemStack(Material.SPLASH_POTION)); // Yeah, the '1' isn't a bug. No - // idea why but MC thinks there's a - // '0' already. - - public static FlagType TAMEABLE_META = new FlagType(TameableWatcher.class, 0, (byte) 0); - - public static FlagType> TAMEABLE_OWNER = new FlagType>(TameableWatcher.class, 1, - Optional. absent()); - - public static FlagType TIPPED_ARROW_COLOR = new FlagType(ArrowWatcher.class, 1, Color.WHITE.asRGB()); - - public static FlagType TNT_FUSE_TICKS = new FlagType(TNTWatcher.class, 0, Integer.MAX_VALUE); - - public static FlagType VEX_ANGRY = new FlagType(VexWatcher.class, 0, (byte) 0); - - public static FlagType VILLAGER_PROFESSION = new FlagType(VillagerWatcher.class, 0, 0); - - public static FlagType VINDICATOR_JOHNNY = new FlagType(VindicatorWatcher.class, 0, (byte) 0); - - public static FlagType WITCH_AGGRESSIVE = new FlagType(WitchWatcher.class, 0, false); - - public static FlagType WITHER_INVUL = new FlagType(WitherWatcher.class, 3, 0); - - public static FlagType WITHER_TARGET_1 = new FlagType(WitherWatcher.class, 0, 0); - - public static FlagType WITHER_TARGET_2 = new FlagType(WitherWatcher.class, 1, 0); - - public static FlagType WITHER_TARGET_3 = new FlagType(WitherWatcher.class, 2, 0); - - public static FlagType WITHER_SKULL_BLUE = new FlagType(WitherSkullWatcher.class, 0, false); - - public static FlagType WOLF_BEGGING = new FlagType(WolfWatcher.class, 1, false); - - public static FlagType WOLF_COLLAR = new FlagType(WolfWatcher.class, 2, 14); - - public static FlagType WOLF_DAMAGE = new FlagType(WolfWatcher.class, 0, 0F); - - public static FlagType ZOMBIE_AGGRESSIVE = new FlagType(ZombieWatcher.class, 2, false); - - public static FlagType ZOMBIE_BABY = new FlagType(ZombieWatcher.class, 0, false); - - public static FlagType ZOMBIE_PLACEHOLDER = new FlagType(ZombieWatcher.class, 1, 0); - - public static FlagType ZOMBIE_VILLAGER_PROFESSION = new FlagType(ZombieVillagerWatcher.class, 1, 0); - - public static FlagType ZOMBIE_VILLAGER_SHAKING = new FlagType(ZombieVillagerWatcher.class, 0, false); - - static { - for (FlagType flagType : values()) { - if (flagType.getFlagWatcher() == FlagWatcher.class) - continue; - - flagType._index += getNoIndexes(flagType.getFlagWatcher().getSuperclass()); - - } - - // Simple verification for the dev that he's setting up the FlagType's properly. - // All flag types should be from 0 to with no empty numbers. - // All flag types should never occur twice. - - HashMap maxValues = new HashMap(); - - for (FlagType type : values()) { - if (maxValues.containsKey(type.getFlagWatcher()) && maxValues.get(type.getFlagWatcher()) > type.getIndex()) - continue; - - maxValues.put(type.getFlagWatcher(), type.getIndex()); - } - - for (Entry entry : maxValues.entrySet()) { - loop: - - for (int i = 0; i < entry.getValue(); i++) { - FlagType found = null; - - for (FlagType type : values()) { - if (type.getIndex() != i) - continue; - - if (!type.getFlagWatcher().isAssignableFrom(entry.getKey())) - continue; - - if (found != null) { - System.err.println(entry.getKey().getSimpleName() + " has multiple FlagType's registered for the index " - + i + " (" + type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName() - + ")"); - continue loop; - } - - found = type; - } - - if (found != null) - continue; - - System.err.println(entry.getKey().getSimpleName() + " has no FlagType registered for the index " + i); - } - } - } - - public static FlagType getFlag(Class watcherClass, int flagNo) { - for (FlagType type : values()) { - if (type.getIndex() != flagNo) - continue; - - if (!type.getFlagWatcher().isAssignableFrom(watcherClass)) - continue; - - return type; - } - - return null; - } - - public static ArrayList getFlags(Class watcherClass) { - ArrayList list = new ArrayList(); - - for (FlagType type : values()) { - if (!type.getFlagWatcher().isAssignableFrom(watcherClass)) - continue; - - list.add(type); - } - - return list; - } - - private static int getNoIndexes(Class c) { - int found = 0; - - for (FlagType type : values()) { - if (type.getFlagWatcher() != c) - continue; - - found++; - } - - if (c != FlagWatcher.class) { - found += getNoIndexes(c.getSuperclass()); - } - - return found; - } - - public static FlagType[] values() { - return _values; - } - - private Y _defaultValue; - private int _index; - private Class _watcher; - - private FlagType(Class watcher, int index, Y defaultValue) { - _index = index; - _watcher = watcher; - _defaultValue = defaultValue; - - _values = Arrays.copyOf(_values, _values.length + 1); - _values[_values.length - 1] = this; - } - - public Y getDefault() { - return _defaultValue; - } - - public Class getFlagWatcher() { - return _watcher; - } - - public int getIndex() { - return _index; - } -} diff --git a/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index 96cf6bc2..cbead397 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -41,7 +41,7 @@ public class FlagWatcher { public FlagWatcher(Disguise disguise) { this.disguise = (TargetedDisguise) disguise; - this.setData(FlagType.ENTITY_AIR_TICKS, 0); + this.setData(MetaIndex.ENTITY_AIR_TICKS, 0); equipment = new LibsEquipment(this); } @@ -85,7 +85,7 @@ public class FlagWatcher { // Its sending the air metadata. This is the least commonly sent metadata which all entitys still share. // I send my custom values if I see this! - if (id == FlagType.ENTITY_AIR_TICKS.getIndex()) { + if (id == MetaIndex.ENTITY_AIR_TICKS.getIndex()) { sendAllCustom = true; } @@ -201,7 +201,7 @@ public class FlagWatcher { } public String getCustomName() { - return (String) getData(FlagType.ENTITY_CUSTOM_NAME); + return (String) getData(MetaIndex.ENTITY_CUSTOM_NAME); } protected TargetedDisguise getDisguise() { @@ -209,7 +209,7 @@ public class FlagWatcher { } private boolean getEntityFlag(int byteValue) { - return (getData(FlagType.ENTITY_META) & 1 << byteValue) != 0; + return (getData(MetaIndex.ENTITY_META) & 1 << byteValue) != 0; } public EntityEquipment getEquipment() { @@ -228,7 +228,7 @@ public class FlagWatcher { return equipment.getItem(slot); } - protected Y getData(FlagType flagType) { + protected Y getData(MetaIndex flagType) { if (entityValues.containsKey(flagType.getIndex())) { return (Y) entityValues.get(flagType.getIndex()); } @@ -248,7 +248,7 @@ public class FlagWatcher { return getCustomName() != null; } - protected boolean hasValue(FlagType no) { + protected boolean hasValue(MetaIndex no) { return entityValues.containsKey(no.getIndex()); } @@ -257,7 +257,7 @@ public class FlagWatcher { } public boolean isCustomNameVisible() { - return getData(FlagType.ENTITY_CUSTOM_NAME_VISIBLE); + return getData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE); } public boolean isEntityAnimationsAdded() { @@ -277,7 +277,7 @@ public class FlagWatcher { } public boolean isNoGravity() { - return getData(FlagType.ENTITY_NO_GRAVITY); + return getData(MetaIndex.ENTITY_NO_GRAVITY); } public boolean isRightClicking() { @@ -315,21 +315,21 @@ public class FlagWatcher { } } - protected void sendData(FlagType... dataValues) { + protected void sendData(MetaIndex... dataValues) { if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this) { return; } List list = new ArrayList<>(); - for (FlagType data : dataValues) { + for (MetaIndex data : dataValues) { if (!entityValues.containsKey(data.getIndex()) || entityValues.get(data.getIndex()) == null) { continue; } Object value = entityValues.get(data.getIndex()); - if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == FlagType.ENTITY_META) { + if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == MetaIndex.ENTITY_META) { value = addEntityAnimations((byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0)); } @@ -376,14 +376,14 @@ public class FlagWatcher { getEquipment().setArmorContents(items); } - protected void setBackupValue(FlagType no, Object value) { + protected void setBackupValue(MetaIndex no, Object value) { backupEntityValues.put(no.getIndex(), value); } public void setBurning(boolean setBurning) { setEntityFlag(0, setBurning); - sendData(FlagType.ENTITY_META); + sendData(MetaIndex.ENTITY_META); } public void setCustomName(String name) { @@ -391,41 +391,41 @@ public class FlagWatcher { name = name.substring(0, 64); } - setData(FlagType.ENTITY_CUSTOM_NAME, name); - sendData(FlagType.ENTITY_CUSTOM_NAME); + setData(MetaIndex.ENTITY_CUSTOM_NAME, name); + sendData(MetaIndex.ENTITY_CUSTOM_NAME); } public void setCustomNameVisible(boolean display) { - setData(FlagType.ENTITY_CUSTOM_NAME_VISIBLE, display); - sendData(FlagType.ENTITY_CUSTOM_NAME_VISIBLE); + setData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE, display); + sendData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE); } private void setEntityFlag(int byteValue, boolean flag) { modifiedEntityAnimations[byteValue] = true; - byte b0 = (byte) getData(FlagType.ENTITY_META); + byte b0 = (byte) getData(MetaIndex.ENTITY_META); if (flag) { - setData(FlagType.ENTITY_META, (byte) (b0 | 1 << byteValue)); + setData(MetaIndex.ENTITY_META, (byte) (b0 | 1 << byteValue)); } else { - setData(FlagType.ENTITY_META, (byte) (b0 & ~(1 << byteValue))); + setData(MetaIndex.ENTITY_META, (byte) (b0 & ~(1 << byteValue))); } } public void setFlyingWithElytra(boolean flying) { setEntityFlag(7, flying); - sendData(FlagType.ENTITY_META); + sendData(MetaIndex.ENTITY_META); } public void setGlowing(boolean glowing) { setEntityFlag(6, glowing); - sendData(FlagType.ENTITY_META); + sendData(MetaIndex.ENTITY_META); } public void setInvisible(boolean setInvis) { setEntityFlag(5, setInvis); - sendData(FlagType.ENTITY_META); + sendData(MetaIndex.ENTITY_META); } /** @@ -506,26 +506,26 @@ public class FlagWatcher { } public void setNoGravity(boolean noGravity) { - setData(FlagType.ENTITY_NO_GRAVITY, noGravity); - sendData(FlagType.ENTITY_NO_GRAVITY); + setData(MetaIndex.ENTITY_NO_GRAVITY, noGravity); + sendData(MetaIndex.ENTITY_NO_GRAVITY); } public void setRightClicking(boolean setRightClicking) { setEntityFlag(4, setRightClicking); - sendData(FlagType.ENTITY_META); + sendData(MetaIndex.ENTITY_META); } public void setSneaking(boolean setSneaking) { setEntityFlag(1, setSneaking); - sendData(FlagType.ENTITY_META); + sendData(MetaIndex.ENTITY_META); } public void setSprinting(boolean setSprinting) { setEntityFlag(3, setSprinting); - sendData(FlagType.ENTITY_META); + sendData(MetaIndex.ENTITY_META); } - protected void setData(FlagType id, Y value) { + protected void setData(MetaIndex id, Y value) { if (value == null && id.getDefault() instanceof ItemStack) throw new IllegalArgumentException("Cannot use null ItemStacks"); diff --git a/src/me/libraryaddict/disguise/disguisetypes/MetaIndex.java b/src/me/libraryaddict/disguise/disguisetypes/MetaIndex.java new file mode 100644 index 00000000..67a5240c --- /dev/null +++ b/src/me/libraryaddict/disguise/disguisetypes/MetaIndex.java @@ -0,0 +1,437 @@ +package me.libraryaddict.disguise.disguisetypes; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.UUID; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +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.google.common.base.Optional; + +import me.libraryaddict.disguise.disguisetypes.watchers.AbstractHorseWatcher; +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.ChestedHorseWatcher; +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.EvokerWatcher; +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.LlamaWatcher; +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.PolarBearWatcher; +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.VexWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.VillagerWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.VindicatorWatcher; +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.ZombieVillagerWatcher; +import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; + +public class MetaIndex { + private static MetaIndex[] _values = new MetaIndex[0]; + + public static MetaIndex AGEABLE_BABY = new MetaIndex(AgeableWatcher.class, 0, false); + + public static MetaIndex AREA_EFFECT_CLOUD_COLOR = new MetaIndex(AreaEffectCloudWatcher.class, 1, + Color.BLACK.asRGB()); + + public static MetaIndex AREA_EFFECT_IGNORE_RADIUS = new MetaIndex(AreaEffectCloudWatcher.class, 2, false); + + public static MetaIndex AREA_EFFECT_PARTICLE = new MetaIndex(AreaEffectCloudWatcher.class, 3, 0); + + public static MetaIndex AREA_EFFECT_PARTICLE_PARAM_1 = new MetaIndex(AreaEffectCloudWatcher.class, 4, 0); + + public static MetaIndex AREA_EFFECT_PARTICLE_PARAM_2 = new MetaIndex(AreaEffectCloudWatcher.class, 5, 0); + + public static MetaIndex AREA_EFFECT_RADIUS = new MetaIndex(AreaEffectCloudWatcher.class, 0, 0F); + + public static MetaIndex ARMORSTAND_BODY = new MetaIndex(ArmorStandWatcher.class, 2, new Vector3F(0, 0, 0)); + + public static MetaIndex ARMORSTAND_HEAD = new MetaIndex(ArmorStandWatcher.class, 1, new Vector3F(0, 0, 0)); + + public static MetaIndex ARMORSTAND_LEFT_ARM = new MetaIndex(ArmorStandWatcher.class, 3, + new Vector3F(0, 0, 0)); + + public static MetaIndex ARMORSTAND_LEFT_LEG = new MetaIndex(ArmorStandWatcher.class, 5, + new Vector3F(0, 0, 0)); + + public static MetaIndex ARMORSTAND_META = new MetaIndex(ArmorStandWatcher.class, 0, (byte) 0); + + public static MetaIndex ARMORSTAND_RIGHT_ARM = new MetaIndex(ArmorStandWatcher.class, 4, + new Vector3F(0, 0, 0)); + + public static MetaIndex ARMORSTAND_RIGHT_LEG = new MetaIndex(ArmorStandWatcher.class, 6, + new Vector3F(0, 0, 0)); + + public static MetaIndex ARROW_CRITICAL = new MetaIndex(ArrowWatcher.class, 0, (byte) 0); + + public static MetaIndex BAT_HANGING = new MetaIndex(BatWatcher.class, 0, (byte) 1); + + public static MetaIndex BLAZE_BLAZING = new MetaIndex(BlazeWatcher.class, 0, (byte) 0); + + public static MetaIndex BOAT_DAMAGE = new MetaIndex(BoatWatcher.class, 2, 40F); + + public static MetaIndex BOAT_DIRECTION = new MetaIndex(BoatWatcher.class, 1, 0); + + public static MetaIndex BOAT_LAST_HIT = new MetaIndex(BoatWatcher.class, 0, 0); + + public static MetaIndex BOAT_LEFT_PADDLING = new MetaIndex(BoatWatcher.class, 5, false); + + public static MetaIndex BOAT_RIGHT_PADDLING = new MetaIndex(BoatWatcher.class, 4, false); + + public static MetaIndex BOAT_TYPE = new MetaIndex(BoatWatcher.class, 3, 0); + + public static MetaIndex CREEPER_IGNITED = new MetaIndex(CreeperWatcher.class, 2, false); + + public static MetaIndex CREEPER_POWERED = new MetaIndex(CreeperWatcher.class, 1, false); + + public static MetaIndex CREEPER_STATE = new MetaIndex(CreeperWatcher.class, 0, -1); + + public static MetaIndex DROPPED_ITEM = new MetaIndex(DroppedItemWatcher.class, 0, + new ItemStack(Material.STONE)); + + public static MetaIndex> ENDER_CRYSTAL_BEAM = new MetaIndex>( + EnderCrystalWatcher.class, 0, Optional. absent()); + + public static MetaIndex ENDER_CRYSTAL_PLATE = new MetaIndex(EnderCrystalWatcher.class, 1, false); + + public static MetaIndex ENDERD_RAGON_PHASE = new MetaIndex(EnderDragonWatcher.class, 0, 0); + + public static MetaIndex ENDERMAN_AGRESSIVE = new MetaIndex(EndermanWatcher.class, 1, false); + + public static MetaIndex> ENDERMAN_ITEM = new MetaIndex>( + EndermanWatcher.class, 0, Optional. absent()); + + public static MetaIndex ENTITY_AIR_TICKS = new MetaIndex(FlagWatcher.class, 1, 0); + + public static MetaIndex ENTITY_CUSTOM_NAME = new MetaIndex(FlagWatcher.class, 2, ""); + + public static MetaIndex ENTITY_CUSTOM_NAME_VISIBLE = new MetaIndex(FlagWatcher.class, 3, false); + + public static MetaIndex ENTITY_META = new MetaIndex(FlagWatcher.class, 0, (byte) 0); + + public static MetaIndex ENTITY_NO_GRAVITY = new MetaIndex(FlagWatcher.class, 5, false); + + public static MetaIndex ENTITY_SILENT = new MetaIndex(FlagWatcher.class, 4, false); + + public static MetaIndex EVOKER_SPELL_TICKS = new MetaIndex(EvokerWatcher.class, 0, (byte) 0); + + public static MetaIndex FALLING_BLOCK_POSITION = new MetaIndex(FallingBlockWatcher.class, 0, + BlockPosition.ORIGIN); + + public static MetaIndex FIREWORK_ITEM = new MetaIndex(FireworkWatcher.class, 0, + new ItemStack(Material.AIR)); + + public static MetaIndex FIREWORK_ATTACHED_ENTITY = new MetaIndex(FireworkWatcher.class, 1, 0); + + public static MetaIndex FISHING_HOOK_HOOKED = new MetaIndex(FishingHookWatcher.class, 0, 0); + + public static MetaIndex GHAST_AGRESSIVE = new MetaIndex(GhastWatcher.class, 0, false); + + public static MetaIndex GUARDIAN_RETRACT_SPIKES = new MetaIndex(GuardianWatcher.class, 0, false); + + public static MetaIndex GUARDIAN_TARGET = new MetaIndex(GuardianWatcher.class, 1, 0); + + public static MetaIndex HORSE_ARMOR = new MetaIndex(HorseWatcher.class, 1, 0); + + public static MetaIndex HORSE_CHESTED_CARRYING_CHEST = new MetaIndex(ChestedHorseWatcher.class, 0, false); + + public static MetaIndex HORSE_COLOR = new MetaIndex(HorseWatcher.class, 0, 0); + + public static MetaIndex HORSE_META = new MetaIndex(AbstractHorseWatcher.class, 0, (byte) 0); + + public static MetaIndex> HORSE_OWNER = new MetaIndex>(AbstractHorseWatcher.class, 1, + Optional. absent()); + + public static MetaIndex INSENTIENT_META = new MetaIndex(InsentientWatcher.class, 0, (byte) 0); + + public static MetaIndex IRON_GOLEM_PLAYER_CREATED = new MetaIndex(IronGolemWatcher.class, 0, (byte) 0); + + public static MetaIndex ITEMFRAME_ITEM = new MetaIndex(ItemFrameWatcher.class, 0, + new ItemStack(Material.AIR)); + + public static MetaIndex ITEMFRAME_ROTATION = new MetaIndex(ItemFrameWatcher.class, 1, 0); + + public static MetaIndex LIVING_ARROWS = new MetaIndex(LivingWatcher.class, 4, 0); + + public static MetaIndex LIVING_HAND = new MetaIndex(LivingWatcher.class, 0, (byte) 0); + + public static MetaIndex LIVING_HEALTH = new MetaIndex(LivingWatcher.class, 1, 1F); + + public static MetaIndex LIVING_POTION_AMBIENT = new MetaIndex(LivingWatcher.class, 3, false); + + public static MetaIndex LIVING_POTIONS = new MetaIndex(LivingWatcher.class, 2, 0); + + public static MetaIndex LLAMA_CARPET = new MetaIndex(LlamaWatcher.class, 1, 0); + + public static MetaIndex LLAMA_COLOR = new MetaIndex(LlamaWatcher.class, 2, -1); + + public static MetaIndex LLAMA_STRENGTH = new MetaIndex(LlamaWatcher.class, 0, 0); + + public static MetaIndex MINECART_BLOCK = new MetaIndex(MinecartWatcher.class, 3, 0); + + public static MetaIndex MINECART_BLOCK_VISIBLE = new MetaIndex(MinecartWatcher.class, 5, false); + + public static MetaIndex MINECART_BLOCK_Y = new MetaIndex(MinecartWatcher.class, 4, 0); + + public static MetaIndex MINECART_SHAKING_DIRECTION = new MetaIndex(MinecartWatcher.class, 1, 1); + + public static MetaIndex MINECART_SHAKING_MULITPLIER = new MetaIndex(MinecartWatcher.class, 2, 0F); + + public static MetaIndex MINECART_SHAKING_POWER = new MetaIndex(MinecartWatcher.class, 0, 0); + + public static MetaIndex OCELOT_TYPE = new MetaIndex(OcelotWatcher.class, 0, 0); + + public static MetaIndex PIG_SADDLED = new MetaIndex(PigWatcher.class, 0, false); + + public static MetaIndex PIG_UNKNOWN = new MetaIndex(PigWatcher.class, 1, 0); + + public static MetaIndex PLAYER_ABSORPTION = new MetaIndex(PlayerWatcher.class, 0, 0F); + + public static MetaIndex PLAYER_HAND = new MetaIndex(PlayerWatcher.class, 3, (byte) 0); + + public static MetaIndex PLAYER_SCORE = new MetaIndex(PlayerWatcher.class, 1, 0); + + public static MetaIndex PLAYER_SKIN = new MetaIndex(PlayerWatcher.class, 2, (byte) 127); + + public static MetaIndex POLAR_BEAR_STANDING = new MetaIndex(PolarBearWatcher.class, 0, false); + + public static MetaIndex RABBIT_TYPE = new MetaIndex(RabbitWatcher.class, 0, 0); + + public static MetaIndex SHEEP_WOOL = new MetaIndex(SheepWatcher.class, 0, (byte) 0); + + public static MetaIndex> SHULKER_ATTACHED = new MetaIndex>(ShulkerWatcher.class, + 1, Optional. absent()); + + public static MetaIndex SHULKER_COLOR = new MetaIndex(ShulkerWatcher.class, 3, (byte) 10); + + public static MetaIndex SHULKER_FACING = new MetaIndex(ShulkerWatcher.class, 0, Direction.DOWN); + + public static MetaIndex SHULKER_PEEKING = new MetaIndex(ShulkerWatcher.class, 2, (byte) 0); + + public static MetaIndex SKELETON_SWING_ARMS = new MetaIndex(SkeletonWatcher.class, 0, false); + + public static MetaIndex SLIME_SIZE = new MetaIndex(SlimeWatcher.class, 0, 0); + + public static MetaIndex SNOWMAN_DERP = new MetaIndex(SnowmanWatcher.class, 0, (byte) 0); + + public static MetaIndex SPIDER_CLIMB = new MetaIndex(SpiderWatcher.class, 0, (byte) 0); + + public static MetaIndex SPLASH_POTION_ITEM = new MetaIndex(SplashPotionWatcher.class, 1, + new ItemStack(Material.SPLASH_POTION)); // Yeah, the '1' isn't a bug. No idea why but MC thinks + // there's a '0' already. + + public static MetaIndex SPLASH_POTION_ITEM_BAD = new MetaIndex(SplashPotionWatcher.class, 0, + new ItemStack(Material.SPLASH_POTION)); // Yeah, the '1' isn't a bug. No + // idea why but MC thinks there's a + // '0' already. + + public static MetaIndex TAMEABLE_META = new MetaIndex(TameableWatcher.class, 0, (byte) 0); + + public static MetaIndex> TAMEABLE_OWNER = new MetaIndex>(TameableWatcher.class, 1, + Optional. absent()); + + public static MetaIndex TIPPED_ARROW_COLOR = new MetaIndex(ArrowWatcher.class, 1, Color.WHITE.asRGB()); + + public static MetaIndex TNT_FUSE_TICKS = new MetaIndex(TNTWatcher.class, 0, Integer.MAX_VALUE); + + public static MetaIndex VEX_ANGRY = new MetaIndex(VexWatcher.class, 0, (byte) 0); + + public static MetaIndex VILLAGER_PROFESSION = new MetaIndex(VillagerWatcher.class, 0, 0); + + public static MetaIndex VINDICATOR_JOHNNY = new MetaIndex(VindicatorWatcher.class, 0, (byte) 0); + + public static MetaIndex WITCH_AGGRESSIVE = new MetaIndex(WitchWatcher.class, 0, false); + + public static MetaIndex WITHER_INVUL = new MetaIndex(WitherWatcher.class, 3, 0); + + public static MetaIndex WITHER_TARGET_1 = new MetaIndex(WitherWatcher.class, 0, 0); + + public static MetaIndex WITHER_TARGET_2 = new MetaIndex(WitherWatcher.class, 1, 0); + + public static MetaIndex WITHER_TARGET_3 = new MetaIndex(WitherWatcher.class, 2, 0); + + public static MetaIndex WITHER_SKULL_BLUE = new MetaIndex(WitherSkullWatcher.class, 0, false); + + public static MetaIndex WOLF_BEGGING = new MetaIndex(WolfWatcher.class, 1, false); + + public static MetaIndex WOLF_COLLAR = new MetaIndex(WolfWatcher.class, 2, 14); + + public static MetaIndex WOLF_DAMAGE = new MetaIndex(WolfWatcher.class, 0, 0F); + + public static MetaIndex ZOMBIE_AGGRESSIVE = new MetaIndex(ZombieWatcher.class, 2, false); + + public static MetaIndex ZOMBIE_BABY = new MetaIndex(ZombieWatcher.class, 0, false); + + public static MetaIndex ZOMBIE_PLACEHOLDER = new MetaIndex(ZombieWatcher.class, 1, 0); + + public static MetaIndex ZOMBIE_VILLAGER_PROFESSION = new MetaIndex(ZombieVillagerWatcher.class, 1, 0); + + public static MetaIndex ZOMBIE_VILLAGER_SHAKING = new MetaIndex(ZombieVillagerWatcher.class, 0, false); + + static { + for (MetaIndex flagType : values()) { + if (flagType.getFlagWatcher() == FlagWatcher.class) + continue; + + flagType._index += getNoIndexes(flagType.getFlagWatcher().getSuperclass()); + + } + + // Simple verification for the dev that he's setting up the FlagType's properly. + // All flag types should be from 0 to with no empty numbers. + // All flag types should never occur twice. + + HashMap maxValues = new HashMap(); + + for (MetaIndex type : values()) { + if (maxValues.containsKey(type.getFlagWatcher()) && maxValues.get(type.getFlagWatcher()) > type.getIndex()) + continue; + + maxValues.put(type.getFlagWatcher(), type.getIndex()); + } + + for (Entry entry : maxValues.entrySet()) { + loop: + + for (int i = 0; i < entry.getValue(); i++) { + MetaIndex found = null; + + for (MetaIndex type : values()) { + if (type.getIndex() != i) + continue; + + if (!type.getFlagWatcher().isAssignableFrom(entry.getKey())) + continue; + + if (found != null) { + System.err.println(entry.getKey().getSimpleName() + " has multiple FlagType's registered for the index " + + i + " (" + type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName() + + ")"); + continue loop; + } + + found = type; + } + + if (found != null) + continue; + + System.err.println(entry.getKey().getSimpleName() + " has no FlagType registered for the index " + i); + } + } + } + + public static MetaIndex getFlag(Class watcherClass, int flagNo) { + for (MetaIndex type : values()) { + if (type.getIndex() != flagNo) + continue; + + if (!type.getFlagWatcher().isAssignableFrom(watcherClass)) + continue; + + return type; + } + + return null; + } + + public static ArrayList getFlags(Class watcherClass) { + ArrayList list = new ArrayList(); + + for (MetaIndex type : values()) { + if (!type.getFlagWatcher().isAssignableFrom(watcherClass)) + continue; + + list.add(type); + } + + return list; + } + + private static int getNoIndexes(Class c) { + int found = 0; + + for (MetaIndex type : values()) { + if (type.getFlagWatcher() != c) + continue; + + found++; + } + + if (c != FlagWatcher.class) { + found += getNoIndexes(c.getSuperclass()); + } + + return found; + } + + public static MetaIndex[] values() { + return _values; + } + + private Y _defaultValue; + private int _index; + private Class _watcher; + + private MetaIndex(Class watcher, int index, Y defaultValue) { + _index = index; + _watcher = watcher; + _defaultValue = defaultValue; + + _values = Arrays.copyOf(_values, _values.length + 1); + _values[_values.length - 1] = this; + } + + public Y getDefault() { + return _defaultValue; + } + + public Class getFlagWatcher() { + return _watcher; + } + + public int getIndex() { + return _index; + } +} diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/AbstractHorseWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/AbstractHorseWatcher.java index 1a0ce803..d2d0b1ce 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/AbstractHorseWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/AbstractHorseWatcher.java @@ -5,7 +5,7 @@ import java.util.UUID; import com.google.common.base.Optional; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class AbstractHorseWatcher extends AgeableWatcher { public AbstractHorseWatcher(Disguise disguise) { @@ -13,7 +13,7 @@ public class AbstractHorseWatcher extends AgeableWatcher { } public Optional getOwner() { - return getData(FlagType.HORSE_OWNER); + return getData(MetaIndex.HORSE_OWNER); } public boolean hasChest() { @@ -49,7 +49,7 @@ public class AbstractHorseWatcher extends AgeableWatcher { } private byte getHorseFlag() { - return getData(FlagType.HORSE_META); + return getData(MetaIndex.HORSE_META); } public void setCanBreed(boolean breed) { @@ -61,16 +61,16 @@ public class AbstractHorseWatcher extends AgeableWatcher { } private void setHorseFlag(int i, boolean flag) { - byte j = getData(FlagType.HORSE_META); + byte j = getData(MetaIndex.HORSE_META); if (flag) { - setData(FlagType.HORSE_META, (byte) (j | i)); + setData(MetaIndex.HORSE_META, (byte) (j | i)); } else { - setData(FlagType.HORSE_META, (byte) (j & ~i)); + setData(MetaIndex.HORSE_META, (byte) (j & ~i)); } - sendData(FlagType.HORSE_META); + sendData(MetaIndex.HORSE_META); } public void setGrazing(boolean grazing) { @@ -82,8 +82,8 @@ public class AbstractHorseWatcher extends AgeableWatcher { } public void setOwner(UUID uuid) { - setData(FlagType.HORSE_OWNER, Optional.of(uuid)); - sendData(FlagType.HORSE_OWNER); + setData(MetaIndex.HORSE_OWNER, Optional.of(uuid)); + sendData(MetaIndex.HORSE_OWNER); } public void setRearing(boolean rear) { diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java index 4d079570..b2cdaf26 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class AgeableWatcher extends InsentientWatcher { @@ -17,7 +17,7 @@ public class AgeableWatcher extends InsentientWatcher public boolean isBaby() { - return getData(FlagType.AGEABLE_BABY); + return getData(MetaIndex.AGEABLE_BABY); } public void setAdult() @@ -32,7 +32,7 @@ public class AgeableWatcher extends InsentientWatcher public void setBaby(boolean isBaby) { - setData(FlagType.AGEABLE_BABY, isBaby); - sendData(FlagType.AGEABLE_BABY); + setData(MetaIndex.AGEABLE_BABY, isBaby); + sendData(MetaIndex.AGEABLE_BABY); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java index c50f850d..ecf3f631 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; /** @@ -16,35 +16,35 @@ public class AreaEffectCloudWatcher extends FlagWatcher { } public float getRadius() { - return getData(FlagType.AREA_EFFECT_RADIUS); + return getData(MetaIndex.AREA_EFFECT_RADIUS); } public int getColor() { - return getData(FlagType.AREA_EFFECT_CLOUD_COLOR); + return getData(MetaIndex.AREA_EFFECT_CLOUD_COLOR); } public boolean isIgnoreRadius() { - return getData(FlagType.AREA_EFFECT_IGNORE_RADIUS); + return getData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS); } public int getParticleId() { - return getData(FlagType.AREA_EFFECT_PARTICLE); + return getData(MetaIndex.AREA_EFFECT_PARTICLE); } public void setRadius(float radius) { - setData(FlagType.AREA_EFFECT_RADIUS, radius); + setData(MetaIndex.AREA_EFFECT_RADIUS, radius); } public void setColor(int color) { - setData(FlagType.AREA_EFFECT_CLOUD_COLOR, color); + setData(MetaIndex.AREA_EFFECT_CLOUD_COLOR, color); } public void setIgnoreRadius(boolean ignore) { - setData(FlagType.AREA_EFFECT_IGNORE_RADIUS, ignore); + setData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS, ignore); } public void setParticleId(int particleId) { - setData(FlagType.AREA_EFFECT_PARTICLE, particleId); + setData(MetaIndex.AREA_EFFECT_PARTICLE, particleId); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java index d727805a..72ebe787 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ArmorStandWatcher.java @@ -5,7 +5,7 @@ import org.bukkit.util.EulerAngle; import com.comphenix.protocol.wrappers.Vector3F; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class ArmorStandWatcher extends LivingWatcher { @@ -16,30 +16,30 @@ public class ArmorStandWatcher extends LivingWatcher private boolean getArmorStandFlag(int value) { - return (getData(FlagType.ARMORSTAND_META) & value) != 0; + return (getData(MetaIndex.ARMORSTAND_META) & value) != 0; } public EulerAngle getBody() { - return getPose(FlagType.ARMORSTAND_BODY); + return getPose(MetaIndex.ARMORSTAND_BODY); } public EulerAngle getHead() { - return getPose(FlagType.ARMORSTAND_HEAD); + return getPose(MetaIndex.ARMORSTAND_HEAD); } public EulerAngle getLeftArm() { - return getPose(FlagType.ARMORSTAND_LEFT_ARM); + return getPose(MetaIndex.ARMORSTAND_LEFT_ARM); } public EulerAngle getLeftLeg() { - return getPose(FlagType.ARMORSTAND_LEFT_LEG); + return getPose(MetaIndex.ARMORSTAND_LEFT_LEG); } - private EulerAngle getPose(FlagType type) + private EulerAngle getPose(MetaIndex type) { if (!hasValue(type)) return new EulerAngle(0, 0, 0); @@ -51,12 +51,12 @@ public class ArmorStandWatcher extends LivingWatcher public EulerAngle getRightArm() { - return getPose(FlagType.ARMORSTAND_RIGHT_ARM); + return getPose(MetaIndex.ARMORSTAND_RIGHT_ARM); } public EulerAngle getRightLeg() { - return getPose(FlagType.ARMORSTAND_RIGHT_LEG); + return getPose(MetaIndex.ARMORSTAND_RIGHT_LEG); } public boolean isMarker() @@ -86,7 +86,7 @@ public class ArmorStandWatcher extends LivingWatcher private void setArmorStandFlag(int value, boolean isTrue) { - byte b1 = (byte) getData(FlagType.ARMORSTAND_META); + byte b1 = (byte) getData(MetaIndex.ARMORSTAND_META); if (isTrue) { @@ -97,49 +97,49 @@ public class ArmorStandWatcher extends LivingWatcher b1 = (byte) (b1 & value); } - setData(FlagType.ARMORSTAND_META, b1); - sendData(FlagType.ARMORSTAND_META); + setData(MetaIndex.ARMORSTAND_META, b1); + sendData(MetaIndex.ARMORSTAND_META); } public void setBody(EulerAngle vector) { - setPose(FlagType.ARMORSTAND_BODY, vector); + setPose(MetaIndex.ARMORSTAND_BODY, vector); } public void setHead(EulerAngle vector) { - setPose(FlagType.ARMORSTAND_HEAD, vector); + setPose(MetaIndex.ARMORSTAND_HEAD, vector); } public void setLeftArm(EulerAngle vector) { - setPose(FlagType.ARMORSTAND_LEFT_ARM, vector); + setPose(MetaIndex.ARMORSTAND_LEFT_ARM, vector); } public void setLeftLeg(EulerAngle vector) { - setPose(FlagType.ARMORSTAND_LEFT_LEG, vector); + setPose(MetaIndex.ARMORSTAND_LEFT_LEG, vector); } public void setMarker(boolean isMarker) { setArmorStandFlag(10, isMarker); - sendData(FlagType.ARMORSTAND_META); + sendData(MetaIndex.ARMORSTAND_META); } public void setNoBasePlate(boolean noBasePlate) { setArmorStandFlag(8, noBasePlate); - sendData(FlagType.ARMORSTAND_META); + sendData(MetaIndex.ARMORSTAND_META); } public void setNoGravity(boolean noGravity) { setArmorStandFlag(2, noGravity); - sendData(FlagType.ARMORSTAND_META); + sendData(MetaIndex.ARMORSTAND_META); } - private void setPose(FlagType type, EulerAngle vector) + private void setPose(MetaIndex type, EulerAngle vector) { setData(type, new Vector3F((float) vector.getX(), (float) vector.getY(), (float) vector.getZ())); sendData(type); @@ -147,24 +147,24 @@ public class ArmorStandWatcher extends LivingWatcher public void setRightArm(EulerAngle vector) { - setPose(FlagType.ARMORSTAND_RIGHT_ARM, vector); + setPose(MetaIndex.ARMORSTAND_RIGHT_ARM, vector); } public void setRightLeg(EulerAngle vector) { - setPose(FlagType.ARMORSTAND_RIGHT_LEG, vector); + setPose(MetaIndex.ARMORSTAND_RIGHT_LEG, vector); } public void setShowArms(boolean showArms) { setArmorStandFlag(4, showArms); - sendData(FlagType.ARMORSTAND_META); + sendData(MetaIndex.ARMORSTAND_META); } public void setSmall(boolean isSmall) { setArmorStandFlag(1, isSmall); - sendData(FlagType.ARMORSTAND_META); + sendData(MetaIndex.ARMORSTAND_META); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java index 5cb77f0c..a84f534e 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ArrowWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; public class ArrowWatcher extends FlagWatcher @@ -13,12 +13,12 @@ public class ArrowWatcher extends FlagWatcher public boolean isCritical() { - return (byte) getData(FlagType.ARROW_CRITICAL) == 1; + return (byte) getData(MetaIndex.ARROW_CRITICAL) == 1; } public void setCritical(boolean critical) { - setData(FlagType.ARROW_CRITICAL, (byte) (critical ? 1 : 0)); - sendData(FlagType.ARROW_CRITICAL); + setData(MetaIndex.ARROW_CRITICAL, (byte) (critical ? 1 : 0)); + sendData(MetaIndex.ARROW_CRITICAL); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.java index 5101bd40..8f1340d0 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/BatWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class BatWatcher extends InsentientWatcher { @@ -15,12 +15,12 @@ public class BatWatcher extends InsentientWatcher public boolean isHanging() { - return ((byte) getData(FlagType.BAT_HANGING)) == 1; + return ((byte) getData(MetaIndex.BAT_HANGING)) == 1; } public void setHanging(boolean hanging) { - setData(FlagType.BAT_HANGING, hanging ? (byte) 1 : (byte) 0); - sendData(FlagType.BAT_HANGING); + setData(MetaIndex.BAT_HANGING, hanging ? (byte) 1 : (byte) 0); + sendData(MetaIndex.BAT_HANGING); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.java index 8ccfbfcf..1c37b8d6 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/BlazeWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class BlazeWatcher extends InsentientWatcher { @@ -12,13 +12,13 @@ public class BlazeWatcher extends InsentientWatcher public boolean isBlazing() { - return getData(FlagType.BLAZE_BLAZING) == 1; + return getData(MetaIndex.BLAZE_BLAZING) == 1; } public void setBlazing(boolean isBlazing) { - setData(FlagType.BLAZE_BLAZING, (byte) (isBlazing ? 1 : 0)); - sendData(FlagType.BLAZE_BLAZING); + setData(MetaIndex.BLAZE_BLAZING, (byte) (isBlazing ? 1 : 0)); + sendData(MetaIndex.BLAZE_BLAZING); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java index bbc25760..2517614a 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/BoatWatcher.java @@ -5,7 +5,7 @@ import java.util.Random; import org.bukkit.TreeSpecies; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; public class BoatWatcher extends FlagWatcher @@ -19,46 +19,46 @@ public class BoatWatcher extends FlagWatcher public float getDamage() { - return getData(FlagType.BOAT_DAMAGE); + return getData(MetaIndex.BOAT_DAMAGE); } public void setDamage(float dmg) { - setData(FlagType.BOAT_DAMAGE, dmg); - sendData(FlagType.BOAT_DAMAGE); + setData(MetaIndex.BOAT_DAMAGE, dmg); + sendData(MetaIndex.BOAT_DAMAGE); } public void setRightPaddling(boolean rightPaddling) { - setData(FlagType.BOAT_RIGHT_PADDLING, rightPaddling); - sendData(FlagType.BOAT_RIGHT_PADDLING); + setData(MetaIndex.BOAT_RIGHT_PADDLING, rightPaddling); + sendData(MetaIndex.BOAT_RIGHT_PADDLING); } public void setLeftPaddling(boolean leftPaddling) { - setData(FlagType.BOAT_LEFT_PADDLING, leftPaddling); - sendData(FlagType.BOAT_LEFT_PADDLING); + setData(MetaIndex.BOAT_LEFT_PADDLING, leftPaddling); + sendData(MetaIndex.BOAT_LEFT_PADDLING); } public boolean isRightPaddling() { - return getData(FlagType.BOAT_RIGHT_PADDLING); + return getData(MetaIndex.BOAT_RIGHT_PADDLING); } public boolean isLeftPaddling() { - return getData(FlagType.BOAT_LEFT_PADDLING); + return getData(MetaIndex.BOAT_LEFT_PADDLING); } public void setBoatType(TreeSpecies boatType) { - setData(FlagType.BOAT_TYPE, (int) boatType.getData()); - sendData(FlagType.BOAT_TYPE); + setData(MetaIndex.BOAT_TYPE, (int) boatType.getData()); + sendData(MetaIndex.BOAT_TYPE); } public TreeSpecies getBoatType() { - return TreeSpecies.getByData(getData(FlagType.BOAT_TYPE).byteValue()); + return TreeSpecies.getByData(getData(MetaIndex.BOAT_TYPE).byteValue()); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/ChestedHorseWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ChestedHorseWatcher.java index 2576f163..1b52923f 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/ChestedHorseWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ChestedHorseWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class ChestedHorseWatcher extends AbstractHorseWatcher { @@ -10,11 +10,11 @@ public class ChestedHorseWatcher extends AbstractHorseWatcher { } public void setCarryingChest(boolean carryingChest) { - setData(FlagType.HORSE_CHESTED_CARRYING_CHEST, carryingChest); - sendData(FlagType.HORSE_CHESTED_CARRYING_CHEST); + setData(MetaIndex.HORSE_CHESTED_CARRYING_CHEST, carryingChest); + sendData(MetaIndex.HORSE_CHESTED_CARRYING_CHEST); } public boolean isCarryingChest() { - return getData(FlagType.HORSE_CHESTED_CARRYING_CHEST); + return getData(MetaIndex.HORSE_CHESTED_CARRYING_CHEST); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java index b17dc251..914cbdb9 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class CreeperWatcher extends InsentientWatcher { @@ -13,24 +13,24 @@ public class CreeperWatcher extends InsentientWatcher public boolean isIgnited() { - return (boolean) getData(FlagType.CREEPER_IGNITED); + return (boolean) getData(MetaIndex.CREEPER_IGNITED); } public boolean isPowered() { - return (boolean) getData(FlagType.CREEPER_POWERED); + return (boolean) getData(MetaIndex.CREEPER_POWERED); } public void setIgnited(boolean ignited) { - setData(FlagType.CREEPER_IGNITED, ignited); - sendData(FlagType.CREEPER_IGNITED); + setData(MetaIndex.CREEPER_IGNITED, ignited); + sendData(MetaIndex.CREEPER_IGNITED); } public void setPowered(boolean powered) { - setData(FlagType.CREEPER_POWERED, powered); - sendData(FlagType.CREEPER_POWERED); + setData(MetaIndex.CREEPER_POWERED, powered); + sendData(MetaIndex.CREEPER_POWERED); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java index 8c2ccdc9..66c4de8f 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/DroppedItemWatcher.java @@ -3,7 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import org.bukkit.inventory.ItemStack; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; public class DroppedItemWatcher extends FlagWatcher { @@ -12,11 +12,11 @@ public class DroppedItemWatcher extends FlagWatcher { } public ItemStack getItemStack() { - return getData(FlagType.DROPPED_ITEM); + return getData(MetaIndex.DROPPED_ITEM); } public void setItemStack(ItemStack item) { - setData(FlagType.DROPPED_ITEM, item); - sendData(FlagType.DROPPED_ITEM); + setData(MetaIndex.DROPPED_ITEM, item); + sendData(MetaIndex.DROPPED_ITEM); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java index 7e69b80a..1f80ff32 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/EnderCrystalWatcher.java @@ -4,7 +4,7 @@ import com.comphenix.protocol.wrappers.BlockPosition; import com.google.common.base.Optional; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; /** @@ -19,24 +19,24 @@ public class EnderCrystalWatcher extends FlagWatcher public void setBeamTarget(BlockPosition position) { - setData(FlagType.ENDER_CRYSTAL_BEAM, Optional.of(position)); - sendData(FlagType.ENDER_CRYSTAL_BEAM); + setData(MetaIndex.ENDER_CRYSTAL_BEAM, Optional.of(position)); + sendData(MetaIndex.ENDER_CRYSTAL_BEAM); } public Optional getBeamTarget() { - return getData(FlagType.ENDER_CRYSTAL_BEAM); + return getData(MetaIndex.ENDER_CRYSTAL_BEAM); } public void setShowBottom(boolean bool) { - setData(FlagType.ENDER_CRYSTAL_PLATE, bool); - sendData(FlagType.ENDER_CRYSTAL_PLATE); + setData(MetaIndex.ENDER_CRYSTAL_PLATE, bool); + sendData(MetaIndex.ENDER_CRYSTAL_PLATE); } public boolean isShowBottom() { - return getData(FlagType.ENDER_CRYSTAL_PLATE); + return getData(MetaIndex.ENDER_CRYSTAL_PLATE); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.java index c0a31566..79298032 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/EnderDragonWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; /** * @author Navid @@ -16,12 +16,12 @@ public class EnderDragonWatcher extends InsentientWatcher public int getPhase() { - return getData(FlagType.ENDERD_RAGON_PHASE); + return getData(MetaIndex.ENDERD_RAGON_PHASE); } public void setPhase(int phase) { - setData(FlagType.ENDERD_RAGON_PHASE, phase); - sendData(FlagType.ENDERD_RAGON_PHASE); + setData(MetaIndex.ENDERD_RAGON_PHASE, phase); + sendData(MetaIndex.ENDERD_RAGON_PHASE); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java index 5388cfad..c2b501ea 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java @@ -7,7 +7,7 @@ import com.comphenix.protocol.wrappers.WrappedBlockData; import com.google.common.base.Optional; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class EndermanWatcher extends InsentientWatcher { @@ -20,7 +20,7 @@ public class EndermanWatcher extends InsentientWatcher @Override public ItemStack getItemInMainHand() { - Optional value = getData(FlagType.ENDERMAN_ITEM); + Optional value = getData(MetaIndex.ENDERMAN_ITEM); if (value.isPresent()) { @@ -62,7 +62,7 @@ public class EndermanWatcher extends InsentientWatcher else optional = Optional. of(WrappedBlockData.createData(type, data)); - setData(FlagType.ENDERMAN_ITEM, optional); + setData(MetaIndex.ENDERMAN_ITEM, optional); } @Deprecated @@ -73,13 +73,13 @@ public class EndermanWatcher extends InsentientWatcher public boolean isAggressive() { - return getData(FlagType.ENDERMAN_AGRESSIVE); + return getData(MetaIndex.ENDERMAN_AGRESSIVE); } public void setAggressive(boolean isAggressive) { - setData(FlagType.ENDERMAN_AGRESSIVE, isAggressive); - sendData(FlagType.ENDERMAN_AGRESSIVE); + setData(MetaIndex.ENDERMAN_AGRESSIVE, isAggressive); + sendData(MetaIndex.ENDERMAN_AGRESSIVE); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/EvokerWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/EvokerWatcher.java index c4b0d954..866e60f4 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/EvokerWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/EvokerWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class EvokerWatcher extends InsentientWatcher { @@ -10,11 +10,11 @@ public class EvokerWatcher extends InsentientWatcher { } public void setSpellTicks(int spellTicks) { - setData(FlagType.EVOKER_SPELL_TICKS, (byte) spellTicks); - sendData(FlagType.EVOKER_SPELL_TICKS); + setData(MetaIndex.EVOKER_SPELL_TICKS, (byte) spellTicks); + sendData(MetaIndex.EVOKER_SPELL_TICKS); } public int getSpellTicks() { - return getData(FlagType.EVOKER_SPELL_TICKS); + return getData(MetaIndex.EVOKER_SPELL_TICKS); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/FireworkWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/FireworkWatcher.java index 22f60d21..3117c6f9 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/FireworkWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/FireworkWatcher.java @@ -4,7 +4,7 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; public class FireworkWatcher extends FlagWatcher { @@ -13,11 +13,11 @@ public class FireworkWatcher extends FlagWatcher { } public ItemStack getFirework() { - if (getData(FlagType.FIREWORK_ITEM) == null) { + if (getData(MetaIndex.FIREWORK_ITEM) == null) { return new ItemStack(Material.AIR); } - return (ItemStack) getData(FlagType.FIREWORK_ITEM); + return (ItemStack) getData(MetaIndex.FIREWORK_ITEM); } public void setFirework(ItemStack newItem) { @@ -28,16 +28,16 @@ public class FireworkWatcher extends FlagWatcher { newItem = newItem.clone(); newItem.setAmount(1); - setData(FlagType.FIREWORK_ITEM, newItem); - sendData(FlagType.FIREWORK_ITEM); + setData(MetaIndex.FIREWORK_ITEM, newItem); + sendData(MetaIndex.FIREWORK_ITEM); } public void setAttachedEntity(int entityId) { - setData(FlagType.FIREWORK_ATTACHED_ENTITY, entityId); - sendData(FlagType.FIREWORK_ATTACHED_ENTITY); + setData(MetaIndex.FIREWORK_ATTACHED_ENTITY, entityId); + sendData(MetaIndex.FIREWORK_ATTACHED_ENTITY); } public int getAttachedEntity() { - return getData(FlagType.FIREWORK_ATTACHED_ENTITY); + return getData(MetaIndex.FIREWORK_ATTACHED_ENTITY); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/FishingHookWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/FishingHookWatcher.java index cb2a0d46..a9dae947 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/FishingHookWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/FishingHookWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; public class FishingHookWatcher extends FlagWatcher @@ -13,13 +13,13 @@ public class FishingHookWatcher extends FlagWatcher public void setHooked(int hookedId) { - setData(FlagType.FISHING_HOOK_HOOKED, hookedId + 1); - sendData(FlagType.FISHING_HOOK_HOOKED); + setData(MetaIndex.FISHING_HOOK_HOOKED, hookedId + 1); + sendData(MetaIndex.FISHING_HOOK_HOOKED); } public int getHooked() { - int hooked = getData(FlagType.FISHING_HOOK_HOOKED); + int hooked = getData(MetaIndex.FISHING_HOOK_HOOKED); if (hooked > 0) hooked--; diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java index 46cd3eb6..bf2f1b71 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class GhastWatcher extends InsentientWatcher { @@ -13,13 +13,13 @@ public class GhastWatcher extends InsentientWatcher public boolean isAggressive() { - return getData(FlagType.GHAST_AGRESSIVE); + return getData(MetaIndex.GHAST_AGRESSIVE); } public void setAggressive(boolean isAggressive) { - setData(FlagType.GHAST_AGRESSIVE, isAggressive); - sendData(FlagType.GHAST_AGRESSIVE); + setData(MetaIndex.GHAST_AGRESSIVE, isAggressive); + sendData(MetaIndex.GHAST_AGRESSIVE); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java index 3b259ed6..ae0c8c2b 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/GuardianWatcher.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class GuardianWatcher extends InsentientWatcher { public GuardianWatcher(Disguise disguise) { @@ -18,7 +18,7 @@ public class GuardianWatcher extends InsentientWatcher { * @return */ public boolean isTarget() { - return ((int) getData(FlagType.GUARDIAN_TARGET)) != 0; + return ((int) getData(MetaIndex.GUARDIAN_TARGET)) != 0; } /** @@ -27,8 +27,8 @@ public class GuardianWatcher extends InsentientWatcher { * @param entityId */ public void setTarget(int entityId) { - setData(FlagType.GUARDIAN_TARGET, entityId); - sendData(FlagType.GUARDIAN_TARGET); + setData(MetaIndex.GUARDIAN_TARGET, entityId); + sendData(MetaIndex.GUARDIAN_TARGET); } public void setTarget(Entity entity) { @@ -46,17 +46,17 @@ public class GuardianWatcher extends InsentientWatcher { if (player == null) return; - setData(FlagType.GUARDIAN_TARGET, player.getEntityId()); - sendData(FlagType.GUARDIAN_TARGET); + setData(MetaIndex.GUARDIAN_TARGET, player.getEntityId()); + sendData(MetaIndex.GUARDIAN_TARGET); } public boolean isRetractingSpikes() { - return getData(FlagType.GUARDIAN_RETRACT_SPIKES); + return getData(MetaIndex.GUARDIAN_RETRACT_SPIKES); } public void setRetractingSpikes(boolean isRetracting) { - setData(FlagType.GUARDIAN_RETRACT_SPIKES, isRetracting); - sendData(FlagType.GUARDIAN_RETRACT_SPIKES); + setData(MetaIndex.GUARDIAN_RETRACT_SPIKES, isRetracting); + sendData(MetaIndex.GUARDIAN_RETRACT_SPIKES); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java index da5fb93e..d8a0f57b 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Horse.Style; import org.bukkit.inventory.ItemStack; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.utilities.DisguiseUtilities; public class HorseWatcher extends AbstractHorseWatcher { @@ -18,7 +18,7 @@ public class HorseWatcher extends AbstractHorseWatcher { } public Color getColor() { - return Color.values()[((Integer) getData(FlagType.HORSE_COLOR) & 0xFF)]; + return Color.values()[((Integer) getData(MetaIndex.HORSE_COLOR) & 0xFF)]; } public ItemStack getHorseArmor() { @@ -39,26 +39,26 @@ public class HorseWatcher extends AbstractHorseWatcher { } public Style getStyle() { - return Style.values()[(getData(FlagType.HORSE_COLOR) >>> 8)]; + return Style.values()[(getData(MetaIndex.HORSE_COLOR) >>> 8)]; } public void setColor(Color color) { - setData(FlagType.HORSE_COLOR, color.ordinal() & 0xFF | getStyle().ordinal() << 8); - sendData(FlagType.HORSE_COLOR); + setData(MetaIndex.HORSE_COLOR, color.ordinal() & 0xFF | getStyle().ordinal() << 8); + sendData(MetaIndex.HORSE_COLOR); } protected int getHorseArmorAsInt() { - return getData(FlagType.HORSE_ARMOR); + return getData(MetaIndex.HORSE_ARMOR); } protected void setHorseArmor(int armor) { - setData(FlagType.HORSE_ARMOR, armor); - sendData(FlagType.HORSE_ARMOR); + setData(MetaIndex.HORSE_ARMOR, armor); + sendData(MetaIndex.HORSE_ARMOR); } public void setStyle(Style style) { - setData(FlagType.HORSE_COLOR, getColor().ordinal() & 0xFF | style.ordinal() << 8); - sendData(FlagType.HORSE_COLOR); + setData(MetaIndex.HORSE_COLOR, getColor().ordinal() & 0xFF | style.ordinal() << 8); + sendData(MetaIndex.HORSE_COLOR); } public void setHorseArmor(ItemStack item) { diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/InsentientWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/InsentientWatcher.java index 5a6dadae..ec770134 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/InsentientWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/InsentientWatcher.java @@ -3,7 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import org.bukkit.inventory.MainHand; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class InsentientWatcher extends LivingWatcher { @@ -15,7 +15,7 @@ public class InsentientWatcher extends LivingWatcher public void setMainHand(MainHand mainHand) { setInsentientFlag(2, mainHand == MainHand.RIGHT); - sendData(FlagType.INSENTIENT_META); + sendData(MetaIndex.INSENTIENT_META); } public MainHand getMainHand() @@ -31,25 +31,25 @@ public class InsentientWatcher extends LivingWatcher public void setAI(boolean ai) { setInsentientFlag(1, ai); - sendData(FlagType.INSENTIENT_META); + sendData(MetaIndex.INSENTIENT_META); } private void setInsentientFlag(int i, boolean flag) { - byte b0 = (byte) getData(FlagType.INSENTIENT_META); + byte b0 = (byte) getData(MetaIndex.INSENTIENT_META); if (flag) { - setData(FlagType.INSENTIENT_META, (byte) (b0 | 1 << i)); + setData(MetaIndex.INSENTIENT_META, (byte) (b0 | 1 << i)); } else { - setData(FlagType.INSENTIENT_META, (byte) (b0 & (~1 << i))); + setData(MetaIndex.INSENTIENT_META, (byte) (b0 & (~1 << i))); } } private boolean getInsentientFlag(int i) { - return ((byte) getData(FlagType.INSENTIENT_META) & 1 << i) != 0; + return ((byte) getData(MetaIndex.INSENTIENT_META) & 1 << i) != 0; } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.java index cc2533bb..1d7723fb 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ItemFrameWatcher.java @@ -4,7 +4,7 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; public class ItemFrameWatcher extends FlagWatcher { @@ -13,15 +13,15 @@ public class ItemFrameWatcher extends FlagWatcher { } public ItemStack getItem() { - if (getData(FlagType.ITEMFRAME_ITEM) == null) { + if (getData(MetaIndex.ITEMFRAME_ITEM) == null) { return new ItemStack(Material.AIR); } - return (ItemStack) getData(FlagType.ITEMFRAME_ITEM); + return (ItemStack) getData(MetaIndex.ITEMFRAME_ITEM); } public int getRotation() { - return getData(FlagType.ITEMFRAME_ROTATION); + return getData(MetaIndex.ITEMFRAME_ROTATION); } public void setItem(ItemStack newItem) { @@ -32,13 +32,13 @@ public class ItemFrameWatcher extends FlagWatcher { newItem = newItem.clone(); newItem.setAmount(1); - setData(FlagType.ITEMFRAME_ITEM, newItem); - sendData(FlagType.ITEMFRAME_ITEM); + setData(MetaIndex.ITEMFRAME_ITEM, newItem); + sendData(MetaIndex.ITEMFRAME_ITEM); } public void setRotation(int rotation) { - setData(FlagType.ITEMFRAME_ROTATION, rotation % 4); - sendData(FlagType.ITEMFRAME_ROTATION); + setData(MetaIndex.ITEMFRAME_ROTATION, rotation % 4); + sendData(MetaIndex.ITEMFRAME_ROTATION); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java index a1942626..186a9dfe 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java @@ -20,7 +20,7 @@ import com.comphenix.protocol.wrappers.WrappedAttribute.Builder; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.ReflectionManager; @@ -72,7 +72,7 @@ public class LivingWatcher extends FlagWatcher { } public float getHealth() { - return (float) getData(FlagType.LIVING_HEALTH); + return (float) getData(MetaIndex.LIVING_HEALTH); } public double getMaxHealth() { @@ -80,7 +80,7 @@ public class LivingWatcher extends FlagWatcher { } public boolean isPotionParticlesAmbient() { - return (boolean) getData(FlagType.LIVING_POTION_AMBIENT); + return (boolean) getData(MetaIndex.LIVING_POTION_AMBIENT); } private int getPotions() { @@ -130,27 +130,27 @@ public class LivingWatcher extends FlagWatcher { } public void setPotionParticlesAmbient(boolean particles) { - setData(FlagType.LIVING_POTION_AMBIENT, particles); - sendData(FlagType.LIVING_POTION_AMBIENT); + setData(MetaIndex.LIVING_POTION_AMBIENT, particles); + sendData(MetaIndex.LIVING_POTION_AMBIENT); } private void sendPotionEffects() { - setData(FlagType.LIVING_POTIONS, getPotions()); - sendData(FlagType.LIVING_POTIONS); + setData(MetaIndex.LIVING_POTIONS, getPotions()); + sendData(MetaIndex.LIVING_POTIONS); } public void setHealth(float health) { - setData(FlagType.LIVING_HEALTH, health); - sendData(FlagType.LIVING_HEALTH); + setData(MetaIndex.LIVING_HEALTH, health); + sendData(MetaIndex.LIVING_HEALTH); } public int getArrowsSticking() { - return (int) getData(FlagType.LIVING_ARROWS); + return (int) getData(MetaIndex.LIVING_ARROWS); } public void setArrowsSticking(int arrowsNo) { - setData(FlagType.LIVING_ARROWS, arrowsNo); - sendData(FlagType.LIVING_ARROWS); + setData(MetaIndex.LIVING_ARROWS, arrowsNo); + sendData(MetaIndex.LIVING_ARROWS); } public void setMaxHealth(double newHealth) { diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/LlamaWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/LlamaWatcher.java index 5b2fc361..f7bbc335 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/LlamaWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/LlamaWatcher.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Llama; import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class LlamaWatcher extends ChestedHorseWatcher { @@ -13,30 +13,30 @@ public class LlamaWatcher extends ChestedHorseWatcher { } public void setColor(Llama.Color color) { - setData(FlagType.LLAMA_COLOR, color.ordinal()); - sendData(FlagType.LLAMA_COLOR); + setData(MetaIndex.LLAMA_COLOR, color.ordinal()); + sendData(MetaIndex.LLAMA_COLOR); } public Llama.Color getColor() { - return Llama.Color.values()[getData(FlagType.LLAMA_COLOR)]; + return Llama.Color.values()[getData(MetaIndex.LLAMA_COLOR)]; } public void setCarpet(AnimalColor color) { - setData(FlagType.LLAMA_CARPET, color.getId()); - sendData(FlagType.LLAMA_CARPET); + setData(MetaIndex.LLAMA_CARPET, color.getId()); + sendData(MetaIndex.LLAMA_CARPET); } public AnimalColor getCarpet() { - return AnimalColor.getColor(getData(FlagType.LLAMA_CARPET)); + return AnimalColor.getColor(getData(MetaIndex.LLAMA_CARPET)); } public void setStrength(int strength) { - setData(FlagType.LLAMA_STRENGTH, strength); - sendData(FlagType.LLAMA_STRENGTH); + setData(MetaIndex.LLAMA_STRENGTH, strength); + sendData(MetaIndex.LLAMA_STRENGTH); } public int getStrength() { - return getData(FlagType.LLAMA_STRENGTH); + return getData(MetaIndex.LLAMA_STRENGTH); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.java index 4597c618..e2284b18 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/MinecartWatcher.java @@ -3,7 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import org.bukkit.inventory.ItemStack; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; public class MinecartWatcher extends FlagWatcher @@ -16,20 +16,20 @@ public class MinecartWatcher extends FlagWatcher public ItemStack getBlockInCart() { - int id = (int) getData(FlagType.MINECART_BLOCK) & 0xffff; - int data = (int) getData(FlagType.MINECART_BLOCK) >> 16; + int id = (int) getData(MetaIndex.MINECART_BLOCK) & 0xffff; + int data = (int) getData(MetaIndex.MINECART_BLOCK) >> 16; return new ItemStack(id, 1, (short) data); } public int getBlockYOffset() { - return (int) getData(FlagType.MINECART_BLOCK_Y); + return (int) getData(MetaIndex.MINECART_BLOCK_Y); } public boolean isViewBlockInCart() { - return (boolean) getData(FlagType.MINECART_BLOCK_VISIBLE); + return (boolean) getData(MetaIndex.MINECART_BLOCK_VISIBLE); } public void setBlockInCart(ItemStack item) @@ -37,21 +37,21 @@ public class MinecartWatcher extends FlagWatcher int id = item.getTypeId(); int data = item.getDurability(); - setData(FlagType.MINECART_BLOCK, id & 0xffff | data << 16); - setData(FlagType.MINECART_BLOCK_VISIBLE, true); // Show block + setData(MetaIndex.MINECART_BLOCK, id & 0xffff | data << 16); + setData(MetaIndex.MINECART_BLOCK_VISIBLE, true); // Show block - sendData(FlagType.MINECART_BLOCK); + sendData(MetaIndex.MINECART_BLOCK); } public void setBlockOffset(int i) { - setData(FlagType.MINECART_BLOCK_Y, i); - sendData(FlagType.MINECART_BLOCK_Y); + setData(MetaIndex.MINECART_BLOCK_Y, i); + sendData(MetaIndex.MINECART_BLOCK_Y); } public void setViewBlockInCart(boolean viewBlock) { - setData(FlagType.MINECART_BLOCK_VISIBLE, viewBlock); - sendData(FlagType.MINECART_BLOCK_VISIBLE); + setData(MetaIndex.MINECART_BLOCK_VISIBLE, viewBlock); + sendData(MetaIndex.MINECART_BLOCK_VISIBLE); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java index 4c1e2cc3..db81accb 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Ocelot; import org.bukkit.entity.Ocelot.Type; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class OcelotWatcher extends TameableWatcher { @@ -16,12 +16,12 @@ public class OcelotWatcher extends TameableWatcher public Type getType() { - return Ocelot.Type.getType(getData(FlagType.OCELOT_TYPE)); + return Ocelot.Type.getType(getData(MetaIndex.OCELOT_TYPE)); } public void setType(Type newType) { - setData(FlagType.OCELOT_TYPE, newType.getId()); - sendData(FlagType.OCELOT_TYPE); + setData(MetaIndex.OCELOT_TYPE, newType.getId()); + sendData(MetaIndex.OCELOT_TYPE); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.java index 4296b48b..df69585e 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/PigWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class PigWatcher extends AgeableWatcher { @@ -10,12 +10,12 @@ public class PigWatcher extends AgeableWatcher { } public boolean isSaddled() { - return (boolean) getData(FlagType.PIG_SADDLED); + return (boolean) getData(MetaIndex.PIG_SADDLED); } public void setSaddled(boolean isSaddled) { - setData(FlagType.PIG_SADDLED, isSaddled); - sendData(FlagType.PIG_SADDLED); + setData(MetaIndex.PIG_SADDLED, isSaddled); + sendData(MetaIndex.PIG_SADDLED); } /* public int getUnknown() { diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java index 8357342c..abf36505 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java @@ -13,7 +13,7 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; import me.libraryaddict.disguise.utilities.DisguiseUtilities; @@ -25,7 +25,7 @@ public class PlayerWatcher extends LivingWatcher { public PlayerWatcher(Disguise disguise) { super(disguise); - setData(FlagType.PLAYER_SKIN, FlagType.PLAYER_SKIN.getDefault()); + setData(MetaIndex.PLAYER_SKIN, MetaIndex.PLAYER_SKIN.getDefault()); } public boolean isDisplayedInTab() { @@ -49,12 +49,12 @@ public class PlayerWatcher extends LivingWatcher { } public void setMainHand(MainHand mainHand) { - setData(FlagType.PLAYER_HAND, (byte) mainHand.ordinal()); - sendData(FlagType.PLAYER_HAND); + setData(MetaIndex.PLAYER_HAND, (byte) mainHand.ordinal()); + sendData(MetaIndex.PLAYER_HAND); } public MainHand getMainHand() { - return MainHand.values()[getData(FlagType.PLAYER_HAND)]; + return MainHand.values()[getData(MetaIndex.PLAYER_HAND)]; } public BlockFace getSleepingDirection() { @@ -79,7 +79,7 @@ public class PlayerWatcher extends LivingWatcher { // Bit 6 (0x40): Hat enabled private boolean isSkinFlag(int i) { - return ((byte) getData(FlagType.PLAYER_SKIN) & 1 << i) != 0; + return ((byte) getData(MetaIndex.PLAYER_SKIN) & 1 << i) != 0; } public boolean isCapeEnabled() { @@ -113,43 +113,43 @@ public class PlayerWatcher extends LivingWatcher { public void setCapeEnabled(boolean enabled) { setSkinFlags(1, enabled); - sendData(FlagType.PLAYER_SKIN); + sendData(MetaIndex.PLAYER_SKIN); } public void setJacketEnabled(boolean enabled) { setSkinFlags(2, enabled); - sendData(FlagType.PLAYER_SKIN); + sendData(MetaIndex.PLAYER_SKIN); } public void setLeftSleeveEnabled(boolean enabled) { setSkinFlags(3, enabled); - sendData(FlagType.PLAYER_SKIN); + sendData(MetaIndex.PLAYER_SKIN); } public void setRightSleeveEnabled(boolean enabled) { setSkinFlags(4, enabled); - sendData(FlagType.PLAYER_SKIN); + sendData(MetaIndex.PLAYER_SKIN); } public void setLeftPantsEnabled(boolean enabled) { setSkinFlags(5, enabled); - sendData(FlagType.PLAYER_SKIN); + sendData(MetaIndex.PLAYER_SKIN); } public void setRightPantsEnabled(boolean enabled) { setSkinFlags(6, enabled); - sendData(FlagType.PLAYER_SKIN); + sendData(MetaIndex.PLAYER_SKIN); } public void setHatEnabled(boolean enabled) { setSkinFlags(7, enabled); - sendData(FlagType.PLAYER_SKIN); + sendData(MetaIndex.PLAYER_SKIN); } public boolean isSleeping() { @@ -228,13 +228,13 @@ public class PlayerWatcher extends LivingWatcher { } private void setSkinFlags(int i, boolean flag) { - byte b0 = (byte) getData(FlagType.PLAYER_SKIN); + byte b0 = (byte) getData(MetaIndex.PLAYER_SKIN); if (flag) { - setData(FlagType.PLAYER_SKIN, (byte) (b0 | 1 << i)); + setData(MetaIndex.PLAYER_SKIN, (byte) (b0 | 1 << i)); } else { - setData(FlagType.PLAYER_SKIN, (byte) (b0 & (~1 << i))); + setData(MetaIndex.PLAYER_SKIN, (byte) (b0 & (~1 << i))); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/PolarBearWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/PolarBearWatcher.java index 9201cefe..02f78a24 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/PolarBearWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/PolarBearWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class PolarBearWatcher extends AgeableWatcher { @@ -12,12 +12,12 @@ public class PolarBearWatcher extends AgeableWatcher public void setStanding(boolean standing) { - setData(FlagType.POLAR_BEAR_STANDING, standing); - sendData(FlagType.POLAR_BEAR_STANDING); + setData(MetaIndex.POLAR_BEAR_STANDING, standing); + sendData(MetaIndex.POLAR_BEAR_STANDING); } public boolean isStanding() { - return getData(FlagType.POLAR_BEAR_STANDING); + return getData(MetaIndex.POLAR_BEAR_STANDING); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.java index 6837d3b8..9e349611 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.RabbitType; import me.libraryaddict.disguise.utilities.DisguiseUtilities; @@ -16,13 +16,13 @@ public class RabbitWatcher extends AgeableWatcher public RabbitType getType() { - return RabbitType.getType((int) getData(FlagType.RABBIT_TYPE)); + return RabbitType.getType((int) getData(MetaIndex.RABBIT_TYPE)); } public void setType(RabbitType type) { - setData(FlagType.RABBIT_TYPE, type.getTypeId()); - sendData(FlagType.RABBIT_TYPE); + setData(MetaIndex.RABBIT_TYPE, type.getTypeId()); + sendData(MetaIndex.RABBIT_TYPE); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.java index c4d57e3f..86f9a8db 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/SheepWatcher.java @@ -4,7 +4,7 @@ import org.bukkit.DyeColor; import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class SheepWatcher extends AgeableWatcher { @@ -13,17 +13,17 @@ public class SheepWatcher extends AgeableWatcher { super(disguise); - setData(FlagType.SHEEP_WOOL, (byte) 0); + setData(MetaIndex.SHEEP_WOOL, (byte) 0); } public AnimalColor getColor() { - return AnimalColor.getColor(((int) getData(FlagType.SHEEP_WOOL) & 15)); + return AnimalColor.getColor(((int) getData(MetaIndex.SHEEP_WOOL) & 15)); } public boolean isSheared() { - return ((byte) getData(FlagType.SHEEP_WOOL) & 16) != 0; + return ((byte) getData(MetaIndex.SHEEP_WOOL) & 16) != 0; } public void setColor(AnimalColor color) @@ -33,25 +33,25 @@ public class SheepWatcher extends AgeableWatcher public void setColor(DyeColor color) { - byte b0 = (byte) getData(FlagType.SHEEP_WOOL); + byte b0 = (byte) getData(MetaIndex.SHEEP_WOOL); - setData(FlagType.SHEEP_WOOL, (byte) (b0 & 240 | color.getWoolData() & 15)); - sendData(FlagType.SHEEP_WOOL); + setData(MetaIndex.SHEEP_WOOL, (byte) (b0 & 240 | color.getWoolData() & 15)); + sendData(MetaIndex.SHEEP_WOOL); } public void setSheared(boolean flag) { - byte b0 = (byte) getData(FlagType.SHEEP_WOOL); + byte b0 = (byte) getData(MetaIndex.SHEEP_WOOL); if (flag) { - setData(FlagType.SHEEP_WOOL, (byte) (b0 | 16)); + setData(MetaIndex.SHEEP_WOOL, (byte) (b0 | 16)); } else { - setData(FlagType.SHEEP_WOOL, (byte) (b0 & -17)); + setData(MetaIndex.SHEEP_WOOL, (byte) (b0 & -17)); } - sendData(FlagType.SHEEP_WOOL); + sendData(MetaIndex.SHEEP_WOOL); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java index b42e5a17..c8a3e635 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ShulkerWatcher.java @@ -8,7 +8,7 @@ import com.google.common.base.Optional; import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; /** * @author Navid @@ -20,25 +20,25 @@ public class ShulkerWatcher extends InsentientWatcher { } public BlockFace getFacingDirection() { - return BlockFace.valueOf(getData(FlagType.SHULKER_FACING).name()); + return BlockFace.valueOf(getData(MetaIndex.SHULKER_FACING).name()); } public void setFacingDirection(BlockFace face) { - setData(FlagType.SHULKER_FACING, Direction.valueOf(face.name())); - sendData(FlagType.SHULKER_FACING); + setData(MetaIndex.SHULKER_FACING, Direction.valueOf(face.name())); + sendData(MetaIndex.SHULKER_FACING); } public BlockPosition getAttachmentPosition() { - return getData(FlagType.SHULKER_ATTACHED).get(); + return getData(MetaIndex.SHULKER_ATTACHED).get(); } public void setAttachmentPosition(BlockPosition pos) { - setData(FlagType.SHULKER_ATTACHED, Optional.of(pos)); - sendData(FlagType.SHULKER_ATTACHED); + setData(MetaIndex.SHULKER_ATTACHED, Optional.of(pos)); + sendData(MetaIndex.SHULKER_ATTACHED); } public int getShieldHeight() { - return getData(FlagType.SHULKER_PEEKING); + return getData(MetaIndex.SHULKER_PEEKING); } public void setShieldHeight(int newHeight) { @@ -48,12 +48,12 @@ public class ShulkerWatcher extends InsentientWatcher { if (newHeight > 127) newHeight = 127; - setData(FlagType.SHULKER_PEEKING, (byte) newHeight); - sendData(FlagType.SHULKER_PEEKING); + setData(MetaIndex.SHULKER_PEEKING, (byte) newHeight); + sendData(MetaIndex.SHULKER_PEEKING); } public void setColor(AnimalColor color) { - setData(FlagType.SHULKER_COLOR, (byte) color.getId()); - sendData(FlagType.SHULKER_COLOR); + setData(MetaIndex.SHULKER_COLOR, (byte) color.getId()); + sendData(MetaIndex.SHULKER_COLOR); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.java index 4d20cd65..3f4eef62 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/SkeletonWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; /** * @author Navid @@ -12,11 +12,11 @@ public class SkeletonWatcher extends InsentientWatcher { } public void setSwingArms(boolean swingingArms) { - setData(FlagType.SKELETON_SWING_ARMS, swingingArms); - sendData(FlagType.SKELETON_SWING_ARMS); + setData(MetaIndex.SKELETON_SWING_ARMS, swingingArms); + sendData(MetaIndex.SKELETON_SWING_ARMS); } public boolean isSwingArms() { - return getData(FlagType.SKELETON_SWING_ARMS); + return getData(MetaIndex.SKELETON_SWING_ARMS); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java index e3b94dca..865b415d 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.utilities.DisguiseUtilities; public class SlimeWatcher extends InsentientWatcher @@ -15,7 +15,7 @@ public class SlimeWatcher extends InsentientWatcher public int getSize() { - return (int) getData(FlagType.SLIME_SIZE); + return (int) getData(MetaIndex.SLIME_SIZE); } public void setSize(int size) @@ -25,8 +25,8 @@ public class SlimeWatcher extends InsentientWatcher size = 1; } - setData(FlagType.SLIME_SIZE, size); - sendData(FlagType.SLIME_SIZE); + setData(MetaIndex.SLIME_SIZE, size); + sendData(MetaIndex.SLIME_SIZE); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/SnowmanWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/SnowmanWatcher.java index c4789220..d60cca37 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/SnowmanWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/SnowmanWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class SnowmanWatcher extends InsentientWatcher { public SnowmanWatcher(Disguise disguise) { @@ -9,11 +9,11 @@ public class SnowmanWatcher extends InsentientWatcher { } public void setDerp(boolean derp) { - setData(FlagType.SNOWMAN_DERP, (byte) (derp ? 0 : 16)); - sendData(FlagType.SNOWMAN_DERP); + setData(MetaIndex.SNOWMAN_DERP, (byte) (derp ? 0 : 16)); + sendData(MetaIndex.SNOWMAN_DERP); } public boolean isDerp() { - return getData(FlagType.SNOWMAN_DERP) == 0; + return getData(MetaIndex.SNOWMAN_DERP) == 0; } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/SpiderWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/SpiderWatcher.java index f032ab4c..67ba6ada 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/SpiderWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/SpiderWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class SpiderWatcher extends InsentientWatcher { @@ -12,12 +12,12 @@ public class SpiderWatcher extends InsentientWatcher public void setClimbing(boolean climbing) { - setData(FlagType.SPIDER_CLIMB, (byte) (climbing ? 1 : 0)); - sendData(FlagType.SPIDER_CLIMB); + setData(MetaIndex.SPIDER_CLIMB, (byte) (climbing ? 1 : 0)); + sendData(MetaIndex.SPIDER_CLIMB); } public boolean isClimbing() { - return getData(FlagType.SPIDER_CLIMB) == (byte) 1; + return getData(MetaIndex.SPIDER_CLIMB) == (byte) 1; } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.java index 9167e31c..7fd1a16d 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/SplashPotionWatcher.java @@ -3,7 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import org.bukkit.inventory.ItemStack; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.utilities.DisguiseUtilities; @@ -27,12 +27,12 @@ public class SplashPotionWatcher extends FlagWatcher { } public void setSplashPotion(ItemStack item) { - setData(FlagType.SPLASH_POTION_ITEM, item); - sendData(FlagType.SPLASH_POTION_ITEM); + setData(MetaIndex.SPLASH_POTION_ITEM, item); + sendData(MetaIndex.SPLASH_POTION_ITEM); } public ItemStack getSplashPotion() { - return getData(FlagType.SPLASH_POTION_ITEM); + return getData(MetaIndex.SPLASH_POTION_ITEM); } public void setPotionId(int newPotionId) { diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java index 46d10520..0e41606f 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/TameableWatcher.java @@ -5,7 +5,7 @@ import java.util.UUID; import com.google.common.base.Optional; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class TameableWatcher extends AgeableWatcher { @@ -16,7 +16,7 @@ public class TameableWatcher extends AgeableWatcher public Optional getOwner() { - return getData(FlagType.TAMEABLE_OWNER); + return getData(MetaIndex.TAMEABLE_OWNER); } public boolean isSitting() @@ -31,29 +31,29 @@ public class TameableWatcher extends AgeableWatcher protected boolean isTameableFlag(int no) { - return ((byte) getData(FlagType.TAMEABLE_META) & no) != 0; + return ((byte) getData(MetaIndex.TAMEABLE_META) & no) != 0; } protected void setTameableFlag(int no, boolean flag) { - byte value = (byte) getData(FlagType.TAMEABLE_META); + byte value = (byte) getData(MetaIndex.TAMEABLE_META); if (flag) { - setData(FlagType.TAMEABLE_META, (byte) (value | no)); + setData(MetaIndex.TAMEABLE_META, (byte) (value | no)); } else { - setData(FlagType.TAMEABLE_META, (byte) (value & -(no + 1))); + setData(MetaIndex.TAMEABLE_META, (byte) (value & -(no + 1))); } - sendData(FlagType.TAMEABLE_META); + sendData(MetaIndex.TAMEABLE_META); } public void setOwner(UUID owner) { - setData(FlagType.TAMEABLE_OWNER, Optional.of(owner)); - sendData(FlagType.TAMEABLE_OWNER); + setData(MetaIndex.TAMEABLE_OWNER, Optional.of(owner)); + sendData(MetaIndex.TAMEABLE_OWNER); } public void setSitting(boolean sitting) diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java index 484aebc0..3abecc41 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java @@ -3,7 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import org.bukkit.Color; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.utilities.DisguiseUtilities; /** @@ -25,13 +25,13 @@ public class TippedArrowWatcher extends ArrowWatcher public Color getColor() { - int color = (int) getData(FlagType.TIPPED_ARROW_COLOR); + int color = (int) getData(MetaIndex.TIPPED_ARROW_COLOR); return Color.fromRGB(color); } public void setColor(Color color) { - setData(FlagType.TIPPED_ARROW_COLOR, color.asRGB()); - sendData(FlagType.TIPPED_ARROW_COLOR); + setData(MetaIndex.TIPPED_ARROW_COLOR, color.asRGB()); + sendData(MetaIndex.TIPPED_ARROW_COLOR); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/VexWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/VexWatcher.java index 398bdb43..217bd4bf 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/VexWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/VexWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class VexWatcher extends InsentientWatcher { @@ -10,12 +10,12 @@ public class VexWatcher extends InsentientWatcher { } public void setAngry(boolean angry) { - setData(FlagType.VEX_ANGRY, (byte) (angry ? 1 : 0)); - sendData(FlagType.VEX_ANGRY); + setData(MetaIndex.VEX_ANGRY, (byte) (angry ? 1 : 0)); + sendData(MetaIndex.VEX_ANGRY); } public boolean isAngry() { - return getData(FlagType.VEX_ANGRY) == 1; + return getData(MetaIndex.VEX_ANGRY) == 1; } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java index 1a94de0a..c0973a52 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java @@ -3,7 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import org.bukkit.entity.Villager.Profession; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.utilities.DisguiseUtilities; public class VillagerWatcher extends AgeableWatcher { @@ -14,13 +14,13 @@ public class VillagerWatcher extends AgeableWatcher { } public Profession getProfession() { - return Profession.values()[getData(FlagType.VILLAGER_PROFESSION)]; + return Profession.values()[getData(MetaIndex.VILLAGER_PROFESSION)]; } @Deprecated public void setProfession(int professionId) { - setData(FlagType.VILLAGER_PROFESSION, professionId); - sendData(FlagType.VILLAGER_PROFESSION); + setData(MetaIndex.VILLAGER_PROFESSION, professionId); + sendData(MetaIndex.VILLAGER_PROFESSION); } public void setProfession(Profession newProfession) { diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/VindicatorWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/VindicatorWatcher.java index cfcba3ba..0a549f26 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/VindicatorWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/VindicatorWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class VindicatorWatcher extends InsentientWatcher { @@ -10,8 +10,8 @@ public class VindicatorWatcher extends InsentientWatcher { } public void setJohnny(boolean isJohnny) { - setData(FlagType.VINDICATOR_JOHNNY, (byte) (isJohnny ? 1 : 0)); - sendData(FlagType.VINDICATOR_JOHNNY); + setData(MetaIndex.VINDICATOR_JOHNNY, (byte) (isJohnny ? 1 : 0)); + sendData(MetaIndex.VINDICATOR_JOHNNY); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.java index 4f0a9319..a36d06a1 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; /** * @author Navid @@ -16,13 +16,13 @@ public class WitchWatcher extends InsentientWatcher public boolean isAggressive() { - return (boolean) getData(FlagType.WITCH_AGGRESSIVE); + return (boolean) getData(MetaIndex.WITCH_AGGRESSIVE); } public void setAggressive(boolean aggressive) { - setData(FlagType.WITCH_AGGRESSIVE, aggressive); - sendData(FlagType.WITCH_AGGRESSIVE); + setData(MetaIndex.WITCH_AGGRESSIVE, aggressive); + sendData(MetaIndex.WITCH_AGGRESSIVE); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.java index 1a469213..4bedec8c 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherSkullWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; public class WitherSkullWatcher extends FlagWatcher @@ -14,13 +14,13 @@ public class WitherSkullWatcher extends FlagWatcher public boolean isBlue() { - return (boolean) getData(FlagType.WITHER_SKULL_BLUE); + return (boolean) getData(MetaIndex.WITHER_SKULL_BLUE); } public void setBlue(boolean blue) { - setData(FlagType.WITHER_SKULL_BLUE, blue); - sendData(FlagType.WITHER_SKULL_BLUE); + setData(MetaIndex.WITHER_SKULL_BLUE, blue); + sendData(MetaIndex.WITHER_SKULL_BLUE); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java index 6245cbc9..8529c7af 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java @@ -5,7 +5,7 @@ import java.security.InvalidParameterException; import org.bukkit.ChatColor; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class WitherWatcher extends InsentientWatcher { @@ -22,14 +22,14 @@ public class WitherWatcher extends InsentientWatcher */ public int getInvulnerability() { - return (int) getData(FlagType.WITHER_INVUL); + return (int) getData(MetaIndex.WITHER_INVUL); } public int[] getTargets() { return new int[] { - getData(FlagType.WITHER_TARGET_1), getData(FlagType.WITHER_TARGET_2), getData(FlagType.WITHER_TARGET_3) + getData(MetaIndex.WITHER_TARGET_1), getData(MetaIndex.WITHER_TARGET_2), getData(MetaIndex.WITHER_TARGET_3) }; } @@ -38,8 +38,8 @@ public class WitherWatcher extends InsentientWatcher */ public void setInvulnerability(int invulnerability) { - setData(FlagType.WITHER_INVUL, invulnerability); - sendData(FlagType.WITHER_INVUL); + setData(MetaIndex.WITHER_INVUL, invulnerability); + sendData(MetaIndex.WITHER_INVUL); } public void setTargets(int... targets) @@ -49,10 +49,10 @@ public class WitherWatcher extends InsentientWatcher throw new InvalidParameterException( ChatColor.RED + "Expected 3 numbers for wither setTargets. Received " + targets.length); } - setData(FlagType.WITHER_TARGET_1, targets[0]); - setData(FlagType.WITHER_TARGET_2, targets[1]); - setData(FlagType.WITHER_TARGET_3, targets[2]); - sendData(FlagType.WITHER_TARGET_1, FlagType.WITHER_TARGET_2, FlagType.WITHER_TARGET_3); + setData(MetaIndex.WITHER_TARGET_1, targets[0]); + setData(MetaIndex.WITHER_TARGET_2, targets[1]); + setData(MetaIndex.WITHER_TARGET_3, targets[2]); + sendData(MetaIndex.WITHER_TARGET_1, MetaIndex.WITHER_TARGET_2, MetaIndex.WITHER_TARGET_3); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.java index 1b266956..c8271e4f 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/WolfWatcher.java @@ -4,7 +4,7 @@ import org.bukkit.DyeColor; import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class WolfWatcher extends TameableWatcher { @@ -16,7 +16,7 @@ public class WolfWatcher extends TameableWatcher public AnimalColor getCollarColor() { - return AnimalColor.getColor(getData(FlagType.WOLF_COLLAR)); + return AnimalColor.getColor(getData(MetaIndex.WOLF_COLLAR)); } /** @@ -26,7 +26,7 @@ public class WolfWatcher extends TameableWatcher */ public float getDamageTaken() { - return (float) getData(FlagType.WOLF_DAMAGE); + return (float) getData(MetaIndex.WOLF_DAMAGE); } /** @@ -36,19 +36,19 @@ public class WolfWatcher extends TameableWatcher */ public void setDamageTaken(float damage) { - setData(FlagType.WOLF_DAMAGE, damage); - sendData(FlagType.WOLF_DAMAGE); + setData(MetaIndex.WOLF_DAMAGE, damage); + sendData(MetaIndex.WOLF_DAMAGE); } public boolean isBegging() { - return (boolean) getData(FlagType.WOLF_BEGGING); + return (boolean) getData(MetaIndex.WOLF_BEGGING); } public void setBegging(boolean begging) { - setData(FlagType.WOLF_BEGGING, begging); - sendData(FlagType.WOLF_BEGGING); + setData(MetaIndex.WOLF_BEGGING, begging); + sendData(MetaIndex.WOLF_BEGGING); } public boolean isAngry() @@ -78,8 +78,8 @@ public class WolfWatcher extends TameableWatcher return; } - setData(FlagType.WOLF_COLLAR, (int) newColor.getDyeData()); - sendData(FlagType.WOLF_COLLAR); + setData(MetaIndex.WOLF_COLLAR, (int) newColor.getDyeData()); + sendData(MetaIndex.WOLF_COLLAR); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java index 0ea140b0..49c1a1eb 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java @@ -3,7 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import org.bukkit.entity.Villager.Profession; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class ZombieVillagerWatcher extends ZombieWatcher { @@ -12,7 +12,7 @@ public class ZombieVillagerWatcher extends ZombieWatcher { } public boolean isShaking() { - return getData(FlagType.ZOMBIE_VILLAGER_SHAKING); + return getData(MetaIndex.ZOMBIE_VILLAGER_SHAKING); } /** @@ -21,12 +21,12 @@ public class ZombieVillagerWatcher extends ZombieWatcher { * @return */ public boolean isVillager() { - return ((int) getData(FlagType.ZOMBIE_VILLAGER_PROFESSION)) != 0; + return ((int) getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION)) != 0; } public void setShaking(boolean shaking) { - setData(FlagType.ZOMBIE_VILLAGER_SHAKING, shaking); - sendData(FlagType.ZOMBIE_VILLAGER_SHAKING); + setData(MetaIndex.ZOMBIE_VILLAGER_SHAKING, shaking); + sendData(MetaIndex.ZOMBIE_VILLAGER_SHAKING); } /** @@ -35,7 +35,7 @@ public class ZombieVillagerWatcher extends ZombieWatcher { * @return */ public Profession getProfession() { - return Profession.values()[getData(FlagType.ZOMBIE_VILLAGER_PROFESSION)]; + return Profession.values()[getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION)]; } /** @@ -45,8 +45,8 @@ public class ZombieVillagerWatcher extends ZombieWatcher { */ @Deprecated public void setProfession(int id) { - setData(FlagType.ZOMBIE_VILLAGER_PROFESSION, id); - sendData(FlagType.ZOMBIE_VILLAGER_PROFESSION); + setData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION, id); + sendData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION); } /** @@ -55,8 +55,8 @@ public class ZombieVillagerWatcher extends ZombieWatcher { * @param profession */ public void setProfession(Profession profession) { - setData(FlagType.ZOMBIE_VILLAGER_PROFESSION, profession.ordinal()); - sendData(FlagType.ZOMBIE_VILLAGER_PROFESSION); + setData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION, profession.ordinal()); + sendData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION); } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java index cce48210..3799a1fa 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java @@ -1,7 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import me.libraryaddict.disguise.disguisetypes.Disguise; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; public class ZombieWatcher extends InsentientWatcher { @@ -14,11 +14,11 @@ public class ZombieWatcher extends InsentientWatcher { } public boolean isBaby() { - return getData(FlagType.ZOMBIE_BABY); + return getData(MetaIndex.ZOMBIE_BABY); } public boolean isAggressive() { - return (boolean) getData(FlagType.ZOMBIE_AGGRESSIVE); + return (boolean) getData(MetaIndex.ZOMBIE_AGGRESSIVE); } public void setAdult() { @@ -30,13 +30,13 @@ public class ZombieWatcher extends InsentientWatcher { } public void setBaby(boolean baby) { - setData(FlagType.ZOMBIE_BABY, baby); - sendData(FlagType.ZOMBIE_BABY); + setData(MetaIndex.ZOMBIE_BABY, baby); + sendData(MetaIndex.ZOMBIE_BABY); } public void setAggressive(boolean handsup) { - setData(FlagType.ZOMBIE_AGGRESSIVE, handsup); - sendData(FlagType.ZOMBIE_AGGRESSIVE); + setData(MetaIndex.ZOMBIE_AGGRESSIVE, handsup); + sendData(MetaIndex.ZOMBIE_AGGRESSIVE); } } diff --git a/src/me/libraryaddict/disguise/utilities/PacketsManager.java b/src/me/libraryaddict/disguise/utilities/PacketsManager.java index ca625a00..de3265ac 100644 --- a/src/me/libraryaddict/disguise/utilities/PacketsManager.java +++ b/src/me/libraryaddict/disguise/utilities/PacketsManager.java @@ -42,7 +42,7 @@ import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; -import me.libraryaddict.disguise.disguisetypes.FlagType; +import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.disguisetypes.MiscDisguise; import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; @@ -361,7 +361,7 @@ public class PacketsManager { spawnPlayer.getDataWatcherModifier().write(0, newWatcher); // Make him invisible - newWatcher.setObject(new WrappedDataWatcherObject(FlagType.ENTITY_META.getIndex(), Registry.get(Byte.class)), + newWatcher.setObject(new WrappedDataWatcherObject(MetaIndex.ENTITY_META.getIndex(), Registry.get(Byte.class)), (byte) 32); packets.addPacket(spawnPlayer);