diff --git a/src/me/libraryaddict/disguise/Commands/DisguiseCommand.java b/src/me/libraryaddict/disguise/Commands/DisguiseCommand.java index a84e6b52..dc975d1f 100644 --- a/src/me/libraryaddict/disguise/Commands/DisguiseCommand.java +++ b/src/me/libraryaddict/disguise/Commands/DisguiseCommand.java @@ -50,6 +50,7 @@ public class DisguiseCommand implements CommandExecutor { } } + @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { Player p = (Player) sender; if (args.length == 0) { diff --git a/src/me/libraryaddict/disguise/Commands/DisguisePlayerCommand.java b/src/me/libraryaddict/disguise/Commands/DisguisePlayerCommand.java index 53d71ab9..cb5c88bf 100644 --- a/src/me/libraryaddict/disguise/Commands/DisguisePlayerCommand.java +++ b/src/me/libraryaddict/disguise/Commands/DisguisePlayerCommand.java @@ -51,6 +51,7 @@ public class DisguisePlayerCommand implements CommandExecutor { } } + @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (sender.hasPermission("libsdisguises.disguiseothers") || (args.length > 0 && args[0].toLowerCase().startsWith("un") && sender diff --git a/src/me/libraryaddict/disguise/Commands/UndisguiseCommand.java b/src/me/libraryaddict/disguise/Commands/UndisguiseCommand.java index eebcc831..77527df0 100644 --- a/src/me/libraryaddict/disguise/Commands/UndisguiseCommand.java +++ b/src/me/libraryaddict/disguise/Commands/UndisguiseCommand.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Player; public class UndisguiseCommand implements CommandExecutor { + @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { Player p = (Player) sender; if (sender.hasPermission("libsdisguises.undisguise")) { diff --git a/src/me/libraryaddict/disguise/Commands/UndisguisePlayerCommand.java b/src/me/libraryaddict/disguise/Commands/UndisguisePlayerCommand.java index f03b9ba3..a5dbb5e9 100644 --- a/src/me/libraryaddict/disguise/Commands/UndisguisePlayerCommand.java +++ b/src/me/libraryaddict/disguise/Commands/UndisguisePlayerCommand.java @@ -11,6 +11,7 @@ import org.bukkit.entity.Player; public class UndisguisePlayerCommand implements CommandExecutor { + @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (sender.hasPermission("libsdisguises.undisguiseothers")) { if (args.length > 0) { diff --git a/src/me/libraryaddict/disguise/DisguiseAPI.java b/src/me/libraryaddict/disguise/DisguiseAPI.java index 25aaf952..f86f5413 100644 --- a/src/me/libraryaddict/disguise/DisguiseAPI.java +++ b/src/me/libraryaddict/disguise/DisguiseAPI.java @@ -33,8 +33,44 @@ public class DisguiseAPI { private static ConcurrentHashMap disguises = new ConcurrentHashMap(); private static PacketListener packetListener; - private static boolean soundsEnabled; private static JavaPlugin plugin; + private static boolean soundsEnabled; + + /** + * @param Player + * - The player to disguise + * @param Disguise + * - The disguise to wear + */ + public static void disguiseToAll(Entity entity, Disguise disguise) { + disguises.put(entity instanceof Player ? ((Player) entity).getName() : entity.getUniqueId(), disguise); + refresh(entity); + } + + public static void enableSounds(boolean isSoundsEnabled) { + if (soundsEnabled != isSoundsEnabled) { + soundsEnabled = isSoundsEnabled; + if (soundsEnabled) { + ProtocolLibrary.getProtocolManager().addPacketListener(packetListener); + } else { + ProtocolLibrary.getProtocolManager().removePacketListener(packetListener); + } + } + } + + /** + * @param Disguiser + * @return Disguise + */ + public static Disguise getDisguise(Object disguiser) { + if (disguiser instanceof Entity) { + if (disguiser instanceof Player) + return disguises.get(((Player) disguiser).getName()); + else + return disguises.get(((Entity) disguiser).getUniqueId()); + } + return disguises.get(disguiser); + } protected static void init(JavaPlugin mainPlugin) { plugin = mainPlugin; @@ -97,14 +133,17 @@ public class DisguiseAPI { } /** - * @param Player - * - The player to disguise - * @param Disguise - * - The disguise to wear + * @param Disguiser + * @return boolean - If the disguiser is disguised */ - public static void disguiseToAll(Entity entity, Disguise disguise) { - disguises.put(entity instanceof Player ? ((Player) entity).getName() : entity.getUniqueId(), disguise); - refresh(entity); + public static boolean isDisguised(Object disguiser) { + if (disguiser instanceof Entity) { + if (disguiser instanceof Player) + return disguises.containsKey(((Player) disguiser).getName()); + else + return disguises.containsKey(((Entity) disguiser).getUniqueId()); + } + return disguises.containsKey(disguiser); } private static void refresh(Entity entity) { @@ -128,34 +167,6 @@ public class DisguiseAPI { }*/ } - /** - * @param Disguiser - * @return Disguise - */ - public static Disguise getDisguise(Object disguiser) { - if (disguiser instanceof Entity) { - if (disguiser instanceof Player) - return disguises.get(((Player) disguiser).getName()); - else - return disguises.get(((Entity) disguiser).getUniqueId()); - } - return disguises.get(disguiser); - } - - /** - * @param Disguiser - * @return boolean - If the disguiser is disguised - */ - public static boolean isDisguised(Object disguiser) { - if (disguiser instanceof Entity) { - if (disguiser instanceof Player) - return disguises.containsKey(((Player) disguiser).getName()); - else - return disguises.containsKey(((Entity) disguiser).getUniqueId()); - } - return disguises.containsKey(disguiser); - } - /** * @param Disguiser * - Undisguises him @@ -164,15 +175,4 @@ public class DisguiseAPI { disguises.remove(entity instanceof Player ? ((Player) entity).getName() : entity.getUniqueId()); refresh(entity); } - - public static void enableSounds(boolean isSoundsEnabled) { - if (soundsEnabled != isSoundsEnabled) { - soundsEnabled = isSoundsEnabled; - if (soundsEnabled) { - ProtocolLibrary.getProtocolManager().addPacketListener(packetListener); - } else { - ProtocolLibrary.getProtocolManager().removePacketListener(packetListener); - } - } - } } \ No newline at end of file diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java index c8ac14af..164c63b9 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java @@ -37,6 +37,13 @@ public class Disguise { disguiseType = newType; } + public PacketContainer constructDestroyPacket(int entityId) { + PacketContainer destroyPacket = ProtocolLibrary.getProtocolManager().createPacket(Packets.Server.DESTROY_ENTITY); + StructureModifier mods = destroyPacket.getModifier(); + mods.write(0, new int[] { entityId }); + return destroyPacket; + } + public PacketContainer constructPacket(org.bukkit.entity.Entity e) { PacketContainer spawnPacket = null; ProtocolManager manager = ProtocolLibrary.getProtocolManager(); @@ -175,13 +182,6 @@ public class Disguise { return spawnPacket; } - public PacketContainer constructDestroyPacket(int entityId) { - PacketContainer destroyPacket = ProtocolLibrary.getProtocolManager().createPacket(Packets.Server.DESTROY_ENTITY); - StructureModifier mods = destroyPacket.getModifier(); - mods.write(0, new int[] { entityId }); - return destroyPacket; - } - public Entity getEntity(World world, Location loc, int entityId) { if (entity != null) { entity.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseSound.java b/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseSound.java index a69275af..8a1456ab 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseSound.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseSound.java @@ -72,10 +72,24 @@ public enum DisguiseSound { ZOMBIE(Sound.ZOMBIE_HURT, Sound.STEP_GRASS, Sound.ZOMBIE_DEATH, Sound.ZOMBIE_IDLE, Sound.ZOMBIE_INFECT, Sound.ZOMBIE_METAL, Sound.ZOMBIE_WOODBREAK, Sound.ZOMBIE_WOOD); public enum SoundType { - HURT, STEP, IDLE, DEATH, CANCEL; + CANCEL, DEATH, HURT, IDLE, STEP; + } + + public static String getSoundName(Sound sound) { + return CraftSound.getSound(sound); + } + public static DisguiseSound getType(String name) { + try { + if (name.equals("GIANT")) + return DisguiseSound.GIANT_ZOMBIE; + return valueOf(name); + } catch (Exception ex) { + return null; + } } private HashSet cancelSounds = new HashSet(); + private HashMap disguiseSounds = new HashMap(); DisguiseSound(Sound... sounds) { @@ -94,10 +108,6 @@ public enum DisguiseSound { } } - public boolean isCancelled(String soundName) { - return cancelSounds.contains(soundName); - } - public Sound getSound(SoundType type) { if (type == null) return null; @@ -108,8 +118,8 @@ public enum DisguiseSound { return cancelSounds; } - public static String getSoundName(Sound sound) { - return CraftSound.getSound(sound); + public boolean isCancelled(String soundName) { + return cancelSounds.contains(soundName); } public boolean isCancelSound(String sound) { @@ -136,14 +146,4 @@ public enum DisguiseSound { } return null; } - - public static DisguiseSound getType(String name) { - try { - if (name.equals("GIANT")) - return DisguiseSound.GIANT_ZOMBIE; - return valueOf(name); - } catch (Exception ex) { - return null; - } - } } diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseType.java b/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseType.java index 5e21dd4a..a2bee759 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseType.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseType.java @@ -9,13 +9,13 @@ public enum DisguiseType { EntityType.MOB), ITEM(EntityType.MISC, 2, 1), ITEM_FRAME(EntityType.MISC, 71), LARGE_FIREBALL(EntityType.MISC, 63, 0), MAGMA_CUBE( EntityType.MOB), MINECART_CHEST(EntityType.MISC, 10, 1), MINECART_FURNACE(EntityType.MISC, 10, 2), MINECART_HOPPER( EntityType.MISC, 10), MINECART_MOB_SPAWNER(EntityType.MISC, 10, 4), MINECART_RIDEABLE(EntityType.MISC, 10, 0), MINECART_TNT( - EntityType.MISC, 10, 3), MUSHROOM_COW(EntityType.MOB), OCELOT(EntityType.MOB), PIG(EntityType.MOB), PIG_ZOMBIE( + EntityType.MISC, 10, 3), MUSHROOM_COW(EntityType.MOB), OCELOT(EntityType.MOB), PAINTING(EntityType.MISC), PIG(EntityType.MOB), PIG_ZOMBIE( EntityType.MOB), PLAYER(EntityType.PLAYER), POTION(EntityType.MISC, 73), PRIMED_TNT(EntityType.MISC, 50), SHEEP( EntityType.MOB), SILVERFISH(EntityType.MOB), SKELETON(EntityType.MOB), SLIME(EntityType.MOB), SMALL_FIREBALL( EntityType.MISC, 64, 0), SNOWBALL(EntityType.MISC, 61), SNOWMAN(EntityType.MOB), SPIDER(EntityType.MOB), SQUID( EntityType.MOB), THROWN_EXP_BOTTLE(EntityType.MISC, 75), VILLAGER(EntityType.MOB), WITCH(EntityType.MOB), WITHER( EntityType.MOB), WITHER_SKELETON(EntityType.MOB), WITHER_SKULL(EntityType.MISC, 66), WOLF(EntityType.MOB), ZOMBIE( - EntityType.MOB), PAINTING(EntityType.MISC); + EntityType.MOB); public static enum EntityType { MISC, MOB, PLAYER; diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index 6207e06d..14f7bd3f 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -28,6 +28,7 @@ import com.comphenix.protocol.reflect.StructureModifier; public class LibsDisguises extends JavaPlugin { + @Override public void onEnable() { DisguiseAPI.init(this); DisguiseAPI.enableSounds(true);