This commit is contained in:
Olof Larsson 2011-10-24 13:02:48 +02:00
parent 5f437b1862
commit 8eec55e37e
5 changed files with 28 additions and 24 deletions

View File

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

View File

@ -25,7 +25,7 @@ public enum FFlag
MONSTERS("monsters", "<i>Can monsters spawn in this territory?", true, false),
EXPLOSIONS("explosions", "<i>Can explosions occur in this territory?", true, false),
FIRESPREAD("firespread", "<i>Can fire spread in territory?", true, false),
LIGHTNING("lightning", "<i>Can lightning strike in this territory?", true, false),
//LIGHTNING("lightning", "<i>Can lightning strike in this territory?", true, false), Possible to add later.
ENDERGRIEF("endergrief", "<i>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 ? "<g>YES" : "<b>NOO") + "<h> " + this.getNicename();
String ret = (value ? "<g>YES" : "<b>NOO") + "<c> " + this.getNicename();
if (withDesc)
{
ret += " " + this.getDescription();

View File

@ -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 +="<h>"+this.getNicename();
ret +="<c>"+this.getNicename();
if (withDesc)
{
ret += " <i>" + this.getDescription();
@ -149,8 +148,15 @@ public enum FPerm
private static final String errorpattern = "<b>%s<b> can't %s in the territory of %s<b>.";
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;

View File

@ -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"),

View File

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