From 8eec55e37e882cf04660021858d9b6e8947562b5 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Mon, 24 Oct 2011 13:02:48 +0200 Subject: [PATCH] asdf --- .../factions/integration/Econ.java | 4 ---- .../massivecraft/factions/struct/FFlag.java | 6 ++--- .../massivecraft/factions/struct/FPerm.java | 14 ++++++++---- .../factions/struct/Permission.java | 6 ++--- .../factions/util/RelationUtil.java | 22 ++++++++++--------- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/com/massivecraft/factions/integration/Econ.java b/src/com/massivecraft/factions/integration/Econ.java index 8e5d666b..6fb310cb 100644 --- a/src/com/massivecraft/factions/integration/Econ.java +++ b/src/com/massivecraft/factions/integration/Econ.java @@ -17,7 +17,6 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.P; import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.struct.FPerm; -import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.util.RelationUtil; public class Econ @@ -95,9 +94,6 @@ public class Econ // Bypassing players can do any kind of transaction if (i instanceof FPlayer && ((FPlayer)i).isAdminBypassing()) return true; - // Players with the any withdraw can do. - if (i instanceof FPlayer && Permission.MONEY_WITHDRAW_ANY.has(((FPlayer)i).getPlayer())) return true; - // You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again. if (i == you) return true; diff --git a/src/com/massivecraft/factions/struct/FFlag.java b/src/com/massivecraft/factions/struct/FFlag.java index 17213aab..1b99e5b2 100644 --- a/src/com/massivecraft/factions/struct/FFlag.java +++ b/src/com/massivecraft/factions/struct/FFlag.java @@ -25,7 +25,7 @@ public enum FFlag MONSTERS("monsters", "Can monsters spawn in this territory?", true, false), EXPLOSIONS("explosions", "Can explosions occur in this territory?", true, false), FIRESPREAD("firespread", "Can fire spread in territory?", true, false), - LIGHTNING("lightning", "Can lightning strike in this territory?", true, false), + //LIGHTNING("lightning", "Can lightning strike in this territory?", true, false), Possible to add later. ENDERGRIEF("endergrief", "Can endermen grief in this territory?", false, true), ; @@ -86,13 +86,13 @@ public enum FFlag if (str.startsWith("m")) return MONSTERS; if (str.startsWith("e")) return EXPLOSIONS; if (str.startsWith("fi")) return FIRESPREAD; - if (str.startsWith("l")) return LIGHTNING; + //if (str.startsWith("l")) return LIGHTNING; return null; } public String getStateInfo(boolean value, boolean withDesc) { - String ret = (value ? "YES" : "NOO") + " " + this.getNicename(); + String ret = (value ? "YES" : "NOO") + " " + this.getNicename(); if (withDesc) { ret += " " + this.getDescription(); diff --git a/src/com/massivecraft/factions/struct/FPerm.java b/src/com/massivecraft/factions/struct/FPerm.java index ce13b6f4..313bffa2 100644 --- a/src/com/massivecraft/factions/struct/FPerm.java +++ b/src/com/massivecraft/factions/struct/FPerm.java @@ -14,7 +14,6 @@ import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; import com.massivecraft.factions.iface.RelationParticipator; -import com.massivecraft.factions.util.RelationUtil; /** * Permissions that you (a player) may or may not have in the territory of a certain faction. @@ -103,7 +102,7 @@ public enum FPerm ret += " "; } - ret +=""+this.getNicename(); + ret +=""+this.getNicename(); if (withDesc) { ret += " " + this.getDescription(); @@ -149,8 +148,15 @@ public enum FPerm private static final String errorpattern = "%s can't %s in the territory of %s."; public boolean has(RelationParticipator testSubject, Faction hostFaction, boolean informIfNot) { - Faction factionDoer = RelationUtil.getFaction(testSubject); - boolean ret = hostFaction.getPermittedRelations(this).contains(hostFaction.getRelationTo(factionDoer)); + //Faction factionDoer = RelationUtil.getFaction(testSubject); + //P.p.log("Testing the permission "+this.toString()+" for a "+testSubject.getClass().getSimpleName()); + //P.p.log("hostFaction: "+hostFaction); + Rel rel = testSubject.getRelationTo(hostFaction); + + //P.p.log("rel: "+rel); + + boolean ret = hostFaction.getPermittedRelations(this).contains(rel); + if (!ret && informIfNot && testSubject instanceof FPlayer) { FPlayer fplayer = (FPlayer)testSubject; diff --git a/src/com/massivecraft/factions/struct/Permission.java b/src/com/massivecraft/factions/struct/Permission.java index a346e26f..565fdb3d 100644 --- a/src/com/massivecraft/factions/struct/Permission.java +++ b/src/com/massivecraft/factions/struct/Permission.java @@ -16,7 +16,7 @@ public enum Permission DEINVITE("deinvite"), DESCRIPTION("description"), DISBAND("disband"), - DISBAND_ANY("disband.any"), + DISBAND_ANY("disband.any"), // WHAT TO DO? FLAG("flag"), FLAG_ANY("flag.any"), PERM("perm"), @@ -36,7 +36,7 @@ public enum Permission MONEY_BALANCE_ANY("money.balance.any"), MONEY_DEPOSIT("money.deposit"), MONEY_WITHDRAW("money.withdraw"), - MONEY_WITHDRAW_ANY("money.withdraw.any"), + MONEY_WITHDRAW_ANY("money.withdraw.any"), // WHAT TO DO? MONEY_F2F("money.f2f"), MONEY_F2P("money.f2p"), MONEY_P2F("money.p2f"), @@ -48,7 +48,7 @@ public enum Permission RELOAD("reload"), SAVE("save"), SETHOME("sethome"), - SETHOME_ANY("sethome.any"), + SETHOME_ANY("sethome.any"), // WHAT TO DO? SHOW("show"), TAG("tag"), TITLE("title"), diff --git a/src/com/massivecraft/factions/util/RelationUtil.java b/src/com/massivecraft/factions/util/RelationUtil.java index 1c09837b..214cc419 100644 --- a/src/com/massivecraft/factions/util/RelationUtil.java +++ b/src/com/massivecraft/factions/util/RelationUtil.java @@ -70,39 +70,41 @@ public class RelationUtil public static Rel getRelationOfThatToMe(RelationParticipator that, RelationParticipator me) { - return getRelationOfThatToMe(me, that, false); + return getRelationOfThatToMe(that, me, false); } public static Rel getRelationOfThatToMe(RelationParticipator that, RelationParticipator me, boolean ignorePeaceful) { Rel ret = null; - Faction fthat = getFaction(me); - if (fthat == null) return Rel.NEUTRAL; // ERROR + Faction myFaction = getFaction(me); + if (myFaction == null) return Rel.NEUTRAL; // ERROR - Faction fme = getFaction(that); - if (fme == null) return Rel.NEUTRAL; // ERROR + Faction thatFaction = getFaction(that); + if (thatFaction == null) return Rel.NEUTRAL; // ERROR // The faction with the lowest wish "wins" - if (fme.getRelationWish(fthat).isLessThan(fthat.getRelationWish(fme))) + if (thatFaction.getRelationWish(myFaction).isLessThan(myFaction.getRelationWish(thatFaction))) { - ret = fme.getRelationWish(fthat); + ret = thatFaction.getRelationWish(myFaction); } else { - ret = fthat.getRelationWish(fme); + ret = myFaction.getRelationWish(thatFaction); } - if (fthat.equals(fme)) + if (myFaction.equals(thatFaction)) { ret = Rel.MEMBER; // Do officer and leader check + //P.p.log("getRelationOfThatToMe the factions are the same for "+that.getClass().getSimpleName()+" and observer "+me.getClass().getSimpleName()); if (that instanceof FPlayer) { ret = ((FPlayer)that).getRole(); + //P.p.log("getRelationOfThatToMe it was a player and role is "+ret); } } - else if (!ignorePeaceful && (fme.getFlag(FFlag.PEACEFUL) || fthat.getFlag(FFlag.PEACEFUL))) + else if (!ignorePeaceful && (thatFaction.getFlag(FFlag.PEACEFUL) || myFaction.getFlag(FFlag.PEACEFUL))) { ret = Rel.TRUCE; }