2018-03-27 01:42:26 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
2019-09-14 21:13:01 +02:00
|
|
|
import com.massivecraft.factions.FactionsPlugin;
|
2018-03-27 01:42:26 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2020-04-09 23:53:05 +02:00
|
|
|
import com.massivecraft.factions.util.ItemBuilder;
|
2018-03-27 01:42:26 +02:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
|
|
|
public class CmdGetVault extends FCommand {
|
2019-12-02 19:55:38 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Illyria Team
|
|
|
|
*/
|
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
public CmdGetVault() {
|
|
|
|
super();
|
2020-01-02 02:59:31 +01:00
|
|
|
this.aliases.addAll(Aliases.getvault);
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
this.requirements = new CommandRequirements.Builder(Permission.GETVAULT)
|
|
|
|
.playerOnly()
|
|
|
|
.memberOnly()
|
|
|
|
.build();
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
@Override
|
|
|
|
public void perform(CommandContext context) {
|
|
|
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fvault.Enabled")) {
|
2019-12-03 11:16:37 +01:00
|
|
|
context.fPlayer.msg(TL.GENERIC_DISABLED, "Faction Vaults");
|
2019-09-15 11:19:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2020-04-09 23:53:05 +02:00
|
|
|
Location vaultLocation = context.faction.getVault();
|
|
|
|
ItemStack vault = new ItemBuilder(Material.CHEST)
|
|
|
|
.amount(1)
|
|
|
|
.name(FactionsPlugin.getInstance().getConfig().getString("fvault.Item.Name"))
|
|
|
|
.lore(FactionsPlugin.getInstance().getConfig().getStringList("fvault.Item.Lore"))
|
|
|
|
.build();
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
//check if vault is set
|
|
|
|
if (vaultLocation != null) {
|
|
|
|
context.msg(TL.COMMAND_GETVAULT_ALREADYSET);
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
//has enough money?
|
|
|
|
int amount = FactionsPlugin.getInstance().getConfig().getInt("fvault.Price");
|
|
|
|
if (!context.fPlayer.hasMoney(amount)) {
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
//success :)
|
2020-04-09 23:53:05 +02:00
|
|
|
context.fPlayer.takeMoney(amount);
|
2019-09-15 11:19:06 +02:00
|
|
|
context.player.getInventory().addItem(vault);
|
|
|
|
context.fPlayer.msg(TL.COMMAND_GETVAULT_RECEIVE);
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_GETVAULT_DESCRIPTION;
|
|
|
|
}
|
2018-03-27 01:42:26 +02:00
|
|
|
|
|
|
|
}
|