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

@@ -18,61 +18,51 @@ public class CmdColeader extends FCommand {
this.aliases.add("setco");
this.optionalArgs.put("player name", "name");
//this.optionalArgs.put("", "");
this.permission = Permission.COLEADER.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = true;
this.requirements = new CommandRequirements.Builder(Permission.COLEADER)
.memberOnly()
.withRole(Role.LEADER)
.build();
}
@Override
public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0);
public void perform(CommandContext context) {
FPlayer you = context.argAsBestFPlayerMatch(0);
if (you == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_COLEADER_CANDIDATES.toString()).color(ChatColor.GOLD);
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) {
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
String s = player.getName();
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s);
}
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) {
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.MODERATOR)) {
String s = player.getName();
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s);
}
sendFancyMessage(msg);
context.sendFancyMessage(msg);
return;
}
boolean permAny = Permission.COLEADER_ANY.has(sender, false);
boolean permAny = Permission.COLEADER_ANY.has(context.sender, false);
Faction targetFaction = you.getFaction();
if (you.isAlt()) {
msg(ChatColor.RED + "You can not promote alt accounts.");
if (targetFaction != context.faction && !permAny) {
context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
return;
}
if (targetFaction != myFaction && !permAny) {
msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true));
if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
context.msg(TL.COMMAND_COLEADER_NOTADMIN);
return;
}
if (fme != null && fme.getRole() != Role.LEADER && !permAny) {
msg(TL.COMMAND_COLEADER_NOTADMIN);
return;
}
if (you == fme && !permAny) {
msg(TL.COMMAND_COLEADER_SELF);
if (you == context.fPlayer && !permAny) {
context.msg(TL.COMMAND_COLEADER_SELF);
return;
}
if (you.getRole() == Role.LEADER) {
msg(TL.COMMAND_COLEADER_TARGETISADMIN);
context.msg(TL.COMMAND_COLEADER_TARGETISADMIN);
return;
}
@@ -80,12 +70,12 @@ public class CmdColeader extends FCommand {
// Revoke
you.setRole(Role.MODERATOR);
targetFaction.msg(TL.COMMAND_COLEADER_REVOKED, you.describeTo(targetFaction, true));
msg(TL.COMMAND_COLEADER_REVOKES, you.describeTo(fme, true));
context.msg(TL.COMMAND_COLEADER_REVOKES, you.describeTo(context.fPlayer, true));
} else {
// Give
you.setRole(Role.COLEADER);
targetFaction.msg(TL.COMMAND_COLEADER_PROMOTED, you.describeTo(targetFaction, true));
msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(fme, true));
context.msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(context.fPlayer, true));
}
}
@@ -94,3 +84,4 @@ public class CmdColeader extends FCommand {
return TL.COMMAND_COLEADER_DESCRIPTION;
}
}