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

@@ -1,13 +1,13 @@
package com.massivecraft.factions.cmd.roles;
import com.massivecraft.factions.FPlayer;
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.struct.Role;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
public class FPromoteCommand extends FCommand {
@@ -15,33 +15,25 @@ public class FPromoteCommand extends FCommand {
public FPromoteCommand() {
super();
this.requiredArgs.add("player");
this.permission = Permission.PROMOTE.node;
this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
this.requirements = new CommandRequirements.Builder(Permission.PROMOTE)
.playerOnly()
.memberOnly()
.withAction(PermissableAction.PROMOTE)
.build();
}
@Override
public void perform() {
FPlayer target = this.argAsBestFPlayerMatch(0);
public void perform(CommandContext context) {
FPlayer target = context.argAsBestFPlayerMatch(0);
if (target == null) {
msg(TL.GENERIC_NOPLAYERFOUND, this.argAsString(0));
context.msg(TL.GENERIC_NOPLAYERFOUND, context.argAsString(0));
return;
}
if (!target.getFaction().equals(myFaction)) {
msg(TL.COMMAND_PROMOTE_WRONGFACTION, target.getName());
return;
}
if (target.isAlt()) {
msg(ChatColor.RED + "You can not edit the rank of alt accounts.");
if (!target.getFaction().equals(context.faction)) {
context.msg(TL.COMMAND_PROMOTE_WRONGFACTION, target.getName());
return;
}
@@ -49,36 +41,31 @@ public class FPromoteCommand extends FCommand {
Role promotion = Role.getRelative(current, +relative);
// Now it ain't that messy
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.PROMOTE);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_NOPERMISSION, "manage ranks");
return;
}
if (target == fme) {
fme.msg(TL.COMMAND_PROMOTE_NOTSELF);
if (!context.fPlayer.isAdminBypassing()) {
if (target == context.fPlayer) {
context.msg(TL.COMMAND_PROMOTE_NOTSELF);
return;
}
// Don't allow people to manage role of their same rank
if (fme.getRole() == current) {
fme.msg(TL.COMMAND_PROMOTE_NOT_SAME);
if (context.fPlayer.getRole() == current) {
context.msg(TL.COMMAND_PROMOTE_NOT_SAME);
return;
}
// Don't allow people to promote people to their same or higher rank.
if (fme.getRole().value <= promotion.value) {
fme.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);
if (context.fPlayer.getRole().value <= promotion.value) {
context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);
return;
}
}
if (promotion == null) {
fme.msg(TL.COMMAND_PROMOTE_NOTTHATPLAYER);
context.msg(TL.COMMAND_PROMOTE_NOTTHATPLAYER);
return;
}
// Don't allow people to promote people to their same or higher rnak.
if (fme.getRole().value <= promotion.value) {
fme.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);
if (context.fPlayer.getRole().value <= promotion.value) {
context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);
return;
}
@@ -90,7 +77,7 @@ public class FPromoteCommand extends FCommand {
target.msg(TL.COMMAND_PROMOTE_TARGET, action, promotion.nicename);
}
fme.msg(TL.COMMAND_PROMOTE_SUCCESS, action, target.getName(), promotion.nicename);
context.msg(TL.COMMAND_PROMOTE_SUCCESS, action, target.getName(), promotion.nicename);
}
@Override