Saber-Factions/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferFp.java

57 lines
1.8 KiB
Java
Raw Normal View History

2019-07-02 03:26:13 +02:00
package com.massivecraft.factions.cmd.econ;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.Aliases;
import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements;
2019-07-02 03:26:13 +02:00
import com.massivecraft.factions.cmd.FCommand;
2014-04-04 20:55:21 +02:00
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
2014-04-04 20:55:21 +02:00
public class CmdMoneyTransferFp extends FCommand {
2019-12-02 19:55:38 +01:00
/**
* @author FactionsUUID Team
*/
public CmdMoneyTransferFp() {
this.aliases.addAll(Aliases.money_transfer_Fp);
this.requiredArgs.add("amount");
this.requiredArgs.add("faction");
this.requiredArgs.add("player");
this.requirements = new CommandRequirements.Builder(Permission.MONEY_F2P).build();
}
@Override
public void perform(CommandContext context) {
double amount = context.argAsDouble(0, 0d);
EconomyParticipator from = context.argAsFaction(1);
if (from == null) {
return;
}
EconomyParticipator to = context.argAsBestFPlayerMatch(2);
if (to == null) {
return;
}
boolean success = Econ.transferMoney(context.fPlayer, from, to, amount);
if (success && Conf.logMoneyTransactions) {
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))));
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_MONEYTRANSFERFP_DESCRIPTION;
}
}