Introduced Brigadier Command System. More Formatting Coming in next commit.
This commit is contained in:
@@ -2,9 +2,8 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Location;
|
||||
@@ -17,57 +16,48 @@ public class CmdVault extends FCommand {
|
||||
public CmdVault() {
|
||||
this.aliases.add("vault");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
|
||||
|
||||
this.permission = Permission.VAULT.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.VAULT)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.VAULT)
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
public void perform(CommandContext context) {
|
||||
|
||||
if (!P.p.getConfig().getBoolean("fvault.Enabled")) {
|
||||
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");
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fvault.Enabled")) {
|
||||
context.fPlayer.sendMessage("This command is disabled!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fme.isInVault()) {
|
||||
me.closeInventory();
|
||||
if (context.fPlayer.isInVault()) {
|
||||
context.player.closeInventory();
|
||||
return;
|
||||
}
|
||||
fme.setInVault(true);
|
||||
Location vaultLocation = fme.getFaction().getVault();
|
||||
|
||||
context.fPlayer.setInVault(true);
|
||||
Location vaultLocation = context.faction.getVault();
|
||||
if (vaultLocation == null) {
|
||||
fme.msg(TL.COMMAND_VAULT_INVALID);
|
||||
context.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);
|
||||
if (Board.getInstance().getFactionAt(vaultFLocation) != context.faction) {
|
||||
context.faction.setVault(null);
|
||||
context.msg(TL.COMMAND_VAULT_INVALID);
|
||||
return;
|
||||
}
|
||||
if (vaultLocation.getBlock().getType() != Material.CHEST) {
|
||||
fme.getFaction().setVault(null);
|
||||
fme.msg(TL.COMMAND_VAULT_INVALID);
|
||||
context.faction.setVault(null);
|
||||
context.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);
|
||||
context.msg(TL.COMMAND_VAULT_OPENING);
|
||||
context.player.openInventory(chestInv);
|
||||
|
||||
|
||||
}
|
||||
@@ -76,4 +66,5 @@ public class CmdVault extends FCommand {
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_VAULT_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user