Point System Added

This commit is contained in:
Driftay
2019-07-01 00:30:23 -04:00
parent 59410de5ab
commit 61f13c92d1
9 changed files with 198 additions and 15 deletions

View File

@@ -1,8 +1,49 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.SaberFactions;
import com.massivecraft.factions.zcore.util.TL;
public class CmdPoints extends FCommand {
public CmdPointsRemove cmdPointsRemove = new CmdPointsRemove();
public CmdPointsSet cmdPointsSet = new CmdPointsSet();
public CmdPointsAdd cmdPointsAdd = new CmdPointsAdd();
public CmdPoints(){
super();
this.aliases.add("points");
this.aliases.add("point");
this.disableOnLock = false;
this.disableOnSpam = false;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
this.addSubCommand(this.cmdPointsAdd);
this.addSubCommand(this.cmdPointsRemove);
this.addSubCommand(this.cmdPointsSet);
}
@Override
public void perform() {
if (!SaberFactions.plugin.getConfig().getBoolean("f-points.Enabled", false)) {
fme.msg(TL.GENERIC_DISABLED);
return;
}
this.commandChain.add(this);
SaberFactions.plugin.cmdAutoHelp.execute(this.sender, this.args, this.commandChain);
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_POINTS_DESCRIPTION;
}
}

View File

@@ -36,11 +36,15 @@ public class CmdPointsAdd extends FCommand {
if (faction == null) {
fme.msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", args.get(0)));
return;
}
if(argAsInt(1) <= 0){
fme.msg(TL.COMMAND_POINTS_INSUFFICIENT);
return;
}
assert faction != null;
faction.setPoints(faction.getPoints() + argAsInt(1));
fme.msg(TL.COMMAND_POINTS_SUCCESSFUL, faction, argAsInt(1));
fme.msg(TL.COMMAND_POINTS_SUCCESSFUL, argAsInt(1), faction, faction.getPoints());
}

View File

@@ -1,4 +1,58 @@
package com.massivecraft.factions.cmd;
public class CmdPointsRemove {
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdPointsRemove extends FCommand {
public CmdPointsRemove() {
super();
this.aliases.add("remove");
this.requiredArgs.add("faction");
this.requiredArgs.add("# of points");
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));
if (faction == null) {
fme.msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", args.get(0)));
return;
}
if(argAsInt(1) <= 0){
fme.msg(TL.COMMAND_POINTS_INSUFFICIENT);
return;
}
faction.setPoints(faction.getPoints() - argAsInt(1));
fme.msg(TL.COMMAND_REMOVEPOINTS_SUCCESSFUL, argAsInt(1), faction, faction.getPoints());
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_REMOVEPOINTS_DESCRIPTION;
}
}

View File

@@ -1,4 +1,58 @@
package com.massivecraft.factions.cmd;
public class CmdPointsSet {
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdPointsSet extends FCommand{
public CmdPointsSet() {
super();
this.aliases.add("set");
this.requiredArgs.add("faction");
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;
}
@Override
public void perform() {
Faction faction = Factions.getInstance().getByTag(args.get(0));
if (faction == null) {
fme.msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", args.get(0)));
return;
}
if(argAsInt(1) < 0){
fme.msg(TL.COMMAND_POINTS_INSUFFICIENT);
return;
}
faction.setPoints(faction.getPoints() - argAsInt(1));
fme.msg(TL.COMMAND_SETPOINTS_SUCCESSFUL, argAsInt(1), faction, faction.getPoints());
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_SETPOINTS_DESCRIPTION;
}
}

View File

@@ -113,6 +113,7 @@ public class FCmdRoot extends FCommand {
public CmdInventorySee cmdInventorySee = new CmdInventorySee();
public CmdFGlobal cmdFGlobal = new CmdFGlobal();
public CmdViewChest cmdViewChest = new CmdViewChest();
public CmdPoints cmdPoints = new CmdPoints();
@@ -237,6 +238,10 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdInventorySee);
}
if(SaberFactions.plugin.getConfig().getBoolean("f-points.Enabled")){
this.addSubCommand(cmdPoints);
}
if(SaberFactions.plugin.getConfig().getBoolean("f-alts.Enabled")){
this.addSubCommand(cmdAlts);
}