2016-05-31 01:22:45 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
2018-03-26 23:43:15 +02:00
|
|
|
import com.massivecraft.factions.Board;
|
|
|
|
import com.massivecraft.factions.FLocation;
|
2019-06-29 03:49:46 +02:00
|
|
|
import com.massivecraft.factions.SaberFactions;
|
2016-05-31 01:22:45 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2018-04-25 02:32:26 +02:00
|
|
|
import com.massivecraft.factions.zcore.fperms.Access;
|
|
|
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
2016-05-31 01:22:45 +02:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2018-03-26 23:43:15 +02:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.block.Chest;
|
|
|
|
import org.bukkit.inventory.Inventory;
|
2016-05-31 01:22:45 +02:00
|
|
|
|
|
|
|
public class CmdVault extends FCommand {
|
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
public CmdVault() {
|
|
|
|
this.aliases.add("vault");
|
2016-05-31 01:22:45 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
//this.requiredArgs.add("");
|
2018-03-26 23:43:15 +02:00
|
|
|
|
2016-05-31 01:22:45 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
this.permission = Permission.VAULT.node;
|
|
|
|
this.disableOnLock = false;
|
2016-05-31 01:22:45 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
senderMustBePlayer = true;
|
|
|
|
senderMustBeMember = true;
|
|
|
|
senderMustBeModerator = false;
|
|
|
|
senderMustBeAdmin = false;
|
2018-12-21 22:46:10 +01:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
}
|
2016-05-31 01:22:45 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
@Override
|
|
|
|
public void perform() {
|
2018-04-25 02:32:26 +02:00
|
|
|
|
2019-06-29 03:49:46 +02:00
|
|
|
if (!SaberFactions.plugin.getConfig().getBoolean("fvault.Enabled")) {
|
2019-03-03 04:51:21 +01:00
|
|
|
fme.sendMessage("This command is disabled!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Access access = fme.getFaction().getAccess(fme, PermissableAction.VAULT);
|
|
|
|
if (access.equals(Access.DENY)) {
|
|
|
|
fme.msg(TL.GENERIC_NOPERMISSION, "vault");
|
|
|
|
return;
|
|
|
|
}
|
2016-05-31 01:22:45 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
if (fme.isInVault()) {
|
|
|
|
me.closeInventory();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fme.setInVault(true);
|
|
|
|
Location vaultLocation = fme.getFaction().getVault();
|
|
|
|
if (vaultLocation == null) {
|
|
|
|
fme.msg(TL.COMMAND_VAULT_INVALID);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
FLocation vaultFLocation = new FLocation(vaultLocation);
|
|
|
|
if (Board.getInstance().getFactionAt(vaultFLocation) != fme.getFaction()) {
|
|
|
|
fme.getFaction().setVault(null);
|
|
|
|
fme.msg(TL.COMMAND_VAULT_INVALID);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (vaultLocation.getBlock().getType() != Material.CHEST) {
|
|
|
|
fme.getFaction().setVault(null);
|
|
|
|
fme.msg(TL.COMMAND_VAULT_INVALID);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Chest chest = (Chest) vaultLocation.getBlock().getState();
|
|
|
|
Inventory chestInv = chest.getBlockInventory();
|
|
|
|
fme.msg(TL.COMMAND_VAULT_OPENING);
|
|
|
|
me.openInventory(chestInv);
|
2016-05-31 01:22:45 +02:00
|
|
|
|
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
}
|
2016-05-31 01:22:45 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_VAULT_DESCRIPTION;
|
|
|
|
}
|
2016-05-31 01:22:45 +02:00
|
|
|
}
|