54 lines
1.6 KiB
Java
54 lines
1.6 KiB
Java
package com.massivecraft.factions.cmd;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import com.massivecraft.factions.Factions;
|
|
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
|
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
import com.massivecraft.factions.entity.Faction;
|
|
import com.massivecraft.factions.entity.MConf;
|
|
import com.massivecraft.factions.entity.MPlayer;
|
|
import com.massivecraft.factions.integration.Econ;
|
|
import com.massivecraft.massivecore.MassiveException;
|
|
import com.massivecraft.massivecore.command.type.primitive.TypeDouble;
|
|
import com.massivecraft.massivecore.money.Money;
|
|
import com.massivecraft.massivecore.util.Txt;
|
|
|
|
public class CmdFactionsMoneyWithdraw extends FactionsCommand
|
|
{
|
|
// -------------------------------------------- //
|
|
// CONSTRUCT
|
|
// -------------------------------------------- //
|
|
|
|
public CmdFactionsMoneyWithdraw()
|
|
{
|
|
// Parameters
|
|
this.addParameter(TypeDouble.get(), "amount");
|
|
this.addParameter(TypeFaction.get(), "faction", "you");
|
|
|
|
// Requirements
|
|
this.addRequirements(ReqBankCommandsEnabled.get());
|
|
}
|
|
|
|
// -------------------------------------------- //
|
|
// OVERRIDE
|
|
// -------------------------------------------- //
|
|
|
|
@Override
|
|
public void perform() throws MassiveException
|
|
{
|
|
Double amount = this.readArg();
|
|
Faction from = this.readArg(msenderFaction);
|
|
|
|
MPlayer to = msender;
|
|
|
|
boolean success = Econ.transferMoney(msender, from, to, amount);
|
|
|
|
if (success && MConf.get().logMoneyTransactions)
|
|
{
|
|
Factions.get().log(ChatColor.stripColor(Txt.parse("%s withdrew %s from the faction bank: %s", msender.getName(), Money.format(amount), from.describeTo(null))));
|
|
}
|
|
}
|
|
|
|
}
|