From 10f535e63722d8eb32c4beaba1b893688805c2de Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sun, 9 Oct 2011 14:53:38 +0200 Subject: [PATCH] Halfway through refactoring of commands and permissions --- src/com/massivecraft/factions/Conf.java | 8 +- src/com/massivecraft/factions/FPlayer.java | 103 +++--- src/com/massivecraft/factions/Faction.java | 10 + src/com/massivecraft/factions/P.java | 13 +- .../factions/commands/CmdBase.java | 42 +++ .../factions/commands/FCommand.java | 80 ++--- .../factions/commands/FCommandAdmin.java | 80 ++--- .../factions/commands/FCommandAutoClaim.java | 79 +++-- .../commands/FCommandAutoSafeclaim.java | 68 ++-- .../commands/FCommandAutoWarclaim.java | 59 ++-- .../factions/commands/FCommandBalance.java | 57 ++-- .../factions/commands/FCommandBypass.java | 51 +-- .../factions/commands/FCommandChat.java | 91 +++--- .../factions/commands/FCommandClaim.java | 35 +- .../factions/commands/FCommandConfig.java | 166 ++++++---- .../factions/commands/FCommandCreate.java | 67 ++-- .../factions/commands/FCommandDeinvite.java | 59 ++-- .../factions/commands/FCommandDeposit.java | 65 ++-- .../commands/FCommandDescription.java | 51 +-- .../factions/commands/FCommandDisband.java | 107 +++--- .../factions/commands/FCommandHelp.java | 68 ++-- .../factions/commands/FCommandHome.java | 91 ++++-- .../factions/commands/FCommandInvite.java | 62 ++-- .../factions/commands/FCommandJoin.java | 77 +++-- .../factions/commands/FCommandKick.java | 87 +++-- .../factions/commands/FCommandLeave.java | 35 +- .../factions/commands/FCommandList.java | 101 +++--- .../factions/commands/FCommandLock.java | 54 ++-- .../factions/commands/FCommandMap.java | 67 ++-- .../factions/commands/FCommandMod.java | 70 ++-- .../factions/commands/FCommandNoBoom.java | 6 +- .../factions/commands/FCommandOpen.java | 14 +- .../factions/commands/FCommandOwner.java | 24 +- .../factions/commands/FCommandOwnerList.java | 16 +- .../factions/commands/FCommandPay.java | 77 ++--- .../factions/commands/FCommandPeaceful.java | 4 +- .../factions/commands/FCommandPermanent.java | 4 +- .../factions/commands/FCommandPower.java | 8 +- .../factions/commands/FCommandSafeclaim.java | 2 +- .../factions/commands/FCommandSethome.java | 22 +- .../factions/commands/FCommandShow.java | 12 +- .../factions/commands/FCommandTag.java | 10 +- .../factions/commands/FCommandTitle.java | 8 +- .../factions/commands/FCommandUnclaim.java | 18 +- .../factions/commands/FCommandUnclaimall.java | 12 +- .../factions/commands/FCommandWarclaim.java | 2 +- .../factions/commands/FCommandWithdraw.java | 78 ++--- .../factions/commands/FRelationCommand.java | 2 +- .../listeners/FactionsPlayerListener.java | 16 +- .../factions/struct/ChatMode.java | 22 +- .../factions/struct/Permission.java | 56 +++- .../massivecraft/factions/zcore/MCommand.java | 60 ++-- .../factions/zcore/persist/PlayerEntity.java | 8 + src/plugin.yml | 306 +++++------------- 54 files changed, 1478 insertions(+), 1312 deletions(-) create mode 100644 src/com/massivecraft/factions/commands/CmdBase.java diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index b5357dff..158d0855 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -1,6 +1,7 @@ package com.massivecraft.factions; import java.util.*; + import org.bukkit.*; import org.bukkit.entity.CreatureType; @@ -10,6 +11,9 @@ public class Conf // not worth saving between server restarts, I think public static transient Set adminBypassPlayers = Collections.synchronizedSet(new HashSet()); + public static List baseCommandAliases = new ArrayList(); + public static boolean allowNoSlashCommand = true; + // Colors public static ChatColor colorMember = ChatColor.GREEN; public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE; @@ -68,8 +72,6 @@ public class Conf public static String factionChatFormat = "%s"+ChatColor.WHITE+" %s"; public static String allianceChatFormat = "%s"+ChatColor.WHITE+" %s"; - public static boolean allowNoSlashCommand = true; - public static double autoLeaveAfterDaysOfInactivity = 14.0; public static boolean worldGuardChecking = false; @@ -239,6 +241,8 @@ public class Conf static { + baseCommandAliases.add("f"); + territoryEnemyDenyCommands.add("home"); territoryEnemyDenyCommands.add("sethome"); territoryEnemyDenyCommands.add("spawn"); diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index d273a5b6..6dc69433 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -1,23 +1,15 @@ package com.massivecraft.factions; -import java.io.*; -import java.lang.reflect.Type; -import java.util.*; -import java.util.logging.Level; -import java.util.Map.Entry; - import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.Player; -import com.google.gson.reflect.TypeToken; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.struct.ChatMode; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; -import com.massivecraft.factions.zcore.persist.Entity; import com.massivecraft.factions.zcore.persist.PlayerEntity; @@ -70,12 +62,46 @@ public class FPlayer extends PlayerEntity // FIELD: autoClaimEnabled private transient boolean autoClaimEnabled; + public boolean isAutoClaimEnabled() + { + if (this.factionId.equals("0")) return false; + return autoClaimEnabled; + } + public void setIsAutoClaimEnabled(boolean enabled) + { + this.autoClaimEnabled = enabled; + if (enabled) + { + this.autoSafeZoneEnabled = false; + this.autoWarZoneEnabled = false; + } + } // FIELD: autoSafeZoneEnabled private transient boolean autoSafeZoneEnabled; - + public boolean isAutoSafeClaimEnabled() { return autoSafeZoneEnabled; } + public void setIsAutoSafeClaimEnabled(boolean enabled) + { + this.autoSafeZoneEnabled = enabled; + if (enabled) + { + this.autoClaimEnabled = false; + this.autoWarZoneEnabled = false; + } + } + // FIELD: autoWarZoneEnabled private transient boolean autoWarZoneEnabled; + public boolean isAutoWarClaimEnabled() { return autoWarZoneEnabled; } + public void setIsAutoWarClaimEnabled(boolean enabled) + { + this.autoWarZoneEnabled = enabled; + if (enabled) + { + this.autoClaimEnabled = false; + this.autoSafeZoneEnabled = false; + } + } // FIELD: loginPvpDisabled private transient boolean loginPvpDisabled; @@ -113,10 +139,11 @@ public class FPlayer extends PlayerEntity public void resetFactionData() { // clean up any territory ownership in old faction, if there is one - if (this.factionId > 0 && Factions.i.exists(this.factionId)) + Faction currentFaction = this.getFaction(); + + if (currentFaction != null && currentFaction.isNormal()) { - // TODO: Get faction function... - Factions.i.get(factionId).clearClaimOwnership(this.getId()); + currentFaction.clearClaimOwnership(this.getId()); } this.factionId = "0"; // The default neutral faction @@ -156,48 +183,7 @@ public class FPlayer extends PlayerEntity return lastLoginTime; } - public boolean autoClaimEnabled() - { - if (this.factionId.equals("0")) return false; - return autoClaimEnabled; - } - public void enableAutoClaim(boolean enabled) - { - this.autoClaimEnabled = enabled; - if (enabled) - { - this.autoSafeZoneEnabled = false; - this.autoWarZoneEnabled = false; - } - } - - public boolean autoSafeZoneEnabled() - { - return autoSafeZoneEnabled; - } - public void enableAutoSafeZone(boolean enabled) - { - this.autoSafeZoneEnabled = enabled; - if (enabled) - { - this.autoClaimEnabled = false; - this.autoWarZoneEnabled = false; - } - } - - public boolean autoWarZoneEnabled() - { - return autoWarZoneEnabled; - } - public void enableAutoWarZone(boolean enabled) - { - this.autoWarZoneEnabled = enabled; - if (enabled) - { - this.autoClaimEnabled = false; - this.autoSafeZoneEnabled = false; - } - } + public void setLastLoginTime(long lastLoginTime) { @@ -513,8 +499,8 @@ public class FPlayer extends PlayerEntity public boolean isInOthersTerritory() { - String idHere = Board.getIdAt(new FLocation(this)); - return idHere > 0 && idHere != this.factionId; + Faction factionHere = Board.getFactionAt(new FLocation(this)); + return factionHere != null && factionHere.isNormal() && factionHere != this.getFaction(); } public boolean isInAllyTerritory() @@ -892,4 +878,9 @@ public class FPlayer extends PlayerEntity } return true; }*/ + + public void sendMessageParsed(String str, Object... args) + { + this.sendMessage(P.p.txt.parse(str, args)); + } } \ No newline at end of file diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index 0d5d34d4..c6f48e08 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -409,6 +409,16 @@ public class Faction extends Entity //----------------------------------------------// // Messages //----------------------------------------------// + public void sendMessageParsed(String message, Object... args) + { + message = P.p.txt.parse(message, args); + + for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) + { + fplayer.sendMessage(message); + } + } + public void sendMessage(String message) { for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) diff --git a/src/com/massivecraft/factions/P.java b/src/com/massivecraft/factions/P.java index 17615585..431c7de8 100644 --- a/src/com/massivecraft/factions/P.java +++ b/src/com/massivecraft/factions/P.java @@ -44,9 +44,6 @@ import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.massivecraft.factions.integration.EssentialsFeatures; -/** - * The data is saved to disk every 30min and on plugin disable. - */ public class P extends MPlugin { // Our single plugin instance @@ -58,6 +55,8 @@ public class P extends MPlugin public final FactionsEntityListener entityListener; public final FactionsBlockListener blockListener; + public CmdBase cmdBase; + public P() { p = this; @@ -82,6 +81,10 @@ public class P extends MPlugin Factions.i.loadFromDisc(); Board.load(); + // Add Base Commands + this.cmdBase = new CmdBase(); + this.getBaseCommands().add(cmdBase); + //setupPermissions(); integrateEssentialsChat(); setupSpout(this); @@ -96,7 +99,7 @@ public class P extends MPlugin //Type mapFLocToStringSetType = new TypeToken>>(){}.getType(); // Add the commands - commands.add(new FCommandHelp()); + /*commands.add(new FCommandHelp()); commands.add(new FCommandAdmin()); commands.add(new FCommandAutoClaim()); commands.add(new FCommandAutoSafeclaim()); @@ -144,7 +147,7 @@ public class P extends MPlugin commands.add(new FCommandVersion()); commands.add(new FCommandWarclaim()); commands.add(new FCommandWarunclaimall()); - commands.add(new FCommandWithdraw()); + commands.add(new FCommandWithdraw());*/ // Register events PluginManager pm = this.getServer().getPluginManager(); diff --git a/src/com/massivecraft/factions/commands/CmdBase.java b/src/com/massivecraft/factions/commands/CmdBase.java new file mode 100644 index 00000000..b172a28f --- /dev/null +++ b/src/com/massivecraft/factions/commands/CmdBase.java @@ -0,0 +1,42 @@ +package com.massivecraft.factions.commands; + +import com.massivecraft.factions.Conf; + +public class CmdBase extends FCommand +{ + //public CmdAccept cmdAccept = new CmdAccept(); + + public CmdBase() + { + super(); + this.aliases.addAll(Conf.baseCommandAliases); + this.allowNoSlashAccess = Conf.allowNoSlashCommand; + + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + + this.setHelpShort("The faction base command"); + this.helpLong.add(p.txt.tags("This command contains all faction stuff.")); + + /*this.subCommands.add(p.cmdHelp); + this.subCommands.add(new CmdIntend()); + this.subCommands.add(new CmdInfect()); + this.subCommands.add(cmdAccept); + this.subCommands.add(new CmdList()); + this.subCommands.add(new CmdSetfood()); + this.subCommands.add(new CmdSetinfection()); + this.subCommands.add(new CmdTurn()); + this.subCommands.add(new CmdCure()); + this.subCommands.add(new CmdVersion());*/ + } + + @Override + public void perform() + { + //this.commandChain.add(this); + //p.cmdHelp.execute(this.sender, this.args, this.commandChain); + } + +} diff --git a/src/com/massivecraft/factions/commands/FCommand.java b/src/com/massivecraft/factions/commands/FCommand.java index 894c75fa..cd46bd44 100644 --- a/src/com/massivecraft/factions/commands/FCommand.java +++ b/src/com/massivecraft/factions/commands/FCommand.java @@ -19,9 +19,16 @@ import com.massivecraft.factions.zcore.MCommand; public abstract class FCommand extends MCommand

{ //TODO: Legacy to handle - //public boolean senderIsConsole; - //private static boolean lock = false; - + private static boolean lock = false; + // TODO: Move these messages to the locked command?? + // TODO: I lost the check for this code somewhere as well :/ + public void setIsLocked(boolean isLocked) { lock = isLocked; } + public boolean isLocked() { return lock; } + public void sendLockMessage() + { + // TODO: CCOLOR!!! + me.sendMessage("Factions is locked. Please try again later"); + } public FPlayer fme; public boolean senderMustBeMember; @@ -70,19 +77,47 @@ public abstract class FCommand extends MCommand

if (this.senderMustBeModerator && ! fplayer.getRole().isAtLeast(Role.MODERATOR)) { - sender.sendMessage(p.txt.parse("Only faction moderators can %s.", this.helpShort)); + sender.sendMessage(p.txt.parse("Only faction moderators can %s.", this.getHelpShort())); return false; } if (this.senderMustBeAdmin && ! fplayer.getRole().isAtLeast(Role.ADMIN)) { - sender.sendMessage(p.txt.parse("Only faction admins can %s.", this.helpShort)); + sender.sendMessage(p.txt.parse("Only faction admins can %s.", this.getHelpShort())); return false; } return true; } + // -------------------------------------------- // + // Assertions + // -------------------------------------------- // + + public boolean assertHasFaction() + { + if (me == null) return true; + + if ( ! fme.hasFaction()) + { + sendMessage("You are not member of any faction."); + return false; + } + return true; + } + + public boolean assertMinRole(Role role) + { + if (me == null) return true; + + if (fme.getRole().value < role.value) + { + sendMessageParsed("You must be "+role+" to "+this.getHelpShort()+"."); + return false; + } + return true; + } + // -------------------------------------------- // // Argument Readers // -------------------------------------------- // @@ -232,12 +267,12 @@ public abstract class FCommand extends MCommand

// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost public boolean payForCommand(double cost) { - if ( ! Econ.enabled() || this.me == null || cost == 0.0 || Conf.adminBypassPlayers.contains(me.getName())) + if ( ! Econ.enabled() || this.fme == null || cost == 0.0 || Conf.adminBypassPlayers.contains(fme.getName())) { return true; } - String desc = this.helpShort.toLowerCase(); + String desc = this.getHelpShort().toLowerCase(); Faction faction = fme.getFaction(); @@ -260,7 +295,7 @@ public abstract class FCommand extends MCommand

} else { - if (!Econ.deductMoney(me.getName(), cost)) + if (!Econ.deductMoney(fme.getName(), cost)) { sendMessage("It costs "+costString+" to "+desc+", which you can't currently afford."); return false; @@ -280,7 +315,7 @@ public abstract class FCommand extends MCommand

} else { - Econ.addMoney(me.getName(), -cost); + Econ.addMoney(fme.getName(), -cost); } @@ -288,31 +323,4 @@ public abstract class FCommand extends MCommand

} return true; } - - - // TODO: Move these messages to the locked command?? - // TODO: I lost the check for this code somewhere as well :/ - public void setIsLocked(boolean isLocked) - { - if( isLocked ) - { - sendMessage("Factions is now locked"); - } - else - { - sendMessage("Factions in now unlocked"); - } - - lock = isLocked; - } - - public boolean isLocked() - { - return lock; - } - - public void sendLockMessage() - { - me.sendMessage("Factions is locked. Please try again later"); - } } diff --git a/src/com/massivecraft/factions/commands/FCommandAdmin.java b/src/com/massivecraft/factions/commands/FCommandAdmin.java index d73ace4b..9a7ad27a 100644 --- a/src/com/massivecraft/factions/commands/FCommandAdmin.java +++ b/src/com/massivecraft/factions/commands/FCommandAdmin.java @@ -1,64 +1,68 @@ package com.massivecraft.factions.commands; -import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; -public class FCommandAdmin extends FCommand { - - public FCommandAdmin() { - aliases.add("admin"); +public class FCommandAdmin extends FCommand +{ + public FCommandAdmin() + { + super(); + this.aliases.add("admin"); - requiredParameters.add("player name"); + this.requiredArgs.add("player name"); + //this.optionalArgs.put("", ""); - helpDescription = "Hand over your admin rights"; + this.permission = Permission.COMMAND_ADMIN.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = true; } @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - if ( ! assertMinRole(Role.ADMIN)) { + FPlayer fyou = this.argAsBestFPlayerMatch(0); + if (fyou == null) return; + + Faction myFaction = fme.getFaction(); + + if (fyou.getFaction() != myFaction) + { + sendMessageParsed("%s is not a member in your faction.", fyou.getNameAndRelevant(fme)); return; } - String playerName = parameters.get(0); - - FPlayer you = findFPlayer(playerName, false); - if (you == null) { + if (fyou == fme) + { + sendMessageParsed("The target player musn't be yourself."); return; } - Faction myFaction = me.getFaction(); - - if (you.getFaction() != myFaction) { - sendMessage(you.getNameAndRelevant(me)+Conf.colorSystem+" is not a member in your faction."); - return; - } - - if (you == me) { - sendMessage("The target player musn't be yourself."); - return; - } - - - me.setRole(Role.MODERATOR); - you.setRole(Role.ADMIN); + fme.setRole(Role.MODERATOR); + fyou.setRole(Role.ADMIN); // Inform all players - for (FPlayer fplayer : FPlayer.getAllOnline()) { - if (fplayer.getFaction() == me.getFaction()) { - fplayer.sendMessage(me.getNameAndRelevant(me)+Conf.colorSystem+" gave "+you.getNameAndRelevant(me)+Conf.colorSystem+" the leadership of your faction."); - } else { - fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" gave "+you.getNameAndRelevant(fplayer)+Conf.colorSystem+" the leadership of "+myFaction.getTag(fplayer)); + for (FPlayer fplayer : FPlayers.i.getOnline()) + { + if (fplayer.getFaction() == myFaction) + { + fplayer.sendMessageParsed("%s gave %s the leadership of your faction.", fme.getNameAndRelevant(fme), fyou.getNameAndRelevant(fme)); + } + else + { + fplayer.sendMessageParsed("%s gave %s the leadership of %s", fme.getNameAndRelevant(fplayer), fyou.getNameAndRelevant(fplayer), myFaction.getTag(fplayer)); } } } diff --git a/src/com/massivecraft/factions/commands/FCommandAutoClaim.java b/src/com/massivecraft/factions/commands/FCommandAutoClaim.java index ca423034..3fbb2af8 100644 --- a/src/com/massivecraft/factions/commands/FCommandAutoClaim.java +++ b/src/com/massivecraft/factions/commands/FCommandAutoClaim.java @@ -3,65 +3,64 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Permission; -public class FCommandAutoClaim extends FCommand { - - public FCommandAutoClaim() { - aliases.add("autoclaim"); - - optionalParameters.add("on|off"); - - helpDescription = "Auto-claim land as you walk around"; +public class FCommandAutoClaim extends FCommand +{ + public FCommandAutoClaim() + { + super(); + this.aliases.add("autoclaim"); + + //this.requiredArgs.add(""); + this.optionalArgs.put("on/off", "flipp"); + + this.permission = Permission.COMMAND_AUTOCLAIM.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; } @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - // default: toggle existing value - boolean enable = !me.autoClaimEnabled(); + boolean enabled = this.argAsBool(0, ! fme.isAutoClaimEnabled()); + + fme.setIsAutoClaimEnabled(enabled); - // if on|off is specified, use that instead - if (parameters.size() > 0) - enable = parseBool(parameters.get(0)); - - me.enableAutoClaim(enable); - - if (!enable) { - sendMessage("Auto-claiming of land disabled."); + if ( ! enabled) + { + sendMessageParsed("Auto-claiming of land disabled."); return; } - Faction myFaction = me.getFaction(); - FLocation flocation = new FLocation(me); + Faction myFaction = fme.getFaction(); + FLocation flocation = new FLocation(fme); - if ( ! assertMinRole(Role.MODERATOR)) { - me.enableAutoClaim(false); + if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) + { + sendMessageParsed("Sorry, this world has land claiming disabled."); + fme.setIsAutoClaimEnabled(false); return; } - if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) { - sendMessage("Sorry, this world has land claiming disabled."); - me.enableAutoClaim(false); + if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) + { + sendMessageParsed("You can't claim more land! You need more power!"); + fme.setIsAutoClaimEnabled(false); return; } - if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) { - sendMessage("You can't claim more land! You need more power!"); - me.enableAutoClaim(false); - return; - } - - sendMessage("Auto-claiming of land enabled."); - me.attemptClaim(false); + sendMessageParsed("Auto-claiming of land enabled."); + fme.attemptClaim(false); } } diff --git a/src/com/massivecraft/factions/commands/FCommandAutoSafeclaim.java b/src/com/massivecraft/factions/commands/FCommandAutoSafeclaim.java index 6dce2c2c..ee8db67e 100644 --- a/src/com/massivecraft/factions/commands/FCommandAutoSafeclaim.java +++ b/src/com/massivecraft/factions/commands/FCommandAutoSafeclaim.java @@ -1,54 +1,58 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; - import com.massivecraft.factions.Board; import com.massivecraft.factions.FLocation; -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.P; +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.struct.Permission; -public class FCommandAutoSafeclaim extends FCommand { +public class FCommandAutoSafeclaim extends FCommand +{ - public FCommandAutoSafeclaim() { - aliases.add("autosafe"); - - optionalParameters.add("on|off"); - - helpDescription = "Auto-claim land for the safezone"; + public FCommandAutoSafeclaim() + { + super(); + this.aliases.add("autosafe"); + + //this.requiredArgs.add(""); + this.optionalArgs.put("on/off", "flipp"); + + this.permission = Permission.MANAGE_SAFE_ZONE.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; + + this.setHelpShort("Auto-claim land for the safezone"); } @Override - public boolean hasPermission(CommandSender sender) { - return P.hasPermManageSafeZone(sender); - } - - @Override - public void perform() { - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - boolean enable = !me.autoSafeZoneEnabled(); + boolean enabled = this.argAsBool(0, ! fme.isAutoSafeClaimEnabled()); + + fme.setIsAutoSafeClaimEnabled(enabled); - if (parameters.size() > 0) - enable = parseBool(parameters.get(0)); - - me.enableAutoSafeZone(enable); - - if (!enable) { - sendMessage("Auto-claiming of safe zone disabled."); + if ( ! enabled) + { + sendMessageParsed("Auto-claiming of safe zone disabled."); return; } - sendMessage("Auto-claiming of safe zone enabled."); + sendMessageParsed("Auto-claiming of safe zone enabled."); - FLocation playerFlocation = new FLocation(me); + FLocation playerFlocation = new FLocation(fme); - if (!Board.getFactionAt(playerFlocation).isSafeZone()) { - Board.setFactionAt(Faction.getSafeZone(), playerFlocation); - sendMessage("This land is now a safe zone."); + if (!Board.getFactionAt(playerFlocation).isSafeZone()) + { + Board.setFactionAt(Factions.i.getSafeZone(), playerFlocation); + sendMessageParsed("This land is now a safe zone."); } } diff --git a/src/com/massivecraft/factions/commands/FCommandAutoWarclaim.java b/src/com/massivecraft/factions/commands/FCommandAutoWarclaim.java index c713899d..3a3f6a56 100644 --- a/src/com/massivecraft/factions/commands/FCommandAutoWarclaim.java +++ b/src/com/massivecraft/factions/commands/FCommandAutoWarclaim.java @@ -1,54 +1,61 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; import com.massivecraft.factions.Board; import com.massivecraft.factions.FLocation; -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.P; +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.struct.Permission; -public class FCommandAutoWarclaim extends FCommand { +public class FCommandAutoWarclaim extends FCommand +{ - public FCommandAutoWarclaim() { + public FCommandAutoWarclaim() + { + super(); + this.aliases.add("autosafe"); + + //this.requiredArgs.add(""); + this.optionalArgs.put("on/off", "flipp"); + + this.permission = Permission.MANAGE_WAR_ZONE.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; + aliases.add("autowar"); - optionalParameters.add("on|off"); - - helpDescription = "Auto-claim land for the warzone"; - } - - @Override - public boolean hasPermission(CommandSender sender) { - return P.hasPermManageWarZone(sender); + this.setHelpShort("Auto-claim land for the warzone"); } @Override public void perform() { - if( isLocked() ) { + if ( isLocked() ) + { sendLockMessage(); return; } - boolean enable = !me.autoWarZoneEnabled(); + boolean enabled = this.argAsBool(0, ! fme.isAutoWarClaimEnabled()); - if (parameters.size() > 0) - enable = parseBool(parameters.get(0)); + fme.setIsAutoWarClaimEnabled(enabled); - me.enableAutoWarZone(enable); - - if (!enable) { - sendMessage("Auto-claiming of war zone disabled."); + if ( ! enabled) + { + sendMessageParsed("Auto-claiming of war zone disabled."); return; } - sendMessage("Auto-claiming of war zone enabled."); + sendMessageParsed("Auto-claiming of war zone enabled."); - FLocation playerFlocation = new FLocation(me); + FLocation playerFlocation = new FLocation(fme); - if (!Board.getFactionAt(playerFlocation).isWarZone()) { - Board.setFactionAt(Faction.getWarZone(), playerFlocation); - sendMessage("This land is now a war zone."); + if (!Board.getFactionAt(playerFlocation).isWarZone()) + { + Board.setFactionAt(Factions.i.getWarZone(), playerFlocation); + sendMessageParsed("This land is now a war zone."); } } diff --git a/src/com/massivecraft/factions/commands/FCommandBalance.java b/src/com/massivecraft/factions/commands/FCommandBalance.java index c9029335..d635bdb7 100644 --- a/src/com/massivecraft/factions/commands/FCommandBalance.java +++ b/src/com/massivecraft/factions/commands/FCommandBalance.java @@ -2,49 +2,52 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.P; - -public class FCommandBalance extends FCommand { - - public FCommandBalance() { - aliases.add("balance"); - aliases.add("money"); +public class FCommandBalance extends FCommand +{ + public FCommandBalance() + { + super(); + this.aliases.add("balance"); + this.aliases.add("money"); - optionalParameters.add("faction tag"); + //this.requiredArgs.add("player name"); + this.optionalArgs.put("factiontag", "yours"); - helpDescription = "Show faction's current balance"; + this.permission = Permission.COMMAND_BALANCE.node; + + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public void perform() { - if ( ! assertHasFaction()) { + public void perform() + { + if ( ! Conf.bankEnabled) + { return; } - if (!Conf.bankEnabled) { + Faction faction = this.argAsFaction(0, fme.getFaction()); + + // TODO MAKE HIERARCHIAL COMMAND STRUCTURE HERE + if ( faction != fme.getFaction() && ! Permission.VIEW_ANY_FACTION_BALANCE.has(sender)) + { + sendMessageParsed("You do not have sufficient permissions to view the bank balance of other factions."); return; } - Faction faction; - - if (parameters.size() > 0) { - if (!P.hasPermViewAnyFactionBalance(sender)) { - sendMessage("You do not have sufficient permissions to view the bank balance of other factions."); - return; - } - faction = findFaction(parameters.get(0), true); - } else { - faction = me.getFaction(); - } - - if(faction == null) { - sendMessage("Faction "+parameters.get(0)+" could not be found."); + if (faction == null) + { + sendMessageParsed("Faction %s could not be found.", args.get(0)); return; } - sendMessage(Conf.colorChrome+faction.getTag()+" balance: "+ Econ.moneyString(faction.getMoney())); + sendMessageParsed("%s balance: %s", faction.getTag(), Econ.moneyString(faction.getMoney())); } } diff --git a/src/com/massivecraft/factions/commands/FCommandBypass.java b/src/com/massivecraft/factions/commands/FCommandBypass.java index 9e2a0e2c..e60c8757 100644 --- a/src/com/massivecraft/factions/commands/FCommandBypass.java +++ b/src/com/massivecraft/factions/commands/FCommandBypass.java @@ -1,34 +1,43 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; - import com.massivecraft.factions.Conf; import com.massivecraft.factions.P; +import com.massivecraft.factions.struct.Permission; -public class FCommandBypass extends FCommand { - - public FCommandBypass() { - aliases.add("bypass"); +public class FCommandBypass extends FCommand +{ + public FCommandBypass() + { + super(); + this.aliases.add("bypass"); - helpDescription = "Enable admin bypass mode; build/destroy anywhere"; - } - - @Override - public boolean hasPermission(CommandSender sender) { - return P.hasPermAdminBypass(sender); + //this.requiredArgs.add(""); + this.optionalArgs.put("on/off", "flipp"); + + this.permission = Permission.ADMIN_BYPASS.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public void perform() { - if ( ! Conf.adminBypassPlayers.contains(me.getName())) { - Conf.adminBypassPlayers.add(me.getName()); - me.sendMessage("You have enabled admin bypass mode. You will be able to build or destroy anywhere."); - P.log(me.getName() + " has ENABLED admin bypass mode."); - } else { - Conf.adminBypassPlayers.remove(me.getName()); - me.sendMessage("You have disabled admin bypass mode."); - P.log(me.getName() + " DISABLED admin bypass mode."); + public void perform() + { + // TODO: Move this to a transient field in the model?? + if ( ! Conf.adminBypassPlayers.contains(fme.getName())) + { + Conf.adminBypassPlayers.add(fme.getName()); + fme.sendMessageParsed("You have enabled admin bypass mode. You will be able to build or destroy anywhere."); + P.p.log(fme.getName() + " has ENABLED admin bypass mode."); + } + else + { + Conf.adminBypassPlayers.remove(fme.getName()); + fme.sendMessageParsed("You have disabled admin bypass mode."); + P.p.log(fme.getName() + " DISABLED admin bypass mode."); } } } diff --git a/src/com/massivecraft/factions/commands/FCommandChat.java b/src/com/massivecraft/factions/commands/FCommandChat.java index e2ff60f1..7a8d8818 100644 --- a/src/com/massivecraft/factions/commands/FCommandChat.java +++ b/src/com/massivecraft/factions/commands/FCommandChat.java @@ -2,56 +2,71 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.struct.ChatMode; +import com.massivecraft.factions.struct.Permission; -public class FCommandChat extends FCommand { +public class FCommandChat extends FCommand +{ - public FCommandChat() { - aliases.add("chat"); - aliases.add("c"); + public FCommandChat() + { + super(); + this.aliases.add("c"); + this.aliases.add("chat"); - optionalParameters.add("mode"); + //this.requiredArgs.add(""); + this.optionalArgs.put("mode", "next"); - helpDescription = "Change chat mode"; + this.permission = Permission.COMMAND_CHAT.node; + + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public void perform() { - if ( ! Conf.factionOnlyChat ) { - sendMessage("Faction-only chat is disabled on this server."); - return; - } - if ( ! assertHasFaction()) { + public void perform() + { + if ( ! Conf.factionOnlyChat ) + { + sendMessageParsed("Faction-only chat is disabled on this server."); return; } - if( this.parameters.size() >= 1 ) { - String mode = this.parameters.get(0); - - if(mode.startsWith("p")) { - me.setChatMode(ChatMode.PUBLIC); - sendMessage("Public chat mode."); - } else if(mode.startsWith("a")) { - me.setChatMode(ChatMode.ALLIANCE); - sendMessage("Alliance only chat mode."); - } else if(mode.startsWith("f")) { - me.setChatMode(ChatMode.FACTION); - sendMessage("Faction only chat mode."); - } else { - sendMessage("Unrecognised chat mode. Please enter either 'a','f' or 'p'"); - } - - } else { + String modeString = this.argAsString(0).toLowerCase(); + ChatMode modeTarget = fme.getChatMode().getNext(); - if(me.getChatMode() == ChatMode.PUBLIC) { - me.setChatMode(ChatMode.ALLIANCE); - sendMessage("Alliance only chat mode."); - } else if (me.getChatMode() == ChatMode.ALLIANCE ) { - me.setChatMode(ChatMode.FACTION); - sendMessage("Faction only chat mode."); - } else { - me.setChatMode(ChatMode.PUBLIC); - sendMessage("Public chat mode."); + if (modeString != null) + { + if(modeString.startsWith("p")) + { + modeTarget = ChatMode.PUBLIC; } + else if (modeString.startsWith("a")) + { + modeTarget = ChatMode.ALLIANCE; + } + else if(modeString.startsWith("f")) + { + modeTarget = ChatMode.FACTION; + } + sendMessageParsed("Unrecognised chat mode. Please enter either 'a','f' or 'p'"); + return; + } + + fme.setChatMode(modeTarget); + + if(fme.getChatMode() == ChatMode.PUBLIC) + { + sendMessageParsed("Public chat mode."); + } + else if (fme.getChatMode() == ChatMode.ALLIANCE ) + { + sendMessageParsed("Alliance only chat mode."); + } + else + { + sendMessageParsed("Faction only chat mode."); } } } diff --git a/src/com/massivecraft/factions/commands/FCommandClaim.java b/src/com/massivecraft/factions/commands/FCommandClaim.java index ba282d85..4c70592f 100644 --- a/src/com/massivecraft/factions/commands/FCommandClaim.java +++ b/src/com/massivecraft/factions/commands/FCommandClaim.java @@ -1,25 +1,38 @@ package com.massivecraft.factions.commands; -public class FCommandClaim extends FCommand { +import com.massivecraft.factions.struct.Permission; + +public class FCommandClaim extends FCommand +{ - public FCommandClaim() { - aliases.add("claim"); + public FCommandClaim() + { + super(); + this.aliases.add("claim"); - helpDescription = "Claim the land where you are standing"; + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); + + this.permission = Permission.COMMAND_CLAIM.node; + + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; + + aliases.add("claim"); } @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - me.attemptClaim(true); + fme.attemptClaim(true); } } diff --git a/src/com/massivecraft/factions/commands/FCommandConfig.java b/src/com/massivecraft/factions/commands/FCommandConfig.java index 5b4574d3..8d5514ae 100644 --- a/src/com/massivecraft/factions/commands/FCommandConfig.java +++ b/src/com/massivecraft/factions/commands/FCommandConfig.java @@ -14,122 +14,148 @@ import org.bukkit.entity.Player; import com.massivecraft.factions.Conf; import com.massivecraft.factions.P; import com.massivecraft.factions.integration.SpoutFeatures; +import com.massivecraft.factions.struct.Permission; -public class FCommandConfig extends FCommand { - +public class FCommandConfig extends FCommand +{ private static HashMap properFieldNames = new HashMap(); - public FCommandConfig() { - aliases.add("config"); - + public FCommandConfig() + { + super(); + this.aliases.add("config"); + + this.requiredArgs.add("setting"); + this.requiredArgs.add("value"); + this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); + + this.permission = Permission.COMMAND_CONFIG.node; + senderMustBePlayer = false; - - requiredParameters.add("setting"); - requiredParameters.add("value"); - - helpDescription = "change a conf.json setting"; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public boolean hasPermission(CommandSender sender) { - return P.hasPermConfigure(sender); - } - - @Override - public void perform() { - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } // store a lookup map of lowercase field names paired with proper capitalization field names // that way, if the person using this command messes up the capitalization, we can fix that - if (properFieldNames.isEmpty()) { + if (properFieldNames.isEmpty()) + { Field[] fields = Conf.class.getDeclaredFields(); - for(int i = 0; i < fields.length; i++) { + for(int i = 0; i < fields.length; i++) + { properFieldNames.put(fields[i].getName().toLowerCase(), fields[i].getName()); } } - String field = parameters.get(0).toLowerCase(); - if (field.startsWith("\"") && field.endsWith("\"")) { + String field = this.argAsString(0).toLowerCase(); + if (field.startsWith("\"") && field.endsWith("\"")) + { field = field.substring(1, field.length() - 1); } String fieldName = properFieldNames.get(field); - if (fieldName == null || fieldName.isEmpty()) { - sendMessage("No configuration setting \""+parameters.get(0)+"\" exists."); + if (fieldName == null || fieldName.isEmpty()) + { + sendMessageParsed("No configuration setting \"%s\" exists.", field); return; } String success = ""; - String value = parameters.get(1); - for(int i = 2; i < parameters.size(); i++) { - value += ' ' + parameters.get(i); + String value = args.get(1); + for(int i = 2; i < args.size(); i++) + { + value += ' ' + args.get(i); } - try { + try + { Field target = Conf.class.getField(fieldName); // boolean - if (target.getType() == boolean.class) { - if (aliasTrue.contains(value.toLowerCase())) { + if (target.getType() == boolean.class) + { + if (aliasTrue.contains(value.toLowerCase())) + { target.setBoolean(null, true); success = "\""+fieldName+"\" option set to true (enabled)."; } - else if (aliasFalse.contains(value.toLowerCase())) { + else if (aliasFalse.contains(value.toLowerCase())) + { target.setBoolean(null, false); success = "\""+fieldName+"\" option set to false (disabled)."; } - else { + else + { sendMessage("Cannot set \""+fieldName+"\": boolean value required (true or false)."); return; } } // int - else if (target.getType() == int.class) { - try { + else if (target.getType() == int.class) + { + try + { int intVal = Integer.parseInt(value); target.setInt(null, intVal); success = "\""+fieldName+"\" option set to "+intVal+"."; } - catch(NumberFormatException ex) { + catch(NumberFormatException ex) + { sendMessage("Cannot set \""+fieldName+"\": integer (whole number) value required."); return; } } // double - else if (target.getType() == double.class) { - try { + else if (target.getType() == double.class) + { + try + { double doubleVal = Double.parseDouble(value); target.setDouble(null, doubleVal); success = "\""+fieldName+"\" option set to "+doubleVal+"."; } - catch(NumberFormatException ex) { + catch(NumberFormatException ex) + { sendMessage("Cannot set \""+fieldName+"\": double (numeric) value required."); return; } } // String - else if (target.getType() == String.class) { + else if (target.getType() == String.class) + { target.set(null, value); success = "\""+fieldName+"\" option set to \""+value+"\"."; } // ChatColor - else if (target.getType() == ChatColor.class) { + else if (target.getType() == ChatColor.class) + { ChatColor newColor = null; - try { + try + { newColor = ChatColor.valueOf(value.toUpperCase()); } - catch (IllegalArgumentException ex) { + catch (IllegalArgumentException ex) + { + } - if (newColor == null) { + if (newColor == null) + { sendMessage("Cannot set \""+fieldName+"\": \""+value.toUpperCase()+"\" is not a valid color."); return; } @@ -138,25 +164,32 @@ public class FCommandConfig extends FCommand { } // Set or other parameterized collection - else if (target.getGenericType() instanceof ParameterizedType) { + else if (target.getGenericType() instanceof ParameterizedType) + { ParameterizedType targSet = (ParameterizedType)target.getGenericType(); Type innerType = targSet.getActualTypeArguments()[0]; // not a Set, somehow, and that should be the only collection we're using in Conf.java - if (targSet.getRawType() != Set.class) { + if (targSet.getRawType() != Set.class) + { sendMessage("\""+fieldName+"\" is not a data collection type which can be modified with this command."); return; } // Set - else if (innerType == Material.class) { + else if (innerType == Material.class) + { Material newMat = null; - try { + try + { newMat = Material.valueOf(value.toUpperCase()); } - catch (IllegalArgumentException ex) { + catch (IllegalArgumentException ex) + { + } - if (newMat == null) { + if (newMat == null) + { sendMessage("Cannot change \""+fieldName+"\" set: \""+value.toUpperCase()+"\" is not a valid material."); return; } @@ -165,13 +198,15 @@ public class FCommandConfig extends FCommand { Set matSet = (Set)target.get(null); // Material already present, so remove it - if (matSet.contains(newMat)) { + if (matSet.contains(newMat)) + { matSet.remove(newMat); target.set(null, matSet); success = "\""+fieldName+"\" set: Material \""+value.toUpperCase()+"\" removed."; } // Material not present yet, add it - else { + else + { matSet.add(newMat); target.set(null, matSet); success = "\""+fieldName+"\" set: Material \""+value.toUpperCase()+"\" added."; @@ -179,18 +214,21 @@ public class FCommandConfig extends FCommand { } // Set - else if (innerType == String.class) { + else if (innerType == String.class) + { @SuppressWarnings("unchecked") Set stringSet = (Set)target.get(null); // String already present, so remove it - if (stringSet.contains(value)) { + if (stringSet.contains(value)) + { stringSet.remove(value); target.set(null, stringSet); success = "\""+fieldName+"\" set: \""+value+"\" removed."; } // String not present yet, add it - else { + else + { stringSet.add(value); target.set(null, stringSet); success = "\""+fieldName+"\" set: \""+value+"\" added."; @@ -198,31 +236,37 @@ public class FCommandConfig extends FCommand { } // Set of unknown type - else { + else + { sendMessage("\""+fieldName+"\" is not a data type set which can be modified with this command."); return; } } // unknown type - else { + else + { sendMessage("\""+fieldName+"\" is not a data type which can be modified with this command."); return; } } - catch (NoSuchFieldException ex) { + catch (NoSuchFieldException ex) + { sendMessage("Configuration setting \""+fieldName+"\" couldn't be matched, though it should be... please report this error."); return; } - catch (IllegalAccessException ex) { + catch (IllegalAccessException ex) + { sendMessage("Error setting configuration setting \""+fieldName+"\" to \""+value+"\"."); return; } - if (!success.isEmpty()) { + if (!success.isEmpty()) + { sendMessage(success); - if (sender instanceof Player) { - P.log(success + " Command was run by "+me.getName()+"."); + if (sender instanceof Player) + { + P.p.log(success + " Command was run by "+fme.getName()+"."); } } // save change to disk diff --git a/src/com/massivecraft/factions/commands/FCommandCreate.java b/src/com/massivecraft/factions/commands/FCommandCreate.java index d2dd72ef..c0b844f7 100644 --- a/src/com/massivecraft/factions/commands/FCommandCreate.java +++ b/src/com/massivecraft/factions/commands/FCommandCreate.java @@ -2,68 +2,77 @@ package com.massivecraft.factions.commands; import java.util.ArrayList; -import org.bukkit.command.CommandSender; - import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.P; +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; -public class FCommandCreate extends FCommand { - - public FCommandCreate() { - aliases.add("create"); +public class FCommandCreate extends FCommand +{ + public FCommandCreate() + { + super(); + this.aliases.add("create"); - requiredParameters.add("faction tag"); - - helpDescription = "Create a new faction"; + this.requiredArgs.add("faction tag"); + //this.optionalArgs.put("", ""); + + this.permission = Permission.CREATE.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public boolean hasPermission(CommandSender sender) { - return P.hasPermCreate(sender); - } - - @Override - public void perform() { - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - String tag = parameters.get(0); + String tag = this.argAsString(0); - if (me.hasFaction()) { + if (fme.hasFaction()) + { sendMessage("You must leave your current faction first."); return; } - if (Faction.isTagTaken(tag)) { + if (Factions.i.isTagTaken(tag)) + { sendMessage("That tag is already in use."); return; } - ArrayList tagValidationErrors = Faction.validateTag(tag); - if (tagValidationErrors.size() > 0) { + ArrayList tagValidationErrors = Factions.validateTag(tag); + if (tagValidationErrors.size() > 0) + { sendMessage(tagValidationErrors); return; } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostCreate)) { + if (!payForCommand(Conf.econCostCreate)) + { return; } - Faction faction = Faction.create(); + Faction faction = Factions.i.create(); faction.setTag(tag); - me.setRole(Role.ADMIN); - me.setFaction(faction); + fme.setRole(Role.ADMIN); + fme.setFaction(faction); - for (FPlayer follower : FPlayer.getAllOnline()) { - follower.sendMessage(me.getNameAndRelevant(follower)+Conf.colorSystem+" created a new faction "+faction.getTag(follower)); + for (FPlayer follower : FPlayers.i.getOnline()) + { + follower.sendMessageParsed("%s created a new faction %s", fme.getNameAndRelevant(follower), faction.getTag(follower)); } sendMessage("You should now: " + new FCommandDescription().getUseageTemplate()); diff --git a/src/com/massivecraft/factions/commands/FCommandDeinvite.java b/src/com/massivecraft/factions/commands/FCommandDeinvite.java index 065ff54d..1905a6ef 100644 --- a/src/com/massivecraft/factions/commands/FCommandDeinvite.java +++ b/src/com/massivecraft/factions/commands/FCommandDeinvite.java @@ -1,55 +1,54 @@ package com.massivecraft.factions.commands; -import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Permission; -public class FCommandDeinvite extends FCommand { +public class FCommandDeinvite extends FCommand +{ - public FCommandDeinvite() { - aliases.add("deinvite"); - aliases.add("deinv"); + public FCommandDeinvite() + { + super(); + this.aliases.add("deinvite"); + this.aliases.add("deinv"); - requiredParameters.add("player name"); + this.requiredArgs.add("player name"); + //this.optionalArgs.put("", ""); - helpDescription = "Remove a pending invitation"; + this.permission = Permission.COMMAND_DEINVITE.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; } @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - String playerName = parameters.get(0); + FPlayer you = this.argAsBestFPlayerMatch(0); + if (you == null) return; - FPlayer you = findFPlayer(playerName, false); - if (you == null) { - return; - } + Faction myFaction = fme.getFaction(); - Faction myFaction = me.getFaction(); - - if ( ! assertMinRole(Role.MODERATOR)) { - return; - } - - if (you.getFaction() == myFaction) { - sendMessage(you.getName()+" is already a member of "+myFaction.getTag()); - sendMessage("You might want to: " + new FCommandKick().getUseageTemplate(false)); + if (you.getFaction() == myFaction) + { + sendMessageParsed("%s is already a member of %s", you.getName(), myFaction.getTag()); + sendMessageParsed("You might want to: %s", new FCommandKick().getUseageTemplate(false)); return; } myFaction.deinvite(you); - you.sendMessage(me.getNameAndRelevant(you)+Conf.colorSystem+" revoked your invitation to "+myFaction.getTag(you)); - myFaction.sendMessage(me.getNameAndRelevant(me)+Conf.colorSystem+" revoked "+you.getNameAndRelevant(me)+"'s"+Conf.colorSystem+" invitation."); + you.sendMessageParsed("%s revoked your invitation to %s", fme.getNameAndRelevant(you), myFaction.getTag(you)); + myFaction.sendMessageParsed("%s revoked %s's invitation.", fme.getNameAndRelevant(fme), you.getNameAndRelevant(fme)); } } diff --git a/src/com/massivecraft/factions/commands/FCommandDeposit.java b/src/com/massivecraft/factions/commands/FCommandDeposit.java index 4e1a45a3..67f2615a 100644 --- a/src/com/massivecraft/factions/commands/FCommandDeposit.java +++ b/src/com/massivecraft/factions/commands/FCommandDeposit.java @@ -2,58 +2,61 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; import com.massivecraft.factions.P; import com.massivecraft.factions.FPlayer; -public class FCommandDeposit extends FCommand { +public class FCommandDeposit extends FCommand +{ - public FCommandDeposit() { - aliases.add("deposit"); + public FCommandDeposit() + { + super(); + this.aliases.add("deposit"); - helpDescription = "Deposit money into your faction's bank"; - requiredParameters.add("amount"); + this.requiredArgs.add("amount"); + //this.optionalArgs + + this.permission = Permission.COMMAND_DEPOSIT.node; + + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } + public void perform() + { + if ( ! Conf.bankEnabled) return; - if (!Conf.bankEnabled) { - return; - } + Faction faction = fme.getFaction(); - double amount = 0.0; - - Faction faction = me.getFaction(); - - if (parameters.size() == 1) { - try { - amount = Double.parseDouble(parameters.get(0)); - } catch (NumberFormatException e) { - // wasn't valid - } - } - - if( amount > 0.0 ) { + double amount = this.argAsDouble(0, 0); + + if( amount > 0.0 ) + { String amountString = Econ.moneyString(amount); - if( !Econ.deductMoney(me.getName(), amount ) ) { - sendMessage("You cannot afford to deposit that much."); + if( ! Econ.deductMoney(fme.getName(), amount ) ) + { + sendMessageParsed("You cannot afford to deposit that much."); } else { faction.addMoney(amount); sendMessage("You have deposited "+amountString+" into "+faction.getTag()+"'s bank."); sendMessage(faction.getTag()+" now has "+Econ.moneyString(faction.getMoney())); - P.log(me.getName() + " deposited "+amountString+" into "+faction.getTag()+"'s bank."); + P.p.log(fme.getName() + " deposited "+amountString+" into "+faction.getTag()+"'s bank."); - for (FPlayer fplayer : FPlayer.getAllOnline()) { - if (fplayer.getFaction() == faction) { - fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has deposited "+amountString); + for (FPlayer fplayer : FPlayers.i.getOnline()) + { + if (fplayer.getFaction() == faction) + { + fplayer.sendMessageParsed("%s has deposited %s", fme.getNameAndRelevant(fplayer), amountString); } } } diff --git a/src/com/massivecraft/factions/commands/FCommandDescription.java b/src/com/massivecraft/factions/commands/FCommandDescription.java index 4a85e3bf..122fb700 100644 --- a/src/com/massivecraft/factions/commands/FCommandDescription.java +++ b/src/com/massivecraft/factions/commands/FCommandDescription.java @@ -2,45 +2,50 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.struct.Role; -import com.massivecraft.factions.util.TextUtil; +import com.massivecraft.factions.FPlayers; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.zcore.util.TextUtil; -public class FCommandDescription extends FCommand { - - public FCommandDescription() { - aliases.add("desc"); +public class FCommandDescription extends FCommand +{ + public FCommandDescription() + { + super(); + this.aliases.add("desc"); - requiredParameters.add("desc"); + this.requiredArgs.add("desc"); + //this.optionalArgs - helpDescription = "Change the faction description"; + this.permission = Permission.COMMAND_DESCRIPTION.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; } @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - - if ( ! assertMinRole(Role.MODERATOR)) { - return; - } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostDesc)) { + if ( ! payForCommand(Conf.econCostDesc)) + { return; } - me.getFaction().setDescription(TextUtil.implode(parameters)); + fme.getFaction().setDescription(TextUtil.implode(args, " ")); // Broadcast the description to everyone - for (FPlayer fplayer : FPlayer.getAllOnline()) { - fplayer.sendMessage("The faction "+fplayer.getRelationColor(me)+me.getFaction().getTag()+Conf.colorSystem+" changed their description to:"); - fplayer.sendMessage(me.getFaction().getDescription()); + for (FPlayer fplayer : FPlayers.i.getOnline()) + { + fplayer.sendMessageParsed("The faction "+fplayer.getRelationColor(fme)+fme.getFaction().getTag()+" changed their description to:"); + fplayer.sendMessageParsed(""+fme.getFaction().getDescription()); } } diff --git a/src/com/massivecraft/factions/commands/FCommandDisband.java b/src/com/massivecraft/factions/commands/FCommandDisband.java index c5b75dcd..63e889ab 100644 --- a/src/com/massivecraft/factions/commands/FCommandDisband.java +++ b/src/com/massivecraft/factions/commands/FCommandDisband.java @@ -2,85 +2,88 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; import com.massivecraft.factions.P; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.integration.SpoutFeatures; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; -public class FCommandDisband extends FCommand { - - public FCommandDisband() { - aliases.add("disband"); +public class FCommandDisband extends FCommand +{ + public FCommandDisband() + { + super(); + this.aliases.add("disband"); + + //this.requiredArgs.add(""); + this.optionalArgs.put("faction tag", "yours"); + + this.permission = Permission.COMMAND_DISBAND.node; senderMustBePlayer = false; - - optionalParameters.add("faction tag"); - - helpDescription = "Disband a faction"; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public void perform() { - - Faction faction = null; - - if( parameters.size() > 0) { - faction = Faction.findByTag(parameters.get(0)); - - if( faction == null || !faction.isNormal()) { - sendMessage("Faction \"" + parameters.get(0) + "\" not found"); + public void perform() + { + // The faction, default to your own.. but null if console sender. + Faction faction = this.argAsFaction(0, fme == null ? null : fme.getFaction()); + if (faction == null) return; + + boolean isMyFaction = fme == null ? false : faction == fme.getFaction(); + + if (isMyFaction) + { + if ( ! assertMinRole(Role.ADMIN)) return; + } + else + { + if ( ! Permission.COMMAND_DISBAND_ANY.has(me, true)) + { return; } - - if ( ! P.hasPermDisband(sender)) { - if (me.getFaction() == faction) { - parameters.clear(); - } - else { - sendMessage("You do not have sufficient permission to disband other factions."); - return; - } - } } - if (parameters.isEmpty()) { - if ( ! assertHasFaction()) { - return; - } - if ( ! assertMinRole(Role.ADMIN)) { - return; - } - faction = me.getFaction(); - - if (faction.isPermanent() && !P.hasPermDisband(sender)) { - sendMessage("Your faction is designated as permanent, so you cannot disband it."); - return; - } + if (faction.isPermanent()) + { + sendMessageParsed("This faction is designated as permanent, so you cannot disband it."); + return; } // Inform all players - for (FPlayer fplayer : FPlayer.getAllOnline()) { - if (fplayer.getFaction() == faction) { - fplayer.sendMessage((senderIsConsole ? "A server admin" : me.getNameAndRelevant(fplayer))+Conf.colorSystem+" disbanded your faction."); - } else { - fplayer.sendMessage((senderIsConsole ? "A server admin" : me.getNameAndRelevant(fplayer))+Conf.colorSystem+" disbanded the faction "+faction.getTag(fplayer)+"."); + for (FPlayer fplayer : FPlayers.i.getOnline()) + { + String who = senderIsConsole ? "A server admin" : fme.getNameAndRelevant(fplayer); + if (fplayer.getFaction() == faction) + { + fplayer.sendMessageParsed("%s disbanded your faction.", who); + } + else + { + fplayer.sendMessageParsed("%s disbanded the faction %s.", who, faction.getTag(fplayer)); } } - if (Conf.bankEnabled) { + if (Conf.bankEnabled) + { double amount = faction.getMoney(); - Econ.addMoney(me.getName(), amount ); //Give all the faction's money to the disbander - if (amount > 0.0) { + Econ.addMoney(fme.getId(), amount); //Give all the faction's money to the disbander + if (amount > 0.0) + { String amountString = Econ.moneyString(amount); - sendMessage("You have been given the disbanded faction's bank, totaling "+amountString+"."); - P.log(me.getName() + " has been given bank holdings of "+amountString+" from disbanding "+faction.getTag()+"."); + sendMessageParsed("You have been given the disbanded faction's bank, totaling %s.", amountString); + P.p.log(fme.getName() + " has been given bank holdings of "+amountString+" from disbanding "+faction.getTag()+"."); } } - Faction.delete( faction.getId() ); + faction.detach(); + SpoutFeatures.updateAppearances(); - } } diff --git a/src/com/massivecraft/factions/commands/FCommandHelp.java b/src/com/massivecraft/factions/commands/FCommandHelp.java index 43adbbc1..a10c6e28 100644 --- a/src/com/massivecraft/factions/commands/FCommandHelp.java +++ b/src/com/massivecraft/factions/commands/FCommandHelp.java @@ -2,44 +2,45 @@ package com.massivecraft.factions.commands; import java.util.ArrayList; -import org.bukkit.command.CommandSender; - import com.massivecraft.factions.Conf; +import com.massivecraft.factions.P; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.util.TextUtil; +import com.massivecraft.factions.struct.Permission; -public class FCommandHelp extends FCommand { +public class FCommandHelp extends FCommand +{ - public FCommandHelp() { - aliases.add("help"); - aliases.add("h"); - aliases.add("?"); + public FCommandHelp() + { + super(); + this.aliases.add("help"); + this.aliases.add("h"); + this.aliases.add("?"); - optionalParameters.add("page"); + //this.requiredArgs.add(""); + this.optionalArgs.put("page", "1"); - helpDescription = "Display a help page"; - } + this.permission = Permission.COMMAND_HELP.node; + + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } @Override - public boolean hasPermission(CommandSender sender) { - return true; - } - - @Override - public void perform() { - int page = 1; - if (parameters.size() > 0) { - try { - page = Integer.parseInt(parameters.get(0)); - } catch (NumberFormatException e) { - // wasn't an integer - } - } - sendMessage(TextUtil.titleize("Factions Help ("+page+"/"+helpPages.size()+")")); + public void perform() + { + int page = this.argAsInt(0, 1); + + sendMessage(p.txt.titleize("Factions Help ("+page+"/"+helpPages.size()+")")); + page -= 1; - if (page < 0 || page >= helpPages.size()) { - sendMessage("This page does not exist"); + + if (page < 0 || page >= helpPages.size()) + { + sendMessageParsed("This page does not exist"); return; } sendMessage(helpPages.get(page)); @@ -51,7 +52,8 @@ public class FCommandHelp extends FCommand { public static ArrayList> helpPages; - public static void updateHelp() { + public static void updateHelp() + { helpPages = new ArrayList>(); ArrayList pageLines; @@ -79,7 +81,8 @@ public class FCommandHelp extends FCommand { pageLines.add( new FCommandSethome().getUseageTemplate() ); helpPages.add(pageLines); - if (Econ.enabled() && Conf.bankEnabled) { + if (Econ.enabled() && Conf.bankEnabled) + { pageLines = new ArrayList(); pageLines.add( "" ); pageLines.add( "Your faction has a bank which is used to pay for certain" ); @@ -162,7 +165,7 @@ public class FCommandHelp extends FCommand { pageLines.add( new FCommandWarclaim().getUseageTemplate() ); pageLines.add( new FCommandAutoWarclaim().getUseageTemplate() ); pageLines.add( new FCommandWarunclaimall().getUseageTemplate() ); - pageLines.add("Note: " + Conf.colorCommand + "f unclaim" + Conf.colorSystem + " works on safe/war zones as well."); + pageLines.add("Note: " + new FCommandUnclaim().getUseageTemplate(false) + P.p.txt.parse("") + " works on safe/war zones as well."); helpPages.add(pageLines); pageLines = new ArrayList(); @@ -178,7 +181,8 @@ public class FCommandHelp extends FCommand { helpPages.add(pageLines); } - static { + static + { updateHelp(); } } diff --git a/src/com/massivecraft/factions/commands/FCommandHome.java b/src/com/massivecraft/factions/commands/FCommandHome.java index e462921b..e712ae2d 100644 --- a/src/com/massivecraft/factions/commands/FCommandHome.java +++ b/src/com/massivecraft/factions/commands/FCommandHome.java @@ -8,60 +8,88 @@ import com.massivecraft.factions.Board; import com.massivecraft.factions.Conf; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; -public class FCommandHome extends FCommand { +public class FCommandHome extends FCommand +{ - public FCommandHome() { - aliases.add("home"); + public FCommandHome() + { + super(); + this.aliases.add("home"); - helpDescription = "Teleport to the faction home"; + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); + + this.permission = Permission.COMMAND_HOME.node; + + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } - - if ( ! Conf.homesEnabled) { - me.sendMessage("Sorry, Faction homes are disabled on this server."); + public void perform() + { + // TODO: Hide this command on help also. + if ( ! Conf.homesEnabled) + { + fme.sendMessage("Sorry, Faction homes are disabled on this server."); return; } - if ( ! Conf.homesTeleportCommandEnabled) { - me.sendMessage("Sorry, the ability to teleport to Faction homes is disabled on this server."); + if ( ! Conf.homesTeleportCommandEnabled) + { + fme.sendMessage("Sorry, the ability to teleport to Faction homes is disabled on this server."); return; } - Faction myFaction = me.getFaction(); + Faction myFaction = fme.getFaction(); - if ( ! myFaction.hasHome()) { - me.sendMessage("You faction does not have a home. " + (me.getRole().value < Role.MODERATOR.value ? " Ask your leader to:" : "You should:")); - me.sendMessage(new FCommandSethome().getUseageTemplate()); + if ( ! myFaction.hasHome()) + { + fme.sendMessage("You faction does not have a home. " + (fme.getRole().value < Role.MODERATOR.value ? " Ask your leader to:" : "You should:")); + fme.sendMessage(new FCommandSethome().getUseageTemplate()); return; } - if (!Conf.homesTeleportAllowedFromEnemyTerritory && me.isInEnemyTerritory()) { - me.sendMessage("You cannot teleport to your faction home while in the territory of an enemy faction."); + if ( ! Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) + { + fme.sendMessage("You cannot teleport to your faction home while in the territory of an enemy faction."); return; } - if (!Conf.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID()) { - me.sendMessage("You cannot teleport to your faction home while in a different world."); + if ( ! Conf.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID()) + { + fme.sendMessage("You cannot teleport to your faction home while in a different world."); return; } Faction faction = Board.getFactionAt(new FLocation(me.getLocation())); // if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby - if ( - Conf.homesTeleportAllowedEnemyDistance > 0 - && !faction.isSafeZone() - && (!me.isInOwnTerritory() || (me.isInOwnTerritory() && !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) - ) { + if + ( + Conf.homesTeleportAllowedEnemyDistance > 0 + && + ! faction.isSafeZone() + && + ( + ! fme.isInOwnTerritory() + || + ( + fme.isInOwnTerritory() + && + ! Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory + ) + ) + ) + { Location loc = me.getLocation(); World w = loc.getWorld(); double x = loc.getX(); @@ -70,11 +98,11 @@ public class FCommandHome extends FCommand { for (Player p : me.getServer().getOnlinePlayers()) { - if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) + if (p == null || !p.isOnline() || p.isDead() || p == fme || p.getWorld() != w) continue; - FPlayer fp = FPlayer.get(p); - if (me.getRelation(fp) != Relation.ENEMY) + FPlayer fp = FPlayers.i.get(p); + if (fme.getRelation(fp) != Relation.ENEMY) continue; Location l = p.getLocation(); @@ -87,13 +115,14 @@ public class FCommandHome extends FCommand { if (dx > max || dy > max || dz > max) continue; - me.sendMessage("You cannot teleport to your faction home while an enemy is within " + Conf.homesTeleportAllowedEnemyDistance + " blocks of you."); + fme.sendMessage("You cannot teleport to your faction home while an enemy is within " + Conf.homesTeleportAllowedEnemyDistance + " blocks of you."); return; } } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostHome)) { + if ( ! payForCommand(Conf.econCostHome)) + { return; } diff --git a/src/com/massivecraft/factions/commands/FCommandInvite.java b/src/com/massivecraft/factions/commands/FCommandInvite.java index ccb9ce0f..4030479c 100644 --- a/src/com/massivecraft/factions/commands/FCommandInvite.java +++ b/src/com/massivecraft/factions/commands/FCommandInvite.java @@ -3,58 +3,58 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Permission; -public class FCommandInvite extends FCommand { - - public FCommandInvite() { - aliases.add("invite"); - aliases.add("inv"); +public class FCommandInvite extends FCommand +{ + public FCommandInvite() + { + super(); + this.aliases.add("invite"); + this.aliases.add("inv"); - requiredParameters.add("player name"); + this.requiredArgs.add("player name"); + //this.optionalArgs.put("", ""); - helpDescription = "Invite a player"; + this.permission = Permission.COMMAND_INVITE.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; } @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - if ( ! assertMinRole(Role.MODERATOR)) { - return; - } + FPlayer you = this.argAsBestFPlayerMatch(0); + if (you == null) return; - String playerName = parameters.get(0); + Faction myFaction = fme.getFaction(); - FPlayer you = findFPlayer(playerName, false); - if (you == null) { - return; - } - - Faction myFaction = me.getFaction(); - - if (you.getFaction() == myFaction) { - sendMessage(you.getName()+" is already a member of "+myFaction.getTag()); - sendMessage("You might want to: " + new FCommandKick().getUseageTemplate(false)); + if (you.getFaction() == myFaction) + { + sendMessageParsed("%s is already a member of %s", you.getName(), myFaction.getTag()); + sendMessageParsed("You might want to: " + new FCommandKick().getUseageTemplate(false)); return; } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostInvite)) { + if ( ! payForCommand(Conf.econCostInvite)) + { return; } myFaction.invite(you); - you.sendMessage(me.getNameAndRelevant(you)+Conf.colorSystem+" invited you to "+myFaction.getTag(you)); - myFaction.sendMessage(me.getNameAndRelevant(me)+Conf.colorSystem+" invited "+you.getNameAndRelevant(me)+Conf.colorSystem+" to your faction."); + you.sendMessageParsed("%s invited you to %s", fme.getNameAndRelevant(you), myFaction.getTag(you)); + myFaction.sendMessageParsed("%s invited %s to your faction.", fme.getNameAndRelevant(fme), you.getNameAndRelevant(fme)); } } diff --git a/src/com/massivecraft/factions/commands/FCommandJoin.java b/src/com/massivecraft/factions/commands/FCommandJoin.java index 4591486b..7a4c00d6 100644 --- a/src/com/massivecraft/factions/commands/FCommandJoin.java +++ b/src/com/massivecraft/factions/commands/FCommandJoin.java @@ -2,69 +2,80 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.Faction; +import com.massivecraft.factions.struct.Permission; -public class FCommandJoin extends FCommand { - - public FCommandJoin() { - aliases.add("join"); +public class FCommandJoin extends FCommand +{ + public FCommandJoin() + { + super(); + this.aliases.add("join"); - requiredParameters.add("faction name"); + this.requiredArgs.add("faction name"); + //this.optionalArgs.put("", ""); - helpDescription = "Join a faction"; + this.permission = Permission.COMMAND_JOIN.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public void perform() { - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - String factionName = parameters.get(0); - - Faction faction = findFaction(factionName); - if (faction == null) { - return; - } + Faction faction = this.argAsFaction(0); + if (faction == null) return; - if ( ! faction.isNormal()) { - sendMessage("You may only join normal factions. This is a system faction."); + if ( ! faction.isNormal()) + { + sendMessageParsed("You may only join normal factions. This is a system faction."); return; } - if (faction == me.getFaction()) { - sendMessage("You are already a member of "+faction.getTag(me)); + if (faction == fme.getFaction()) + { + sendMessageParsed("You are already a member of %s", faction.getTag(fme)); return; } - if (me.hasFaction()) { - sendMessage("You must leave your current faction first."); + if (fme.hasFaction()) + { + sendMessageParsed("You must leave your current faction first."); return; } - if (!Conf.CanLeaveWithNegativePower && me.getPower() < 0) { - sendMessage("You cannot join a faction until your power is positive."); + if (!Conf.CanLeaveWithNegativePower && fme.getPower() < 0) + { + sendMessageParsed("You cannot join a faction until your power is positive."); return; } - if( ! faction.getOpen() && ! faction.isInvited(me)) { - sendMessage("This guild requires invitation."); - faction.sendMessage(me.getNameAndRelevant(faction)+Conf.colorSystem+" tried to join your faction."); + if( ! faction.getOpen() && ! faction.isInvited(fme)) + { + sendMessageParsed("This guild requires invitation."); + faction.sendMessageParsed("%s tried to join your faction.", fme.getNameAndRelevant(faction)); return; } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostJoin)) { + if (!payForCommand(Conf.econCostJoin)) + { return; } - me.sendMessage(Conf.colorSystem+"You successfully joined "+faction.getTag(me)); - faction.sendMessage(me.getNameAndRelevant(faction)+Conf.colorSystem+" joined your faction."); + fme.sendMessageParsed("You successfully joined %s", faction.getTag(fme)); + faction.sendMessageParsed("%s joined your faction.", fme.getNameAndRelevant(faction)); - me.resetFactionData(); - me.setFaction(faction); - faction.deinvite(me); + fme.resetFactionData(); + fme.setFaction(faction); + faction.deinvite(fme); } - } diff --git a/src/com/massivecraft/factions/commands/FCommandKick.java b/src/com/massivecraft/factions/commands/FCommandKick.java index f4342f02..1a20ab4e 100644 --- a/src/com/massivecraft/factions/commands/FCommandKick.java +++ b/src/com/massivecraft/factions/commands/FCommandKick.java @@ -2,81 +2,98 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.P; +import com.massivecraft.factions.struct.Permission; -public class FCommandKick extends FCommand { +public class FCommandKick extends FCommand +{ - public FCommandKick() { - aliases.add("kick"); + public FCommandKick() + { + super(); + this.aliases.add("kick"); - requiredParameters.add("player name"); + this.requiredArgs.add("player name"); + //this.optionalArgs.put("", ""); - helpDescription = "Kick a player from the faction"; + this.permission = Permission.COMMAND_KICK.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; } @Override - public void perform() { - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - String playerName = parameters.get(0); + FPlayer you = this.argAsBestFPlayerMatch(0); + if (you == null) return; - FPlayer you = findFPlayer(playerName, false); - if (you == null) { - return; - } - - if (me == you) { - sendMessage("You cannot kick yourself."); - sendMessage("You might want to: " + new FCommandLeave().getUseageTemplate(false)); + if (fme == you) + { + sendMessageParsed("You cannot kick yourself."); + sendMessageParsed("You might want to: %s", new FCommandLeave().getUseageTemplate(false)); return; } Faction yourFaction = you.getFaction(); - Faction myFaction = me.getFaction(); + Faction myFaction = fme.getFaction(); // players with admin-level "disband" permission can bypass these requirements - if (!P.hasPermDisband(sender)) { - if (yourFaction != myFaction) { - sendMessage(you.getNameAndRelevant(me)+Conf.colorSystem+" is not a member of "+myFaction.getTag(me)); + if ( ! Permission.COMMAND_KICK_ANY.has(sender)) + { + if (yourFaction != myFaction) + { + sendMessageParsed("%s is not a member of %s", you.getNameAndRelevant(fme), myFaction.getTag(fme)); return; } - if (you.getRole().value >= me.getRole().value) { // TODO add more informative messages. - sendMessage("Your rank is too low to kick this player."); + if (you.getRole().value >= fme.getRole().value) + { + // TODO add more informative messages. + sendMessageParsed("Your rank is too low to kick this player."); return; } - if (!Conf.CanLeaveWithNegativePower && you.getPower() < 0) { - sendMessage("You cannot kick that member until their power is positive."); + if ( ! Conf.CanLeaveWithNegativePower && you.getPower() < 0) + { + sendMessageParsed("You cannot kick that member until their power is positive."); return; } } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostKick)) { + if ( ! payForCommand(Conf.econCostKick)) + { return; } - yourFaction.sendMessage(me.getNameAndRelevant(yourFaction)+Conf.colorSystem+" kicked "+you.getNameAndRelevant(yourFaction)+Conf.colorSystem+" from the faction! :O"); - you.sendMessage(me.getNameAndRelevant(you)+Conf.colorSystem+" kicked you from "+yourFaction.getTag(you)+Conf.colorSystem+"! :O"); - if (yourFaction != myFaction) { - me.sendMessage(Conf.colorSystem+"You kicked "+you.getNameAndRelevant(myFaction)+Conf.colorSystem+" from the faction "+yourFaction.getTag(me)+Conf.colorSystem+"!"); + yourFaction.sendMessageParsed("%s kicked %s from the faction! :O", fme.getNameAndRelevant(yourFaction), you.getNameAndRelevant(yourFaction)); + you.sendMessageParsed("%s kicked you from %s! :O", fme.getNameAndRelevant(you), yourFaction.getTag(you)); + if (yourFaction != myFaction) + { + fme.sendMessageParsed("You kicked %s from the faction %s!", you.getNameAndRelevant(myFaction), yourFaction.getTag(fme)); } yourFaction.deinvite(you); you.resetFactionData(); - if (yourFaction.getFPlayers().isEmpty() && !yourFaction.isPermanent()) { + if (yourFaction.getFPlayers().isEmpty() && !yourFaction.isPermanent()) + { // Remove this faction - for (FPlayer fplayer : FPlayer.getAllOnline()) { - fplayer.sendMessage("The faction "+yourFaction.getTag(fplayer)+Conf.colorSystem+" was disbanded."); + for (FPlayer fplayer : FPlayers.i.getOnline()) + { + fplayer.sendMessageParsed("The faction %s was disbanded.", yourFaction.getTag(fplayer)); } - Faction.delete(yourFaction.getId()); + yourFaction.detach(); } } diff --git a/src/com/massivecraft/factions/commands/FCommandLeave.java b/src/com/massivecraft/factions/commands/FCommandLeave.java index 70c3c8d9..089cd49f 100644 --- a/src/com/massivecraft/factions/commands/FCommandLeave.java +++ b/src/com/massivecraft/factions/commands/FCommandLeave.java @@ -1,32 +1,35 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; +import com.massivecraft.factions.struct.Permission; public class FCommandLeave extends FCommand { - public FCommandLeave() { - aliases.add("leave"); + public FCommandLeave() + { + super(); + this.aliases.add("leave"); - helpDescription = "Leave your faction"; + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); + + this.permission = Permission.COMMAND_LEAVE.node; + + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public boolean hasPermission(CommandSender sender) { - return true; - } - - @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } - - if( isLocked() ) { + public void perform() + { + if ( isLocked() ) + { sendLockMessage(); return; } - me.leave(true); + fme.leave(true); } } diff --git a/src/com/massivecraft/factions/commands/FCommandList.java b/src/com/massivecraft/factions/commands/FCommandList.java index f2559027..8a6ddb48 100644 --- a/src/com/massivecraft/factions/commands/FCommandList.java +++ b/src/com/massivecraft/factions/commands/FCommandList.java @@ -4,55 +4,45 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import org.bukkit.command.CommandSender; - import com.massivecraft.factions.Conf; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.util.TextUtil; +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.struct.Permission; -public class FCommandList extends FCommand { +public class FCommandList extends FCommand +{ - public FCommandList() { - aliases.add("list"); - aliases.add("ls"); + public FCommandList() + { + super(); + this.aliases.add("list"); + this.aliases.add("ls"); + + //this.requiredArgs.add(""); + this.optionalArgs.put("page", "1"); + + this.permission = Permission.COMMAND_LIST.node; senderMustBePlayer = false; - - optionalParameters.add("page"); - - helpDescription = "Show a list of the factions"; - } - - @Override - public boolean hasPermission(CommandSender sender) { - return true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public void perform() { - ArrayList FactionList = new ArrayList(Faction.getAll()); - FactionList.remove(Faction.getNone()); - FactionList.remove(Faction.getSafeZone()); - FactionList.remove(Faction.getWarZone()); - + public void perform() + { // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostList)) { - return; - } - - int page = 1; - if (parameters.size() > 0) { - try { - page = Integer.parseInt(parameters.get(0)); - } catch (NumberFormatException e) { - // wasn't an integer - } - } - page -= 1; - + if ( ! payForCommand(Conf.econCostList)) return; + + ArrayList factionList = new ArrayList(Factions.i.get()); + factionList.remove(Factions.i.getNone()); + factionList.remove(Factions.i.getSafeZone()); + factionList.remove(Factions.i.getWarZone()); + // Sort by total followers first - Collections.sort(FactionList, new Comparator(){ + Collections.sort(factionList, new Comparator(){ @Override public int compare(Faction f1, Faction f2) { if (f1.getFPlayers().size() < f2.getFPlayers().size()) @@ -64,7 +54,7 @@ public class FCommandList extends FCommand { }); // Then sort by how many members are online now - Collections.sort(FactionList, new Comparator(){ + Collections.sort(factionList, new Comparator(){ @Override public int compare(Faction f1, Faction f2) { if (f1.getFPlayersWhereOnline(true).size() < f2.getFPlayersWhereOnline(true).size()) @@ -74,29 +64,22 @@ public class FCommandList extends FCommand { return 0; } }); - - FactionList.add(0, Faction.getNone()); - int maxPage = (int)Math.floor((double)FactionList.size() / 9D); - if (page < 0 || page > maxPage) { - sendMessage("The faction list is only " + (maxPage+1) + " page(s) long"); - return; - } - - String header = "Faction List"; - if (maxPage > 1) header += " (page " + (page+1) + " of " + (maxPage+1) + ")"; - sendMessage(TextUtil.titleize(header)); - - int maxPos = (page+1) * 9; - if (maxPos > FactionList.size()) maxPos = FactionList.size(); - for (int pos = page * 9; pos < maxPos; pos++) { - Faction faction = FactionList.get(pos); - if (faction.getId() == 0) { - sendMessage("Factionless"+Conf.colorSystem+" "+faction.getFPlayersWhereOnline(true).size() + " online"); - } else { - sendMessage(faction.getTag(me)+Conf.colorSystem+" "+faction.getFPlayersWhereOnline(true).size()+"/"+faction.getFPlayers().size()+" online, "+faction.getLandRounded()+"/"+faction.getPowerRounded()+"/"+faction.getPowerMaxRounded()); - } + ArrayList lines = new ArrayList(); + lines.add(p.txt.parse("Factionless %d online", Factions.i.getNone().getFPlayersWhereOnline(true).size())); + for (Faction faction : factionList) + { + lines.add(p.txt.parse("%s %d/%d online, %d/%d/%d", + faction.getTag(fme), + faction.getFPlayersWhereOnline(true).size(), + faction.getFPlayers().size(), + faction.getLandRounded(), + faction.getPowerRounded(), + faction.getPowerMaxRounded()) + ); } + + sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), "Faction List")); } } diff --git a/src/com/massivecraft/factions/commands/FCommandLock.java b/src/com/massivecraft/factions/commands/FCommandLock.java index 08676453..a4883a59 100644 --- a/src/com/massivecraft/factions/commands/FCommandLock.java +++ b/src/com/massivecraft/factions/commands/FCommandLock.java @@ -1,36 +1,44 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; - -import com.massivecraft.factions.P; +import com.massivecraft.factions.struct.Permission; public class FCommandLock extends FCommand { - public FCommandLock() { - aliases.add("lock"); + // TODO: This solution needs refactoring. + /* + factions.lock: + description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten + default: op + */ + + public FCommandLock() + { + super(); + this.aliases.add("lock"); + + //this.requiredArgs.add(""); + this.optionalArgs.put("on/off", "flipp"); + + this.permission = Permission.COMMAND_LOCK.node; senderMustBePlayer = false; - - optionalParameters.add("on|off"); - - helpDescription = "lock all write stuff"; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public boolean hasPermission(CommandSender sender) { - return P.hasPermLock(sender); - } - - @Override - public void perform() { - if( parameters.size() > 0 ) { - setLock( parseBool( parameters.get(0) )); - } else { - if( isLocked() ) { - sendMessage("Factions is locked"); - } else { - sendMessage("Factions is not locked"); - } + public void perform() + { + setIsLocked(this.argAsBool(0, ! isLocked())); + + if( isLocked() ) + { + sendMessageParsed("Factions is now locked"); + } + else + { + sendMessageParsed("Factions in now unlocked"); } } diff --git a/src/com/massivecraft/factions/commands/FCommandMap.java b/src/com/massivecraft/factions/commands/FCommandMap.java index e6a0e4d9..d9303404 100644 --- a/src/com/massivecraft/factions/commands/FCommandMap.java +++ b/src/com/massivecraft/factions/commands/FCommandMap.java @@ -1,61 +1,66 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; - import com.massivecraft.factions.Board; import com.massivecraft.factions.Conf; import com.massivecraft.factions.FLocation; +import com.massivecraft.factions.struct.Permission; -public class FCommandMap extends FCommand { - - public FCommandMap() { - aliases.add("map"); +public class FCommandMap extends FCommand +{ + public FCommandMap() + { + super(); + this.aliases.add("map"); - optionalParameters.add("on|off"); + //this.requiredArgs.add(""); + this.optionalArgs.put("on/off", "once"); - helpDescription = "Show territory map, set optional auto update"; + this.permission = Permission.COMMAND_MAP.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public boolean hasPermission(CommandSender sender) { - return true; - } - - @Override - public void perform() { - if (parameters.size() > 0) { - String mapAutoUpdating = parameters.get(0); - if (parseBool(mapAutoUpdating)) { + public void perform() + { + if (this.argIsSet(0)) + { + if (this.argAsBool(0, ! fme.isMapAutoUpdating())) + { // Turn on // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostMap)) { - return; - } + if ( ! payForCommand(Conf.econCostMap)) return; - me.setMapAutoUpdating(true); - sendMessage("Map auto update ENABLED."); + fme.setMapAutoUpdating(true); + sendMessageParsed("Map auto update ENABLED."); // And show the map once showMap(); - } else { + } + else + { // Turn off - me.setMapAutoUpdating(false); - sendMessage("Map auto update DISABLED."); + fme.setMapAutoUpdating(false); + sendMessageParsed("Map auto update DISABLED."); } - } else { + } + else + { // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostMap)) { - return; - } + if ( ! payForCommand(Conf.econCostMap)) return; showMap(); } } - public void showMap() { - sendMessage(Board.getMap(me.getFaction(), new FLocation(me), me.getPlayer().getLocation().getYaw())); + public void showMap() + { + sendMessage(Board.getMap(fme.getFaction(), new FLocation(fme), fme.getPlayer().getLocation().getYaw())); } } diff --git a/src/com/massivecraft/factions/commands/FCommandMod.java b/src/com/massivecraft/factions/commands/FCommandMod.java index 2622aa40..85cdb8a5 100644 --- a/src/com/massivecraft/factions/commands/FCommandMod.java +++ b/src/com/massivecraft/factions/commands/FCommandMod.java @@ -1,62 +1,66 @@ package com.massivecraft.factions.commands; -import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; -public class FCommandMod extends FCommand { +public class FCommandMod extends FCommand +{ - public FCommandMod() { - aliases.add("mod"); + public FCommandMod() + { + super(); + this.aliases.add("mod"); - requiredParameters.add("player name"); + this.requiredArgs.add("player name"); + //this.optionalArgs.put("", ""); - helpDescription = "Give or revoke moderator rights"; + this.permission = Permission.COMMAND_MOD.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = true; } @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - if ( ! assertMinRole(Role.ADMIN)) { + FPlayer you = this.argAsBestFPlayerMatch(0); + if (you == null) return; + + Faction myFaction = fme.getFaction(); + + if (you.getFaction() != myFaction) + { + sendMessageParsed("%s is not a member in your faction.", you.getNameAndRelevant(fme)); return; } - String playerName = parameters.get(0); - - FPlayer you = findFPlayer(playerName, false); - if (you == null) { - return; - } - - Faction myFaction = me.getFaction(); - - if (you.getFaction() != myFaction) { - sendMessage(you.getNameAndRelevant(me)+Conf.colorSystem+" is not a member in your faction."); - return; - } - - if (you == me) { - sendMessage("The target player musn't be yourself."); + if (you == fme) + { + sendMessageParsed("The target player musn't be yourself."); return; } - if (you.getRole() == Role.MODERATOR) { + if (you.getRole() == Role.MODERATOR) + { // Revoke you.setRole(Role.NORMAL); - myFaction.sendMessage(you.getNameAndRelevant(myFaction)+Conf.colorSystem+" is no longer moderator in your faction."); - } else { + myFaction.sendMessageParsed("%s is no longer moderator in your faction.", you.getNameAndRelevant(myFaction)); + } + else + { // Give you.setRole(Role.MODERATOR); - myFaction.sendMessage(you.getNameAndRelevant(myFaction)+Conf.colorSystem+" was promoted to moderator in your faction."); + myFaction.sendMessageParsed("%s was promoted to moderator in your faction.", you.getNameAndRelevant(myFaction)); } } diff --git a/src/com/massivecraft/factions/commands/FCommandNoBoom.java b/src/com/massivecraft/factions/commands/FCommandNoBoom.java index 28099534..f6655cf3 100644 --- a/src/com/massivecraft/factions/commands/FCommandNoBoom.java +++ b/src/com/massivecraft/factions/commands/FCommandNoBoom.java @@ -35,10 +35,10 @@ public class FCommandNoBoom extends FCommand { return; } - Faction myFaction = me.getFaction(); + Faction myFaction = fme.getFaction(); if (!myFaction.isPeaceful()) { - me.sendMessage("This command is only usable by factions which are specially designated as peaceful."); + fme.sendMessage("This command is only usable by factions which are specially designated as peaceful."); return; } @@ -52,7 +52,7 @@ public class FCommandNoBoom extends FCommand { String enabled = myFaction.noExplosionsInTerritory() ? "disabled" : "enabled"; // Inform - myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" has "+enabled+" explosions in your faction's territory."); + myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" has "+enabled+" explosions in your faction's territory."); } } diff --git a/src/com/massivecraft/factions/commands/FCommandOpen.java b/src/com/massivecraft/factions/commands/FCommandOpen.java index 5aad8a8f..47ae03d3 100644 --- a/src/com/massivecraft/factions/commands/FCommandOpen.java +++ b/src/com/massivecraft/factions/commands/FCommandOpen.java @@ -24,24 +24,26 @@ public class FCommandOpen extends FCommand { return; } - if ( ! assertMinRole(Role.MODERATOR)) { + if ( ! assertMinRole(Role.MODERATOR)) + { return; } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostOpen)) { + if (!payForCommand(Conf.econCostOpen)) + { return; } - Faction myFaction = me.getFaction(); - myFaction.setOpen( ! me.getFaction().getOpen()); + Faction myFaction = fme.getFaction(); + myFaction.setOpen( ! fme.getFaction().getOpen()); String open = myFaction.getOpen() ? "open" : "closed"; // Inform - myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed the faction to "+open); + myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed the faction to "+open); for (Faction faction : Faction.getAll()) { - if (faction == me.getFaction()) { + if (faction == fme.getFaction()) { continue; } faction.sendMessage(Conf.colorSystem+"The faction "+myFaction.getTag(faction)+Conf.colorSystem+" is now "+open); diff --git a/src/com/massivecraft/factions/commands/FCommandOwner.java b/src/com/massivecraft/factions/commands/FCommandOwner.java index 2c81c329..6a085882 100644 --- a/src/com/massivecraft/factions/commands/FCommandOwner.java +++ b/src/com/massivecraft/factions/commands/FCommandOwner.java @@ -21,7 +21,7 @@ public class FCommandOwner extends FCommand { @Override public void perform() { - boolean hasBypass = P.hasPermAdminBypass(me); + boolean hasBypass = P.hasPermAdminBypass(fme); if ( ! hasBypass && ! assertHasFaction()) { return; @@ -33,14 +33,14 @@ public class FCommandOwner extends FCommand { } if ( ! Conf.ownedAreasEnabled) { - me.sendMessage("Sorry, but owned areas are disabled on this server."); + fme.sendMessage("Sorry, but owned areas are disabled on this server."); return; } - Faction myFaction = me.getFaction(); + Faction myFaction = fme.getFaction(); if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) { - me.sendMessage("Sorry, but you have reached the server's limit of "+Conf.ownedAreasLimitPerFaction+" owned areas per faction."); + fme.sendMessage("Sorry, but you have reached the server's limit of "+Conf.ownedAreasLimitPerFaction+" owned areas per faction."); return; } @@ -48,17 +48,17 @@ public class FCommandOwner extends FCommand { return; } - FLocation flocation = new FLocation(me); + FLocation flocation = new FLocation(fme); if (Board.getIdAt(flocation) != myFaction.getId()) { if (!hasBypass) { - me.sendMessage("This land is not claimed by your faction, so you can't set ownership of it."); + fme.sendMessage("This land is not claimed by your faction, so you can't set ownership of it."); return; } myFaction = Board.getFactionAt(flocation); if (!myFaction.isNormal()) { - me.sendMessage("This land is not claimed by a faction. Ownership is not possible."); + fme.sendMessage("This land is not claimed by a faction. Ownership is not possible."); return; } } @@ -68,7 +68,7 @@ public class FCommandOwner extends FCommand { if (parameters.size() > 0) { target = findFPlayer(parameters.get(0), false); } else { - target = me; + target = fme; } if (target == null) { return; @@ -77,20 +77,20 @@ public class FCommandOwner extends FCommand { String playerName = target.getName(); if (target.getFaction().getId() != myFaction.getId()) { - me.sendMessage(playerName + " is not a member of this faction."); + fme.sendMessage(playerName + " is not a member of this faction."); return; } // if no player name was passed, and this claim does already have owners set, clear them if (parameters.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) { myFaction.clearClaimOwnership(flocation); - me.sendMessage("You have cleared ownership for this claimed area."); + fme.sendMessage("You have cleared ownership for this claimed area."); return; } if (myFaction.isPlayerInOwnerList(playerName, flocation)) { myFaction.removePlayerAsOwner(playerName, flocation); - me.sendMessage("You have removed ownership of this claimed land from "+playerName+"."); + fme.sendMessage("You have removed ownership of this claimed land from "+playerName+"."); return; } @@ -100,6 +100,6 @@ public class FCommandOwner extends FCommand { } myFaction.setPlayerAsOwner(playerName, flocation); - me.sendMessage("You have added "+playerName+" to the owner list for this claimed land."); + fme.sendMessage("You have added "+playerName+" to the owner list for this claimed land."); } } diff --git a/src/com/massivecraft/factions/commands/FCommandOwnerList.java b/src/com/massivecraft/factions/commands/FCommandOwnerList.java index 8e8cb1f4..b7e2cd2b 100644 --- a/src/com/massivecraft/factions/commands/FCommandOwnerList.java +++ b/src/com/massivecraft/factions/commands/FCommandOwnerList.java @@ -20,29 +20,29 @@ public class FCommandOwnerList extends FCommand { @Override public void perform() { - boolean hasBypass = P.hasPermAdminBypass(me); + boolean hasBypass = P.hasPermAdminBypass(fme); if ( ! hasBypass && ! assertHasFaction()) { return; } if ( ! Conf.ownedAreasEnabled) { - me.sendMessage("Owned areas are disabled on this server."); + fme.sendMessage("Owned areas are disabled on this server."); return; } - Faction myFaction = me.getFaction(); - FLocation flocation = new FLocation(me); + Faction myFaction = fme.getFaction(); + FLocation flocation = new FLocation(fme); if (Board.getIdAt(flocation) != myFaction.getId()) { if (!hasBypass) { - me.sendMessage("This land is not claimed by your faction."); + fme.sendMessage("This land is not claimed by your faction."); return; } myFaction = Board.getFactionAt(flocation); if (!myFaction.isNormal()) { - me.sendMessage("This land is not claimed by any faction, thus no owners."); + fme.sendMessage("This land is not claimed by any faction, thus no owners."); return; } } @@ -50,10 +50,10 @@ public class FCommandOwnerList extends FCommand { String owners = myFaction.getOwnerListString(flocation); if (owners == null || owners.isEmpty()) { - me.sendMessage("No owners are set here; everyone in the faction has access."); + fme.sendMessage("No owners are set here; everyone in the faction has access."); return; } - me.sendMessage("Current owner(s) of this land: "+owners); + fme.sendMessage("Current owner(s) of this land: "+owners); } } diff --git a/src/com/massivecraft/factions/commands/FCommandPay.java b/src/com/massivecraft/factions/commands/FCommandPay.java index 0119d976..23e284eb 100644 --- a/src/com/massivecraft/factions/commands/FCommandPay.java +++ b/src/com/massivecraft/factions/commands/FCommandPay.java @@ -2,77 +2,70 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; import com.massivecraft.factions.P; import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; public class FCommandPay extends FCommand { - public FCommandPay() { - aliases.add("pay"); + this.aliases.add("pay"); - helpDescription = "Pay another faction from your bank"; - requiredParameters.add("faction"); - requiredParameters.add("amount"); + this.requiredArgs.add("faction"); + this.requiredArgs.add("amount"); + //this.optionalArgs.put("factiontag", "yours"); + + this.permission = Permission.COMMAND_PAY.node; + + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override public void perform() { - if ( ! assertHasFaction()) { + if ( ! Conf.bankEnabled) return; + + if ( ! Conf.bankMembersCanWithdraw && ! assertMinRole(Role.MODERATOR)) + { + sendMessageParsed("Only faction moderators or admins are able to pay another faction."); return; } - if (!Conf.bankEnabled) { - return; - } - - if ( !Conf.bankMembersCanWithdraw && !assertMinRole(Role.MODERATOR)) { - sendMessage("Only faction moderators or admins are able to pay another faction."); - return; - } - - double amount = 0.0; - - Faction us = me.getFaction(); - Faction them = null; - - if (parameters.size() == 2) { - try { - them = Faction.findByTag(parameters.get(0)); - amount = Double.parseDouble(parameters.get(1)); - } catch (NumberFormatException e) { - // wasn't valid - } - } - - if(them == null) { - sendMessage("Faction "+parameters.get(0)+" could not be found."); - return; - } + Faction us = fme.getFaction(); + Faction them = this.argAsFaction(0); + if ( them == null ) return; + double amount = this.argAsDouble(1, 0d); - if( amount > 0.0 ) { + if( amount > 0.0 ) + { String amountString = Econ.moneyString(amount); - if( amount > us.getMoney() ) { + if( amount > us.getMoney() ) + { amount = us.getMoney(); } us.removeMoney(amount); them.addMoney(amount); - sendMessage("You have paid "+amountString+" from "+us.getTag()+"'s bank to "+them.getTag()+"'s bank."); - sendMessage(us.getTag()+" now has "+Econ.moneyString(us.getMoney())); - P.log(me.getName() + " paid "+amountString+" from "+us.getTag()+"'s bank to "+them.getTag()+"'s bank."); - for (FPlayer fplayer : FPlayer.getAllOnline()) { - if (fplayer.getFaction() == us || fplayer.getFaction() == them) { - fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has sent "+amountString+" from "+us.getTag()+" to "+them.getTag() ); + sendMessageParsed("You have paid "+amountString+" from "+us.getTag()+"'s bank to "+them.getTag()+"'s bank."); + sendMessageParsed(""+us.getTag()+" now has "+Econ.moneyString(us.getMoney())); + P.p.log(fme.getName() + " paid "+amountString+" from "+us.getTag()+"'s bank to "+them.getTag()+"'s bank."); + + for (FPlayer fplayer : FPlayers.i.getOnline()) + { + if (fplayer.getFaction() == us || fplayer.getFaction() == them) + { + fplayer.sendMessageParsed(fme.getNameAndRelevant(fplayer)+" has sent "+amountString+" from "+us.getTag()+" to "+them.getTag()); } } } } - } diff --git a/src/com/massivecraft/factions/commands/FCommandPeaceful.java b/src/com/massivecraft/factions/commands/FCommandPeaceful.java index 96be4d83..44dc9561 100644 --- a/src/com/massivecraft/factions/commands/FCommandPeaceful.java +++ b/src/com/massivecraft/factions/commands/FCommandPeaceful.java @@ -46,9 +46,9 @@ public class FCommandPeaceful extends FCommand { // Inform all players for (FPlayer fplayer : FPlayer.getAllOnline()) { if (fplayer.getFaction() == faction) { - fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction."); + fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction."); } else { - fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\"."); + fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\"."); } } diff --git a/src/com/massivecraft/factions/commands/FCommandPermanent.java b/src/com/massivecraft/factions/commands/FCommandPermanent.java index 032a8665..6d81746a 100644 --- a/src/com/massivecraft/factions/commands/FCommandPermanent.java +++ b/src/com/massivecraft/factions/commands/FCommandPermanent.java @@ -46,9 +46,9 @@ public class FCommandPermanent extends FCommand { // Inform all players for (FPlayer fplayer : FPlayer.getAllOnline()) { if (fplayer.getFaction() == faction) { - fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction."); + fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction."); } else { - fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\"."); + fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\"."); } } } diff --git a/src/com/massivecraft/factions/commands/FCommandPower.java b/src/com/massivecraft/factions/commands/FCommandPower.java index 42505099..3a5ffb95 100644 --- a/src/com/massivecraft/factions/commands/FCommandPower.java +++ b/src/com/massivecraft/factions/commands/FCommandPower.java @@ -30,8 +30,8 @@ public class FCommandPower extends FCommand { public void perform() { FPlayer target; if (parameters.size() > 0) { - if (!P.hasPermViewAnyPower(me)) { - me.sendMessage("You do not have the appropriate permission to view another player's power level."); + if (!P.hasPermViewAnyPower(fme)) { + fme.sendMessage("You do not have the appropriate permission to view another player's power level."); return; } target = findFPlayer(parameters.get(0), false); @@ -39,7 +39,7 @@ public class FCommandPower extends FCommand { sendMessage("From the console, you must specify a player (f power )."); return; } else { - target = me; + target = fme; } if (target == null) { @@ -51,7 +51,7 @@ public class FCommandPower extends FCommand { return; } - sendMessage(target.getNameAndRelevant(me)+Conf.colorChrome+" - Power / Maxpower: "+Conf.colorSystem+target.getPowerRounded()+" / "+target.getPowerMaxRounded()); + sendMessage(target.getNameAndRelevant(fme)+Conf.colorChrome+" - Power / Maxpower: "+Conf.colorSystem+target.getPowerRounded()+" / "+target.getPowerMaxRounded()); } } diff --git a/src/com/massivecraft/factions/commands/FCommandSafeclaim.java b/src/com/massivecraft/factions/commands/FCommandSafeclaim.java index d2fc0062..b91bc3cf 100644 --- a/src/com/massivecraft/factions/commands/FCommandSafeclaim.java +++ b/src/com/massivecraft/factions/commands/FCommandSafeclaim.java @@ -32,7 +32,7 @@ public class FCommandSafeclaim extends FCommand { } // The current location of the player - FLocation playerFlocation = new FLocation(me); + FLocation playerFlocation = new FLocation(fme); // Was a radius set? if (parameters.size() > 0) { diff --git a/src/com/massivecraft/factions/commands/FCommandSethome.java b/src/com/massivecraft/factions/commands/FCommandSethome.java index d44a4bbd..6e355e62 100644 --- a/src/com/massivecraft/factions/commands/FCommandSethome.java +++ b/src/com/massivecraft/factions/commands/FCommandSethome.java @@ -31,28 +31,28 @@ public class FCommandSethome extends FCommand { } if ( ! Conf.homesEnabled) { - me.sendMessage("Sorry, Faction homes are disabled on this server."); + fme.sendMessage("Sorry, Faction homes are disabled on this server."); return; } - Faction myFaction = me.getFaction(); + Faction myFaction = fme.getFaction(); if (parameters.size() > 0) { - if (!P.hasPermAdminBypass(me)) { - me.sendMessage("You cannot set the home of another faction without adminBypass permission."); + if (!P.hasPermAdminBypass(fme)) { + fme.sendMessage("You cannot set the home of another faction without adminBypass permission."); return; } myFaction = findFaction(parameters.get(0), true); if (myFaction == null) { - me.sendMessage("No such faction seems to exist."); + fme.sendMessage("No such faction seems to exist."); return; } } - if (Conf.homesMustBeInClaimedTerritory && !me.isInOwnTerritory() && !P.hasPermAdminBypass(me)) { - me.sendMessage("Sorry, your faction home can only be set inside your own claimed territory."); + if (Conf.homesMustBeInClaimedTerritory && !fme.isInOwnTerritory() && !P.hasPermAdminBypass(fme)) { + fme.sendMessage("Sorry, your faction home can only be set inside your own claimed territory."); return; } @@ -61,12 +61,12 @@ public class FCommandSethome extends FCommand { return; } - myFaction.setHome(me.getLocation()); + myFaction.setHome(fme.getLocation()); - myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:"); + myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:"); myFaction.sendMessage(new FCommandHome().getUseageTemplate()); - if (myFaction != me.getFaction()) { - me.sendMessage("You have set the home for the "+myFaction.getTag(me)+Conf.colorSystem+" faction."); + if (myFaction != fme.getFaction()) { + fme.sendMessage("You have set the home for the "+myFaction.getTag(fme)+Conf.colorSystem+" faction."); } } diff --git a/src/com/massivecraft/factions/commands/FCommandShow.java b/src/com/massivecraft/factions/commands/FCommandShow.java index d3557f85..4d0c4f06 100644 --- a/src/com/massivecraft/factions/commands/FCommandShow.java +++ b/src/com/massivecraft/factions/commands/FCommandShow.java @@ -40,7 +40,7 @@ public class FCommandShow extends FCommand { sendMessage("From the command line, you must specify a faction tag (f who )."); return; } else { - faction = me.getFaction(); + faction = fme.getFaction(); } if (faction == null) { @@ -56,7 +56,7 @@ public class FCommandShow extends FCommand { Collection mods = faction.getFPlayersWhereRole(Role.MODERATOR); Collection normals = faction.getFPlayersWhereRole(Role.NORMAL); - sendMessage(TextUtil.titleize(faction.getTag(me))); + sendMessage(TextUtil.titleize(faction.getTag(fme))); sendMessage(Conf.colorChrome+"Description: "+Conf.colorSystem+faction.getDescription()); if ( ! faction.isNormal()) { return; @@ -99,7 +99,7 @@ public class FCommandShow extends FCommand { if (otherFaction == faction) { continue; } - listpart = otherFaction.getTag(me)+Conf.colorSystem+", "; + listpart = otherFaction.getTag(fme)+Conf.colorSystem+", "; if (otherFaction.getRelation(faction).isAlly()) { allyList += listpart; } else if (otherFaction.getRelation(faction).isEnemy()) { @@ -120,7 +120,7 @@ public class FCommandShow extends FCommand { String onlineList = Conf.colorChrome+"Members online: "; String offlineList = Conf.colorChrome+"Members offline: "; for (FPlayer follower : admins) { - listpart = follower.getNameAndTitle(me)+Conf.colorSystem+", "; + listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", "; if (follower.isOnline()) { onlineList += listpart; } else { @@ -128,7 +128,7 @@ public class FCommandShow extends FCommand { } } for (FPlayer follower : mods) { - listpart = follower.getNameAndTitle(me)+Conf.colorSystem+", "; + listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", "; if (follower.isOnline()) { onlineList += listpart; } else { @@ -136,7 +136,7 @@ public class FCommandShow extends FCommand { } } for (FPlayer follower : normals) { - listpart = follower.getNameAndTitle(me)+Conf.colorSystem+", "; + listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", "; if (follower.isOnline()) { onlineList += listpart; } else { diff --git a/src/com/massivecraft/factions/commands/FCommandTag.java b/src/com/massivecraft/factions/commands/FCommandTag.java index d34286ea..079d9e93 100644 --- a/src/com/massivecraft/factions/commands/FCommandTag.java +++ b/src/com/massivecraft/factions/commands/FCommandTag.java @@ -37,7 +37,7 @@ public class FCommandTag extends FCommand { String tag = parameters.get(0); // TODO does not first test cover selfcase? - if (Faction.isTagTaken(tag) && ! TextUtil.getComparisonString(tag).equals(me.getFaction().getComparisonTag())) { + if (Faction.isTagTaken(tag) && ! TextUtil.getComparisonString(tag).equals(fme.getFaction().getComparisonTag())) { sendMessage("That tag is already taken"); return; } @@ -54,18 +54,18 @@ public class FCommandTag extends FCommand { return; } - Faction myFaction = me.getFaction(); + Faction myFaction = fme.getFaction(); String oldtag = myFaction.getTag(); myFaction.setTag(tag); // Inform - myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed your faction tag to "+Conf.colorMember+myFaction.getTag()); + myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed your faction tag to "+Conf.colorMember+myFaction.getTag()); for (Faction faction : Faction.getAll()) { - if (faction == me.getFaction()) { + if (faction == fme.getFaction()) { continue; } - faction.sendMessage(Conf.colorSystem+"The faction "+me.getRelationColor(faction)+oldtag+Conf.colorSystem+" changed their name to "+myFaction.getTag(faction)); + faction.sendMessage(Conf.colorSystem+"The faction "+fme.getRelationColor(faction)+oldtag+Conf.colorSystem+" changed their name to "+myFaction.getTag(faction)); } if (Conf.spoutFactionTagsOverNames) { diff --git a/src/com/massivecraft/factions/commands/FCommandTitle.java b/src/com/massivecraft/factions/commands/FCommandTitle.java index ebbe23cc..610651c2 100644 --- a/src/com/massivecraft/factions/commands/FCommandTitle.java +++ b/src/com/massivecraft/factions/commands/FCommandTitle.java @@ -38,7 +38,7 @@ public class FCommandTitle extends FCommand { return; } - if ( ! canIAdministerYou(me, you)) { + if ( ! canIAdministerYou(fme, you)) { return; } @@ -50,11 +50,11 @@ public class FCommandTitle extends FCommand { you.setTitle(title); // Inform - Faction myFaction = me.getFaction(); - myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed a title: "+you.getNameAndRelevant(myFaction)); + Faction myFaction = fme.getFaction(); + myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed a title: "+you.getNameAndRelevant(myFaction)); if (Conf.spoutFactionTitlesOverNames) { - SpoutFeatures.updateAppearances(me); + SpoutFeatures.updateAppearances(fme); } } diff --git a/src/com/massivecraft/factions/commands/FCommandUnclaim.java b/src/com/massivecraft/factions/commands/FCommandUnclaim.java index c390e47c..cc43afd9 100644 --- a/src/com/massivecraft/factions/commands/FCommandUnclaim.java +++ b/src/com/massivecraft/factions/commands/FCommandUnclaim.java @@ -25,7 +25,7 @@ public class FCommandUnclaim extends FCommand { return; } - FLocation flocation = new FLocation(me); + FLocation flocation = new FLocation(fme); Faction otherFaction = Board.getFactionAt(flocation); if (otherFaction.isSafeZone()) { @@ -47,10 +47,10 @@ public class FCommandUnclaim extends FCommand { return; } - if (Conf.adminBypassPlayers.contains(me.getName())) { + if (Conf.adminBypassPlayers.contains(fme.getName())) { Board.removeAt(flocation); - otherFaction.sendMessage(me.getNameAndRelevant(otherFaction)+Conf.colorSystem+" unclaimed some of your land."); + otherFaction.sendMessage(fme.getNameAndRelevant(otherFaction)+Conf.colorSystem+" unclaimed some of your land."); sendMessage("You unclaimed this land."); return; } @@ -63,7 +63,7 @@ public class FCommandUnclaim extends FCommand { return; } - Faction myFaction = me.getFaction(); + Faction myFaction = fme.getFaction(); if ( myFaction != otherFaction) { @@ -77,25 +77,25 @@ public class FCommandUnclaim extends FCommand { // a real refund if (refund > 0.0) { if(Conf.bankFactionPaysLandCosts) { - Faction faction = me.getFaction(); + Faction faction = fme.getFaction(); faction.addMoney(refund); moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+"."; } else { - Econ.addMoney(me.getName(), refund); + Econ.addMoney(fme.getName(), refund); moneyBack = " They received a refund of "+Econ.moneyString(refund)+"."; } } // wait, you're charging people to unclaim land? outrageous else if (refund < 0.0) { if(Conf.bankFactionPaysLandCosts) { - Faction faction = me.getFaction(); + Faction faction = fme.getFaction(); if(!faction.removeMoney(-refund)) { sendMessage("Unclaiming this land will cost "+Econ.moneyString(-refund)+", which your faction can't currently afford."); return; } moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+"."; } else { - if (!Econ.deductMoney(me.getName(), -refund)) { + if (!Econ.deductMoney(fme.getName(), -refund)) { sendMessage("Unclaiming this land will cost "+Econ.moneyString(-refund)+", which you can't currently afford."); return; } @@ -109,7 +109,7 @@ public class FCommandUnclaim extends FCommand { } Board.removeAt(flocation); - myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed some land."+moneyBack); + myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed some land."+moneyBack); } } diff --git a/src/com/massivecraft/factions/commands/FCommandUnclaimall.java b/src/com/massivecraft/factions/commands/FCommandUnclaimall.java index b86c0384..111d77c1 100644 --- a/src/com/massivecraft/factions/commands/FCommandUnclaimall.java +++ b/src/com/massivecraft/factions/commands/FCommandUnclaimall.java @@ -30,7 +30,7 @@ public class FCommandUnclaimall extends FCommand { return; } - Faction myFaction = me.getFaction(); + Faction myFaction = fme.getFaction(); String moneyBack = ""; if (Econ.enabled()) { @@ -38,25 +38,25 @@ public class FCommandUnclaimall extends FCommand { // a real refund if (refund > 0.0) { if(Conf.bankFactionPaysLandCosts) { - Faction faction = me.getFaction(); + Faction faction = fme.getFaction(); faction.addMoney(refund); moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+"."; } else { - Econ.addMoney(me.getName(), refund); + Econ.addMoney(fme.getName(), refund); moneyBack = " They received a refund of "+Econ.moneyString(refund)+"."; } } // wait, you're charging people to unclaim land? outrageous else if (refund < 0.0) { if(Conf.bankFactionPaysLandCosts) { - Faction faction = me.getFaction(); + Faction faction = fme.getFaction(); if(!faction.removeMoney(-refund)) { sendMessage("Unclaiming all faction land will cost "+Econ.moneyString(-refund)+", which your faction can't currently afford."); return; } moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+"."; } else { - if (!Econ.deductMoney(me.getName(), -refund)) { + if (!Econ.deductMoney(fme.getName(), -refund)) { sendMessage("Unclaiming all faction land will cost "+Econ.moneyString(-refund)+", which you can't currently afford."); return; } @@ -71,7 +71,7 @@ public class FCommandUnclaimall extends FCommand { } Board.unclaimAll(myFaction.getId()); - myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed ALL of your faction's land."+moneyBack); + myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed ALL of your faction's land."+moneyBack); } } diff --git a/src/com/massivecraft/factions/commands/FCommandWarclaim.java b/src/com/massivecraft/factions/commands/FCommandWarclaim.java index 923e0cfe..f7c7e275 100644 --- a/src/com/massivecraft/factions/commands/FCommandWarclaim.java +++ b/src/com/massivecraft/factions/commands/FCommandWarclaim.java @@ -31,7 +31,7 @@ public class FCommandWarclaim extends FCommand { } // The current location of the player - FLocation playerFlocation = new FLocation(me); + FLocation playerFlocation = new FLocation(fme); // Was a radius set? if (parameters.size() > 0) { diff --git a/src/com/massivecraft/factions/commands/FCommandWithdraw.java b/src/com/massivecraft/factions/commands/FCommandWithdraw.java index d36d5a78..d472db4d 100644 --- a/src/com/massivecraft/factions/commands/FCommandWithdraw.java +++ b/src/com/massivecraft/factions/commands/FCommandWithdraw.java @@ -2,64 +2,70 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; import com.massivecraft.factions.P; import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; -public class FCommandWithdraw extends FCommand { +public class FCommandWithdraw extends FCommand +{ - public FCommandWithdraw() { - aliases.add("withdraw"); + public FCommandWithdraw() + { + this.aliases.add("withdraw"); - helpDescription = "Withdraw money from your faction's bank"; - requiredParameters.add("amount"); + this.requiredArgs.add("amount"); + //this.optionalArgs.put("factiontag", "yours"); + + this.permission = Permission.COMMAND_WITHDRAW.node; + + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public void perform() { - if ( ! assertHasFaction()) { + public void perform() + { + if ( ! Conf.bankEnabled) return; + + if ( ! Conf.bankMembersCanWithdraw && ! assertMinRole(Role.MODERATOR)) + { + sendMessageParsed("Only faction moderators or admins are able to withdraw from the bank."); return; } - if (!Conf.bankEnabled) { - return; - } + Faction faction = fme.getFaction(); - if ( !Conf.bankMembersCanWithdraw && !assertMinRole(Role.MODERATOR)) { - sendMessage("Only faction moderators or admins are able to withdraw from the bank."); - return; - } + double amount = this.argAsDouble(0, 0d); - double amount = 0.0; - - Faction faction = me.getFaction(); - - if (parameters.size() == 1) { - try { - amount = Double.parseDouble(parameters.get(0)); - } catch (NumberFormatException e) { - // wasn't valid - } - } - - if( amount > 0.0 ) { + if( amount > 0.0 ) + { String amountString = Econ.moneyString(amount); - if( amount > faction.getMoney() ) { + if( amount > faction.getMoney() ) + { amount = faction.getMoney(); } - faction.removeMoney(amount); - Econ.addMoney(me.getName(), amount); - sendMessage("You have withdrawn "+amountString+" from "+faction.getTag()+"'s bank."); - sendMessage(faction.getTag()+" now has "+Econ.moneyString(faction.getMoney())); - P.log(me.getName() + " withdrew "+amountString+" from "+faction.getTag()+"'s bank."); + // TODO: Improve messages. - for (FPlayer fplayer : FPlayer.getAllOnline()) { - if (fplayer.getFaction() == faction) { - fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has withdrawn "+amountString); + faction.removeMoney(amount); + Econ.addMoney(fme.getName(), amount); + sendMessageParsed("You have withdrawn "+amountString+" from "+faction.getTag()+"'s bank."); + sendMessageParsed(""+faction.getTag()+" now has "+Econ.moneyString(faction.getMoney())); + P.p.log(fme.getName() + " withdrew "+amountString+" from "+faction.getTag()+"'s bank."); + + // TODO: FAction.getOnlineMembers(). + for (FPlayer fplayer : FPlayers.i.getOnline()) + { + if (fplayer.getFaction() == faction) + { + fplayer.sendMessageParsed("%s has withdrawn %s", fme.getNameAndRelevant(fplayer), amountString); } } } diff --git a/src/com/massivecraft/factions/commands/FRelationCommand.java b/src/com/massivecraft/factions/commands/FRelationCommand.java index c9403cd3..5f9b45bd 100644 --- a/src/com/massivecraft/factions/commands/FRelationCommand.java +++ b/src/com/massivecraft/factions/commands/FRelationCommand.java @@ -32,7 +32,7 @@ public class FRelationCommand extends FCommand { return; } - Faction myFaction = me.getFaction(); + Faction myFaction = fme.getFaction(); Faction otherFaction = findFaction(otherFactionName, false); if (otherFaction == null) { return; diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 362b3408..473cdf93 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -236,7 +236,7 @@ public class FactionsPlayerListener extends PlayerListener } } - if (me.autoClaimEnabled()) + if (me.isAutoClaimEnabled()) { Faction myFaction = me.getFaction(); // TODO: Why is this ("cost") here and unused??? Should it be used somewhere Brettflan? :) @@ -247,26 +247,26 @@ public class FactionsPlayerListener extends PlayerListener if (me.getRole().value < Role.MODERATOR.value) { me.sendMessage("You must be "+Role.MODERATOR+" to claim land."); - me.enableAutoClaim(false); + me.setIsAutoClaimEnabled(false); } else if (Conf.worldsNoClaiming.contains(to.getWorldName())) { me.sendMessage("Sorry, this world has land claiming disabled."); - me.enableAutoClaim(false); + me.setIsAutoClaimEnabled(false); } else if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) { me.sendMessage("You can't claim more land! You need more power!"); - me.enableAutoClaim(false); + me.setIsAutoClaimEnabled(false); } else me.attemptClaim(false); } - else if (me.autoSafeZoneEnabled()) + else if (me.isAutoSafeClaimEnabled()) { if ( ! Permission.MANAGE_SAFE_ZONE.has(player)) { - me.enableAutoSafeZone(false); + me.setIsAutoSafeClaimEnabled(false); } else { @@ -279,11 +279,11 @@ public class FactionsPlayerListener extends PlayerListener } } } - else if (me.autoWarZoneEnabled()) + else if (me.isAutoWarClaimEnabled()) { if ( ! Permission.MANAGE_WAR_ZONE.has(player)) { - me.enableAutoWarZone(false); + me.setIsAutoWarClaimEnabled(false); } else { diff --git a/src/com/massivecraft/factions/struct/ChatMode.java b/src/com/massivecraft/factions/struct/ChatMode.java index 86fb9fd7..6e9e6e05 100644 --- a/src/com/massivecraft/factions/struct/ChatMode.java +++ b/src/com/massivecraft/factions/struct/ChatMode.java @@ -1,6 +1,7 @@ package com.massivecraft.factions.struct; -public enum ChatMode { +public enum ChatMode +{ FACTION(2, "faction chat"), ALLIANCE(1, "alliance chat"), PUBLIC(0, "public chat"); @@ -8,21 +9,32 @@ public enum ChatMode { public final int value; public final String nicename; - private ChatMode(final int value, final String nicename) { + private ChatMode(final int value, final String nicename) + { this.value = value; this.nicename = nicename; } - public boolean isAtLeast(ChatMode role) { + public boolean isAtLeast(ChatMode role) + { return this.value >= role.value; } - public boolean isAtMost(ChatMode role) { + public boolean isAtMost(ChatMode role) + { return this.value <= role.value; } @Override - public String toString() { + public String toString() + { return this.nicename; } + + public ChatMode getNext() + { + if (this == PUBLIC) return ALLIANCE; + if (this == ALLIANCE)return FACTION; + return PUBLIC; + } } diff --git a/src/com/massivecraft/factions/struct/Permission.java b/src/com/massivecraft/factions/struct/Permission.java index 9b8262e9..562afcc7 100644 --- a/src/com/massivecraft/factions/struct/Permission.java +++ b/src/com/massivecraft/factions/struct/Permission.java @@ -6,27 +6,53 @@ import com.massivecraft.factions.P; public enum Permission { - PARTICIPATE("factions.participate"), - CREATE("factions.create"), - VIEW_ANY_POWER("factions.viewAnyPower"), - PEACEFUL_EXPLOTION_TOGGLE("factions.peacefulExplosionToggle"), - ADMIN_BYPASS("factions.adminBypass"), - CONFIG("factions.config"), - DISBAN("factions.disband"), - LOCK("factions.lock"), - MANAGE_SAFE_ZONE("factions.manageSafeZone"), - MANAGE_WAR_ZONE("factions.manageWarZone"), - OWNERSHIP_BYPASS("factions.ownershipBypass"), - RELOAD("factions.reload"), - SAVE_ALL("factions.saveall"), - SET_PEACEFUL("factions.setPeaceful"), + PARTICIPATE("participate"), + CREATE("create"), + VIEW_ANY_POWER("viewAnyPower"), + VIEW_ANY_FACTION_BALANCE("viewAnyFactionBalance"), + PEACEFUL_EXPLOTION_TOGGLE("peacefulExplosionToggle"), + ADMIN_BYPASS("adminBypass"), + CONFIG("config"), + DISBAND("disband"), + LOCK("lock"), + MANAGE_SAFE_ZONE("manageSafeZone"), + MANAGE_WAR_ZONE("manageWarZone"), + OWNERSHIP_BYPASS("ownershipBypass"), + RELOAD("reload"), + SAVE_ALL("saveall"), + SET_PEACEFUL("setPeaceful"), + SET_PERMANENT("setPermanent"), + COMMAND_ADMIN("command.admin"), + COMMAND_AUTOCLAIM("command.autoClaim"), + COMMAND_BALANCE("command.balance"), + COMMAND_WITHDRAW("command.withdraw"), + COMMAND_PAY("command.pay"), + COMMAND_CHAT("command.chat"), + COMMAND_CLAIM("command.claim"), + COMMAND_CONFIG("command.config"), + COMMAND_DEINVITE("command.deinvite"), + COMMAND_DEPOSIT("command.deposit"), + COMMAND_DESCRIPTION("command.description"), + COMMAND_DISBAND("command.disband"), + COMMAND_DISBAND_ANY("command.disband.any"), + COMMAND_HELP("command.help"), + COMMAND_HOME("command.home"), + COMMAND_INVITE("command.invite"), + COMMAND_JOIN("command.join"), + COMMAND_KICK("command.kick"), + COMMAND_KICK_ANY("command.kick.any"), + COMMAND_LEAVE("command.leave"), + COMMAND_LIST("command.list"), + COMMAND_LOCK("command.lock"), + COMMAND_MAP("command.map"), + COMMAND_MOD("command.mod"), ; public final String node; Permission(final String node) { - this.node = node; + this.node = "factions."+node; } public boolean has(CommandSender sender, boolean informSenderIfNot) diff --git a/src/com/massivecraft/factions/zcore/MCommand.java b/src/com/massivecraft/factions/zcore/MCommand.java index c2bdfb2f..21ef83a4 100644 --- a/src/com/massivecraft/factions/zcore/MCommand.java +++ b/src/com/massivecraft/factions/zcore/MCommand.java @@ -27,8 +27,25 @@ public abstract class MCommand public List requiredArgs; public LinkedHashMap optionalArgs; - // Help info - public String helpShort; + // FIELD: Help Short + // This field may be left blank and will in such case be loaded from the permissions node instead. + // Thus make sure the permissions node description is an action description like "eat hamburgers" or "do admin stuff". + private String helpShort; + public void setHelpShort(String val) { this.helpShort = val; } + public String getHelpShort() + { + if (this.helpShort == null) + { + String pdesc = p.perm.getPermissionDescription(this.permission); + if (pdesc != null) + { + return pdesc; + } + return "*no short help available*"; + } + return this.helpShort; + } + public List helpLong; public CommandVisibility visibility; @@ -39,6 +56,7 @@ public abstract class MCommand // Information available on execution of the command public CommandSender sender; // Will always be set public Player me; // Will only be set when the sender is a player + public boolean senderIsConsole; public List args; // Will contain the arguments, or and empty list if there are none. public List> commandChain; // The command chain used to execute this command @@ -56,7 +74,7 @@ public abstract class MCommand this.requiredArgs = new ArrayList(); this.optionalArgs = new LinkedHashMap(); - this.helpShort = "*Default helpShort*"; + this.helpShort = null; this.helpLong = new ArrayList(); this.visibility = CommandVisibility.VISIBLE; } @@ -69,10 +87,12 @@ public abstract class MCommand if (sender instanceof Player) { this.me = (Player)sender; + this.senderIsConsole = false; } else { this.me = null; + this.senderIsConsole = true; } this.args = args; this.commandChain = commandChain; @@ -255,38 +275,38 @@ public abstract class MCommand // Message Sending Helpers // -------------------------------------------- // - public void sendMessage(String msg, boolean parseColors) + public void sendMessageParsed(String str, Object... args) { - if (parseColors) - { - sender.sendMessage(p.txt.tags(msg)); - return; - } - sender.sendMessage(msg); + sender.sendMessage(p.txt.parse(str, args)); } public void sendMessage(String msg) { - this.sendMessage(msg, false); - } - - public void sendMessage(List msgs, boolean parseColors) - { - for(String msg : msgs) - { - this.sendMessage(msg, parseColors); - } + sender.sendMessage(msg); } public void sendMessage(List msgs) { - sendMessage(msgs, false); + for(String msg : msgs) + { + this.sendMessage(msg); + } } // -------------------------------------------- // // Argument Readers // -------------------------------------------- // + // Is set? + public boolean argIsSet(int idx) + { + if (this.args.size() < idx+1) + { + return false; + } + return true; + } + // STRING public String argAsString(int idx, String def) { diff --git a/src/com/massivecraft/factions/zcore/persist/PlayerEntity.java b/src/com/massivecraft/factions/zcore/persist/PlayerEntity.java index f8ccced9..ea1c468c 100644 --- a/src/com/massivecraft/factions/zcore/persist/PlayerEntity.java +++ b/src/com/massivecraft/factions/zcore/persist/PlayerEntity.java @@ -26,6 +26,14 @@ public class PlayerEntity extends Entity // Message Sending Helpers // -------------------------------------------- // + /* + public void sendMessageParsed(String str, Object... args) + { + this.sendMessage(p.txt.parse(str, args)); + } + Refference issue!! + */ + public void sendMessage(String msg) { Player player = this.getPlayer(); diff --git a/src/plugin.yml b/src/plugin.yml index fcf062cc..179f64eb 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -39,254 +39,114 @@ permissions: factions.setPermanent: true factions.commandDisable.none: true factions.participate: - description: Allows the player to participate in a faction + description: participate in a faction default: true factions.create: - description: Allows the player to create a new faction + description: create a new faction default: true factions.viewAnyPower: - description: Allows the player to view the power level of anyone else + description: view the power level of anyone else default: true factions.viewAnyFactionBalance: - description: Allows the player to view the faction bank balance for any faction + description: view the faction bank balance for any faction default: true factions.peacefulExplosionToggle: - description: Allows peaceful faction admins and moderators to disable explosions in their territory + description: disable explosions in your territory as a peaceful faction admin or moderator default: true factions.adminBypass: - description: Allows the player to bypass many normal restrictions, and use the bypass command + description: enable admin bypass mode (build/destroy anywhere) default: op factions.config: - description: Can use /f config command to change conf.json options - default: op - factions.disband: - description: Can use the /f disband command to disband any faction - default: op - factions.lock: - description: Can use the /f lock [on/off] command to temporarily lock the data files from being overwritten + description: use /f config command to change conf.json options default: op factions.manageSafeZone: - description: Allows the player to claim land as a safe zone, and to build/destroy within safe zones + description: claim land as a safe zone and build/destroy within safe zones default: op factions.manageWarZone: - description: Allows the player to claim land as a war zone, and to build/destroy within war zones + description: claim land as a war zone and build/destroy within war zones default: op factions.ownershipBypass: - description: Allows the player to bypass ownership restrictions within own faction's territory + description: bypass ownership restrictions within own faction's territory default: op factions.reload: - description: Can use the /f reload command to reload data file(s) from disk + description: use the /f reload command to reload data file(s) from disk default: op factions.saveall: - description: Can use the /f saveall command to save all data to disk + description: use the /f saveall command to save all data to disk default: op factions.setPeaceful: - description: Can designate specific factions as "peaceful" (no PvP, no land stealing, etc.) + description: designate specific factions as "peaceful" (no PvP, no land stealing, etc.) default: op factions.setPermanent: - description: Can designate specific factions as permanent (not disbanded even with no members) + description: designate specific factions as permanent (not disbanded even with no members) default: op - factions.commandDisable.none: - description: no commands disabled (ignore all other commandDisable permissions) + + factions.command.admin: + description: hand over your admin rights + default: true + factions.command.autoClaim: + description: auto-claim land as you walk around + default: true + factions.command.balance: + description: show current faction balance + default: true + factions.command.withdraw: + description: withdraw money from your faction bank + default: true + factions.command.pay: + description: pay another faction from your bank + default: true + factions.command.chat: + description: change chat mode + default: true + factions.command.claim: + description: claim the land where you are standing + default: true + factions.command.config: + description: change a conf.json setting default: op - factions.commandDisable.admin: - description: admin command disabled - default: false - factions.commandDisable.autoclaim: - description: autoclaim command disabled - default: false - factions.commandDisable.autosafe: - description: autosafe command disabled - default: false - factions.commandDisable.autowar: - description: autowar command disabled - default: false - factions.commandDisable.balance: - description: balance/money command disabled - default: false - factions.commandDisable.bypass: - description: bypass command disabled - default: false - factions.commandDisable.chat: - description: chat command disabled - default: false - factions.commandDisable.c: - description: chat command disabled - default: false - factions.commandDisable.claim: - description: claim command disabled - default: false - factions.commandDisable.create: - description: create command disabled - default: false - factions.commandDisable.deinvite: - description: deinvite command disabled - default: false - factions.commandDisable.deinv: - description: deinvite command disabled - default: false - factions.commandDisable.deposit: - description: deposit command disabled - default: false - factions.commandDisable.desc: - description: desc command disabled - default: false - factions.commandDisable.disband: - description: disband command disabled - default: false - factions.commandDisable.help: - description: help command disabled - default: false - factions.commandDisable.h: - description: help command disabled - default: false - factions.commandDisable.?: - description: help command disabled - default: false - factions.commandDisable.home: - description: home command disabled - default: false - factions.commandDisable.invite: - description: invite command disabled - default: false - factions.commandDisable.inv: - description: invite command disabled - default: false - factions.commandDisable.join: - description: join command disabled - default: false - factions.commandDisable.kick: - description: kick command disabled - default: false - factions.commandDisable.leave: - description: leave command disabled - default: false - factions.commandDisable.list: - description: list command disabled - default: false - factions.commandDisable.ls: - description: list command disabled - default: false - factions.commandDisable.lock: - description: lock command disabled - default: false - factions.commandDisable.map: - description: map command disabled - default: false - factions.commandDisable.mod: - description: mod command disabled - default: false - factions.commandDisable.money: - description: balance/money command disabled - default: false - factions.commandDisable.noboom: - description: noboom command disabled - default: false - factions.commandDisable.open: - description: open command disabled - default: false - factions.commandDisable.close: - description: open command disabled - default: false - factions.commandDisable.owner: - description: owner command disabled - default: false - factions.commandDisable.ownerlist: - description: ownerlist command disabled - default: false - factions.commandDisable.pay: - description: pay command disabled - default: false - factions.commandDisable.peaceful: - description: peaceful command disabled - default: false - factions.commandDisable.permanent: - description: permanent command disabled - default: false - factions.commandDisable.power: - description: power command disabled - default: false - factions.commandDisable.pow: - description: power command disabled - default: false - factions.commandDisable.ally: - description: ally command disabled - default: false - factions.commandDisable.enemy: - description: enemy command disabled - default: false - factions.commandDisable.neutral: - description: neutral command disabled - default: false - factions.commandDisable.reload: - description: reload command disabled - default: false - factions.commandDisable.safeclaim: - description: safeclaim command disabled - default: false - factions.commandDisable.safe: - description: safeclaim command disabled - default: false - factions.commandDisable.safeunclaimall: - description: safeunclaimall command disabled - default: false - factions.commandDisable.safedeclaimall: - description: safeunclaimall command disabled - default: false - factions.commandDisable.saveall: - description: saveall command disabled - default: false - factions.commandDisable.save: - description: saveall command disabled - default: false - factions.commandDisable.sethome: - description: sethome command disabled - default: false - factions.commandDisable.show: - description: show command disabled - default: false - factions.commandDisable.who: - description: show command disabled - default: false - factions.commandDisable.tag: - description: tag command disabled - default: false - factions.commandDisable.title: - description: title command disabled - default: false - factions.commandDisable.unclaim: - description: unclaim command disabled - default: false - factions.commandDisable.declaim: - description: unclaim command disabled - default: false - factions.commandDisable.unclaimall: - description: unclaimall command disabled - default: false - factions.commandDisable.declaimall: - description: unclaimall command disabled - default: false - factions.commandDisable.version: - description: version command disabled - default: false - factions.commandDisable.warclaim: - description: warclaim command disabled - default: false - factions.commandDisable.war: - description: warclaim command disabled - default: false - factions.commandDisable.warunclaimall: - description: warunclaimall command disabled - default: false - factions.commandDisable.wardeclaimall: - description: warunclaimall command disabled - default: false - factions.commandDisable.withdraw: - description: withdraw command disabled - default: false - factions.commandDisable.worldnoclaim: - description: worldnoclaim command disabled - default: false - factions.commandDisable.worldnopowerloss: - description: worldnopowerloss command disabled - default: false + factions.command.deinvite: + description: remove a pending invitation + default: true + factions.command.deposit: + description: deposit money into your faction bank + default: true + factions.command.description: + description: change the faction description + default: true + factions.command.disband: + description: disband a faction + default: true + factions.command.disband.any: + description: disband an other faction + default: op + factions.command.help: + description: display a help page + default: true + factions.command.home: + description: teleport to the faction home + default: true + factions.command.join: + description: join a faction + default: true + factions.command.kick: + description: kick a player from the faction + default: true + factions.command.kick.any: + description: kick anyone from any faction + default: op + factions.command.leave: + description: leave your faction + default: true + factions.command.list: + description: see a list of the factions + default: true + factions.command.lock: + description: lock all write stuff + default: op + factions.command.map: + description: show territory map, set optional auto update + default: true + factions.command.mod: + description: give or revoke moderator rights + default: true \ No newline at end of file