From 2e8359aa15ee753f00bf0dea9bf1da1d8da85bcd Mon Sep 17 00:00:00 2001 From: Gibstick Date: Sat, 27 Jul 2013 11:32:58 -0400 Subject: [PATCH] removed redundant temp hashmap, removed "PLAYER" from entity list --- src/ca/gibstick/discosheep/DiscoSheep.java | 28 +++++++--------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/ca/gibstick/discosheep/DiscoSheep.java b/src/ca/gibstick/discosheep/DiscoSheep.java index d2b8709..e5ba679 100644 --- a/src/ca/gibstick/discosheep/DiscoSheep.java +++ b/src/ca/gibstick/discosheep/DiscoSheep.java @@ -41,33 +41,23 @@ public final class DiscoSheep extends JavaPlugin { getConfig().addDefault("default.duration", toSeconds_i(DiscoParty.defaultDuration)); getConfig().addDefault("default.period-ticks", DiscoParty.defaultPeriod); - Map tempMap = new HashMap(); // temporary map to store guest config values - - - // create a default hashmap of for all living entities - // this creates a default config entry with all living entites present - // except for bosses, pigzombie (NPE for some reason) - // and horses (until 1.6.2 stable) + /* + * 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) + */ 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)) { - tempMap.put(ent.toString(), 0); + && !ent.equals(EntityType.HORSE) + && !ent.equals(EntityType.PLAYER)) { + getConfig().addDefault("default.guests." + ent.toString(), 0); + getConfig().addDefault("max.guests." + ent.toString(), 0); } } - for (Map.Entry entry : tempMap.entrySet()) { - getConfig().addDefault("default.guests." + entry.getKey(), entry.getValue()); - } - - // same thing, but for limits (no default limits) - - for (Map.Entry entry : tempMap.entrySet()) { - getConfig().addDefault("max.guests." + entry.getKey(), entry.getValue()); - } - loadConfigFromDisk(); }