From 98260c75de5203ed49e69ec4feb915d4170a6df2 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Thu, 13 Oct 2011 16:07:07 +0200 Subject: [PATCH] Bugfixes and awesome probably complete money commands. --- plugin.yml | 31 ++++--- src/com/massivecraft/factions/FPlayers.java | 2 +- .../massivecraft/factions/cmd/CmdHelp.java | 92 +++++++++---------- .../massivecraft/factions/cmd/CmdMoney.java | 9 +- .../factions/cmd/CmdMoneyBalance.java | 3 +- .../factions/cmd/CmdMoneyDeposit.java | 6 +- .../factions/cmd/CmdMoneyPay.java | 37 -------- .../factions/cmd/CmdMoneyTransferFf.java | 40 ++++++++ .../factions/cmd/CmdMoneyTransferFp.java | 40 ++++++++ .../factions/cmd/CmdMoneyTransferPf.java | 40 ++++++++ .../factions/cmd/CmdMoneyWithdraw.java | 45 +-------- .../massivecraft/factions/cmd/FCommand.java | 4 +- .../factions/integration/Econ.java | 4 + .../factions/struct/Permission.java | 4 +- .../massivecraft/factions/zcore/MCommand.java | 24 ++--- .../factions/zcore/util/PermUtil.java | 1 + 16 files changed, 221 insertions(+), 161 deletions(-) delete mode 100644 src/com/massivecraft/factions/cmd/CmdMoneyPay.java create mode 100644 src/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java create mode 100644 src/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java create mode 100644 src/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java diff --git a/plugin.yml b/plugin.yml index a9297c8f..a0c051a8 100644 --- a/plugin.yml +++ b/plugin.yml @@ -31,6 +31,7 @@ permissions: factions.kick.any: true factions.ownershipbypass: true factions.kit.fullplayer: + default: true description: Can also create new factions. children: factions.kit.halfplayer: true @@ -57,8 +58,10 @@ permissions: factions.money.balance: true factions.money.balance.any: true factions.money.deposit: true - factions.money.pay: true factions.money.withdraw: true + factions.money.f2f: true + factions.money.f2p: true + factions.money.p2f: true factions.noboom: true factions.open: true factions.owner: true @@ -121,26 +124,32 @@ permissions: description: show the territory map, and set optional auto update factions.mod: description: give or revoke moderator rights - factions.money.*: - children: - factions.money.balance: true - factions.money.balance.any: true - factions.money.deposit: true - factions.money.pay: true - factions.money.withdraw: true - factions.money.withdraw.any: true factions.money.balance: description: show your factions current money balance factions.money.balance.any: description: show money balance for factions other than your own factions.money.deposit: description: deposit money into a faction bank - factions.money.pay: - description: pay another faction from your bank factions.money.withdraw: description: withdraw money from your faction bank factions.money.withdraw.any: description: withdraw money from your factions other than your own + factions.money.f2f: + description: transfer money from faction to faction + factions.money.f2p: + description: transfer money from faction to player + factions.money.p2f: + description: transfer money from player to faction + factions.money.*: + children: + factions.money.balance: true + factions.money.balance.any: true + factions.money.deposit: true + factions.money.withdraw: true + factions.money.withdraw.any: true + factions.money.f2f: true + factions.money.f2p: true + factions.money.p2f: true factions.noboom: description: toggle explosions (peaceful factions only) factions.open: diff --git a/src/com/massivecraft/factions/FPlayers.java b/src/com/massivecraft/factions/FPlayers.java index 165d222a..ec3a023d 100644 --- a/src/com/massivecraft/factions/FPlayers.java +++ b/src/com/massivecraft/factions/FPlayers.java @@ -74,7 +74,7 @@ public class FPlayers extends PlayerEntityCollection { for (FPlayer fplayer : this.get()) { - if (fplayer.getId().equalsIgnoreCase(playername) || fplayer.getId().startsWith(playername)) + if (fplayer.getId().equalsIgnoreCase(playername) || fplayer.getId().toLowerCase().startsWith(playername.toLowerCase())) { return fplayer; } diff --git a/src/com/massivecraft/factions/cmd/CmdHelp.java b/src/com/massivecraft/factions/cmd/CmdHelp.java index 6d72e12f..a60a7c94 100644 --- a/src/com/massivecraft/factions/cmd/CmdHelp.java +++ b/src/com/massivecraft/factions/cmd/CmdHelp.java @@ -60,27 +60,27 @@ public class CmdHelp extends FCommand ArrayList pageLines; pageLines = new ArrayList(); - pageLines.add( p.cmdBase.cmdHelp.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdList.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdShow.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdPower.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdJoin.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdLeave.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdChat.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdHome.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdHelp.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdList.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdShow.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdPower.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdJoin.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdLeave.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdChat.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdHome.getUseageTemplate(true) ); pageLines.add( p.txt.parse("Learn how to create a faction on the next page.") ); helpPages.add(pageLines); pageLines = new ArrayList(); - pageLines.add( p.cmdBase.cmdCreate.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdDescription.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdTag.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdCreate.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdDescription.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdTag.getUseageTemplate(true) ); pageLines.add( p.txt.parse("You might want to close it and use invitations:" )); - pageLines.add( p.cmdBase.cmdOpen.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdInvite.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdDeinvite.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdOpen.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdInvite.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdDeinvite.getUseageTemplate(true) ); pageLines.add( p.txt.parse("And don't forget to set your home:" )); - pageLines.add( p.cmdBase.cmdSethome.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdSethome.getUseageTemplate(true) ); helpPages.add(pageLines); if (Econ.shouldBeUsed()) @@ -91,7 +91,7 @@ public class CmdHelp extends FCommand pageLines.add( p.txt.parse("things, so it will need to have money deposited into it." )); pageLines.add( p.txt.parse("To lear more use the money command." )); pageLines.add( "" ); - pageLines.add( p.cmdBase.cmdMoney.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdMoney.getUseageTemplate(true) ); pageLines.add( "" ); pageLines.add( "" ); pageLines.add( "" ); @@ -99,23 +99,23 @@ public class CmdHelp extends FCommand } pageLines = new ArrayList(); - pageLines.add( p.cmdBase.cmdClaim.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdAutoClaim.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdUnclaim.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdUnclaimall.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdKick.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdMod.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdAdmin.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdTitle.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdClaim.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdAutoClaim.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdUnclaim.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdUnclaimall.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdKick.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdMod.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdAdmin.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdTitle.getUseageTemplate(true) ); pageLines.add( p.txt.parse("Player titles are just for fun. No rules connected to them." )); helpPages.add(pageLines); pageLines = new ArrayList(); - pageLines.add( p.cmdBase.cmdMap.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdBoom.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdMap.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdBoom.getUseageTemplate(true) ); pageLines.add(""); - pageLines.add( p.cmdBase.cmdOwner.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdOwnerList.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdOwner.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdOwnerList.getUseageTemplate(true) ); pageLines.add(""); pageLines.add(p.txt.parse("Claimed land with ownership set is further protected so")); pageLines.add(p.txt.parse("that only the owner(s), faction admin, and possibly the")); @@ -123,11 +123,11 @@ public class CmdHelp extends FCommand helpPages.add(pageLines); pageLines = new ArrayList(); - pageLines.add( p.cmdBase.cmdDisband.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdDisband.getUseageTemplate(true) ); pageLines.add(""); - pageLines.add( p.cmdBase.cmdRelationAlly.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdRelationNeutral.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdRelationEnemy.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdRelationAlly.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdRelationNeutral.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdRelationEnemy.getUseageTemplate(true) ); pageLines.add(p.txt.parse("Set the relation you WISH to have with another faction.")); pageLines.add(p.txt.parse("Your default relation with other factions will be neutral.")); pageLines.add(p.txt.parse("If BOTH factions choose \"ally\" you will be allies.")); @@ -160,26 +160,26 @@ public class CmdHelp extends FCommand pageLines = new ArrayList(); pageLines.add("Finally some commands for the server admins:"); - pageLines.add( p.cmdBase.cmdBypass.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdSafeclaim.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdAutoSafeclaim.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdSafeunclaimall.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdWarclaim.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdAutoWarclaim.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdWarunclaimall.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdBypass.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdSafeclaim.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdAutoSafeclaim.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdWarclaim.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdAutoWarclaim.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdWarunclaimall.getUseageTemplate(true) ); pageLines.add(p.txt.parse("Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("") + " works on safe/war zones as well.")); helpPages.add(pageLines); pageLines = new ArrayList(); pageLines.add(p.txt.parse("More commands for server admins:")); - pageLines.add( p.cmdBase.cmdPeaceful.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdPermanent.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdPeaceful.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdPermanent.getUseageTemplate(true) ); pageLines.add(p.txt.parse("Peaceful factions are protected from PvP and land capture.")); - pageLines.add( p.cmdBase.cmdLock.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdReload.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdSaveAll.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdVersion.getUseageTemplate() ); - pageLines.add( p.cmdBase.cmdConfig.getUseageTemplate() ); + pageLines.add( p.cmdBase.cmdLock.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdReload.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdSaveAll.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdVersion.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdConfig.getUseageTemplate(true) ); helpPages.add(pageLines); } } diff --git a/src/com/massivecraft/factions/cmd/CmdMoney.java b/src/com/massivecraft/factions/cmd/CmdMoney.java index dee5504a..d7762079 100644 --- a/src/com/massivecraft/factions/cmd/CmdMoney.java +++ b/src/com/massivecraft/factions/cmd/CmdMoney.java @@ -7,7 +7,9 @@ public class CmdMoney extends FCommand public CmdMoneyBalance cmdMoneyBalance = new CmdMoneyBalance(); public CmdMoneyDeposit cmdMoneyDeposit = new CmdMoneyDeposit(); public CmdMoneyWithdraw cmdMoneyWithdraw = new CmdMoneyWithdraw(); - public CmdMoneyPay cmdMoneyPay = new CmdMoneyPay(); + public CmdMoneyTransferFf cmdMoneyTransferFf = new CmdMoneyTransferFf(); + public CmdMoneyTransferFp cmdMoneyTransferFp = new CmdMoneyTransferFp(); + public CmdMoneyTransferPf cmdMoneyTransferPf = new CmdMoneyTransferPf(); public CmdMoney() { @@ -18,7 +20,6 @@ public class CmdMoney extends FCommand //this.optionalArgs.put("","") this.isMoneyCommand = true; - this.isBankCommand = false; senderMustBePlayer = false; senderMustBeMember = false; @@ -31,7 +32,9 @@ public class CmdMoney extends FCommand this.addSubCommand(this.cmdMoneyBalance); this.addSubCommand(this.cmdMoneyDeposit); this.addSubCommand(this.cmdMoneyWithdraw); - this.addSubCommand(this.cmdMoneyPay); + this.addSubCommand(this.cmdMoneyTransferFf); + this.addSubCommand(this.cmdMoneyTransferFp); + this.addSubCommand(this.cmdMoneyTransferPf); } @Override diff --git a/src/com/massivecraft/factions/cmd/CmdMoneyBalance.java b/src/com/massivecraft/factions/cmd/CmdMoneyBalance.java index 5a12dfed..cbbbad09 100644 --- a/src/com/massivecraft/factions/cmd/CmdMoneyBalance.java +++ b/src/com/massivecraft/factions/cmd/CmdMoneyBalance.java @@ -16,8 +16,7 @@ public class CmdMoneyBalance extends FCommand this.optionalArgs.put("faction", "yours"); this.permission = Permission.MONEY_BALANCE.node; - this.isMoneyCommand = true; - this.isBankCommand = true; + this.setHelpShort("show faction balance"); senderMustBePlayer = false; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdMoneyDeposit.java b/src/com/massivecraft/factions/cmd/CmdMoneyDeposit.java index 6eae216f..a4a69071 100644 --- a/src/com/massivecraft/factions/cmd/CmdMoneyDeposit.java +++ b/src/com/massivecraft/factions/cmd/CmdMoneyDeposit.java @@ -11,14 +11,14 @@ public class CmdMoneyDeposit extends FCommand public CmdMoneyDeposit() { super(); + this.aliases.add("d"); this.aliases.add("deposit"); this.requiredArgs.add("amount"); this.optionalArgs.put("faction", "yours"); this.permission = Permission.MONEY_DEPOSIT.node; - this.isMoneyCommand = true; - this.isBankCommand = true; + this.setHelpShort("deposit money"); senderMustBePlayer = true; senderMustBeMember = false; @@ -29,7 +29,7 @@ public class CmdMoneyDeposit extends FCommand @Override public void perform() { - double amount = this.argAsDouble(0, 0); + double amount = this.argAsDouble(0, 0d); Faction faction = this.argAsFaction(1, myFaction); if (faction == null) return; Econ.transferMoney(fme, fme, faction, amount); diff --git a/src/com/massivecraft/factions/cmd/CmdMoneyPay.java b/src/com/massivecraft/factions/cmd/CmdMoneyPay.java deleted file mode 100644 index 0e0df2ae..00000000 --- a/src/com/massivecraft/factions/cmd/CmdMoneyPay.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.struct.Permission; - - -public class CmdMoneyPay extends FCommand -{ - public CmdMoneyPay() - { - this.aliases.add("pay"); - - this.requiredArgs.add("amount"); - this.requiredArgs.add("faction"); - - //this.optionalArgs.put("", ""); - - this.permission = Permission.MONEY_PAY.node; - this.isMoneyCommand = true; - this.isBankCommand = true; - - senderMustBePlayer = true; - senderMustBeMember = true; - senderMustBeModerator = false; - senderMustBeAdmin = false; - } - - @Override - public void perform() - { - double amount = this.argAsDouble(0, 0); - Faction faction = this.argAsFaction(1); - if (faction == null) return; - Econ.transferMoney(fme, myFaction, faction, amount); - } -} diff --git a/src/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java b/src/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java new file mode 100644 index 00000000..08615c01 --- /dev/null +++ b/src/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java @@ -0,0 +1,40 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.iface.EconomyParticipator; +import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.struct.Permission; + + +public class CmdMoneyTransferFf extends FCommand +{ + public CmdMoneyTransferFf() + { + this.aliases.add("ff"); + + this.requiredArgs.add("amount"); + this.requiredArgs.add("faction"); + this.requiredArgs.add("faction"); + + //this.optionalArgs.put("", ""); + + this.permission = Permission.MONEY_F2F.node; + this.setHelpShort("transfer f -> f"); + + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } + + @Override + public void perform() + { + double amount = this.argAsDouble(0, 0d); + EconomyParticipator from = this.argAsFaction(1); + if (from == null) return; + EconomyParticipator to = this.argAsFaction(2); + if (to == null) return; + + Econ.transferMoney(fme, from, to, amount); + } +} diff --git a/src/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java b/src/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java new file mode 100644 index 00000000..30435a87 --- /dev/null +++ b/src/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java @@ -0,0 +1,40 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.iface.EconomyParticipator; +import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.struct.Permission; + + +public class CmdMoneyTransferFp extends FCommand +{ + public CmdMoneyTransferFp() + { + this.aliases.add("fp"); + + this.requiredArgs.add("amount"); + this.requiredArgs.add("faction"); + this.requiredArgs.add("player"); + + //this.optionalArgs.put("", ""); + + this.permission = Permission.MONEY_F2P.node; + this.setHelpShort("transfer f -> p"); + + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } + + @Override + public void perform() + { + double amount = this.argAsDouble(0, 0d); + EconomyParticipator from = this.argAsFaction(1); + if (from == null) return; + EconomyParticipator to = this.argAsBestFPlayerMatch(2); + if (to == null) return; + + Econ.transferMoney(fme, from, to, amount); + } +} diff --git a/src/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java b/src/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java new file mode 100644 index 00000000..ac1af4bb --- /dev/null +++ b/src/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java @@ -0,0 +1,40 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.iface.EconomyParticipator; +import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.struct.Permission; + + +public class CmdMoneyTransferPf extends FCommand +{ + public CmdMoneyTransferPf() + { + this.aliases.add("pf"); + + this.requiredArgs.add("amount"); + this.requiredArgs.add("player"); + this.requiredArgs.add("faction"); + + //this.optionalArgs.put("", ""); + + this.permission = Permission.MONEY_P2F.node; + this.setHelpShort("transfer p -> f"); + + senderMustBePlayer = false; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } + + @Override + public void perform() + { + double amount = this.argAsDouble(0, 0d); + EconomyParticipator from = this.argAsBestFPlayerMatch(1); + if (from == null) return; + EconomyParticipator to = this.argAsFaction(2); + if (to == null) return; + + Econ.transferMoney(fme, from, to, amount); + } +} diff --git a/src/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java b/src/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java index ec2eff00..2b588d17 100644 --- a/src/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java +++ b/src/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java @@ -6,17 +6,16 @@ import com.massivecraft.factions.struct.Permission; public class CmdMoneyWithdraw extends FCommand { - public CmdMoneyWithdraw() { + this.aliases.add("w"); this.aliases.add("withdraw"); this.requiredArgs.add("amount"); this.optionalArgs.put("faction", "yours"); this.permission = Permission.MONEY_WITHDRAW.node; - this.isMoneyCommand = true; - this.isBankCommand = true; + this.setHelpShort("withdraw money"); senderMustBePlayer = true; senderMustBeMember = false; @@ -27,47 +26,9 @@ public class CmdMoneyWithdraw extends FCommand @Override public void perform() { - double amount = this.argAsDouble(0, 0); + double amount = this.argAsDouble(0, 0d); Faction faction = this.argAsFaction(1, myFaction); if (faction == null) return; Econ.transferMoney(fme, faction, fme, amount); - - /*if ( ! Conf.bankMembersCanWithdraw && ! assertMinRole(Role.MODERATOR)) - { - msg("Only faction moderators or admins are able to withdraw from the bank."); - return; - } - - Faction faction = myFaction; - - double amount = this.argAsDouble(0, 0d); - - if( amount > 0.0 ) - { - String amountString = Econ.moneyString(amount); - - if( amount > faction.getMoney() ) - { - amount = faction.getMoney(); - } - - // TODO: Improve messages. - - faction.removeMoney(amount); - Econ.addMoney(fme.getName(), amount); - msg("You have withdrawn "+amountString+" from "+faction.getTag()+"'s bank."); - msg(""+faction.getTag()+" now has "+Econ.moneyString(faction.getMoney())); - P.p.log(fme.getName() + " withdrew "+amountString+" from "+faction.getTag()+"'s bank."); - - // TODO: FAction.getOnlineMembers(). - for (FPlayer fplayer : FPlayers.i.getOnline()) - { - if (fplayer.getFaction() == faction) - { - fplayer.msg("%s has withdrawn %s", fme.getNameAndRelevant(fplayer), amountString); - } - } - }*/ } - } diff --git a/src/com/massivecraft/factions/cmd/FCommand.java b/src/com/massivecraft/factions/cmd/FCommand.java index 4cae6c89..7d0514c5 100644 --- a/src/com/massivecraft/factions/cmd/FCommand.java +++ b/src/com/massivecraft/factions/cmd/FCommand.java @@ -27,7 +27,6 @@ public abstract class FCommand extends MCommand

public boolean senderMustBeAdmin; public boolean isMoneyCommand; - public boolean isBankCommand; public FCommand() { @@ -38,7 +37,6 @@ public abstract class FCommand extends MCommand

// The money commands must be disabled if money should not be used. isMoneyCommand = false; - isBankCommand = false; senderMustBeMember = false; senderMustBeModerator = false; @@ -76,7 +74,7 @@ public abstract class FCommand extends MCommand

return false; } - if (this.isBankCommand && ! Conf.bankEnabled) + if (this.isMoneyCommand && ! Conf.bankEnabled) { msg("The faction bank system is diabled on this server."); return false; diff --git a/src/com/massivecraft/factions/integration/Econ.java b/src/com/massivecraft/factions/integration/Econ.java index aecd24b7..6130373c 100644 --- a/src/com/massivecraft/factions/integration/Econ.java +++ b/src/com/massivecraft/factions/integration/Econ.java @@ -16,6 +16,7 @@ import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions; import com.massivecraft.factions.P; import com.massivecraft.factions.iface.EconomyParticipator; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.util.RelationUtil; @@ -95,6 +96,9 @@ public class Econ // Bypassing players can do any kind of transaction if (i instanceof FPlayer && ((FPlayer)i).isAdminBypassing()) return true; + // Players with the any withdraw can to. + if (i instanceof FPlayer && Permission.MONEY_WITHDRAW_ANY.has(((FPlayer)i).getPlayer())) return true; + // You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again. if (i == you) return true; diff --git a/src/com/massivecraft/factions/struct/Permission.java b/src/com/massivecraft/factions/struct/Permission.java index 5dc87219..32c324bf 100644 --- a/src/com/massivecraft/factions/struct/Permission.java +++ b/src/com/massivecraft/factions/struct/Permission.java @@ -34,9 +34,11 @@ public enum Permission MONEY_BALANCE("money.balance"), MONEY_BALANCE_ANY("money.balance.any"), MONEY_DEPOSIT("money.deposit"), - MONEY_PAY("money.pay"), MONEY_WITHDRAW("money.withdraw"), MONEY_WITHDRAW_ANY("money.withdraw.any"), + MONEY_F2F("money.f2f"), + MONEY_F2P("money.f2p"), + MONEY_P2F("money.p2f"), NO_BOOM("noboom"), OPEN("open"), OWNER("owner"), diff --git a/src/com/massivecraft/factions/zcore/MCommand.java b/src/com/massivecraft/factions/zcore/MCommand.java index c51bb476..905b936d 100644 --- a/src/com/massivecraft/factions/zcore/MCommand.java +++ b/src/com/massivecraft/factions/zcore/MCommand.java @@ -48,7 +48,7 @@ public abstract class MCommand { return pdesc; } - return "*no short help available*"; + return "*info unavailable*"; } return this.helpShort; } @@ -265,7 +265,7 @@ public abstract class MCommand if (addShortHelp) { ret.append(p.txt.parseTags(" ")); - ret.append(this.helpShort); + ret.append(this.getHelpShort()); } return ret.toString(); @@ -332,12 +332,12 @@ public abstract class MCommand } // INT ====================== - public int strAsInt(String str, int def) + public Integer strAsInt(String str, Integer def) { if (str == null) return def; try { - int ret = Integer.parseInt(str); + Integer ret = Integer.parseInt(str); return ret; } catch (Exception e) @@ -345,22 +345,22 @@ public abstract class MCommand return def; } } - public int argAsInt(int idx, int def) + public Integer argAsInt(int idx, Integer def) { return strAsInt(this.argAsString(idx), def); } - public int argAsInt(int idx) + public Integer argAsInt(int idx) { - return this.argAsInt(idx, -1); + return this.argAsInt(idx, null); } // Double ====================== - public double strAsDouble(String str, double def) + public Double strAsDouble(String str, Double def) { if (str == null) return def; try { - double ret = Double.parseDouble(str); + Double ret = Double.parseDouble(str); return ret; } catch (Exception e) @@ -368,13 +368,13 @@ public abstract class MCommand return def; } } - public double argAsDouble(int idx, double def) + public Double argAsDouble(int idx, Double def) { return strAsDouble(this.argAsString(idx), def); } - public double argAsDouble(int idx) + public Double argAsDouble(int idx) { - return this.argAsDouble(idx, -1d); + return this.argAsDouble(idx, null); } // TODO: Go through the str conversion for the other arg-readers as well. diff --git a/src/com/massivecraft/factions/zcore/util/PermUtil.java b/src/com/massivecraft/factions/zcore/util/PermUtil.java index 2853d2ae..60d59306 100644 --- a/src/com/massivecraft/factions/zcore/util/PermUtil.java +++ b/src/com/massivecraft/factions/zcore/util/PermUtil.java @@ -44,6 +44,7 @@ public class PermUtil { { for(Permission permission : p.getDescription().getPermissions()) { + //p.log("\""+permission.getName()+"\" = \""+permission.getDescription()+"\""); this.permissionDescriptions.put(permission.getName(), permission.getDescription()); }