Ugly NPE evasion. Solves the issue probably but why did it turn null even in the first place?

This commit is contained in:
Olof Larsson committed 2013-05-28 09:10:24 +02:00
1 parent ac95004450
commit 34d2dcb97b
2 files changed
+15 -13

No files matched your search

+5 -5
View File
@@ -24,12 +24,12 @@ public enum FPerm
// ENUM // 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"), PAINBUILD(true, "painbuild", "edit, take damage"),
DOOR(true, "door", "use doors", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), 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), 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), 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), CONTAINER(true, "container", "use containers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER),
INVITE(false, "invite", "invite players", Rel.LEADER, Rel.OFFICER), INVITE(false, "invite", "invite players", Rel.LEADER, Rel.OFFICER),
KICK(false, "kick", "kick members", Rel.LEADER, Rel.OFFICER), KICK(false, "kick", "kick members", Rel.LEADER, Rel.OFFICER),
@@ -642,14 +642,19 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
while (iter.hasNext()) while (iter.hasNext())
{ {
Entry<FPerm, Set<Rel>> entry = iter.next(); Entry<FPerm, Set<Rel>> 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<Rel> keyDefault = key.getDefault(this); Set<Rel> keyDefault = key.getDefault(this);
Set<Rel> value = entry.getValue(); Set<Rel> 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)) if (keyDefault.equals(value))
{ {
iter.remove(); iter.remove();
@@ -660,9 +665,6 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
} }
} }
//System.out.println("setPerms target:");
//System.out.println(Factions.get().gson.toJson(target, new TypeToken<Map<FPerm, Set<Rel>>>(){}.getType()));
// Detect Nochange // Detect Nochange
if (MUtil.equals(this.perms, target)) return; if (MUtil.equals(this.perms, target)) return;