From a0c8fd8d7d81e33cf9f7d85b2f77f6f8252f2305 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sun, 9 Oct 2011 18:35:39 +0200 Subject: [PATCH] herp... --- src/com/massivecraft/factions/Conf.java | 4 - src/com/massivecraft/factions/FLocation.java | 57 +++++--- src/com/massivecraft/factions/FPlayer.java | 12 +- src/com/massivecraft/factions/Faction.java | 8 +- src/com/massivecraft/factions/P.java | 22 ++- src/com/massivecraft/factions/SaveTask.java | 12 -- .../factions/commands/FCommand.java | 5 +- .../factions/commands/FCommandAdmin.java | 3 - .../factions/commands/FCommandAutoClaim.java | 2 - .../factions/commands/FCommandBalance.java | 4 +- .../factions/commands/FCommandBypass.java | 10 +- .../factions/commands/FCommandDeinvite.java | 3 - .../factions/commands/FCommandDeposit.java | 2 +- .../commands/FCommandDescription.java | 6 +- .../factions/commands/FCommandDisband.java | 4 +- .../factions/commands/FCommandHome.java | 2 - .../factions/commands/FCommandInvite.java | 3 - .../factions/commands/FCommandJoin.java | 2 +- .../factions/commands/FCommandKick.java | 1 - .../factions/commands/FCommandMap.java | 2 +- .../factions/commands/FCommandMod.java | 3 - .../factions/commands/FCommandNoBoom.java | 61 ++++---- .../factions/commands/FCommandOpen.java | 57 ++++---- .../factions/commands/FCommandOwner.java | 108 +++++++------- .../factions/commands/FCommandOwnerList.java | 61 +++++--- .../factions/commands/FCommandPay.java | 2 +- .../factions/commands/FCommandPeaceful.java | 87 +++++------ .../factions/commands/FCommandPermanent.java | 83 +++++------ .../factions/commands/FCommandPower.java | 64 +++----- .../commands/FCommandRelationAlly.java | 20 +-- .../commands/FCommandRelationEnemy.java | 20 +-- .../commands/FCommandRelationNeutral.java | 20 +-- .../factions/commands/FCommandReload.java | 108 +++++++------- .../factions/commands/FCommandSafeclaim.java | 75 +++++----- .../commands/FCommandSafeunclaimall.java | 44 +++--- .../factions/commands/FCommandSaveAll.java | 45 +++--- .../factions/commands/FCommandSethome.java | 95 ++++++------ .../factions/commands/FCommandShow.java | 137 +++++++++--------- .../factions/commands/FCommandTag.java | 69 ++++----- .../factions/commands/FCommandTitle.java | 60 ++++---- .../factions/commands/FCommandUnclaim.java | 130 ++++++++++------- .../factions/commands/FCommandUnclaimall.java | 6 +- .../factions/commands/FCommandVersion.java | 35 ++--- .../factions/commands/FCommandWithdraw.java | 2 +- .../factions/commands/FRelationCommand.java | 100 +++++++------ .../listeners/FactionsBlockListener.java | 9 +- .../listeners/FactionsEntityListener.java | 7 +- .../listeners/FactionsPlayerListener.java | 18 +-- .../factions/struct/Permission.java | 21 ++- .../factions/struct/Relation.java | 16 ++ .../massivecraft/factions/zcore/MPlugin.java | 14 +- .../factions/zcore/persist/SaveTask.java | 10 ++ src/plugin.yml | 83 ++++++++--- 53 files changed, 974 insertions(+), 860 deletions(-) delete mode 100644 src/com/massivecraft/factions/SaveTask.java diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index 158d0855..0d76eb3a 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -7,10 +7,6 @@ import org.bukkit.entity.CreatureType; public class Conf { - // track players with admin access who have enabled "admin bypass" mode, and should therefore be able to build anywhere - // 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; diff --git a/src/com/massivecraft/factions/FLocation.java b/src/com/massivecraft/factions/FLocation.java index 56bc5417..2e1ba5eb 100644 --- a/src/com/massivecraft/factions/FLocation.java +++ b/src/com/massivecraft/factions/FLocation.java @@ -8,7 +8,8 @@ import org.bukkit.entity.Player; import com.massivecraft.factions.util.MiscUtil; -public class FLocation { +public class FLocation +{ private String worldName = "world"; private int x = 0; @@ -20,31 +21,37 @@ public class FLocation { // Constructors //----------------------------------------------// - public FLocation() { + public FLocation() + { } - public FLocation(String worldName, int x, int z) { + public FLocation(String worldName, int x, int z) + { this.worldName = worldName; this.x = x; this.z = z; } - public FLocation(Location location) { + public FLocation(Location location) + { // this(location.getWorld().getName(), (int) Math.floor(location.getX() / cellSize) , (int) Math.floor(location.getZ() / cellSize)); // handy dandy rapid bitshifting instead of division this(location.getWorld().getName(), location.getBlockX() >> 4, location.getBlockZ() >> 4); } - public FLocation(Player player) { + public FLocation(Player player) + { this(player.getLocation()); } - public FLocation(FPlayer fplayer) { + public FLocation(FPlayer fplayer) + { this(fplayer.getPlayer()); } - public FLocation(Block block) { + public FLocation(Block block) + { this(block.getLocation()); } @@ -52,31 +59,38 @@ public class FLocation { // Getters and Setters //----------------------------------------------// - public String getWorldName() { + public String getWorldName() + { return worldName; } - public void setWorldName(String worldName) { + public void setWorldName(String worldName) + { this.worldName = worldName; } - public long getX() { + public long getX() + { return x; } - public void setX(int x) { + public void setX(int x) + { this.x = x; } - public long getZ() { + public long getZ() + { return z; } - public void setZ(int z) { + public void setZ(int z) + { this.z = z; } - public String getCoordString() { + public String getCoordString() + { return ""+x+","+z; } @@ -93,11 +107,14 @@ public class FLocation { return new FLocation(this.worldName, this.x + dx, this.z + dz); } - public static HashSet getArea(FLocation from, FLocation to) { + public static HashSet getArea(FLocation from, FLocation to) + { HashSet ret = new HashSet(); - for (long x : MiscUtil.range(from.getX(), to.getX())) { - for (long z : MiscUtil.range(from.getZ(), to.getZ())) { + for (long x : MiscUtil.range(from.getX(), to.getX())) + { + for (long z : MiscUtil.range(from.getZ(), to.getZ())) + { ret.add(new FLocation(from.getWorldName(), (int)x, (int)z)); } } @@ -110,7 +127,8 @@ public class FLocation { //----------------------------------------------// @Override - public int hashCode() { + public int hashCode() + { int hash = 3; hash = 19 * hash + (this.worldName != null ? this.worldName.hashCode() : 0); hash = 19 * hash + this.x; @@ -119,7 +137,8 @@ public class FLocation { }; @Override - public boolean equals(Object obj) { + public boolean equals(Object obj) + { if (obj == this) return true; if (!(obj instanceof FLocation)) diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index 6dc69433..4996ee74 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -103,6 +103,10 @@ public class FPlayer extends PlayerEntity } } + private transient boolean isAdminBypassing = false; + public boolean isAdminBypassing() { return this.isAdminBypassing; } + public void setIsAdminBypassing(boolean val) { this.isAdminBypassing = val; } + // FIELD: loginPvpDisabled private transient boolean loginPvpDisabled; @@ -555,7 +559,7 @@ public class FPlayer extends PlayerEntity } // if economy is enabled and they're not on the bypass list, make 'em pay - if (makePay && Econ.enabled() && !Conf.adminBypassPlayers.contains(this.getId())) + if (makePay && Econ.enabled() && ! this.isAdminBypassing()) { double cost = Conf.econCostLeave; // pay up @@ -625,7 +629,7 @@ public class FPlayer extends PlayerEntity return false; } - if (myFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers && !Conf.adminBypassPlayers.contains(this.getId())) + if (myFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers && ! this.isAdminBypassing()) { sendMessage("Your faction must have at least "+Conf.claimsRequireMinFactionMembers+" members to claim land."); return false; @@ -667,7 +671,7 @@ public class FPlayer extends PlayerEntity if ( Conf.claimsMustBeConnected - && !Conf.adminBypassPlayers.contains(this.getId()) + && ! this.isAdminBypassing() && myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.isConnectedLocation(flocation, myFaction) && (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !otherFaction.isNormal()) @@ -709,7 +713,7 @@ public class FPlayer extends PlayerEntity } // if economy is enabled and they're not on the bypass list, make 'em pay - if (Econ.enabled() && !Conf.adminBypassPlayers.contains(this.getId())) + if (Econ.enabled() && ! this.isAdminBypassing()) { double cost = Econ.calculateClaimCost(ownedLand, otherFaction.isNormal()); String costString = Econ.moneyString(cost); diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index c6f48e08..51c0dd70 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -46,8 +46,10 @@ public class Faction extends Entity // FIELD: peacefulExplosionsEnabled private boolean peacefulExplosionsEnabled; - public void setPeacefulExplosions(boolean disable) { peacefulExplosionsEnabled = disable; } //TODO: Convert to argswitch in command!! - public void setPeacefulExplosions() { setPeacefulExplosions(!peacefulExplosionsEnabled); } + public void setPeacefulExplosionsEnabled(boolean val) { peacefulExplosionsEnabled = val; } + public boolean getPeacefulExplosionsEnabled(){ return this.peacefulExplosionsEnabled; } + + public boolean noExplosionsInTerritory() { return this.peaceful && ! peacefulExplosionsEnabled; } // FIELD: permanent // "permanent" status can only be set by server admins/moderators/ops, and allows the faction to remain even with 0 members @@ -157,7 +159,7 @@ public class Faction extends Entity public boolean noMonstersInTerritory() { return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisableMonsters); } - public boolean noExplosionsInTerritory() { return peaceful && !peacefulExplosionsEnabled; } + // ------------------------------- // Understand the types diff --git a/src/com/massivecraft/factions/P.java b/src/com/massivecraft/factions/P.java index 431c7de8..bf168616 100644 --- a/src/com/massivecraft/factions/P.java +++ b/src/com/massivecraft/factions/P.java @@ -197,9 +197,18 @@ public class P extends MPlugin @Override public void onDisable() { + Board.save(); + Conf.save(); unhookEssentialsChat(); super.onDisable(); } + + @Override + public void postSaveTask() + { + Board.save(); + Conf.save(); + } // -------------------------------------------- // // Integration with other plugins @@ -500,17 +509,4 @@ public class P extends MPlugin } */ - // -------------------------------------------- // - // Save all - // -------------------------------------------- // - - // TODO: Add a hook to this?? - public static void saveAll() - { - // FPlayer.save(); - // Faction.save(); - Board.save(); - Conf.save(); - } - } diff --git a/src/com/massivecraft/factions/SaveTask.java b/src/com/massivecraft/factions/SaveTask.java deleted file mode 100644 index c187be1a..00000000 --- a/src/com/massivecraft/factions/SaveTask.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.massivecraft.factions; - -public class SaveTask implements Runnable { - - //TODO are they removed on disable? - - @Override - public void run() { - P.saveAll(); - } - -} diff --git a/src/com/massivecraft/factions/commands/FCommand.java b/src/com/massivecraft/factions/commands/FCommand.java index cd46bd44..68e37a89 100644 --- a/src/com/massivecraft/factions/commands/FCommand.java +++ b/src/com/massivecraft/factions/commands/FCommand.java @@ -31,6 +31,7 @@ public abstract class FCommand extends MCommand

} public FPlayer fme; + public Faction myFaction; public boolean senderMustBeMember; public boolean senderMustBeModerator; public boolean senderMustBeAdmin; @@ -49,10 +50,12 @@ public abstract class FCommand extends MCommand

if (sender instanceof Player) { this.fme = FPlayers.i.get((Player)sender); + this.myFaction = this.fme.getFaction(); } else { this.fme = null; + this.myFaction = null; } super.execute(sender, args, commandChain); } @@ -267,7 +270,7 @@ 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.fme == null || cost == 0.0 || Conf.adminBypassPlayers.contains(fme.getName())) + if ( ! Econ.enabled() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) { return true; } diff --git a/src/com/massivecraft/factions/commands/FCommandAdmin.java b/src/com/massivecraft/factions/commands/FCommandAdmin.java index 9a7ad27a..832da6a5 100644 --- a/src/com/massivecraft/factions/commands/FCommandAdmin.java +++ b/src/com/massivecraft/factions/commands/FCommandAdmin.java @@ -2,7 +2,6 @@ package com.massivecraft.factions.commands; 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; @@ -36,8 +35,6 @@ public class FCommandAdmin extends FCommand 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)); diff --git a/src/com/massivecraft/factions/commands/FCommandAutoClaim.java b/src/com/massivecraft/factions/commands/FCommandAutoClaim.java index 3fbb2af8..0ca8ad37 100644 --- a/src/com/massivecraft/factions/commands/FCommandAutoClaim.java +++ b/src/com/massivecraft/factions/commands/FCommandAutoClaim.java @@ -2,7 +2,6 @@ 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.Permission; public class FCommandAutoClaim extends FCommand @@ -42,7 +41,6 @@ public class FCommandAutoClaim extends FCommand return; } - Faction myFaction = fme.getFaction(); FLocation flocation = new FLocation(fme); if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) diff --git a/src/com/massivecraft/factions/commands/FCommandBalance.java b/src/com/massivecraft/factions/commands/FCommandBalance.java index d635bdb7..d0a38367 100644 --- a/src/com/massivecraft/factions/commands/FCommandBalance.java +++ b/src/com/massivecraft/factions/commands/FCommandBalance.java @@ -32,10 +32,10 @@ public class FCommandBalance extends FCommand return; } - Faction faction = this.argAsFaction(0, fme.getFaction()); + Faction faction = this.argAsFaction(0, myFaction); // TODO MAKE HIERARCHIAL COMMAND STRUCTURE HERE - if ( faction != fme.getFaction() && ! Permission.VIEW_ANY_FACTION_BALANCE.has(sender)) + if ( faction != myFaction && ! Permission.VIEW_ANY_FACTION_BALANCE.has(sender)) { sendMessageParsed("You do not have sufficient permissions to view the bank balance of other factions."); return; diff --git a/src/com/massivecraft/factions/commands/FCommandBypass.java b/src/com/massivecraft/factions/commands/FCommandBypass.java index e60c8757..26d8addd 100644 --- a/src/com/massivecraft/factions/commands/FCommandBypass.java +++ b/src/com/massivecraft/factions/commands/FCommandBypass.java @@ -1,10 +1,8 @@ package com.massivecraft.factions.commands; -import com.massivecraft.factions.Conf; import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission; - public class FCommandBypass extends FCommand { public FCommandBypass() @@ -15,7 +13,7 @@ public class FCommandBypass extends FCommand //this.requiredArgs.add(""); this.optionalArgs.put("on/off", "flipp"); - this.permission = Permission.ADMIN_BYPASS.node; + this.permission = Permission.COMMAND_BYPASS.node; senderMustBePlayer = true; senderMustBeMember = false; @@ -26,16 +24,16 @@ public class FCommandBypass extends FCommand @Override public void perform() { + fme.setIsAdminBypassing(this.argAsBool(0, ! fme.isAdminBypassing())); + // TODO: Move this to a transient field in the model?? - if ( ! Conf.adminBypassPlayers.contains(fme.getName())) + if ( fme.isAdminBypassing()) { - 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/FCommandDeinvite.java b/src/com/massivecraft/factions/commands/FCommandDeinvite.java index 1905a6ef..33527e7e 100644 --- a/src/com/massivecraft/factions/commands/FCommandDeinvite.java +++ b/src/com/massivecraft/factions/commands/FCommandDeinvite.java @@ -1,7 +1,6 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission; public class FCommandDeinvite extends FCommand @@ -36,8 +35,6 @@ public class FCommandDeinvite extends FCommand FPlayer you = this.argAsBestFPlayerMatch(0); if (you == null) return; - Faction myFaction = fme.getFaction(); - if (you.getFaction() == myFaction) { sendMessageParsed("%s is already a member of %s", you.getName(), myFaction.getTag()); diff --git a/src/com/massivecraft/factions/commands/FCommandDeposit.java b/src/com/massivecraft/factions/commands/FCommandDeposit.java index 67f2615a..db3ce728 100644 --- a/src/com/massivecraft/factions/commands/FCommandDeposit.java +++ b/src/com/massivecraft/factions/commands/FCommandDeposit.java @@ -33,7 +33,7 @@ public class FCommandDeposit extends FCommand { if ( ! Conf.bankEnabled) return; - Faction faction = fme.getFaction(); + Faction faction = myFaction; double amount = this.argAsDouble(0, 0); diff --git a/src/com/massivecraft/factions/commands/FCommandDescription.java b/src/com/massivecraft/factions/commands/FCommandDescription.java index 122fb700..cb88392c 100644 --- a/src/com/massivecraft/factions/commands/FCommandDescription.java +++ b/src/com/massivecraft/factions/commands/FCommandDescription.java @@ -39,13 +39,13 @@ public class FCommandDescription extends FCommand return; } - fme.getFaction().setDescription(TextUtil.implode(args, " ")); + myFaction.setDescription(TextUtil.implode(args, " ")); // Broadcast the description to everyone 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()); + fplayer.sendMessageParsed("The faction "+fplayer.getRelationColor(fme)+myFaction.getTag()+" changed their description to:"); + fplayer.sendMessageParsed(""+myFaction.getDescription()); } } diff --git a/src/com/massivecraft/factions/commands/FCommandDisband.java b/src/com/massivecraft/factions/commands/FCommandDisband.java index 63e889ab..f4541905 100644 --- a/src/com/massivecraft/factions/commands/FCommandDisband.java +++ b/src/com/massivecraft/factions/commands/FCommandDisband.java @@ -33,10 +33,10 @@ public class FCommandDisband extends FCommand public void perform() { // The faction, default to your own.. but null if console sender. - Faction faction = this.argAsFaction(0, fme == null ? null : fme.getFaction()); + Faction faction = this.argAsFaction(0, fme == null ? null : myFaction); if (faction == null) return; - boolean isMyFaction = fme == null ? false : faction == fme.getFaction(); + boolean isMyFaction = fme == null ? false : faction == myFaction; if (isMyFaction) { diff --git a/src/com/massivecraft/factions/commands/FCommandHome.java b/src/com/massivecraft/factions/commands/FCommandHome.java index e712ae2d..c36afc88 100644 --- a/src/com/massivecraft/factions/commands/FCommandHome.java +++ b/src/com/massivecraft/factions/commands/FCommandHome.java @@ -49,8 +49,6 @@ public class FCommandHome extends FCommand return; } - Faction myFaction = fme.getFaction(); - if ( ! myFaction.hasHome()) { fme.sendMessage("You faction does not have a home. " + (fme.getRole().value < Role.MODERATOR.value ? " Ask your leader to:" : "You should:")); diff --git a/src/com/massivecraft/factions/commands/FCommandInvite.java b/src/com/massivecraft/factions/commands/FCommandInvite.java index 4030479c..2fa8b69a 100644 --- a/src/com/massivecraft/factions/commands/FCommandInvite.java +++ b/src/com/massivecraft/factions/commands/FCommandInvite.java @@ -2,7 +2,6 @@ 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; public class FCommandInvite extends FCommand @@ -36,8 +35,6 @@ public class FCommandInvite extends FCommand FPlayer you = this.argAsBestFPlayerMatch(0); if (you == null) return; - Faction myFaction = fme.getFaction(); - if (you.getFaction() == myFaction) { sendMessageParsed("%s is already a member of %s", you.getName(), myFaction.getTag()); diff --git a/src/com/massivecraft/factions/commands/FCommandJoin.java b/src/com/massivecraft/factions/commands/FCommandJoin.java index 7a4c00d6..c343a0b9 100644 --- a/src/com/massivecraft/factions/commands/FCommandJoin.java +++ b/src/com/massivecraft/factions/commands/FCommandJoin.java @@ -40,7 +40,7 @@ public class FCommandJoin extends FCommand return; } - if (faction == fme.getFaction()) + if (faction == myFaction) { sendMessageParsed("You are already a member of %s", faction.getTag(fme)); return; diff --git a/src/com/massivecraft/factions/commands/FCommandKick.java b/src/com/massivecraft/factions/commands/FCommandKick.java index 1a20ab4e..8bae11f2 100644 --- a/src/com/massivecraft/factions/commands/FCommandKick.java +++ b/src/com/massivecraft/factions/commands/FCommandKick.java @@ -45,7 +45,6 @@ public class FCommandKick extends FCommand } Faction yourFaction = you.getFaction(); - Faction myFaction = fme.getFaction(); // players with admin-level "disband" permission can bypass these requirements if ( ! Permission.COMMAND_KICK_ANY.has(sender)) diff --git a/src/com/massivecraft/factions/commands/FCommandMap.java b/src/com/massivecraft/factions/commands/FCommandMap.java index d9303404..3061a6c0 100644 --- a/src/com/massivecraft/factions/commands/FCommandMap.java +++ b/src/com/massivecraft/factions/commands/FCommandMap.java @@ -60,7 +60,7 @@ public class FCommandMap extends FCommand public void showMap() { - sendMessage(Board.getMap(fme.getFaction(), new FLocation(fme), fme.getPlayer().getLocation().getYaw())); + sendMessage(Board.getMap(myFaction, 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 85cdb8a5..306f7515 100644 --- a/src/com/massivecraft/factions/commands/FCommandMod.java +++ b/src/com/massivecraft/factions/commands/FCommandMod.java @@ -1,7 +1,6 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; @@ -36,8 +35,6 @@ public class FCommandMod extends FCommand 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)); diff --git a/src/com/massivecraft/factions/commands/FCommandNoBoom.java b/src/com/massivecraft/factions/commands/FCommandNoBoom.java index f6655cf3..c960d190 100644 --- a/src/com/massivecraft/factions/commands/FCommandNoBoom.java +++ b/src/com/massivecraft/factions/commands/FCommandNoBoom.java @@ -1,58 +1,49 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; - import com.massivecraft.factions.Conf; -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.P; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Permission; -public class FCommandNoBoom extends FCommand { - - public FCommandNoBoom() { - aliases.add("noboom"); +public class FCommandNoBoom extends FCommand +{ + public FCommandNoBoom() + { + super(); + this.aliases.add("noboom"); - helpDescription = "Peaceful factions only: toggle explosions"; + //this.requiredArgs.add(""); + this.optionalArgs.put("on/off", "flipp"); + + this.permission = Permission.COMMAND_NO_BOOM.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; } @Override - public boolean hasPermission(CommandSender sender) { - return P.hasPermPeacefulExplosionToggle(sender); - } - - @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - if ( ! assertMinRole(Role.MODERATOR)) { - return; - } - - Faction myFaction = fme.getFaction(); - - if (!myFaction.isPeaceful()) { - fme.sendMessage("This command is only usable by factions which are specially designated as peaceful."); + if ( ! myFaction.isPeaceful()) + { + fme.sendMessageParsed("This command is only usable by factions which are specially designated as peaceful."); 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.econCostNoBoom)) { - return; - } + if ( ! payForCommand(Conf.econCostNoBoom)) return; - myFaction.setPeacefulExplosions(); + myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, ! myFaction.getPeacefulExplosionsEnabled())); String enabled = myFaction.noExplosionsInTerritory() ? "disabled" : "enabled"; // Inform - myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" has "+enabled+" explosions in your faction's territory."); + myFaction.sendMessageParsed("%s has "+enabled+" explosions in your faction's territory.", fme.getNameAndRelevant(myFaction)); } - } diff --git a/src/com/massivecraft/factions/commands/FCommandOpen.java b/src/com/massivecraft/factions/commands/FCommandOpen.java index 47ae03d3..f97d55a3 100644 --- a/src/com/massivecraft/factions/commands/FCommandOpen.java +++ b/src/com/massivecraft/factions/commands/FCommandOpen.java @@ -2,51 +2,52 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.struct.Permission; -public class FCommandOpen extends FCommand { - - public FCommandOpen() { - aliases.add("open"); - aliases.add("close"); +public class FCommandOpen extends FCommand +{ + public FCommandOpen() + { + super(); + this.aliases.add("open"); - helpDescription = "Switch if invitation is required to join"; + //this.requiredArgs.add(""); + this.optionalArgs.put("yes/no", "flipp"); + + this.permission = Permission.COMMAND_OPEN.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; } @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } - - if( isLocked() ) { - sendLockMessage(); - return; - } - - if ( ! assertMinRole(Role.MODERATOR)) + public void perform() + { + if( isLocked() ) { + sendLockMessage(); 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)) - { - return; - } + if ( ! payForCommand(Conf.econCostOpen)) return; - Faction myFaction = fme.getFaction(); - myFaction.setOpen( ! fme.getFaction().getOpen()); + myFaction.setOpen(this.argAsBool(0, ! myFaction.getOpen())); String open = myFaction.getOpen() ? "open" : "closed"; // Inform - myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed the faction to "+open); - for (Faction faction : Faction.getAll()) { - if (faction == fme.getFaction()) { + myFaction.sendMessageParsed("%s changed the faction to ", fme.getNameAndRelevant(myFaction)); + for (Faction faction : Factions.i.get()) + { + if (faction == myFaction) + { continue; } - faction.sendMessage(Conf.colorSystem+"The faction "+myFaction.getTag(faction)+Conf.colorSystem+" is now "+open); + faction.sendMessageParsed("The faction %s is now %s", myFaction.getTag(faction), open); } } diff --git a/src/com/massivecraft/factions/commands/FCommandOwner.java b/src/com/massivecraft/factions/commands/FCommandOwner.java index 6a085882..de310334 100644 --- a/src/com/massivecraft/factions/commands/FCommandOwner.java +++ b/src/com/massivecraft/factions/commands/FCommandOwner.java @@ -4,102 +4,112 @@ import com.massivecraft.factions.Board; import com.massivecraft.factions.Conf; import com.massivecraft.factions.FLocation; 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 FCommandOwner extends FCommand { +public class FCommandOwner extends FCommand +{ - public FCommandOwner() { - aliases.add("owner"); - - optionalParameters.add("player name"); - - helpDescription = "set ownership of claimed land"; + public FCommandOwner() + { + super(); + this.aliases.add("owner"); + + //this.requiredArgs.add(""); + this.optionalArgs.put("player name", "you"); + + this.permission = Permission.COMMAND_OWNER.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } + // TODO: Fix colors! + @Override - public void perform() { - boolean hasBypass = P.hasPermAdminBypass(fme); - + public void perform() + { + if( isLocked() ) + { + sendLockMessage(); + return; + } + + boolean hasBypass = fme.isAdminBypassing(); + if ( ! hasBypass && ! assertHasFaction()) { return; } - if( isLocked() ) { - sendLockMessage(); + if ( ! Conf.ownedAreasEnabled) + { + fme.sendMessageParsed("Sorry, but owned areas are disabled on this server."); return; } - if ( ! Conf.ownedAreasEnabled) { - fme.sendMessage("Sorry, but owned areas are disabled on this server."); + if ( ! hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) + { + fme.sendMessageParsed("Sorry, but you have reached the server's limit of %d owned areas per faction.", Conf.ownedAreasLimitPerFaction); return; } - Faction myFaction = fme.getFaction(); - - if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) { - fme.sendMessage("Sorry, but you have reached the server's limit of "+Conf.ownedAreasLimitPerFaction+" owned areas per faction."); - return; - } - - if (!hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.ADMIN)) { + if ( ! hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.ADMIN)) + { return; } FLocation flocation = new FLocation(fme); - if (Board.getIdAt(flocation) != myFaction.getId()) { - if (!hasBypass) { - fme.sendMessage("This land is not claimed by your faction, so you can't set ownership of it."); + Faction factionHere = Board.getFactionAt(flocation); + if (factionHere != myFaction) + { + if ( ! hasBypass) + { + fme.sendMessageParsed("This land is not claimed by your faction, so you can't set ownership of it."); return; } - myFaction = Board.getFactionAt(flocation); - if (!myFaction.isNormal()) { - fme.sendMessage("This land is not claimed by a faction. Ownership is not possible."); + if ( ! factionHere.isNormal()) + { + fme.sendMessageParsed("This land is not claimed by a faction. Ownership is not possible."); return; } } - FPlayer target; - - if (parameters.size() > 0) { - target = findFPlayer(parameters.get(0), false); - } else { - target = fme; - } - if (target == null) { - return; - } + FPlayer target = this.argAsBestFPlayerMatch(0, fme); + if (target == null) return; String playerName = target.getName(); - if (target.getFaction().getId() != myFaction.getId()) { - fme.sendMessage(playerName + " is not a member of this faction."); + if (target.getFaction() != myFaction) + { + fme.sendMessageParsed("%s is not a member of this faction.", playerName); return; } // if no player name was passed, and this claim does already have owners set, clear them - if (parameters.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) { + if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) + { myFaction.clearClaimOwnership(flocation); - fme.sendMessage("You have cleared ownership for this claimed area."); + fme.sendMessageParsed("You have cleared ownership for this claimed area."); return; } - if (myFaction.isPlayerInOwnerList(playerName, flocation)) { + if (myFaction.isPlayerInOwnerList(playerName, flocation)) + { myFaction.removePlayerAsOwner(playerName, flocation); - fme.sendMessage("You have removed ownership of this claimed land from "+playerName+"."); + fme.sendMessageParsed("You have removed ownership of this claimed land from %s.", playerName); 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.econCostOwner)) { - return; - } + if ( ! payForCommand(Conf.econCostOwner)) return; myFaction.setPlayerAsOwner(playerName, flocation); - fme.sendMessage("You have added "+playerName+" to the owner list for this claimed land."); + fme.sendMessageParsed("You have added %s to the owner list for this claimed land.", playerName); } } diff --git a/src/com/massivecraft/factions/commands/FCommandOwnerList.java b/src/com/massivecraft/factions/commands/FCommandOwnerList.java index b7e2cd2b..b3ae056f 100644 --- a/src/com/massivecraft/factions/commands/FCommandOwnerList.java +++ b/src/com/massivecraft/factions/commands/FCommandOwnerList.java @@ -1,59 +1,72 @@ package com.massivecraft.factions.commands; -import java.util.Set; -import java.util.Iterator; - import com.massivecraft.factions.Board; import com.massivecraft.factions.Conf; import com.massivecraft.factions.FLocation; -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.P; +import com.massivecraft.factions.struct.Permission; -public class FCommandOwnerList extends FCommand { +public class FCommandOwnerList extends FCommand +{ - public FCommandOwnerList() { - aliases.add("ownerlist"); - - helpDescription = "list owner(s) of this claimed land"; + public FCommandOwnerList() + { + super(); + this.aliases.add("ownerlist"); + + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); + + this.permission = Permission.COMMAND_OWNERLIST.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public void perform() { - boolean hasBypass = P.hasPermAdminBypass(fme); + public void perform() + { + boolean hasBypass = fme.isAdminBypassing(); - if ( ! hasBypass && ! assertHasFaction()) { + if ( ! hasBypass && ! assertHasFaction()) + { return; } - if ( ! Conf.ownedAreasEnabled) { - fme.sendMessage("Owned areas are disabled on this server."); + if ( ! Conf.ownedAreasEnabled) + { + fme.sendMessageParsed("Owned areas are disabled on this server."); return; } - Faction myFaction = fme.getFaction(); FLocation flocation = new FLocation(fme); - if (Board.getIdAt(flocation) != myFaction.getId()) { - if (!hasBypass) { - fme.sendMessage("This land is not claimed by your faction."); + if (Board.getIdAt(flocation) != myFaction.getId()) + { + if (!hasBypass) + { + fme.sendMessageParsed("This land is not claimed by your faction."); return; } myFaction = Board.getFactionAt(flocation); - if (!myFaction.isNormal()) { - fme.sendMessage("This land is not claimed by any faction, thus no owners."); + if (!myFaction.isNormal()) + { + fme.sendMessageParsed("This land is not claimed by any faction, thus no owners."); return; } } String owners = myFaction.getOwnerListString(flocation); - if (owners == null || owners.isEmpty()) { - fme.sendMessage("No owners are set here; everyone in the faction has access."); + if (owners == null || owners.isEmpty()) + { + fme.sendMessageParsed("No owners are set here; everyone in the faction has access."); return; } - fme.sendMessage("Current owner(s) of this land: "+owners); + fme.sendMessageParsed("Current owner(s) of this land: %s", owners); } } diff --git a/src/com/massivecraft/factions/commands/FCommandPay.java b/src/com/massivecraft/factions/commands/FCommandPay.java index 23e284eb..00c94295 100644 --- a/src/com/massivecraft/factions/commands/FCommandPay.java +++ b/src/com/massivecraft/factions/commands/FCommandPay.java @@ -18,7 +18,7 @@ public class FCommandPay extends FCommand this.requiredArgs.add("faction"); this.requiredArgs.add("amount"); - //this.optionalArgs.put("factiontag", "yours"); + //this.optionalArgs.put("", ""); this.permission = Permission.COMMAND_PAY.node; diff --git a/src/com/massivecraft/factions/commands/FCommandPeaceful.java b/src/com/massivecraft/factions/commands/FCommandPeaceful.java index 44dc9561..c5edf93b 100644 --- a/src/com/massivecraft/factions/commands/FCommandPeaceful.java +++ b/src/com/massivecraft/factions/commands/FCommandPeaceful.java @@ -1,59 +1,62 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; - -import com.massivecraft.factions.Conf; +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; -public class FCommandPeaceful extends FCommand { +public class FCommandPeaceful extends FCommand +{ - public FCommandPeaceful() { - aliases.add("peaceful"); + public FCommandPeaceful() + { + super(); + this.aliases.add("peaceful"); + + this.requiredArgs.add("faction tag"); + //this.optionalArgs.put("", ""); + + this.permission = Permission.COMMAND_SET_PEACEFUL.node; senderMustBePlayer = false; - - requiredParameters.add("faction tag"); - - helpDescription = "Designate a faction as peaceful"; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public boolean hasPermission(CommandSender sender) { - return P.hasPermSetPeaceful(sender); - } - - @Override - public void perform() { - if( parameters.size() > 0) { - Faction faction = Faction.findByTag(parameters.get(0)); - - if (faction == null) { - sendMessage("No faction found with the tag \"" + parameters.get(0) + "\""); - return; - } + public void perform() + { + Faction faction = this.argAsFaction(0); + if (faction == null) return; - String change; - if(faction.isPeaceful()) { - change = "removed peaceful status from"; - faction.setPeaceful(false); - } else { - change = "granted peaceful status to"; - faction.setPeaceful(true); - } - // Inform all players - for (FPlayer fplayer : FPlayer.getAllOnline()) { - if (fplayer.getFaction() == faction) { - fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction."); - } else { - fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\"."); - } - } - - SpoutFeatures.updateAppearances(faction); + String change; + if (faction.isPeaceful()) + { + change = "removed peaceful status from"; + faction.setPeaceful(false); } + else + { + change = "granted peaceful status to"; + faction.setPeaceful(true); + } + + // Inform all players + for (FPlayer fplayer : FPlayers.i.getOnline()) + { + if (fplayer.getFaction() == faction) + { + fplayer.sendMessageParsed(fme.getNameAndRelevant(fplayer)+" has "+change+" your faction."); + } + else + { + fplayer.sendMessageParsed(fme.getNameAndRelevant(fplayer)+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\"."); + } + } + + SpoutFeatures.updateAppearances(faction); } } diff --git a/src/com/massivecraft/factions/commands/FCommandPermanent.java b/src/com/massivecraft/factions/commands/FCommandPermanent.java index 6d81746a..7298b694 100644 --- a/src/com/massivecraft/factions/commands/FCommandPermanent.java +++ b/src/com/massivecraft/factions/commands/FCommandPermanent.java @@ -1,57 +1,58 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; - -import com.massivecraft.factions.Conf; +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; -public class FCommandPermanent extends FCommand { - - public FCommandPermanent() { - aliases.add("permanent"); +public class FCommandPermanent extends FCommand +{ + public FCommandPermanent() + { + super(); + this.aliases.add("permanent"); + + this.requiredArgs.add("faction tag"); + //this.optionalArgs.put("", ""); + + this.permission = Permission.COMMAND_SET_PERMANENT.node; senderMustBePlayer = false; - - requiredParameters.add("faction tag"); - - helpDescription = "Designate a faction as permanent"; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public boolean hasPermission(CommandSender sender) { - return P.hasPermSetPermanent(sender); - } - - @Override - public void perform() { - if( parameters.size() > 0) { - Faction faction = Faction.findByTag(parameters.get(0)); - - if (faction == null) { - sendMessage("No faction found with the tag \"" + parameters.get(0) + "\""); - return; + public void perform() + { + Faction faction = this.argAsFaction(0); + if (faction == null) return; + + String change; + if(faction.isPermanent()) + { + change = "removed permanent status from"; + faction.setPermanent(false); + } + else + { + change = "added permanent status to"; + faction.setPermanent(true); + } + + // Inform all players + for (FPlayer fplayer : FPlayers.i.getOnline()) + { + if (fplayer.getFaction() == faction) + { + fplayer.sendMessageParsed(fme.getNameAndRelevant(fplayer)+" has "+change+" your faction."); } - - String change; - if(faction.isPermanent()) { - change = "removed permanent status from"; - faction.setPermanent(false); - } else { - change = "added permanent status to"; - faction.setPermanent(true); - } - // Inform all players - for (FPlayer fplayer : FPlayer.getAllOnline()) { - if (fplayer.getFaction() == faction) { - fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction."); - } else { - fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\"."); - } + else + { + fplayer.sendMessageParsed(fme.getNameAndRelevant(fplayer)+" 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 3a5ffb95..b4e9f54c 100644 --- a/src/com/massivecraft/factions/commands/FCommandPower.java +++ b/src/com/massivecraft/factions/commands/FCommandPower.java @@ -1,57 +1,41 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - import com.massivecraft.factions.Conf; -import com.massivecraft.factions.P; import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.struct.Permission; - -public class FCommandPower extends FCommand { +public class FCommandPower extends FCommand +{ - public FCommandPower() { - aliases.add("power"); - aliases.add("pow"); + public FCommandPower() + { + super(); + this.aliases.add("power"); + this.aliases.add("pow"); + + //this.requiredArgs.add("faction tag"); + this.optionalArgs.put("player name", "you"); + + this.permission = Permission.COMMAND_POWER.node; senderMustBePlayer = false; - - optionalParameters.add("player name"); - - helpDescription = "show player power info"; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public boolean hasPermission(CommandSender sender) { - return true; - } - - @Override - public void perform() { - FPlayer target; - if (parameters.size() > 0) { - 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); - } else if (!(sender instanceof Player)) { - sendMessage("From the console, you must specify a player (f power )."); - return; - } else { - target = fme; - } - - if (target == null) { - return; - } + public void perform() + { + FPlayer target = this.argAsBestFPlayerMatch(0, fme); + if (target == null) return; + + if (target != me && ! Permission.COMMAND_POWER_ANY.has(sender, true)) 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.econCostPower)) { - return; - } + if ( ! payForCommand(Conf.econCostPower)) return; - sendMessage(target.getNameAndRelevant(fme)+Conf.colorChrome+" - Power / Maxpower: "+Conf.colorSystem+target.getPowerRounded()+" / "+target.getPowerMaxRounded()); + sendMessageParsed("%s - Power / Maxpower: %d / %d", target.getNameAndRelevant(fme), target.getPowerRounded(), target.getPowerMaxRounded()); } } diff --git a/src/com/massivecraft/factions/commands/FCommandRelationAlly.java b/src/com/massivecraft/factions/commands/FCommandRelationAlly.java index 44331766..72f9a4b4 100644 --- a/src/com/massivecraft/factions/commands/FCommandRelationAlly.java +++ b/src/com/massivecraft/factions/commands/FCommandRelationAlly.java @@ -2,21 +2,11 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.struct.Relation; -public class FCommandRelationAlly extends FRelationCommand { - - public FCommandRelationAlly() { +public class FCommandRelationAlly extends FRelationCommand +{ + public FCommandRelationAlly() + { aliases.add("ally"); + targetRelation = Relation.ALLY; } - - @Override - public void perform() { - - if( isLocked() ) { - sendLockMessage(); - return; - } - - relation(Relation.ALLY, parameters.get(0)); - } - } diff --git a/src/com/massivecraft/factions/commands/FCommandRelationEnemy.java b/src/com/massivecraft/factions/commands/FCommandRelationEnemy.java index 3504afa8..37387df4 100644 --- a/src/com/massivecraft/factions/commands/FCommandRelationEnemy.java +++ b/src/com/massivecraft/factions/commands/FCommandRelationEnemy.java @@ -2,21 +2,11 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.struct.Relation; -public class FCommandRelationEnemy extends FRelationCommand { - - public FCommandRelationEnemy() { +public class FCommandRelationEnemy extends FRelationCommand +{ + public FCommandRelationEnemy() + { aliases.add("enemy"); + targetRelation = Relation.ENEMY; } - - @Override - public void perform() { - - if( isLocked() ) { - sendLockMessage(); - return; - } - - relation(Relation.ENEMY, parameters.get(0)); - } - } diff --git a/src/com/massivecraft/factions/commands/FCommandRelationNeutral.java b/src/com/massivecraft/factions/commands/FCommandRelationNeutral.java index e7edcf0c..58d67629 100644 --- a/src/com/massivecraft/factions/commands/FCommandRelationNeutral.java +++ b/src/com/massivecraft/factions/commands/FCommandRelationNeutral.java @@ -2,21 +2,11 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.struct.Relation; -public class FCommandRelationNeutral extends FRelationCommand { - - public FCommandRelationNeutral() { +public class FCommandRelationNeutral extends FRelationCommand +{ + public FCommandRelationNeutral() + { aliases.add("neutral"); + targetRelation = Relation.NEUTRAL; } - - @Override - public void perform() { - - if( isLocked() ) { - sendLockMessage(); - return; - } - - relation(Relation.NEUTRAL, parameters.get(0)); - } - } diff --git a/src/com/massivecraft/factions/commands/FCommandReload.java b/src/com/massivecraft/factions/commands/FCommandReload.java index 51399144..34344733 100644 --- a/src/com/massivecraft/factions/commands/FCommandReload.java +++ b/src/com/massivecraft/factions/commands/FCommandReload.java @@ -1,77 +1,77 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; - import com.massivecraft.factions.Board; import com.massivecraft.factions.Conf; -import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.Faction; +import com.massivecraft.factions.FPlayers; +import com.massivecraft.factions.Factions; import com.massivecraft.factions.P; +import com.massivecraft.factions.struct.Permission; -public class FCommandReload extends FCommand { +public class FCommandReload extends FCommand +{ - public FCommandReload() { - aliases.add("reload"); + public FCommandReload() + { + super(); + this.aliases.add("reload"); + + //this.requiredArgs.add(""); + this.optionalArgs.put("file", "all"); + + this.permission = Permission.COMMAND_RELOAD.node; senderMustBePlayer = false; - - optionalParameters.add("file"); - - helpDescription = "reloads all json files, or a specific one"; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public boolean hasPermission(CommandSender sender) { - return P.hasPermReload(sender); - } - - @Override - public void perform() { - P.log("=== RELOAD START ==="); + public void perform() + { long timeInitStart = System.currentTimeMillis(); - String fileName = "s"; + String file = this.argAsString(0, "all").toLowerCase(); - // Was a single file specified? - if (parameters.size() > 0) { - String file = parameters.get(0); - if (file.equalsIgnoreCase("conf") || file.equalsIgnoreCase("conf.json")) { - P.log("RELOADING CONF.JSON"); - Conf.load(); - fileName = " conf.json"; - } - else if (file.equalsIgnoreCase("board") || file.equalsIgnoreCase("board.json")) { - P.log("RELOADING BOARD.JSON"); - Board.load(); - fileName = " board.json"; - } - else if (file.equalsIgnoreCase("factions") || file.equalsIgnoreCase("factions.json")) { - P.log("RELOADING FACTIONS.JSON"); - Faction.load(); - fileName = " factions.json"; - } - else if (file.equalsIgnoreCase("players") || file.equalsIgnoreCase("players.json")) { - P.log("RELOADING PLAYERS.JSON"); - FPlayer.load(); - fileName = " players.json"; - } - else { - P.log("RELOAD CANCELLED - SPECIFIED FILE INVALID"); - sendMessage("Invalid file specified. Valid files: conf, board, factions, players."); - return; - } - } - else { - P.log("RELOADING ALL FILES"); + String fileName; + + if (file.startsWith("c")) + { Conf.load(); - FPlayer.load(); - Faction.load(); + fileName = "conf.json"; + } + else if (file.startsWith("b")) + { Board.load(); + fileName = "board.json"; + } + else if (file.startsWith("f")) + { + Factions.i.loadFromDisc(); + fileName = "factions.json"; + } + else if (file.startsWith("p")) + { + FPlayers.i.loadFromDisc(); + fileName = "players.json"; + } + else if (file.startsWith("a")) + { + fileName = "all"; + Conf.load(); + FPlayers.i.loadFromDisc(); + Factions.i.loadFromDisc(); + Board.load(); + } + else + { + P.p.log("RELOAD CANCELLED - SPECIFIED FILE INVALID"); + sendMessageParsed("Invalid file specified. Valid files: all, conf, board, factions, players"); + return; } long timeReload = (System.currentTimeMillis()-timeInitStart); - P.log("=== RELOAD DONE (Took "+timeReload+"ms) ==="); - sendMessage("Factions file" + fileName + " reloaded from disk, took " + timeReload + "ms"); + sendMessageParsed("reloaded %s from disk, took %dms", fileName, timeReload); } } diff --git a/src/com/massivecraft/factions/commands/FCommandSafeclaim.java b/src/com/massivecraft/factions/commands/FCommandSafeclaim.java index b91bc3cf..b368d24e 100644 --- a/src/com/massivecraft/factions/commands/FCommandSafeclaim.java +++ b/src/com/massivecraft/factions/commands/FCommandSafeclaim.java @@ -1,32 +1,36 @@ 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 FCommandSafeclaim extends FCommand { +public class FCommandSafeclaim extends FCommand +{ - public FCommandSafeclaim() { - aliases.add("safeclaim"); - aliases.add("safe"); + public FCommandSafeclaim() + { + this.aliases.add("safeclaim"); + this.aliases.add("safe"); - optionalParameters.add("radius"); + //this.requiredArgs.add(""); + this.optionalArgs.put("radius", "0"); - helpDescription = "Claim land for the safezone"; + this.permission = Permission.MANAGE_SAFE_ZONE.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + + this.setHelpShort("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; } @@ -34,31 +38,18 @@ public class FCommandSafeclaim extends FCommand { // The current location of the player FLocation playerFlocation = new FLocation(fme); - // Was a radius set? - if (parameters.size() > 0) { - int radius; - try { - radius = Integer.parseInt(parameters.get(0)); - } - catch(NumberFormatException ex) { - sendMessage("Usage: " + getUseageTemplate(false)); - sendMessage("The radius value must be an integer."); - return; - } - - FLocation from = playerFlocation.getRelative(radius, radius); - FLocation to = playerFlocation.getRelative(-radius, -radius); - - for (FLocation locToClaim : FLocation.getArea(from, to)) { - Board.setFactionAt(Faction.getSafeZone(), locToClaim); - } - - sendMessage("You claimed "+(1+radius*2)*(1+radius*2)+" chunks for the safe zone."); - - } else { - Board.setFactionAt(Faction.getSafeZone(), playerFlocation); - sendMessage("This land is now a safe zone."); + int radius = this.argAsInt(0, 0); + if (radius < 0) radius = 0; + + FLocation from = playerFlocation.getRelative(radius, radius); + FLocation to = playerFlocation.getRelative(-radius, -radius); + + for (FLocation locToClaim : FLocation.getArea(from, to)) + { + Board.setFactionAt(Factions.i.getSafeZone(), locToClaim); } + + sendMessageParsed("You claimed %d chunks for the safe zone.", (1+radius*2)*(1+radius*2)); } } diff --git a/src/com/massivecraft/factions/commands/FCommandSafeunclaimall.java b/src/com/massivecraft/factions/commands/FCommandSafeunclaimall.java index 55c5c486..04baaac4 100644 --- a/src/com/massivecraft/factions/commands/FCommandSafeunclaimall.java +++ b/src/com/massivecraft/factions/commands/FCommandSafeunclaimall.java @@ -1,35 +1,41 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; - import com.massivecraft.factions.Board; -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.P; +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.struct.Permission; -public class FCommandSafeunclaimall extends FCommand { +public class FCommandSafeunclaimall extends FCommand +{ - public FCommandSafeunclaimall() { - aliases.add("safeunclaimall"); - aliases.add("safedeclaimall"); + public FCommandSafeunclaimall() + { + this.aliases.add("safeunclaimall"); + this.aliases.add("safedeclaimall"); - helpDescription = "Unclaim all safezone land"; + //this.requiredArgs.add(""); + this.optionalArgs.put("radius", "0"); + + this.permission = Permission.MANAGE_SAFE_ZONE.node; + + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + + this.setHelpShort("Unclaim all safezone land"); } @Override - public boolean hasPermission(CommandSender sender) { - return P.hasPermManageSafeZone(sender); - } - - @Override - public void perform() { - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - Board.unclaimAll(Faction.getSafeZone().getId()); - sendMessage("You unclaimed ALL safe zone land."); + Board.unclaimAll(Factions.i.getSafeZone().getId()); + sendMessageParsed("You unclaimed ALL safe zone land."); } } diff --git a/src/com/massivecraft/factions/commands/FCommandSaveAll.java b/src/com/massivecraft/factions/commands/FCommandSaveAll.java index f15ff337..5a27a095 100644 --- a/src/com/massivecraft/factions/commands/FCommandSaveAll.java +++ b/src/com/massivecraft/factions/commands/FCommandSaveAll.java @@ -1,30 +1,39 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; +import com.massivecraft.factions.Board; +import com.massivecraft.factions.Conf; +import com.massivecraft.factions.FPlayers; +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.P; - -public class FCommandSaveAll extends FCommand { +public class FCommandSaveAll extends FCommand +{ - public FCommandSaveAll() { - aliases.add("saveall"); - aliases.add("save"); + public FCommandSaveAll() + { + super(); + this.aliases.add("saveall"); + this.aliases.add("save"); + + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); + + this.permission = Permission.COMMAND_SAVE.node; senderMustBePlayer = false; - - helpDescription = "save factions to disk"; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public boolean hasPermission(CommandSender sender) { - return P.hasPermSaveAll(sender); - } - - @Override - public void perform() { - P.saveAll(); - - sendMessage("Factions saved to disk!"); + public void perform() + { + FPlayers.i.saveToDisc(); + Factions.i.saveToDisc(); + Board.save(); + Conf.save(); + sendMessageParsed("Factions saved to disk!"); } } diff --git a/src/com/massivecraft/factions/commands/FCommandSethome.java b/src/com/massivecraft/factions/commands/FCommandSethome.java index 6e355e62..bbb7f321 100644 --- a/src/com/massivecraft/factions/commands/FCommandSethome.java +++ b/src/com/massivecraft/factions/commands/FCommandSethome.java @@ -1,72 +1,81 @@ package com.massivecraft.factions.commands; +import com.massivecraft.factions.Board; import com.massivecraft.factions.Conf; +import com.massivecraft.factions.FLocation; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.P; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; -public class FCommandSethome extends FCommand { - - public FCommandSethome() { - aliases.add("sethome"); +public class FCommandSethome extends FCommand +{ + public FCommandSethome() + { + this.aliases.add("sethome"); - optionalParameters.add("faction tag"); + //this.requiredArgs.add(""); + this.optionalArgs.put("faction tag", "mine"); - helpDescription = "Set the faction home"; + this.permission = Permission.COMMAND_SETHOME.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public void perform() { - if ( ! assertHasFaction()) { - return; - } - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - if ( ! assertMinRole(Role.MODERATOR)) { + if ( ! Conf.homesEnabled) + { + fme.sendMessageParsed("Sorry, Faction homes are disabled on this server."); return; } - if ( ! Conf.homesEnabled) { - fme.sendMessage("Sorry, Faction homes are disabled on this server."); - return; + Faction faction = this.argAsFaction(0, myFaction); + if (faction == null) return; + + // Can the player set the home for this faction? + if (faction == myFaction) + { + if ( ! Permission.COMMAND_SETHOME_ANY.has(sender) && ! assertMinRole(Role.MODERATOR)) return; + } + else + { + if (Permission.COMMAND_SETHOME_ANY.has(sender, true)) return; } - Faction myFaction = fme.getFaction(); - - if (parameters.size() > 0) { - 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) { - fme.sendMessage("No such faction seems to exist."); - return; - } - } - - if (Conf.homesMustBeInClaimedTerritory && !fme.isInOwnTerritory() && !P.hasPermAdminBypass(fme)) { - fme.sendMessage("Sorry, your faction home can only be set inside your own claimed territory."); + // Can the player set the faction home HERE? + if + ( + ! Permission.COMMAND_BYPASS.has(me) + && + Conf.homesMustBeInClaimedTerritory + && + Board.getFactionAt(new FLocation(me)) != faction + ) + { + fme.sendMessageParsed("Sorry, your faction home can only be set inside your own claimed territory."); 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.econCostSethome)) { - return; - } + if ( ! payForCommand(Conf.econCostSethome)) return; - myFaction.setHome(fme.getLocation()); + faction.setHome(me.getLocation()); - myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:"); - myFaction.sendMessage(new FCommandHome().getUseageTemplate()); - if (myFaction != fme.getFaction()) { - fme.sendMessage("You have set the home for the "+myFaction.getTag(fme)+Conf.colorSystem+" faction."); + faction.sendMessage(fme.getNameAndRelevant(myFaction)+" set the home for your faction. You can now use:"); + faction.sendMessage(new FCommandHome().getUseageTemplate()); + if (faction != myFaction) + { + fme.sendMessageParsed("You have set the home for the "+faction.getTag(fme)+" faction."); } } diff --git a/src/com/massivecraft/factions/commands/FCommandShow.java b/src/com/massivecraft/factions/commands/FCommandShow.java index 4d0c4f06..b069b4d9 100644 --- a/src/com/massivecraft/factions/commands/FCommandShow.java +++ b/src/com/massivecraft/factions/commands/FCommandShow.java @@ -2,114 +2,112 @@ package com.massivecraft.factions.commands; import java.util.Collection; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - import com.massivecraft.factions.Conf; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; -import com.massivecraft.factions.util.TextUtil; - -public class FCommandShow extends FCommand { +public class FCommandShow extends FCommand +{ - public FCommandShow() { - aliases.add("show"); - aliases.add("who"); + public FCommandShow() + { + this.aliases.add("show"); + this.aliases.add("who"); - senderMustBePlayer = false; + //this.requiredArgs.add(""); + this.optionalArgs.put("faction tag", "yours"); - optionalParameters.add("faction tag"); + this.permission = Permission.COMMAND_SHOW.node; - helpDescription = "Show faction information"; + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } - - @Override - public boolean hasPermission(CommandSender sender) { - return true; - } - - @Override - public void perform() { - Faction faction; - if (parameters.size() > 0) { - faction = findFaction(parameters.get(0), true); - } else if (!(sender instanceof Player)) { - sendMessage("From the command line, you must specify a faction tag (f who )."); - return; - } else { - faction = fme.getFaction(); - } - if (faction == null) { - return; - } + @Override + public void perform() + { + Faction faction = this.argAsFaction(0, myFaction); + if (faction == null) 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.econCostShow)) { - return; - } + if ( ! payForCommand(Conf.econCostShow)) return; Collection admins = faction.getFPlayersWhereRole(Role.ADMIN); Collection mods = faction.getFPlayersWhereRole(Role.MODERATOR); Collection normals = faction.getFPlayersWhereRole(Role.NORMAL); - sendMessage(TextUtil.titleize(faction.getTag(fme))); - sendMessage(Conf.colorChrome+"Description: "+Conf.colorSystem+faction.getDescription()); - if ( ! faction.isNormal()) { + sendMessageParsed(p.txt.titleize(faction.getTag(fme))); + sendMessageParsed("Description: %s", faction.getDescription()); + if ( ! faction.isNormal()) + { return; } String peaceStatus = ""; - if (faction.isPeaceful()) { + if (faction.isPeaceful()) + { peaceStatus = " "+Conf.colorNeutral+"This faction is Peaceful"; } - sendMessage(Conf.colorChrome+"Joining: "+Conf.colorSystem+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus); - sendMessage(Conf.colorChrome+"Land / Power / Maxpower: "+Conf.colorSystem+ faction.getLandRounded()+" / "+faction.getPowerRounded()+" / "+faction.getPowerMaxRounded()); + sendMessageParsed("Joining: "+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus); + sendMessageParsed("Land / Power / Maxpower: %d/%d/%d", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded()); - if (faction.isPermanent()) { - sendMessage(Conf.colorChrome+"This faction is permanent, remaining even with no members."); + if (faction.isPermanent()) + { + sendMessageParsed("This faction is permanent, remaining even with no members."); } // show the land value - if (Econ.enabled()) { + if (Econ.enabled()) + { double value = Econ.calculateTotalLandValue(faction.getLandRounded()); double refund = value * Conf.econClaimRefundMultiplier; - if (value > 0) { + if (value > 0) + { String stringValue = Econ.moneyString(value); String stringRefund = (refund > 0.0) ? (" ("+Econ.moneyString(refund)+" depreciated)") : ""; - sendMessage(Conf.colorChrome+"Total land value: " + Conf.colorSystem + stringValue + stringRefund); + sendMessageParsed("Total land value: " + stringValue + stringRefund); } //Show bank contents if(Conf.bankEnabled) { - sendMessage(Conf.colorChrome+"Bank contains: " + Conf.colorSystem + Econ.moneyString(faction.getMoney())); + sendMessageParsed("Bank contains: "+Econ.moneyString(faction.getMoney())); } } String listpart; // List relation - String allyList = Conf.colorChrome+"Allies: "; - String enemyList = Conf.colorChrome+"Enemies: "; - for (Faction otherFaction : Faction.getAll()) { - if (otherFaction == faction) { + String allyList = p.txt.parse("Allies: "); + String enemyList = p.txt.parse("Enemies: "); + for (Faction otherFaction : Factions.i.get()) + { + if (otherFaction == faction) + { continue; } - listpart = otherFaction.getTag(fme)+Conf.colorSystem+", "; - if (otherFaction.getRelation(faction).isAlly()) { + listpart = otherFaction.getTag(fme)+p.txt.parse("")+", "; + if (otherFaction.getRelation(faction).isAlly()) + { allyList += listpart; - } else if (otherFaction.getRelation(faction).isEnemy()) { + } + else if (otherFaction.getRelation(faction).isEnemy()) + { enemyList += listpart; } } - if (allyList.endsWith(", ")) { + if (allyList.endsWith(", ")) + { allyList = allyList.substring(0, allyList.length()-2); } - if (enemyList.endsWith(", ")) { + if (enemyList.endsWith(", ")) + { enemyList = enemyList.substring(0, enemyList.length()-2); } @@ -117,26 +115,33 @@ public class FCommandShow extends FCommand { sendMessage(enemyList); // List the members... - String onlineList = Conf.colorChrome+"Members online: "; - String offlineList = Conf.colorChrome+"Members offline: "; - for (FPlayer follower : admins) { - listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", "; - if (follower.isOnline()) { + String onlineList = p.txt.parse("")+"Members online: "; + String offlineList = p.txt.parse("")+"Members offline: "; + for (FPlayer follower : admins) + { + listpart = follower.getNameAndTitle(fme)+p.txt.parse("")+", "; + if (follower.isOnline()) + { onlineList += listpart; - } else { + } + else + { offlineList += listpart; } } - for (FPlayer follower : mods) { - listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", "; - if (follower.isOnline()) { + for (FPlayer follower : mods) + { + listpart = follower.getNameAndTitle(fme)+p.txt.parse("")+", "; + if + (follower.isOnline()) + { onlineList += listpart; } else { offlineList += listpart; } } for (FPlayer follower : normals) { - listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", "; + listpart = follower.getNameAndTitle(fme)+p.txt.parse("")+", "; 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 079d9e93..52c197af 100644 --- a/src/com/massivecraft/factions/commands/FCommandTag.java +++ b/src/com/massivecraft/factions/commands/FCommandTag.java @@ -4,71 +4,74 @@ import java.util.ArrayList; import com.massivecraft.factions.Conf; import com.massivecraft.factions.Faction; +import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.SpoutFeatures; -import com.massivecraft.factions.struct.Role; -import com.massivecraft.factions.util.TextUtil; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.util.MiscUtil; - -public class FCommandTag extends FCommand { +public class FCommandTag extends FCommand +{ - public FCommandTag() { - aliases.add("tag"); + public FCommandTag() + { + this.aliases.add("tag"); - requiredParameters.add("faction tag"); + this.requiredArgs.add("faction tag"); + //this.optionalArgs.put("", ""); - helpDescription = "Change the faction tag"; + this.permission = Permission.COMMAND_TAG.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; - } - - String tag = parameters.get(0); + String tag = this.argAsString(0); // TODO does not first test cover selfcase? - if (Faction.isTagTaken(tag) && ! TextUtil.getComparisonString(tag).equals(fme.getFaction().getComparisonTag())) { - sendMessage("That tag is already taken"); + if (Factions.i.isTagTaken(tag) && ! MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag())) + { + sendMessageParsed("That tag is already taken"); return; } ArrayList errors = new ArrayList(); - errors.addAll(Faction.validateTag(tag)); - if (errors.size() > 0) { + errors.addAll(Factions.validateTag(tag)); + if (errors.size() > 0) + { sendMessage(errors); 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.econCostTag)) { - return; - } - - Faction myFaction = fme.getFaction(); + if ( ! payForCommand(Conf.econCostTag)) return; String oldtag = myFaction.getTag(); myFaction.setTag(tag); // Inform - myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed your faction tag to "+Conf.colorMember+myFaction.getTag()); - for (Faction faction : Faction.getAll()) { - if (faction == fme.getFaction()) { + myFaction.sendMessageParsed("%s changed your faction tag to %s", fme.getNameAndRelevant(myFaction), myFaction.getTag(myFaction)); + for (Faction faction : Factions.i.get()) + { + if (faction == myFaction) + { continue; } - faction.sendMessage(Conf.colorSystem+"The faction "+fme.getRelationColor(faction)+oldtag+Conf.colorSystem+" changed their name to "+myFaction.getTag(faction)); + faction.sendMessageParsed("The faction %s changed their name to %s.", fme.getRelationColor(faction)+oldtag, myFaction.getTag(faction)); } - if (Conf.spoutFactionTagsOverNames) { + if (Conf.spoutFactionTagsOverNames) + { SpoutFeatures.updateAppearances(myFaction); } } diff --git a/src/com/massivecraft/factions/commands/FCommandTitle.java b/src/com/massivecraft/factions/commands/FCommandTitle.java index 610651c2..05c89541 100644 --- a/src/com/massivecraft/factions/commands/FCommandTitle.java +++ b/src/com/massivecraft/factions/commands/FCommandTitle.java @@ -2,59 +2,55 @@ package com.massivecraft.factions.commands; import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.Faction; import com.massivecraft.factions.integration.SpoutFeatures; -import com.massivecraft.factions.util.TextUtil; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.zcore.util.TextUtil; -public class FCommandTitle extends FCommand { - - public FCommandTitle() { - aliases.add("title"); +public class FCommandTitle extends FCommand +{ + public FCommandTitle() + { + this.aliases.add("title"); - requiredParameters.add("player name"); + this.requiredArgs.add("player name"); + this.optionalArgs.put("title", ""); - optionalParameters.add("title"); + this.permission = Permission.COMMAND_TITLE.node; - helpDescription = "Set or remove a players title"; + 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); - parameters.remove(0); - String title = TextUtil.implode(parameters); + FPlayer you = this.argAsBestFPlayerMatch(0); + if (you == null) return; - FPlayer you = findFPlayer(playerName, false); - if (you == null) { - return; - } + args.remove(0); + String title = TextUtil.implode(args, " "); - if ( ! canIAdministerYou(fme, you)) { - return; - } + if ( ! canIAdministerYou(fme, 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.econCostTitle)) { - return; - } + if ( ! payForCommand(Conf.econCostTitle)) return; you.setTitle(title); // Inform - Faction myFaction = fme.getFaction(); - myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed a title: "+you.getNameAndRelevant(myFaction)); + myFaction.sendMessageParsed("%s changed a title: %s", fme.getNameAndRelevant(myFaction), you.getNameAndRelevant(myFaction)); - if (Conf.spoutFactionTitlesOverNames) { - SpoutFeatures.updateAppearances(fme); + if (Conf.spoutFactionTitlesOverNames) + { + SpoutFeatures.updateAppearances(me); } } diff --git a/src/com/massivecraft/factions/commands/FCommandUnclaim.java b/src/com/massivecraft/factions/commands/FCommandUnclaim.java index cc43afd9..c00ed932 100644 --- a/src/com/massivecraft/factions/commands/FCommandUnclaim.java +++ b/src/com/massivecraft/factions/commands/FCommandUnclaim.java @@ -5,22 +5,32 @@ import com.massivecraft.factions.Conf; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.P; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; -public class FCommandUnclaim extends FCommand { - - public FCommandUnclaim() { - aliases.add("unclaim"); - aliases.add("declaim"); +public class FCommandUnclaim extends FCommand +{ + public FCommandUnclaim() + { + this.aliases.add("unclaim"); + this.aliases.add("declaim"); - helpDescription = "Unclaim the land where you are standing"; + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); + + this.permission = Permission.COMMAND_UNCLAIM.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } @Override - public void perform() { - - if( isLocked() ) { + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } @@ -28,88 +38,110 @@ public class FCommandUnclaim extends FCommand { FLocation flocation = new FLocation(fme); Faction otherFaction = Board.getFactionAt(flocation); - if (otherFaction.isSafeZone()) { - if (P.hasPermManageSafeZone(sender)) { + if (otherFaction.isSafeZone()) + { + if (Permission.MANAGE_SAFE_ZONE.has(sender)) + { Board.removeAt(flocation); - sendMessage("Safe zone was unclaimed."); - } else { - sendMessage("This is a safe zone. You lack permissions to unclaim."); + sendMessageParsed("Safe zone was unclaimed."); + } + else + { + sendMessageParsed("This is a safe zone. You lack permissions to unclaim."); } return; } - else if (otherFaction.isWarZone()) { - if (P.hasPermManageWarZone(sender)) { + else if (otherFaction.isWarZone()) + { + if (Permission.MANAGE_WAR_ZONE.has(sender)) + { Board.removeAt(flocation); - sendMessage("War zone was unclaimed."); - } else { - sendMessage("This is a war zone. You lack permissions to unclaim."); + sendMessageParsed("War zone was unclaimed."); + } + else + { + sendMessageParsed("This is a war zone. You lack permissions to unclaim."); } return; } - if (Conf.adminBypassPlayers.contains(fme.getName())) { + if (fme.isAdminBypassing()) + { Board.removeAt(flocation); - otherFaction.sendMessage(fme.getNameAndRelevant(otherFaction)+Conf.colorSystem+" unclaimed some of your land."); - sendMessage("You unclaimed this land."); + otherFaction.sendMessageParsed("%s unclaimed some of your land.", fme.getNameAndRelevant(otherFaction)); + sendMessageParsed("You unclaimed this land."); return; } - if ( ! assertHasFaction()) { + if ( ! assertHasFaction()) + { return; } - if ( ! assertMinRole(Role.MODERATOR)) { + if ( ! assertMinRole(Role.MODERATOR)) + { return; } - Faction myFaction = fme.getFaction(); - - if ( myFaction != otherFaction) { - sendMessage("You don't own this land."); + if ( myFaction != otherFaction) + { + sendMessageParsed("You don't own this land."); return; } - String moneyBack = ""; - if (Econ.enabled()) { + String moneyBack = ""; + if (Econ.enabled()) + { double refund = Econ.calculateClaimRefund(myFaction.getLandRounded()); // a real refund - if (refund > 0.0) { - if(Conf.bankFactionPaysLandCosts) { - Faction faction = fme.getFaction(); + if (refund > 0.0) + { + if(Conf.bankFactionPaysLandCosts) + { + Faction faction = myFaction; faction.addMoney(refund); - moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+"."; - } else { + moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+"."; + } + else + { Econ.addMoney(fme.getName(), refund); - moneyBack = " They received a refund of "+Econ.moneyString(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 = fme.getFaction(); - if(!faction.removeMoney(-refund)) { - sendMessage("Unclaiming this land will cost "+Econ.moneyString(-refund)+", which your faction can't currently afford."); + else if (refund < 0.0) + { + if(Conf.bankFactionPaysLandCosts) + { + Faction faction = myFaction; + if(!faction.removeMoney(-refund)) + { + sendMessageParsed("Unclaiming this land will cost %s which your faction can't currently afford.", Econ.moneyString(-refund)); return; } - moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+"."; - } else { - if (!Econ.deductMoney(fme.getName(), -refund)) { - sendMessage("Unclaiming this land will cost "+Econ.moneyString(-refund)+", which you can't currently afford."); + moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+"."; + } + else + { + if (!Econ.deductMoney(fme.getName(), -refund)) + { + sendMessageParsed("Unclaiming this land will cost %s which you can't currently afford.", Econ.moneyString(-refund)); return; } - moneyBack = " It cost them "+Econ.moneyString(refund)+"."; + moneyBack = " It cost them "+Econ.moneyString(refund)+"."; } } // no refund - else { + else + { moneyBack = ""; } } Board.removeAt(flocation); - myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed some land."+moneyBack); + myFaction.sendMessageParsed("%s unclaimed some land."+moneyBack, fme.getNameAndRelevant(myFaction)); } } diff --git a/src/com/massivecraft/factions/commands/FCommandUnclaimall.java b/src/com/massivecraft/factions/commands/FCommandUnclaimall.java index 111d77c1..c221fb4e 100644 --- a/src/com/massivecraft/factions/commands/FCommandUnclaimall.java +++ b/src/com/massivecraft/factions/commands/FCommandUnclaimall.java @@ -30,15 +30,13 @@ public class FCommandUnclaimall extends FCommand { return; } - Faction myFaction = fme.getFaction(); - String moneyBack = ""; if (Econ.enabled()) { double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded()); // a real refund if (refund > 0.0) { if(Conf.bankFactionPaysLandCosts) { - Faction faction = fme.getFaction(); + Faction faction = myFaction; faction.addMoney(refund); moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+"."; } else { @@ -49,7 +47,7 @@ public class FCommandUnclaimall extends FCommand { // wait, you're charging people to unclaim land? outrageous else if (refund < 0.0) { if(Conf.bankFactionPaysLandCosts) { - Faction faction = fme.getFaction(); + Faction faction = myFaction; if(!faction.removeMoney(-refund)) { sendMessage("Unclaiming all faction land will cost "+Econ.moneyString(-refund)+", which your faction can't currently afford."); return; diff --git a/src/com/massivecraft/factions/commands/FCommandVersion.java b/src/com/massivecraft/factions/commands/FCommandVersion.java index 967ba166..0e1ca647 100644 --- a/src/com/massivecraft/factions/commands/FCommandVersion.java +++ b/src/com/massivecraft/factions/commands/FCommandVersion.java @@ -1,28 +1,29 @@ package com.massivecraft.factions.commands; -import org.bukkit.command.CommandSender; - import com.massivecraft.factions.P; +import com.massivecraft.factions.struct.Permission; -public class FCommandVersion extends FCommand { - - public FCommandVersion() { - aliases.add("version"); +public class FCommandVersion extends FCommand +{ + public FCommandVersion() + { + this.aliases.add("version"); + + //this.requiredArgs.add(""); + //this.optionalArgs.put("", ""); + + this.permission = Permission.COMMAND_VERSION.node; senderMustBePlayer = false; - - helpDescription = "Which version are you using?"; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; } - + @Override - public boolean hasPermission(CommandSender sender) { - return true; + public void perform() + { + sendMessageParsed("You are running "+P.p.getDescription().getFullName()); } - - @Override - public void perform() { - sendMessage("You are running "+P.p.getDescription().getFullName()); - } - } diff --git a/src/com/massivecraft/factions/commands/FCommandWithdraw.java b/src/com/massivecraft/factions/commands/FCommandWithdraw.java index d472db4d..429b5086 100644 --- a/src/com/massivecraft/factions/commands/FCommandWithdraw.java +++ b/src/com/massivecraft/factions/commands/FCommandWithdraw.java @@ -39,7 +39,7 @@ public class FCommandWithdraw extends FCommand return; } - Faction faction = fme.getFaction(); + Faction faction = myFaction; double amount = this.argAsDouble(0, 0d); diff --git a/src/com/massivecraft/factions/commands/FRelationCommand.java b/src/com/massivecraft/factions/commands/FRelationCommand.java index 5f9b45bd..a1762fae 100644 --- a/src/com/massivecraft/factions/commands/FRelationCommand.java +++ b/src/com/massivecraft/factions/commands/FRelationCommand.java @@ -4,76 +4,82 @@ import org.bukkit.ChatColor; import com.massivecraft.factions.Conf; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.P; import com.massivecraft.factions.integration.SpoutFeatures; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; -import com.massivecraft.factions.struct.Role; - -public class FRelationCommand extends FCommand { +public abstract class FRelationCommand extends FCommand +{ + public Relation targetRelation; - public FRelationCommand() { - requiredParameters.add("faction tag"); + public FRelationCommand() + { + super(); + this.requiredArgs.add("faction tag"); + //this.optionalArgs.put("player name", "you"); - helpDescription = "Set relation wish to another faction"; + this.permission = Permission.COMMAND_RELATION.node; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = true; + senderMustBeAdmin = false; } - public void relation(Relation whishedRelation, String otherFactionName) { - if ( ! assertHasFaction()) { - return; - } - - if( isLocked() ) { + @Override + public void perform() + { + if( isLocked() ) + { sendLockMessage(); return; } - if ( ! assertMinRole(Role.MODERATOR)) { + Faction them = this.argAsFaction(0); + + if ( ! them.isNormal()) + { + sendMessageParsed("Nope! You can't."); return; } - Faction myFaction = fme.getFaction(); - Faction otherFaction = findFaction(otherFactionName, false); - if (otherFaction == null) { - return; - } - - if (!otherFaction.isNormal()) { - sendMessage("Nope! You can't :) You can only ally with player factions."); - return; - } - - if (otherFaction == myFaction) { - sendMessage("Nope! You can't declare a relation to yourself :)"); + if (them == myFaction) + { + sendMessageParsed("Nope! You can't declare a relation to yourself :)"); return; } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - double cost = whishedRelation.isAlly() ? Conf.econCostAlly : (whishedRelation.isEnemy() ? Conf.econCostEnemy : Conf.econCostNeutral); - if (!payForCommand(cost)) { - return; - } + if ( ! payForCommand(targetRelation.getRelationCost())) return; - myFaction.setRelationWish(otherFaction, whishedRelation); - Relation currentRelation = myFaction.getRelation(otherFaction, true); + myFaction.setRelationWish(them, targetRelation); + Relation currentRelation = myFaction.getRelation(them, true); ChatColor currentRelationColor = currentRelation.getColor(); - if (whishedRelation.value == currentRelation.value) { - otherFaction.sendMessage(Conf.colorSystem+"Your faction is now "+currentRelationColor+whishedRelation.toString()+Conf.colorSystem+" to "+currentRelationColor+myFaction.getTag()); - myFaction.sendMessage(Conf.colorSystem+"Your faction is now "+currentRelationColor+whishedRelation.toString()+Conf.colorSystem+" to "+currentRelationColor+otherFaction.getTag()); - } else { - otherFaction.sendMessage(currentRelationColor+myFaction.getTag()+Conf.colorSystem+ " wishes to be your "+whishedRelation.getColor()+whishedRelation.toString()); - otherFaction.sendMessage(Conf.colorSystem+"Type "+Conf.colorCommand+P.p.getBaseCommand()+" "+whishedRelation+" "+myFaction.getTag()+Conf.colorSystem+" to accept."); - myFaction.sendMessage(currentRelationColor+otherFaction.getTag()+Conf.colorSystem+ " were informed that you wish to be "+whishedRelation.getColor()+whishedRelation); + if (targetRelation.value == currentRelation.value) + { + them.sendMessageParsed("Your faction is now "+currentRelationColor+targetRelation.toString()+" to "+currentRelationColor+myFaction.getTag()); + myFaction.sendMessageParsed("Your faction is now "+currentRelationColor+targetRelation.toString()+" to "+currentRelationColor+them.getTag()); } - if (!whishedRelation.isNeutral() && otherFaction.isPeaceful()) { - otherFaction.sendMessage(Conf.colorSystem+"This will have no effect while your faction is peaceful."); - myFaction.sendMessage(Conf.colorSystem+"This will have no effect while their faction is peaceful."); + else + { + them.sendMessageParsed(currentRelationColor+myFaction.getTag()+" wishes to be your "+targetRelation.getColor()+targetRelation.toString()); + them.sendMessageParsed("Type /"+Conf.baseCommandAliases.get(0)+" "+targetRelation+" "+myFaction.getTag()+" to accept."); + myFaction.sendMessageParsed(currentRelationColor+them.getTag()+" were informed that you wish to be "+targetRelation.getColor()+targetRelation); } - if (!whishedRelation.isNeutral() && myFaction.isPeaceful()) { - otherFaction.sendMessage(Conf.colorSystem+"This will have no effect while their faction is peaceful."); - myFaction.sendMessage(Conf.colorSystem+"This will have no effect while your faction is peaceful."); + + if ( ! targetRelation.isNeutral() && them.isPeaceful()) + { + them.sendMessageParsed("This will have no effect while your faction is peaceful."); + myFaction.sendMessageParsed("This will have no effect while their faction is peaceful."); + } + + if ( ! targetRelation.isNeutral() && myFaction.isPeaceful()) + { + them.sendMessageParsed("This will have no effect while their faction is peaceful."); + myFaction.sendMessageParsed("This will have no effect while your faction is peaceful."); } - SpoutFeatures.updateAppearances(myFaction, otherFaction); + SpoutFeatures.updateAppearances(myFaction, them); + } } diff --git a/src/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/com/massivecraft/factions/listeners/FactionsBlockListener.java index 25be4506..d61ab11f 100644 --- a/src/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -174,19 +174,20 @@ public class FactionsBlockListener extends BlockListener public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) { - - if (Conf.adminBypassPlayers.contains(player.getName())) + FPlayer me = FPlayers.i.get(player); + + if (me.isAdminBypassing()) { return true; } FLocation loc = new FLocation(location); Faction otherFaction = Board.getFactionAt(loc); - FPlayer me = FPlayers.i.get(player); + if (otherFaction.isNone()) { - if (!Conf.wildernessDenyBuild || Permission.ADMIN_BYPASS.has(player) || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) + if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) { return true; // This is not faction territory. Use whatever you like here. } diff --git a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java index 8c0e1aca..c7fef60a 100644 --- a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -439,18 +439,17 @@ public class FactionsEntityListener extends EntityListener public boolean playerCanDoPaintings(Player player, FLocation loc, String action) { - - if (Conf.adminBypassPlayers.contains(player.getName())) + FPlayer me = FPlayers.i.get(player); + if (me.isAdminBypassing()) { return true; } Faction otherFaction = Board.getFactionAt(loc); - FPlayer me = FPlayers.i.get(player); if (otherFaction.isNone()) { - if (!Conf.wildernessDenyBuild || Permission.ADMIN_BYPASS.has(player) || Conf.worldsNoWildernessProtection.contains(player.getWorld().getName())) + if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(player.getWorld().getName())) { return true; // This is not faction territory. Use whatever you like here. } diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 473cdf93..f03d5dbb 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -331,8 +331,8 @@ public class FactionsPlayerListener extends PlayerListener public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck) { - - if (Conf.adminBypassPlayers.contains(player.getName())) + FPlayer me = FPlayers.i.get(player); + if (me.isAdminBypassing()) { return true; } @@ -354,11 +354,11 @@ public class FactionsPlayerListener extends PlayerListener } } - FPlayer me = FPlayers.i.get(player); + if (otherFaction.isNone()) { - if (!Conf.wildernessDenyUseage || Permission.ADMIN_BYPASS.has(player) || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) + if (!Conf.wildernessDenyUseage || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) { return true; // This is not faction territory. Use whatever you like here. } @@ -422,8 +422,8 @@ public class FactionsPlayerListener extends PlayerListener public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) { - - if (Conf.adminBypassPlayers.contains(player.getName())) + FPlayer me = FPlayers.i.get(player); + if (me.isAdminBypassing()) { return true; } @@ -454,7 +454,7 @@ public class FactionsPlayerListener extends PlayerListener } } - FPlayer me = FPlayers.i.get(player); + Faction myFaction = me.getFaction(); Relation rel = myFaction.getRelation(otherFaction); boolean ownershipFail = Conf.ownedAreasEnabled && Conf.ownedAreaProtectMaterials && !otherFaction.playerHasOwnershipRights(me, loc); @@ -575,7 +575,7 @@ public class FactionsPlayerListener extends PlayerListener && ! Conf.territoryNeutralDenyCommands.isEmpty() && - ! Conf.adminBypassPlayers.contains(me.getName()) + ! me.isAdminBypassing() ) { Iterator iter = Conf.territoryNeutralDenyCommands.iterator(); @@ -603,7 +603,7 @@ public class FactionsPlayerListener extends PlayerListener && ! Conf.territoryEnemyDenyCommands.isEmpty() && - ! Conf.adminBypassPlayers.contains(me.getName()) + ! me.isAdminBypassing() ) { Iterator iter = Conf.territoryEnemyDenyCommands.iterator(); diff --git a/src/com/massivecraft/factions/struct/Permission.java b/src/com/massivecraft/factions/struct/Permission.java index 562afcc7..5e1f304c 100644 --- a/src/com/massivecraft/factions/struct/Permission.java +++ b/src/com/massivecraft/factions/struct/Permission.java @@ -11,7 +11,6 @@ public enum Permission VIEW_ANY_POWER("viewAnyPower"), VIEW_ANY_FACTION_BALANCE("viewAnyFactionBalance"), PEACEFUL_EXPLOTION_TOGGLE("peacefulExplosionToggle"), - ADMIN_BYPASS("adminBypass"), CONFIG("config"), DISBAND("disband"), LOCK("lock"), @@ -22,11 +21,13 @@ public enum Permission 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_BYPASS("command.bypass"), COMMAND_CHAT("command.chat"), COMMAND_CLAIM("command.claim"), COMMAND_CONFIG("command.config"), @@ -46,6 +47,24 @@ public enum Permission COMMAND_LOCK("command.lock"), COMMAND_MAP("command.map"), COMMAND_MOD("command.mod"), + COMMAND_NO_BOOM("command.noBoom"), + COMMAND_OPEN("command.open"), + COMMAND_OWNER("command.owner"), + COMMAND_OWNERLIST("command.ownerlist"), + COMMAND_SET_PEACEFUL("command.setPeaceful"), + COMMAND_SET_PERMANENT("command.setPermanent"), + COMMAND_POWER("command.power"), + COMMAND_POWER_ANY("command.power.any"), + COMMAND_RELATION("command.relation"), + COMMAND_RELOAD("command.reload"), + COMMAND_SAVE("command.save"), + COMMAND_SETHOME("command.sethome"), + COMMAND_SETHOME_ANY("command.sethome.any"), + COMMAND_SHOW("command.show"), + COMMAND_TAG("command.tag"), + COMMAND_TITLE("command.title"), + COMMAND_UNCLAIM("command.unclaim"), + COMMAND_VERSION("command.version"), ; public final String node; diff --git a/src/com/massivecraft/factions/struct/Relation.java b/src/com/massivecraft/factions/struct/Relation.java index dfba0f22..87d786de 100644 --- a/src/com/massivecraft/factions/struct/Relation.java +++ b/src/com/massivecraft/factions/struct/Relation.java @@ -163,4 +163,20 @@ public enum Relation return Conf.territoryDenyUseage; } } + + public double getRelationCost() + { + if (isEnemy()) + { + return Conf.econCostEnemy; + } + else if (isAlly()) + { + return Conf.econCostAlly; + } + else + { + return Conf.econCostNeutral; + } + } } diff --git a/src/com/massivecraft/factions/zcore/MPlugin.java b/src/com/massivecraft/factions/zcore/MPlugin.java index 2cc4a2ea..bd68f3a9 100644 --- a/src/com/massivecraft/factions/zcore/MPlugin.java +++ b/src/com/massivecraft/factions/zcore/MPlugin.java @@ -79,7 +79,7 @@ public abstract class MPlugin extends JavaPlugin long saveTicks = 20 * 60 * 30; // Approximately every 30 min if (saveTask == null) { - saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(), saveTicks, saveTicks); + saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks); } return true; @@ -220,6 +220,18 @@ public abstract class MPlugin extends JavaPlugin return false; } + // -------------------------------------------- // + // HOOKS + // -------------------------------------------- // + public void preSaveTask() + { + + } + + public void postSaveTask() + { + + } // -------------------------------------------- // // LOGGING diff --git a/src/com/massivecraft/factions/zcore/persist/SaveTask.java b/src/com/massivecraft/factions/zcore/persist/SaveTask.java index effb4424..b78c27d0 100644 --- a/src/com/massivecraft/factions/zcore/persist/SaveTask.java +++ b/src/com/massivecraft/factions/zcore/persist/SaveTask.java @@ -1,9 +1,19 @@ package com.massivecraft.factions.zcore.persist; +import com.massivecraft.factions.zcore.MPlugin; + public class SaveTask implements Runnable { + MPlugin p; + public SaveTask(MPlugin p) + { + this.p = p; + } + public void run() { + p.preSaveTask(); EM.saveAllToDisc(); + p.postSaveTask(); } } diff --git a/src/plugin.yml b/src/plugin.yml index 179f64eb..34e055f4 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -44,21 +44,12 @@ permissions: factions.create: description: create a new faction default: true - factions.viewAnyPower: - description: view the power level of anyone else - default: true factions.viewAnyFactionBalance: description: view the faction bank balance for any faction default: true factions.peacefulExplosionToggle: description: disable explosions in your territory as a peaceful faction admin or moderator default: true - factions.adminBypass: - description: enable admin bypass mode (build/destroy anywhere) - default: op - factions.config: - description: use /f config command to change conf.json options - default: op factions.manageSafeZone: description: claim land as a safe zone and build/destroy within safe zones default: op @@ -68,18 +59,7 @@ permissions: factions.ownershipBypass: description: bypass ownership restrictions within own faction's territory default: op - factions.reload: - description: use the /f reload command to reload data file(s) from disk - default: op - factions.saveall: - description: use the /f saveall command to save all data to disk - default: op - factions.setPeaceful: - description: designate specific factions as "peaceful" (no PvP, no land stealing, etc.) - default: op - factions.setPermanent: - description: designate specific factions as permanent (not disbanded even with no members) - default: op + factions.command.admin: description: hand over your admin rights @@ -96,6 +76,9 @@ permissions: factions.command.pay: description: pay another faction from your bank default: true + factions.command.bypass: + description: enable admin bypass mode + default: op factions.command.chat: description: change chat mode default: true @@ -149,4 +132,60 @@ permissions: default: true factions.command.mod: description: give or revoke moderator rights - default: true \ No newline at end of file + default: true + factions.command.noBoom: + description: toggle explosions (peaceful factions only) + default: true + factions.command.open: + description: switch if invitation is required to join + default: true + factions.command.owner: + description: set ownership of claimed land + default: true + factions.command.ownerlist: + description: list owner(s) of this claimed land + default: true + factions.command.setPeaceful: + description: designate a faction as peaceful + default: op + factions.command.setPermanent: + description: designate a faction as permanent + default: op + factions.command.power: + description: show player power info + default: true + factions.command.power.any: + description: view an other players power level + default: true + factions.command.relation: + description: set relation wish to another faction + default: true + factions.command.reload: + description: reload data file(s) from disk + default: op + factions.command.save: + description: save all data to disk + default: op + factions.command.sethome: + description: set the faction home + default: true + factions.command.sethome.any: + description: set any faction home + default: op + factions.command.show: + description: chow faction information + default: true + factions.command.tag: + description: change the faction tag + default: true + factions.command.title: + description: set or remove a players title + default: true + factions.command.version: + description: see the version of the plugin + default: true + factions.command.unclaim: + description: unclaim the land where you are standing + default: true + + \ No newline at end of file