From c8433a4770c641db2ad53cfe02df8fde94bcdb54 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Tue, 2 Feb 2016 19:03:11 +0100 Subject: [PATCH] Rename admin mode to override. Improve Rel names system. --- plugin.yml | 6 +- src/com/massivecraft/factions/Perm.java | 2 +- src/com/massivecraft/factions/Rel.java | 75 +++++++++++++------ .../factions/cmd/CmdFactions.java | 8 +- .../factions/cmd/CmdFactionsFlagList.java | 2 +- .../factions/cmd/CmdFactionsFlagSet.java | 2 +- .../factions/cmd/CmdFactionsJoin.java | 2 +- .../factions/cmd/CmdFactionsKick.java | 6 +- ...onsAdmin.java => CmdFactionsOverride.java} | 18 ++--- .../factions/cmd/CmdFactionsPermList.java | 2 +- .../factions/cmd/CmdFactionsPermSet.java | 2 +- .../factions/cmd/CmdFactionsRank.java | 2 +- .../factions/cmd/CmdFactionsSetXRadius.java | 2 +- .../factions/cmd/CmdFactionsSethome.java | 2 +- .../factions/cmd/CmdFactionsTitle.java | 2 +- .../factions/cmd/type/TypeRank.java | 22 ++---- .../factions/cmd/type/TypeRel.java | 24 ++---- .../factions/engine/EngineMain.java | 20 ++--- .../massivecraft/factions/entity/MFlag.java | 4 +- .../massivecraft/factions/entity/MPerm.java | 12 +-- .../massivecraft/factions/entity/MPlayer.java | 30 ++++---- .../factions/integration/Econ.java | 4 +- .../worldguard/EngineWorldGuard.java | 4 +- 23 files changed, 137 insertions(+), 116 deletions(-) rename src/com/massivecraft/factions/cmd/{CmdFactionsAdmin.java => CmdFactionsOverride.java} (61%) diff --git a/plugin.yml b/plugin.yml index 93caaa4e..ac4e841c 100644 --- a/plugin.yml +++ b/plugin.yml @@ -14,7 +14,7 @@ permissions: 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.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.one: {description: claim a single chunk, default: false} factions.claim.auto: {description: claim as you walk around, default: false} @@ -91,7 +91,7 @@ permissions: factions.access.faction: true factions.access.player: true factions.access.view: true - factions.admin: true + factions.override: true factions.claim: true factions.claim.one: true factions.claim.auto: true @@ -187,7 +187,7 @@ permissions: default: false children: factions.kit.rank0: true - factions.admin: true + factions.override: true factions.invite.list.other: true factions.kit.rank0: default: false diff --git a/src/com/massivecraft/factions/Perm.java b/src/com/massivecraft/factions/Perm.java index 4a48fd44..c22f35f4 100644 --- a/src/com/massivecraft/factions/Perm.java +++ b/src/com/massivecraft/factions/Perm.java @@ -14,7 +14,7 @@ public enum Perm ACCESS_VIEW, ACCESS_PLAYER, ACCESS_FACTION, - ADMIN, + OVERRIDE, CLAIM, CLAIM_ONE, CLAIM_AUTO, diff --git a/src/com/massivecraft/factions/Rel.java b/src/com/massivecraft/factions/Rel.java index c9e1523b..9b2b888c 100644 --- a/src/com/massivecraft/factions/Rel.java +++ b/src/com/massivecraft/factions/Rel.java @@ -1,8 +1,12 @@ package com.massivecraft.factions; +import java.util.Collections; +import java.util.Set; + import org.bukkit.ChatColor; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.massivecore.collections.MassiveSet; public enum Rel @@ -11,14 +15,38 @@ public enum Rel // ENUM // -------------------------------------------- // - LEADER (70, true, "your faction leader", "your faction leader", "", ""), - OFFICER (60, true, "an officer in your faction", "officers in your faction", "", ""), - MEMBER (50, true, "a member in your faction", "members in your faction", "your faction", "your factions"), - RECRUIT (45, true, "a recruit in your faction", "recruits in your faction", "", ""), - ALLY (40, true, "an ally", "allies", "an allied faction", "allied factions"), - TRUCE (30, true, "someone in truce with you", "those in truce with you", "a faction in truce", "factions in truce"), - NEUTRAL (20, false, "someone neutral to you", "those neutral to you", "a neutral faction", "neutral factions"), - ENEMY (10, false, "an enemy", "enemies", "an enemy faction", "enemy factions"), + ENEMY( + "an enemy", "enemies", "an enemy faction", "enemy factions", + "Enemy" + ), + NEUTRAL( + "someone neutral to you", "those neutral to you", "a neutral faction", "neutral factions", + "Neutral" + ), + 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 ; @@ -27,13 +55,7 @@ public enum Rel // FIELDS // -------------------------------------------- // - // TODO: Are not enums sorted without this? - private final int value; - public int getValue() { return this.value; } - - // Used for friendly fire. - private final boolean friend; - public boolean isFriend() { return this.friend; } + public int getValue() { return this.ordinal(); } private final String descPlayerOne; public String getDescPlayerOne() { return this.descPlayerOne; } @@ -47,18 +69,21 @@ public enum Rel private final String descFactionMany; public String getDescFactionMany() { return this.descFactionMany; } + private final Set names; + public Set getNames() { return this.names; } + public String getName() { return this.getNames().iterator().next(); } + // -------------------------------------------- // // 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.descPlayerMany = descPlayerMany; this.descFactionOne = descFactionOne; this.descFactionMany = descFactionMany; + this.names = Collections.unmodifiableSet(new MassiveSet(names)); } // -------------------------------------------- // @@ -67,22 +92,22 @@ public enum Rel public boolean isAtLeast(Rel rel) { - return this.value >= rel.value; + return this.getValue() >= rel.getValue(); } public boolean isAtMost(Rel rel) { - return this.value <= rel.value; + return this.getValue() <= rel.getValue(); } public boolean isLessThan(Rel rel) { - return this.value < rel.value; + return this.getValue() < rel.getValue(); } public boolean isMoreThan(Rel rel) { - return this.value > rel.value; + return this.getValue() > rel.getValue(); } public boolean isRank() @@ -90,6 +115,12 @@ public enum Rel return this.isAtLeast(Rel.RECRUIT); } + // Used for friendly fire. + public boolean isFriend() + { + return this.isAtLeast(TRUCE); + } + public ChatColor getColor() { if (this.isAtLeast(RECRUIT)) diff --git a/src/com/massivecraft/factions/cmd/CmdFactions.java b/src/com/massivecraft/factions/cmd/CmdFactions.java index c37f9020..6049871d 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactions.java +++ b/src/com/massivecraft/factions/cmd/CmdFactions.java @@ -32,7 +32,9 @@ public class CmdFactions extends FactionsCommand public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle(); public CmdFactionsRank cmdFactionsRank = new CmdFactionsRank(); public CmdFactionsRankOld cmdFactionsRankOldLeader = new CmdFactionsRankOld("leader"); + public CmdFactionsRankOld cmdFactionsRankOldOwner = new CmdFactionsRankOld("owner"); public CmdFactionsRankOld cmdFactionsRankOldOfficer = new CmdFactionsRankOld("officer"); + public CmdFactionsRankOld cmdFactionsRankOldModerator = new CmdFactionsRankOld("moderator"); public CmdFactionsRankOld cmdFactionsRankOldPromote = new CmdFactionsRankOld("promote"); public CmdFactionsRankOld cmdFactionsRankOldDemote = new CmdFactionsRankOld("demote"); public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney(); @@ -53,7 +55,7 @@ public class CmdFactions extends FactionsCommand public CmdFactionsExpansions cmdFactionsExpansions = new CmdFactionsExpansions(); public CmdFactionsXPlaceholder cmdFactionsTax = new CmdFactionsXPlaceholder("FactionsTax", "tax"); public CmdFactionsXPlaceholder cmdFactionsDynmap = new CmdFactionsXPlaceholder("FactionsDynmap", "dynmap"); - public CmdFactionsAdmin cmdFactionsAdmin = new CmdFactionsAdmin(); + public CmdFactionsOverride cmdFactionsOverride = new CmdFactionsOverride(); public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband(); public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost(); public CmdFactionsSetpower cmdFactionsSetpower = new CmdFactionsSetpower(); @@ -85,7 +87,9 @@ public class CmdFactions extends FactionsCommand this.addChild(this.cmdFactionsTitle); this.addChild(this.cmdFactionsRank); this.addChild(this.cmdFactionsRankOldLeader); + this.addChild(this.cmdFactionsRankOldOwner); this.addChild(this.cmdFactionsRankOldOfficer); + this.addChild(this.cmdFactionsRankOldModerator); this.addChild(this.cmdFactionsRankOldPromote); this.addChild(this.cmdFactionsRankOldDemote); this.addChild(this.cmdFactionsMoney); @@ -105,7 +109,7 @@ public class CmdFactions extends FactionsCommand this.addChild(this.cmdFactionsExpansions); this.addChild(this.cmdFactionsTax); this.addChild(this.cmdFactionsDynmap); - this.addChild(this.cmdFactionsAdmin); + this.addChild(this.cmdFactionsOverride); this.addChild(this.cmdFactionsDisband); this.addChild(this.cmdFactionsPowerBoost); this.addChild(this.cmdFactionsSetpower); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsFlagList.java b/src/com/massivecraft/factions/cmd/CmdFactionsFlagList.java index 0a8c488b..0b9e5971 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsFlagList.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsFlagList.java @@ -43,7 +43,7 @@ public class CmdFactionsFlagList extends FactionsCommand 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)); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsFlagSet.java b/src/com/massivecraft/factions/cmd/CmdFactionsFlagSet.java index d35fcf22..3561ea49 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsFlagSet.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsFlagSet.java @@ -47,7 +47,7 @@ public class CmdFactionsFlagSet extends FactionsCommand if ( ! MPerm.getPermFlags().has(msender, faction, true)) return; // Is this flag editable? - if (!msender.isUsingAdminMode() && ! flag.isEditable()) + if (!msender.isOverriding() && ! flag.isEditable()) { msg("The flag %s is not editable.", flag.getName()); return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java b/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java index 761e52fa..4ffc54d0 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java @@ -98,7 +98,7 @@ public class CmdFactionsJoin extends FactionsCommand return; } - if( ! (faction.getFlag(MFlag.getFlagOpen()) || faction.isInvited(mplayer) || msender.isUsingAdminMode())) + if( ! (faction.getFlag(MFlag.getFlagOpen()) || faction.isInvited(mplayer) || msender.isOverriding())) { msg("This faction requires invitation."); if (samePlayer) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java b/src/com/massivecraft/factions/cmd/CmdFactionsKick.java index 6c968228..18b6e720 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsKick.java @@ -54,19 +54,19 @@ public class CmdFactionsKick extends FactionsCommand return; } - if (mplayer.getRole() == Rel.LEADER && !(this.senderIsConsole || msender.isUsingAdminMode())) + if (mplayer.getRole() == Rel.LEADER && !(this.senderIsConsole || msender.isOverriding())) { msg("The leader can not be kicked."); return; } - if (mplayer.getRole().compareTo(msender.getRole()) < 0 && !(this.senderIsConsole || msender.isUsingAdminMode())) + if (mplayer.getRole().compareTo(msender.getRole()) < 0 && !(this.senderIsConsole || msender.isOverriding())) { msg("You can't kick people of higher rank than yourself."); return; } - if ( ! MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0 && ! msender.isUsingAdminMode()) + if ( ! MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0 && ! msender.isOverriding()) { msg("You can't kick that person until their power is positive."); return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java b/src/com/massivecraft/factions/cmd/CmdFactionsOverride.java similarity index 61% rename from src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java rename to src/com/massivecraft/factions/cmd/CmdFactionsOverride.java index 9c42c732..0ba94556 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsOverride.java @@ -8,22 +8,22 @@ import com.massivecraft.massivecore.command.type.primitive.TypeBoolean; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.Txt; -public class CmdFactionsAdmin extends FactionsCommand +public class CmdFactionsOverride extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // - public CmdFactionsAdmin() + public CmdFactionsOverride() { // Aliases - this.addAliases("admin"); + this.addAliases("override", "admin"); // Parameters this.addParameter(TypeBoolean.getOn(), "on/off", "flip"); // 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 { // Args - boolean target = this.readArg(!msender.isUsingAdminMode()); + boolean target = this.readArg( ! msender.isOverriding()); // Apply - msender.setUsingAdminMode(target); + msender.setOverriding(target); // Inform - String desc = Txt.parse(msender.isUsingAdminMode() ? "ENABLED" : "DISABLED"); + String desc = Txt.parse(msender.isOverriding() ? "ENABLED" : "DISABLED"); - String messageYou = Txt.parse("%s %s admin bypass mode.", msender.getDisplayName(msender), desc); - String messageLog = Txt.parse("%s %s admin bypass mode.", msender.getDisplayName(IdUtil.getConsole()), desc); + String messageYou = Txt.parse("%s %s override mode.", msender.getDisplayName(msender), desc); + String messageLog = Txt.parse("%s %s override mode.", msender.getDisplayName(IdUtil.getConsole()), desc); msender.message(messageYou); Factions.get().log(messageLog); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPermList.java b/src/com/massivecraft/factions/cmd/CmdFactionsPermList.java index 1a376295..d565316d 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPermList.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPermList.java @@ -43,7 +43,7 @@ public class CmdFactionsPermList extends FactionsCommand for (MPerm perm : MPerm.getAll()) { - if ( ! perm.isVisible() && ! msender.isUsingAdminMode()) continue; + if ( ! perm.isVisible() && ! msender.isOverriding()) continue; messages.add(perm.getDesc(true, true)); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java b/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java index 4fac832c..c58ef663 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java @@ -55,7 +55,7 @@ public class CmdFactionsPermSet extends FactionsCommand if ( ! MPerm.getPermPerms().has(msender, faction, true)) return; // Is this perm editable? - if ( ! msender.isUsingAdminMode() && ! perm.isEditable()) + if ( ! msender.isOverriding() && ! perm.isEditable()) { msg("The perm %s is not editable.", perm.getName()); return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRank.java b/src/com/massivecraft/factions/cmd/CmdFactionsRank.java index 02d0fb12..c157797c 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRank.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsRank.java @@ -165,7 +165,7 @@ public class CmdFactionsRank extends FactionsCommand private void ensureAllowed() throws MassiveException { // 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). // We can at least try to limit their powers. diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java index 7bc5b14d..db21756a 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java @@ -42,7 +42,7 @@ public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX } // Radius Claim Max - if (radius > MConf.get().setRadiusMax && ! msender.isUsingAdminMode()) + if (radius > MConf.get().setRadiusMax && ! msender.isOverriding()) { msg("The maximum radius allowed is %s.", MConf.get().setRadiusMax); return null; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java index b6c149ce..d67ce356 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java @@ -46,7 +46,7 @@ public class CmdFactionsSethome extends FactionsCommandHome if ( ! MPerm.getPermSethome().has(msender, faction, true)) return; // Verify - if (!msender.isUsingAdminMode() && !faction.isValidHome(newHome)) + if (!msender.isOverriding() && !faction.isValidHome(newHome)) { msender.msg("Sorry, your faction home can only be set inside your own claimed territory."); return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java b/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java index 8a102f46..91908a7c 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java @@ -52,7 +52,7 @@ public class CmdFactionsTitle extends FactionsCommand if ( ! MPerm.getPermTitle().has(msender, you.getFaction(), true)) return; // Rank Check - if (!msender.isUsingAdminMode() && you.getRole().isMoreThan(msender.getRole())) + if (!msender.isOverriding() && you.getRole().isMoreThan(msender.getRole())) { msg("You can not edit titles for higher ranks."); return; diff --git a/src/com/massivecraft/factions/cmd/type/TypeRank.java b/src/com/massivecraft/factions/cmd/type/TypeRank.java index 04617060..924ea83b 100644 --- a/src/com/massivecraft/factions/cmd/type/TypeRank.java +++ b/src/com/massivecraft/factions/cmd/type/TypeRank.java @@ -91,26 +91,20 @@ public class TypeRank extends TypeEnum return "rank"; } + @Override + public String getNameInner(Rel value) + { + return value.getName(); + } + @Override public Set getNamesInner(Rel value) { // Create - Set ret = new MassiveSet(super.getNamesInner(value)); + Set ret = new MassiveSet(); // Fill Exact - if (value == Rel.LEADER) - { - ret.add("admin"); - } - else if (value == Rel.OFFICER) - { - ret.add("moderator"); - } - else if (value == Rel.MEMBER) - { - ret.add("member"); - ret.add("normal"); - } + ret.addAll(value.getNames()); // Fill Relative Rel start = this.getStartRank(); diff --git a/src/com/massivecraft/factions/cmd/type/TypeRel.java b/src/com/massivecraft/factions/cmd/type/TypeRel.java index 94937e80..68e896bf 100644 --- a/src/com/massivecraft/factions/cmd/type/TypeRel.java +++ b/src/com/massivecraft/factions/cmd/type/TypeRel.java @@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd.type; import java.util.Set; import com.massivecraft.factions.Rel; -import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.command.type.enumeration.TypeEnum; public class TypeRel extends TypeEnum @@ -26,25 +25,16 @@ public class TypeRel extends TypeEnum return "role"; } + @Override + public String getNameInner(Rel value) + { + return value.getName(); + } + @Override public Set getNamesInner(Rel value) { - Set ret = new MassiveSet(super.getNamesInner(value)); - - 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; + return value.getNames(); } } diff --git a/src/com/massivecraft/factions/engine/EngineMain.java b/src/com/massivecraft/factions/engine/EngineMain.java index d7f02ad0..2f157905 100644 --- a/src/com/massivecraft/factions/engine/EngineMain.java +++ b/src/com/massivecraft/factions/engine/EngineMain.java @@ -154,7 +154,7 @@ public class EngineMain extends EngineAbstract final boolean peaceful = faction.getFlag(MFlag.getFlagPeaceful()); // ID - if (mplayer.isUsingAdminMode()) + if (mplayer.isOverriding()) { 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 currentFactions = currentFactionChunks.keySet(); final Set chunks = event.getChunks(); - // Admin Mode? Sure! - if (mplayer.isUsingAdminMode()) return; + // Override Mode? Sure! + if (mplayer.isOverriding()) return; // CALC: Is there at least one normal faction among the current ones? boolean currentFactionsContainsAtLeastOneNormal = false; @@ -907,7 +907,7 @@ public class EngineMain extends EngineAbstract // ... fast evaluate if the attacker is overriding ... 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 ... if (defenderPsFaction.getFlag(MFlag.getFlagPvp()) == false) @@ -1096,8 +1096,8 @@ public class EngineMain extends EngineAbstract if (MUtil.isntPlayer(player)) return; MPlayer mplayer = MPlayer.get(player); - // ... and the player does not have adminmode ... - if (mplayer.isUsingAdminMode()) return; + // ... and the player is not overriding ... + if (mplayer.isOverriding()) return; // ... clean up the command ... String command = event.getMessage(); @@ -1404,7 +1404,7 @@ public class EngineMain extends EngineAbstract String name = mplayer.getName(); 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)) { @@ -1672,7 +1672,7 @@ public class EngineMain extends EngineAbstract if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; MPlayer mplayer = MPlayer.get(player); - if (mplayer.isUsingAdminMode()) return true; + if (mplayer.isOverriding()) return true; return MPerm.getPermBuild().has(mplayer, ps, verboose); } @@ -1685,7 +1685,7 @@ public class EngineMain extends EngineAbstract if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; MPlayer me = MPlayer.get(player); - if (me.isUsingAdminMode()) return true; + if (me.isOverriding()) return true; PS ps = PS.valueOf(block); Material material = block.getType(); @@ -1731,7 +1731,7 @@ public class EngineMain extends EngineAbstract // ... and the player is not using admin mode ... MPlayer me = MPlayer.get(player); - if (me.isUsingAdminMode()) return true; + if (me.isOverriding()) return true; // ... check container entity rights ... if (MConf.get().entityTypesContainer.contains(type) && ! MPerm.getPermContainer().has(me, ps, verboose)) return false; diff --git a/src/com/massivecraft/factions/entity/MFlag.java b/src/com/massivecraft/factions/entity/MFlag.java index 50760b43..a5f83616 100644 --- a/src/com/massivecraft/factions/entity/MFlag.java +++ b/src/com/massivecraft/factions/entity/MFlag.java @@ -193,7 +193,7 @@ public class MFlag extends Entity implements Prioritized, Registerable, N // Is this flag editable by 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) private boolean editable = false; public boolean isEditable() { return this.editable; } @@ -201,7 +201,7 @@ public class MFlag extends Entity implements Prioritized, Registerable, N // Is this flag visible to 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. // 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. diff --git a/src/com/massivecraft/factions/entity/MPerm.java b/src/com/massivecraft/factions/entity/MPerm.java index 5d4f04d4..9ba6abc7 100644 --- a/src/com/massivecraft/factions/entity/MPerm.java +++ b/src/com/massivecraft/factions/entity/MPerm.java @@ -245,7 +245,7 @@ public class MPerm extends Entity implements Prioritized, Registerable, N // Is this perm editable by 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) private boolean editable = false; public boolean isEditable() { return this.editable; } @@ -253,7 +253,7 @@ public class MPerm extends Entity implements Prioritized, Registerable, N // Is this perm visible to 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. // Say we set "editable" to false. // In such case we might want to hide the perm by setting "visible" false. @@ -296,9 +296,9 @@ public class MPerm extends Entity implements Prioritized, Registerable, N String ret = Txt.parse("%s does not allow you to %s.", hostFaction.describeTo(mplayer, true), this.getDesc()); Player player = mplayer.getPlayer(); - if (player != null && Perm.ADMIN.has(player)) + if (player != null && Perm.OVERRIDE.has(player)) { - ret += Txt.parse("\nYou can bypass by using " + Factions.get().getOuterCmdFactions().cmdFactionsAdmin.getTemplate(false).toPlain(true)); + ret += Txt.parse("\nYou can bypass by using " + Factions.get().getOuterCmdFactions().cmdFactionsOverride.getTemplate(false).toPlain(true)); } return ret; @@ -355,7 +355,7 @@ public class MPerm extends Entity implements Prioritized, Registerable, N if (mplayer == null) throw new NullPointerException("mplayer"); if (hostFaction == null) throw new NullPointerException("hostFaction"); - if (mplayer.isUsingAdminMode()) return true; + if (mplayer.isOverriding()) return true; Rel rel = mplayer.getRelationTo(hostFaction); if (hostFaction.isPermitted(this, rel)) return true; @@ -371,7 +371,7 @@ public class MPerm extends Entity implements Prioritized, Registerable, N if (mplayer == null) throw new NullPointerException("mplayer"); if (ps == null) throw new NullPointerException("ps"); - if (mplayer.isUsingAdminMode()) return true; + if (mplayer.isOverriding()) return true; TerritoryAccess ta = BoardColl.get().getTerritoryAccessAt(ps); Faction hostFaction = ta.getHostFaction(); diff --git a/src/com/massivecraft/factions/entity/MPlayer.java b/src/com/massivecraft/factions/entity/MPlayer.java index e9cc53d0..283a03e0 100644 --- a/src/com/massivecraft/factions/entity/MPlayer.java +++ b/src/com/massivecraft/factions/entity/MPlayer.java @@ -30,6 +30,7 @@ import com.massivecraft.massivecore.store.SenderEntity; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.Txt; +import com.massivecraft.massivecore.xlib.gson.annotations.SerializedName; public class MPlayer extends SenderEntity implements EconomyParticipator @@ -57,7 +58,7 @@ public class MPlayer extends SenderEntity implements EconomyParticipato this.setPowerBoost(that.powerBoost); this.setPower(that.power); this.setMapAutoUpdating(that.mapAutoUpdating); - this.setUsingAdminMode(that.usingAdminMode); + this.setOverriding(that.overriding); this.setTerritoryInfoTitles(that.territoryInfoTitles); return this; @@ -73,7 +74,7 @@ public class MPlayer extends SenderEntity implements EconomyParticipato if (this.hasPowerBoost()) 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.isUsingAdminMode()) return false; + if (this.isOverriding()) return false; if (this.isTerritoryInfoTitles() != MConf.get().territoryInfoTitlesDefault) return false; return true; @@ -156,9 +157,10 @@ public class MPlayer extends SenderEntity implements EconomyParticipato // Null means false private Boolean mapAutoUpdating = null; - // Is this player using admin mode? + // Is this player overriding? // Null means false - private Boolean usingAdminMode = null; + @SerializedName(value = "usingAdminMode") + private Boolean overriding = null; // Does this player use titles for territory info? // Null means default specified in MConf. @@ -533,35 +535,35 @@ public class MPlayer extends SenderEntity implements EconomyParticipato } // -------------------------------------------- // - // FIELD: usingAdminMode + // FIELD: overriding // -------------------------------------------- // - public boolean isUsingAdminMode() + public boolean isOverriding() { - if (this.usingAdminMode == null) return false; - if (this.usingAdminMode == false) return false; + if (this.overriding == null) return false; + if (this.overriding == false) return false; // 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 true; } - public void setUsingAdminMode(Boolean usingAdminMode) + public void setOverriding(Boolean overriding) { // Clean input - Boolean target = usingAdminMode; + Boolean target = overriding; if (MUtil.equals(target, false)) target = null; // Detect Nochange - if (MUtil.equals(this.usingAdminMode, target)) return; + if (MUtil.equals(this.overriding, target)) return; // Apply - this.usingAdminMode = target; + this.overriding = target; // Mark as changed this.changed(); diff --git a/src/com/massivecraft/factions/integration/Econ.java b/src/com/massivecraft/factions/integration/Econ.java index a46880de..cb3ba87b 100644 --- a/src/com/massivecraft/factions/integration/Econ.java +++ b/src/com/massivecraft/factions/integration/Econ.java @@ -31,7 +31,7 @@ public class Econ if (!isEnabled()) return true; if (cost == 0D) return true; - if (usender.isUsingAdminMode()) return true; + if (usender.isOverriding()) return true; Faction usenderFaction = usender.getFaction(); @@ -72,7 +72,7 @@ public class Econ if (me == null) return true; // 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 if (me == you) return true; diff --git a/src/com/massivecraft/factions/integration/worldguard/EngineWorldGuard.java b/src/com/massivecraft/factions/integration/worldguard/EngineWorldGuard.java index 22615df0..3f907fdc 100644 --- a/src/com/massivecraft/factions/integration/worldguard/EngineWorldGuard.java +++ b/src/com/massivecraft/factions/integration/worldguard/EngineWorldGuard.java @@ -81,8 +81,8 @@ public class EngineWorldGuard extends EngineAbstract if ( ! MConf.get().worldguardCheckWorldsEnabled.contains(mplayer.getPlayer())) return; - // For admins don't bother checking - if (mplayer.isUsingAdminMode()) return; + // For overriders don't bother checking + if (mplayer.isOverriding()) return; for (PS chunkChecking : event.getChunks()) {