From 34d2dcb97b6977a81c198212ab00a01ac0897a38 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Tue, 28 May 2013 09:10:24 +0200 Subject: [PATCH] Ugly NPE evasion. Solves the issue probably but why did it turn null even in the first place? --- src/com/massivecraft/factions/FPerm.java | 10 +++++----- .../massivecraft/factions/entity/Faction.java | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/com/massivecraft/factions/FPerm.java b/src/com/massivecraft/factions/FPerm.java index 5003a6c9..429c2578 100644 --- a/src/com/massivecraft/factions/FPerm.java +++ b/src/com/massivecraft/factions/FPerm.java @@ -24,12 +24,12 @@ public enum FPerm // ENUM // -------------------------------------------- // - BUILD(true, "build", "edit the terrain", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY), + BUILD(true, "build", "edit the terrain", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY), PAINBUILD(true, "painbuild", "edit, take damage"), - DOOR(true, "door", "use doors", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), - BUTTON(true, "button", "use stone buttons", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), - LEVER(true, "lever", "use levers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), - CONTAINER(true, "container", "use containers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER), + DOOR(true, "door", "use doors", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), + BUTTON(true, "button", "use stone buttons", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), + LEVER(true, "lever", "use levers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), + CONTAINER(true, "container", "use containers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER), INVITE(false, "invite", "invite players", Rel.LEADER, Rel.OFFICER), KICK(false, "kick", "kick members", Rel.LEADER, Rel.OFFICER), diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/com/massivecraft/factions/entity/Faction.java index da75f4fe..a40218a0 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/com/massivecraft/factions/entity/Faction.java @@ -642,14 +642,19 @@ public class Faction extends Entity implements EconomyParticipator while (iter.hasNext()) { Entry> entry = iter.next(); - FPerm key = entry.getKey(); - if (key == null) System.out.println("key was null"); + + FPerm key = entry.getKey(); + if (key == null) + { + // TODO: I have no idea why this key is null at times... Why? + System.out.println("key was null :/"); + iter.remove(); + continue; + } + Set keyDefault = key.getDefault(this); Set value = entry.getValue(); - if (keyDefault == null) System.out.println("keyDefault was null"); - if (value == null) System.out.println("value was null"); - if (keyDefault.equals(value)) { iter.remove(); @@ -660,9 +665,6 @@ public class Faction extends Entity implements EconomyParticipator } } - //System.out.println("setPerms target:"); - //System.out.println(Factions.get().gson.toJson(target, new TypeToken>>(){}.getType())); - // Detect Nochange if (MUtil.equals(this.perms, target)) return;