Reformat
This commit is contained in:
@@ -10,39 +10,53 @@ import org.bukkit.Bukkit;
|
||||
|
||||
public class CmdAdmin extends FCommand {
|
||||
public CmdAdmin() {
|
||||
super(); this.aliases.add("admin");
|
||||
super();
|
||||
this.aliases.add("admin");
|
||||
|
||||
this.requiredArgs.add("player name");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.ADMIN.node; this.disableOnLock = true;
|
||||
this.permission = Permission.ADMIN.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer fyou = this.argAsBestFPlayerMatch(0); if (fyou == null) { return; }
|
||||
FPlayer fyou = this.argAsBestFPlayerMatch(0);
|
||||
if (fyou == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean permAny = Permission.ADMIN_ANY.has(sender, false); Faction targetFaction = fyou.getFaction();
|
||||
boolean permAny = Permission.ADMIN_ANY.has(sender, false);
|
||||
Faction targetFaction = fyou.getFaction();
|
||||
|
||||
if (targetFaction != myFaction && !permAny) {
|
||||
msg("%s<i> is not a member in your faction.", fyou.describeTo(fme, true)); return;
|
||||
msg("%s<i> is not a member in your faction.", fyou.describeTo(fme, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
|
||||
msg("<b>You are not the faction admin."); return;
|
||||
msg("<b>You are not the faction admin.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fyou == fme && !permAny) {
|
||||
msg("<b>The target player musn't be yourself."); return;
|
||||
msg("<b>The target player musn't be yourself.");
|
||||
return;
|
||||
}
|
||||
|
||||
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
|
||||
if (fyou.getFaction() != targetFaction) {
|
||||
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.i.get(me), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; }
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FPlayer admin = targetFaction.getFPlayerAdmin();
|
||||
@@ -56,7 +70,10 @@ public class CmdAdmin extends FCommand {
|
||||
}
|
||||
|
||||
// promote target player, and demote existing admin if one exists
|
||||
if (admin != null) { admin.setRole(Role.MODERATOR); } fyou.setRole(Role.ADMIN);
|
||||
if (admin != null) {
|
||||
admin.setRole(Role.MODERATOR);
|
||||
}
|
||||
fyou.setRole(Role.ADMIN);
|
||||
msg("<i>You have promoted %s<i> to the position of faction admin.", fyou.describeTo(fme, true));
|
||||
|
||||
// Inform all players
|
||||
|
||||
@@ -6,27 +6,36 @@ import com.massivecraft.factions.struct.Role;
|
||||
|
||||
public class CmdAutoClaim extends FCommand {
|
||||
public CmdAutoClaim() {
|
||||
super(); this.aliases.add("autoclaim");
|
||||
super();
|
||||
this.aliases.add("autoclaim");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.permission = Permission.AUTOCLAIM.node; this.disableOnLock = true;
|
||||
this.permission = Permission.AUTOCLAIM.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction forFaction = this.argAsFaction(0, myFaction);
|
||||
if (forFaction == null || forFaction == fme.getAutoClaimFor()) {
|
||||
fme.setAutoClaimFor(null); msg("<i>Auto-claiming of land disabled."); return;
|
||||
fme.setAutoClaimFor(null);
|
||||
msg("<i>Auto-claiming of land disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fme.canClaimForFaction(forFaction)) {
|
||||
if (myFaction == forFaction) {
|
||||
msg("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString());
|
||||
} else { msg("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(fme)); }
|
||||
} else {
|
||||
msg("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(fme));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,10 @@ import java.util.ArrayList;
|
||||
|
||||
public class CmdAutoHelp extends MCommand<P> {
|
||||
public CmdAutoHelp() {
|
||||
super(P.p); this.aliases.add("?"); this.aliases.add("h"); this.aliases.add("help");
|
||||
super(P.p);
|
||||
this.aliases.add("?");
|
||||
this.aliases.add("h");
|
||||
this.aliases.add("help");
|
||||
|
||||
this.setHelpShort("");
|
||||
|
||||
@@ -17,7 +20,9 @@ public class CmdAutoHelp extends MCommand<P> {
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (this.commandChain.size() == 0) { return; }
|
||||
if (this.commandChain.size() == 0) {
|
||||
return;
|
||||
}
|
||||
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1);
|
||||
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
|
||||
@@ -5,24 +5,32 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdBoom extends FCommand {
|
||||
public CmdBoom() {
|
||||
super(); this.aliases.add("noboom");
|
||||
super();
|
||||
this.aliases.add("noboom");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("on/off", "flip");
|
||||
|
||||
this.permission = Permission.NO_BOOM.node; this.disableOnLock = true;
|
||||
this.permission = Permission.NO_BOOM.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!myFaction.isPeaceful()) {
|
||||
fme.msg("<b>This command is only usable by factions which are specially designated as peaceful."); return;
|
||||
fme.msg("<b>This command is only usable by factions which are specially designated as peaceful.");
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostNoBoom, "to toggle explosions", "for toggling explosions")) { return; }
|
||||
if (!payForCommand(Conf.econCostNoBoom, "to toggle explosions", "for toggling explosions")) {
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, !myFaction.getPeacefulExplosionsEnabled()));
|
||||
|
||||
|
||||
@@ -5,14 +5,19 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdBypass extends FCommand {
|
||||
public CmdBypass() {
|
||||
super(); this.aliases.add("bypass");
|
||||
super();
|
||||
this.aliases.add("bypass");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("on/off", "flip");
|
||||
|
||||
this.permission = Permission.BYPASS.node; this.disableOnLock = false;
|
||||
this.permission = Permission.BYPASS.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -24,7 +29,8 @@ public class CmdBypass extends FCommand {
|
||||
fme.msg("<i>You have enabled admin bypass mode. You will be able to build or destroy anywhere.");
|
||||
P.p.log(fme.getName() + " has ENABLED admin bypass mode.");
|
||||
} else {
|
||||
fme.msg("<i>You have disabled admin bypass mode."); P.p.log(fme.getName() + " DISABLED admin bypass mode.");
|
||||
fme.msg("<i>You have disabled admin bypass mode.");
|
||||
P.p.log(fme.getName() + " DISABLED admin bypass mode.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,33 +7,43 @@ import com.massivecraft.factions.struct.Permission;
|
||||
public class CmdChat extends FCommand {
|
||||
|
||||
public CmdChat() {
|
||||
super(); this.aliases.add("c"); this.aliases.add("chat");
|
||||
super();
|
||||
this.aliases.add("c");
|
||||
this.aliases.add("chat");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("mode", "next");
|
||||
|
||||
this.permission = Permission.CHAT.node; this.disableOnLock = false;
|
||||
this.permission = Permission.CHAT.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!Conf.factionOnlyChat) {
|
||||
msg("<b>The built in chat chat channels are disabled on this server."); return;
|
||||
msg("<b>The built in chat chat channels are disabled on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
String modeString = this.argAsString(0); ChatMode modeTarget = fme.getChatMode().getNext();
|
||||
String modeString = this.argAsString(0);
|
||||
ChatMode modeTarget = fme.getChatMode().getNext();
|
||||
|
||||
if (modeString != null) {
|
||||
modeString.toLowerCase(); if (modeString.startsWith("p")) {
|
||||
modeString.toLowerCase();
|
||||
if (modeString.startsWith("p")) {
|
||||
modeTarget = ChatMode.PUBLIC;
|
||||
} else if (modeString.startsWith("a")) {
|
||||
modeTarget = ChatMode.ALLIANCE;
|
||||
} else if (modeString.startsWith("f")) {
|
||||
modeTarget = ChatMode.FACTION;
|
||||
} else {
|
||||
msg("<b>Unrecognised chat mode. <i>Please enter either 'a','f' or 'p'"); return;
|
||||
msg("<b>Unrecognised chat mode. <i>Please enter either 'a','f' or 'p'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,13 +5,18 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdChatSpy extends FCommand {
|
||||
public CmdChatSpy() {
|
||||
super(); this.aliases.add("chatspy");
|
||||
super();
|
||||
this.aliases.add("chatspy");
|
||||
|
||||
this.optionalArgs.put("on/off", "flip");
|
||||
|
||||
this.permission = Permission.CHATSPY.node; this.disableOnLock = false;
|
||||
this.permission = Permission.CHATSPY.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -19,9 +24,11 @@ public class CmdChatSpy extends FCommand {
|
||||
fme.setSpyingChat(this.argAsBool(0, !fme.isSpyingChat()));
|
||||
|
||||
if (fme.isSpyingChat()) {
|
||||
fme.msg("<i>You have enabled chat spying mode."); P.p.log(fme.getName() + " has ENABLED chat spying mode.");
|
||||
fme.msg("<i>You have enabled chat spying mode.");
|
||||
P.p.log(fme.getName() + " has ENABLED chat spying mode.");
|
||||
} else {
|
||||
fme.msg("<i>You have disabled chat spying mode."); P.p.log(fme.getName() + " DISABLED chat spying mode.");
|
||||
fme.msg("<i>You have disabled chat spying mode.");
|
||||
P.p.log(fme.getName() + " DISABLED chat spying mode.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,23 +10,31 @@ import com.massivecraft.factions.util.SpiralTask;
|
||||
public class CmdClaim extends FCommand {
|
||||
|
||||
public CmdClaim() {
|
||||
super(); this.aliases.add("claim");
|
||||
super();
|
||||
this.aliases.add("claim");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction", "your"); this.optionalArgs.put("radius", "1");
|
||||
this.optionalArgs.put("faction", "your");
|
||||
this.optionalArgs.put("radius", "1");
|
||||
|
||||
this.permission = Permission.CLAIM.node; this.disableOnLock = true;
|
||||
this.permission = Permission.CLAIM.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
// Read and validate input
|
||||
final Faction forFaction = this.argAsFaction(0, myFaction); int radius = this.argAsInt(1, 1);
|
||||
final Faction forFaction = this.argAsFaction(0, myFaction);
|
||||
int radius = this.argAsInt(1, 1);
|
||||
|
||||
if (radius < 1) {
|
||||
msg("<b>If you specify a radius, it must be at least 1."); return;
|
||||
msg("<b>If you specify a radius, it must be at least 1.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (radius < 2) {
|
||||
@@ -35,7 +43,8 @@ public class CmdClaim extends FCommand {
|
||||
} else {
|
||||
// radius claim
|
||||
if (!Permission.CLAIM_RADIUS.has(sender, false)) {
|
||||
msg("<b>You do not have permission to claim in a radius."); return;
|
||||
msg("<b>You do not have permission to claim in a radius.");
|
||||
return;
|
||||
}
|
||||
|
||||
new SpiralTask(new FLocation(me), radius) {
|
||||
@@ -45,8 +54,11 @@ public class CmdClaim extends FCommand {
|
||||
@Override
|
||||
public boolean work() {
|
||||
boolean success = fme.attemptClaim(forFaction, this.currentLocation(), true);
|
||||
if (success) { failCount = 0; } else if (!success && failCount++ >= limit) {
|
||||
this.stop(); return false;
|
||||
if (success) {
|
||||
failCount = 0;
|
||||
} else if (!success && failCount++ >= limit) {
|
||||
this.stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -17,13 +17,19 @@ public class CmdConfig extends FCommand {
|
||||
private static HashMap<String, String> properFieldNames = new HashMap<String, String>();
|
||||
|
||||
public CmdConfig() {
|
||||
super(); this.aliases.add("config");
|
||||
super();
|
||||
this.aliases.add("config");
|
||||
|
||||
this.requiredArgs.add("setting"); this.requiredArgs.add("value"); this.errorOnToManyArgs = false;
|
||||
this.requiredArgs.add("setting");
|
||||
this.requiredArgs.add("value");
|
||||
this.errorOnToManyArgs = false;
|
||||
|
||||
this.permission = Permission.CONFIG.node; this.disableOnLock = true;
|
||||
this.permission = Permission.CONFIG.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@@ -32,22 +38,27 @@ public class CmdConfig extends FCommand {
|
||||
// store a lookup map of lowercase field names paired with proper capitalization field names
|
||||
// that way, if the person using this command messes up the capitalization, we can fix that
|
||||
if (properFieldNames.isEmpty()) {
|
||||
Field[] fields = Conf.class.getDeclaredFields(); for (int i = 0; i < fields.length; i++) {
|
||||
Field[] fields = Conf.class.getDeclaredFields();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
properFieldNames.put(fields[i].getName().toLowerCase(), fields[i].getName());
|
||||
}
|
||||
}
|
||||
|
||||
String field = this.argAsString(0).toLowerCase(); if (field.startsWith("\"") && field.endsWith("\"")) {
|
||||
String field = this.argAsString(0).toLowerCase();
|
||||
if (field.startsWith("\"") && field.endsWith("\"")) {
|
||||
field = field.substring(1, field.length() - 1);
|
||||
} String fieldName = properFieldNames.get(field);
|
||||
}
|
||||
String fieldName = properFieldNames.get(field);
|
||||
|
||||
if (fieldName == null || fieldName.isEmpty()) {
|
||||
msg("<b>No configuration setting \"<h>%s<b>\" exists.", field); return;
|
||||
msg("<b>No configuration setting \"<h>%s<b>\" exists.", field);
|
||||
return;
|
||||
}
|
||||
|
||||
String success;
|
||||
|
||||
String value = args.get(1); for (int i = 2; i < args.size(); i++) {
|
||||
String value = args.get(1);
|
||||
for (int i = 2; i < args.size(); i++) {
|
||||
value += ' ' + args.get(i);
|
||||
}
|
||||
|
||||
@@ -56,7 +67,8 @@ public class CmdConfig extends FCommand {
|
||||
|
||||
// boolean
|
||||
if (target.getType() == boolean.class) {
|
||||
boolean targetValue = this.strAsBool(value); target.setBoolean(null, targetValue);
|
||||
boolean targetValue = this.strAsBool(value);
|
||||
target.setBoolean(null, targetValue);
|
||||
|
||||
if (targetValue) {
|
||||
success = "\"" + fieldName + "\" option set to true (enabled).";
|
||||
@@ -68,17 +80,20 @@ public class CmdConfig extends FCommand {
|
||||
// int
|
||||
else if (target.getType() == int.class) {
|
||||
try {
|
||||
int intVal = Integer.parseInt(value); target.setInt(null, intVal);
|
||||
int intVal = Integer.parseInt(value);
|
||||
target.setInt(null, intVal);
|
||||
success = "\"" + fieldName + "\" option set to " + intVal + ".";
|
||||
} catch (NumberFormatException ex) {
|
||||
sendMessage("Cannot set \"" + fieldName + "\": integer (whole number) value required."); return;
|
||||
sendMessage("Cannot set \"" + fieldName + "\": integer (whole number) value required.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// long
|
||||
else if (target.getType() == long.class) {
|
||||
try {
|
||||
long longVal = Long.parseLong(value); target.setLong(null, longVal);
|
||||
long longVal = Long.parseLong(value);
|
||||
target.setLong(null, longVal);
|
||||
success = "\"" + fieldName + "\" option set to " + longVal + ".";
|
||||
} catch (NumberFormatException ex) {
|
||||
sendMessage("Cannot set \"" + fieldName + "\": long integer (whole number) value required.");
|
||||
@@ -89,38 +104,46 @@ public class CmdConfig extends FCommand {
|
||||
// double
|
||||
else if (target.getType() == double.class) {
|
||||
try {
|
||||
double doubleVal = Double.parseDouble(value); target.setDouble(null, doubleVal);
|
||||
double doubleVal = Double.parseDouble(value);
|
||||
target.setDouble(null, doubleVal);
|
||||
success = "\"" + fieldName + "\" option set to " + doubleVal + ".";
|
||||
} catch (NumberFormatException ex) {
|
||||
sendMessage("Cannot set \"" + fieldName + "\": double (numeric) value required."); return;
|
||||
sendMessage("Cannot set \"" + fieldName + "\": double (numeric) value required.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// float
|
||||
else if (target.getType() == float.class) {
|
||||
try {
|
||||
float floatVal = Float.parseFloat(value); target.setFloat(null, floatVal);
|
||||
float floatVal = Float.parseFloat(value);
|
||||
target.setFloat(null, floatVal);
|
||||
success = "\"" + fieldName + "\" option set to " + floatVal + ".";
|
||||
} catch (NumberFormatException ex) {
|
||||
sendMessage("Cannot set \"" + fieldName + "\": float (numeric) value required."); return;
|
||||
sendMessage("Cannot set \"" + fieldName + "\": float (numeric) value required.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// String
|
||||
else if (target.getType() == String.class) {
|
||||
target.set(null, value); success = "\"" + fieldName + "\" option set to \"" + value + "\".";
|
||||
target.set(null, value);
|
||||
success = "\"" + fieldName + "\" option set to \"" + value + "\".";
|
||||
}
|
||||
|
||||
// ChatColor
|
||||
else if (target.getType() == ChatColor.class) {
|
||||
ChatColor newColor = null; try {
|
||||
ChatColor newColor = null;
|
||||
try {
|
||||
newColor = ChatColor.valueOf(value.toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
|
||||
} if (newColor == null) {
|
||||
}
|
||||
if (newColor == null) {
|
||||
sendMessage("Cannot set \"" + fieldName + "\": \"" + value.toUpperCase() + "\" is not a valid color.");
|
||||
return;
|
||||
} target.set(null, newColor);
|
||||
}
|
||||
target.set(null, newColor);
|
||||
success = "\"" + fieldName + "\" color option set to \"" + value.toUpperCase() + "\".";
|
||||
}
|
||||
|
||||
@@ -137,11 +160,13 @@ public class CmdConfig extends FCommand {
|
||||
|
||||
// Set<Material>
|
||||
else if (innerType == Material.class) {
|
||||
Material newMat = null; try {
|
||||
Material newMat = null;
|
||||
try {
|
||||
newMat = Material.valueOf(value.toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
|
||||
} if (newMat == null) {
|
||||
}
|
||||
if (newMat == null) {
|
||||
sendMessage("Cannot change \"" + fieldName + "\" set: \"" + value.toUpperCase() + "\" is not a valid material.");
|
||||
return;
|
||||
}
|
||||
@@ -150,12 +175,14 @@ public class CmdConfig extends FCommand {
|
||||
|
||||
// Material already present, so remove it
|
||||
if (matSet.contains(newMat)) {
|
||||
matSet.remove(newMat); target.set(null, matSet);
|
||||
matSet.remove(newMat);
|
||||
target.set(null, matSet);
|
||||
success = "\"" + fieldName + "\" set: Material \"" + value.toUpperCase() + "\" removed.";
|
||||
}
|
||||
// Material not present yet, add it
|
||||
else {
|
||||
matSet.add(newMat); target.set(null, matSet);
|
||||
matSet.add(newMat);
|
||||
target.set(null, matSet);
|
||||
success = "\"" + fieldName + "\" set: Material \"" + value.toUpperCase() + "\" added.";
|
||||
}
|
||||
}
|
||||
@@ -166,12 +193,14 @@ public class CmdConfig extends FCommand {
|
||||
|
||||
// String already present, so remove it
|
||||
if (stringSet.contains(value)) {
|
||||
stringSet.remove(value); target.set(null, stringSet);
|
||||
stringSet.remove(value);
|
||||
target.set(null, stringSet);
|
||||
success = "\"" + fieldName + "\" set: \"" + value + "\" removed.";
|
||||
}
|
||||
// String not present yet, add it
|
||||
else {
|
||||
stringSet.add(value); target.set(null, stringSet);
|
||||
stringSet.add(value);
|
||||
target.set(null, stringSet);
|
||||
success = "\"" + fieldName + "\" set: \"" + value + "\" added.";
|
||||
}
|
||||
}
|
||||
@@ -192,14 +221,18 @@ public class CmdConfig extends FCommand {
|
||||
sendMessage("Configuration setting \"" + fieldName + "\" couldn't be matched, though it should be... please report this error.");
|
||||
return;
|
||||
} catch (IllegalAccessException ex) {
|
||||
sendMessage("Error setting configuration setting \"" + fieldName + "\" to \"" + value + "\"."); return;
|
||||
sendMessage("Error setting configuration setting \"" + fieldName + "\" to \"" + value + "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!success.isEmpty()) {
|
||||
if (sender instanceof Player) {
|
||||
sendMessage(success); P.p.log(success + " Command was run by " + fme.getName() + ".");
|
||||
sendMessage(success);
|
||||
P.p.log(success + " Command was run by " + fme.getName() + ".");
|
||||
} else // using P.p.log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
|
||||
{ P.p.log(success); }
|
||||
{
|
||||
P.p.log(success);
|
||||
}
|
||||
}
|
||||
// save change to disk
|
||||
Conf.save();
|
||||
|
||||
@@ -12,14 +12,19 @@ import java.util.ArrayList;
|
||||
|
||||
public class CmdCreate extends FCommand {
|
||||
public CmdCreate() {
|
||||
super(); this.aliases.add("create");
|
||||
super();
|
||||
this.aliases.add("create");
|
||||
|
||||
this.requiredArgs.add("faction tag");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.CREATE.node; this.disableOnLock = true;
|
||||
this.permission = Permission.CREATE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,32 +32,44 @@ public class CmdCreate extends FCommand {
|
||||
String tag = this.argAsString(0);
|
||||
|
||||
if (fme.hasFaction()) {
|
||||
msg("<b>You must leave your current faction first."); return;
|
||||
msg("<b>You must leave your current faction first.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Factions.i.isTagTaken(tag)) {
|
||||
msg("<b>That tag is already in use."); return;
|
||||
msg("<b>That tag is already in use.");
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<String> tagValidationErrors = Factions.validateTag(tag); if (tagValidationErrors.size() > 0) {
|
||||
sendMessage(tagValidationErrors); return;
|
||||
ArrayList<String> tagValidationErrors = Factions.validateTag(tag);
|
||||
if (tagValidationErrors.size() > 0) {
|
||||
sendMessage(tagValidationErrors);
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||
if (!canAffordCommand(Conf.econCostCreate, "to create a new faction")) { return; }
|
||||
if (!canAffordCommand(Conf.econCostCreate, "to create a new faction")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// trigger the faction creation event (cancellable)
|
||||
FactionCreateEvent createEvent = new FactionCreateEvent(me, tag);
|
||||
Bukkit.getServer().getPluginManager().callEvent(createEvent); if (createEvent.isCancelled()) { return; }
|
||||
Bukkit.getServer().getPluginManager().callEvent(createEvent);
|
||||
if (createEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (!payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) { return; }
|
||||
if (!payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Faction faction = Factions.i.create();
|
||||
|
||||
// TODO: Why would this even happen??? Auto increment clash??
|
||||
if (faction == null) {
|
||||
msg("<b>There was an internal error while trying to create your faction. Please try again."); return;
|
||||
msg("<b>There was an internal error while trying to create your faction. Please try again.");
|
||||
return;
|
||||
}
|
||||
|
||||
// finish setting up the Faction
|
||||
@@ -64,7 +81,8 @@ public class CmdCreate extends FCommand {
|
||||
// join event cannot be cancelled or you'll have an empty faction
|
||||
|
||||
// finish setting up the FPlayer
|
||||
fme.setRole(Role.ADMIN); fme.setFaction(faction);
|
||||
fme.setRole(Role.ADMIN);
|
||||
fme.setFaction(faction);
|
||||
|
||||
for (FPlayer follower : FPlayers.i.getOnline()) {
|
||||
follower.msg("%s<i> created a new faction %s", fme.describeTo(follower, true), faction.getTag(follower));
|
||||
@@ -72,7 +90,9 @@ public class CmdCreate extends FCommand {
|
||||
|
||||
msg("<i>You should now: %s", p.cmdBase.cmdDescription.getUseageTemplate());
|
||||
|
||||
if (Conf.logFactionCreate) { P.p.log(fme.getName() + " created a new faction: " + tag); }
|
||||
if (Conf.logFactionCreate) {
|
||||
P.p.log(fme.getName() + " created a new faction: " + tag);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,23 +6,33 @@ import com.massivecraft.factions.struct.Permission;
|
||||
public class CmdDeinvite extends FCommand {
|
||||
|
||||
public CmdDeinvite() {
|
||||
super(); this.aliases.add("deinvite"); this.aliases.add("deinv");
|
||||
super();
|
||||
this.aliases.add("deinvite");
|
||||
this.aliases.add("deinv");
|
||||
|
||||
this.requiredArgs.add("player name");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.DEINVITE.node; this.disableOnLock = true;
|
||||
this.permission = Permission.DEINVITE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0); if (you == null) { return; }
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getFaction() == myFaction) {
|
||||
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
|
||||
msg("<i>You might want to: %s", p.cmdBase.cmdKick.getUseageTemplate(false)); return;
|
||||
msg("<i>You might want to: %s", p.cmdBase.cmdKick.getUseageTemplate(false));
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction.deinvite(you);
|
||||
|
||||
@@ -8,14 +8,20 @@ import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
|
||||
public class CmdDescription extends FCommand {
|
||||
public CmdDescription() {
|
||||
super(); this.aliases.add("desc");
|
||||
super();
|
||||
this.aliases.add("desc");
|
||||
|
||||
this.requiredArgs.add("desc"); this.errorOnToManyArgs = false;
|
||||
this.requiredArgs.add("desc");
|
||||
this.errorOnToManyArgs = false;
|
||||
//this.optionalArgs
|
||||
|
||||
this.permission = Permission.DESCRIPTION.node; this.disableOnLock = true;
|
||||
this.permission = Permission.DESCRIPTION.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,7 +35,8 @@ public class CmdDescription extends FCommand {
|
||||
|
||||
if (!Conf.broadcastDescriptionChanges) {
|
||||
fme.msg("You have changed the description for <h>%s<i> to:", myFaction.describeTo(fme));
|
||||
fme.sendMessage(myFaction.getDescription()); return;
|
||||
fme.sendMessage(myFaction.getDescription());
|
||||
return;
|
||||
}
|
||||
|
||||
// Broadcast the description to everyone
|
||||
|
||||
@@ -11,26 +11,35 @@ import org.bukkit.Bukkit;
|
||||
|
||||
public class CmdDisband extends FCommand {
|
||||
public CmdDisband() {
|
||||
super(); this.aliases.add("disband");
|
||||
super();
|
||||
this.aliases.add("disband");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction tag", "yours");
|
||||
|
||||
this.permission = Permission.DISBAND.node; this.disableOnLock = true;
|
||||
this.permission = Permission.DISBAND.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
// The faction, default to your own.. but null if console sender.
|
||||
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction); if (faction == null) { return; }
|
||||
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isMyFaction = fme == null ? false : faction == myFaction;
|
||||
|
||||
if (isMyFaction) {
|
||||
if (!assertMinRole(Role.ADMIN)) { return; }
|
||||
if (!assertMinRole(Role.ADMIN)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!Permission.DISBAND_ANY.has(sender, true)) {
|
||||
return;
|
||||
@@ -38,13 +47,19 @@ public class CmdDisband extends FCommand {
|
||||
}
|
||||
|
||||
if (!faction.isNormal()) {
|
||||
msg("<i>You cannot disband the Wilderness, SafeZone, or WarZone."); return;
|
||||
} if (faction.isPermanent()) {
|
||||
msg("<i>This faction is designated as permanent, so you cannot disband it."); return;
|
||||
msg("<i>You cannot disband the Wilderness, SafeZone, or WarZone.");
|
||||
return;
|
||||
}
|
||||
if (faction.isPermanent()) {
|
||||
msg("<i>This faction is designated as permanent, so you cannot disband it.");
|
||||
return;
|
||||
}
|
||||
|
||||
FactionDisbandEvent disbandEvent = new FactionDisbandEvent(me, faction.getId());
|
||||
Bukkit.getServer().getPluginManager().callEvent(disbandEvent); if (disbandEvent.isCancelled()) { return; }
|
||||
Bukkit.getServer().getPluginManager().callEvent(disbandEvent);
|
||||
if (disbandEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send FPlayerLeaveEvent for each player in the faction
|
||||
for (FPlayer fplayer : faction.getFPlayers()) {
|
||||
@@ -59,7 +74,8 @@ public class CmdDisband extends FCommand {
|
||||
} else {
|
||||
fplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getTag(fplayer));
|
||||
}
|
||||
} if (Conf.logFactionDisband) {
|
||||
}
|
||||
if (Conf.logFactionDisband) {
|
||||
P.p.log("The faction " + faction.getTag() + " (" + faction.getId() + ") was disbanded by " + (senderIsConsole ? "console command" : fme.getName()) + ".");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,20 +11,28 @@ import java.util.ArrayList;
|
||||
public class CmdHelp extends FCommand {
|
||||
|
||||
public CmdHelp() {
|
||||
super(); this.aliases.add("help"); this.aliases.add("h"); this.aliases.add("?");
|
||||
super();
|
||||
this.aliases.add("help");
|
||||
this.aliases.add("h");
|
||||
this.aliases.add("?");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("page", "1");
|
||||
|
||||
this.permission = Permission.HELP.node; this.disableOnLock = false;
|
||||
this.permission = Permission.HELP.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (helpPages == null) { updateHelp(); }
|
||||
if (helpPages == null) {
|
||||
updateHelp();
|
||||
}
|
||||
|
||||
int page = this.argAsInt(0, 1);
|
||||
|
||||
@@ -33,8 +41,10 @@ public class CmdHelp extends FCommand {
|
||||
page -= 1;
|
||||
|
||||
if (page < 0 || page >= helpPages.size()) {
|
||||
msg("<b>This page does not exist"); return;
|
||||
} sendMessage(helpPages.get(page));
|
||||
msg("<b>This page does not exist");
|
||||
return;
|
||||
}
|
||||
sendMessage(helpPages.get(page));
|
||||
}
|
||||
|
||||
//----------------------------------------------//
|
||||
@@ -44,9 +54,11 @@ public class CmdHelp extends FCommand {
|
||||
public ArrayList<ArrayList<String>> helpPages;
|
||||
|
||||
public void updateHelp() {
|
||||
helpPages = new ArrayList<ArrayList<String>>(); ArrayList<String> pageLines;
|
||||
helpPages = new ArrayList<ArrayList<String>>();
|
||||
ArrayList<String> pageLines;
|
||||
|
||||
pageLines = new ArrayList<String>(); pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true));
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdShow.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdPower.getUseageTemplate(true));
|
||||
@@ -54,9 +66,11 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.cmdBase.cmdLeave.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdChat.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdHome.getUseageTemplate(true));
|
||||
pageLines.add(p.txt.parse("<i>Learn how to create a faction on the next page.")); helpPages.add(pageLines);
|
||||
pageLines.add(p.txt.parse("<i>Learn how to create a faction on the next page."));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>(); pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true));
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true));
|
||||
pageLines.add(p.txt.parse("<i>You might want to close it and use invitations:"));
|
||||
@@ -64,18 +78,25 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.cmdBase.cmdInvite.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdDeinvite.getUseageTemplate(true));
|
||||
pageLines.add(p.txt.parse("<i>And don't forget to set your home:"));
|
||||
pageLines.add(p.cmdBase.cmdSethome.getUseageTemplate(true)); helpPages.add(pageLines);
|
||||
pageLines.add(p.cmdBase.cmdSethome.getUseageTemplate(true));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) {
|
||||
pageLines = new ArrayList<String>(); pageLines.add("");
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add("");
|
||||
pageLines.add(p.txt.parse("<i>Your faction has a bank which is used to pay for certain"));
|
||||
pageLines.add(p.txt.parse("<i>things, so it will need to have money deposited into it."));
|
||||
pageLines.add(p.txt.parse("<i>To learn more, use the money command.")); pageLines.add("");
|
||||
pageLines.add(p.cmdBase.cmdMoney.getUseageTemplate(true)); pageLines.add(""); pageLines.add("");
|
||||
pageLines.add(""); helpPages.add(pageLines);
|
||||
pageLines.add(p.txt.parse("<i>To learn more, use the money command."));
|
||||
pageLines.add("");
|
||||
pageLines.add(p.cmdBase.cmdMoney.getUseageTemplate(true));
|
||||
pageLines.add("");
|
||||
pageLines.add("");
|
||||
pageLines.add("");
|
||||
helpPages.add(pageLines);
|
||||
}
|
||||
|
||||
pageLines = new ArrayList<String>(); pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true));
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdUnclaim.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdUnclaimall.getUseageTemplate(true));
|
||||
@@ -86,16 +107,20 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.txt.parse("<i>Player titles are just for fun. No rules connected to them."));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>(); pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true));
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdOwner.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdOwnerList.getUseageTemplate(true));
|
||||
pageLines.add(p.txt.parse("<i>Claimed land with ownership set is further protected so"));
|
||||
pageLines.add(p.txt.parse("<i>that only the owner(s), faction admin, and possibly the"));
|
||||
pageLines.add(p.txt.parse("<i>faction moderators have full access.")); helpPages.add(pageLines);
|
||||
pageLines.add(p.txt.parse("<i>faction moderators have full access."));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>(); pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true));
|
||||
pageLines.add(""); pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true));
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true));
|
||||
pageLines.add("");
|
||||
pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdRelationNeutral.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdRelationEnemy.getUseageTemplate(true));
|
||||
pageLines.add(p.txt.parse("<i>Set the relation you WISH to have with another faction."));
|
||||
@@ -104,9 +129,11 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.txt.parse("<i>If ONE faction chooses \"enemy\" you will be enemies."));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>(); pageLines.add(p.txt.parse("<i>You can never hurt members or allies."));
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add(p.txt.parse("<i>You can never hurt members or allies."));
|
||||
pageLines.add(p.txt.parse("<i>You can not hurt neutrals in their own territory."));
|
||||
pageLines.add(p.txt.parse("<i>You can always hurt enemies and players without faction.")); pageLines.add("");
|
||||
pageLines.add(p.txt.parse("<i>You can always hurt enemies and players without faction."));
|
||||
pageLines.add("");
|
||||
pageLines.add(p.txt.parse("<i>Damage from enemies is reduced in your own territory."));
|
||||
pageLines.add(p.txt.parse("<i>When you die you lose power. It is restored over time."));
|
||||
pageLines.add(p.txt.parse("<i>The power of a faction is the sum of all member power."));
|
||||
@@ -117,14 +144,17 @@ public class CmdHelp extends FCommand {
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add(p.txt.parse("<i>Only faction members can build and destroy in their own"));
|
||||
pageLines.add(p.txt.parse("<i>territory. Usage of the following items is also restricted:"));
|
||||
pageLines.add(p.txt.parse("<i>Door, Chest, Furnace, Dispenser, Diode.")); pageLines.add("");
|
||||
pageLines.add(p.txt.parse("<i>Door, Chest, Furnace, Dispenser, Diode."));
|
||||
pageLines.add("");
|
||||
pageLines.add(p.txt.parse("<i>Make sure to put pressure plates in front of doors for your"));
|
||||
pageLines.add(p.txt.parse("<i>guest visitors. Otherwise they can't get through. You can"));
|
||||
pageLines.add(p.txt.parse("<i>also use this to create member only areas."));
|
||||
pageLines.add(p.txt.parse("<i>As dispensers are protected, you can create traps without"));
|
||||
pageLines.add(p.txt.parse("<i>worrying about those arrows getting stolen.")); helpPages.add(pageLines);
|
||||
pageLines.add(p.txt.parse("<i>worrying about those arrows getting stolen."));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>(); pageLines.add("Finally some commands for the server admins:");
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add("Finally some commands for the server admins:");
|
||||
pageLines.add(p.cmdBase.cmdBypass.getUseageTemplate(true));
|
||||
pageLines.add(p.txt.parse("<c>/f claim safezone <i>claim land for the Safe Zone"));
|
||||
pageLines.add(p.txt.parse("<c>/f claim warzone <i>claim land for the War Zone"));
|
||||
@@ -132,20 +162,25 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdWarunclaimall.getUseageTemplate(true));
|
||||
pageLines.add(p.txt.parse("<i>Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("<i>") + " works on safe/war zones as well."));
|
||||
pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true)); helpPages.add(pageLines);
|
||||
pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>(); pageLines.add(p.txt.parse("<i>More commands for server admins:"));
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add(p.txt.parse("<i>More commands for server admins:"));
|
||||
pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdPermanent.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdPermanentPower.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdPowerBoost.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true)); helpPages.add(pageLines);
|
||||
pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>(); pageLines.add(p.txt.parse("<i>Even more commands for server admins:"));
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add(p.txt.parse("<i>Even more commands for server admins:"));
|
||||
pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdSaveAll.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdVersion.getUseageTemplate(true)); helpPages.add(pageLines);
|
||||
pageLines.add(p.cmdBase.cmdVersion.getUseageTemplate(true));
|
||||
helpPages.add(pageLines);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,58 +17,82 @@ import java.util.List;
|
||||
public class CmdHome extends FCommand {
|
||||
|
||||
public CmdHome() {
|
||||
super(); this.aliases.add("home");
|
||||
super();
|
||||
this.aliases.add("home");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.HOME.node; this.disableOnLock = false;
|
||||
this.permission = Permission.HOME.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
// TODO: Hide this command on help also.
|
||||
if (!Conf.homesEnabled) {
|
||||
fme.msg("<b>Sorry, Faction homes are disabled on this server."); return;
|
||||
fme.msg("<b>Sorry, Faction homes are disabled on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Conf.homesTeleportCommandEnabled) {
|
||||
fme.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server."); return;
|
||||
fme.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!myFaction.hasHome()) {
|
||||
fme.msg("<b>Your faction does not have a home. " + (fme.getRole().value < Role.MODERATOR.value ? "<i> Ask your leader to:" : "<i>You should:"));
|
||||
fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate()); return;
|
||||
fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) {
|
||||
fme.msg("<b>You cannot teleport to your faction home while in the territory of an enemy faction."); return;
|
||||
fme.msg("<b>You cannot teleport to your faction home while in the territory of an enemy faction.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Conf.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID()) {
|
||||
fme.msg("<b>You cannot teleport to your faction home while in a different world."); return;
|
||||
fme.msg("<b>You cannot teleport to your faction home while in a different world.");
|
||||
return;
|
||||
}
|
||||
|
||||
Faction faction = Board.getFactionAt(new FLocation(me.getLocation())); Location loc = me.getLocation().clone();
|
||||
Faction faction = Board.getFactionAt(new FLocation(me.getLocation()));
|
||||
Location loc = me.getLocation().clone();
|
||||
|
||||
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
||||
if (Conf.homesTeleportAllowedEnemyDistance > 0 &&
|
||||
!faction.isSafeZone() &&
|
||||
(!fme.isInOwnTerritory() || (fme.isInOwnTerritory() && !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory))) {
|
||||
World w = loc.getWorld(); double x = loc.getX(); double y = loc.getY(); double z = loc.getZ();
|
||||
World w = loc.getWorld();
|
||||
double x = loc.getX();
|
||||
double y = loc.getY();
|
||||
double z = loc.getZ();
|
||||
|
||||
for (Player p : me.getServer().getOnlinePlayers()) {
|
||||
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) { continue; }
|
||||
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FPlayer fp = FPlayers.i.get(p); if (fme.getRelationTo(fp) != Relation.ENEMY) { continue; }
|
||||
FPlayer fp = FPlayers.i.get(p);
|
||||
if (fme.getRelationTo(fp) != Relation.ENEMY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Location l = p.getLocation(); double dx = Math.abs(x - l.getX()); double dy = Math.abs(y - l.getY());
|
||||
double dz = Math.abs(z - l.getZ()); double max = Conf.homesTeleportAllowedEnemyDistance;
|
||||
Location l = p.getLocation();
|
||||
double dx = Math.abs(x - l.getX());
|
||||
double dy = Math.abs(y - l.getY());
|
||||
double dz = Math.abs(z - l.getZ());
|
||||
double max = Conf.homesTeleportAllowedEnemyDistance;
|
||||
|
||||
// box-shaped distance check
|
||||
if (dx > max || dy > max || dz > max) { continue; }
|
||||
if (dx > max || dy > max || dz > max) {
|
||||
continue;
|
||||
}
|
||||
|
||||
fme.msg("<b>You cannot teleport to your faction home while an enemy is within " + Conf.homesTeleportAllowedEnemyDistance + " blocks of you.");
|
||||
return;
|
||||
@@ -76,7 +100,9 @@ public class CmdHome extends FCommand {
|
||||
}
|
||||
|
||||
// if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown)
|
||||
if (Essentials.handleTeleport(me, myFaction.getHome())) { return; }
|
||||
if (Essentials.handleTeleport(me, myFaction.getHome())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostHome, "to teleport to your faction home", "for teleporting to your faction home")) {
|
||||
@@ -85,8 +111,10 @@ public class CmdHome extends FCommand {
|
||||
|
||||
// Create a smoke effect
|
||||
if (Conf.homesTeleportCommandSmokeEffectEnabled) {
|
||||
List<Location> smokeLocations = new ArrayList<Location>(); smokeLocations.add(loc);
|
||||
smokeLocations.add(loc.add(0, 1, 0)); smokeLocations.add(myFaction.getHome());
|
||||
List<Location> smokeLocations = new ArrayList<Location>();
|
||||
smokeLocations.add(loc);
|
||||
smokeLocations.add(loc.add(0, 1, 0));
|
||||
smokeLocations.add(myFaction.getHome());
|
||||
smokeLocations.add(myFaction.getHome().clone().add(0, 1, 0));
|
||||
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
|
||||
}
|
||||
|
||||
@@ -6,27 +6,39 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdInvite extends FCommand {
|
||||
public CmdInvite() {
|
||||
super(); this.aliases.add("invite"); this.aliases.add("inv");
|
||||
super();
|
||||
this.aliases.add("invite");
|
||||
this.aliases.add("inv");
|
||||
|
||||
this.requiredArgs.add("player name");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.INVITE.node; this.disableOnLock = true;
|
||||
this.permission = Permission.INVITE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0); if (you == null) { return; }
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getFaction() == myFaction) {
|
||||
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
|
||||
msg("<i>You might want to: " + p.cmdBase.cmdKick.getUseageTemplate(false)); return;
|
||||
msg("<i>You might want to: " + p.cmdBase.cmdKick.getUseageTemplate(false));
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostInvite, "to invite someone", "for inviting someone")) { return; }
|
||||
if (!payForCommand(Conf.econCostInvite, "to invite someone", "for inviting someone")) {
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction.invite(you);
|
||||
|
||||
|
||||
@@ -7,27 +7,39 @@ import org.bukkit.Bukkit;
|
||||
|
||||
public class CmdJoin extends FCommand {
|
||||
public CmdJoin() {
|
||||
super(); this.aliases.add("join");
|
||||
super();
|
||||
this.aliases.add("join");
|
||||
|
||||
this.requiredArgs.add("faction name"); this.optionalArgs.put("player", "you");
|
||||
this.requiredArgs.add("faction name");
|
||||
this.optionalArgs.put("player", "you");
|
||||
|
||||
this.permission = Permission.JOIN.node; this.disableOnLock = true;
|
||||
this.permission = Permission.JOIN.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction faction = this.argAsFaction(0); if (faction == null) { return; }
|
||||
Faction faction = this.argAsFaction(0);
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
FPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false); boolean samePlayer = fplayer == fme;
|
||||
FPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false);
|
||||
boolean samePlayer = fplayer == fme;
|
||||
|
||||
if (!samePlayer && !Permission.JOIN_OTHERS.has(sender, false)) {
|
||||
msg("<b>You do not have permission to move other players into a faction."); return;
|
||||
msg("<b>You do not have permission to move other players into a faction.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!faction.isNormal()) {
|
||||
msg("<b>Players may only join normal factions. This is a system faction."); return;
|
||||
msg("<b>Players may only join normal factions. This is a system faction.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (faction == fplayer.getFaction()) {
|
||||
@@ -46,35 +58,50 @@ public class CmdJoin extends FCommand {
|
||||
}
|
||||
|
||||
if (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0) {
|
||||
msg("<b>%s cannot join a faction with a negative power level.", fplayer.describeTo(fme, true)); return;
|
||||
msg("<b>%s cannot join a faction with a negative power level.", fplayer.describeTo(fme, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(faction.getOpen() || faction.isInvited(fplayer) || fme.isAdminBypassing() || Permission.JOIN_ANY.has(sender, false))) {
|
||||
msg("<i>This faction requires invitation.");
|
||||
if (samePlayer) { faction.msg("%s<i> tried to join your faction.", fplayer.describeTo(faction, true)); }
|
||||
if (samePlayer) {
|
||||
faction.msg("%s<i> tried to join your faction.", fplayer.describeTo(faction, true));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||
if (samePlayer && !canAffordCommand(Conf.econCostJoin, "to join a faction")) { return; }
|
||||
if (samePlayer && !canAffordCommand(Conf.econCostJoin, "to join a faction")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// trigger the join event (cancellable)
|
||||
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.i.get(me), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND);
|
||||
Bukkit.getServer().getPluginManager().callEvent(joinEvent); if (joinEvent.isCancelled()) { return; }
|
||||
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
||||
if (joinEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (samePlayer && !payForCommand(Conf.econCostJoin, "to join a faction", "for joining a faction")) { return; }
|
||||
if (samePlayer && !payForCommand(Conf.econCostJoin, "to join a faction", "for joining a faction")) {
|
||||
return;
|
||||
}
|
||||
|
||||
fme.msg("<i>%s successfully joined %s.", fplayer.describeTo(fme, true), faction.getTag(fme));
|
||||
|
||||
if (!samePlayer) {
|
||||
fplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(fplayer, true), faction.getTag(fplayer));
|
||||
} faction.msg("<i>%s joined your faction.", fplayer.describeTo(faction, true));
|
||||
}
|
||||
faction.msg("<i>%s joined your faction.", fplayer.describeTo(faction, true));
|
||||
|
||||
fplayer.resetFactionData(); fplayer.setFaction(faction); faction.deinvite(fplayer);
|
||||
fplayer.resetFactionData();
|
||||
fplayer.setFaction(faction);
|
||||
faction.deinvite(fplayer);
|
||||
|
||||
if (Conf.logFactionJoin) {
|
||||
if (samePlayer) { P.p.log("%s joined the faction %s.", fplayer.getName(), faction.getTag()); } else {
|
||||
if (samePlayer) {
|
||||
P.p.log("%s joined the faction %s.", fplayer.getName(), faction.getTag());
|
||||
} else {
|
||||
P.p.log("%s moved the player %s into the faction %s.", fme.getName(), fplayer.getName(), faction.getTag());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,23 +12,32 @@ import org.bukkit.Bukkit;
|
||||
public class CmdKick extends FCommand {
|
||||
|
||||
public CmdKick() {
|
||||
super(); this.aliases.add("kick");
|
||||
super();
|
||||
this.aliases.add("kick");
|
||||
|
||||
this.requiredArgs.add("player name");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.KICK.node; this.disableOnLock = false;
|
||||
this.permission = Permission.KICK.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0); if (you == null) { return; }
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fme == you) {
|
||||
msg("<b>You cannot kick yourself.");
|
||||
msg("<i>You might want to: %s", p.cmdBase.cmdLeave.getUseageTemplate(false)); return;
|
||||
msg("<i>You might want to: %s", p.cmdBase.cmdLeave.getUseageTemplate(false));
|
||||
return;
|
||||
}
|
||||
|
||||
Faction yourFaction = you.getFaction();
|
||||
@@ -36,25 +45,33 @@ public class CmdKick extends FCommand {
|
||||
// players with admin-level "disband" permission can bypass these requirements
|
||||
if (!Permission.KICK_ANY.has(sender)) {
|
||||
if (yourFaction != myFaction) {
|
||||
msg("%s<b> is not a member of %s", you.describeTo(fme, true), myFaction.describeTo(fme)); return;
|
||||
msg("%s<b> is not a member of %s", you.describeTo(fme, true), myFaction.describeTo(fme));
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole().value >= fme.getRole().value) {
|
||||
// TODO add more informative messages.
|
||||
msg("<b>Your rank is too low to kick this player."); return;
|
||||
msg("<b>Your rank is too low to kick this player.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Conf.canLeaveWithNegativePower && you.getPower() < 0) {
|
||||
msg("<b>You cannot kick that member until their power is positive."); return;
|
||||
msg("<b>You cannot kick that member until their power is positive.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||
if (!canAffordCommand(Conf.econCostKick, "to kick someone from the faction")) { return; }
|
||||
if (!canAffordCommand(Conf.econCostKick, "to kick someone from the faction")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// trigger the leave event (cancellable) [reason:kicked]
|
||||
FPlayerLeaveEvent event = new FPlayerLeaveEvent(you, you.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; }
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (!payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction")) {
|
||||
@@ -71,9 +88,12 @@ public class CmdKick extends FCommand {
|
||||
P.p.log((senderIsConsole ? "A console command" : fme.getName()) + " kicked " + you.getName() + " from the faction: " + yourFaction.getTag());
|
||||
}
|
||||
|
||||
if (you.getRole() == Role.ADMIN) { yourFaction.promoteNewLeader(); }
|
||||
if (you.getRole() == Role.ADMIN) {
|
||||
yourFaction.promoteNewLeader();
|
||||
}
|
||||
|
||||
yourFaction.deinvite(you); you.resetFactionData();
|
||||
yourFaction.deinvite(you);
|
||||
you.resetFactionData();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,14 +5,19 @@ import com.massivecraft.factions.struct.Permission;
|
||||
public class CmdLeave extends FCommand {
|
||||
|
||||
public CmdLeave() {
|
||||
super(); this.aliases.add("leave");
|
||||
super();
|
||||
this.aliases.add("leave");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.LEAVE.node; this.disableOnLock = true;
|
||||
this.permission = Permission.LEAVE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,32 +13,46 @@ import java.util.Comparator;
|
||||
public class CmdList extends FCommand {
|
||||
|
||||
public CmdList() {
|
||||
super(); this.aliases.add("list"); this.aliases.add("ls");
|
||||
super();
|
||||
this.aliases.add("list");
|
||||
this.aliases.add("ls");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("page", "1");
|
||||
|
||||
this.permission = Permission.LIST.node; this.disableOnLock = false;
|
||||
this.permission = Permission.LIST.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) { return; }
|
||||
if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Faction> factionList = new ArrayList<Faction>(Factions.i.get());
|
||||
factionList.remove(Factions.i.getNone()); factionList.remove(Factions.i.getSafeZone());
|
||||
factionList.remove(Factions.i.getNone());
|
||||
factionList.remove(Factions.i.getSafeZone());
|
||||
factionList.remove(Factions.i.getWarZone());
|
||||
|
||||
// Sort by total followers first
|
||||
Collections.sort(factionList, new Comparator<Faction>() {
|
||||
@Override
|
||||
public int compare(Faction f1, Faction f2) {
|
||||
int f1Size = f1.getFPlayers().size(); int f2Size = f2.getFPlayers().size();
|
||||
if (f1Size < f2Size) { return 1; } else if (f1Size > f2Size) { return -1; } return 0;
|
||||
int f1Size = f1.getFPlayers().size();
|
||||
int f2Size = f2.getFPlayers().size();
|
||||
if (f1Size < f2Size) {
|
||||
return 1;
|
||||
} else if (f1Size > f2Size) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -48,7 +62,12 @@ public class CmdList extends FCommand {
|
||||
public int compare(Faction f1, Faction f2) {
|
||||
int f1Size = f1.getFPlayersWhereOnline(true).size();
|
||||
int f2Size = f2.getFPlayersWhereOnline(true).size();
|
||||
if (f1Size < f2Size) { return 1; } else if (f1Size > f2Size) { return -1; } return 0;
|
||||
if (f1Size < f2Size) {
|
||||
return 1;
|
||||
} else if (f1Size > f2Size) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -73,11 +92,19 @@ public class CmdList extends FCommand {
|
||||
|
||||
factionList.add(0, Factions.i.getNone());
|
||||
|
||||
final int pageheight = 9; int pagenumber = this.argAsInt(0, 1);
|
||||
final int pageheight = 9;
|
||||
int pagenumber = this.argAsInt(0, 1);
|
||||
int pagecount = (factionList.size() / pageheight) + 1;
|
||||
if (pagenumber > pagecount) { pagenumber = pagecount; } else if (pagenumber < 1) { pagenumber = 1; }
|
||||
int start = (pagenumber - 1) * pageheight; int end = start + pageheight;
|
||||
if (end > factionList.size()) { end = factionList.size(); }
|
||||
if (pagenumber > pagecount) {
|
||||
pagenumber = pagecount;
|
||||
} else if (pagenumber < 1) {
|
||||
pagenumber = 1;
|
||||
}
|
||||
int start = (pagenumber - 1) * pageheight;
|
||||
int end = start + pageheight;
|
||||
if (end > factionList.size()) {
|
||||
end = factionList.size();
|
||||
}
|
||||
|
||||
lines.add(p.txt.titleize("Faction List " + pagenumber + "/" + pagecount));
|
||||
|
||||
|
||||
@@ -12,14 +12,18 @@ public class CmdLock extends FCommand {
|
||||
*/
|
||||
|
||||
public CmdLock() {
|
||||
super(); this.aliases.add("lock");
|
||||
super();
|
||||
this.aliases.add("lock");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("on/off", "flip");
|
||||
|
||||
this.permission = Permission.LOCK.node; this.disableOnLock = false;
|
||||
this.permission = Permission.LOCK.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,14 +8,19 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdMap extends FCommand {
|
||||
public CmdMap() {
|
||||
super(); this.aliases.add("map");
|
||||
super();
|
||||
this.aliases.add("map");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("on/off", "once");
|
||||
|
||||
this.permission = Permission.MAP.node; this.disableOnLock = false;
|
||||
this.permission = Permission.MAP.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,19 +30,25 @@ public class CmdMap extends FCommand {
|
||||
// Turn on
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { return; }
|
||||
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) {
|
||||
return;
|
||||
}
|
||||
|
||||
fme.setMapAutoUpdating(true); msg("<i>Map auto update <green>ENABLED.");
|
||||
fme.setMapAutoUpdating(true);
|
||||
msg("<i>Map auto update <green>ENABLED.");
|
||||
|
||||
// And show the map once
|
||||
showMap();
|
||||
} else {
|
||||
// Turn off
|
||||
fme.setMapAutoUpdating(false); msg("<i>Map auto update <red>DISABLED.");
|
||||
fme.setMapAutoUpdating(false);
|
||||
msg("<i>Map auto update <red>DISABLED.");
|
||||
}
|
||||
} else {
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { return; }
|
||||
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) {
|
||||
return;
|
||||
}
|
||||
|
||||
showMap();
|
||||
}
|
||||
|
||||
@@ -8,37 +8,49 @@ import com.massivecraft.factions.struct.Role;
|
||||
public class CmdMod extends FCommand {
|
||||
|
||||
public CmdMod() {
|
||||
super(); this.aliases.add("mod");
|
||||
super();
|
||||
this.aliases.add("mod");
|
||||
|
||||
this.requiredArgs.add("player name");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.MOD.node; this.disableOnLock = true;
|
||||
this.permission = Permission.MOD.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0); if (you == null) { return; }
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean permAny = Permission.MOD_ANY.has(sender, false); Faction targetFaction = you.getFaction();
|
||||
boolean permAny = Permission.MOD_ANY.has(sender, false);
|
||||
Faction targetFaction = you.getFaction();
|
||||
|
||||
if (targetFaction != myFaction && !permAny) {
|
||||
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true)); return;
|
||||
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
|
||||
msg("<b>You are not the faction admin."); return;
|
||||
msg("<b>You are not the faction admin.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (you == fme && !permAny) {
|
||||
msg("<b>The target player musn't be yourself."); return;
|
||||
msg("<b>The target player musn't be yourself.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole() == Role.ADMIN) {
|
||||
msg("<b>The target player is a faction admin. Demote them first."); return;
|
||||
msg("<b>The target player is a faction admin. Demote them first.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole() == Role.MODERATOR) {
|
||||
|
||||
@@ -11,27 +11,34 @@ public class CmdMoney extends FCommand {
|
||||
public CmdMoneyTransferPf cmdMoneyTransferPf = new CmdMoneyTransferPf();
|
||||
|
||||
public CmdMoney() {
|
||||
super(); this.aliases.add("money");
|
||||
super();
|
||||
this.aliases.add("money");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("","")
|
||||
|
||||
this.isMoneyCommand = true;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
|
||||
this.setHelpShort("faction money commands");
|
||||
this.helpLong.add(p.txt.parseTags("<i>The faction money commands."));
|
||||
|
||||
this.addSubCommand(this.cmdMoneyBalance); this.addSubCommand(this.cmdMoneyDeposit);
|
||||
this.addSubCommand(this.cmdMoneyWithdraw); this.addSubCommand(this.cmdMoneyTransferFf);
|
||||
this.addSubCommand(this.cmdMoneyTransferFp); this.addSubCommand(this.cmdMoneyTransferPf);
|
||||
this.addSubCommand(this.cmdMoneyBalance);
|
||||
this.addSubCommand(this.cmdMoneyDeposit);
|
||||
this.addSubCommand(this.cmdMoneyWithdraw);
|
||||
this.addSubCommand(this.cmdMoneyTransferFf);
|
||||
this.addSubCommand(this.cmdMoneyTransferFp);
|
||||
this.addSubCommand(this.cmdMoneyTransferPf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
this.commandChain.add(this); P.p.cmdAutoHelp.execute(this.sender, this.args, this.commandChain);
|
||||
this.commandChain.add(this);
|
||||
P.p.cmdAutoHelp.execute(this.sender, this.args, this.commandChain);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,25 +6,35 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdMoneyBalance extends FCommand {
|
||||
public CmdMoneyBalance() {
|
||||
super(); this.aliases.add("b"); this.aliases.add("balance");
|
||||
super();
|
||||
this.aliases.add("b");
|
||||
this.aliases.add("balance");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction", "yours");
|
||||
|
||||
this.permission = Permission.MONEY_BALANCE.node; this.setHelpShort("show faction balance");
|
||||
this.permission = Permission.MONEY_BALANCE.node;
|
||||
this.setHelpShort("show faction balance");
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction faction = myFaction; if (this.argIsSet(0)) {
|
||||
Faction faction = myFaction;
|
||||
if (this.argIsSet(0)) {
|
||||
faction = this.argAsFaction(0);
|
||||
}
|
||||
|
||||
if (faction == null) { return; }
|
||||
if (faction != myFaction && !Permission.MONEY_BALANCE_ANY.has(sender, true)) { return; }
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
if (faction != myFaction && !Permission.MONEY_BALANCE_ANY.has(sender, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Econ.sendBalanceInfo(fme, faction);
|
||||
}
|
||||
|
||||
@@ -11,19 +11,30 @@ import org.bukkit.ChatColor;
|
||||
public class CmdMoneyDeposit extends FCommand {
|
||||
|
||||
public CmdMoneyDeposit() {
|
||||
super(); this.aliases.add("d"); this.aliases.add("deposit");
|
||||
super();
|
||||
this.aliases.add("d");
|
||||
this.aliases.add("deposit");
|
||||
|
||||
this.requiredArgs.add("amount"); this.optionalArgs.put("faction", "yours");
|
||||
this.requiredArgs.add("amount");
|
||||
this.optionalArgs.put("faction", "yours");
|
||||
|
||||
this.permission = Permission.MONEY_DEPOSIT.node; this.setHelpShort("deposit money");
|
||||
this.permission = Permission.MONEY_DEPOSIT.node;
|
||||
this.setHelpShort("deposit money");
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d); EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
||||
if (faction == null) { return; } boolean success = Econ.transferMoney(fme, fme, faction, amount);
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
boolean success = Econ.transferMoney(fme, fme, faction, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s deposited %s in the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||
|
||||
@@ -12,20 +12,32 @@ public class CmdMoneyTransferFf extends FCommand {
|
||||
public CmdMoneyTransferFf() {
|
||||
this.aliases.add("ff");
|
||||
|
||||
this.requiredArgs.add("amount"); this.requiredArgs.add("faction"); this.requiredArgs.add("faction");
|
||||
this.requiredArgs.add("amount");
|
||||
this.requiredArgs.add("faction");
|
||||
this.requiredArgs.add("faction");
|
||||
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.MONEY_F2F.node; this.setHelpShort("transfer f -> f");
|
||||
this.permission = Permission.MONEY_F2F.node;
|
||||
this.setHelpShort("transfer f -> f");
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d); EconomyParticipator from = this.argAsFaction(1);
|
||||
if (from == null) { return; } EconomyParticipator to = this.argAsFaction(2); if (to == null) { return; }
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator from = this.argAsFaction(1);
|
||||
if (from == null) {
|
||||
return;
|
||||
}
|
||||
EconomyParticipator to = this.argAsFaction(2);
|
||||
if (to == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||
|
||||
|
||||
@@ -12,21 +12,32 @@ public class CmdMoneyTransferFp extends FCommand {
|
||||
public CmdMoneyTransferFp() {
|
||||
this.aliases.add("fp");
|
||||
|
||||
this.requiredArgs.add("amount"); this.requiredArgs.add("faction"); this.requiredArgs.add("player");
|
||||
this.requiredArgs.add("amount");
|
||||
this.requiredArgs.add("faction");
|
||||
this.requiredArgs.add("player");
|
||||
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.MONEY_F2P.node; this.setHelpShort("transfer f -> p");
|
||||
this.permission = Permission.MONEY_F2P.node;
|
||||
this.setHelpShort("transfer f -> p");
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d); EconomyParticipator from = this.argAsFaction(1);
|
||||
if (from == null) { return; } EconomyParticipator to = this.argAsBestFPlayerMatch(2);
|
||||
if (to == null) { return; }
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator from = this.argAsFaction(1);
|
||||
if (from == null) {
|
||||
return;
|
||||
}
|
||||
EconomyParticipator to = this.argAsBestFPlayerMatch(2);
|
||||
if (to == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||
|
||||
|
||||
@@ -12,20 +12,32 @@ public class CmdMoneyTransferPf extends FCommand {
|
||||
public CmdMoneyTransferPf() {
|
||||
this.aliases.add("pf");
|
||||
|
||||
this.requiredArgs.add("amount"); this.requiredArgs.add("player"); this.requiredArgs.add("faction");
|
||||
this.requiredArgs.add("amount");
|
||||
this.requiredArgs.add("player");
|
||||
this.requiredArgs.add("faction");
|
||||
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.MONEY_P2F.node; this.setHelpShort("transfer p -> f");
|
||||
this.permission = Permission.MONEY_P2F.node;
|
||||
this.setHelpShort("transfer p -> f");
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d); EconomyParticipator from = this.argAsBestFPlayerMatch(1);
|
||||
if (from == null) { return; } EconomyParticipator to = this.argAsFaction(2); if (to == null) { return; }
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator from = this.argAsBestFPlayerMatch(1);
|
||||
if (from == null) {
|
||||
return;
|
||||
}
|
||||
EconomyParticipator to = this.argAsFaction(2);
|
||||
if (to == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||
|
||||
|
||||
@@ -10,19 +10,29 @@ import org.bukkit.ChatColor;
|
||||
|
||||
public class CmdMoneyWithdraw extends FCommand {
|
||||
public CmdMoneyWithdraw() {
|
||||
this.aliases.add("w"); this.aliases.add("withdraw");
|
||||
this.aliases.add("w");
|
||||
this.aliases.add("withdraw");
|
||||
|
||||
this.requiredArgs.add("amount"); this.optionalArgs.put("faction", "yours");
|
||||
this.requiredArgs.add("amount");
|
||||
this.optionalArgs.put("faction", "yours");
|
||||
|
||||
this.permission = Permission.MONEY_WITHDRAW.node; this.setHelpShort("withdraw money");
|
||||
this.permission = Permission.MONEY_WITHDRAW.node;
|
||||
this.setHelpShort("withdraw money");
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
double amount = this.argAsDouble(0, 0d); EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
||||
if (faction == null) { return; } boolean success = Econ.transferMoney(fme, faction, fme, amount);
|
||||
double amount = this.argAsDouble(0, 0d);
|
||||
EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
boolean success = Econ.transferMoney(fme, faction, fme, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s withdrew %s from the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||
|
||||
@@ -7,14 +7,19 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdOpen extends FCommand {
|
||||
public CmdOpen() {
|
||||
super(); this.aliases.add("open");
|
||||
super();
|
||||
this.aliases.add("open");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("yes/no", "flip");
|
||||
|
||||
this.permission = Permission.OPEN.node; this.disableOnLock = false;
|
||||
this.permission = Permission.OPEN.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,7 +38,8 @@ public class CmdOpen extends FCommand {
|
||||
for (Faction faction : Factions.i.get()) {
|
||||
if (faction == myFaction) {
|
||||
continue;
|
||||
} faction.msg("<i>The faction %s<i> is now %s", myFaction.getTag(faction), open);
|
||||
}
|
||||
faction.msg("<i>The faction %s<i> is now %s", myFaction.getTag(faction), open);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,14 +8,19 @@ import com.massivecraft.factions.struct.Role;
|
||||
public class CmdOwner extends FCommand {
|
||||
|
||||
public CmdOwner() {
|
||||
super(); this.aliases.add("owner");
|
||||
super();
|
||||
this.aliases.add("owner");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("player name", "you");
|
||||
|
||||
this.permission = Permission.OWNER.node; this.disableOnLock = true;
|
||||
this.permission = Permission.OWNER.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
// TODO: Fix colors!
|
||||
@@ -29,7 +34,8 @@ public class CmdOwner extends FCommand {
|
||||
}
|
||||
|
||||
if (!Conf.ownedAreasEnabled) {
|
||||
fme.msg("<b>Sorry, but owned areas are disabled on this server."); return;
|
||||
fme.msg("<b>Sorry, but owned areas are disabled on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) {
|
||||
@@ -43,33 +49,42 @@ public class CmdOwner extends FCommand {
|
||||
|
||||
FLocation flocation = new FLocation(fme);
|
||||
|
||||
Faction factionHere = Board.getFactionAt(flocation); if (factionHere != myFaction) {
|
||||
Faction factionHere = Board.getFactionAt(flocation);
|
||||
if (factionHere != myFaction) {
|
||||
if (!hasBypass) {
|
||||
fme.msg("<b>This land is not claimed by your faction, so you can't set ownership of it."); return;
|
||||
fme.msg("<b>This land is not claimed by your faction, so you can't set ownership of it.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!factionHere.isNormal()) {
|
||||
fme.msg("<b>This land is not claimed by a faction. Ownership is not possible."); return;
|
||||
fme.msg("<b>This land is not claimed by a faction. Ownership is not possible.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FPlayer target = this.argAsBestFPlayerMatch(0, fme); if (target == null) { return; }
|
||||
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String playerName = target.getName();
|
||||
|
||||
if (target.getFaction() != myFaction) {
|
||||
fme.msg("%s<i> is not a member of this faction.", playerName); return;
|
||||
fme.msg("%s<i> is not a member of this faction.", playerName);
|
||||
return;
|
||||
}
|
||||
|
||||
// if no player name was passed, and this claim does already have owners set, clear them
|
||||
if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) {
|
||||
myFaction.clearClaimOwnership(flocation); fme.msg("<i>You have cleared ownership for this claimed area.");
|
||||
myFaction.clearClaimOwnership(flocation);
|
||||
fme.msg("<i>You have cleared ownership for this claimed area.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (myFaction.isPlayerInOwnerList(target, flocation)) {
|
||||
myFaction.removePlayerAsOwner(target, flocation);
|
||||
fme.msg("<i>You have removed ownership of this claimed land from %s<i>.", playerName); return;
|
||||
fme.msg("<i>You have removed ownership of this claimed land from %s<i>.", playerName);
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
|
||||
@@ -9,14 +9,19 @@ import com.massivecraft.factions.struct.Permission;
|
||||
public class CmdOwnerList extends FCommand {
|
||||
|
||||
public CmdOwnerList() {
|
||||
super(); this.aliases.add("ownerlist");
|
||||
super();
|
||||
this.aliases.add("ownerlist");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.OWNERLIST.node; this.disableOnLock = false;
|
||||
this.permission = Permission.OWNERLIST.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28,25 +33,30 @@ public class CmdOwnerList extends FCommand {
|
||||
}
|
||||
|
||||
if (!Conf.ownedAreasEnabled) {
|
||||
fme.msg("<b>Owned areas are disabled on this server."); return;
|
||||
fme.msg("<b>Owned areas are disabled on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
FLocation flocation = new FLocation(fme);
|
||||
|
||||
if (Board.getFactionAt(flocation) != myFaction) {
|
||||
if (!hasBypass) {
|
||||
fme.msg("<b>This land is not claimed by your faction."); return;
|
||||
fme.msg("<b>This land is not claimed by your faction.");
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction = Board.getFactionAt(flocation); if (!myFaction.isNormal()) {
|
||||
fme.msg("<i>This land is not claimed by any faction, thus no owners."); return;
|
||||
myFaction = Board.getFactionAt(flocation);
|
||||
if (!myFaction.isNormal()) {
|
||||
fme.msg("<i>This land is not claimed by any faction, thus no owners.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String owners = myFaction.getOwnerListString(flocation);
|
||||
|
||||
if (owners == null || owners.isEmpty()) {
|
||||
fme.msg("<i>No owners are set here; everyone in the faction has access."); return;
|
||||
fme.msg("<i>No owners are set here; everyone in the faction has access.");
|
||||
return;
|
||||
}
|
||||
|
||||
fme.msg("<i>Current owner(s) of this land: %s", owners);
|
||||
|
||||
@@ -8,25 +8,35 @@ import com.massivecraft.factions.struct.Permission;
|
||||
public class CmdPeaceful extends FCommand {
|
||||
|
||||
public CmdPeaceful() {
|
||||
super(); this.aliases.add("peaceful");
|
||||
super();
|
||||
this.aliases.add("peaceful");
|
||||
|
||||
this.requiredArgs.add("faction tag");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.SET_PEACEFUL.node; this.disableOnLock = true;
|
||||
this.permission = Permission.SET_PEACEFUL.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction faction = this.argAsFaction(0); if (faction == null) { return; }
|
||||
Faction faction = this.argAsFaction(0);
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String change; if (faction.isPeaceful()) {
|
||||
change = "removed peaceful status from"; faction.setPeaceful(false);
|
||||
String change;
|
||||
if (faction.isPeaceful()) {
|
||||
change = "removed peaceful status from";
|
||||
faction.setPeaceful(false);
|
||||
} else {
|
||||
change = "granted peaceful status to"; faction.setPeaceful(true);
|
||||
change = "granted peaceful status to";
|
||||
faction.setPeaceful(true);
|
||||
}
|
||||
|
||||
// Inform all players
|
||||
|
||||
@@ -9,25 +9,35 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdPermanent extends FCommand {
|
||||
public CmdPermanent() {
|
||||
super(); this.aliases.add("permanent");
|
||||
super();
|
||||
this.aliases.add("permanent");
|
||||
|
||||
this.requiredArgs.add("faction tag");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.SET_PERMANENT.node; this.disableOnLock = true;
|
||||
this.permission = Permission.SET_PERMANENT.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction faction = this.argAsFaction(0); if (faction == null) { return; }
|
||||
Faction faction = this.argAsFaction(0);
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String change; if (faction.isPermanent()) {
|
||||
change = "removed permanent status from"; faction.setPermanent(false);
|
||||
String change;
|
||||
if (faction.isPermanent()) {
|
||||
change = "removed permanent status from";
|
||||
faction.setPermanent(false);
|
||||
} else {
|
||||
change = "added permanent status to"; faction.setPermanent(true);
|
||||
change = "added permanent status to";
|
||||
faction.setPermanent(true);
|
||||
}
|
||||
|
||||
P.p.log((fme == null ? "A server admin" : fme.getName()) + " " + change + " the faction \"" + faction.getTag() + "\".");
|
||||
|
||||
@@ -6,25 +6,34 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdPermanentPower extends FCommand {
|
||||
public CmdPermanentPower() {
|
||||
super(); this.aliases.add("permanentpower");
|
||||
super();
|
||||
this.aliases.add("permanentpower");
|
||||
|
||||
this.requiredArgs.add("faction"); this.optionalArgs.put("power", "reset");
|
||||
this.requiredArgs.add("faction");
|
||||
this.optionalArgs.put("power", "reset");
|
||||
|
||||
this.permission = Permission.SET_PERMANENTPOWER.node; this.disableOnLock = true;
|
||||
this.permission = Permission.SET_PERMANENTPOWER.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction targetFaction = this.argAsFaction(0); if (targetFaction == null) { return; }
|
||||
Faction targetFaction = this.argAsFaction(0);
|
||||
if (targetFaction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Integer targetPower = this.argAsInt(1);
|
||||
|
||||
targetFaction.setPermanentPower(targetPower);
|
||||
|
||||
String change = "removed permanentpower status from"; if (targetFaction.hasPermanentPower()) {
|
||||
String change = "removed permanentpower status from";
|
||||
if (targetFaction.hasPermanentPower()) {
|
||||
change = "added permanentpower status to";
|
||||
}
|
||||
|
||||
|
||||
@@ -7,22 +7,32 @@ import com.massivecraft.factions.struct.Permission;
|
||||
public class CmdPower extends FCommand {
|
||||
|
||||
public CmdPower() {
|
||||
super(); this.aliases.add("power"); this.aliases.add("pow");
|
||||
super();
|
||||
this.aliases.add("power");
|
||||
this.aliases.add("pow");
|
||||
|
||||
//this.requiredArgs.add("faction tag");
|
||||
this.optionalArgs.put("player name", "you");
|
||||
|
||||
this.permission = Permission.POWER.node; this.disableOnLock = false;
|
||||
this.permission = Permission.POWER.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer target = this.argAsBestFPlayerMatch(0, fme); if (target == null) { return; }
|
||||
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (target != fme && !Permission.POWER_ANY.has(sender, true)) { return; }
|
||||
if (target != fme && !Permission.POWER_ANY.has(sender, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostPower, "to show player power info", "for showing player power info")) {
|
||||
|
||||
@@ -7,38 +7,56 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdPowerBoost extends FCommand {
|
||||
public CmdPowerBoost() {
|
||||
super(); this.aliases.add("powerboost");
|
||||
super();
|
||||
this.aliases.add("powerboost");
|
||||
|
||||
this.requiredArgs.add("p|f|player|faction"); this.requiredArgs.add("name"); this.requiredArgs.add("#");
|
||||
this.requiredArgs.add("p|f|player|faction");
|
||||
this.requiredArgs.add("name");
|
||||
this.requiredArgs.add("#");
|
||||
|
||||
this.permission = Permission.POWERBOOST.node; this.disableOnLock = true;
|
||||
this.permission = Permission.POWERBOOST.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
String type = this.argAsString(0).toLowerCase(); boolean doPlayer = true;
|
||||
String type = this.argAsString(0).toLowerCase();
|
||||
boolean doPlayer = true;
|
||||
if (type.equals("f") || type.equals("faction")) {
|
||||
doPlayer = false;
|
||||
} else if (!type.equals("p") && !type.equals("player")) {
|
||||
msg("<b>You must specify \"p\" or \"player\" to target a player or \"f\" or \"faction\" to target a faction.");
|
||||
msg("<b>ex. /f powerboost p SomePlayer 0.5 -or- /f powerboost f SomeFaction -5"); return;
|
||||
msg("<b>ex. /f powerboost p SomePlayer 0.5 -or- /f powerboost f SomeFaction -5");
|
||||
return;
|
||||
}
|
||||
|
||||
Double targetPower = this.argAsDouble(2); if (targetPower == null) {
|
||||
msg("<b>You must specify a valid numeric value for the power bonus/penalty amount."); return;
|
||||
Double targetPower = this.argAsDouble(2);
|
||||
if (targetPower == null) {
|
||||
msg("<b>You must specify a valid numeric value for the power bonus/penalty amount.");
|
||||
return;
|
||||
}
|
||||
|
||||
String target;
|
||||
|
||||
if (doPlayer) {
|
||||
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1); if (targetPlayer == null) { return; }
|
||||
targetPlayer.setPowerBoost(targetPower); target = "Player \"" + targetPlayer.getName() + "\"";
|
||||
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1);
|
||||
if (targetPlayer == null) {
|
||||
return;
|
||||
}
|
||||
targetPlayer.setPowerBoost(targetPower);
|
||||
target = "Player \"" + targetPlayer.getName() + "\"";
|
||||
} else {
|
||||
Faction targetFaction = this.argAsFaction(1); if (targetFaction == null) { return; }
|
||||
targetFaction.setPowerBoost(targetPower); target = "Faction \"" + targetFaction.getTag() + "\"";
|
||||
Faction targetFaction = this.argAsFaction(1);
|
||||
if (targetFaction == null) {
|
||||
return;
|
||||
}
|
||||
targetFaction.setPowerBoost(targetPower);
|
||||
target = "Faction \"" + targetFaction.getTag() + "\"";
|
||||
}
|
||||
|
||||
msg("<i>" + target + " now has a power bonus/penalty of " + targetPower + " to min and max power levels.");
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.massivecraft.factions.struct.Relation;
|
||||
|
||||
public class CmdRelationAlly extends FRelationCommand {
|
||||
public CmdRelationAlly() {
|
||||
aliases.add("ally"); targetRelation = Relation.ALLY;
|
||||
aliases.add("ally");
|
||||
targetRelation = Relation.ALLY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.massivecraft.factions.struct.Relation;
|
||||
|
||||
public class CmdRelationEnemy extends FRelationCommand {
|
||||
public CmdRelationEnemy() {
|
||||
aliases.add("enemy"); targetRelation = Relation.ENEMY;
|
||||
aliases.add("enemy");
|
||||
targetRelation = Relation.ENEMY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.massivecraft.factions.struct.Relation;
|
||||
|
||||
public class CmdRelationNeutral extends FRelationCommand {
|
||||
public CmdRelationNeutral() {
|
||||
aliases.add("neutral"); targetRelation = Relation.NEUTRAL;
|
||||
aliases.add("neutral");
|
||||
targetRelation = Relation.NEUTRAL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,36 +6,50 @@ import com.massivecraft.factions.struct.Permission;
|
||||
public class CmdReload extends FCommand {
|
||||
|
||||
public CmdReload() {
|
||||
super(); this.aliases.add("reload");
|
||||
super();
|
||||
this.aliases.add("reload");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("file", "all");
|
||||
|
||||
this.permission = Permission.RELOAD.node; this.disableOnLock = false;
|
||||
this.permission = Permission.RELOAD.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
long timeInitStart = System.currentTimeMillis(); String file = this.argAsString(0, "all").toLowerCase();
|
||||
long timeInitStart = System.currentTimeMillis();
|
||||
String file = this.argAsString(0, "all").toLowerCase();
|
||||
|
||||
String fileName;
|
||||
|
||||
if (file.startsWith("c")) {
|
||||
Conf.load(); fileName = "conf.json";
|
||||
Conf.load();
|
||||
fileName = "conf.json";
|
||||
} else if (file.startsWith("b")) {
|
||||
Board.load(); fileName = "board.json";
|
||||
Board.load();
|
||||
fileName = "board.json";
|
||||
} else if (file.startsWith("f")) {
|
||||
Factions.i.loadFromDisc(); fileName = "factions.json";
|
||||
Factions.i.loadFromDisc();
|
||||
fileName = "factions.json";
|
||||
} else if (file.startsWith("p")) {
|
||||
FPlayers.i.loadFromDisc(); fileName = "players.json";
|
||||
FPlayers.i.loadFromDisc();
|
||||
fileName = "players.json";
|
||||
} else if (file.startsWith("a")) {
|
||||
fileName = "all"; Conf.load(); FPlayers.i.loadFromDisc(); Factions.i.loadFromDisc(); Board.load();
|
||||
fileName = "all";
|
||||
Conf.load();
|
||||
FPlayers.i.loadFromDisc();
|
||||
Factions.i.loadFromDisc();
|
||||
Board.load();
|
||||
} else {
|
||||
P.p.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
|
||||
msg("<b>Invalid file specified. <i>Valid files: all, conf, board, factions, players"); return;
|
||||
msg("<b>Invalid file specified. <i>Valid files: all, conf, board, factions, players");
|
||||
return;
|
||||
}
|
||||
|
||||
long timeReload = (System.currentTimeMillis() - timeInitStart);
|
||||
|
||||
@@ -9,14 +9,18 @@ import com.massivecraft.factions.struct.Permission;
|
||||
public class CmdSafeunclaimall extends FCommand {
|
||||
|
||||
public CmdSafeunclaimall() {
|
||||
this.aliases.add("safeunclaimall"); this.aliases.add("safedeclaimall");
|
||||
this.aliases.add("safeunclaimall");
|
||||
this.aliases.add("safedeclaimall");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("radius", "0");
|
||||
|
||||
this.permission = Permission.MANAGE_SAFE_ZONE.node; this.disableOnLock = true;
|
||||
this.permission = Permission.MANAGE_SAFE_ZONE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
|
||||
this.setHelpShort("Unclaim all safezone land");
|
||||
@@ -24,9 +28,12 @@ public class CmdSafeunclaimall extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Board.unclaimAll(Factions.i.getSafeZone().getId()); msg("<i>You unclaimed ALL safe zone land.");
|
||||
Board.unclaimAll(Factions.i.getSafeZone().getId());
|
||||
msg("<i>You unclaimed ALL safe zone land.");
|
||||
|
||||
if (Conf.logLandUnclaims) { P.p.log(fme.getName() + " unclaimed all safe zones."); }
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(fme.getName() + " unclaimed all safe zones.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,20 +9,29 @@ import com.massivecraft.factions.struct.Permission;
|
||||
public class CmdSaveAll extends FCommand {
|
||||
|
||||
public CmdSaveAll() {
|
||||
super(); this.aliases.add("saveall"); this.aliases.add("save");
|
||||
super();
|
||||
this.aliases.add("saveall");
|
||||
this.aliases.add("save");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.SAVE.node; this.disableOnLock = false;
|
||||
this.permission = Permission.SAVE.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayers.i.saveToDisc(); Factions.i.saveToDisc(); Board.save(); Conf.save(); msg("<i>Factions saved to disk!");
|
||||
FPlayers.i.saveToDisc();
|
||||
Factions.i.saveToDisc();
|
||||
Board.save();
|
||||
Conf.save();
|
||||
msg("<i>Factions saved to disk!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,40 +14,56 @@ public class CmdSethome extends FCommand {
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction tag", "mine");
|
||||
|
||||
this.permission = Permission.SETHOME.node; this.disableOnLock = true;
|
||||
this.permission = Permission.SETHOME.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!Conf.homesEnabled) {
|
||||
fme.msg("<b>Sorry, Faction homes are disabled on this server."); return;
|
||||
fme.msg("<b>Sorry, Faction homes are disabled on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
Faction faction = this.argAsFaction(0, myFaction); if (faction == null) { return; }
|
||||
Faction faction = this.argAsFaction(0, myFaction);
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Can the player set the home for this faction?
|
||||
if (faction == myFaction) {
|
||||
if (!Permission.SETHOME_ANY.has(sender) && !assertMinRole(Role.MODERATOR)) { return; }
|
||||
if (!Permission.SETHOME_ANY.has(sender) && !assertMinRole(Role.MODERATOR)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!Permission.SETHOME_ANY.has(sender, true)) { return; }
|
||||
if (!Permission.SETHOME_ANY.has(sender, true)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Can the player set the faction home HERE?
|
||||
if (!Permission.BYPASS.has(me) &&
|
||||
Conf.homesMustBeInClaimedTerritory &&
|
||||
Board.getFactionAt(new FLocation(me)) != faction) {
|
||||
fme.msg("<b>Sorry, your faction home can only be set inside your own claimed territory."); return;
|
||||
fme.msg("<b>Sorry, your faction home can only be set inside your own claimed territory.");
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostSethome, "to set the faction home", "for setting the faction home")) { return; }
|
||||
if (!payForCommand(Conf.econCostSethome, "to set the faction home", "for setting the faction home")) {
|
||||
return;
|
||||
}
|
||||
|
||||
faction.setHome(me.getLocation());
|
||||
|
||||
faction.msg("%s<i> set the home for your faction. You can now use:", fme.describeTo(myFaction, true));
|
||||
faction.sendMessage(p.cmdBase.cmdHome.getUseageTemplate()); if (faction != myFaction) {
|
||||
faction.sendMessage(p.cmdBase.cmdHome.getUseageTemplate());
|
||||
if (faction != myFaction) {
|
||||
fme.msg("<b>You have set the home for the " + faction.getTag(fme) + "<i> faction.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,20 +14,29 @@ import java.util.Collection;
|
||||
public class CmdShow extends FCommand {
|
||||
|
||||
public CmdShow() {
|
||||
this.aliases.add("show"); this.aliases.add("who");
|
||||
this.aliases.add("show");
|
||||
this.aliases.add("who");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction tag", "yours");
|
||||
|
||||
this.permission = Permission.SHOW.node; this.disableOnLock = false;
|
||||
this.permission = Permission.SHOW.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction faction = myFaction; if (this.argIsSet(0)) {
|
||||
faction = this.argAsFaction(0); if (faction == null) { return; }
|
||||
Faction faction = myFaction;
|
||||
if (this.argIsSet(0)) {
|
||||
faction = this.argAsFaction(0);
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
@@ -39,12 +48,14 @@ public class CmdShow extends FCommand {
|
||||
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
|
||||
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
|
||||
|
||||
msg(p.txt.titleize(faction.getTag(fme))); msg("<a>Description: <i>%s", faction.getDescription());
|
||||
msg(p.txt.titleize(faction.getTag(fme)));
|
||||
msg("<a>Description: <i>%s", faction.getDescription());
|
||||
if (!faction.isNormal()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String peaceStatus = ""; if (faction.isPeaceful()) {
|
||||
String peaceStatus = "";
|
||||
if (faction.isPeaceful()) {
|
||||
peaceStatus = " " + Conf.colorNeutral + "This faction is Peaceful";
|
||||
}
|
||||
|
||||
@@ -61,7 +72,8 @@ public class CmdShow extends FCommand {
|
||||
// show the land value
|
||||
if (Econ.shouldBeUsed()) {
|
||||
double value = Econ.calculateTotalLandValue(faction.getLandRounded());
|
||||
double refund = value * Conf.econClaimRefundMultiplier; if (value > 0) {
|
||||
double refund = value * Conf.econClaimRefundMultiplier;
|
||||
if (value > 0) {
|
||||
String stringValue = Econ.moneyString(value);
|
||||
String stringRefund = (refund > 0.0) ? (" (" + Econ.moneyString(refund) + " depreciated)") : "";
|
||||
msg("<a>Total land value: <i>" + stringValue + stringRefund);
|
||||
@@ -76,38 +88,55 @@ public class CmdShow extends FCommand {
|
||||
String listpart;
|
||||
|
||||
// List relation
|
||||
String allyList = p.txt.parse("<a>Allies: "); String enemyList = p.txt.parse("<a>Enemies: ");
|
||||
String allyList = p.txt.parse("<a>Allies: ");
|
||||
String enemyList = p.txt.parse("<a>Enemies: ");
|
||||
for (Faction otherFaction : Factions.i.get()) {
|
||||
if (otherFaction == faction) { continue; }
|
||||
if (otherFaction == faction) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Relation rel = otherFaction.getRelationTo(faction); if (!rel.isAlly() && !rel.isEnemy()) {
|
||||
Relation rel = otherFaction.getRelationTo(faction);
|
||||
if (!rel.isAlly() && !rel.isEnemy()) {
|
||||
continue; // if not ally or enemy, drop out now so we're not wasting time on it; good performance boost
|
||||
}
|
||||
|
||||
listpart = otherFaction.getTag(fme) + p.txt.parse("<i>") + ", ";
|
||||
if (rel.isAlly()) { allyList += listpart; } else if (rel.isEnemy()) { enemyList += listpart; }
|
||||
} if (allyList.endsWith(", ")) { allyList = allyList.substring(0, allyList.length() - 2); }
|
||||
if (enemyList.endsWith(", ")) { enemyList = enemyList.substring(0, enemyList.length() - 2); }
|
||||
if (rel.isAlly()) {
|
||||
allyList += listpart;
|
||||
} else if (rel.isEnemy()) {
|
||||
enemyList += listpart;
|
||||
}
|
||||
}
|
||||
if (allyList.endsWith(", ")) {
|
||||
allyList = allyList.substring(0, allyList.length() - 2);
|
||||
}
|
||||
if (enemyList.endsWith(", ")) {
|
||||
enemyList = enemyList.substring(0, enemyList.length() - 2);
|
||||
}
|
||||
|
||||
sendMessage(allyList); sendMessage(enemyList);
|
||||
sendMessage(allyList);
|
||||
sendMessage(enemyList);
|
||||
|
||||
// List the members...
|
||||
String onlineList = p.txt.parse("<a>") + "Members online: ";
|
||||
String offlineList = p.txt.parse("<a>") + "Members offline: "; for (FPlayer follower : admins) {
|
||||
String offlineList = p.txt.parse("<a>") + "Members offline: ";
|
||||
for (FPlayer follower : admins) {
|
||||
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
||||
if (follower.isOnlineAndVisibleTo(me)) {
|
||||
onlineList += listpart;
|
||||
} else {
|
||||
offlineList += listpart;
|
||||
}
|
||||
} for (FPlayer follower : mods) {
|
||||
}
|
||||
for (FPlayer follower : mods) {
|
||||
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
||||
if (follower.isOnlineAndVisibleTo(me)) {
|
||||
onlineList += listpart;
|
||||
} else {
|
||||
offlineList += listpart;
|
||||
}
|
||||
} for (FPlayer follower : normals) {
|
||||
}
|
||||
for (FPlayer follower : normals) {
|
||||
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
||||
if (follower.isOnlineAndVisibleTo(me)) {
|
||||
onlineList += listpart;
|
||||
@@ -118,11 +147,13 @@ public class CmdShow extends FCommand {
|
||||
|
||||
if (onlineList.endsWith(", ")) {
|
||||
onlineList = onlineList.substring(0, onlineList.length() - 2);
|
||||
} if (offlineList.endsWith(", ")) {
|
||||
}
|
||||
if (offlineList.endsWith(", ")) {
|
||||
offlineList = offlineList.substring(0, offlineList.length() - 2);
|
||||
}
|
||||
|
||||
sendMessage(onlineList); sendMessage(offlineList);
|
||||
sendMessage(onlineList);
|
||||
sendMessage(offlineList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,13 @@ public class CmdTag extends FCommand {
|
||||
this.requiredArgs.add("faction tag");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.TAG.node; this.disableOnLock = true;
|
||||
this.permission = Permission.TAG.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,25 +33,36 @@ public class CmdTag extends FCommand {
|
||||
|
||||
// TODO does not first test cover selfcase?
|
||||
if (Factions.i.isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag())) {
|
||||
msg("<b>That tag is already taken"); return;
|
||||
msg("<b>That tag is already taken");
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<String> errors = new ArrayList<String>(); errors.addAll(Factions.validateTag(tag));
|
||||
ArrayList<String> errors = new ArrayList<String>();
|
||||
errors.addAll(Factions.validateTag(tag));
|
||||
if (errors.size() > 0) {
|
||||
sendMessage(errors); return;
|
||||
sendMessage(errors);
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||
if (!canAffordCommand(Conf.econCostTag, "to change the faction tag")) { return; }
|
||||
if (!canAffordCommand(Conf.econCostTag, "to change the faction tag")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// trigger the faction rename event (cancellable)
|
||||
FactionRenameEvent renameEvent = new FactionRenameEvent(fme, tag);
|
||||
Bukkit.getServer().getPluginManager().callEvent(renameEvent); if (renameEvent.isCancelled()) { return; }
|
||||
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
|
||||
if (renameEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (!payForCommand(Conf.econCostTag, "to change the faction tag", "for changing the faction tag")) { return; }
|
||||
if (!payForCommand(Conf.econCostTag, "to change the faction tag", "for changing the faction tag")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String oldtag = myFaction.getTag(); myFaction.setTag(tag);
|
||||
String oldtag = myFaction.getTag();
|
||||
myFaction.setTag(tag);
|
||||
|
||||
// Inform
|
||||
myFaction.msg("%s<i> changed your faction tag to %s", fme.describeTo(myFaction, true), myFaction.getTag(myFaction));
|
||||
|
||||
@@ -9,23 +9,36 @@ public class CmdTitle extends FCommand {
|
||||
public CmdTitle() {
|
||||
this.aliases.add("title");
|
||||
|
||||
this.requiredArgs.add("player name"); this.optionalArgs.put("title", "");
|
||||
this.requiredArgs.add("player name");
|
||||
this.optionalArgs.put("title", "");
|
||||
|
||||
this.permission = Permission.TITLE.node; this.disableOnLock = true;
|
||||
this.permission = Permission.TITLE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0); if (you == null) { return; }
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
args.remove(0); String title = TextUtil.implode(args, " ");
|
||||
args.remove(0);
|
||||
String title = TextUtil.implode(args, " ");
|
||||
|
||||
if (!canIAdministerYou(fme, you)) { return; }
|
||||
if (!canIAdministerYou(fme, you)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostTitle, "to change a players title", "for changing a players title")) { return; }
|
||||
if (!payForCommand(Conf.econCostTitle, "to change a players title", "for changing a players title")) {
|
||||
return;
|
||||
}
|
||||
|
||||
you.setTitle(title);
|
||||
|
||||
|
||||
@@ -9,40 +9,50 @@ import org.bukkit.Bukkit;
|
||||
|
||||
public class CmdUnclaim extends FCommand {
|
||||
public CmdUnclaim() {
|
||||
this.aliases.add("unclaim"); this.aliases.add("declaim");
|
||||
this.aliases.add("unclaim");
|
||||
this.aliases.add("declaim");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.UNCLAIM.node; this.disableOnLock = true;
|
||||
this.permission = Permission.UNCLAIM.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FLocation flocation = new FLocation(fme); Faction otherFaction = Board.getFactionAt(flocation);
|
||||
FLocation flocation = new FLocation(fme);
|
||||
Faction otherFaction = Board.getFactionAt(flocation);
|
||||
|
||||
if (otherFaction.isSafeZone()) {
|
||||
if (Permission.MANAGE_SAFE_ZONE.has(sender)) {
|
||||
Board.removeAt(flocation); msg("<i>Safe zone was unclaimed.");
|
||||
Board.removeAt(flocation);
|
||||
msg("<i>Safe zone was unclaimed.");
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
||||
}
|
||||
} else {
|
||||
msg("<b>This is a safe zone. You lack permissions to unclaim.");
|
||||
} return;
|
||||
}
|
||||
return;
|
||||
} else if (otherFaction.isWarZone()) {
|
||||
if (Permission.MANAGE_WAR_ZONE.has(sender)) {
|
||||
Board.removeAt(flocation); msg("<i>War zone was unclaimed.");
|
||||
Board.removeAt(flocation);
|
||||
msg("<i>War zone was unclaimed.");
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
||||
}
|
||||
} else {
|
||||
msg("<b>This is a war zone. You lack permissions to unclaim.");
|
||||
} return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (fme.isAdminBypassing()) {
|
||||
@@ -68,11 +78,15 @@ public class CmdUnclaim extends FCommand {
|
||||
|
||||
|
||||
if (myFaction != otherFaction) {
|
||||
msg("<b>You don't own this land."); return;
|
||||
msg("<b>You don't own this land.");
|
||||
return;
|
||||
}
|
||||
|
||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(flocation, otherFaction, fme);
|
||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent); if (unclaimEvent.isCancelled()) { return; }
|
||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
||||
if (unclaimEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Econ.shouldBeUsed()) {
|
||||
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
|
||||
@@ -82,11 +96,14 @@ public class CmdUnclaim extends FCommand {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!Econ.modifyMoney(fme, refund, "to unclaim this land", "for unclaiming this land")) { return; }
|
||||
if (!Econ.modifyMoney(fme, refund, "to unclaim this land", "for unclaiming this land")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Board.removeAt(flocation); myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
||||
Board.removeAt(flocation);
|
||||
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
||||
|
||||
@@ -10,14 +10,19 @@ import org.bukkit.Bukkit;
|
||||
|
||||
public class CmdUnclaimall extends FCommand {
|
||||
public CmdUnclaimall() {
|
||||
this.aliases.add("unclaimall"); this.aliases.add("declaimall");
|
||||
this.aliases.add("unclaimall");
|
||||
this.aliases.add("declaimall");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.UNCLAIM_ALL.node; this.disableOnLock = true;
|
||||
this.permission = Permission.UNCLAIM_ALL.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,9 +11,12 @@ public class CmdVersion extends FCommand {
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.VERSION.node; this.disableOnLock = false;
|
||||
this.permission = Permission.VERSION.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,18 @@ import com.massivecraft.factions.struct.Permission;
|
||||
public class CmdWarunclaimall extends FCommand {
|
||||
|
||||
public CmdWarunclaimall() {
|
||||
this.aliases.add("warunclaimall"); this.aliases.add("wardeclaimall");
|
||||
this.aliases.add("warunclaimall");
|
||||
this.aliases.add("wardeclaimall");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.MANAGE_WAR_ZONE.node; this.disableOnLock = true;
|
||||
this.permission = Permission.MANAGE_WAR_ZONE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
|
||||
this.setHelpShort("unclaim all warzone land");
|
||||
@@ -24,9 +28,12 @@ public class CmdWarunclaimall extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Board.unclaimAll(Factions.i.getWarZone().getId()); msg("<i>You unclaimed ALL war zone land.");
|
||||
Board.unclaimAll(Factions.i.getWarZone().getId());
|
||||
msg("<i>You unclaimed ALL war zone land.");
|
||||
|
||||
if (Conf.logLandUnclaims) { P.p.log(fme.getName() + " unclaimed all war zones."); }
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(fme.getName() + " unclaimed all war zones.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,14 +52,17 @@ public class FCmdRoot extends FCommand {
|
||||
public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall();
|
||||
|
||||
public FCmdRoot() {
|
||||
super(); this.aliases.addAll(Conf.baseCommandAliases);
|
||||
super();
|
||||
this.aliases.addAll(Conf.baseCommandAliases);
|
||||
this.aliases.removeAll(Collections.singletonList(null)); // remove any nulls from extra commas
|
||||
this.allowNoSlashAccess = Conf.allowNoSlashCommand;
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("","")
|
||||
|
||||
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
|
||||
this.disableOnLock = false;
|
||||
@@ -69,29 +72,57 @@ public class FCmdRoot extends FCommand {
|
||||
|
||||
//this.subCommands.add(p.cmdHelp);
|
||||
|
||||
this.addSubCommand(this.cmdAdmin); this.addSubCommand(this.cmdAutoClaim); this.addSubCommand(this.cmdBoom);
|
||||
this.addSubCommand(this.cmdBypass); this.addSubCommand(this.cmdChat); this.addSubCommand(this.cmdChatSpy);
|
||||
this.addSubCommand(this.cmdClaim); this.addSubCommand(this.cmdConfig); this.addSubCommand(this.cmdCreate);
|
||||
this.addSubCommand(this.cmdDeinvite); this.addSubCommand(this.cmdDescription);
|
||||
this.addSubCommand(this.cmdDisband); this.addSubCommand(this.cmdHelp); this.addSubCommand(this.cmdHome);
|
||||
this.addSubCommand(this.cmdInvite); this.addSubCommand(this.cmdJoin); this.addSubCommand(this.cmdKick);
|
||||
this.addSubCommand(this.cmdLeave); this.addSubCommand(this.cmdList); this.addSubCommand(this.cmdLock);
|
||||
this.addSubCommand(this.cmdMap); this.addSubCommand(this.cmdMod); this.addSubCommand(this.cmdMoney);
|
||||
this.addSubCommand(this.cmdOpen); this.addSubCommand(this.cmdOwner); this.addSubCommand(this.cmdOwnerList);
|
||||
this.addSubCommand(this.cmdPeaceful); this.addSubCommand(this.cmdPermanent);
|
||||
this.addSubCommand(this.cmdPermanentPower); this.addSubCommand(this.cmdPower);
|
||||
this.addSubCommand(this.cmdPowerBoost); this.addSubCommand(this.cmdRelationAlly);
|
||||
this.addSubCommand(this.cmdRelationEnemy); this.addSubCommand(this.cmdRelationNeutral);
|
||||
this.addSubCommand(this.cmdReload); this.addSubCommand(this.cmdSafeunclaimall);
|
||||
this.addSubCommand(this.cmdSaveAll); this.addSubCommand(this.cmdSethome); this.addSubCommand(this.cmdShow);
|
||||
this.addSubCommand(this.cmdTag); this.addSubCommand(this.cmdTitle); this.addSubCommand(this.cmdUnclaim);
|
||||
this.addSubCommand(this.cmdUnclaimall); this.addSubCommand(this.cmdVersion);
|
||||
this.addSubCommand(this.cmdAdmin);
|
||||
this.addSubCommand(this.cmdAutoClaim);
|
||||
this.addSubCommand(this.cmdBoom);
|
||||
this.addSubCommand(this.cmdBypass);
|
||||
this.addSubCommand(this.cmdChat);
|
||||
this.addSubCommand(this.cmdChatSpy);
|
||||
this.addSubCommand(this.cmdClaim);
|
||||
this.addSubCommand(this.cmdConfig);
|
||||
this.addSubCommand(this.cmdCreate);
|
||||
this.addSubCommand(this.cmdDeinvite);
|
||||
this.addSubCommand(this.cmdDescription);
|
||||
this.addSubCommand(this.cmdDisband);
|
||||
this.addSubCommand(this.cmdHelp);
|
||||
this.addSubCommand(this.cmdHome);
|
||||
this.addSubCommand(this.cmdInvite);
|
||||
this.addSubCommand(this.cmdJoin);
|
||||
this.addSubCommand(this.cmdKick);
|
||||
this.addSubCommand(this.cmdLeave);
|
||||
this.addSubCommand(this.cmdList);
|
||||
this.addSubCommand(this.cmdLock);
|
||||
this.addSubCommand(this.cmdMap);
|
||||
this.addSubCommand(this.cmdMod);
|
||||
this.addSubCommand(this.cmdMoney);
|
||||
this.addSubCommand(this.cmdOpen);
|
||||
this.addSubCommand(this.cmdOwner);
|
||||
this.addSubCommand(this.cmdOwnerList);
|
||||
this.addSubCommand(this.cmdPeaceful);
|
||||
this.addSubCommand(this.cmdPermanent);
|
||||
this.addSubCommand(this.cmdPermanentPower);
|
||||
this.addSubCommand(this.cmdPower);
|
||||
this.addSubCommand(this.cmdPowerBoost);
|
||||
this.addSubCommand(this.cmdRelationAlly);
|
||||
this.addSubCommand(this.cmdRelationEnemy);
|
||||
this.addSubCommand(this.cmdRelationNeutral);
|
||||
this.addSubCommand(this.cmdReload);
|
||||
this.addSubCommand(this.cmdSafeunclaimall);
|
||||
this.addSubCommand(this.cmdSaveAll);
|
||||
this.addSubCommand(this.cmdSethome);
|
||||
this.addSubCommand(this.cmdShow);
|
||||
this.addSubCommand(this.cmdTag);
|
||||
this.addSubCommand(this.cmdTitle);
|
||||
this.addSubCommand(this.cmdUnclaim);
|
||||
this.addSubCommand(this.cmdUnclaimall);
|
||||
this.addSubCommand(this.cmdVersion);
|
||||
this.addSubCommand(this.cmdWarunclaimall);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
this.commandChain.add(this); this.cmdHelp.execute(this.sender, this.args, this.commandChain);
|
||||
this.commandChain.add(this);
|
||||
this.cmdHelp.execute(this.sender, this.args, this.commandChain);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,30 +32,38 @@ public abstract class FCommand extends MCommand<P> {
|
||||
// The money commands must be disabled if money should not be used.
|
||||
isMoneyCommand = false;
|
||||
|
||||
senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, List<String> args, List<MCommand<?>> commandChain) {
|
||||
if (sender instanceof Player) {
|
||||
this.fme = FPlayers.i.get((Player) sender); this.myFaction = this.fme.getFaction();
|
||||
this.fme = FPlayers.i.get((Player) sender);
|
||||
this.myFaction = this.fme.getFaction();
|
||||
} else {
|
||||
this.fme = null; this.myFaction = null;
|
||||
} super.execute(sender, args, commandChain);
|
||||
this.fme = null;
|
||||
this.myFaction = null;
|
||||
}
|
||||
super.execute(sender, args, commandChain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (p.getLocked() && this.disableOnLock) {
|
||||
msg("<b>Factions was locked by an admin. Please try again later."); return false;
|
||||
msg("<b>Factions was locked by an admin. Please try again later.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isMoneyCommand && !Conf.econEnabled) {
|
||||
msg("<b>Faction economy features are disabled on this server."); return false;
|
||||
msg("<b>Faction economy features are disabled on this server.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isMoneyCommand && !Conf.bankEnabled) {
|
||||
msg("<b>The faction bank system is disabled on this server."); return false;
|
||||
msg("<b>The faction bank system is disabled on this server.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -63,24 +71,34 @@ public abstract class FCommand extends MCommand<P> {
|
||||
|
||||
@Override
|
||||
public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) {
|
||||
boolean superValid = super.validSenderType(sender, informSenderIfNot); if (!superValid) { return false; }
|
||||
boolean superValid = super.validSenderType(sender, informSenderIfNot);
|
||||
if (!superValid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin)) { return true; }
|
||||
if (!(this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) { return false; }
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FPlayer fplayer = FPlayers.i.get((Player) sender);
|
||||
|
||||
if (!fplayer.hasFaction()) {
|
||||
sender.sendMessage(p.txt.parse("<b>You are not member of any faction.")); return false;
|
||||
sender.sendMessage(p.txt.parse("<b>You are not member of any faction."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.senderMustBeModerator && !fplayer.getRole().isAtLeast(Role.MODERATOR)) {
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort())); return false;
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort()));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.senderMustBeAdmin && !fplayer.getRole().isAtLeast(Role.ADMIN)) {
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort())); return false;
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -91,19 +109,27 @@ public abstract class FCommand extends MCommand<P> {
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean assertHasFaction() {
|
||||
if (me == null) { return true; }
|
||||
if (me == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!fme.hasFaction()) {
|
||||
sendMessage("You are not member of any faction."); return false;
|
||||
} return true;
|
||||
sendMessage("You are not member of any faction.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean assertMinRole(Role role) {
|
||||
if (me == null) { return true; }
|
||||
if (me == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (fme.getRole().value < role.value) {
|
||||
msg("<b>You <h>must be " + role + "<b> to " + this.getHelpShort() + "."); return false;
|
||||
} return true;
|
||||
msg("<b>You <h>must be " + role + "<b> to " + this.getHelpShort() + ".");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@@ -115,7 +141,8 @@ public abstract class FCommand extends MCommand<P> {
|
||||
FPlayer ret = def;
|
||||
|
||||
if (name != null) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name); FPlayer fplayer = FPlayers.i.get(player);
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
FPlayer fplayer = FPlayers.i.get(player);
|
||||
if (fplayer != null) {
|
||||
ret = fplayer;
|
||||
}
|
||||
@@ -176,7 +203,8 @@ public abstract class FCommand extends MCommand<P> {
|
||||
|
||||
// Next we match player names
|
||||
if (faction == null) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name); FPlayer fplayer = FPlayers.i.get(player);
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
FPlayer fplayer = FPlayers.i.get(player);
|
||||
if (fplayer != null) {
|
||||
faction = fplayer.getFaction();
|
||||
}
|
||||
@@ -237,19 +265,27 @@ public abstract class FCommand extends MCommand<P> {
|
||||
|
||||
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
|
||||
public boolean payForCommand(double cost, String toDoThis, String forDoingThis) {
|
||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) { return true; }
|
||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) {
|
||||
return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis);
|
||||
} else { return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis); }
|
||||
} else {
|
||||
return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis);
|
||||
}
|
||||
}
|
||||
|
||||
// like above, but just make sure they can pay; returns true unless person can't afford the cost
|
||||
public boolean canAffordCommand(double cost, String toDoThis) {
|
||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) { return true; }
|
||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) {
|
||||
return Econ.hasAtLeast(myFaction, cost, toDoThis);
|
||||
} else { return Econ.hasAtLeast(fme, cost, toDoThis); }
|
||||
} else {
|
||||
return Econ.hasAtLeast(fme, cost, toDoThis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,28 +12,39 @@ public abstract class FRelationCommand extends FCommand {
|
||||
public Relation targetRelation;
|
||||
|
||||
public FRelationCommand() {
|
||||
super(); this.requiredArgs.add("faction tag");
|
||||
super();
|
||||
this.requiredArgs.add("faction tag");
|
||||
//this.optionalArgs.put("player name", "you");
|
||||
|
||||
this.permission = Permission.RELATION.node; this.disableOnLock = true;
|
||||
this.permission = Permission.RELATION.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction them = this.argAsFaction(0); if (them == null) { return; }
|
||||
Faction them = this.argAsFaction(0);
|
||||
if (them == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!them.isNormal()) {
|
||||
msg("<b>Nope! You can't."); return;
|
||||
msg("<b>Nope! You can't.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (them == myFaction) {
|
||||
msg("<b>Nope! You can't declare a relation to yourself :)"); return;
|
||||
msg("<b>Nope! You can't declare a relation to yourself :)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (myFaction.getRelationWish(them) == targetRelation) {
|
||||
msg("<b>You already have that relation wish set with %s.", them.getTag()); return;
|
||||
msg("<b>You already have that relation wish set with %s.", them.getTag());
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
@@ -42,7 +53,8 @@ public abstract class FRelationCommand extends FCommand {
|
||||
}
|
||||
|
||||
// try to set the new relation
|
||||
Relation oldRelation = myFaction.getRelationTo(them, true); myFaction.setRelationWish(them, targetRelation);
|
||||
Relation oldRelation = myFaction.getRelationTo(them, true);
|
||||
myFaction.setRelationWish(them, targetRelation);
|
||||
Relation currentRelation = myFaction.getRelationTo(them, true);
|
||||
ChatColor currentRelationColor = currentRelation.getColor();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user