Introduced Brigadier Command System. More Formatting Coming in next commit.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package com.massivecraft.factions.cmd.points;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
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.util.TL;
|
||||
|
||||
public class CmdPoints extends FCommand {
|
||||
@@ -14,13 +17,9 @@ public class CmdPoints extends FCommand {
|
||||
super();
|
||||
this.aliases.add("points");
|
||||
|
||||
this.disableOnLock = false;
|
||||
this.disableOnSpam = false;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.POINTS)
|
||||
.playerOnly()
|
||||
.build();
|
||||
|
||||
|
||||
this.addSubCommand(this.cmdPointsAdd);
|
||||
@@ -30,13 +29,13 @@ public class CmdPoints extends FCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!P.p.getConfig().getBoolean("f-points.Enabled", true)) {
|
||||
msg(TL.GENERIC_DISABLED);
|
||||
public void perform(CommandContext context) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("f-points.Enabled", true)) {
|
||||
context.msg(TL.GENERIC_DISABLED);
|
||||
return;
|
||||
}
|
||||
this.commandChain.add(this);
|
||||
P.p.cmdAutoHelp.execute(this.sender, this.args, this.commandChain);
|
||||
context.commandChain.add(this);
|
||||
FactionsPlugin.getInstance().cmdAutoHelp.execute(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.massivecraft.factions.cmd.points;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
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.util.TL;
|
||||
@@ -17,44 +19,34 @@ public class CmdPointsAdd extends FCommand {
|
||||
this.requiredArgs.add("# of points");
|
||||
|
||||
|
||||
this.errorOnToManyArgs = false;
|
||||
//this.optionalArgs
|
||||
|
||||
this.permission = Permission.ADDPOINTS.node;
|
||||
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.ADDPOINTS)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction faction = Factions.getInstance().getByTag(args.get(0));
|
||||
public void perform(CommandContext context) {
|
||||
Faction faction = Factions.getInstance().getByTag(context.args.get(0));
|
||||
|
||||
if (faction == null) {
|
||||
FPlayer fPlayer = this.argAsFPlayer(0);
|
||||
FPlayer fPlayer = context.argAsFPlayer(0);
|
||||
if (fPlayer != null) {
|
||||
faction = fPlayer.getFaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (faction == null || faction.isWilderness()) {
|
||||
msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", args.get(0)));
|
||||
context.msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", context.args.get(0)));
|
||||
return;
|
||||
}
|
||||
if (argAsInt(1) <= 0) {
|
||||
msg(TL.COMMAND_POINTS_INSUFFICIENT);
|
||||
if (context.argAsInt(1) <= 0) {
|
||||
context.msg(TL.COMMAND_POINTS_INSUFFICIENT);
|
||||
return;
|
||||
}
|
||||
|
||||
faction.setPoints(faction.getPoints() + argAsInt(1));
|
||||
faction.setPoints(faction.getPoints() + context.argAsInt(1));
|
||||
|
||||
msg(TL.COMMAND_POINTS_SUCCESSFUL, argAsInt(1), faction.getTag(), faction.getPoints());
|
||||
context.msg(TL.COMMAND_POINTS_SUCCESSFUL, context.argAsInt(1), faction.getTag(), faction.getPoints());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.massivecraft.factions.cmd.points;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
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.util.TL;
|
||||
@@ -16,44 +18,34 @@ public class CmdPointsRemove extends FCommand {
|
||||
this.requiredArgs.add("faction/player");
|
||||
this.requiredArgs.add("# of points");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.REMOVEPOINTS)
|
||||
.build();
|
||||
|
||||
this.errorOnToManyArgs = false;
|
||||
//this.optionalArgs
|
||||
|
||||
this.permission = Permission.REMOVEPOINTS.node;
|
||||
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction faction = Factions.getInstance().getByTag(args.get(0));
|
||||
public void perform(CommandContext context) {
|
||||
Faction faction = Factions.getInstance().getByTag(context.args.get(0));
|
||||
|
||||
|
||||
FPlayer fPlayer = this.argAsFPlayer(0);
|
||||
FPlayer fPlayer = context.argAsFPlayer(0);
|
||||
if (fPlayer != null) {
|
||||
faction = fPlayer.getFaction();
|
||||
}
|
||||
|
||||
if (faction == null || faction.isWilderness()) {
|
||||
msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", args.get(0)));
|
||||
context.msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", context.args.get(0)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (argAsInt(1) <= 0) {
|
||||
msg(TL.COMMAND_POINTS_INSUFFICIENT);
|
||||
if (context.argAsInt(1) <= 0) {
|
||||
context.msg(TL.COMMAND_POINTS_INSUFFICIENT);
|
||||
return;
|
||||
}
|
||||
|
||||
faction.setPoints(faction.getPoints() - argAsInt(1));
|
||||
msg(TL.COMMAND_REMOVEPOINTS_SUCCESSFUL, argAsInt(1), faction.getTag(), faction.getPoints());
|
||||
faction.setPoints(faction.getPoints() - context.argAsInt(1));
|
||||
context.msg(TL.COMMAND_REMOVEPOINTS_SUCCESSFUL, context.argAsInt(1), faction.getTag(), faction.getPoints());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.massivecraft.factions.cmd.points;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
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.util.TL;
|
||||
@@ -17,42 +19,32 @@ public class CmdPointsSet extends FCommand {
|
||||
this.requiredArgs.add("# of points");
|
||||
|
||||
|
||||
this.errorOnToManyArgs = false;
|
||||
//this.optionalArgs
|
||||
|
||||
this.permission = Permission.SETPOINTS.node;
|
||||
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.SETPOINTS)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction faction = Factions.getInstance().getByTag(args.get(0));
|
||||
public void perform(CommandContext context) {
|
||||
Faction faction = Factions.getInstance().getByTag(context.args.get(0));
|
||||
|
||||
FPlayer fPlayer = this.argAsFPlayer(0);
|
||||
FPlayer fPlayer = context.argAsFPlayer(0);
|
||||
if (fPlayer != null) {
|
||||
faction = fPlayer.getFaction();
|
||||
}
|
||||
|
||||
if (faction == null || faction.isWilderness()) {
|
||||
msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", args.get(0)));
|
||||
context.msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", context.args.get(0)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (argAsInt(1) < 0) {
|
||||
msg(TL.COMMAND_POINTS_INSUFFICIENT);
|
||||
if (context.argAsInt(1) < 0) {
|
||||
context.msg(TL.COMMAND_POINTS_INSUFFICIENT);
|
||||
return;
|
||||
}
|
||||
|
||||
faction.setPoints(argAsInt(1));
|
||||
msg(TL.COMMAND_SETPOINTS_SUCCESSFUL, argAsInt(1), faction.getTag(), faction.getPoints());
|
||||
faction.setPoints(context.argAsInt(1));
|
||||
context.msg(TL.COMMAND_SETPOINTS_SUCCESSFUL, context.argAsInt(1), faction.getTag(), faction.getPoints());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user