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; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.SaberFactions;
import com.massivecraft.factions.zcore.util.TL;
public class CmdPoints extends FCommand { 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) { if (faction == null) {
fme.msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", args.get(0))); 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)); 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; 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; 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 CmdInventorySee cmdInventorySee = new CmdInventorySee();
public CmdFGlobal cmdFGlobal = new CmdFGlobal(); public CmdFGlobal cmdFGlobal = new CmdFGlobal();
public CmdViewChest cmdViewChest = new CmdViewChest(); public CmdViewChest cmdViewChest = new CmdViewChest();
public CmdPoints cmdPoints = new CmdPoints();
@ -237,6 +238,10 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdInventorySee); this.addSubCommand(this.cmdInventorySee);
} }
if(SaberFactions.plugin.getConfig().getBoolean("f-points.Enabled")){
this.addSubCommand(cmdPoints);
}
if(SaberFactions.plugin.getConfig().getBoolean("f-alts.Enabled")){ if(SaberFactions.plugin.getConfig().getBoolean("f-alts.Enabled")){
this.addSubCommand(cmdAlts); this.addSubCommand(cmdAlts);
} }

View File

@ -101,6 +101,8 @@ public enum Permission {
TOP("top"), TOP("top"),
VIEWCHEST("viewchest"), VIEWCHEST("viewchest"),
ADDPOINTS("addpoints"), ADDPOINTS("addpoints"),
REMOVEPOINTS("removepoints"),
SETPOINTS("setpoints"),
VAULT("vault"), VAULT("vault"),
GETVAULT("getvault"), GETVAULT("getvault"),
SETMAXVAULTS("setmaxvaults"), SETMAXVAULTS("setmaxvaults"),

View File

@ -543,9 +543,19 @@ public enum TL {
COMMAND_PERM_TOP("RCT MEM OFF ALLY TRUCE NEUT ENEMY"), COMMAND_PERM_TOP("RCT MEM OFF ALLY TRUCE NEUT ENEMY"),
COMMAND_POINTS_FAILURE("&c&l[!] &c{faction} does not exist."), 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_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_DESCRIPTION("Toggles a permanent faction option"),
COMMAND_PERMANENT_GRANT("&c&l[!]&7 added permanent status to"), COMMAND_PERMANENT_GRANT("&c&l[!]&7 added permanent status to"),
COMMAND_PERMANENT_REVOKE("&c&l[!]&7 removed permanent status from"), COMMAND_PERMANENT_REVOKE("&c&l[!]&7 removed permanent status from"),

View File

@ -74,6 +74,7 @@ public enum TagReplacer {
FACTION_DEATHS(TagType.FACTION, "{faction-deaths}"), FACTION_DEATHS(TagType.FACTION, "{faction-deaths}"),
FACTION_BANCOUNT(TagType.FACTION, "{faction-bancount}"), FACTION_BANCOUNT(TagType.FACTION, "{faction-bancount}"),
FACTION_STRIKES(TagType.FACTION, "{strikes}"), FACTION_STRIKES(TagType.FACTION, "{strikes}"),
FACTION_POINTS(TagType.FACTION, "{faction-points}"),
/** /**
* General variables, require no faction or player * General variables, require no faction or player
@ -259,6 +260,8 @@ public enum TagReplacer {
return String.valueOf(fac.getBannedPlayers().size()); return String.valueOf(fac.getBannedPlayers().size());
case FACTION_STRIKES: case FACTION_STRIKES:
return String.valueOf(fac.getStrikes()); return String.valueOf(fac.getStrikes());
case FACTION_POINTS:
return String.valueOf(fac.getPoints());
default: default:
} }

View File

@ -275,18 +275,19 @@ hcf:
show: show:
# First line can be {header} for default header, or any string (we recommend &m for smooth lines ;plugin) # First line can be {header} for default header, or any string (we recommend &m for smooth lines ;plugin)
- '&8&m--------------&7 &8<&e{faction}&8> &8&m--------------' - '&8&m--------------&7 &8<&e{faction}&8> &8&m--------------'
- '&6 * &eOwner &7{leader}' - '&6 * &eOwner: &7{leader}'
- '&6 * &eDescription &7{description}' - '&6 * &eDescription: &7{description}'
- '&6 * &eLand / Power / Max Power: &7{chunks} &8/ &7{power} &8/ &7{maxPower}' - '&6 * &eLand / Power / Max Power: &7{chunks} &8/ &7{power} &8/ &7{maxPower}'
- '&6 * &eFaction Strikes: &7{strikes}' - '&6 * &eFaction Strikes: &7{strikes}'
- '&6 * &eFounded &7{create-date}' - '&6 * &eFaction Points: &7{faction-points}'
- '&6 * &eBalance &f{faction-balance}' - '&6 * &eFounded: &7{create-date}'
- '&6 * &eAllies &c{allies-list}' - '&6 * &eBalance: &f{faction-balance}'
- '&6 * &eEnemies &c{enemies-list}' - '&6 * &eAllies: &c{allies-list}'
- '&6 * &eOnline Members &8(&7{online}/{members}&8) &7{online-list}' - '&6 * &eEnemies: &c{enemies-list}'
- '&6 * &eOffline Members &8(&7{offline}/{members}&8) &7{offline-list}' - '&6 * &eOnline Members: &8(&7{online}/{members}&8) &7{online-list}'
- '&6 * &eAlts &8{alts}' - '&6 * &eOffline Members: &8(&7{offline}/{members}&8) &7{offline-list}'
- '&6 * &eBans &7{faction-bancount}' - '&6 * &eAlts: &8{alts}'
- '&6 * &eBans: &7{faction-bancount}'
- '&8&m----------------------------------------' - '&8&m----------------------------------------'
# For a /f show that does not display fancy messages that are essentially empty, use minimal-show # For a /f show that does not display fancy messages that are essentially empty, use minimal-show
minimal-show: false minimal-show: false
@ -800,6 +801,14 @@ Falling-Block-Fix:
f-grace: f-grace:
Enabled: true Enabled: true
############################################################
# +------------------------------------------------------+ #
# | Faction Points | #
# +------------------------------------------------------+ #
############################################################
f-points:
Enabled: true
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | Faction Focus | # # | Faction Focus | #
@ -1219,6 +1228,7 @@ Tntfill:
# - {faction-kills} : # of kills the faction has # - {faction-kills} : # of kills the faction has
# - {faction-deaths}: # of deaths the faction has # - {faction-deaths}: # of deaths the faction has
# - {faction-bancount} : # of bans the faction has # - {faction-bancount} : # of bans the faction has
# - {faction-points} : # of points a faction has
# Faction Permissions GUI variables. Can only be used in GUI # Faction Permissions GUI variables. Can only be used in GUI
# - {relation} : Shows relation name (Can be used in action and relation) # - {relation} : Shows relation name (Can be used in action and relation)
# - {relation-color} : Relation color # - {relation-color} : Relation color