From cf03bd5b8a8bf65a0829a1c37421501ca74b2150 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Mon, 29 Apr 2013 16:29:10 +0200 Subject: [PATCH] Fixing one permission check bug and adding some debug output in hope to find that bug. --- src/com/massivecraft/factions/FPerm.java | 4 ++-- .../massivecraft/factions/cmd/CmdFactionsPerm.java | 2 ++ src/com/massivecraft/factions/entity/Faction.java | 11 +++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/com/massivecraft/factions/FPerm.java b/src/com/massivecraft/factions/FPerm.java index 4c2df76a..5003a6c9 100644 --- a/src/com/massivecraft/factions/FPerm.java +++ b/src/com/massivecraft/factions/FPerm.java @@ -145,8 +145,8 @@ public enum FPerm { if (uplayer.isUsingAdminMode()) return true; - Faction faction = uplayer.getFaction(); - if (this.has(faction, hostFaction)) return true; + Rel rel = uplayer.getRelationTo(hostFaction); + if (hostFaction.getPermittedRelations(this).contains(rel)) return true; if (verboose) uplayer.sendMessage(this.createDeniedMessage(uplayer, hostFaction)); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java b/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java index c279fc03..39de35ad 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java @@ -47,6 +47,7 @@ public class CmdFactionsPerm extends FCommand FPerm perm = this.arg(1, ARFPerm.get()); if (perm == null) return; + System.out.println("perm = "+perm); if ( ! this.argIsSet(2)) { @@ -72,6 +73,7 @@ public class CmdFactionsPerm extends FCommand if (val == null) return; // Do the change + System.out.println("setRelationPermitted perm "+perm+", rel "+rel+", val "+val); faction.setRelationPermitted(perm, rel, val); // The following is to make sure the leader always has the right to change perms if that is our goal. diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/com/massivecraft/factions/entity/Faction.java index 512140a0..b54dd76c 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/com/massivecraft/factions/entity/Faction.java @@ -22,6 +22,7 @@ import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.store.Entity; import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.SenderUtil; +import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; public class Faction extends Entity implements EconomyParticipator @@ -660,6 +661,9 @@ 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; @@ -694,6 +698,10 @@ public class Faction extends Entity implements EconomyParticipator public void setRelationPermitted(FPerm perm, Rel rel, boolean permitted) { Map> perms = this.getPerms(); + + System.out.println("setRelationPermitted before:"); + System.out.println(Factions.get().gson.toJson(perms, new TypeToken>>(){}.getType())); + Set rels = perms.get(perm); if (permitted) @@ -705,6 +713,9 @@ public class Faction extends Entity implements EconomyParticipator rels.remove(rel); } + System.out.println("setRelationPermitted after:"); + System.out.println(Factions.get().gson.toJson(perms, new TypeToken>>(){}.getType())); + this.setPerms(perms); }