2016-05-31 01:22:45 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.drtshock.playervaults.PlayerVaults;
|
2018-03-02 03:54:14 +01:00
|
|
|
import com.drtshock.playervaults.translations.Lang;
|
2016-05-31 01:22:45 +02:00
|
|
|
import com.drtshock.playervaults.vaultmanagement.UUIDVaultManager;
|
|
|
|
import com.drtshock.playervaults.vaultmanagement.VaultOperations;
|
|
|
|
import com.drtshock.playervaults.vaultmanagement.VaultViewInfo;
|
2018-03-26 23:43:15 +02:00
|
|
|
import com.massivecraft.factions.Board;
|
2016-05-31 01:22:45 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
2018-03-26 23:43:15 +02:00
|
|
|
import com.massivecraft.factions.FLocation;
|
|
|
|
import com.massivecraft.factions.P;
|
2016-05-31 01:22:45 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2018-03-26 23:43:15 +02:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.block.Chest;
|
2016-05-31 01:22:45 +02:00
|
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
import org.bukkit.entity.Player;
|
2018-03-26 23:43:15 +02:00
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.inventory.Inventory;
|
2016-05-31 01:22:45 +02:00
|
|
|
|
|
|
|
public class CmdVault extends FCommand {
|
|
|
|
|
|
|
|
public CmdVault() {
|
|
|
|
this.aliases.add("vault");
|
|
|
|
|
|
|
|
//this.requiredArgs.add("");
|
2018-03-26 23:43:15 +02:00
|
|
|
|
2016-05-31 01:22:45 +02:00
|
|
|
|
|
|
|
this.permission = Permission.VAULT.node;
|
|
|
|
this.disableOnLock = false;
|
|
|
|
|
|
|
|
senderMustBePlayer = true;
|
|
|
|
senderMustBeMember = true;
|
|
|
|
senderMustBeModerator = false;
|
|
|
|
senderMustBeAdmin = false;
|
|
|
|
}
|
|
|
|
|
2018-03-26 23:43:15 +02:00
|
|
|
@Override
|
2016-05-31 01:22:45 +02:00
|
|
|
public void perform() {
|
2018-03-26 23:43:15 +02:00
|
|
|
if (!P.p.getConfig().getBoolean("fvault.Enabled")){
|
|
|
|
fme.sendMessage("This command is disabled!");
|
|
|
|
return;
|
2016-05-31 01:22:45 +02:00
|
|
|
}
|
|
|
|
|
2018-03-26 23:43:15 +02:00
|
|
|
if (fme.isInVault()){
|
|
|
|
me.closeInventory();
|
2016-05-31 01:22:45 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-03-26 23:43:15 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
2016-05-31 01:25:27 +02:00
|
|
|
return TL.COMMAND_VAULT_DESCRIPTION;
|
2016-05-31 01:22:45 +02:00
|
|
|
}
|
|
|
|
}
|