Point System Added
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -101,6 +101,8 @@ public enum Permission {
|
||||
TOP("top"),
|
||||
VIEWCHEST("viewchest"),
|
||||
ADDPOINTS("addpoints"),
|
||||
REMOVEPOINTS("removepoints"),
|
||||
SETPOINTS("setpoints"),
|
||||
VAULT("vault"),
|
||||
GETVAULT("getvault"),
|
||||
SETMAXVAULTS("setmaxvaults"),
|
||||
|
||||
@@ -543,9 +543,19 @@ public enum TL {
|
||||
COMMAND_PERM_TOP("RCT MEM OFF ALLY TRUCE NEUT ENEMY"),
|
||||
|
||||
COMMAND_POINTS_FAILURE("&c&l[!] &c{faction} does not exist."),
|
||||
COMMAND_POINTS_SUCCESSFUL("&c&l[!] &7You have given &b%1$s &e%2$s &7points!"),
|
||||
COMMAND_POINTS_SUCCESSFUL("&c&l[!] &7You have taken &e%1$s &7points from &b%2$s&7. &b%2$s's &7New Point Balance: &e%3$s"),
|
||||
COMMAND_POINTS_INSUFFICIENT("&c&l[!] &7You may not add/set/remove a negative number of points to a faction!"),
|
||||
COMMAND_POINTS_DESCRIPTION("General Command For Faction Points"),
|
||||
|
||||
COMMAND_ADDPOINTS_DESCRIPTION("Add Points to Faction"),
|
||||
|
||||
|
||||
COMMAND_REMOVEPOINTS_SUCCESSFUL("&c&l[!] &7You have taken &e%1$s &7points from &b%2$s&7. &b%2$s's &7New Point Balance: &e%3$s"),
|
||||
COMMAND_REMOVEPOINTS_DESCRIPTION("Remove Points from a Faction"),
|
||||
|
||||
COMMAND_SETPOINTS_SUCCESSFUL("&c&l[!] &7You have set &e%1$s &7points to &b%2$s&7. &b%2$s's &7New Point Balance: &e%3$s"),
|
||||
COMMAND_SETPOINTS_DESCRIPTION("Set Points of a Faction"),
|
||||
|
||||
COMMAND_PERMANENT_DESCRIPTION("Toggles a permanent faction option"),
|
||||
COMMAND_PERMANENT_GRANT("&c&l[!]&7 added permanent status to"),
|
||||
COMMAND_PERMANENT_REVOKE("&c&l[!]&7 removed permanent status from"),
|
||||
|
||||
@@ -74,6 +74,7 @@ public enum TagReplacer {
|
||||
FACTION_DEATHS(TagType.FACTION, "{faction-deaths}"),
|
||||
FACTION_BANCOUNT(TagType.FACTION, "{faction-bancount}"),
|
||||
FACTION_STRIKES(TagType.FACTION, "{strikes}"),
|
||||
FACTION_POINTS(TagType.FACTION, "{faction-points}"),
|
||||
|
||||
/**
|
||||
* General variables, require no faction or player
|
||||
@@ -259,6 +260,8 @@ public enum TagReplacer {
|
||||
return String.valueOf(fac.getBannedPlayers().size());
|
||||
case FACTION_STRIKES:
|
||||
return String.valueOf(fac.getStrikes());
|
||||
case FACTION_POINTS:
|
||||
return String.valueOf(fac.getPoints());
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user