Some flag tweaks. Use same name scheme as permissions. Also added deposit permission.

This commit is contained in:
Olof Larsson 2014-10-07 12:30:44 +02:00
parent 662dbb85ed
commit 4286a0c1a0
13 changed files with 131 additions and 120 deletions

View File

@ -49,7 +49,7 @@ public class CmdFactionsDisband extends FactionsCommand
if ( ! MPerm.getPermDisband().has(msender, faction, true)) return; if ( ! MPerm.getPermDisband().has(msender, faction, true)) return;
// Verify // Verify
if (faction.getFlag(MFlag.getPermanent())) if (faction.getFlag(MFlag.getFlagPermanent()))
{ {
msg("<i>This faction is designated as permanent, so you cannot disband it."); msg("<i>This faction is designated as permanent, so you cannot disband it.");
return; return;

View File

@ -78,7 +78,7 @@ public class CmdFactionsFaction extends FactionsCommand
// INFO: Open // INFO: Open
// TODO: Why hardcode displaying the open flag only? We should rather display everything publicly editable. // TODO: Why hardcode displaying the open flag only? We should rather display everything publicly editable.
msg("<a>Open: <i>"+(faction.getFlag(MFlag.getOpen()) ? "<lime>Yes<i>, anyone can join" : "<rose>No<i>, only invited people can join")); msg("<a>Open: <i>"+(faction.getFlag(MFlag.getFlagOpen()) ? "<lime>Yes<i>, anyone can join" : "<rose>No<i>, only invited people can join"));
// INFO: Power // INFO: Power
double powerBoost = faction.getPowerBoost(); double powerBoost = faction.getPowerBoost();
@ -120,12 +120,12 @@ public class CmdFactionsFaction extends FactionsCommand
// Display important flags // Display important flags
// TODO: Find the non default flags, and display them instead. // TODO: Find the non default flags, and display them instead.
if (faction.getFlag(MFlag.getPermanent())) if (faction.getFlag(MFlag.getFlagPermanent()))
{ {
msg("<a>This faction is permanent - remaining even with no followers."); msg("<a>This faction is permanent - remaining even with no followers.");
} }
if (faction.getFlag(MFlag.getPeaceful())) if (faction.getFlag(MFlag.getFlagPeaceful()))
{ {
msg("<a>This faction is peaceful - in truce with everyone."); msg("<a>This faction is peaceful - in truce with everyone.");
} }
@ -136,7 +136,7 @@ public class CmdFactionsFaction extends FactionsCommand
// List the relations to other factions // List the relations to other factions
Map<Rel, List<String>> relationNames = faction.getFactionNamesPerRelation(msender, true); Map<Rel, List<String>> relationNames = faction.getFactionNamesPerRelation(msender, true);
if (faction.getFlag(MFlag.getPeaceful())) if (faction.getFlag(MFlag.getFlagPeaceful()))
{ {
sendMessage(Txt.parse("<a>In Truce with:<i> *everyone*")); sendMessage(Txt.parse("<a>In Truce with:<i> *everyone*"));
} }

View File

@ -97,7 +97,7 @@ public class CmdFactionsHome extends FactionsCommandHome
( (
MConf.get().homesTeleportAllowedEnemyDistance > 0 MConf.get().homesTeleportAllowedEnemyDistance > 0
&& &&
factionHere.getFlag(MFlag.getPvp()) factionHere.getFlag(MFlag.getFlagPvp())
&& &&
( (
! msender.isInOwnTerritory() ! msender.isInOwnTerritory()

View File

@ -80,7 +80,7 @@ public class CmdFactionsJoin extends FactionsCommand
return; return;
} }
if( ! (faction.getFlag(MFlag.getOpen()) || faction.isInvited(mplayer) || msender.isUsingAdminMode() || Perm.JOIN_ANY.has(sender, false))) if( ! (faction.getFlag(MFlag.getFlagOpen()) || faction.isInvited(mplayer) || msender.isUsingAdminMode() || Perm.JOIN_ANY.has(sender, false)))
{ {
msg("<i>This faction requires invitation."); msg("<i>This faction requires invitation.");
if (samePlayer) if (samePlayer)

View File

@ -91,13 +91,13 @@ public abstract class CmdFactionsRelationAbstract extends FactionsCommand
// TODO: The ally case should work!! // TODO: The ally case should work!!
// * this might have to be bumped up to make that happen, & allow ALLY,NEUTRAL only // * this might have to be bumped up to make that happen, & allow ALLY,NEUTRAL only
if ( newRelation != Rel.TRUCE && otherFaction.getFlag(MFlag.getPeaceful())) if ( newRelation != Rel.TRUCE && otherFaction.getFlag(MFlag.getFlagPeaceful()))
{ {
otherFaction.msg("<i>This will have no effect while your faction is peaceful."); otherFaction.msg("<i>This will have no effect while your faction is peaceful.");
msenderFaction.msg("<i>This will have no effect while their faction is peaceful."); msenderFaction.msg("<i>This will have no effect while their faction is peaceful.");
} }
if ( newRelation != Rel.TRUCE && msenderFaction.getFlag(MFlag.getPeaceful())) if ( newRelation != Rel.TRUCE && msenderFaction.getFlag(MFlag.getFlagPeaceful()))
{ {
otherFaction.msg("<i>This will have no effect while their faction is peaceful."); otherFaction.msg("<i>This will have no effect while their faction is peaceful.");
msenderFaction.msg("<i>This will have no effect while your faction is peaceful."); msenderFaction.msg("<i>This will have no effect while your faction is peaceful.");

View File

@ -885,7 +885,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public double getPower() public double getPower()
{ {
if (this.getFlag(MFlag.getInfpower())) return 999999; if (this.getFlag(MFlag.getFlagInfpower())) return 999999;
double ret = 0; double ret = 0;
for (MPlayer mplayer : this.getMPlayers()) for (MPlayer mplayer : this.getMPlayers())
@ -906,7 +906,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public double getPowerMax() public double getPowerMax()
{ {
if (this.getFlag(MFlag.getInfpower())) return 999999; if (this.getFlag(MFlag.getFlagInfpower())) return 999999;
double ret = 0; double ret = 0;
for (MPlayer mplayer : this.getMPlayers()) for (MPlayer mplayer : this.getMPlayers())
@ -1065,7 +1065,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public void promoteNewLeader() public void promoteNewLeader()
{ {
if ( ! this.isNormal()) return; if ( ! this.isNormal()) return;
if (this.getFlag(MFlag.getPermanent()) && MConf.get().permanentFactionsDisableLeaderPromotion) return; if (this.getFlag(MFlag.getFlagPermanent()) && MConf.get().permanentFactionsDisableLeaderPromotion) return;
MPlayer oldLeader = this.getLeader(); MPlayer oldLeader = this.getLeader();
@ -1079,7 +1079,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
if (replacements == null || replacements.isEmpty()) if (replacements == null || replacements.isEmpty())
{ {
// faction leader is the only member; one-man faction // faction leader is the only member; one-man faction
if (this.getFlag(MFlag.getPermanent())) if (this.getFlag(MFlag.getFlagPermanent()))
{ {
if (oldLeader != null) if (oldLeader != null)
{ {
@ -1142,8 +1142,8 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public boolean isExplosionsAllowed() public boolean isExplosionsAllowed()
{ {
boolean explosions = this.getFlag(MFlag.getExplosions()); boolean explosions = this.getFlag(MFlag.getFlagExplosions());
boolean offlineexplosions = this.getFlag(MFlag.getOfflineexplosions()); boolean offlineexplosions = this.getFlag(MFlag.getFlagOfflineexplosions());
boolean online = this.isFactionConsideredOnline(); boolean online = this.isFactionConsideredOnline();
return (online && explosions) || (!online && offlineexplosions); return (online && explosions) || (!online && offlineexplosions);

View File

@ -92,24 +92,25 @@ public class FactionColl extends Coll<Faction>
faction.setName(ChatColor.DARK_GREEN+"Wilderness"); faction.setName(ChatColor.DARK_GREEN+"Wilderness");
faction.setDescription(null); faction.setDescription(null);
faction.setFlag(MFlag.getOpen(), false); faction.setFlag(MFlag.getFlagOpen(), false);
faction.setFlag(MFlag.getPermanent(), true); faction.setFlag(MFlag.getFlagPermanent(), true);
faction.setFlag(MFlag.getPeaceful(), false); faction.setFlag(MFlag.getFlagPeaceful(), false);
faction.setFlag(MFlag.getInfpower(), true); faction.setFlag(MFlag.getFlagInfpower(), true);
faction.setFlag(MFlag.getPowerloss(), true); faction.setFlag(MFlag.getFlagPowerloss(), true);
faction.setFlag(MFlag.getPvp(), true); faction.setFlag(MFlag.getFlagPvp(), true);
faction.setFlag(MFlag.getFriendlyire(), false); faction.setFlag(MFlag.getFlagFriendlyire(), false);
faction.setFlag(MFlag.getMonsters(), true); faction.setFlag(MFlag.getFlagMonsters(), true);
faction.setFlag(MFlag.getExplosions(), true); faction.setFlag(MFlag.getFlagExplosions(), true);
faction.setFlag(MFlag.getOfflineexplosions(), true); faction.setFlag(MFlag.getFlagOfflineexplosions(), true);
faction.setFlag(MFlag.getFirespread(), true); faction.setFlag(MFlag.getFlagFirespread(), true);
faction.setFlag(MFlag.getEndergrief(), true); faction.setFlag(MFlag.getFlagEndergrief(), true);
faction.setPermittedRelations(MPerm.getPermBuild(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); faction.setPermittedRelations(MPerm.getPermBuild(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
faction.setPermittedRelations(MPerm.getPermDoor(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); faction.setPermittedRelations(MPerm.getPermDoor(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
faction.setPermittedRelations(MPerm.getPermContainer(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); faction.setPermittedRelations(MPerm.getPermContainer(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
faction.setPermittedRelations(MPerm.getPermButton(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); faction.setPermittedRelations(MPerm.getPermButton(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
faction.setPermittedRelations(MPerm.getPermLever(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); faction.setPermittedRelations(MPerm.getPermLever(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
faction.setPermittedRelations(MPerm.getPermDeposit(), Rel.LEADER, Rel.OFFICER); // Wilderness deposit should be limited as an anti spam meassure.
return faction; return faction;
} }
@ -125,18 +126,18 @@ public class FactionColl extends Coll<Faction>
faction.setName("SafeZone"); faction.setName("SafeZone");
faction.setDescription("Free from PVP and monsters"); faction.setDescription("Free from PVP and monsters");
faction.setFlag(MFlag.getOpen(), false); faction.setFlag(MFlag.getFlagOpen(), false);
faction.setFlag(MFlag.getPermanent(), true); faction.setFlag(MFlag.getFlagPermanent(), true);
faction.setFlag(MFlag.getPeaceful(), true); faction.setFlag(MFlag.getFlagPeaceful(), true);
faction.setFlag(MFlag.getInfpower(), true); faction.setFlag(MFlag.getFlagInfpower(), true);
faction.setFlag(MFlag.getPowerloss(), false); faction.setFlag(MFlag.getFlagPowerloss(), false);
faction.setFlag(MFlag.getPvp(), false); faction.setFlag(MFlag.getFlagPvp(), false);
faction.setFlag(MFlag.getFriendlyire(), false); faction.setFlag(MFlag.getFlagFriendlyire(), false);
faction.setFlag(MFlag.getMonsters(), false); faction.setFlag(MFlag.getFlagMonsters(), false);
faction.setFlag(MFlag.getExplosions(), false); faction.setFlag(MFlag.getFlagExplosions(), false);
faction.setFlag(MFlag.getOfflineexplosions(), false); faction.setFlag(MFlag.getFlagOfflineexplosions(), false);
faction.setFlag(MFlag.getFirespread(), false); faction.setFlag(MFlag.getFlagFirespread(), false);
faction.setFlag(MFlag.getEndergrief(), false); faction.setFlag(MFlag.getFlagEndergrief(), false);
faction.setPermittedRelations(MPerm.getPermDoor(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); faction.setPermittedRelations(MPerm.getPermDoor(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
faction.setPermittedRelations(MPerm.getPermContainer(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); faction.setPermittedRelations(MPerm.getPermContainer(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
@ -158,18 +159,18 @@ public class FactionColl extends Coll<Faction>
faction.setName("WarZone"); faction.setName("WarZone");
faction.setDescription("Not the safest place to be"); faction.setDescription("Not the safest place to be");
faction.setFlag(MFlag.getOpen(), false); faction.setFlag(MFlag.getFlagOpen(), false);
faction.setFlag(MFlag.getPermanent(), true); faction.setFlag(MFlag.getFlagPermanent(), true);
faction.setFlag(MFlag.getPeaceful(), true); faction.setFlag(MFlag.getFlagPeaceful(), true);
faction.setFlag(MFlag.getInfpower(), true); faction.setFlag(MFlag.getFlagInfpower(), true);
faction.setFlag(MFlag.getPowerloss(), true); faction.setFlag(MFlag.getFlagPowerloss(), true);
faction.setFlag(MFlag.getPvp(), true); faction.setFlag(MFlag.getFlagPvp(), true);
faction.setFlag(MFlag.getFriendlyire(), true); faction.setFlag(MFlag.getFlagFriendlyire(), true);
faction.setFlag(MFlag.getMonsters(), true); faction.setFlag(MFlag.getFlagMonsters(), true);
faction.setFlag(MFlag.getExplosions(), true); faction.setFlag(MFlag.getFlagExplosions(), true);
faction.setFlag(MFlag.getOfflineexplosions(), true); faction.setFlag(MFlag.getFlagOfflineexplosions(), true);
faction.setFlag(MFlag.getFirespread(), true); faction.setFlag(MFlag.getFlagFirespread(), true);
faction.setFlag(MFlag.getEndergrief(), true); faction.setFlag(MFlag.getFlagEndergrief(), true);
faction.setPermittedRelations(MPerm.getPermDoor(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); faction.setPermittedRelations(MPerm.getPermDoor(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
faction.setPermittedRelations(MPerm.getPermContainer(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); faction.setPermittedRelations(MPerm.getPermContainer(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);
@ -195,7 +196,7 @@ public class FactionColl extends Coll<Faction>
for (Faction faction : this.getAll()) for (Faction faction : this.getAll())
{ {
int landCount = faction.getLandCount(); int landCount = faction.getLandCount();
if (!faction.getFlag(MFlag.getPeaceful()) && landCount > 0) if (!faction.getFlag(MFlag.getFlagPeaceful()) && landCount > 0)
{ {
List<MPlayer> players = faction.getMPlayers(); List<MPlayer> players = faction.getMPlayers();
int playerCount = players.size(); int playerCount = players.size();

View File

@ -56,32 +56,32 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable
public static void setupStandardFlags() public static void setupStandardFlags()
{ {
getOpen(); getFlagOpen();
getMonsters(); getFlagMonsters();
getPowerloss(); getFlagPowerloss();
getPvp(); getFlagPvp();
getFriendlyire(); getFlagFriendlyire();
getExplosions(); getFlagExplosions();
getOfflineexplosions(); getFlagOfflineexplosions();
getFirespread(); getFlagFirespread();
getEndergrief(); getFlagEndergrief();
getPermanent(); getFlagPermanent();
getPeaceful(); getFlagPeaceful();
getInfpower(); getFlagInfpower();
} }
public static MFlag getOpen() { return getCreative(PRIORITY_OPEN, ID_OPEN, ID_OPEN, "Open factions can be joined without invite.", false, true, true); } public static MFlag getFlagOpen() { return getCreative(PRIORITY_OPEN, ID_OPEN, ID_OPEN, "Open factions can be joined without invite.", false, true, true); }
public static MFlag getMonsters() { return getCreative(PRIORITY_MONSTERS, ID_MONSTERS, ID_MONSTERS, "Can monsters spawn in this territory?", false, true, true); } public static MFlag getFlagMonsters() { return getCreative(PRIORITY_MONSTERS, ID_MONSTERS, ID_MONSTERS, "Can monsters spawn in this territory?", false, true, true); }
public static MFlag getPowerloss() { return getCreative(PRIORITY_POWERLOSS, ID_POWERLOSS, ID_POWERLOSS, "Is power lost on death in this territory?", true, false, true); } public static MFlag getFlagPowerloss() { return getCreative(PRIORITY_POWERLOSS, ID_POWERLOSS, ID_POWERLOSS, "Is power lost on death in this territory?", true, false, true); }
public static MFlag getPvp() { return getCreative(PRIORITY_PVP, ID_PVP, ID_PVP, "Can you PVP in territory?", true, false, true); } public static MFlag getFlagPvp() { return getCreative(PRIORITY_PVP, ID_PVP, ID_PVP, "Can you PVP in territory?", true, false, true); }
public static MFlag getFriendlyire() { return getCreative(PRIORITY_FRIENDLYFIRE, ID_FRIENDLYFIRE, ID_FRIENDLYFIRE, "Can friends hurt eachother here?", false, false, true); } public static MFlag getFlagFriendlyire() { return getCreative(PRIORITY_FRIENDLYFIRE, ID_FRIENDLYFIRE, ID_FRIENDLYFIRE, "Can friends hurt eachother here?", false, false, true); }
public static MFlag getExplosions() { return getCreative(PRIORITY_EXPLOSIONS, ID_EXPLOSIONS, ID_EXPLOSIONS, "Can explosions occur in this territory?", true, false, true); } public static MFlag getFlagExplosions() { return getCreative(PRIORITY_EXPLOSIONS, ID_EXPLOSIONS, ID_EXPLOSIONS, "Can explosions occur in this territory?", true, false, true); }
public static MFlag getOfflineexplosions() { return getCreative(PRIORITY_OFFLINEEXPLOSIONS, ID_OFFLINEEXPLOSIONS, ID_OFFLINEEXPLOSIONS, "Can explosions occur if faction is offline?", false, false, true); } public static MFlag getFlagOfflineexplosions() { return getCreative(PRIORITY_OFFLINEEXPLOSIONS, ID_OFFLINEEXPLOSIONS, ID_OFFLINEEXPLOSIONS, "Can explosions occur if faction is offline?", false, false, true); }
public static MFlag getFirespread() { return getCreative(PRIORITY_FIRESPREAD, ID_FIRESPREAD, ID_FIRESPREAD, "Can fire spread in territory?", true, false, true); } public static MFlag getFlagFirespread() { return getCreative(PRIORITY_FIRESPREAD, ID_FIRESPREAD, ID_FIRESPREAD, "Can fire spread in territory?", true, false, true); }
public static MFlag getEndergrief() { return getCreative(PRIORITY_ENDERGRIEF, ID_ENDERGRIEF, ID_ENDERGRIEF, "Can endermen grief in this territory?", false, false, true); } public static MFlag getFlagEndergrief() { return getCreative(PRIORITY_ENDERGRIEF, ID_ENDERGRIEF, ID_ENDERGRIEF, "Can endermen grief in this territory?", false, false, true); }
public static MFlag getPermanent() { return getCreative(PRIORITY_PERMANENT, ID_PERMANENT, ID_PERMANENT, "A permanent faction will never be deleted.", false, false, true); } public static MFlag getFlagPermanent() { return getCreative(PRIORITY_PERMANENT, ID_PERMANENT, ID_PERMANENT, "A permanent faction will never be deleted.", false, false, true); }
public static MFlag getPeaceful() { return getCreative(PRIORITY_PEACEFUL, ID_PEACEFUL, ID_PEACEFUL, "Always in truce with other factions.", false, false, true); } public static MFlag getFlagPeaceful() { return getCreative(PRIORITY_PEACEFUL, ID_PEACEFUL, ID_PEACEFUL, "Always in truce with other factions.", false, false, true); }
public static MFlag getInfpower() { return getCreative(PRIORITY_INFPOWER, ID_INFPOWER, ID_INFPOWER, "This flag gives the faction infinite power.", false, false, true); } public static MFlag getFlagInfpower() { return getCreative(PRIORITY_INFPOWER, ID_INFPOWER, ID_INFPOWER, "This flag gives the faction infinite power.", false, false, true); }
public static MFlag getCreative(int priority, String id, String name, String desc, boolean standard, boolean editable, boolean visible) public static MFlag getCreative(int priority, String id, String name, String desc, boolean standard, boolean editable, boolean visible)
{ {

View File

@ -39,6 +39,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable
public final static transient String ID_TITLE = "title"; public final static transient String ID_TITLE = "title";
public final static transient String ID_HOME = "home"; public final static transient String ID_HOME = "home";
public final static transient String ID_SETHOME = "sethome"; public final static transient String ID_SETHOME = "sethome";
public final static transient String ID_DEPOSIT = "deposit";
public final static transient String ID_WITHDRAW = "withdraw"; public final static transient String ID_WITHDRAW = "withdraw";
public final static transient String ID_TERRITORY = "territory"; public final static transient String ID_TERRITORY = "territory";
public final static transient String ID_ACCESS = "access"; public final static transient String ID_ACCESS = "access";
@ -62,13 +63,14 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable
public final static transient int PRIORITY_TITLE = 12000; public final static transient int PRIORITY_TITLE = 12000;
public final static transient int PRIORITY_HOME = 13000; public final static transient int PRIORITY_HOME = 13000;
public final static transient int PRIORITY_SETHOME = 14000; public final static transient int PRIORITY_SETHOME = 14000;
public final static transient int PRIORITY_WITHDRAW = 15000; public final static transient int PRIORITY_DEPOSIT = 15000;
public final static transient int PRIORITY_TERRITORY = 16000; public final static transient int PRIORITY_WITHDRAW = 16000;
public final static transient int PRIORITY_ACCESS = 17000; public final static transient int PRIORITY_TERRITORY = 17000;
public final static transient int PRIORITY_REL = 18000; public final static transient int PRIORITY_ACCESS = 18000;
public final static transient int PRIORITY_DISBAND = 19000; public final static transient int PRIORITY_REL = 19000;
public final static transient int PRIORITY_FLAGS = 20000; public final static transient int PRIORITY_DISBAND = 20000;
public final static transient int PRIORITY_PERMS = 21000; public final static transient int PRIORITY_FLAGS = 21000;
public final static transient int PRIORITY_PERMS = 22000;
// -------------------------------------------- // // -------------------------------------------- //
// META: CORE // META: CORE
@ -101,6 +103,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable
getPermTitle(); getPermTitle();
getPermHome(); getPermHome();
getPermSethome(); getPermSethome();
getPermDeposit();
getPermWithdraw(); getPermWithdraw();
getPermTerritory(); getPermTerritory();
getPermAccess(); getPermAccess();
@ -125,6 +128,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable
public static MPerm getPermTitle() { return getCreative(PRIORITY_TITLE, ID_TITLE, ID_TITLE, "set titles", MUtil.set(Rel.LEADER, Rel.OFFICER), false, true, true); } public static MPerm getPermTitle() { return getCreative(PRIORITY_TITLE, ID_TITLE, ID_TITLE, "set titles", MUtil.set(Rel.LEADER, Rel.OFFICER), false, true, true); }
public static MPerm getPermHome() { return getCreative(PRIORITY_HOME, ID_HOME, ID_HOME, "teleport home", MUtil.set(Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), false, true, true); } public static MPerm getPermHome() { return getCreative(PRIORITY_HOME, ID_HOME, ID_HOME, "teleport home", MUtil.set(Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), false, true, true); }
public static MPerm getPermSethome() { return getCreative(PRIORITY_SETHOME, ID_SETHOME, ID_SETHOME, "set the home", MUtil.set(Rel.LEADER, Rel.OFFICER), false, true, true); } public static MPerm getPermSethome() { return getCreative(PRIORITY_SETHOME, ID_SETHOME, ID_SETHOME, "set the home", MUtil.set(Rel.LEADER, Rel.OFFICER), false, true, true); }
public static MPerm getPermDeposit() { return getCreative(PRIORITY_DEPOSIT, ID_DEPOSIT, ID_DEPOSIT, "deposit money", MUtil.set(Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), false, false, false); } // non editable, non visible.
public static MPerm getPermWithdraw() { return getCreative(PRIORITY_WITHDRAW, ID_WITHDRAW, ID_WITHDRAW, "withdraw money", MUtil.set(Rel.LEADER, Rel.OFFICER), false, true, true); } public static MPerm getPermWithdraw() { return getCreative(PRIORITY_WITHDRAW, ID_WITHDRAW, ID_WITHDRAW, "withdraw money", MUtil.set(Rel.LEADER, Rel.OFFICER), false, true, true); }
public static MPerm getPermTerritory() { return getCreative(PRIORITY_TERRITORY, ID_TERRITORY, ID_TERRITORY, "claim or unclaim", MUtil.set(Rel.LEADER, Rel.OFFICER), false, true, true); } public static MPerm getPermTerritory() { return getCreative(PRIORITY_TERRITORY, ID_TERRITORY, ID_TERRITORY, "claim or unclaim", MUtil.set(Rel.LEADER, Rel.OFFICER), false, true, true); }
public static MPerm getPermAccess() { return getCreative(PRIORITY_ACCESS, ID_ACCESS, ID_ACCESS, "grant territory", MUtil.set(Rel.LEADER, Rel.OFFICER), false, true, true); } public static MPerm getPermAccess() { return getCreative(PRIORITY_ACCESS, ID_ACCESS, ID_ACCESS, "grant territory", MUtil.set(Rel.LEADER, Rel.OFFICER), false, true, true); }

View File

@ -734,7 +734,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
{ {
Faction myFaction = this.getFaction(); Faction myFaction = this.getFaction();
boolean permanent = myFaction.getFlag(MFlag.getPermanent()); boolean permanent = myFaction.getFlag(MFlag.getFlagPermanent());
if (myFaction.getMPlayers().size() > 1) if (myFaction.getMPlayers().size() > 1)
{ {
@ -824,7 +824,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
int ownedLand = newFaction.getLandCount(); int ownedLand = newFaction.getLandCount();
if (mconf.claimedLandsMax != 0 && ownedLand >= mconf.claimedLandsMax && ! newFaction.getFlag(MFlag.getInfpower())) if (mconf.claimedLandsMax != 0 && ownedLand >= mconf.claimedLandsMax && ! newFaction.getFlag(MFlag.getFlagInfpower()))
{ {
msg("<b>Limit reached. You can't claim more land."); msg("<b>Limit reached. You can't claim more land.");
return false; return false;

View File

@ -51,12 +51,12 @@ public class Econ
public static void modifyUniverseMoney(Object universe, double delta) public static void modifyUniverseMoney(Object universe, double delta)
{ {
if (!isEnabled()) return; if ( ! isEnabled()) return;
if (MConf.get().econUniverseAccount == null) return; if (MConf.get().econUniverseAccount == null) return;
if (MConf.get().econUniverseAccount.length() == 0) return; if (MConf.get().econUniverseAccount.length() == 0) return;
if (!Money.exists(MConf.get().econUniverseAccount)) return; if ( ! Money.exists(MConf.get().econUniverseAccount)) return;
Money.spawn(MConf.get().econUniverseAccount, null, delta); Money.spawn(MConf.get().econUniverseAccount, null, delta);
} }
@ -66,30 +66,30 @@ public class Econ
to.msg("<a>%s's<i> balance is <h>%s<i>.", about.describeTo(to, true), Money.format(Money.get(about))); to.msg("<a>%s's<i> balance is <h>%s<i>.", about.describeTo(to, true), Money.format(Money.get(about)));
} }
public static boolean canIControllYou(EconomyParticipator i, EconomyParticipator you) public static boolean isMePermittedYou(EconomyParticipator me, EconomyParticipator you, MPerm mperm)
{ {
Faction fI = RelationUtil.getFaction(i); // Null means special system invocation and is always to be accepted.
if (me == null) return true;
// Always accept when in admin mode.
if (me instanceof MPlayer && ((MPlayer)me).isUsingAdminMode()) return true;
// Always accept control of self
if (me == you) return true;
Faction fMe = RelationUtil.getFaction(me);
Faction fYou = RelationUtil.getFaction(you); Faction fYou = RelationUtil.getFaction(you);
// This is a system invoker. Accept it.
if (fI == null) return true;
// Bypassing players can do any kind of transaction
if (i instanceof MPlayer && ((MPlayer)i).isUsingAdminMode()) 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;
// A faction can always transfer away the money of it's members and its own money... // A faction can always transfer away the money of it's members and its own money...
// This will however probably never happen as a faction does not have free will. // This will however probably never happen as a faction does not have free will.
// Ohh by the way... Yes it could. For daily rent to the faction. // Ohh by the way... Yes it could. For daily rent to the faction.
if (i == fI && fI == fYou) return true; if (me == fMe && fMe == fYou) return true;
// Factions can be controlled by those that have permissions // Factions can be controlled by those that have permissions
if (you instanceof Faction) if (you instanceof Faction)
{ {
if (i instanceof Faction && MPerm.getPermWithdraw().has((Faction)i, fYou)) return true; if (me instanceof Faction && mperm.has((Faction)me, fYou)) return true;
if (i instanceof MPlayer && MPerm.getPermWithdraw().has((MPlayer)i, fYou, false)) return true; if (me instanceof MPlayer && mperm.has((MPlayer)me, fYou, false)) return true;
} }
// Otherwise you may not! ;,,; // Otherwise you may not! ;,,;
@ -102,7 +102,7 @@ public class Econ
} }
public static boolean transferMoney(EconomyParticipator from, EconomyParticipator to, EconomyParticipator by, double amount, boolean notify) public static boolean transferMoney(EconomyParticipator from, EconomyParticipator to, EconomyParticipator by, double amount, boolean notify)
{ {
if (!isEnabled()) return false; if ( ! isEnabled()) return false;
// The amount must be positive. // The amount must be positive.
// If the amount is negative we must flip and multiply amount with -1. // If the amount is negative we must flip and multiply amount with -1.
@ -114,10 +114,16 @@ public class Econ
to = temp; to = temp;
} }
// Check the rights // Check Permissions
if ( ! canIControllYou(by, from)) if ( ! isMePermittedYou(by, from, MPerm.getPermWithdraw()))
{ {
by.msg("<h>%s<i> lacks permission to control <h>%s's<i> money.", by.describeTo(by, true), from.describeTo(by)); by.msg("<h>%s<i> lack permission to withdraw money from <h>%s's<i>.", by.describeTo(by, true), from.describeTo(by));
return false;
}
if ( ! isMePermittedYou(by, to, MPerm.getPermDeposit()))
{
by.msg("<h>%s<i> lack permission to deposit money to <h>%s's<i>.", by.describeTo(by, true), to.describeTo(by));
return false; return false;
} }
@ -211,7 +217,7 @@ public class Econ
public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis)
{ {
if (!isEnabled()) return true; if ( ! isEnabled()) return true;
if (Money.get(ep) < delta) if (Money.get(ep) < delta)
{ {
@ -226,7 +232,7 @@ public class Econ
public static boolean modifyMoney(EconomyParticipator ep, double delta, String actionDescription) public static boolean modifyMoney(EconomyParticipator ep, double delta, String actionDescription)
{ {
if (!isEnabled()) return false; if ( ! isEnabled()) return false;
if (delta == 0) return true; if (delta == 0) return true;
String You = ep.describeTo(ep, true); String You = ep.describeTo(ep, true);

View File

@ -327,7 +327,7 @@ public class FactionsListenerMain implements Listener
// ... and powerloss can happen here ... // ... and powerloss can happen here ...
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(player)); Faction faction = BoardColl.get().getFactionAt(PS.valueOf(player));
if (!faction.getFlag(MFlag.getPowerloss())) if (!faction.getFlag(MFlag.getFlagPowerloss()))
{ {
mplayer.msg("<i>You didn't lose any power since the territory you died in works that way."); mplayer.msg("<i>You didn't lose any power since the territory you died in works that way.");
return; return;
@ -430,7 +430,7 @@ public class FactionsListenerMain implements Listener
Faction defenderPsFaction = BoardColl.get().getFactionAt(defenderPs); Faction defenderPsFaction = BoardColl.get().getFactionAt(defenderPs);
// ... PVP flag may cause a damage block ... // ... PVP flag may cause a damage block ...
if (defenderPsFaction.getFlag(MFlag.getPvp()) == false) if (defenderPsFaction.getFlag(MFlag.getFlagPvp()) == false)
{ {
if (eattacker == null) if (eattacker == null)
{ {
@ -448,7 +448,7 @@ public class FactionsListenerMain implements Listener
} }
return ret; return ret;
} }
return defenderPsFaction.getFlag(MFlag.getMonsters()); return defenderPsFaction.getFlag(MFlag.getFlagMonsters());
} }
// ... and if the attacker is a player ... // ... and if the attacker is a player ...
@ -466,7 +466,7 @@ public class FactionsListenerMain implements Listener
// ... PVP flag may cause a damage block ... // ... PVP flag may cause a damage block ...
// (just checking the defender as above isn't enough. What about the attacker? It could be in a no-pvp area) // (just checking the defender as above isn't enough. What about the attacker? It could be in a no-pvp area)
// NOTE: This check is probably not that important but we could keep it anyways. // NOTE: This check is probably not that important but we could keep it anyways.
if (attackerPsFaction.getFlag(MFlag.getPvp()) == false) if (attackerPsFaction.getFlag(MFlag.getFlagPvp()) == false)
{ {
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event);
if (!ret && notify) uattacker.msg("<i>PVP is disabled in %s.", attackerPsFaction.describeTo(uattacker)); if (!ret && notify) uattacker.msg("<i>PVP is disabled in %s.", attackerPsFaction.describeTo(uattacker));
@ -503,7 +503,7 @@ public class FactionsListenerMain implements Listener
Rel relation = defendFaction.getRelationTo(attackFaction); Rel relation = defendFaction.getRelationTo(attackFaction);
// Check the relation // Check the relation
if (udefender.hasFaction() && relation.isFriend() && defenderPsFaction.getFlag(MFlag.getFriendlyire()) == false) if (udefender.hasFaction() && relation.isFriend() && defenderPsFaction.getFlag(MFlag.getFlagFriendlyire()) == false)
{ {
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event);
if (!ret && notify) uattacker.msg("<i>You can't hurt %s<i>.", relation.getDescPlayerMany()); if (!ret && notify) uattacker.msg("<i>You can't hurt %s<i>.", relation.getDescPlayerMany());
@ -606,7 +606,7 @@ public class FactionsListenerMain implements Listener
command = command.trim(); command = command.trim();
// ... the command may be denied for members of permanent factions ... // ... the command may be denied for members of permanent factions ...
if (mplayer.hasFaction() && mplayer.getFaction().getFlag(MFlag.getPermanent()) && containsCommand(command, MConf.get().denyCommandsPermanentFactionMember)) if (mplayer.hasFaction() && mplayer.getFaction().getFlag(MFlag.getFlagPermanent()) && containsCommand(command, MConf.get().denyCommandsPermanentFactionMember))
{ {
mplayer.msg("<b>You can't use \"<h>/%s<b>\" as member of a permanent faction.", command); mplayer.msg("<b>You can't use \"<h>/%s<b>\" as member of a permanent faction.", command);
event.setCancelled(true); event.setCancelled(true);
@ -673,7 +673,7 @@ public class FactionsListenerMain implements Listener
Faction faction = BoardColl.get().getFactionAt(ps); Faction faction = BoardColl.get().getFactionAt(ps);
if (faction == null) return; if (faction == null) return;
if (faction.getFlag(MFlag.getMonsters())) return; if (faction.getFlag(MFlag.getFlagMonsters())) return;
// ... block the spawn. // ... block the spawn.
event.setCancelled(true); event.setCancelled(true);
@ -692,7 +692,7 @@ public class FactionsListenerMain implements Listener
// ... at a place where monsters are forbidden ... // ... at a place where monsters are forbidden ...
PS ps = PS.valueOf(target); PS ps = PS.valueOf(target);
Faction faction = BoardColl.get().getFactionAt(ps); Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.getFlag(MFlag.getMonsters())) return; if (faction.getFlag(MFlag.getFlagMonsters())) return;
// ... then if ghast target nothing ... // ... then if ghast target nothing ...
if (event.getEntityType() == EntityType.GHAST) if (event.getEntityType() == EntityType.GHAST)
@ -796,7 +796,7 @@ public class FactionsListenerMain implements Listener
// ... and the faction there has endergrief disabled ... // ... and the faction there has endergrief disabled ...
PS ps = PS.valueOf(event.getBlock()); PS ps = PS.valueOf(event.getBlock());
Faction faction = BoardColl.get().getFactionAt(ps); Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.getFlag(MFlag.getEndergrief())) return; if (faction.getFlag(MFlag.getFlagEndergrief())) return;
// ... stop the block alteration. // ... stop the block alteration.
event.setCancelled(true); event.setCancelled(true);
@ -812,7 +812,7 @@ public class FactionsListenerMain implements Listener
PS ps = PS.valueOf(block); PS ps = PS.valueOf(block);
Faction faction = BoardColl.get().getFactionAt(ps); Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.getFlag(MFlag.getFirespread())) return; if (faction.getFlag(MFlag.getFlagFirespread())) return;
// then cancel the event. // then cancel the event.
cancellable.setCancelled(true); cancellable.setCancelled(true);

View File

@ -108,7 +108,7 @@ public class RelationUtil
//P.p.log("getRelationOfThatToMe it was a player and role is "+ret); //P.p.log("getRelationOfThatToMe it was a player and role is "+ret);
} }
} }
else if (!ignorePeaceful && (thatFaction.getFlag(MFlag.getPeaceful()) || myFaction.getFlag(MFlag.getPeaceful()))) else if (!ignorePeaceful && (thatFaction.getFlag(MFlag.getFlagPeaceful()) || myFaction.getFlag(MFlag.getFlagPeaceful())))
{ {
ret = Rel.TRUCE; ret = Rel.TRUCE;
} }
@ -137,12 +137,12 @@ public class RelationUtil
Faction thatFaction = getFaction(that); Faction thatFaction = getFaction(that);
if (thatFaction != null && thatFaction != getFaction(me)) if (thatFaction != null && thatFaction != getFaction(me))
{ {
if (thatFaction.getFlag(MFlag.getFriendlyire()) == true) if (thatFaction.getFlag(MFlag.getFlagFriendlyire()) == true)
{ {
return MConf.get().colorFriendlyFire; return MConf.get().colorFriendlyFire;
} }
if (thatFaction.getFlag(MFlag.getPvp()) == false) if (thatFaction.getFlag(MFlag.getFlagPvp()) == false)
{ {
return MConf.get().colorNoPVP; return MConf.get().colorNoPVP;
} }