From c78843aa2a9d57beed47f35f321849cbba53f9db Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 30 May 2013 02:25:00 +1200 Subject: [PATCH] Read desc Tried a little fix for sounds. Hopefully made a fix for concurrent modification errors Fixed typo in disguise player command Added warning and disable if ProtocolLib isn't found --- plugin.yml | 2 +- .../disguise/Commands/DisguisePlayerCommand.java | 2 +- src/me/libraryaddict/disguise/DisguiseAPI.java | 6 +++--- .../disguise/DisguiseTypes/DisguiseSound.java | 12 ++++++------ src/me/libraryaddict/disguise/LibsDisguises.java | 8 ++++++++ 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/plugin.yml b/plugin.yml index e1ed28f5..32dbf713 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,7 +2,7 @@ name: LibsDisguises main: me.libraryaddict.disguise.LibsDisguises version: ${project.version} author: libraryaddict -depend: [ProtocolLib] +softdepend: [ProtocolLib] commands: disguise: aliases: [d, dis] diff --git a/src/me/libraryaddict/disguise/Commands/DisguisePlayerCommand.java b/src/me/libraryaddict/disguise/Commands/DisguisePlayerCommand.java index cb5c88bf..3d3fee7c 100644 --- a/src/me/libraryaddict/disguise/Commands/DisguisePlayerCommand.java +++ b/src/me/libraryaddict/disguise/Commands/DisguisePlayerCommand.java @@ -69,7 +69,7 @@ public class DisguisePlayerCommand implements CommandExecutor { } else sender.sendMessage(ChatColor.RED + "You do not have permission to use this command."); } else { - if (args.length == 1) { + if (args.length > 1) { Player p = Bukkit.getPlayer(args[0]); if (p != null) { if (args[1].equalsIgnoreCase("undiguise") || args[1].equalsIgnoreCase("undis") diff --git a/src/me/libraryaddict/disguise/DisguiseAPI.java b/src/me/libraryaddict/disguise/DisguiseAPI.java index f1c9d7c2..30573b57 100644 --- a/src/me/libraryaddict/disguise/DisguiseAPI.java +++ b/src/me/libraryaddict/disguise/DisguiseAPI.java @@ -107,6 +107,7 @@ public class DisguiseAPI { } } if (disguisedEntity != null) { + // TODO Check if they been damage with invincibility ticks Sound sound = null; DisguiseSound dSound = DisguiseSound.getType(DisguiseAPI.getDisguise(disguisedEntity).getType().name()); if (dSound != null) @@ -150,9 +151,8 @@ public class DisguiseAPI { EntityTrackerEntry entry = (EntityTrackerEntry) ((WorldServer) ((CraftEntity) entity).getHandle().world).tracker.trackedEntities .get(entity.getEntityId()); if (entry != null) { - Iterator itel = entry.trackedPlayers.iterator(); - while (itel.hasNext()) { - EntityPlayer player = (EntityPlayer) itel.next(); + EntityPlayer[] players = (EntityPlayer[]) entry.trackedPlayers.toArray(); + for (EntityPlayer player : players) { if (entity instanceof Player && !player.getBukkitEntity().canSee((Player) entity)) continue; entry.clear(player); diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseSound.java b/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseSound.java index cf0d4423..ec063ab8 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseSound.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/DisguiseSound.java @@ -12,7 +12,7 @@ public enum DisguiseSound { BLAZE(Sound.BLAZE_HIT, null, Sound.BLAZE_DEATH, Sound.BLAZE_BREATH), - CAVE_SPIDER(Sound.SPIDER_IDLE, Sound.SPIDER_WALK, Sound.SPIDER_DEATH, null), + CAVE_SPIDER(Sound.SPIDER_IDLE, Sound.SPIDER_WALK, Sound.SPIDER_DEATH, Sound.PIG_IDLE), CHICKEN(Sound.CHICKEN_HURT, Sound.CHICKEN_WALK, Sound.CHICKEN_HURT, Sound.CHICKEN_IDLE, Sound.CHICKEN_EGG_POP), @@ -28,9 +28,9 @@ public enum DisguiseSound { GHAST(Sound.GHAST_SCREAM, null, Sound.GHAST_DEATH, Sound.GHAST_MOAN, Sound.GHAST_CHARGE, Sound.GHAST_FIREBALL, Sound.GHAST_SCREAM2), - GIANT_ZOMBIE(Sound.HURT_FLESH, Sound.STEP_GRASS), + GIANT_ZOMBIE(Sound.HURT_FLESH, Sound.STEP_GRASS, null, null), - IRON_GOLEM(Sound.IRONGOLEM_HIT, Sound.IRONGOLEM_WALK, Sound.IRONGOLEM_DEATH, null, Sound.IRONGOLEM_THROW), + IRON_GOLEM(Sound.IRONGOLEM_HIT, Sound.IRONGOLEM_WALK, Sound.IRONGOLEM_DEATH, Sound.IRONGOLEM_THROW), MAGMA_CUBE(Sound.SLIME_ATTACK, Sound.SLIME_WALK2, null, null, Sound.SLIME_WALK), @@ -38,13 +38,13 @@ public enum DisguiseSound { OCELOT(Sound.CAT_HIT, Sound.STEP_GRASS, Sound.CAT_HIT, Sound.CAT_MEOW, Sound.CAT_PURR, Sound.CAT_PURREOW), - PIG(Sound.PIG_IDLE, Sound.PIG_WALK, Sound.PIG_DEATH, null), + PIG(Sound.PIG_IDLE, Sound.PIG_WALK, Sound.PIG_DEATH, Sound.PIG_IDLE), PIG_ZOMBIE(Sound.ZOMBIE_PIG_HURT, null, Sound.ZOMBIE_PIG_DEATH, Sound.ZOMBIE_PIG_IDLE, Sound.ZOMBIE_PIG_ANGRY), PLAYER(Sound.HURT_FLESH, Sound.STEP_GRASS), - SHEEP(Sound.SHEEP_IDLE, Sound.SHEEP_WALK, null, null, null, Sound.SHEEP_SHEAR), + SHEEP(Sound.SHEEP_IDLE, Sound.SHEEP_WALK, null, Sound.SHEEP_IDLE, Sound.SHEEP_SHEAR), SILVERFISH(Sound.SILVERFISH_HIT, Sound.SILVERFISH_WALK, Sound.SILVERFISH_KILL, Sound.SILVERFISH_IDLE), @@ -52,7 +52,7 @@ public enum DisguiseSound { SLIME(Sound.SLIME_ATTACK, Sound.SLIME_WALK2, null, null, Sound.SLIME_WALK), - SPIDER(Sound.SPIDER_IDLE, Sound.SPIDER_WALK, Sound.SPIDER_DEATH, null), + SPIDER(Sound.SPIDER_IDLE, Sound.SPIDER_WALK, Sound.SPIDER_DEATH, Sound.PIG_IDLE), WITHER(Sound.WITHER_HURT, null, Sound.WITHER_DEATH, Sound.WITHER_IDLE, Sound.WITHER_SHOOT, Sound.WITHER_SPAWN), diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index 14f7bd3f..2c1b34a7 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -10,6 +10,8 @@ import me.libraryaddict.disguise.DisguiseTypes.Disguise; import me.libraryaddict.disguise.DisguiseTypes.DisguiseType; import me.libraryaddict.disguise.DisguiseTypes.PlayerDisguise; import net.minecraft.server.v1_5_R3.WatchableObject; + +import org.bukkit.Bukkit; import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.ExperienceOrb; @@ -30,6 +32,12 @@ public class LibsDisguises extends JavaPlugin { @Override public void onEnable() { + if (Bukkit.getPluginManager().getPlugin("ProtocolLib") == null) { + System.out.print("[LibsDisguises] WARNING! WARNING! LibsDisguises couldn't find ProtocolLib! This plugin depends on it to run!"); + System.out.print("[LibsDisguises] WARNING! WARNING! LibsDisguises couldn't find ProtocolLib! LibsDisguises is now shutting down!"); + getPluginLoader().disablePlugin(this); + return; + } DisguiseAPI.init(this); DisguiseAPI.enableSounds(true); final ProtocolManager manager = ProtocolLibrary.getProtocolManager();