From 7c640f1bc7022b058e6b8ff7765833c499d7019a Mon Sep 17 00:00:00 2001 From: Gibstick Date: Sun, 28 Jul 2013 13:47:16 -0400 Subject: [PATCH] excluded more mobs that NPE, fixed array out of bounds in parsing --- src/ca/gibstick/discosheep/DiscoSheep.java | 9 ++++++--- .../gibstick/discosheep/DiscoSheepCommandExecutor.java | 2 +- src/ca/gibstick/discosheep/PartyEvents.java | 9 ++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/ca/gibstick/discosheep/DiscoSheep.java b/src/ca/gibstick/discosheep/DiscoSheep.java index 487257f..c16263d 100644 --- a/src/ca/gibstick/discosheep/DiscoSheep.java +++ b/src/ca/gibstick/discosheep/DiscoSheep.java @@ -44,15 +44,18 @@ public final class DiscoSheep extends JavaPlugin { /* * Iterate through all live entities and create default configuration values for them - * excludes bosses and pigmen since they throw NPE for some reason - * excludes horses for 1.5.2 compatibility (also NPE) + * excludes bosses and other mobs that throw NPE */ for (EntityType ent : EntityType.values()) { if (ent.isAlive() && !ent.equals(EntityType.ENDER_DRAGON) && !ent.equals(EntityType.WITHER) && !ent.equals(EntityType.PIG_ZOMBIE) - && !ent.equals(EntityType.HORSE) + && !ent.equals(EntityType.OCELOT) + && !ent.equals(EntityType.CAVE_SPIDER) + && !ent.equals(EntityType.MAGMA_CUBE) + && !ent.equals(EntityType.MUSHROOM_COW) + && !ent.equals(EntityType.IRON_GOLEM) && !ent.equals(EntityType.PLAYER)) { getConfig().addDefault("default.guests." + ent.toString(), 0); getConfig().addDefault("max.guests." + ent.toString(), 0); diff --git a/src/ca/gibstick/discosheep/DiscoSheepCommandExecutor.java b/src/ca/gibstick/discosheep/DiscoSheepCommandExecutor.java index 18efafc..b5f3d5e 100644 --- a/src/ca/gibstick/discosheep/DiscoSheepCommandExecutor.java +++ b/src/ca/gibstick/discosheep/DiscoSheepCommandExecutor.java @@ -156,7 +156,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor { String[] guests = getNextArgs(args, i + 1); int j = 0; - while (j < guests.length) { + while (j < guests.length - 1) { try { mainParty.setGuestNumber(guests[j], getNextIntArg(guests, j)); } catch (IllegalArgumentException e) { diff --git a/src/ca/gibstick/discosheep/PartyEvents.java b/src/ca/gibstick/discosheep/PartyEvents.java index 4ca8197..cc1ef9d 100644 --- a/src/ca/gibstick/discosheep/PartyEvents.java +++ b/src/ca/gibstick/discosheep/PartyEvents.java @@ -1,6 +1,5 @@ package ca.gibstick.discosheep; -import java.util.logging.Level; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Sheep; import org.bukkit.event.EventHandler; @@ -18,6 +17,12 @@ public class PartyEvents implements Listener { DiscoSheep parent; DiscoParty party; + /* + * There will be multiple isntances of PartyEvents, + * and each instance will only listen for its own party. + * That way, we don't have multiple instances iterating through + * the entire parties hashmap redunandtly + */ public PartyEvents(DiscoSheep parent, DiscoParty party) { this.parent = parent; @@ -54,8 +59,6 @@ public class PartyEvents implements Listener { party.jump((LivingEntity) e.getEntity()); e.setCancelled(true); } - - parent.getLogger().log(Level.INFO, "Debug: EVENT TRIGGERED"); } // prevent uninvited guests from targetting players