Saber-Factions/src/main/java/com/massivecraft/factions/cmd/econ/CmdMoneyTransferFp.java
2019-09-15 05:02:53 -04:00

51 lines
1.8 KiB
Java

package com.massivecraft.factions.cmd.econ;
import com.massivecraft.factions.Conf;
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.zcore.util.TL;
import org.bukkit.ChatColor;
public class CmdMoneyTransferFp extends FCommand {
public CmdMoneyTransferFp() {
this.aliases.add("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;
}
}