Fixing one permission check bug and adding some debug output in hope to find that bug.

This commit is contained in:
Olof Larsson 2013-04-29 16:29:10 +02:00
parent 709c1fe80d
commit cf03bd5b8a
3 changed files with 15 additions and 2 deletions

View File

@ -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));

View File

@ -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.

View File

@ -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<Faction> implements EconomyParticipator
@ -660,6 +661,9 @@ 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
if (MUtil.equals(this.perms, target)) return;
@ -694,6 +698,10 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public void setRelationPermitted(FPerm perm, Rel rel, boolean permitted)
{
Map<FPerm, Set<Rel>> perms = this.getPerms();
System.out.println("setRelationPermitted before:");
System.out.println(Factions.get().gson.toJson(perms, new TypeToken<Map<FPerm, Set<Rel>>>(){}.getType()));
Set<Rel> rels = perms.get(perm);
if (permitted)
@ -705,6 +713,9 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
rels.remove(rel);
}
System.out.println("setRelationPermitted after:");
System.out.println(Factions.get().gson.toJson(perms, new TypeToken<Map<FPerm, Set<Rel>>>(){}.getType()));
this.setPerms(perms);
}