Introduced Brigadier Command System. More Formatting Coming in next commit.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.massivecraft.factions.cmd.econ;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
@@ -21,15 +23,7 @@ public class CmdMoney extends FCommand {
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("","")
|
||||
|
||||
this.isMoneyCommand = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
|
||||
this.helpLong.add(p.txt.parseTags(TL.COMMAND_MONEY_LONG.toString()));
|
||||
this.helpLong.add(FactionsPlugin.getInstance().txt.parseTags(TL.COMMAND_MONEY_LONG.toString()));
|
||||
|
||||
this.addSubCommand(this.cmdMoneyBalance);
|
||||
this.addSubCommand(this.cmdMoneyDeposit);
|
||||
@@ -37,13 +31,16 @@ public class CmdMoney extends FCommand {
|
||||
this.addSubCommand(this.cmdMoneyTransferFf);
|
||||
this.addSubCommand(this.cmdMoneyTransferFp);
|
||||
this.addSubCommand(this.cmdMoneyTransferPf);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
this.commandChain.add(this);
|
||||
P.p.cmdAutoHelp.execute(this.sender, this.args, this.commandChain);
|
||||
public void perform(CommandContext context) {
|
||||
if (!Conf.econEnabled) {
|
||||
context.msg(TL.ECON_OFF, "economy option is enabled, please set \'econEnabled\' to true in conf.json");
|
||||
return;
|
||||
}
|
||||
context.commandChain.add(this);
|
||||
FactionsPlugin.getInstance().cmdAutoHelp.execute(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.massivecraft.factions.cmd.econ;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
@@ -16,36 +18,30 @@ public class CmdMoneyBalance extends FCommand {
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction", "yours");
|
||||
this.isMoneyCommand = true;
|
||||
|
||||
this.permission = Permission.MONEY_BALANCE.node;
|
||||
this.setHelpShort(TL.COMMAND_MONEYBALANCE_SHORT.toString());
|
||||
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.MONEY_BALANCE).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction faction = myFaction;
|
||||
if (this.argIsSet(0)) {
|
||||
faction = this.argAsFaction(0);
|
||||
public void perform(CommandContext context) {
|
||||
Faction faction = context.faction;
|
||||
if (context.argIsSet(0)) {
|
||||
faction = context.argAsFaction(0);
|
||||
}
|
||||
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
if (faction != myFaction && !Permission.MONEY_BALANCE_ANY.has(sender, true)) {
|
||||
if (faction != context.faction && !Permission.MONEY_BALANCE_ANY.has(context.sender, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fme != null) {
|
||||
Econ.sendBalanceInfo((CommandSender) fme, faction);
|
||||
if (context.fPlayer != null) {
|
||||
Econ.sendBalanceInfo((CommandSender) context.fPlayer, faction);
|
||||
} else {
|
||||
Econ.sendBalanceInfo(sender, faction);
|
||||
Econ.sendBalanceInfo(context.sender, faction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.massivecraft.factions.cmd.econ;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
@@ -20,29 +22,22 @@ public class CmdMoneyDeposit extends FCommand {
|
||||
this.requiredArgs.add("amount");
|
||||
this.optionalArgs.put("faction", "yours");
|
||||
|
||||
this.isMoneyCommand = true;
|
||||
|
||||
this.permission = Permission.MONEY_DEPOSIT.node;
|
||||
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.MONEY_DEPOSIT)
|
||||
.memberOnly()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
||||
public void perform(CommandContext context) {
|
||||
double amount = context.argAsDouble(0, 0d);
|
||||
EconomyParticipator faction = context.argAsFaction(1, context.faction);
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
boolean success = Econ.transferMoney(fme, fme, faction, amount);
|
||||
boolean success = Econ.transferMoney(context.fPlayer, context.fPlayer, faction, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYDEPOSIT_DEPOSITED.toString(), fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||
FactionsPlugin.getInstance().log(ChatColor.stripColor(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_MONEYDEPOSIT_DEPOSITED.toString(), context.fPlayer.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,3 +47,4 @@ public class CmdMoneyDeposit extends FCommand {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.massivecraft.factions.cmd.econ;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
@@ -13,6 +15,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class CmdMoneyTransferFf extends FCommand {
|
||||
|
||||
|
||||
public CmdMoneyTransferFf() {
|
||||
this.aliases.add("ff");
|
||||
|
||||
@@ -20,45 +23,32 @@ public class CmdMoneyTransferFf extends FCommand {
|
||||
this.requiredArgs.add("faction");
|
||||
this.requiredArgs.add("faction");
|
||||
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.MONEY_F2F.node;
|
||||
|
||||
this.isMoneyCommand = true;
|
||||
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.MONEY_F2F).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator from = this.argAsFaction(1);
|
||||
public void perform(CommandContext context) {
|
||||
double amount = context.argAsDouble(0, 0d);
|
||||
EconomyParticipator from = context.argAsFaction(1);
|
||||
if (from == null) {
|
||||
return;
|
||||
}
|
||||
EconomyParticipator to = this.argAsFaction(2);
|
||||
EconomyParticipator to = context.argAsFaction(2);
|
||||
if (to == null) {
|
||||
return;
|
||||
}
|
||||
if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - myFaction.getFoundedDate()) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) {
|
||||
msg("Your faction is too young to transfer money like this");
|
||||
return;
|
||||
}
|
||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||
|
||||
boolean success = Econ.transferMoney(context.fPlayer, from, to, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
String name = sender instanceof Player ? fme.getName() : sender.getName();
|
||||
P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYTRANSFERFF_TRANSFER.toString(), name, Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
||||
String name = context.sender instanceof Player ? context.fPlayer.getName() : context.sender.getName();
|
||||
FactionsPlugin.getInstance().log(ChatColor.stripColor(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_MONEYTRANSFERFF_TRANSFER.toString(), name, Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_MONEYTRANSFERFF_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.massivecraft.factions.cmd.econ;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
@@ -11,7 +13,6 @@ import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
public class CmdMoneyTransferFp extends FCommand {
|
||||
|
||||
public CmdMoneyTransferFp() {
|
||||
this.aliases.add("fp");
|
||||
|
||||
@@ -19,39 +20,25 @@ public class CmdMoneyTransferFp extends FCommand {
|
||||
this.requiredArgs.add("faction");
|
||||
this.requiredArgs.add("player");
|
||||
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.MONEY_F2P.node;
|
||||
|
||||
this.isMoneyCommand = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.MONEY_F2P).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator from = this.argAsFaction(1);
|
||||
public void perform(CommandContext context) {
|
||||
double amount = context.argAsDouble(0, 0d);
|
||||
EconomyParticipator from = context.argAsFaction(1);
|
||||
if (from == null) {
|
||||
return;
|
||||
}
|
||||
EconomyParticipator to = this.argAsBestFPlayerMatch(2);
|
||||
EconomyParticipator to = context.argAsBestFPlayerMatch(2);
|
||||
if (to == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - myFaction.getFoundedDate()) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) {
|
||||
msg("Your faction is too young to transfer money like this");
|
||||
return;
|
||||
}
|
||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||
boolean success = Econ.transferMoney(context.fPlayer, from, to, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYTRANSFERFP_TRANSFER.toString(), fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
||||
FactionsPlugin.getInstance().log(ChatColor.stripColor(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_MONEYTRANSFERFP_TRANSFER.toString(), context.fPlayer.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,3 +47,4 @@ public class CmdMoneyTransferFp extends FCommand {
|
||||
return TL.COMMAND_MONEYTRANSFERFP_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.massivecraft.factions.cmd.econ;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
@@ -19,39 +21,25 @@ public class CmdMoneyTransferPf extends FCommand {
|
||||
this.requiredArgs.add("player");
|
||||
this.requiredArgs.add("faction");
|
||||
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.MONEY_P2F.node;
|
||||
this.isMoneyCommand = true;
|
||||
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.MONEY_P2F).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator from = this.argAsBestFPlayerMatch(1);
|
||||
public void perform(CommandContext context) {
|
||||
double amount = context.argAsDouble(0, 0d);
|
||||
EconomyParticipator from = context.argAsBestFPlayerMatch(1);
|
||||
if (from == null) {
|
||||
return;
|
||||
}
|
||||
EconomyParticipator to = this.argAsFaction(2);
|
||||
EconomyParticipator to = context.argAsFaction(2);
|
||||
if (to == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - myFaction.getFoundedDate()) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) {
|
||||
msg("Your faction is too young to transfer money like this");
|
||||
return;
|
||||
}
|
||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||
boolean success = Econ.transferMoney(context.fPlayer, from, to, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYTRANSFERPF_TRANSFER.toString(), fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
||||
FactionsPlugin.getInstance().log(ChatColor.stripColor(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_MONEYTRANSFERPF_TRANSFER.toString(), context.fPlayer.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.massivecraft.factions.cmd.econ;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
@@ -21,41 +24,30 @@ public class CmdMoneyWithdraw extends FCommand {
|
||||
this.requiredArgs.add("amount");
|
||||
this.optionalArgs.put("faction", "yours");
|
||||
|
||||
this.permission = Permission.MONEY_WITHDRAW.node;
|
||||
this.isMoneyCommand = true;
|
||||
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.MONEY_F2P)
|
||||
.playerOnly()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
||||
public void perform(CommandContext context) {
|
||||
double amount = context.argAsDouble(0, 0d);
|
||||
EconomyParticipator faction = context.argAsFaction(1, context.faction);
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Access access = myFaction.getAccess(fme, PermissableAction.WITHDRAW);
|
||||
if (access == Access.DENY) {
|
||||
fme.msg(TL.GENERIC_NOPERMISSION, "withdraw");
|
||||
return;
|
||||
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.WITHDRAW);
|
||||
if (context.fPlayer.getRole() != Role.LEADER) {
|
||||
if (access == Access.DENY) {
|
||||
context.msg(TL.GENERIC_NOPERMISSION, "withdraw", "withdraw money from the bank");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - myFaction.getFoundedDate()) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) {
|
||||
msg("Your faction is too young to withdraw money like this");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean success = Econ.transferMoney(fme, faction, fme, amount);
|
||||
boolean success = Econ.transferMoney(context.fPlayer, faction, context.fPlayer, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
P.p.log(ChatColor.stripColor(P.p.txt.parse(TL.COMMAND_MONEYWITHDRAW_WITHDRAW.toString(), fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||
FactionsPlugin.getInstance().log(ChatColor.stripColor(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_MONEYWITHDRAW_WITHDRAW.toString(), context.fPlayer.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user