Saber-Factions/src/main/java/com/massivecraft/factions/cmd/CmdVault.java

82 lines
2.4 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import com.drtshock.playervaults.PlayerVaults;
2018-03-02 03:54:14 +01:00
import com.drtshock.playervaults.translations.Lang;
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;
import com.massivecraft.factions.Conf;
2018-03-26 23:43:15 +02:00
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.P;
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;
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;
public class CmdVault extends FCommand {
public CmdVault() {
this.aliases.add("vault");
//this.requiredArgs.add("");
2018-03-26 23:43:15 +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
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;
}
2018-03-26 23:43:15 +02:00
if (fme.isInVault()){
me.closeInventory();
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);
}
@Override
public TL getUsageTranslation() {
2016-05-31 01:25:27 +02:00
return TL.COMMAND_VAULT_DESCRIPTION;
}
}