Some reformat

This commit is contained in:
drtshock
2014-07-01 14:49:42 -05:00
parent 955958ce61
commit dc54f78cc1
83 changed files with 883 additions and 800 deletions

View File

@@ -28,7 +28,7 @@ public class CmdAdmin extends FCommand {
@Override
public void perform() {
FPlayer fyou = this.argAsBestFPlayerMatch(0);
if (fyou == null) return;
if (fyou == null) { return; }
boolean permAny = Permission.ADMIN_ANY.has(sender, false);
Faction targetFaction = fyou.getFaction();
@@ -52,7 +52,7 @@ public class CmdAdmin extends FCommand {
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;
if (event.isCancelled()) { return; }
}
FPlayer admin = targetFaction.getFPlayerAdmin();
@@ -66,8 +66,7 @@ public class CmdAdmin extends FCommand {
}
// promote target player, and demote existing admin if one exists
if (admin != null)
admin.setRole(Role.MODERATOR);
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));

View File

@@ -31,10 +31,8 @@ public class CmdAutoClaim extends FCommand {
}
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));
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)); }
return;
}

View File

@@ -20,7 +20,7 @@ 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>();

View File

@@ -28,7 +28,7 @@ public class CmdBoom extends FCommand {
}
// 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()));

View File

@@ -28,7 +28,8 @@ public class CmdBypass extends FCommand {
if (fme.isAdminBypassing()) {
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 {
}
else {
fme.msg("<i>You have disabled admin bypass mode.");
P.p.log(fme.getName() + " DISABLED admin bypass mode.");
}

View File

@@ -37,11 +37,14 @@ public class CmdChat extends FCommand {
modeString.toLowerCase();
if (modeString.startsWith("p")) {
modeTarget = ChatMode.PUBLIC;
} else if (modeString.startsWith("a")) {
}
else if (modeString.startsWith("a")) {
modeTarget = ChatMode.ALLIANCE;
} else if (modeString.startsWith("f")) {
}
else if (modeString.startsWith("f")) {
modeTarget = ChatMode.FACTION;
} else {
}
else {
msg("<b>Unrecognised chat mode. <i>Please enter either 'a','f' or 'p'");
return;
}
@@ -51,9 +54,11 @@ public class CmdChat extends FCommand {
if (fme.getChatMode() == ChatMode.PUBLIC) {
msg("<i>Public chat mode.");
} else if (fme.getChatMode() == ChatMode.ALLIANCE) {
}
else if (fme.getChatMode() == ChatMode.ALLIANCE) {
msg("<i>Alliance only chat mode.");
} else {
}
else {
msg("<i>Faction only chat mode.");
}
}

View File

@@ -26,7 +26,8 @@ public class CmdChatSpy extends FCommand {
if (fme.isSpyingChat()) {
fme.msg("<i>You have enabled chat spying mode.");
P.p.log(fme.getName() + " has ENABLED chat spying mode.");
} else {
}
else {
fme.msg("<i>You have disabled chat spying mode.");
P.p.log(fme.getName() + " DISABLED chat spying mode.");
}

View File

@@ -40,7 +40,8 @@ public class CmdClaim extends FCommand {
if (radius < 2) {
// single chunk
fme.attemptClaim(forFaction, me.getLocation(), true);
} else {
}
else {
// radius claim
if (!Permission.CLAIM_RADIUS.has(sender, false)) {
msg("<b>You do not have permission to claim in a radius.");
@@ -54,8 +55,7 @@ public class CmdClaim extends FCommand {
@Override
public boolean work() {
boolean success = fme.attemptClaim(forFaction, this.currentLocation(), true);
if (success)
failCount = 0;
if (success) { failCount = 0; }
else if (!success && failCount++ >= limit) {
this.stop();
return false;

View File

@@ -72,7 +72,8 @@ public class CmdConfig extends FCommand {
if (targetValue) {
success = "\"" + fieldName + "\" option set to true (enabled).";
} else {
}
else {
success = "\"" + fieldName + "\" option set to false (disabled).";
}
}
@@ -231,8 +232,9 @@ public class CmdConfig extends FCommand {
if (sender instanceof Player) {
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);
}
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); }
}
// save change to disk
Conf.save();

View File

@@ -48,15 +48,15 @@ public class CmdCreate extends FCommand {
}
// 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;
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();
@@ -84,8 +84,7 @@ 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); }
}
}

View File

@@ -25,7 +25,7 @@ public class CmdDeinvite extends FCommand {
@Override
public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
if (you == null) { return; }
if (you.getFaction() == myFaction) {
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());

View File

@@ -27,8 +27,9 @@ public class CmdDescription extends FCommand {
@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.econCostDesc, "to change faction description", "for changing faction description"))
if (!payForCommand(Conf.econCostDesc, "to change faction description", "for changing faction description")) {
return;
}
myFaction.setDescription(TextUtil.implode(args, " ").replaceAll("(&([a-f0-9]))", "& $2")); // since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up

View File

@@ -30,13 +30,14 @@ public class CmdDisband extends FCommand {
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;
if (faction == null) { return; }
boolean isMyFaction = fme == null ? false : faction == myFaction;
if (isMyFaction) {
if (!assertMinRole(Role.ADMIN)) return;
} else {
if (!assertMinRole(Role.ADMIN)) { return; }
}
else {
if (!Permission.DISBAND_ANY.has(sender, true)) {
return;
}
@@ -53,7 +54,7 @@ public class CmdDisband extends FCommand {
FactionDisbandEvent disbandEvent = new FactionDisbandEvent(me, faction.getId());
Bukkit.getServer().getPluginManager().callEvent(disbandEvent);
if (disbandEvent.isCancelled()) return;
if (disbandEvent.isCancelled()) { return; }
// Send FPlayerLeaveEvent for each player in the faction
for (FPlayer fplayer : faction.getFPlayers()) {
@@ -65,12 +66,14 @@ public class CmdDisband extends FCommand {
String who = senderIsConsole ? "A server admin" : fme.describeTo(fplayer);
if (fplayer.getFaction() == faction) {
fplayer.msg("<h>%s<i> disbanded your faction.", who);
} else {
}
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()) + ".");
}
if (Econ.shouldBeUsed() && !senderIsConsole) {
//Give all the faction's money to the disbander

View File

@@ -30,7 +30,7 @@ public class CmdHelp extends FCommand {
@Override
public void perform() {
if (helpPages == null) updateHelp();
if (helpPages == null) { updateHelp(); }
int page = this.argAsInt(0, 1);

View File

@@ -87,12 +87,10 @@ public class CmdHome extends FCommand {
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;
if (fme.getRelationTo(fp) != Relation.ENEMY) { continue; }
Location l = p.getLocation();
double dx = Math.abs(x - l.getX());
@@ -101,8 +99,7 @@ public class CmdHome extends FCommand {
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;
@@ -110,11 +107,12 @@ 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"))
if (!payForCommand(Conf.econCostHome, "to teleport to your faction home", "for teleporting to your faction home")) {
return;
}
// Create a smoke effect
if (Conf.homesTeleportCommandSmokeEffectEnabled) {

View File

@@ -25,7 +25,7 @@ public class CmdInvite extends FCommand {
@Override
public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
if (you == null) { return; }
if (you.getFaction() == myFaction) {
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
@@ -34,7 +34,7 @@ public class CmdInvite extends FCommand {
}
// 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);

View File

@@ -25,7 +25,7 @@ public class CmdJoin extends FCommand {
@Override
public void perform() {
Faction faction = this.argAsFaction(0);
if (faction == null) return;
if (faction == null) { return; }
FPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false);
boolean samePlayer = fplayer == fme;
@@ -62,26 +62,26 @@ public class CmdJoin extends FCommand {
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;
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)
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));
fplayer.resetFactionData();
@@ -89,10 +89,10 @@ public class CmdJoin extends FCommand {
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());
}
}
}
}

View File

@@ -30,7 +30,7 @@ public class CmdKick extends FCommand {
@Override
public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
if (you == null) { return; }
if (fme == you) {
msg("<b>You cannot kick yourself.");
@@ -60,16 +60,17 @@ public class CmdKick extends FCommand {
}
// 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;
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"))
if (!payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction")) {
return;
}
yourFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.describeTo(yourFaction, true), you.describeTo(yourFaction, true));
you.msg("%s<i> kicked you from %s<i>! :O", fme.describeTo(you, true), yourFaction.describeTo(you));
@@ -77,11 +78,11 @@ public class CmdKick extends FCommand {
fme.msg("<i>You kicked %s<i> from the faction %s<i>!", you.describeTo(fme), yourFaction.describeTo(fme));
}
if (Conf.logFactionKick)
if (Conf.logFactionKick) {
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();

View File

@@ -32,7 +32,7 @@ public class CmdList extends FCommand {
@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());
@@ -45,10 +45,8 @@ public class CmdList extends FCommand {
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;
if (f1Size < f2Size) { return 1; }
else if (f1Size > f2Size) { return -1; }
return 0;
}
});
@@ -59,10 +57,8 @@ 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;
if (f1Size < f2Size) { return 1; }
else if (f1Size > f2Size) { return -1; }
return 0;
}
});
@@ -91,14 +87,11 @@ public class CmdList extends FCommand {
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;
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 (end > factionList.size()) { end = factionList.size(); }
lines.add(p.txt.titleize("Faction List " + pagenumber + "/" + pagecount));
@@ -108,12 +101,12 @@ public class CmdList extends FCommand {
continue;
}
lines.add(p.txt.parse("%s<i> %d/%d online, %d/%d/%d",
faction.getTag(fme),
faction.getFPlayersWhereOnline(true).size(),
faction.getFPlayers().size(),
faction.getLandRounded(),
faction.getPowerRounded(),
faction.getPowerMaxRounded())
faction.getTag(fme),
faction.getFPlayersWhereOnline(true).size(),
faction.getFPlayers().size(),
faction.getLandRounded(),
faction.getPowerRounded(),
faction.getPowerMaxRounded())
);
}

View File

@@ -33,7 +33,8 @@ public class CmdLock extends FCommand {
if (p.getLocked()) {
msg("<i>Factions is now locked");
} else {
}
else {
msg("<i>Factions in now unlocked");
}
}

View File

@@ -30,21 +30,23 @@ 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.");
// And show the map once
showMap();
} else {
}
else {
// Turn off
fme.setMapAutoUpdating(false);
msg("<i>Map auto update <red>DISABLED.");
}
} else {
}
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();
}

View File

@@ -26,7 +26,7 @@ public class CmdMod extends FCommand {
@Override
public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
if (you == null) { return; }
boolean permAny = Permission.MOD_ANY.has(sender, false);
Faction targetFaction = you.getFaction();
@@ -56,7 +56,8 @@ public class CmdMod extends FCommand {
you.setRole(Role.NORMAL);
targetFaction.msg("%s<i> is no longer moderator in your faction.", you.describeTo(targetFaction, true));
msg("<i>You have removed moderator status from %s<i>.", you.describeTo(fme, true));
} else {
}
else {
// Give
you.setRole(Role.MODERATOR);
targetFaction.msg("%s<i> was promoted to moderator in your faction.", you.describeTo(targetFaction, true));

View File

@@ -29,8 +29,8 @@ public class CmdMoneyBalance extends FCommand {
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);
}

View File

@@ -31,11 +31,12 @@ public class CmdMoneyDeposit extends FCommand {
public void perform() {
double amount = this.argAsDouble(0, 0d);
EconomyParticipator faction = this.argAsFaction(1, myFaction);
if (faction == null) return;
if (faction == null) { return; }
boolean success = Econ.transferMoney(fme, fme, faction, amount);
if (success && Conf.logMoneyTransactions)
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))));
}
}
}

View File

@@ -31,13 +31,14 @@ public class CmdMoneyTransferFf extends FCommand {
public void perform() {
double amount = this.argAsDouble(0, 0d);
EconomyParticipator from = this.argAsFaction(1);
if (from == null) return;
if (from == null) { return; }
EconomyParticipator to = this.argAsFaction(2);
if (to == null) return;
if (to == null) { return; }
boolean success = Econ.transferMoney(fme, from, to, amount);
if (success && Conf.logMoneyTransactions)
if (success && Conf.logMoneyTransactions) {
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
}
}
}

View File

@@ -31,13 +31,14 @@ public class CmdMoneyTransferFp extends FCommand {
public void perform() {
double amount = this.argAsDouble(0, 0d);
EconomyParticipator from = this.argAsFaction(1);
if (from == null) return;
if (from == null) { return; }
EconomyParticipator to = this.argAsBestFPlayerMatch(2);
if (to == null) return;
if (to == null) { return; }
boolean success = Econ.transferMoney(fme, from, to, amount);
if (success && Conf.logMoneyTransactions)
if (success && Conf.logMoneyTransactions) {
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
}
}
}

View File

@@ -31,13 +31,14 @@ public class CmdMoneyTransferPf extends FCommand {
public void perform() {
double amount = this.argAsDouble(0, 0d);
EconomyParticipator from = this.argAsBestFPlayerMatch(1);
if (from == null) return;
if (from == null) { return; }
EconomyParticipator to = this.argAsFaction(2);
if (to == null) return;
if (to == null) { return; }
boolean success = Econ.transferMoney(fme, from, to, amount);
if (success && Conf.logMoneyTransactions)
if (success && Conf.logMoneyTransactions) {
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
}
}
}

View File

@@ -29,10 +29,11 @@ public class CmdMoneyWithdraw extends FCommand {
public void perform() {
double amount = this.argAsDouble(0, 0d);
EconomyParticipator faction = this.argAsFaction(1, myFaction);
if (faction == null) return;
if (faction == null) { return; }
boolean success = Econ.transferMoney(fme, faction, fme, amount);
if (success && Conf.logMoneyTransactions)
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))));
}
}
}

View File

@@ -25,8 +25,9 @@ public class CmdOpen extends FCommand {
@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.econCostOpen, "to open or close the faction", "for opening or closing the faction"))
if (!payForCommand(Conf.econCostOpen, "to open or close the faction", "for opening or closing the faction")) {
return;
}
myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen()));

View File

@@ -63,7 +63,7 @@ public class CmdOwner extends FCommand {
}
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
if (target == null) return;
if (target == null) { return; }
String playerName = target.getName();
@@ -86,8 +86,9 @@ public class CmdOwner extends FCommand {
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostOwner, "to set ownership of claimed land", "for setting ownership of claimed land"))
if (!payForCommand(Conf.econCostOwner, "to set ownership of claimed land", "for setting ownership of claimed land")) {
return;
}
myFaction.setPlayerAsOwner(target, flocation);

View File

@@ -26,13 +26,14 @@ public class CmdPeaceful extends FCommand {
@Override
public void perform() {
Faction faction = this.argAsFaction(0);
if (faction == null) return;
if (faction == null) { return; }
String change;
if (faction.isPeaceful()) {
change = "removed peaceful status from";
faction.setPeaceful(false);
} else {
}
else {
change = "granted peaceful status to";
faction.setPeaceful(true);
}
@@ -41,7 +42,8 @@ public class CmdPeaceful extends FCommand {
for (FPlayer fplayer : FPlayers.i.getOnline()) {
if (fplayer.getFaction() == faction) {
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> has " + change + " your faction.");
} else {
}
else {
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> has " + change + " the faction \"" + faction.getTag(fplayer) + "<i>\".");
}
}

View File

@@ -27,13 +27,14 @@ public class CmdPermanent extends FCommand {
@Override
public void perform() {
Faction faction = this.argAsFaction(0);
if (faction == null) return;
if (faction == null) { return; }
String change;
if (faction.isPermanent()) {
change = "removed permanent status from";
faction.setPermanent(false);
} else {
}
else {
change = "added permanent status to";
faction.setPermanent(true);
}
@@ -44,7 +45,8 @@ public class CmdPermanent extends FCommand {
for (FPlayer fplayer : FPlayers.i.getOnline()) {
if (fplayer.getFaction() == faction) {
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> " + change + " your faction.");
} else {
}
else {
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> " + change + " the faction \"" + faction.getTag(fplayer) + "\".");
}
}

View File

@@ -24,7 +24,7 @@ public class CmdPermanentPower extends FCommand {
@Override
public void perform() {
Faction targetFaction = this.argAsFaction(0);
if (targetFaction == null) return;
if (targetFaction == null) { return; }
Integer targetPower = this.argAsInt(1);

View File

@@ -26,12 +26,14 @@ public class CmdPower extends FCommand {
@Override
public void perform() {
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
if (target == null) return;
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")) return;
if (!payForCommand(Conf.econCostPower, "to show player power info", "for showing player power info")) {
return;
}
double powerBoost = target.getPowerBoost();
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";

View File

@@ -29,7 +29,8 @@ public class CmdPowerBoost extends FCommand {
boolean doPlayer = true;
if (type.equals("f") || type.equals("faction")) {
doPlayer = false;
} else if (!type.equals("p") && !type.equals("player")) {
}
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;
@@ -45,18 +46,20 @@ public class CmdPowerBoost extends FCommand {
if (doPlayer) {
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1);
if (targetPlayer == null) return;
if (targetPlayer == null) { return; }
targetPlayer.setPowerBoost(targetPower);
target = "Player \"" + targetPlayer.getName() + "\"";
} else {
}
else {
Faction targetFaction = this.argAsFaction(1);
if (targetFaction == null) return;
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.");
if (!senderIsConsole)
if (!senderIsConsole) {
P.p.log(fme.getName() + " has set the power bonus/penalty for " + target + " to " + targetPower + ".");
}
}
}

View File

@@ -31,22 +31,27 @@ public class CmdReload extends FCommand {
if (file.startsWith("c")) {
Conf.load();
fileName = "conf.json";
} else if (file.startsWith("b")) {
}
else if (file.startsWith("b")) {
Board.load();
fileName = "board.json";
} else if (file.startsWith("f")) {
}
else if (file.startsWith("f")) {
Factions.i.loadFromDisc();
fileName = "factions.json";
} else if (file.startsWith("p")) {
}
else if (file.startsWith("p")) {
FPlayers.i.loadFromDisc();
fileName = "players.json";
} else if (file.startsWith("a")) {
}
else if (file.startsWith("a")) {
fileName = "all";
Conf.load();
FPlayers.i.loadFromDisc();
Factions.i.loadFromDisc();
Board.load();
} else {
}
else {
P.p.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
msg("<b>Invalid file specified. <i>Valid files: all, conf, board, factions, players");
return;

View File

@@ -31,8 +31,7 @@ public class CmdSafeunclaimall extends FCommand {
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."); }
}
}

View File

@@ -31,13 +31,14 @@ public class CmdSethome extends FCommand {
}
Faction faction = this.argAsFaction(0, myFaction);
if (faction == null) return;
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;
} else {
if (!Permission.SETHOME_ANY.has(sender, true)) return;
if (!Permission.SETHOME_ANY.has(sender) && !assertMinRole(Role.MODERATOR)) { return; }
}
else {
if (!Permission.SETHOME_ANY.has(sender, true)) { return; }
}
// Can the player set the faction home HERE?
@@ -54,7 +55,7 @@ public class CmdSethome extends FCommand {
}
// 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());

View File

@@ -34,11 +34,13 @@ public class CmdShow extends FCommand {
Faction faction = myFaction;
if (this.argIsSet(0)) {
faction = this.argAsFaction(0);
if (faction == null) return;
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
if (!payForCommand(Conf.econCostShow, "to show faction information", "for showing faction information")) return;
if (!payForCommand(Conf.econCostShow, "to show faction information", "for showing faction information")) {
return;
}
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
@@ -87,22 +89,19 @@ public class CmdShow extends FCommand {
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())
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 (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 (allyList.endsWith(", ")) { allyList = allyList.substring(0, allyList.length() - 2); }
if (enemyList.endsWith(", ")) { enemyList = enemyList.substring(0, enemyList.length() - 2); }
sendMessage(allyList);
sendMessage(enemyList);
@@ -114,7 +113,8 @@ public class CmdShow extends FCommand {
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
if (follower.isOnlineAndVisibleTo(me)) {
onlineList += listpart;
} else {
}
else {
offlineList += listpart;
}
}
@@ -123,7 +123,8 @@ public class CmdShow extends FCommand {
if
(follower.isOnlineAndVisibleTo(me)) {
onlineList += listpart;
} else {
}
else {
offlineList += listpart;
}
}
@@ -131,7 +132,8 @@ public class CmdShow extends FCommand {
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
if (follower.isOnlineAndVisibleTo(me)) {
onlineList += listpart;
} else {
}
else {
offlineList += listpart;
}
}

View File

@@ -45,15 +45,15 @@ public class CmdTag extends FCommand {
}
// 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;
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);

View File

@@ -24,15 +24,15 @@ public class CmdTitle extends FCommand {
@Override
public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
if (you == null) { return; }
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);

View File

@@ -34,20 +34,25 @@ public class CmdUnclaim extends FCommand {
Board.removeAt(flocation);
msg("<i>Safe zone was unclaimed.");
if (Conf.logLandUnclaims)
if (Conf.logLandUnclaims) {
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
} else {
}
}
else {
msg("<b>This is a safe zone. You lack permissions to unclaim.");
}
return;
} else if (otherFaction.isWarZone()) {
}
else if (otherFaction.isWarZone()) {
if (Permission.MANAGE_WAR_ZONE.has(sender)) {
Board.removeAt(flocation);
msg("<i>War zone was unclaimed.");
if (Conf.logLandUnclaims)
if (Conf.logLandUnclaims) {
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
} else {
}
}
else {
msg("<b>This is a war zone. You lack permissions to unclaim.");
}
return;
@@ -59,8 +64,9 @@ public class CmdUnclaim extends FCommand {
otherFaction.msg("%s<i> unclaimed some of your land.", fme.describeTo(otherFaction, true));
msg("<i>You unclaimed this land.");
if (Conf.logLandUnclaims)
if (Conf.logLandUnclaims) {
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
}
return;
}
@@ -81,23 +87,27 @@ public class CmdUnclaim extends FCommand {
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(flocation, otherFaction, fme);
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
if (unclaimEvent.isCancelled()) return;
if (unclaimEvent.isCancelled()) { return; }
if (Econ.shouldBeUsed()) {
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
if (!Econ.modifyMoney(myFaction, refund, "to unclaim this land", "for unclaiming this land")) return;
} else {
if (!Econ.modifyMoney(fme, refund, "to unclaim this land", "for unclaiming this land")) return;
if (!Econ.modifyMoney(myFaction, refund, "to unclaim this land", "for unclaiming this land")) {
return;
}
}
else {
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));
if (Conf.logLandUnclaims)
if (Conf.logLandUnclaims) {
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
}
}
}

View File

@@ -30,11 +30,14 @@ public class CmdUnclaimall extends FCommand {
if (Econ.shouldBeUsed()) {
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
if (!Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land"))
if (!Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land")) {
return;
} else {
if (!Econ.modifyMoney(fme, refund, "to unclaim all faction land", "for unclaiming all faction land"))
}
}
else {
if (!Econ.modifyMoney(fme, refund, "to unclaim all faction land", "for unclaiming all faction land")) {
return;
}
}
}
@@ -45,8 +48,9 @@ public class CmdUnclaimall extends FCommand {
Board.unclaimAll(myFaction.getId());
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
if (Conf.logLandUnclaims)
if (Conf.logLandUnclaims) {
P.p.log(fme.getName() + " unclaimed everything for the faction: " + myFaction.getTag());
}
}
}

View File

@@ -31,8 +31,7 @@ public class CmdWarunclaimall extends FCommand {
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."); }
}
}

View File

@@ -42,7 +42,8 @@ public abstract class FCommand extends MCommand<P> {
if (sender instanceof Player) {
this.fme = FPlayers.i.get((Player) sender);
this.myFaction = this.fme.getFaction();
} else {
}
else {
this.fme = null;
this.myFaction = null;
}
@@ -72,11 +73,11 @@ 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;
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);
@@ -103,7 +104,7 @@ 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.");
@@ -113,7 +114,7 @@ public abstract class FCommand extends MCommand<P> {
}
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() + ".");
@@ -240,13 +241,16 @@ public abstract class FCommand extends MCommand<P> {
if (you.getRole().equals(Role.ADMIN)) {
i.sendMessage(p.txt.parse("<b>Only the faction admin can do that."));
} else if (i.getRole().equals(Role.MODERATOR)) {
}
else if (i.getRole().equals(Role.MODERATOR)) {
if (i == you) {
return true; //Moderators can control themselves
} else {
}
else {
i.sendMessage(p.txt.parse("<b>Moderators can't control each other..."));
}
} else {
}
else {
i.sendMessage(p.txt.parse("<b>You must be a faction moderator to do that."));
}
@@ -255,21 +259,21 @@ 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())
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())
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); }
}
}

View File

@@ -28,7 +28,7 @@ public abstract class FRelationCommand extends FCommand {
@Override
public void perform() {
Faction them = this.argAsFaction(0);
if (them == null) return;
if (them == null) { return; }
if (!them.isNormal()) {
msg("<b>Nope! You can't.");
@@ -46,8 +46,9 @@ public abstract class FRelationCommand extends FCommand {
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(targetRelation.getRelationCost(), "to change a relation wish", "for changing a relation wish"))
if (!payForCommand(targetRelation.getRelationCost(), "to change a relation wish", "for changing a relation wish")) {
return;
}
// try to set the new relation
Relation oldRelation = myFaction.getRelationTo(them, true);