Code Enhancements...

This commit is contained in:
Driftay
2019-07-03 23:24:32 -04:00
parent 2937e05fda
commit 9d40fec03b
23 changed files with 55 additions and 98 deletions

View File

@@ -27,14 +27,11 @@ public class CmdConvert extends FCommand {
this.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_RUNNING.toString());
return;
}
switch (nb) {
case JSON:
FactionsJSON.convertTo();
break;
default:
this.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_INVALID.toString());
return;
if (nb == Backend.JSON) {
FactionsJSON.convertTo();
} else {
this.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_INVALID.toString());
return;
}
Conf.backEnd = nb;
}

View File

@@ -79,9 +79,7 @@ public class CmdHome extends FCommand {
final 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))) {
if (Conf.homesTeleportAllowedEnemyDistance > 0 && !faction.isSafeZone() && (!fme.isInOwnTerritory() || !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) {
World w = loc.getWorld();
double x = loc.getX();
double y = loc.getY();

View File

@@ -69,7 +69,7 @@ public class CmdList extends FCommand {
});
// Then sort by how many members are online now
Collections.sort(factionList, (f1, f2) -> {
factionList.sort((f1, f2) -> {
int f1Size = f1.getFPlayersWhereOnline(true).size();
int f2Size = f2.getFPlayersWhereOnline(true).size();
if (f1Size < f2Size) {

View File

@@ -67,7 +67,7 @@ public class CmdRules extends FCommand {
String message = "";
StringBuilder string = new StringBuilder(message);
for (int i = 1; i <= args.size() - 1; i++) {
string.append(" " + args.get(i));
string.append(" ").append(args.get(i));
}
fme.getFaction().addRule(string.toString());
fme.msg(TL.COMMAND_RULES_ADD_SUCCESS);

View File

@@ -72,9 +72,7 @@ public class CmdSeeChunk extends FCommand {
private void startTask() {
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SaberFactions.plugin, () -> {
Iterator<String> itr = seeChunkMap.keySet().iterator();
while (itr.hasNext()) {
Object nameObject = itr.next();
for (Object nameObject : seeChunkMap.keySet()) {
String name = nameObject + "";
Player player = Bukkit.getPlayer(name);
showBorders(player);

View File

@@ -43,25 +43,28 @@ public class CmdStrikeSet extends FCommand {
if (faction == null) {
fme.msg(TL.COMMAND_SETSTRIKES_FAILURE.toString().replace("{faction}", args.get(1)));
}
if (args.get(0).equalsIgnoreCase("set")) {
faction.setStrikes(argAsInt(2));
success = true;
} else if (args.get(0).equalsIgnoreCase("give")) {
faction.setStrikes(faction.getStrikes() + argAsInt(2));
success = true;
} else if (args.get(0).equalsIgnoreCase("take")) {
faction.setStrikes(faction.getStrikes() - argAsInt(2));
success = true;
}
if (success) {
for (FPlayer fPlayer : FPlayers.getInstance().getOnlinePlayers()) {
fPlayer.msg(TL.COMMAND_SETSTRIKES_BROADCAST.toString()
.replace("{faction}", faction.getTag())
.replace("{reason}", getReason()));
if (faction != null) {
if (args.get(0).equalsIgnoreCase("set")) {
faction.setStrikes(argAsInt(2));
success = true;
} else if (args.get(0).equalsIgnoreCase("give")) {
faction.setStrikes(faction.getStrikes() + argAsInt(2));
success = true;
} else if (args.get(0).equalsIgnoreCase("take")) {
faction.setStrikes(faction.getStrikes() - argAsInt(2));
success = true;
}
if (success) {
for (FPlayer fPlayer : FPlayers.getInstance().getOnlinePlayers()) {
fPlayer.msg(TL.COMMAND_SETSTRIKES_BROADCAST.toString()
.replace("{faction}", faction.getTag())
.replace("{reason}", getReason()));
}
fme.msg(TL.COMMAND_SETSTRIKES_SUCCESS.toString()
.replace("{faction}", faction.getTag())
.replace("{strikes}", faction.getStrikes() + ""));
}
fme.msg(TL.COMMAND_SETSTRIKES_SUCCESS.toString()
.replace("{faction}", faction.getTag())
.replace("{strikes}", faction.getStrikes() + ""));
}
}