excluded more mobs that NPE, fixed array out of bounds in parsing

This commit is contained in:
Gibstick 2013-07-28 13:47:16 -04:00
parent d8fe7b480d
commit 7c640f1bc7
3 changed files with 13 additions and 7 deletions

View File

@ -44,15 +44,18 @@ public final class DiscoSheep extends JavaPlugin {
/* /*
* Iterate through all live entities and create default configuration values for them * Iterate through all live entities and create default configuration values for them
* excludes bosses and pigmen since they throw NPE for some reason * excludes bosses and other mobs that throw NPE
* excludes horses for 1.5.2 compatibility (also NPE)
*/ */
for (EntityType ent : EntityType.values()) { for (EntityType ent : EntityType.values()) {
if (ent.isAlive() if (ent.isAlive()
&& !ent.equals(EntityType.ENDER_DRAGON) && !ent.equals(EntityType.ENDER_DRAGON)
&& !ent.equals(EntityType.WITHER) && !ent.equals(EntityType.WITHER)
&& !ent.equals(EntityType.PIG_ZOMBIE) && !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)) { && !ent.equals(EntityType.PLAYER)) {
getConfig().addDefault("default.guests." + ent.toString(), 0); getConfig().addDefault("default.guests." + ent.toString(), 0);
getConfig().addDefault("max.guests." + ent.toString(), 0); getConfig().addDefault("max.guests." + ent.toString(), 0);

View File

@ -156,7 +156,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
String[] guests = getNextArgs(args, i + 1); String[] guests = getNextArgs(args, i + 1);
int j = 0; int j = 0;
while (j < guests.length) { while (j < guests.length - 1) {
try { try {
mainParty.setGuestNumber(guests[j], getNextIntArg(guests, j)); mainParty.setGuestNumber(guests[j], getNextIntArg(guests, j));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {

View File

@ -1,6 +1,5 @@
package ca.gibstick.discosheep; package ca.gibstick.discosheep;
import java.util.logging.Level;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Sheep; import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -18,6 +17,12 @@ public class PartyEvents implements Listener {
DiscoSheep parent; DiscoSheep parent;
DiscoParty party; 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) { public PartyEvents(DiscoSheep parent, DiscoParty party) {
this.parent = parent; this.parent = parent;
@ -54,8 +59,6 @@ public class PartyEvents implements Listener {
party.jump((LivingEntity) e.getEntity()); party.jump((LivingEntity) e.getEntity());
e.setCancelled(true); e.setCancelled(true);
} }
parent.getLogger().log(Level.INFO, "Debug: EVENT TRIGGERED");
} }
// prevent uninvited guests from targetting players // prevent uninvited guests from targetting players