Introduced Brigadier Command System. More Formatting Coming in next commit.

This commit is contained in:
Driftay
2019-09-14 15:13:01 -04:00
parent b06e6e0f04
commit 3c9b606bb9
207 changed files with 4465 additions and 4017 deletions

View File

@@ -2,8 +2,12 @@ package com.massivecraft.factions.cmd.claim;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements;
import com.massivecraft.factions.cmd.FCommand;
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;
import org.bukkit.block.BlockFace;
@@ -23,32 +27,28 @@ public class CmdClaimLine extends FCommand {
this.optionalArgs.put("direction", "facing");
this.optionalArgs.put("faction", "you");
this.permission = Permission.CLAIM_LINE.node;
this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
this.requirements = new CommandRequirements.Builder(Permission.CLAIM_LINE)
.playerOnly()
.memberOnly()
.withAction(PermissableAction.TERRITORY)
.build();
}
@Override
public void perform() {
public void perform(CommandContext context) {
// Args
Integer amount = this.argAsInt(0, 1); // Default to 1
Integer amount = context.argAsInt(0, 1); // Default to 1
if (amount > Conf.lineClaimLimit) {
fme.msg(TL.COMMAND_CLAIMLINE_ABOVEMAX, Conf.lineClaimLimit);
context.fPlayer.msg(TL.COMMAND_CLAIMLINE_ABOVEMAX, Conf.lineClaimLimit);
return;
}
String direction = this.argAsString(1);
String direction = context.argAsString(1);
BlockFace blockFace;
if (direction == null) {
blockFace = axis[Math.round(me.getLocation().getYaw() / 90f) & 0x3];
blockFace = axis[Math.round(context.player.getLocation().getYaw() / 90f) & 0x3];
} else if (direction.equalsIgnoreCase("north")) {
blockFace = BlockFace.NORTH;
} else if (direction.equalsIgnoreCase("east")) {
@@ -58,16 +58,26 @@ public class CmdClaimLine extends FCommand {
} else if (direction.equalsIgnoreCase("west")) {
blockFace = BlockFace.WEST;
} else {
fme.msg(TL.COMMAND_CLAIMLINE_NOTVALID, direction);
context.msg(TL.COMMAND_CLAIMLINE_NOTVALID, direction);
return;
}
final Faction forFaction = this.argAsFaction(2, myFaction);
Location location = me.getLocation();
final Faction forFaction = context.argAsFaction(2, context.faction);
if (forFaction != context.fPlayer.getFaction()) {
if (!context.fPlayer.isAdminBypassing()) {
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
context.msg(TL.COMMAND_CLAIM_DENIED);
return;
}
}
}
Location location = context.player.getLocation();
// TODO: make this a task like claiming a radius?
for (int i = 0; i < amount; i++) {
fme.attemptClaim(forFaction, location, true);
context.fPlayer.attemptClaim(forFaction, location, true);
location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16);
}
}