Rename admin mode to override. Improve Rel names system.

This commit is contained in:
Olof Larsson 2016-02-02 19:03:11 +01:00
parent cb8aa093db
commit c8433a4770
23 changed files with 137 additions and 116 deletions

View File

@ -14,7 +14,7 @@ permissions:
factions.access.faction: {description: grant faction access, with the proper fperm, default: false} factions.access.faction: {description: grant faction access, with the proper fperm, default: false}
factions.access.player: {description: grant player access, with the proper fperm, default: false} factions.access.player: {description: grant player access, with the proper fperm, default: false}
factions.access.view: {description: view access, default: false} factions.access.view: {description: view access, default: false}
factions.admin: {description: enable adminmode, default: false} factions.override: {description: enable override mode, default: false}
factions.claim: {description: claim faction territory, default: false} factions.claim: {description: claim faction territory, default: false}
factions.claim.one: {description: claim a single chunk, default: false} factions.claim.one: {description: claim a single chunk, default: false}
factions.claim.auto: {description: claim as you walk around, default: false} factions.claim.auto: {description: claim as you walk around, default: false}
@ -91,7 +91,7 @@ permissions:
factions.access.faction: true factions.access.faction: true
factions.access.player: true factions.access.player: true
factions.access.view: true factions.access.view: true
factions.admin: true factions.override: true
factions.claim: true factions.claim: true
factions.claim.one: true factions.claim.one: true
factions.claim.auto: true factions.claim.auto: true
@ -187,7 +187,7 @@ permissions:
default: false default: false
children: children:
factions.kit.rank0: true factions.kit.rank0: true
factions.admin: true factions.override: true
factions.invite.list.other: true factions.invite.list.other: true
factions.kit.rank0: factions.kit.rank0:
default: false default: false

View File

@ -14,7 +14,7 @@ public enum Perm
ACCESS_VIEW, ACCESS_VIEW,
ACCESS_PLAYER, ACCESS_PLAYER,
ACCESS_FACTION, ACCESS_FACTION,
ADMIN, OVERRIDE,
CLAIM, CLAIM,
CLAIM_ONE, CLAIM_ONE,
CLAIM_AUTO, CLAIM_AUTO,

View File

@ -1,8 +1,12 @@
package com.massivecraft.factions; package com.massivecraft.factions;
import java.util.Collections;
import java.util.Set;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.massivecore.collections.MassiveSet;
public enum Rel public enum Rel
@ -11,14 +15,38 @@ public enum Rel
// ENUM // ENUM
// -------------------------------------------- // // -------------------------------------------- //
LEADER (70, true, "your faction leader", "your faction leader", "", ""), ENEMY(
OFFICER (60, true, "an officer in your faction", "officers in your faction", "", ""), "an enemy", "enemies", "an enemy faction", "enemy factions",
MEMBER (50, true, "a member in your faction", "members in your faction", "your faction", "your factions"), "Enemy"
RECRUIT (45, true, "a recruit in your faction", "recruits in your faction", "", ""), ),
ALLY (40, true, "an ally", "allies", "an allied faction", "allied factions"), NEUTRAL(
TRUCE (30, true, "someone in truce with you", "those in truce with you", "a faction in truce", "factions in truce"), "someone neutral to you", "those neutral to you", "a neutral faction", "neutral factions",
NEUTRAL (20, false, "someone neutral to you", "those neutral to you", "a neutral faction", "neutral factions"), "Neutral"
ENEMY (10, false, "an enemy", "enemies", "an enemy faction", "enemy factions"), ),
TRUCE(
"someone in truce with you", "those in truce with you", "a faction in truce", "factions in truce",
"Truce"
),
ALLY(
"an ally", "allies", "an allied faction", "allied factions",
"Ally"
),
RECRUIT(
"a recruit in your faction", "recruits in your faction", "", "",
"Recruit"
),
MEMBER(
"a member in your faction", "members in your faction", "your faction", "your factions",
"Member"
),
OFFICER
(
"an officer in your faction", "officers in your faction", "", "",
"Officer", "Moderator"
),
LEADER("your faction leader", "your faction leader", "", "",
"Leader", "Admin", "Owner"
),
// END OF LIST // END OF LIST
; ;
@ -27,13 +55,7 @@ public enum Rel
// FIELDS // FIELDS
// -------------------------------------------- // // -------------------------------------------- //
// TODO: Are not enums sorted without this? public int getValue() { return this.ordinal(); }
private final int value;
public int getValue() { return this.value; }
// Used for friendly fire.
private final boolean friend;
public boolean isFriend() { return this.friend; }
private final String descPlayerOne; private final String descPlayerOne;
public String getDescPlayerOne() { return this.descPlayerOne; } public String getDescPlayerOne() { return this.descPlayerOne; }
@ -47,18 +69,21 @@ public enum Rel
private final String descFactionMany; private final String descFactionMany;
public String getDescFactionMany() { return this.descFactionMany; } public String getDescFactionMany() { return this.descFactionMany; }
private final Set<String> names;
public Set<String> getNames() { return this.names; }
public String getName() { return this.getNames().iterator().next(); }
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
private Rel(final int value, final boolean friend, final String descPlayerOne, final String descPlayerMany, final String descFactionOne, final String descFactionMany) private Rel(String descPlayerOne, String descPlayerMany, String descFactionOne, String descFactionMany, String... names)
{ {
this.value = value;
this.friend = friend;
this.descPlayerOne = descPlayerOne; this.descPlayerOne = descPlayerOne;
this.descPlayerMany = descPlayerMany; this.descPlayerMany = descPlayerMany;
this.descFactionOne = descFactionOne; this.descFactionOne = descFactionOne;
this.descFactionMany = descFactionMany; this.descFactionMany = descFactionMany;
this.names = Collections.unmodifiableSet(new MassiveSet<String>(names));
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -67,22 +92,22 @@ public enum Rel
public boolean isAtLeast(Rel rel) public boolean isAtLeast(Rel rel)
{ {
return this.value >= rel.value; return this.getValue() >= rel.getValue();
} }
public boolean isAtMost(Rel rel) public boolean isAtMost(Rel rel)
{ {
return this.value <= rel.value; return this.getValue() <= rel.getValue();
} }
public boolean isLessThan(Rel rel) public boolean isLessThan(Rel rel)
{ {
return this.value < rel.value; return this.getValue() < rel.getValue();
} }
public boolean isMoreThan(Rel rel) public boolean isMoreThan(Rel rel)
{ {
return this.value > rel.value; return this.getValue() > rel.getValue();
} }
public boolean isRank() public boolean isRank()
@ -90,6 +115,12 @@ public enum Rel
return this.isAtLeast(Rel.RECRUIT); return this.isAtLeast(Rel.RECRUIT);
} }
// Used for friendly fire.
public boolean isFriend()
{
return this.isAtLeast(TRUCE);
}
public ChatColor getColor() public ChatColor getColor()
{ {
if (this.isAtLeast(RECRUIT)) if (this.isAtLeast(RECRUIT))

View File

@ -32,7 +32,9 @@ public class CmdFactions extends FactionsCommand
public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle(); public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle();
public CmdFactionsRank cmdFactionsRank = new CmdFactionsRank(); public CmdFactionsRank cmdFactionsRank = new CmdFactionsRank();
public CmdFactionsRankOld cmdFactionsRankOldLeader = new CmdFactionsRankOld("leader"); public CmdFactionsRankOld cmdFactionsRankOldLeader = new CmdFactionsRankOld("leader");
public CmdFactionsRankOld cmdFactionsRankOldOwner = new CmdFactionsRankOld("owner");
public CmdFactionsRankOld cmdFactionsRankOldOfficer = new CmdFactionsRankOld("officer"); public CmdFactionsRankOld cmdFactionsRankOldOfficer = new CmdFactionsRankOld("officer");
public CmdFactionsRankOld cmdFactionsRankOldModerator = new CmdFactionsRankOld("moderator");
public CmdFactionsRankOld cmdFactionsRankOldPromote = new CmdFactionsRankOld("promote"); public CmdFactionsRankOld cmdFactionsRankOldPromote = new CmdFactionsRankOld("promote");
public CmdFactionsRankOld cmdFactionsRankOldDemote = new CmdFactionsRankOld("demote"); public CmdFactionsRankOld cmdFactionsRankOldDemote = new CmdFactionsRankOld("demote");
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney(); public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
@ -53,7 +55,7 @@ public class CmdFactions extends FactionsCommand
public CmdFactionsExpansions cmdFactionsExpansions = new CmdFactionsExpansions(); public CmdFactionsExpansions cmdFactionsExpansions = new CmdFactionsExpansions();
public CmdFactionsXPlaceholder cmdFactionsTax = new CmdFactionsXPlaceholder("FactionsTax", "tax"); public CmdFactionsXPlaceholder cmdFactionsTax = new CmdFactionsXPlaceholder("FactionsTax", "tax");
public CmdFactionsXPlaceholder cmdFactionsDynmap = new CmdFactionsXPlaceholder("FactionsDynmap", "dynmap"); public CmdFactionsXPlaceholder cmdFactionsDynmap = new CmdFactionsXPlaceholder("FactionsDynmap", "dynmap");
public CmdFactionsAdmin cmdFactionsAdmin = new CmdFactionsAdmin(); public CmdFactionsOverride cmdFactionsOverride = new CmdFactionsOverride();
public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband(); public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband();
public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost(); public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost();
public CmdFactionsSetpower cmdFactionsSetpower = new CmdFactionsSetpower(); public CmdFactionsSetpower cmdFactionsSetpower = new CmdFactionsSetpower();
@ -85,7 +87,9 @@ public class CmdFactions extends FactionsCommand
this.addChild(this.cmdFactionsTitle); this.addChild(this.cmdFactionsTitle);
this.addChild(this.cmdFactionsRank); this.addChild(this.cmdFactionsRank);
this.addChild(this.cmdFactionsRankOldLeader); this.addChild(this.cmdFactionsRankOldLeader);
this.addChild(this.cmdFactionsRankOldOwner);
this.addChild(this.cmdFactionsRankOldOfficer); this.addChild(this.cmdFactionsRankOldOfficer);
this.addChild(this.cmdFactionsRankOldModerator);
this.addChild(this.cmdFactionsRankOldPromote); this.addChild(this.cmdFactionsRankOldPromote);
this.addChild(this.cmdFactionsRankOldDemote); this.addChild(this.cmdFactionsRankOldDemote);
this.addChild(this.cmdFactionsMoney); this.addChild(this.cmdFactionsMoney);
@ -105,7 +109,7 @@ public class CmdFactions extends FactionsCommand
this.addChild(this.cmdFactionsExpansions); this.addChild(this.cmdFactionsExpansions);
this.addChild(this.cmdFactionsTax); this.addChild(this.cmdFactionsTax);
this.addChild(this.cmdFactionsDynmap); this.addChild(this.cmdFactionsDynmap);
this.addChild(this.cmdFactionsAdmin); this.addChild(this.cmdFactionsOverride);
this.addChild(this.cmdFactionsDisband); this.addChild(this.cmdFactionsDisband);
this.addChild(this.cmdFactionsPowerBoost); this.addChild(this.cmdFactionsPowerBoost);
this.addChild(this.cmdFactionsSetpower); this.addChild(this.cmdFactionsSetpower);

View File

@ -43,7 +43,7 @@ public class CmdFactionsFlagList extends FactionsCommand
for (MFlag flag : MFlag.getAll()) for (MFlag flag : MFlag.getAll())
{ {
if ( ! flag.isVisible() && ! msender.isUsingAdminMode()) continue; if ( ! flag.isVisible() && ! msender.isOverriding()) continue;
messages.add(flag.getStateDesc(false, false, true, true, true, false)); messages.add(flag.getStateDesc(false, false, true, true, true, false));
} }

View File

@ -47,7 +47,7 @@ public class CmdFactionsFlagSet extends FactionsCommand
if ( ! MPerm.getPermFlags().has(msender, faction, true)) return; if ( ! MPerm.getPermFlags().has(msender, faction, true)) return;
// Is this flag editable? // Is this flag editable?
if (!msender.isUsingAdminMode() && ! flag.isEditable()) if (!msender.isOverriding() && ! flag.isEditable())
{ {
msg("<b>The flag <h>%s <b>is not editable.", flag.getName()); msg("<b>The flag <h>%s <b>is not editable.", flag.getName());
return; return;

View File

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

View File

@ -54,19 +54,19 @@ public class CmdFactionsKick extends FactionsCommand
return; return;
} }
if (mplayer.getRole() == Rel.LEADER && !(this.senderIsConsole || msender.isUsingAdminMode())) if (mplayer.getRole() == Rel.LEADER && !(this.senderIsConsole || msender.isOverriding()))
{ {
msg("<b>The leader can not be kicked."); msg("<b>The leader can not be kicked.");
return; return;
} }
if (mplayer.getRole().compareTo(msender.getRole()) < 0 && !(this.senderIsConsole || msender.isUsingAdminMode())) if (mplayer.getRole().compareTo(msender.getRole()) < 0 && !(this.senderIsConsole || msender.isOverriding()))
{ {
msg("<b>You can't kick people of higher rank than yourself."); msg("<b>You can't kick people of higher rank than yourself.");
return; return;
} }
if ( ! MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0 && ! msender.isUsingAdminMode()) if ( ! MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0 && ! msender.isOverriding())
{ {
msg("<b>You can't kick that person until their power is positive."); msg("<b>You can't kick that person until their power is positive.");
return; return;

View File

@ -8,22 +8,22 @@ import com.massivecraft.massivecore.command.type.primitive.TypeBoolean;
import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsAdmin extends FactionsCommand public class CmdFactionsOverride extends FactionsCommand
{ {
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public CmdFactionsAdmin() public CmdFactionsOverride()
{ {
// Aliases // Aliases
this.addAliases("admin"); this.addAliases("override", "admin");
// Parameters // Parameters
this.addParameter(TypeBoolean.getOn(), "on/off", "flip"); this.addParameter(TypeBoolean.getOn(), "on/off", "flip");
// Requirements // Requirements
this.addRequirements(RequirementHasPerm.get(Perm.ADMIN.node)); this.addRequirements(RequirementHasPerm.get(Perm.OVERRIDE.node));
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -34,16 +34,16 @@ public class CmdFactionsAdmin extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
boolean target = this.readArg(!msender.isUsingAdminMode()); boolean target = this.readArg( ! msender.isOverriding());
// Apply // Apply
msender.setUsingAdminMode(target); msender.setOverriding(target);
// Inform // Inform
String desc = Txt.parse(msender.isUsingAdminMode() ? "<g>ENABLED" : "<b>DISABLED"); String desc = Txt.parse(msender.isOverriding() ? "<g>ENABLED" : "<b>DISABLED");
String messageYou = Txt.parse("<i>%s %s <i>admin bypass mode.", msender.getDisplayName(msender), desc); String messageYou = Txt.parse("<i>%s %s <i>override mode.", msender.getDisplayName(msender), desc);
String messageLog = Txt.parse("<i>%s %s <i>admin bypass mode.", msender.getDisplayName(IdUtil.getConsole()), desc); String messageLog = Txt.parse("<i>%s %s <i>override mode.", msender.getDisplayName(IdUtil.getConsole()), desc);
msender.message(messageYou); msender.message(messageYou);
Factions.get().log(messageLog); Factions.get().log(messageLog);

View File

@ -43,7 +43,7 @@ public class CmdFactionsPermList extends FactionsCommand
for (MPerm perm : MPerm.getAll()) for (MPerm perm : MPerm.getAll())
{ {
if ( ! perm.isVisible() && ! msender.isUsingAdminMode()) continue; if ( ! perm.isVisible() && ! msender.isOverriding()) continue;
messages.add(perm.getDesc(true, true)); messages.add(perm.getDesc(true, true));
} }

View File

@ -55,7 +55,7 @@ public class CmdFactionsPermSet extends FactionsCommand
if ( ! MPerm.getPermPerms().has(msender, faction, true)) return; if ( ! MPerm.getPermPerms().has(msender, faction, true)) return;
// Is this perm editable? // Is this perm editable?
if ( ! msender.isUsingAdminMode() && ! perm.isEditable()) if ( ! msender.isOverriding() && ! perm.isEditable())
{ {
msg("<b>The perm <h>%s <b>is not editable.", perm.getName()); msg("<b>The perm <h>%s <b>is not editable.", perm.getName());
return; return;

View File

@ -165,7 +165,7 @@ public class CmdFactionsRank extends FactionsCommand
private void ensureAllowed() throws MassiveException private void ensureAllowed() throws MassiveException
{ {
// People with permission don't follow the normal rules. // People with permission don't follow the normal rules.
if (msender.isUsingAdminMode()) return; if (msender.isOverriding()) return;
// If somone gets the leadership of wilderness (Which has happened before). // If somone gets the leadership of wilderness (Which has happened before).
// We can at least try to limit their powers. // We can at least try to limit their powers.

View File

@ -42,7 +42,7 @@ public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX
} }
// Radius Claim Max // Radius Claim Max
if (radius > MConf.get().setRadiusMax && ! msender.isUsingAdminMode()) if (radius > MConf.get().setRadiusMax && ! msender.isOverriding())
{ {
msg("<b>The maximum radius allowed is <h>%s<b>.", MConf.get().setRadiusMax); msg("<b>The maximum radius allowed is <h>%s<b>.", MConf.get().setRadiusMax);
return null; return null;

View File

@ -46,7 +46,7 @@ public class CmdFactionsSethome extends FactionsCommandHome
if ( ! MPerm.getPermSethome().has(msender, faction, true)) return; if ( ! MPerm.getPermSethome().has(msender, faction, true)) return;
// Verify // Verify
if (!msender.isUsingAdminMode() && !faction.isValidHome(newHome)) if (!msender.isOverriding() && !faction.isValidHome(newHome))
{ {
msender.msg("<b>Sorry, your faction home can only be set inside your own claimed territory."); msender.msg("<b>Sorry, your faction home can only be set inside your own claimed territory.");
return; return;

View File

@ -52,7 +52,7 @@ public class CmdFactionsTitle extends FactionsCommand
if ( ! MPerm.getPermTitle().has(msender, you.getFaction(), true)) return; if ( ! MPerm.getPermTitle().has(msender, you.getFaction(), true)) return;
// Rank Check // Rank Check
if (!msender.isUsingAdminMode() && you.getRole().isMoreThan(msender.getRole())) if (!msender.isOverriding() && you.getRole().isMoreThan(msender.getRole()))
{ {
msg("<b>You can not edit titles for higher ranks."); msg("<b>You can not edit titles for higher ranks.");
return; return;

View File

@ -91,26 +91,20 @@ public class TypeRank extends TypeEnum<Rel>
return "rank"; return "rank";
} }
@Override
public String getNameInner(Rel value)
{
return value.getName();
}
@Override @Override
public Set<String> getNamesInner(Rel value) public Set<String> getNamesInner(Rel value)
{ {
// Create // Create
Set<String> ret = new MassiveSet<String>(super.getNamesInner(value)); Set<String> ret = new MassiveSet<String>();
// Fill Exact // Fill Exact
if (value == Rel.LEADER) ret.addAll(value.getNames());
{
ret.add("admin");
}
else if (value == Rel.OFFICER)
{
ret.add("moderator");
}
else if (value == Rel.MEMBER)
{
ret.add("member");
ret.add("normal");
}
// Fill Relative // Fill Relative
Rel start = this.getStartRank(); Rel start = this.getStartRank();

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd.type;
import java.util.Set; import java.util.Set;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.command.type.enumeration.TypeEnum; import com.massivecraft.massivecore.command.type.enumeration.TypeEnum;
public class TypeRel extends TypeEnum<Rel> public class TypeRel extends TypeEnum<Rel>
@ -26,25 +25,16 @@ public class TypeRel extends TypeEnum<Rel>
return "role"; return "role";
} }
@Override
public String getNameInner(Rel value)
{
return value.getName();
}
@Override @Override
public Set<String> getNamesInner(Rel value) public Set<String> getNamesInner(Rel value)
{ {
Set<String> ret = new MassiveSet<String>(super.getNamesInner(value)); return value.getNames();
if (value == Rel.LEADER)
{
ret.add("admin");
}
else if (value == Rel.OFFICER)
{
ret.add("moderator");
}
else if (value == Rel.MEMBER)
{
ret.add("normal");
}
return ret;
} }
} }

View File

@ -154,7 +154,7 @@ public class EngineMain extends EngineAbstract
final boolean peaceful = faction.getFlag(MFlag.getFlagPeaceful()); final boolean peaceful = faction.getFlag(MFlag.getFlagPeaceful());
// ID // ID
if (mplayer.isUsingAdminMode()) if (mplayer.isOverriding())
{ {
show(idPriorityLiness, Const.SHOW_ID_FACTION_ID, Const.SHOW_PRIORITY_FACTION_ID, "ID", faction.getId()); show(idPriorityLiness, Const.SHOW_ID_FACTION_ID, Const.SHOW_PRIORITY_FACTION_ID, "ID", faction.getId());
} }
@ -516,8 +516,8 @@ public class EngineMain extends EngineAbstract
final Set<Faction> currentFactions = currentFactionChunks.keySet(); final Set<Faction> currentFactions = currentFactionChunks.keySet();
final Set<PS> chunks = event.getChunks(); final Set<PS> chunks = event.getChunks();
// Admin Mode? Sure! // Override Mode? Sure!
if (mplayer.isUsingAdminMode()) return; if (mplayer.isOverriding()) return;
// CALC: Is there at least one normal faction among the current ones? // CALC: Is there at least one normal faction among the current ones?
boolean currentFactionsContainsAtLeastOneNormal = false; boolean currentFactionsContainsAtLeastOneNormal = false;
@ -907,7 +907,7 @@ public class EngineMain extends EngineAbstract
// ... fast evaluate if the attacker is overriding ... // ... fast evaluate if the attacker is overriding ...
MPlayer mplayer = MPlayer.get(eattacker); MPlayer mplayer = MPlayer.get(eattacker);
if (mplayer != null && mplayer.isUsingAdminMode()) return true; if (mplayer != null && mplayer.isOverriding()) return true;
// ... PVP flag may cause a damage block ... // ... PVP flag may cause a damage block ...
if (defenderPsFaction.getFlag(MFlag.getFlagPvp()) == false) if (defenderPsFaction.getFlag(MFlag.getFlagPvp()) == false)
@ -1096,8 +1096,8 @@ public class EngineMain extends EngineAbstract
if (MUtil.isntPlayer(player)) return; if (MUtil.isntPlayer(player)) return;
MPlayer mplayer = MPlayer.get(player); MPlayer mplayer = MPlayer.get(player);
// ... and the player does not have adminmode ... // ... and the player is not overriding ...
if (mplayer.isUsingAdminMode()) return; if (mplayer.isOverriding()) return;
// ... clean up the command ... // ... clean up the command ...
String command = event.getMessage(); String command = event.getMessage();
@ -1404,7 +1404,7 @@ public class EngineMain extends EngineAbstract
String name = mplayer.getName(); String name = mplayer.getName();
if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true;
if (mplayer.isUsingAdminMode()) return true; if (mplayer.isOverriding()) return true;
if (!MPerm.getPermBuild().has(mplayer, ps, false) && MPerm.getPermPainbuild().has(mplayer, ps, false)) if (!MPerm.getPermBuild().has(mplayer, ps, false) && MPerm.getPermPainbuild().has(mplayer, ps, false))
{ {
@ -1672,7 +1672,7 @@ public class EngineMain extends EngineAbstract
if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true;
MPlayer mplayer = MPlayer.get(player); MPlayer mplayer = MPlayer.get(player);
if (mplayer.isUsingAdminMode()) return true; if (mplayer.isOverriding()) return true;
return MPerm.getPermBuild().has(mplayer, ps, verboose); return MPerm.getPermBuild().has(mplayer, ps, verboose);
} }
@ -1685,7 +1685,7 @@ public class EngineMain extends EngineAbstract
if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true;
MPlayer me = MPlayer.get(player); MPlayer me = MPlayer.get(player);
if (me.isUsingAdminMode()) return true; if (me.isOverriding()) return true;
PS ps = PS.valueOf(block); PS ps = PS.valueOf(block);
Material material = block.getType(); Material material = block.getType();
@ -1731,7 +1731,7 @@ public class EngineMain extends EngineAbstract
// ... and the player is not using admin mode ... // ... and the player is not using admin mode ...
MPlayer me = MPlayer.get(player); MPlayer me = MPlayer.get(player);
if (me.isUsingAdminMode()) return true; if (me.isOverriding()) return true;
// ... check container entity rights ... // ... check container entity rights ...
if (MConf.get().entityTypesContainer.contains(type) && ! MPerm.getPermContainer().has(me, ps, verboose)) return false; if (MConf.get().entityTypesContainer.contains(type) && ! MPerm.getPermContainer().has(me, ps, verboose)) return false;

View File

@ -193,7 +193,7 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
// Is this flag editable by players? // Is this flag editable by players?
// With this we mean standard non administrator players. // With this we mean standard non administrator players.
// All flags can be changed using /f admin. // All flags can be changed using /f override.
// Example: true (if players want to turn mob spawning on I guess they should be able to) // Example: true (if players want to turn mob spawning on I guess they should be able to)
private boolean editable = false; private boolean editable = false;
public boolean isEditable() { return this.editable; } public boolean isEditable() { return this.editable; }
@ -201,7 +201,7 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
// Is this flag visible to players? // Is this flag visible to players?
// With this we mean standard non administrator players. // With this we mean standard non administrator players.
// All flags can be seen using /f admin. // All flags can be seen using /f override.
// Some flags can be rendered meaningless by settings in Factions or external plugins. // Some flags can be rendered meaningless by settings in Factions or external plugins.
// Say we set "editable" to false and "standard" to true for the "open" flag to force all factions being open. // Say we set "editable" to false and "standard" to true for the "open" flag to force all factions being open.
// In such case we might want to hide the open flag by setting "visible" false. // In such case we might want to hide the open flag by setting "visible" false.

View File

@ -245,7 +245,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
// Is this perm editable by players? // Is this perm editable by players?
// With this we mean standard non administrator players. // With this we mean standard non administrator players.
// All perms can be changed using /f admin. // All perms can be changed using /f override.
// Example: true (all perms are editable by default) // Example: true (all perms are editable by default)
private boolean editable = false; private boolean editable = false;
public boolean isEditable() { return this.editable; } public boolean isEditable() { return this.editable; }
@ -253,7 +253,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
// Is this perm visible to players? // Is this perm visible to players?
// With this we mean standard non administrator players. // With this we mean standard non administrator players.
// All perms can be seen using /f admin. // All perms can be seen using /f override.
// Some perms can be rendered meaningless by settings in Factions or external plugins. // Some perms can be rendered meaningless by settings in Factions or external plugins.
// Say we set "editable" to false. // Say we set "editable" to false.
// In such case we might want to hide the perm by setting "visible" false. // In such case we might want to hide the perm by setting "visible" false.
@ -296,9 +296,9 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
String ret = Txt.parse("%s<b> does not allow you to %s<b>.", hostFaction.describeTo(mplayer, true), this.getDesc()); String ret = Txt.parse("%s<b> does not allow you to %s<b>.", hostFaction.describeTo(mplayer, true), this.getDesc());
Player player = mplayer.getPlayer(); Player player = mplayer.getPlayer();
if (player != null && Perm.ADMIN.has(player)) if (player != null && Perm.OVERRIDE.has(player))
{ {
ret += Txt.parse("\n<i>You can bypass by using " + Factions.get().getOuterCmdFactions().cmdFactionsAdmin.getTemplate(false).toPlain(true)); ret += Txt.parse("\n<i>You can bypass by using " + Factions.get().getOuterCmdFactions().cmdFactionsOverride.getTemplate(false).toPlain(true));
} }
return ret; return ret;
@ -355,7 +355,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
if (mplayer == null) throw new NullPointerException("mplayer"); if (mplayer == null) throw new NullPointerException("mplayer");
if (hostFaction == null) throw new NullPointerException("hostFaction"); if (hostFaction == null) throw new NullPointerException("hostFaction");
if (mplayer.isUsingAdminMode()) return true; if (mplayer.isOverriding()) return true;
Rel rel = mplayer.getRelationTo(hostFaction); Rel rel = mplayer.getRelationTo(hostFaction);
if (hostFaction.isPermitted(this, rel)) return true; if (hostFaction.isPermitted(this, rel)) return true;
@ -371,7 +371,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
if (mplayer == null) throw new NullPointerException("mplayer"); if (mplayer == null) throw new NullPointerException("mplayer");
if (ps == null) throw new NullPointerException("ps"); if (ps == null) throw new NullPointerException("ps");
if (mplayer.isUsingAdminMode()) return true; if (mplayer.isOverriding()) return true;
TerritoryAccess ta = BoardColl.get().getTerritoryAccessAt(ps); TerritoryAccess ta = BoardColl.get().getTerritoryAccessAt(ps);
Faction hostFaction = ta.getHostFaction(); Faction hostFaction = ta.getHostFaction();

View File

@ -30,6 +30,7 @@ import com.massivecraft.massivecore.store.SenderEntity;
import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
import com.massivecraft.massivecore.xlib.gson.annotations.SerializedName;
public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipator public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipator
@ -57,7 +58,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
this.setPowerBoost(that.powerBoost); this.setPowerBoost(that.powerBoost);
this.setPower(that.power); this.setPower(that.power);
this.setMapAutoUpdating(that.mapAutoUpdating); this.setMapAutoUpdating(that.mapAutoUpdating);
this.setUsingAdminMode(that.usingAdminMode); this.setOverriding(that.overriding);
this.setTerritoryInfoTitles(that.territoryInfoTitles); this.setTerritoryInfoTitles(that.territoryInfoTitles);
return this; return this;
@ -73,7 +74,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
if (this.hasPowerBoost()) return false; if (this.hasPowerBoost()) return false;
if (this.getPowerRounded() != (int) Math.round(MConf.get().defaultPlayerPower)) return false; if (this.getPowerRounded() != (int) Math.round(MConf.get().defaultPlayerPower)) return false;
// if (this.isMapAutoUpdating()) return false; // Just having an auto updating map is not in itself reason enough for database storage. // if (this.isMapAutoUpdating()) return false; // Just having an auto updating map is not in itself reason enough for database storage.
if (this.isUsingAdminMode()) return false; if (this.isOverriding()) return false;
if (this.isTerritoryInfoTitles() != MConf.get().territoryInfoTitlesDefault) return false; if (this.isTerritoryInfoTitles() != MConf.get().territoryInfoTitlesDefault) return false;
return true; return true;
@ -156,9 +157,10 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
// Null means false // Null means false
private Boolean mapAutoUpdating = null; private Boolean mapAutoUpdating = null;
// Is this player using admin mode? // Is this player overriding?
// Null means false // Null means false
private Boolean usingAdminMode = null; @SerializedName(value = "usingAdminMode")
private Boolean overriding = null;
// Does this player use titles for territory info? // Does this player use titles for territory info?
// Null means default specified in MConf. // Null means default specified in MConf.
@ -533,35 +535,35 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
} }
// -------------------------------------------- // // -------------------------------------------- //
// FIELD: usingAdminMode // FIELD: overriding
// -------------------------------------------- // // -------------------------------------------- //
public boolean isUsingAdminMode() public boolean isOverriding()
{ {
if (this.usingAdminMode == null) return false; if (this.overriding == null) return false;
if (this.usingAdminMode == false) return false; if (this.overriding == false) return false;
// Deactivate admin mode if we don't have permissions for it. // Deactivate admin mode if we don't have permissions for it.
if (this.getSender() != null && !Perm.ADMIN.has(this.getSender(), false)) if (this.getSender() != null && ! Perm.OVERRIDE.has(this.getSender(), false))
{ {
this.setUsingAdminMode(false); this.setOverriding(false);
return false; return false;
} }
return true; return true;
} }
public void setUsingAdminMode(Boolean usingAdminMode) public void setOverriding(Boolean overriding)
{ {
// Clean input // Clean input
Boolean target = usingAdminMode; Boolean target = overriding;
if (MUtil.equals(target, false)) target = null; if (MUtil.equals(target, false)) target = null;
// Detect Nochange // Detect Nochange
if (MUtil.equals(this.usingAdminMode, target)) return; if (MUtil.equals(this.overriding, target)) return;
// Apply // Apply
this.usingAdminMode = target; this.overriding = target;
// Mark as changed // Mark as changed
this.changed(); this.changed();

View File

@ -31,7 +31,7 @@ public class Econ
if (!isEnabled()) return true; if (!isEnabled()) return true;
if (cost == 0D) return true; if (cost == 0D) return true;
if (usender.isUsingAdminMode()) return true; if (usender.isOverriding()) return true;
Faction usenderFaction = usender.getFaction(); Faction usenderFaction = usender.getFaction();
@ -72,7 +72,7 @@ public class Econ
if (me == null) return true; if (me == null) return true;
// Always accept when in admin mode. // Always accept when in admin mode.
if (me instanceof MPlayer && ((MPlayer)me).isUsingAdminMode()) return true; if (me instanceof MPlayer && ((MPlayer)me).isOverriding()) return true;
// Always accept control of self // Always accept control of self
if (me == you) return true; if (me == you) return true;

View File

@ -81,8 +81,8 @@ public class EngineWorldGuard extends EngineAbstract
if ( ! MConf.get().worldguardCheckWorldsEnabled.contains(mplayer.getPlayer())) return; if ( ! MConf.get().worldguardCheckWorldsEnabled.contains(mplayer.getPlayer())) return;
// For admins don't bother checking // For overriders don't bother checking
if (mplayer.isUsingAdminMode()) return; if (mplayer.isOverriding()) return;
for (PS chunkChecking : event.getChunks()) for (PS chunkChecking : event.getChunks())
{ {