Changed permission view. Bank withdraw permission in the works
This commit is contained in:
parent
99e8acd79f
commit
5f437b1862
@ -187,7 +187,7 @@ public class Conf
|
||||
|
||||
//Faction banks, to pay for land claiming and other costs instead of individuals paying for them
|
||||
public static boolean bankEnabled = true;
|
||||
public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction
|
||||
//public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction
|
||||
public static boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome
|
||||
public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs.
|
||||
|
||||
|
@ -46,13 +46,6 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
}
|
||||
return this.getTag(this.getColorTo(observer).toString());
|
||||
}
|
||||
public String getTag(FPlayer otherFplayer) {
|
||||
if (otherFplayer == null)
|
||||
{
|
||||
return getTag();
|
||||
}
|
||||
return this.getTag(this.getColorTo(otherFplayer).toString());
|
||||
}
|
||||
public void setTag(String str)
|
||||
{
|
||||
if (Conf.factionTagForceUpperCase)
|
||||
|
@ -113,11 +113,11 @@ public class Factions extends EntityCollection<Faction>
|
||||
faction.setFlag(FFlag.LIGHTNING, true);
|
||||
faction.setFlag(FFlag.ENDERGRIEF, true);
|
||||
|
||||
faction.setPermittedRelations(FPerm.BUILD, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.DOOR, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.CONTAINER, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.BUTTON, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.LEVER, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.BUILD, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
faction.setPermittedRelations(FPerm.DOOR, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
faction.setPermittedRelations(FPerm.CONTAINER, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
faction.setPermittedRelations(FPerm.BUTTON, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
faction.setPermittedRelations(FPerm.LEVER, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
}
|
||||
|
||||
public void setFlagsForSafeZone(Faction faction)
|
||||
@ -134,11 +134,10 @@ public class Factions extends EntityCollection<Faction>
|
||||
faction.setFlag(FFlag.LIGHTNING, false);
|
||||
faction.setFlag(FFlag.ENDERGRIEF, false);
|
||||
|
||||
faction.setPermittedRelations(FPerm.BUILD, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.DOOR, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.CONTAINER, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.BUTTON, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.LEVER, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.DOOR, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
faction.setPermittedRelations(FPerm.CONTAINER, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
faction.setPermittedRelations(FPerm.BUTTON, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
faction.setPermittedRelations(FPerm.LEVER, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
}
|
||||
|
||||
public void setFlagsForWarZone(Faction faction)
|
||||
@ -155,11 +154,10 @@ public class Factions extends EntityCollection<Faction>
|
||||
faction.setFlag(FFlag.LIGHTNING, true);
|
||||
faction.setFlag(FFlag.ENDERGRIEF, true);
|
||||
|
||||
faction.setPermittedRelations(FPerm.BUILD, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.DOOR, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.CONTAINER, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.BUTTON, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.LEVER, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.DOOR, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
faction.setPermittedRelations(FPerm.CONTAINER, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
faction.setPermittedRelations(FPerm.BUTTON, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
faction.setPermittedRelations(FPerm.LEVER, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class CmdFlag extends FCommand
|
||||
|
||||
if ( ! this.argIsSet(1))
|
||||
{
|
||||
msg(p.txt.titleize("Flags for " + faction.describeTo(fme)));
|
||||
msg(p.txt.titleize("Flags for " + faction.describeTo(fme, true)));
|
||||
for (FFlag flag : FFlag.values())
|
||||
{
|
||||
msg(flag.getStateInfo(faction.getFlag(flag), true));
|
||||
@ -51,7 +51,7 @@ public class CmdFlag extends FCommand
|
||||
if (flag == null) return;
|
||||
if ( ! this.argIsSet(2))
|
||||
{
|
||||
msg(p.txt.titleize("Flag for " + faction.describeTo(fme)));
|
||||
msg(p.txt.titleize("Flag for " + faction.describeTo(fme, true)));
|
||||
msg(flag.getStateInfo(faction.getFlag(flag), true));
|
||||
return;
|
||||
}
|
||||
@ -81,7 +81,7 @@ public class CmdFlag extends FCommand
|
||||
}
|
||||
|
||||
// Do the change
|
||||
msg(p.txt.titleize("Flag for " + faction.describeTo(fme)));
|
||||
msg(p.txt.titleize("Flag for " + faction.describeTo(fme, true)));
|
||||
faction.setFlag(flag, targetValue);
|
||||
msg(flag.getStateInfo(faction.getFlag(flag), true));
|
||||
}
|
||||
|
@ -44,7 +44,8 @@ public class CmdPerm extends FCommand
|
||||
|
||||
if ( ! this.argIsSet(1))
|
||||
{
|
||||
msg(p.txt.titleize("Perms for " + faction.describeTo(fme)));
|
||||
msg(p.txt.titleize("Perms for " + faction.describeTo(fme, true)));
|
||||
msg(FPerm.getStateHeaders());
|
||||
for (FPerm perm : FPerm.values())
|
||||
{
|
||||
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
|
||||
@ -56,7 +57,8 @@ public class CmdPerm extends FCommand
|
||||
if (perm == null) return;
|
||||
if ( ! this.argIsSet(2))
|
||||
{
|
||||
msg(p.txt.titleize("Perm for " + faction.describeTo(fme)));
|
||||
msg(p.txt.titleize("Perm for " + faction.describeTo(fme, true)));
|
||||
msg(FPerm.getStateHeaders());
|
||||
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
|
||||
return;
|
||||
}
|
||||
@ -81,7 +83,8 @@ public class CmdPerm extends FCommand
|
||||
|
||||
// Do the change
|
||||
faction.setPermittedRelations(perm, targetValue);
|
||||
msg(p.txt.titleize("Perm for " + faction.describeTo(fme)));
|
||||
msg(p.txt.titleize("Perm for " + faction.describeTo(fme, true)));
|
||||
msg(FPerm.getStateHeaders());
|
||||
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,8 @@ import com.massivecraft.factions.Faction;
|
||||
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.struct.Rel;
|
||||
import com.massivecraft.factions.util.RelationUtil;
|
||||
|
||||
public class Econ
|
||||
@ -106,8 +106,8 @@ public class Econ
|
||||
// Ohh by the way... Yes it could. For daily rent to the faction.
|
||||
if (i == fI && fI == fYou) return true;
|
||||
|
||||
// Factions can be controlled by members that are moderators... or any member if any member can withdraw.
|
||||
if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer)i).getRole().isAtLeast(Rel.OFFICER))) return true;
|
||||
// Factions can be controlled by those that have permissions
|
||||
if (you instanceof Faction && FPerm.WITHDRAW.has(i, fYou)) return true;
|
||||
|
||||
// Otherwise you may not! ;,,;
|
||||
i.msg("<h>%s<i> lack permission to controll <h>%s's<i> money.", i.describeTo(i, true), you.describeTo(i));
|
||||
|
@ -15,7 +15,6 @@ import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.iface.RelationParticipator;
|
||||
import com.massivecraft.factions.util.RelationUtil;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
|
||||
/**
|
||||
* Permissions that you (a player) may or may not have in the territory of a certain faction.
|
||||
@ -23,12 +22,13 @@ import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
*/
|
||||
public enum FPerm
|
||||
{
|
||||
BUILD("build", "edit the terrain", Rel.MEMBER),
|
||||
BUILD("build", "edit the terrain", Rel.LEADER, Rel.OFFICER, Rel.MEMBER),
|
||||
PAINBUILD("painbuild", "edit but take damage", Rel.ALLY),
|
||||
DOOR("door", "use doors", Rel.MEMBER, Rel.ALLY),
|
||||
CONTAINER("container", "use containers", Rel.MEMBER),
|
||||
BUTTON("button", "use stone buttons", Rel.MEMBER, Rel.ALLY),
|
||||
LEVER("lever", "use levers", Rel.MEMBER, Rel.ALLY),
|
||||
DOOR("door", "use doors", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY),
|
||||
CONTAINER("container", "use containers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER),
|
||||
BUTTON("button", "use stone buttons", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY),
|
||||
LEVER("lever", "use levers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY),
|
||||
WITHDRAW("withdraw", "withdraw faction money", Rel.LEADER, Rel.OFFICER),
|
||||
;
|
||||
|
||||
private final String nicename;
|
||||
@ -69,27 +69,41 @@ public enum FPerm
|
||||
if (str.startsWith("c")) return CONTAINER;
|
||||
if (str.startsWith("but")) return BUTTON;
|
||||
if (str.startsWith("l")) return LEVER;
|
||||
if (str.startsWith("w")) return WITHDRAW;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getStateHeaders()
|
||||
{
|
||||
String ret = "";
|
||||
for (Rel rel : Rel.values())
|
||||
{
|
||||
ret += rel.getColor().toString();
|
||||
ret += rel.toString().substring(0, 3);
|
||||
ret += " ";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getStateInfo(Set<Rel> value, boolean withDesc)
|
||||
{
|
||||
String ret = "<h>"+this.getNicename()+ " ";
|
||||
String ret = "";
|
||||
|
||||
List<String> rels = new ArrayList<String>();
|
||||
for (Rel rel : value)
|
||||
for (Rel rel : Rel.values())
|
||||
{
|
||||
rels.add("<p>"+rel);
|
||||
}
|
||||
if (rels.size() > 0)
|
||||
if (value.contains(rel))
|
||||
{
|
||||
ret += TextUtil.implode(rels, "<c>+");
|
||||
ret += "<g>YES";
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += "NOONE";
|
||||
ret += "<b>NOO";
|
||||
}
|
||||
ret += " ";
|
||||
}
|
||||
|
||||
ret +="<h>"+this.getNicename();
|
||||
if (withDesc)
|
||||
{
|
||||
ret += " <i>" + this.getDescription();
|
||||
@ -133,18 +147,26 @@ 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, FLocation floc, boolean informIfNot)
|
||||
public boolean has(RelationParticipator testSubject, Faction hostFaction, boolean informIfNot)
|
||||
{
|
||||
Faction factionThere = Board.getFactionAt(floc);
|
||||
Faction factionDoer = RelationUtil.getFaction(testSubject);
|
||||
boolean ret = factionThere.getPermittedRelations(this).contains(factionThere.getRelationTo(factionDoer));
|
||||
boolean ret = hostFaction.getPermittedRelations(this).contains(hostFaction.getRelationTo(factionDoer));
|
||||
if (!ret && informIfNot && testSubject instanceof FPlayer)
|
||||
{
|
||||
FPlayer fplayer = (FPlayer)testSubject;
|
||||
fplayer.msg(errorpattern, fplayer.describeTo(fplayer, true), this.getDescription(), factionThere.describeTo(fplayer));
|
||||
fplayer.msg(errorpattern, fplayer.describeTo(fplayer, true), this.getDescription(), hostFaction.describeTo(fplayer));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public boolean has(RelationParticipator testSubject, Faction hostFaction)
|
||||
{
|
||||
return this.has(testSubject, hostFaction, false);
|
||||
}
|
||||
public boolean has(RelationParticipator testSubject, FLocation floc, boolean informIfNot)
|
||||
{
|
||||
Faction factionThere = Board.getFactionAt(floc);
|
||||
return this.has(testSubject, factionThere, informIfNot);
|
||||
}
|
||||
public boolean has(RelationParticipator testSubject, Location loc, boolean informIfNot)
|
||||
{
|
||||
FLocation floc = new FLocation(loc);
|
||||
|
@ -93,7 +93,7 @@ public enum Rel
|
||||
|
||||
public ChatColor getColor()
|
||||
{
|
||||
if (this == MEMBER)
|
||||
if (this.isAtLeast(MEMBER))
|
||||
return Conf.colorMember;
|
||||
else if (this == ALLY)
|
||||
return Conf.colorAlly;
|
||||
|
Loading…
Reference in New Issue
Block a user