From dc54f78cc172ac45f90a30b508e09811d5acdf35 Mon Sep 17 00:00:00 2001 From: drtshock Date: Tue, 1 Jul 2014 14:49:42 -0500 Subject: [PATCH] Some reformat --- .../java/com/massivecraft/factions/Board.java | 40 ++-- .../com/massivecraft/factions/FLocation.java | 11 +- .../com/massivecraft/factions/FPlayer.java | 128 +++++++----- .../com/massivecraft/factions/Faction.java | 54 +++-- .../com/massivecraft/factions/Factions.java | 23 +-- .../java/com/massivecraft/factions/P.java | 54 +++-- .../massivecraft/factions/cmd/CmdAdmin.java | 7 +- .../factions/cmd/CmdAutoClaim.java | 6 +- .../factions/cmd/CmdAutoHelp.java | 2 +- .../massivecraft/factions/cmd/CmdBoom.java | 2 +- .../massivecraft/factions/cmd/CmdBypass.java | 3 +- .../massivecraft/factions/cmd/CmdChat.java | 15 +- .../massivecraft/factions/cmd/CmdChatSpy.java | 3 +- .../massivecraft/factions/cmd/CmdClaim.java | 6 +- .../massivecraft/factions/cmd/CmdConfig.java | 8 +- .../massivecraft/factions/cmd/CmdCreate.java | 9 +- .../factions/cmd/CmdDeinvite.java | 2 +- .../factions/cmd/CmdDescription.java | 3 +- .../massivecraft/factions/cmd/CmdDisband.java | 15 +- .../massivecraft/factions/cmd/CmdHelp.java | 2 +- .../massivecraft/factions/cmd/CmdHome.java | 14 +- .../massivecraft/factions/cmd/CmdInvite.java | 4 +- .../massivecraft/factions/cmd/CmdJoin.java | 20 +- .../massivecraft/factions/cmd/CmdKick.java | 15 +- .../massivecraft/factions/cmd/CmdList.java | 35 ++-- .../massivecraft/factions/cmd/CmdLock.java | 3 +- .../com/massivecraft/factions/cmd/CmdMap.java | 10 +- .../com/massivecraft/factions/cmd/CmdMod.java | 5 +- .../factions/cmd/CmdMoneyBalance.java | 4 +- .../factions/cmd/CmdMoneyDeposit.java | 5 +- .../factions/cmd/CmdMoneyTransferFf.java | 7 +- .../factions/cmd/CmdMoneyTransferFp.java | 7 +- .../factions/cmd/CmdMoneyTransferPf.java | 7 +- .../factions/cmd/CmdMoneyWithdraw.java | 5 +- .../massivecraft/factions/cmd/CmdOpen.java | 3 +- .../massivecraft/factions/cmd/CmdOwner.java | 5 +- .../factions/cmd/CmdPeaceful.java | 8 +- .../factions/cmd/CmdPermanent.java | 8 +- .../factions/cmd/CmdPermanentPower.java | 2 +- .../massivecraft/factions/cmd/CmdPower.java | 8 +- .../factions/cmd/CmdPowerBoost.java | 13 +- .../massivecraft/factions/cmd/CmdReload.java | 15 +- .../factions/cmd/CmdSafeunclaimall.java | 3 +- .../massivecraft/factions/cmd/CmdSethome.java | 11 +- .../massivecraft/factions/cmd/CmdShow.java | 32 +-- .../com/massivecraft/factions/cmd/CmdTag.java | 6 +- .../massivecraft/factions/cmd/CmdTitle.java | 6 +- .../massivecraft/factions/cmd/CmdUnclaim.java | 32 +-- .../factions/cmd/CmdUnclaimall.java | 12 +- .../factions/cmd/CmdWarunclaimall.java | 3 +- .../massivecraft/factions/cmd/FCommand.java | 38 ++-- .../factions/cmd/FRelationCommand.java | 5 +- .../factions/integration/Econ.java | 102 +++++----- .../factions/integration/Essentials.java | 2 +- .../factions/integration/Worldguard.java | 9 +- .../listeners/FactionsBlockListener.java | 85 ++++---- .../listeners/FactionsChatListener.java | 38 ++-- .../listeners/FactionsEntityListener.java | 185 +++++++++--------- .../listeners/FactionsExploitListener.java | 9 +- .../listeners/FactionsPlayerListener.java | 136 +++++++------ .../factions/struct/ChatMode.java | 4 +- .../factions/struct/Relation.java | 81 +++----- .../factions/util/AsciiCompass.java | 33 ++-- .../factions/util/AutoLeaveProcessTask.java | 8 +- .../factions/util/AutoLeaveTask.java | 6 +- .../factions/util/LazyLocation.java | 4 +- .../massivecraft/factions/util/Metrics.java | 12 +- .../massivecraft/factions/util/MiscUtil.java | 8 +- .../factions/util/RelationUtil.java | 24 ++- .../factions/util/SpiralTask.java | 28 ++- .../factions/zcore/FCommandHandler.java | 3 +- .../massivecraft/factions/zcore/MCommand.java | 18 +- .../massivecraft/factions/zcore/MPlugin.java | 26 ++- .../zcore/MPluginSecretPlayerListener.java | 6 +- .../zcore/MPluginSecretServerListener.java | 2 +- .../zcore/persist/EntityCollection.java | 21 +- .../factions/zcore/persist/PlayerEntity.java | 4 +- .../factions/zcore/persist/SaveTask.java | 2 +- .../factions/zcore/util/PermUtil.java | 9 +- .../factions/zcore/util/Persist.java | 2 +- .../factions/zcore/util/SmokeUtil.java | 2 +- .../massivecraft/factions/zcore/util/TL.java | 2 +- .../factions/zcore/util/TextUtil.java | 68 +++---- 83 files changed, 883 insertions(+), 800 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/Board.java b/src/main/java/com/massivecraft/factions/Board.java index ac9336bc..7665e940 100644 --- a/src/main/java/com/massivecraft/factions/Board.java +++ b/src/main/java/com/massivecraft/factions/Board.java @@ -173,33 +173,39 @@ public class Board { for (int dx = 0; dx < width; dx++) { if (dx == halfWidth && dz == halfHeight) { row += ChatColor.AQUA + "+"; - } else { + } + else { FLocation flocationHere = topLeft.getRelative(dx, dz); Faction factionHere = getFactionAt(flocationHere); Relation relation = faction.getRelationTo(factionHere); if (factionHere.isNone()) { row += ChatColor.GRAY + "-"; - } else if (factionHere.isSafeZone()) { + } + else if (factionHere.isSafeZone()) { row += Conf.colorPeaceful + "+"; - } else if (factionHere.isWarZone()) { + } + else if (factionHere.isWarZone()) { row += ChatColor.DARK_RED + "+"; - } else if - ( - factionHere == faction - || - factionHere == factionLoc - || - relation.isAtLeast(Relation.ALLY) - || - (Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL)) - || - (Conf.showEnemyFactionsOnMap && relation.equals(Relation.ENEMY)) - ) { - if (!fList.containsKey(factionHere.getTag())) + } + else if + ( + factionHere == faction + || + factionHere == factionLoc + || + relation.isAtLeast(Relation.ALLY) + || + (Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL)) + || + (Conf.showEnemyFactionsOnMap && relation.equals(Relation.ENEMY)) + ) { + if (!fList.containsKey(factionHere.getTag())) { fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]); + } char tag = fList.get(factionHere.getTag()); row += factionHere.getColorTo(faction) + "" + tag; - } else { + } + else { row += ChatColor.GRAY + "-"; } } diff --git a/src/main/java/com/massivecraft/factions/FLocation.java b/src/main/java/com/massivecraft/factions/FLocation.java index 6b782e36..a7cf44ce 100644 --- a/src/main/java/com/massivecraft/factions/FLocation.java +++ b/src/main/java/com/massivecraft/factions/FLocation.java @@ -136,7 +136,7 @@ public class FLocation { //----------------------------------------------// public Set getCircle(double radius) { Set ret = new LinkedHashSet(); - if (radius <= 0) return ret; + if (radius <= 0) { return ret; } int xfrom = (int) Math.floor(this.x - radius); int xto = (int) Math.ceil(this.x + radius); @@ -146,8 +146,7 @@ public class FLocation { for (int x = xfrom; x <= xto; x++) { for (int z = zfrom; z <= zto; z++) { FLocation potential = new FLocation(this.worldName, x, z); - if (this.getDistanceTo(potential) <= radius) - ret.add(potential); + if (this.getDistanceTo(potential) <= radius) { ret.add(potential); } } } @@ -178,10 +177,8 @@ public class FLocation { @Override public boolean equals(Object obj) { - if (obj == this) - return true; - if (!(obj instanceof FLocation)) - return false; + if (obj == this) { return true; } + if (!(obj instanceof FLocation)) { return false; } FLocation that = (FLocation) obj; return this.x == that.x && this.z == that.z && (this.worldName == null ? that.worldName == null : this.worldName.equals(that.worldName)); diff --git a/src/main/java/com/massivecraft/factions/FPlayer.java b/src/main/java/com/massivecraft/factions/FPlayer.java index 91d99f25..62ed8445 100644 --- a/src/main/java/com/massivecraft/factions/FPlayer.java +++ b/src/main/java/com/massivecraft/factions/FPlayer.java @@ -58,7 +58,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { public void setFaction(Faction faction) { Faction oldFaction = this.getFaction(); - if (oldFaction != null) oldFaction.removeFPlayer(this); + if (oldFaction != null) { oldFaction.removeFPlayer(this); } faction.addFPlayer(this); this.factionId = faction.getId(); } @@ -458,10 +458,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { protected void alterPower(double delta) { this.power += delta; - if (this.power > this.getPowerMax()) - this.power = this.getPowerMax(); - else if (this.power < this.getPowerMin()) - this.power = this.getPowerMin(); + if (this.power > this.getPowerMax()) { this.power = this.getPowerMax(); } + else if (this.power < this.getPowerMin()) { this.power = this.getPowerMin(); } } public double getPowerMax() { @@ -496,8 +494,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { this.lastPowerUpdateTime = now; Player thisPlayer = this.getPlayer(); - if (thisPlayer != null && thisPlayer.isDead()) + if (thisPlayer != null && thisPlayer.isDead()) { return; // don't let dead players regain power until they respawn + } int millisPerMinute = 60 * 1000; this.alterPower(millisPassed * Conf.powerPerMinute / millisPerMinute); @@ -581,21 +580,23 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { } // if economy is enabled and they're not on the bypass list, make sure they can pay - if (makePay && !Econ.hasAtLeast(this, Conf.econCostLeave, "to leave your faction.")) return; + if (makePay && !Econ.hasAtLeast(this, Conf.econCostLeave, "to leave your faction.")) { return; } FPlayerLeaveEvent leaveEvent = new FPlayerLeaveEvent(this, myFaction, FPlayerLeaveEvent.PlayerLeaveReason.LEAVE); Bukkit.getServer().getPluginManager().callEvent(leaveEvent); - if (leaveEvent.isCancelled()) return; + if (leaveEvent.isCancelled()) { return; } // then make 'em pay (if applicable) - if (makePay && !Econ.modifyMoney(this, -Conf.econCostLeave, "to leave your faction.", "for leaving your faction.")) + if (makePay && !Econ.modifyMoney(this, -Conf.econCostLeave, "to leave your faction.", "for leaving your faction.")) { return; + } // Am I the last one in the faction? if (myFaction.getFPlayers().size() == 1) { // Transfer all money - if (Econ.shouldBeUsed()) + if (Econ.shouldBeUsed()) { Econ.transferMoney(this, myFaction, this, Econ.getBalance(myFaction.getAccountId())); + } } if (myFaction.isNormal()) { @@ -603,8 +604,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { fplayer.msg("%s left %s.", this.describeTo(fplayer, true), myFaction.describeTo(fplayer)); } - if (Conf.logFactionLeave) - P.p.log(this.getName() + " left the faction: " + myFaction.getTag()); + if (Conf.logFactionLeave) { P.p.log(this.getName() + " left the faction: " + myFaction.getTag()); } } this.resetFactionData(); @@ -616,18 +616,19 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { } myFaction.detach(); - if (Conf.logFactionDisband) + if (Conf.logFactionDisband) { P.p.log("The faction " + myFaction.getTag() + " (" + myFaction.getId() + ") was disbanded due to the last player (" + this.getName() + ") leaving."); + } } } public boolean canClaimForFaction(Faction forFaction) { - if (forFaction.isNone()) return false; + if (forFaction.isNone()) { return false; } if (this.isAdminBypassing() - || (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR)) - || (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) - || (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()))) { + || (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR)) + || (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) + || (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()))) { return true; } @@ -644,50 +645,70 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { if (Conf.worldGuardChecking && Worldguard.checkForRegionsInChunk(location)) { // Checks for WorldGuard regions in the chunk attempting to be claimed error = P.p.txt.parse("This land is protected"); - } else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) { + } + else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) { error = P.p.txt.parse("Sorry, this world has land claiming disabled."); - } else if (this.isAdminBypassing()) { + } + else if (this.isAdminBypassing()) { return true; - } else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) { + } + else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) { return true; - } else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) { + } + else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) { return true; - } else if (myFaction != forFaction) { + } + else if (myFaction != forFaction) { error = P.p.txt.parse("You can't claim land for %s.", forFaction.describeTo(this)); - } else if (forFaction == currentFaction) { + } + else if (forFaction == currentFaction) { error = P.p.txt.parse("%s already own this land.", forFaction.describeTo(this, true)); - } else if (this.getRole().value < Role.MODERATOR.value) { + } + else if (this.getRole().value < Role.MODERATOR.value) { error = P.p.txt.parse("You must be %s to claim land.", Role.MODERATOR.toString()); - } else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) { + } + else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) { error = P.p.txt.parse("Factions must have at least %s members to claim land.", Conf.claimsRequireMinFactionMembers); - } else if (currentFaction.isSafeZone()) { + } + else if (currentFaction.isSafeZone()) { error = P.p.txt.parse("You can not claim a Safe Zone."); - } else if (currentFaction.isWarZone()) { + } + else if (currentFaction.isWarZone()) { error = P.p.txt.parse("You can not claim a War Zone."); - } else if (ownedLand >= forFaction.getPowerRounded()) { + } + else if (ownedLand >= forFaction.getPowerRounded()) { error = P.p.txt.parse("You can't claim more land! You need more power!"); - } else if (Conf.claimedLandsMax != 0 && ownedLand >= Conf.claimedLandsMax && forFaction.isNormal()) { + } + else if (Conf.claimedLandsMax != 0 && ownedLand >= Conf.claimedLandsMax && forFaction.isNormal()) { error = P.p.txt.parse("Limit reached. You can't claim more land!"); - } else if (currentFaction.getRelationTo(forFaction) == Relation.ALLY) { + } + else if (currentFaction.getRelationTo(forFaction) == Relation.ALLY) { error = P.p.txt.parse("You can't claim the land of your allies."); - } else if (Conf.claimsMustBeConnected - && !this.isAdminBypassing() - && myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 - && !Board.isConnectedLocation(flocation, myFaction) - && (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())) { - if (Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction) + } + else if (Conf.claimsMustBeConnected + && !this.isAdminBypassing() + && myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 + && !Board.isConnectedLocation(flocation, myFaction) + && (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())) { + if (Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction) { error = P.p.txt.parse("You can only claim additional land which is connected to your first claim or controlled by another faction!"); - else + } + else { error = P.p.txt.parse("You can only claim additional land which is connected to your first claim!"); - } else if (currentFaction.isNormal()) { + } + } + else if (currentFaction.isNormal()) { if (myFaction.isPeaceful()) { error = P.p.txt.parse("%s owns this land. Your faction is peaceful, so you cannot claim land from other factions.", currentFaction.getTag(this)); - } else if (currentFaction.isPeaceful()) { + } + else if (currentFaction.isPeaceful()) { error = P.p.txt.parse("%s owns this land, and is a peaceful faction. You cannot claim land from them.", currentFaction.getTag(this)); - } else if (!currentFaction.hasLandInflation()) { + } + else if (!currentFaction.hasLandInflation()) { // TODO more messages WARN current faction most importantly error = P.p.txt.parse("%s owns this land and is strong enough to keep it.", currentFaction.getTag(this)); - } else if (!Board.isBorderLocation(flocation)) { + } + else if (!Board.isBorderLocation(flocation)) { error = P.p.txt.parse("You must start claiming land at the border of the territory."); } } @@ -707,7 +728,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { int ownedLand = forFaction.getLandRounded(); - if (!this.canClaimForFactionAtLocation(forFaction, location, notifyFailure)) return false; + if (!this.canClaimForFactionAtLocation(forFaction, location, notifyFailure)) { return false; } // if economy is enabled and they're not on the bypass list, make sure they can pay boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone(); @@ -716,23 +737,24 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { if (mustPay) { cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal()); - if (Conf.econClaimUnconnectedFee != 0.0 && forFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.isConnectedLocation(flocation, forFaction)) + if (Conf.econClaimUnconnectedFee != 0.0 && forFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.isConnectedLocation(flocation, forFaction)) { cost += Conf.econClaimUnconnectedFee; + } - if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts && this.hasFaction()) - payee = this.getFaction(); - else - payee = this; + if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts && this.hasFaction()) { payee = this.getFaction(); } + else { payee = this; } - if (!Econ.hasAtLeast(payee, cost, "to claim this land")) return false; + if (!Econ.hasAtLeast(payee, cost, "to claim this land")) { return false; } } LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this); Bukkit.getServer().getPluginManager().callEvent(claimEvent); - if (claimEvent.isCancelled()) return false; + if (claimEvent.isCancelled()) { return false; } // then make 'em pay (if applicable) - if (mustPay && !Econ.modifyMoney(payee, -cost, "to claim this land", "for claiming this land")) return false; + if (mustPay && !Econ.modifyMoney(payee, -cost, "to claim this land", "for claiming this land")) { + return false; + } // announce success Set informTheseFPlayers = new HashSet(); @@ -744,8 +766,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { Board.setFactionAt(forFaction, flocation); - if (Conf.logLandClaims) + if (Conf.logLandClaims) { P.p.log(this.getName() + " claimed land at (" + flocation.getCoordString() + ") for the faction: " + forFaction.getTag()); + } return true; } @@ -756,8 +779,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { @Override public boolean shouldBeSaved() { - if (!this.hasFaction() && (this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))) + if (!this.hasFaction() && (this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))) { return false; + } return !this.deleteMe; } diff --git a/src/main/java/com/massivecraft/factions/Faction.java b/src/main/java/com/massivecraft/factions/Faction.java index 16b32016..5f1fb0fc 100644 --- a/src/main/java/com/massivecraft/factions/Faction.java +++ b/src/main/java/com/massivecraft/factions/Faction.java @@ -165,8 +165,9 @@ public class Faction extends Entity implements EconomyParticipator { } public void confirmValidHome() { - if (!Conf.homesMustBeInClaimedTerritory || this.home == null || (this.home.getLocation() != null && Board.getFactionAt(new FLocation(this.home.getLocation())) == this)) + if (!Conf.homesMustBeInClaimedTerritory || this.home == null || (this.home.getLocation() != null && Board.getFactionAt(new FLocation(this.home.getLocation())) == this)) { return; + } msg("Your faction home has been un-set since it is no longer in your territory."); this.home = null; @@ -183,8 +184,7 @@ public class Faction extends Entity implements EconomyParticipator { String aid = "faction-" + this.getId(); // We need to override the default money given to players. - if (!Econ.hasAccount(aid)) - Econ.setBalance(aid, 0); + if (!Econ.hasAccount(aid)) { Econ.setBalance(aid, 0); } return aid; } @@ -312,7 +312,8 @@ public class Faction extends Entity implements EconomyParticipator { public void setRelationWish(Faction otherFaction, Relation relation) { if (this.relationWish.containsKey(otherFaction.getId()) && relation.equals(Relation.NEUTRAL)) { this.relationWish.remove(otherFaction.getId()); - } else { + } + else { this.relationWish.put(otherFaction.getId(), relation); } } @@ -377,7 +378,7 @@ public class Faction extends Entity implements EconomyParticipator { // maintain the reference list of FPlayers in this faction public void refreshFPlayers() { fplayers.clear(); - if (this.isPlayerFreeType()) return; + if (this.isPlayerFreeType()) { return; } for (FPlayer fplayer : FPlayers.i.get()) { if (fplayer.getFaction() == this) { @@ -387,13 +388,13 @@ public class Faction extends Entity implements EconomyParticipator { } protected boolean addFPlayer(FPlayer fplayer) { - if (this.isPlayerFreeType()) return false; + if (this.isPlayerFreeType()) { return false; } return fplayers.add(fplayer); } protected boolean removeFPlayer(FPlayer fplayer) { - if (this.isPlayerFreeType()) return false; + if (this.isPlayerFreeType()) { return false; } return fplayers.remove(fplayer); } @@ -417,7 +418,7 @@ public class Faction extends Entity implements EconomyParticipator { } public FPlayer getFPlayerAdmin() { - if (!this.isNormal()) return null; + if (!this.isNormal()) { return null; } for (FPlayer fplayer : fplayers) { if (fplayer.getRole() == Role.ADMIN) { @@ -429,7 +430,7 @@ public class Faction extends Entity implements EconomyParticipator { public ArrayList getFPlayersWhereRole(Role role) { ArrayList ret = new ArrayList(); - if (!this.isNormal()) return ret; + if (!this.isNormal()) { return ret; } for (FPlayer fplayer : fplayers) { if (fplayer.getRole() == role) { @@ -442,7 +443,7 @@ public class Faction extends Entity implements EconomyParticipator { public ArrayList getOnlinePlayers() { ArrayList ret = new ArrayList(); - if (this.isPlayerFreeType()) return ret; + if (this.isPlayerFreeType()) { return ret; } for (Player player : P.p.getServer().getOnlinePlayers()) { FPlayer fplayer = FPlayers.i.get(player); @@ -457,7 +458,7 @@ public class Faction extends Entity implements EconomyParticipator { // slightly faster check than getOnlinePlayers() if you just want to see if there are any players online public boolean hasPlayersOnline() { // only real factions can have players online, not safe zone / war zone - if (this.isPlayerFreeType()) return false; + if (this.isPlayerFreeType()) { return false; } for (Player player : P.p.getServer().getOnlinePlayers()) { FPlayer fplayer = FPlayers.i.get(player); @@ -481,35 +482,34 @@ public class Faction extends Entity implements EconomyParticipator { // used when current leader is about to be removed from the faction; promotes new leader, or disbands faction if no other members left public void promoteNewLeader() { - if (!this.isNormal()) return; - if (this.isPermanent() && Conf.permanentFactionsDisableLeaderPromotion) return; + if (!this.isNormal()) { return; } + if (this.isPermanent() && Conf.permanentFactionsDisableLeaderPromotion) { return; } FPlayer oldLeader = this.getFPlayerAdmin(); // get list of moderators, or list of normal members if there are no moderators ArrayList replacements = this.getFPlayersWhereRole(Role.MODERATOR); - if (replacements == null || replacements.isEmpty()) - replacements = this.getFPlayersWhereRole(Role.NORMAL); + if (replacements == null || replacements.isEmpty()) { replacements = this.getFPlayersWhereRole(Role.NORMAL); } if (replacements == null || replacements.isEmpty()) { // faction admin is the only member; one-man faction if (this.isPermanent()) { - if (oldLeader != null) - oldLeader.setRole(Role.NORMAL); + if (oldLeader != null) { oldLeader.setRole(Role.NORMAL); } return; } // no members left and faction isn't permanent, so disband it - if (Conf.logFactionDisband) + if (Conf.logFactionDisband) { P.p.log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left."); + } for (FPlayer fplayer : FPlayers.i.getOnline()) { fplayer.msg("The faction %s was disbanded.", this.getTag(fplayer)); } this.detach(); - } else { // promote new faction admin - if (oldLeader != null) - oldLeader.setRole(Role.NORMAL); + } + else { // promote new faction admin + if (oldLeader != null) { oldLeader.setRole(Role.NORMAL); } replacements.get(0).setRole(Role.ADMIN); this.msg("Faction admin %s has been removed. %s has been promoted as the new faction admin.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName()); P.p.log("Faction " + this.getTag() + " (" + this.getId() + ") admin was removed. Replacement admin: " + replacements.get(0).getName()); @@ -566,7 +566,7 @@ public class Faction extends Entity implements EconomyParticipator { for (Entry> entry : claimOwnership.entrySet()) { ownerData = entry.getValue(); - if (ownerData == null) continue; + if (ownerData == null) { continue; } Iterator iter = ownerData.iterator(); while (iter.hasNext()) { @@ -653,21 +653,19 @@ public class Faction extends Entity implements EconomyParticipator { public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) { // in own faction, with sufficient role or permission to bypass ownership? if (fplayer.getFaction() == this - && (fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.ADMIN) - || Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer()))) { + && (fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.ADMIN) + || Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer()))) { return true; } // make sure claimOwnership is initialized - if (claimOwnership.isEmpty()) - return true; + if (claimOwnership.isEmpty()) { return true; } // need to check the ownership list, then Set ownerData = claimOwnership.get(loc); // if no owner list, owner list is empty, or player is in owner list, they're allowed - if (ownerData == null || ownerData.isEmpty() || ownerData.contains(fplayer.getId())) - return true; + if (ownerData == null || ownerData.isEmpty() || ownerData.contains(fplayer.getId())) { return true; } return false; } diff --git a/src/main/java/com/massivecraft/factions/Factions.java b/src/main/java/com/massivecraft/factions/Factions.java index 30e42003..fe6e2abf 100644 --- a/src/main/java/com/massivecraft/factions/Factions.java +++ b/src/main/java/com/massivecraft/factions/Factions.java @@ -33,14 +33,15 @@ public class Factions extends EntityCollection { @Override public boolean loadFromDisc() { - if (!super.loadFromDisc()) return false; + if (!super.loadFromDisc()) { return false; } // Make sure the default neutral faction exists if (!this.exists("0")) { Faction faction = this.create("0"); faction.setTag(TL.WILDERNESS.toString()); faction.setDescription(TL.WILDERNESS_DESCRIPTION.toString()); - } else { + } + else { if (!this.get("0").getTag().equalsIgnoreCase(TL.WILDERNESS.toString())) { get("0").setTag(TL.WILDERNESS.toString()); } @@ -54,17 +55,17 @@ public class Factions extends EntityCollection { Faction faction = this.create("-1"); faction.setTag(TL.SAFEZONE.toString()); faction.setDescription(TL.SAFEZONE_DESCRIPTION.toString()); - } else { + } + else { if (!getSafeZone().getTag().equalsIgnoreCase(TL.SAFEZONE.toString())) { getSafeZone().setTag(TL.SAFEZONE.toString()); } - if(!getSafeZone().getDescription().equalsIgnoreCase(TL.SAFEZONE_DESCRIPTION.toString())) { + if (!getSafeZone().getDescription().equalsIgnoreCase(TL.SAFEZONE_DESCRIPTION.toString())) { getSafeZone().setDescription(TL.SAFEZONE_DESCRIPTION.toString()); } // if SafeZone has old pre-1.6.0 name, rename it to remove troublesome " " Faction faction = this.getSafeZone(); - if (faction.getTag().contains(" ")) - faction.setTag(TL.SAFEZONE.toString()); + if (faction.getTag().contains(" ")) { faction.setTag(TL.SAFEZONE.toString()); } } // Make sure the war zone faction exists @@ -72,17 +73,17 @@ public class Factions extends EntityCollection { Faction faction = this.create("-2"); faction.setTag(TL.WARZONE.toString()); faction.setDescription(TL.WARZONE_DESCRIPTION.toString()); - } else { + } + else { if (!getWarZone().getTag().equalsIgnoreCase(TL.WARZONE.toString())) { getWarZone().setTag(TL.WARZONE.toString()); } - if(!getWarZone().getDescription().equalsIgnoreCase(TL.WARZONE_DESCRIPTION.toString())) { + if (!getWarZone().getDescription().equalsIgnoreCase(TL.WARZONE_DESCRIPTION.toString())) { getWarZone().setDescription(TL.WARZONE_DESCRIPTION.toString()); } // if WarZone has old pre-1.6.0 name, rename it to remove troublesome " " Faction faction = this.getWarZone(); - if (faction.getTag().contains(" ")) - faction.setTag(TL.WARZONE.toString()); + if (faction.getTag().contains(" ")) { faction.setTag(TL.WARZONE.toString()); } } // populate all faction player lists @@ -166,7 +167,7 @@ public class Factions extends EntityCollection { } String tag = TextUtil.getBestStartWithCI(tag2faction.keySet(), searchFor); - if (tag == null) return null; + if (tag == null) { return null; } return tag2faction.get(tag); } diff --git a/src/main/java/com/massivecraft/factions/P.java b/src/main/java/com/massivecraft/factions/P.java index 7af83e38..92035d8b 100644 --- a/src/main/java/com/massivecraft/factions/P.java +++ b/src/main/java/com/massivecraft/factions/P.java @@ -79,7 +79,7 @@ public class P extends MPlugin { return; } - if (!preEnable()) return; + if (!preEnable()) { return; } this.loadSuccessful = false; // Load Conf from disk @@ -123,11 +123,11 @@ public class P extends MPlugin { }.getType(); return new GsonBuilder() - .setPrettyPrinting() - .disableHtmlEscaping() - .excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE) - .registerTypeAdapter(LazyLocation.class, new MyLocationTypeAdapter()) - .registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter()); + .setPrettyPrinting() + .disableHtmlEscaping() + .excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE) + .registerTypeAdapter(LazyLocation.class, new MyLocationTypeAdapter()) + .registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter()); } @Override @@ -146,7 +146,7 @@ public class P extends MPlugin { public void startAutoLeaveTask(boolean restartIfRunning) { if (AutoLeaveTask != null) { - if (!restartIfRunning) return; + if (!restartIfRunning) { return; } this.getServer().getScheduler().cancelTask(AutoLeaveTask); } @@ -169,8 +169,9 @@ public class P extends MPlugin { @Override public boolean handleCommand(CommandSender sender, String commandString, boolean testOnly) { - if (sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player) sender)) + if (sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player) sender)) { return true; + } return super.handleCommand(sender, commandString, testOnly); } @@ -178,7 +179,7 @@ public class P extends MPlugin { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] split) { // if bare command at this point, it has already been handled by MPlugin's command listeners - if (split == null || split.length == 0) return true; + if (split == null || split.length == 0) { return true; } // otherwise, needs to be handled; presumably another plugin directly ran the command String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0); @@ -204,17 +205,17 @@ public class P extends MPlugin { // enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand() public boolean shouldLetFactionsHandleThisChat(AsyncPlayerChatEvent event) { - if (event == null) return false; + if (event == null) { return false; } return (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage())); } // Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels, // local chat, or anything else which targets individual recipients, so Faction Chat can be done public boolean isPlayerFactionChatting(Player player) { - if (player == null) return false; + if (player == null) { return false; } FPlayer me = FPlayers.i.get(player); - if (me == null) return false; + if (me == null) { return false; } return me.getChatMode().isAtLeast(ChatMode.ALLIANCE); } @@ -223,7 +224,7 @@ public class P extends MPlugin { // TODO: GET THIS BACK AND WORKING public boolean isFactionsCommand(String check) { - if (check == null || check.isEmpty()) return false; + if (check == null || check.isEmpty()) { return false; } return this.handleCommand(null, check, true); } @@ -236,37 +237,32 @@ public class P extends MPlugin { public String getPlayerFactionTagRelation(Player speaker, Player listener) { String tag = "~"; - if (speaker == null) - return tag; + if (speaker == null) { return tag; } FPlayer me = FPlayers.i.get(speaker); - if (me == null) - return tag; + if (me == null) { return tag; } // if listener isn't set, or config option is disabled, give back uncolored tag if (listener == null || !Conf.chatTagRelationColored) { tag = me.getChatTag().trim(); - } else { - FPlayer you = FPlayers.i.get(listener); - if (you == null) - tag = me.getChatTag().trim(); - else // everything checks out, give the colored tag - tag = me.getChatTag(you).trim(); } - if (tag.isEmpty()) - tag = "~"; + else { + FPlayer you = FPlayers.i.get(listener); + if (you == null) { tag = me.getChatTag().trim(); } + else // everything checks out, give the colored tag + { tag = me.getChatTag(you).trim(); } + } + if (tag.isEmpty()) { tag = "~"; } return tag; } // Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat public String getPlayerTitle(Player player) { - if (player == null) - return ""; + if (player == null) { return ""; } FPlayer me = FPlayers.i.get(player); - if (me == null) - return ""; + if (me == null) { return ""; } return me.getTitle().trim(); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java b/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java index d184a6fa..c329fefc 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java @@ -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("You have promoted %s to the position of faction admin.", fyou.describeTo(fme, true)); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdAutoClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdAutoClaim.java index e192d83f..559c7e51 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdAutoClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdAutoClaim.java @@ -31,10 +31,8 @@ public class CmdAutoClaim extends FCommand { } if (!fme.canClaimForFaction(forFaction)) { - if (myFaction == forFaction) - msg("You must be %s to claim land.", Role.MODERATOR.toString()); - else - msg("You can't claim land for %s.", forFaction.describeTo(fme)); + if (myFaction == forFaction) { msg("You must be %s to claim land.", Role.MODERATOR.toString()); } + else { msg("You can't claim land for %s.", forFaction.describeTo(fme)); } return; } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java b/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java index 16be3fc2..465cfd6c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java @@ -20,7 +20,7 @@ public class CmdAutoHelp extends MCommand

{ @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 lines = new ArrayList(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBoom.java b/src/main/java/com/massivecraft/factions/cmd/CmdBoom.java index 60cdd571..8ef31d7a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdBoom.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBoom.java @@ -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())); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBypass.java b/src/main/java/com/massivecraft/factions/cmd/CmdBypass.java index 1955501f..2ffba0aa 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdBypass.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBypass.java @@ -28,7 +28,8 @@ public class CmdBypass extends FCommand { if (fme.isAdminBypassing()) { fme.msg("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("You have disabled admin bypass mode."); P.p.log(fme.getName() + " DISABLED admin bypass mode."); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java index 637d21b4..66004141 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java @@ -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("Unrecognised chat mode. Please enter either 'a','f' or 'p'"); return; } @@ -51,9 +54,11 @@ public class CmdChat extends FCommand { if (fme.getChatMode() == ChatMode.PUBLIC) { msg("Public chat mode."); - } else if (fme.getChatMode() == ChatMode.ALLIANCE) { + } + else if (fme.getChatMode() == ChatMode.ALLIANCE) { msg("Alliance only chat mode."); - } else { + } + else { msg("Faction only chat mode."); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdChatSpy.java b/src/main/java/com/massivecraft/factions/cmd/CmdChatSpy.java index 2c1f8dc8..f1b9ae16 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdChatSpy.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdChatSpy.java @@ -26,7 +26,8 @@ public class CmdChatSpy extends FCommand { if (fme.isSpyingChat()) { fme.msg("You have enabled chat spying mode."); P.p.log(fme.getName() + " has ENABLED chat spying mode."); - } else { + } + else { fme.msg("You have disabled chat spying mode."); P.p.log(fme.getName() + " DISABLED chat spying mode."); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java index 14112681..33bcfc50 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java @@ -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("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; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java b/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java index 410f360f..ceb0478a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java @@ -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(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java b/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java index 6d65498a..c9649993 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java @@ -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("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); } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java index 2dc46d97..1dea77bc 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java @@ -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 is already a member of %s", you.getName(), myFaction.getTag()); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java b/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java index 8135f185..bdd815c1 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java @@ -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 diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java index 57f9b126..80937f0d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java @@ -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("%s disbanded your faction.", who); - } else { + } + else { fplayer.msg("%s 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 diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java b/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java index cccac5bb..8070b558 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java @@ -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); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java index b839641f..77c1524e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java @@ -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("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) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java index c4abccdd..0d2bcfc5 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java @@ -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 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); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java index 7ca01ce0..95d4e446 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java @@ -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("This faction requires invitation."); - if (samePlayer) - faction.msg("%s tried to join your faction.", fplayer.describeTo(faction, true)); + if (samePlayer) { faction.msg("%s 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("%s successfully joined %s.", fplayer.describeTo(fme, true), faction.getTag(fme)); - if (!samePlayer) + if (!samePlayer) { fplayer.msg("%s moved you into the faction %s.", fme.describeTo(fplayer, true), faction.getTag(fplayer)); + } faction.msg("%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()); + } } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java index bb7fc512..4360278f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java @@ -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("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 kicked %s from the faction! :O", fme.describeTo(yourFaction, true), you.describeTo(yourFaction, true)); you.msg("%s kicked you from %s! :O", fme.describeTo(you, true), yourFaction.describeTo(you)); @@ -77,11 +78,11 @@ public class CmdKick extends FCommand { fme.msg("You kicked %s from the faction %s!", 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(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdList.java b/src/main/java/com/massivecraft/factions/cmd/CmdList.java index 56b45f42..88b2544e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdList.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdList.java @@ -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 factionList = new ArrayList(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 %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()) ); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdLock.java b/src/main/java/com/massivecraft/factions/cmd/CmdLock.java index b015e823..e4e5dd9e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdLock.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdLock.java @@ -33,7 +33,8 @@ public class CmdLock extends FCommand { if (p.getLocked()) { msg("Factions is now locked"); - } else { + } + else { msg("Factions in now unlocked"); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMap.java b/src/main/java/com/massivecraft/factions/cmd/CmdMap.java index 76448efc..5cd32b5d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMap.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMap.java @@ -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("Map auto update ENABLED."); // And show the map once showMap(); - } else { + } + else { // Turn off fme.setMapAutoUpdating(false); msg("Map auto update 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(); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMod.java b/src/main/java/com/massivecraft/factions/cmd/CmdMod.java index 3185cbca..2db28ad9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMod.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMod.java @@ -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 is no longer moderator in your faction.", you.describeTo(targetFaction, true)); msg("You have removed moderator status from %s.", you.describeTo(fme, true)); - } else { + } + else { // Give you.setRole(Role.MODERATOR); targetFaction.msg("%s was promoted to moderator in your faction.", you.describeTo(targetFaction, true)); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyBalance.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyBalance.java index c12f09d2..97536911 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyBalance.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyBalance.java @@ -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); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyDeposit.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyDeposit.java index c5d48383..1d2964ea 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyDeposit.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyDeposit.java @@ -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)))); + } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java index 1bd147a7..91ccb32d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFf.java @@ -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)))); + } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java index cbe84701..55023248 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferFp.java @@ -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)))); + } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java index 704bb5b9..41155cec 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyTransferPf.java @@ -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)))); + } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java index daf7f21c..df5057fa 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdMoneyWithdraw.java @@ -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)))); + } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java b/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java index e052f371..a71254fe 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java @@ -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())); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java b/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java index 44133ccd..9223e955 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java @@ -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); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java b/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java index 301f7626..202351a7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java @@ -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)) + " has " + change + " your faction."); - } else { + } + else { fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + " has " + change + " the faction \"" + faction.getTag(fplayer) + "\"."); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPermanent.java b/src/main/java/com/massivecraft/factions/cmd/CmdPermanent.java index d341a619..3d0a2fa4 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPermanent.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPermanent.java @@ -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)) + " " + change + " your faction."); - } else { + } + else { fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + " " + change + " the faction \"" + faction.getTag(fplayer) + "\"."); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPermanentPower.java b/src/main/java/com/massivecraft/factions/cmd/CmdPermanentPower.java index 4d3543d2..dd95b4e3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPermanentPower.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPermanentPower.java @@ -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); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPower.java b/src/main/java/com/massivecraft/factions/cmd/CmdPower.java index 71af37fb..4ec19b42 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPower.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPower.java @@ -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 + ")"; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPowerBoost.java b/src/main/java/com/massivecraft/factions/cmd/CmdPowerBoost.java index d0a06d5d..a887690e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPowerBoost.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPowerBoost.java @@ -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("You must specify \"p\" or \"player\" to target a player or \"f\" or \"faction\" to target a faction."); msg("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("" + 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 + "."); + } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdReload.java b/src/main/java/com/massivecraft/factions/cmd/CmdReload.java index a6bca27e..422c91b6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdReload.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdReload.java @@ -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("Invalid file specified. Valid files: all, conf, board, factions, players"); return; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSafeunclaimall.java b/src/main/java/com/massivecraft/factions/cmd/CmdSafeunclaimall.java index 002b329f..9ab3eed3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSafeunclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSafeunclaimall.java @@ -31,8 +31,7 @@ public class CmdSafeunclaimall extends FCommand { Board.unclaimAll(Factions.i.getSafeZone().getId()); msg("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."); } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java b/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java index 2b9f889f..13768da2 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java @@ -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()); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java index 9fc7ccee..468cad6f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java @@ -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 admins = faction.getFPlayersWhereRole(Role.ADMIN); Collection mods = faction.getFPlayersWhereRole(Role.MODERATOR); @@ -87,22 +89,19 @@ public class CmdShow extends FCommand { String allyList = p.txt.parse("Allies: "); String enemyList = p.txt.parse("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("") + ", "; - 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("") + ", "; 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("") + ", "; if (follower.isOnlineAndVisibleTo(me)) { onlineList += listpart; - } else { + } + else { offlineList += listpart; } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTag.java b/src/main/java/com/massivecraft/factions/cmd/CmdTag.java index 7efd995c..ba10f671 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTag.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTag.java @@ -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); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java b/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java index c473dddc..7b63646c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java @@ -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); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java index 5ce263de..96aae58e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java @@ -34,20 +34,25 @@ public class CmdUnclaim extends FCommand { Board.removeAt(flocation); msg("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("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("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("This is a war zone. You lack permissions to unclaim."); } return; @@ -59,8 +64,9 @@ public class CmdUnclaim extends FCommand { otherFaction.msg("%s unclaimed some of your land.", fme.describeTo(otherFaction, true)); msg("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 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()); + } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaimall.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaimall.java index 0daf6a01..96ed5c16 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaimall.java @@ -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 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()); + } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdWarunclaimall.java b/src/main/java/com/massivecraft/factions/cmd/CmdWarunclaimall.java index a2153048..084bd2fc 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdWarunclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdWarunclaimall.java @@ -31,8 +31,7 @@ public class CmdWarunclaimall extends FCommand { Board.unclaimAll(Factions.i.getWarZone().getId()); msg("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."); } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/FCommand.java b/src/main/java/com/massivecraft/factions/cmd/FCommand.java index d34511b4..a914a798 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCommand.java @@ -42,7 +42,8 @@ public abstract class FCommand extends MCommand

{ 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

{ @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

{ // -------------------------------------------- // 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

{ } public boolean assertMinRole(Role role) { - if (me == null) return true; + if (me == null) { return true; } if (fme.getRole().value < role.value) { msg("You must be " + role + " to " + this.getHelpShort() + "."); @@ -240,13 +241,16 @@ public abstract class FCommand extends MCommand

{ if (you.getRole().equals(Role.ADMIN)) { i.sendMessage(p.txt.parse("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("Moderators can't control each other...")); } - } else { + } + else { i.sendMessage(p.txt.parse("You must be a faction moderator to do that.")); } @@ -255,21 +259,21 @@ public abstract class FCommand extends MCommand

{ // 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); } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java b/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java index 57031913..1ae9a7df 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java @@ -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("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); diff --git a/src/main/java/com/massivecraft/factions/integration/Econ.java b/src/main/java/com/massivecraft/factions/integration/Econ.java index 9d058c4b..0e1008e4 100644 --- a/src/main/java/com/massivecraft/factions/integration/Econ.java +++ b/src/main/java/com/massivecraft/factions/integration/Econ.java @@ -19,7 +19,7 @@ public class Econ { private static Economy econ = null; public static void setup() { - if (isSetup()) return; + if (isSetup()) { return; } String integrationFail = "Economy integration is " + (Conf.econEnabled ? "enabled, but" : "disabled, and") + " the plugin \"Vault\" "; @@ -37,8 +37,9 @@ public class Econ { P.p.log("Economy integration through Vault plugin successful."); - if (!Conf.econEnabled) + if (!Conf.econEnabled) { P.p.log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true"); + } P.p.cmdBase.cmdHelp.updateHelp(); @@ -55,11 +56,11 @@ public class Econ { public static void modifyUniverseMoney(double delta) { - if (!shouldBeUsed()) return; + if (!shouldBeUsed()) { return; } - if (Conf.econUniverseAccount == null) return; - if (Conf.econUniverseAccount.length() == 0) return; - if (!econ.hasAccount(Conf.econUniverseAccount)) return; + if (Conf.econUniverseAccount == null) { return; } + if (Conf.econUniverseAccount.length() == 0) { return; } + if (!econ.hasAccount(Conf.econUniverseAccount)) { return; } modifyBalance(Conf.econUniverseAccount, delta); } @@ -77,25 +78,26 @@ public class Econ { Faction fYou = RelationUtil.getFaction(you); // This is a system invoker. Accept it. - if (fI == null) return true; + if (fI == null) { return true; } // Bypassing players can do any kind of transaction - if (i instanceof FPlayer && ((FPlayer) i).isAdminBypassing()) return true; + if (i instanceof FPlayer && ((FPlayer) i).isAdminBypassing()) { return true; } // Players with the any withdraw can do. - if (i instanceof FPlayer && Permission.MONEY_WITHDRAW_ANY.has(((FPlayer) i).getPlayer())) return true; + if (i instanceof FPlayer && Permission.MONEY_WITHDRAW_ANY.has(((FPlayer) i).getPlayer())) { return true; } // You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again. - if (i == you) return true; + if (i == you) { return true; } // A faction can always transfer away the money of it's members and its own money... // This will however probably never happen as a faction does not have free will. // Ohh by the way... Yes it could. For daily rent to the faction. - if (i == fI && fI == fYou) return true; + if (i == fI && fI == fYou) { return true; } // Factions can be controlled by members that are moderators... or any member if any member can withdraw. - if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer) i).getRole().value >= Role.MODERATOR.value)) + if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer) i).getRole().value >= Role.MODERATOR.value)) { return true; + } // Otherwise you may not! ;,,; i.msg("%s lacks permission to control %s's money.", i.describeTo(i, true), you.describeTo(i)); @@ -107,7 +109,7 @@ public class Econ { } public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify) { - if (!shouldBeUsed()) return false; + if (!shouldBeUsed()) { return false; } // The amount must be positive. // If the amount is negative we must flip and multiply amount with -1. @@ -119,13 +121,14 @@ public class Econ { } // Check the rights - if (!canIControllYou(invoker, from)) return false; + if (!canIControllYou(invoker, from)) { return false; } // Is there enough money for the transaction to happen? if (!econ.has(from.getAccountId(), amount)) { // There was not enough money to pay - if (invoker != null && notify) + if (invoker != null && notify) { invoker.msg("%s can't afford to transfer %s to %s.", from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker)); + } return false; } @@ -136,17 +139,19 @@ public class Econ { if (erw.transactionSuccess()) { EconomyResponse erd = econ.depositPlayer(to.getAccountId(), amount); if (erd.transactionSuccess()) { - if (notify) sendTransferInfo(invoker, from, to, amount); + if (notify) { sendTransferInfo(invoker, from, to, amount); } return true; - } else { + } + else { // transaction failed, refund account econ.depositPlayer(from.getAccountId(), amount); } } // if we get here something with the transaction failed - if (notify) + if (notify) { invoker.msg("Unable to transfer %s to %s from %s.", moneyString(amount), to.describeTo(invoker), from.describeTo(invoker, true)); + } return false; } @@ -156,9 +161,11 @@ public class Econ { if (ep == null) { // Add nothing - } else if (ep instanceof FPlayer) { + } + else if (ep instanceof FPlayer) { fplayers.add((FPlayer) ep); - } else if (ep instanceof Faction) { + } + else if (ep instanceof Faction) { fplayers.addAll(((Faction) ep).getFPlayers()); } @@ -175,15 +182,18 @@ public class Econ { for (FPlayer recipient : recipients) { recipient.msg("%s was transfered from %s to %s.", moneyString(amount), from.describeTo(recipient), to.describeTo(recipient)); } - } else if (invoker == from) { + } + else if (invoker == from) { for (FPlayer recipient : recipients) { recipient.msg("%s gave %s to %s.", from.describeTo(recipient, true), moneyString(amount), to.describeTo(recipient)); } - } else if (invoker == to) { + } + else if (invoker == to) { for (FPlayer recipient : recipients) { recipient.msg("%s took %s from %s.", to.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient)); } - } else { + } + else { for (FPlayer recipient : recipients) { recipient.msg("%s transfered %s from %s to %s.", invoker.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient), to.describeTo(recipient)); } @@ -191,18 +201,19 @@ public class Econ { } public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) { - if (!shouldBeUsed()) return true; + if (!shouldBeUsed()) { return true; } if (!econ.has(ep.getAccountId(), delta)) { - if (toDoThis != null && !toDoThis.isEmpty()) + if (toDoThis != null && !toDoThis.isEmpty()) { ep.msg("%s can't afford %s %s.", ep.describeTo(ep, true), moneyString(delta), toDoThis); + } return false; } return true; } public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis) { - if (!shouldBeUsed()) return false; + if (!shouldBeUsed()) { return false; } String acc = ep.getAccountId(); String You = ep.describeTo(ep, true); @@ -219,29 +230,36 @@ public class Econ { EconomyResponse er = econ.depositPlayer(acc, delta); if (er.transactionSuccess()) { modifyUniverseMoney(-delta); - if (forDoingThis != null && !forDoingThis.isEmpty()) + if (forDoingThis != null && !forDoingThis.isEmpty()) { ep.msg("%s gained %s %s.", You, moneyString(delta), forDoingThis); + } return true; - } else { + } + else { // transfer to account failed - if (forDoingThis != null && !forDoingThis.isEmpty()) + if (forDoingThis != null && !forDoingThis.isEmpty()) { ep.msg("%s would have gained %s %s, but the deposit failed.", You, moneyString(delta), forDoingThis); + } return false; } - } else { + } + else { // The player should loose money // The player might not have enough. if (econ.has(acc, -delta) && econ.withdrawPlayer(acc, -delta).transactionSuccess()) { // There is enough money to pay modifyUniverseMoney(-delta); - if (forDoingThis != null && !forDoingThis.isEmpty()) + if (forDoingThis != null && !forDoingThis.isEmpty()) { ep.msg("%s lost %s %s.", You, moneyString(-delta), forDoingThis); + } return true; - } else { + } + else { // There was not enough money to pay - if (toDoThis != null && !toDoThis.isEmpty()) + if (toDoThis != null && !toDoThis.isEmpty()) { ep.msg("%s can't afford %s %s.", You, moneyString(-delta), toDoThis); + } return false; } } @@ -253,7 +271,7 @@ public class Econ { } public static void oldMoneyDoTransfer() { - if (!shouldBeUsed()) return; + if (!shouldBeUsed()) { return; } for (Faction faction : Factions.i.get()) { if (faction.money > 0) { @@ -271,8 +289,8 @@ public class Econ { // basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction return Conf.econCostClaimWilderness - + (Conf.econCostClaimWilderness * Conf.econClaimAdditionalMultiplier * ownedLand) - - (takingFromAnotherFaction ? Conf.econCostClaimFromFactionBonus : 0); + + (Conf.econCostClaimWilderness * Conf.econClaimAdditionalMultiplier * ownedLand) + - (takingFromAnotherFaction ? Conf.econCostClaimFromFactionBonus : 0); } // calculate refund amount for unclaiming land @@ -309,17 +327,13 @@ public class Econ { public static boolean setBalance(String account, double amount) { double current = econ.getBalance(account); - if (current > amount) - return econ.withdrawPlayer(account, current - amount).transactionSuccess(); - else - return econ.depositPlayer(account, amount - current).transactionSuccess(); + if (current > amount) { return econ.withdrawPlayer(account, current - amount).transactionSuccess(); } + else { return econ.depositPlayer(account, amount - current).transactionSuccess(); } } public static boolean modifyBalance(String account, double amount) { - if (amount < 0) - return econ.withdrawPlayer(account, -amount).transactionSuccess(); - else - return econ.depositPlayer(account, amount).transactionSuccess(); + if (amount < 0) { return econ.withdrawPlayer(account, -amount).transactionSuccess(); } + else { return econ.depositPlayer(account, amount).transactionSuccess(); } } public static boolean deposit(String account, double amount) { diff --git a/src/main/java/com/massivecraft/factions/integration/Essentials.java b/src/main/java/com/massivecraft/factions/integration/Essentials.java index b423d243..356d6121 100644 --- a/src/main/java/com/massivecraft/factions/integration/Essentials.java +++ b/src/main/java/com/massivecraft/factions/integration/Essentials.java @@ -23,7 +23,7 @@ public class Essentials { // return false if feature is disabled or Essentials isn't available public static boolean handleTeleport(Player player, Location loc) { - if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) return false; + if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) { return false; } Teleport teleport = (Teleport) essentials.getUser(player).getTeleport(); Trade trade = new Trade(Conf.econCostHome, essentials); diff --git a/src/main/java/com/massivecraft/factions/integration/Worldguard.java b/src/main/java/com/massivecraft/factions/integration/Worldguard.java index 1d8561ec..9e6ecd58 100644 --- a/src/main/java/com/massivecraft/factions/integration/Worldguard.java +++ b/src/main/java/com/massivecraft/factions/integration/Worldguard.java @@ -36,7 +36,8 @@ public class Worldguard { enabled = false; wg = null; P.p.log("Could not hook to WorldGuard. WorldGuard checks are disabled."); - } else { + } + else { wg = (WorldGuardPlugin) wgplug; enabled = true; P.p.log("Successfully hooked to WorldGuard."); @@ -79,8 +80,7 @@ public class Worldguard { World world = loc.getWorld(); Vector pt = toVector(loc); - if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0) - return wg.canBuild(player, loc); + if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0) { return wg.canBuild(player, loc); } return false; } @@ -117,7 +117,8 @@ public class Worldguard { overlaps = region.getIntersectingRegions(allregionslist); if (overlaps == null || overlaps.isEmpty()) { foundregions = false; - } else { + } + else { foundregions = true; } } catch (Exception e) { diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java index c09d5e05..f83f83ca 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -23,21 +23,22 @@ public class FactionsBlockListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void onBlockPlace(BlockPlaceEvent event) { - if (event.isCancelled()) return; - if (!event.canBuild()) return; + if (event.isCancelled()) { return; } + if (!event.canBuild()) { return; } // special case for flint&steel, which should only be prevented by DenyUsage list if (event.getBlockPlaced().getType() == Material.FIRE) { return; } - if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) + if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) { event.setCancelled(true); + } } @EventHandler(priority = EventPriority.NORMAL) public void onBlockBreak(BlockBreakEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) { event.setCancelled(true); @@ -46,7 +47,7 @@ public class FactionsBlockListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void onBlockDamage(BlockDamageEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } if (event.getInstaBreak() && !playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) { event.setCancelled(true); @@ -55,8 +56,8 @@ public class FactionsBlockListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void onBlockPistonExtend(BlockPistonExtendEvent event) { - if (event.isCancelled()) return; - if (!Conf.pistonProtectionThroughDenyBuild) return; + if (event.isCancelled()) { return; } + if (!Conf.pistonProtectionThroughDenyBuild) { return; } Faction pistonFaction = Board.getFactionAt(new FLocation(event.getBlock())); @@ -102,75 +103,69 @@ public class FactionsBlockListener implements Listener { Faction otherFaction = Board.getFactionAt(new FLocation(target)); - if (pistonFaction == otherFaction) - return true; + if (pistonFaction == otherFaction) { return true; } if (otherFaction.isNone()) { - if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName())) + if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName())) { return true; + } return false; - } else if (otherFaction.isSafeZone()) { - if (!Conf.safeZoneDenyBuild) - return true; + } + else if (otherFaction.isSafeZone()) { + if (!Conf.safeZoneDenyBuild) { return true; } return false; - } else if (otherFaction.isWarZone()) { - if (!Conf.warZoneDenyBuild) - return true; + } + else if (otherFaction.isWarZone()) { + if (!Conf.warZoneDenyBuild) { return true; } return false; } Relation rel = pistonFaction.getRelationTo(otherFaction); - if (rel.confDenyBuild(otherFaction.hasPlayersOnline())) - return false; + if (rel.confDenyBuild(otherFaction.hasPlayersOnline())) { return false; } return true; } public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) { String name = player.getName(); - if (Conf.playersWhoBypassAllProtection.contains(name)) return true; + if (Conf.playersWhoBypassAllProtection.contains(name)) { return true; } FPlayer me = FPlayers.i.get(player.getUniqueId().toString()); - if (me.isAdminBypassing()) return true; + if (me.isAdminBypassing()) { return true; } FLocation loc = new FLocation(location); Faction otherFaction = Board.getFactionAt(loc); if (otherFaction.isNone()) { - if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) - return true; + if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return true; } - if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) + if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) { return true; // This is not faction territory. Use whatever you like here. + } - if (!justCheck) - me.msg("You can't " + action + " in the wilderness."); + if (!justCheck) { me.msg("You can't " + action + " in the wilderness."); } return false; - } else if (otherFaction.isSafeZone()) { - if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) - return true; + } + else if (otherFaction.isSafeZone()) { + if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return true; } - if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) - return true; + if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) { return true; } - if (!justCheck) - me.msg("You can't " + action + " in a safe zone."); + if (!justCheck) { me.msg("You can't " + action + " in a safe zone."); } return false; - } else if (otherFaction.isWarZone()) { - if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) - return true; + } + else if (otherFaction.isWarZone()) { + if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return true; } - if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) - return true; + if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) { return true; } - if (!justCheck) - me.msg("You can't " + action + " in a war zone."); + if (!justCheck) { me.msg("You can't " + action + " in a war zone."); } return false; } @@ -185,14 +180,16 @@ public class FactionsBlockListener implements Listener { if (pain) { player.damage(Conf.actionDeniedPainAmount); - if (!deny) + if (!deny) { me.msg("It is painful to try to " + action + " in the territory of " + otherFaction.getTag(myFaction)); + } } // cancel building/destroying in other territory? if (deny) { - if (!justCheck) + if (!justCheck) { me.msg("You can't " + action + " in the territory of " + otherFaction.getTag(myFaction)); + } return false; } @@ -202,12 +199,14 @@ public class FactionsBlockListener implements Listener { if (!pain && Conf.ownedAreaPainBuild && !justCheck) { player.damage(Conf.actionDeniedPainAmount); - if (!Conf.ownedAreaDenyBuild) + if (!Conf.ownedAreaDenyBuild) { me.msg("It is painful to try to " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc)); + } } if (Conf.ownedAreaDenyBuild) { - if (!justCheck) + if (!justCheck) { me.msg("You can't " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc)); + } return false; } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java index 8740dd9a..7ed0f19d 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java @@ -25,7 +25,7 @@ public class FactionsChatListener implements Listener { // this is for handling slashless command usage and faction/alliance chat, set at lowest priority so Factions gets to them first @EventHandler(priority = EventPriority.LOWEST) public void onPlayerEarlyChat(PlayerChatEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } Player talkingPlayer = event.getPlayer(); String msg = event.getMessage(); @@ -34,8 +34,9 @@ public class FactionsChatListener implements Listener { // slashless factions commands need to be handled here if the user isn't in public chat mode if (chat != ChatMode.PUBLIC && p.handleCommand(talkingPlayer, msg, false, true)) { - if (Conf.logPlayerCommands) + if (Conf.logPlayerCommands) { Bukkit.getLogger().log(Level.INFO, "[PLAYER_COMMAND] " + talkingPlayer.getName() + ": " + msg); + } event.setCancelled(true); return; } @@ -51,13 +52,15 @@ public class FactionsChatListener implements Listener { //Send to any players who are spying chat for (FPlayer fplayer : FPlayers.i.getOnline()) { - if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction) + if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction) { fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message); + } } event.setCancelled(true); return; - } else if (chat == ChatMode.ALLIANCE) { + } + else if (chat == ChatMode.ALLIANCE) { Faction myFaction = me.getFaction(); String message = String.format(Conf.allianceChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg); @@ -67,12 +70,10 @@ public class FactionsChatListener implements Listener { //Send to all our allies for (FPlayer fplayer : FPlayers.i.getOnline()) { - if (myFaction.getRelationTo(fplayer) == Relation.ALLY) - fplayer.sendMessage(message); + if (myFaction.getRelationTo(fplayer) == Relation.ALLY) { fplayer.sendMessage(message); } - //Send to any players who are spying chat - else if (fplayer.isSpyingChat()) - fplayer.sendMessage("[ACspy]: " + message); + //Send to any players who are spying chat + else if (fplayer.isSpyingChat()) { fplayer.sendMessage("[ACspy]: " + message); } } Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("AllianceChat: " + message)); @@ -85,11 +86,11 @@ public class FactionsChatListener implements Listener { // this is for handling insertion of the player's faction tag, set at highest priority to give other plugins a chance to modify chat first @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerChat(PlayerChatEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } // Are we to insert the Faction tag into the format? // If we are not to insert it - we are done. - if (!Conf.chatTagEnabled || Conf.chatTagHandledByAnotherPlugin) return; + if (!Conf.chatTagEnabled || Conf.chatTagHandledByAnotherPlugin) { return; } Player talkingPlayer = event.getPlayer(); String msg = event.getMessage(); @@ -107,17 +108,19 @@ public class FactionsChatListener implements Listener { eventFormat = eventFormat.replace(Conf.chatTagReplaceString, ""); Conf.chatTagPadAfter = false; Conf.chatTagPadBefore = false; - } else if (!Conf.chatTagInsertAfterString.isEmpty() && eventFormat.contains(Conf.chatTagInsertAfterString)) { + } + else if (!Conf.chatTagInsertAfterString.isEmpty() && eventFormat.contains(Conf.chatTagInsertAfterString)) { // we're using the "insert after string" method InsertIndex = eventFormat.indexOf(Conf.chatTagInsertAfterString) + Conf.chatTagInsertAfterString.length(); - } else if (!Conf.chatTagInsertBeforeString.isEmpty() && eventFormat.contains(Conf.chatTagInsertBeforeString)) { + } + else if (!Conf.chatTagInsertBeforeString.isEmpty() && eventFormat.contains(Conf.chatTagInsertBeforeString)) { // we're using the "insert before string" method InsertIndex = eventFormat.indexOf(Conf.chatTagInsertBeforeString); - } else { + } + else { // we'll fall back to using the index place method InsertIndex = Conf.chatTagInsertIndex; - if (InsertIndex > eventFormat.length()) - return; + if (InsertIndex > eventFormat.length()) { return; } } String formatStart = eventFormat.substring(0, InsertIndex) + ((Conf.chatTagPadBefore && !me.getChatTag().isEmpty()) ? " " : ""); @@ -148,7 +151,8 @@ public class FactionsChatListener implements Listener { // Write to the log... We will write the non colored message. String nonColoredMsg = ChatColor.stripColor(String.format(nonColoredMsgFormat, talkingPlayer.getDisplayName(), msg)); Bukkit.getLogger().log(Level.INFO, nonColoredMsg); - } else { + } + else { // No relation color. event.setFormat(nonColoredMsgFormat); } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java index afc12356..114b92aa 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -54,16 +54,20 @@ public class FactionsEntityListener implements Listener { if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) { powerLossEvent.setMessage("The world you are in has power loss normally disabled, but you still lost power since you were in a war zone.\nYour power is now %d / %d"); } - } else if (faction.isNone() && !Conf.wildernessPowerLoss && !Conf.worldsNoWildernessProtection.contains(player.getWorld().getName())) { + } + else if (faction.isNone() && !Conf.wildernessPowerLoss && !Conf.worldsNoWildernessProtection.contains(player.getWorld().getName())) { powerLossEvent.setMessage("You didn't lose any power since you were in the wilderness."); powerLossEvent.setCancelled(true); - } else if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) { + } + else if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) { powerLossEvent.setMessage("You didn't lose any power due to the world you died in."); powerLossEvent.setCancelled(true); - } else if (Conf.peacefulMembersDisablePowerLoss && fplayer.hasFaction() && fplayer.getFaction().isPeaceful()) { + } + else if (Conf.peacefulMembersDisablePowerLoss && fplayer.hasFaction() && fplayer.getFaction().isPeaceful()) { powerLossEvent.setMessage("You didn't lose any power since you are in a peaceful faction."); powerLossEvent.setCancelled(true); - } else { + } + else { powerLossEvent.setMessage("Your power is now %d / %d"); } @@ -87,14 +91,15 @@ public class FactionsEntityListener implements Listener { */ @EventHandler(priority = EventPriority.NORMAL) public void onEntityDamage(EntityDamageEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } if (event instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event; if (!this.canDamagerHurtDamagee(sub, true)) { event.setCancelled(true); } - } else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) { + } + else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) { // Players can not take any damage in a Safe Zone event.setCancelled(true); } @@ -102,7 +107,7 @@ public class FactionsEntityListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void onEntityExplode(EntityExplodeEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } Location loc = event.getLocation(); Entity boomer = event.getEntity(); @@ -133,40 +138,43 @@ public class FactionsEntityListener implements Listener { ) { // creeper which needs prevention event.setCancelled(true); - } else if - ( + } + else if + ( // it's a bit crude just using fireball protection for Wither boss too, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever - (boomer instanceof Fireball || boomer instanceof WitherSkull || boomer instanceof Wither) - && - ( - (faction.isNone() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) - || - (faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) - || - (faction.isWarZone() && Conf.warZoneBlockFireballs) - || - faction.isSafeZone() - ) - ) { + (boomer instanceof Fireball || boomer instanceof WitherSkull || boomer instanceof Wither) + && + ( + (faction.isNone() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) + || + (faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) + || + (faction.isWarZone() && Conf.warZoneBlockFireballs) + || + faction.isSafeZone() + ) + ) { // ghast fireball which needs prevention event.setCancelled(true); - } else if - ( - (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) - && - ( - (faction.isNone() && Conf.wildernessBlockTNT && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) - || - (faction.isNormal() && (online ? Conf.territoryBlockTNT : Conf.territoryBlockTNTWhenOffline)) - || - (faction.isWarZone() && Conf.warZoneBlockTNT) - || - (faction.isSafeZone() && Conf.safeZoneBlockTNT) - ) - ) { + } + else if + ( + (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) + && + ( + (faction.isNone() && Conf.wildernessBlockTNT && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) + || + (faction.isNormal() && (online ? Conf.territoryBlockTNT : Conf.territoryBlockTNTWhenOffline)) + || + (faction.isWarZone() && Conf.warZoneBlockTNT) + || + (faction.isSafeZone() && Conf.safeZoneBlockTNT) + ) + ) { // TNT which needs prevention event.setCancelled(true); - } else if ((boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) { + } + else if ((boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) { // TNT in water/lava doesn't normally destroy any surrounding blocks, which is usually desired behavior, but... // this change below provides workaround for waterwalling providing perfect protection, // and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots @@ -183,8 +191,9 @@ public class FactionsEntityListener implements Listener { for (Block target : targets) { int id = target.getTypeId(); // ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet - if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) + if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) { target.breakNaturally(); + } } } } @@ -193,23 +202,22 @@ public class FactionsEntityListener implements Listener { // mainly for flaming arrows; don't want allies or people in safe zones to be ignited even after damage event is cancelled @EventHandler(priority = EventPriority.NORMAL) public void onEntityCombustByEntity(EntityCombustByEntityEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0); - if (!this.canDamagerHurtDamagee(sub, false)) - event.setCancelled(true); + if (!this.canDamagerHurtDamagee(sub, false)) { event.setCancelled(true); } sub = null; } private static final Set badPotionEffects = new LinkedHashSet(Arrays.asList( - PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, - PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, - PotionEffectType.WITHER + PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, + PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, + PotionEffectType.WITHER )); @EventHandler(priority = EventPriority.NORMAL) public void onPotionSplashEvent(PotionSplashEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } // see if the potion has a harmful effect boolean badjuju = false; @@ -219,7 +227,7 @@ public class FactionsEntityListener implements Listener { break; } } - if (!badjuju) return; + if (!badjuju) { return; } ProjectileSource thrower = event.getPotion().getShooter(); if (!(thrower instanceof Entity)) { @@ -231,8 +239,9 @@ public class FactionsEntityListener implements Listener { while (iter.hasNext()) { LivingEntity target = iter.next(); EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent((Entity) thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0); - if (!this.canDamagerHurtDamagee(sub, true)) + if (!this.canDamagerHurtDamagee(sub, true)) { event.setIntensity(target, 0.0); // affected entity list doesn't accept modification (so no iter.remove()), but this works + } sub = null; } } @@ -256,13 +265,11 @@ public class FactionsEntityListener implements Listener { Entity damagee = sub.getEntity(); double damage = sub.getDamage(); - if (!(damagee instanceof Player)) - return true; + if (!(damagee instanceof Player)) { return true; } FPlayer defender = FPlayers.i.get((Player) damagee); - if (defender == null || defender.getPlayer() == null) - return true; + if (defender == null || defender.getPlayer() == null) { return true; } Location defenderLoc = defender.getPlayer().getLocation(); Faction defLocFaction = Board.getFactionAt(new FLocation(defenderLoc)); @@ -273,7 +280,7 @@ public class FactionsEntityListener implements Listener { } if (damager == damagee) // ender pearl usage and other self-inflicted damage - return true; + { return true; } // Players can not take attack damage in a SafeZone, or possibly peaceful territory if (defLocFaction.noPvPInTerritory()) { @@ -287,19 +294,18 @@ public class FactionsEntityListener implements Listener { return !defLocFaction.noMonstersInTerritory(); } - if (!(damager instanceof Player)) - return true; + if (!(damager instanceof Player)) { return true; } FPlayer attacker = FPlayers.i.get((Player) damager); - if (attacker == null || attacker.getPlayer() == null) - return true; + if (attacker == null || attacker.getPlayer() == null) { return true; } - if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) return true; + if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) { return true; } if (attacker.hasLoginPvpDisabled()) { - if (notify) + if (notify) { attacker.msg("You can't hurt other players for " + Conf.noPVPDamageToOthersForXSecondsAfterLogin + " seconds after logging in."); + } return false; } @@ -307,38 +313,40 @@ public class FactionsEntityListener implements Listener { // so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be? if (locFaction.noPvPInTerritory()) { - if (notify) + if (notify) { attacker.msg("You can't hurt other players while you are in " + (locFaction.isSafeZone() ? "a SafeZone." : "peaceful territory.")); + } return false; } - if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) - return true; + if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) { return true; } - if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) - return true; + if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) { return true; } Faction defendFaction = defender.getFaction(); Faction attackFaction = attacker.getFaction(); if (attackFaction.isNone() && Conf.disablePVPForFactionlessPlayers) { - if (notify) attacker.msg("You can't hurt other players until you join a faction."); + if (notify) { attacker.msg("You can't hurt other players until you join a faction."); } return false; - } else if (defendFaction.isNone()) { + } + else if (defendFaction.isNone()) { if (defLocFaction == attackFaction && Conf.enablePVPAgainstFactionlessInAttackersLand) { // Allow PVP vs. Factionless in attacker's faction territory return true; - } else if (Conf.disablePVPForFactionlessPlayers) { - if (notify) attacker.msg("You can't hurt players who are not currently in a faction."); + } + else if (Conf.disablePVPForFactionlessPlayers) { + if (notify) { attacker.msg("You can't hurt players who are not currently in a faction."); } return false; } } if (defendFaction.isPeaceful()) { - if (notify) attacker.msg("You can't hurt players who are in a peaceful faction."); + if (notify) { attacker.msg("You can't hurt players who are in a peaceful faction."); } return false; - } else if (attackFaction.isPeaceful()) { - if (notify) attacker.msg("You can't hurt players while you are in a peaceful faction."); + } + else if (attackFaction.isPeaceful()) { + if (notify) { attacker.msg("You can't hurt players while you are in a peaceful faction."); } return false; } @@ -346,17 +354,16 @@ public class FactionsEntityListener implements Listener { // You can not hurt neutral factions if (Conf.disablePVPBetweenNeutralFactions && relation.isNeutral()) { - if (notify) attacker.msg("You can't hurt neutral factions. Declare them as an enemy."); + if (notify) { attacker.msg("You can't hurt neutral factions. Declare them as an enemy."); } return false; } // Players without faction may be hurt anywhere - if (!defender.hasFaction()) - return true; + if (!defender.hasFaction()) { return true; } // You can never hurt faction members or allies if (relation.isMember() || relation.isAlly()) { - if (notify) attacker.msg("You can't hurt %s.", defender.describeTo(attacker)); + if (notify) { attacker.msg("You can't hurt %s.", defender.describeTo(attacker)); } return false; } @@ -399,7 +406,7 @@ public class FactionsEntityListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void onEntityTarget(EntityTargetEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } // if there is a target Entity target = event.getTarget(); @@ -420,7 +427,7 @@ public class FactionsEntityListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void onPaintingBreak(HangingBreakEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } if (event.getCause() == RemoveCause.EXPLOSION) { Location loc = event.getEntity().getLocation(); Faction faction = Board.getFactionAt(new FLocation(loc)); @@ -444,8 +451,8 @@ public class FactionsEntityListener implements Listener { faction.isNormal() && (online - ? (Conf.territoryBlockCreepers || Conf.territoryBlockFireballs || Conf.territoryBlockTNT) - : (Conf.territoryBlockCreepersWhenOffline || Conf.territoryBlockFireballsWhenOffline || Conf.territoryBlockTNTWhenOffline) + ? (Conf.territoryBlockCreepers || Conf.territoryBlockFireballs || Conf.territoryBlockTNT) + : (Conf.territoryBlockCreepersWhenOffline || Conf.territoryBlockFireballsWhenOffline || Conf.territoryBlockTNTWhenOffline) ) ) || @@ -477,7 +484,7 @@ public class FactionsEntityListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void onPaintingPlace(HangingPlaceEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false)) { event.setCancelled(true); @@ -486,19 +493,19 @@ public class FactionsEntityListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void onEntityChangeBlock(EntityChangeBlockEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } Entity entity = event.getEntity(); // for now, only interested in Enderman and Wither boss tomfoolery - if (!(entity instanceof Enderman) && !(entity instanceof Wither)) return; + if (!(entity instanceof Enderman) && !(entity instanceof Wither)) { return; } Location loc = event.getBlock().getLocation(); if (entity instanceof Enderman) { - if (stopEndermanBlockManipulation(loc)) - event.setCancelled(true); - } else if (entity instanceof Wither) { + if (stopEndermanBlockManipulation(loc)) { event.setCancelled(true); } + } + else if (entity instanceof Wither) { Faction faction = Board.getFactionAt(new FLocation(loc)); // it's a bit crude just using fireball protection, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever if @@ -510,8 +517,7 @@ public class FactionsEntityListener implements Listener { (faction.isWarZone() && Conf.warZoneBlockFireballs) || faction.isSafeZone() - ) - event.setCancelled(true); + ) { event.setCancelled(true); } } } @@ -540,11 +546,14 @@ public class FactionsEntityListener implements Listener { if (claimFaction.isNone()) { return Conf.wildernessDenyEndermanBlocks; - } else if (claimFaction.isNormal()) { + } + else if (claimFaction.isNormal()) { return claimFaction.hasPlayersOnline() ? Conf.territoryDenyEndermanBlocks : Conf.territoryDenyEndermanBlocksWhenOffline; - } else if (claimFaction.isSafeZone()) { + } + else if (claimFaction.isSafeZone()) { return Conf.safeZoneDenyEndermanBlocks; - } else if (claimFaction.isWarZone()) { + } + else if (claimFaction.isWarZone()) { return Conf.warZoneDenyEndermanBlocks; } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java index 8f8da66c..a02e97b7 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java @@ -14,21 +14,20 @@ import org.bukkit.event.player.PlayerTeleportEvent; public class FactionsExploitListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void obsidianGenerator(BlockFromToEvent event) { - if (event.isCancelled() == true || !Conf.handleExploitObsidianGenerators) return; + if (event.isCancelled() == true || !Conf.handleExploitObsidianGenerators) { return; } // thanks to ObGenBlocker and WorldGuard for this method Block block = event.getToBlock(); int source = event.getBlock().getTypeId(); int target = block.getTypeId(); - if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11)) - block.setTypeId(0); + if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11)) { block.setTypeId(0); } } @EventHandler(priority = EventPriority.NORMAL) public void enderPearlTeleport(PlayerTeleportEvent event) { - if (event.isCancelled() == true || !Conf.handleExploitEnderPearlClipping) return; - if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) return; + if (event.isCancelled() == true || !Conf.handleExploitEnderPearlClipping) { return; } + if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) { return; } // this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar... Location target = event.getTo(); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index f43ee3e4..feed3d14 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -57,13 +57,12 @@ public class FactionsPlayerListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onPlayerMove(PlayerMoveEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } // quick check to make sure player is moving between chunks; good performance boost - if(event.getFrom().getBlockX() >> 4 == event.getTo().getBlockX() >> 4 - && event.getFrom().getBlockZ() >> 4 == event.getTo().getBlockZ() >> 4 - && event.getFrom().getWorld() == event.getTo().getWorld()) - return; + if (event.getFrom().getBlockX() >> 4 == event.getTo().getBlockX() >> 4 + && event.getFrom().getBlockZ() >> 4 == event.getTo().getBlockZ() >> 4 + && event.getFrom().getWorld() == event.getTo().getWorld()) { return; } Player player = event.getPlayer(); FPlayer me = FPlayers.i.get(player); @@ -92,41 +91,45 @@ public class FactionsPlayerListener implements Listener { if (me.isMapAutoUpdating()) { me.sendMessage(Board.getMap(me.getFaction(), to, player.getLocation().getYaw())); - } else { + } + else { Faction myFaction = me.getFaction(); String ownersTo = myFaction.getOwnerListString(to); if (changedFaction) { me.sendFactionHereMessage(); - if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder &&myFaction == factionTo && !ownersTo.isEmpty()) { + if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty()) { me.sendMessage(Conf.ownedLandMessage + ownersTo); } - } else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && factionFrom == factionTo &&myFaction == factionTo) { + } + else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && factionFrom == factionTo && myFaction == factionTo) { String ownersFrom = myFaction.getOwnerListString(from); if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo)) { - if (!ownersTo.isEmpty()) - me.sendMessage(Conf.ownedLandMessage + ownersTo); - else if (!Conf.publicLandMessage.isEmpty()) - me.sendMessage(Conf.publicLandMessage); + if (!ownersTo.isEmpty()) { me.sendMessage(Conf.ownedLandMessage + ownersTo); } + else if (!Conf.publicLandMessage.isEmpty()) { me.sendMessage(Conf.publicLandMessage); } } } } if (me.getAutoClaimFor() != null) { me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true); - } else if (me.isAutoSafeClaimEnabled()) { + } + else if (me.isAutoSafeClaimEnabled()) { if (!Permission.MANAGE_SAFE_ZONE.has(player)) { me.setIsAutoSafeClaimEnabled(false); - } else { + } + else { if (!Board.getFactionAt(to).isSafeZone()) { Board.setFactionAt(Factions.i.getSafeZone(), to); me.msg("This land is now a safe zone."); } } - } else if (me.isAutoWarClaimEnabled()) { + } + else if (me.isAutoWarClaimEnabled()) { if (!Permission.MANAGE_WAR_ZONE.has(player)) { me.setIsAutoWarClaimEnabled(false); - } else { + } + else { if (!Board.getFactionAt(to).isWarZone()) { Board.setFactionAt(Factions.i.getWarZone(), to); me.msg("This land is now a war zone."); @@ -137,14 +140,16 @@ public class FactionsPlayerListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void onPlayerInteract(PlayerInteractEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } // only need to check right-clicks and physical as of MC 1.4+; good performance boost - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) return; + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) { return; } Block block = event.getClickedBlock(); Player player = event.getPlayer(); - if (block == null) return; // clicked in air, apparently + if (block == null) { + return; // clicked in air, apparently + } if (!canPlayerUseBlock(player, block, false)) { event.setCancelled(true); @@ -165,7 +170,9 @@ public class FactionsPlayerListener implements Listener { return; } - if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; // only interested on right-clicks for below + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { + return; // only interested on right-clicks for below + } if (!playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) { event.setCancelled(true); @@ -184,10 +191,8 @@ public class FactionsPlayerListener implements Listener { // returns the current attempt count public int increment() { long Now = System.currentTimeMillis(); - if (Now > lastAttempt + 2000) - attempts = 1; - else - attempts++; + if (Now > lastAttempt + 2000) { attempts = 1; } + else { attempts++; } lastAttempt = Now; return attempts; } @@ -196,44 +201,47 @@ public class FactionsPlayerListener implements Listener { public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck) { String name = player.getName(); - if (Conf.playersWhoBypassAllProtection.contains(name)) return true; + if (Conf.playersWhoBypassAllProtection.contains(name)) { return true; } FPlayer me = FPlayers.i.get(player); - if (me.isAdminBypassing()) return true; + if (me.isAdminBypassing()) { return true; } FLocation loc = new FLocation(location); Faction otherFaction = Board.getFactionAt(loc); if (otherFaction.hasPlayersOnline()) { - if (!Conf.territoryDenyUseageMaterials.contains(material)) + if (!Conf.territoryDenyUseageMaterials.contains(material)) { return true; // Item isn't one we're preventing for online factions. - } else { - if (!Conf.territoryDenyUseageMaterialsWhenOffline.contains(material)) + } + } + else { + if (!Conf.territoryDenyUseageMaterialsWhenOffline.contains(material)) { return true; // Item isn't one we're preventing for offline factions. + } } if (otherFaction.isNone()) { - if (!Conf.wildernessDenyUseage || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) + if (!Conf.wildernessDenyUseage || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) { return true; // This is not faction territory. Use whatever you like here. + } - if (!justCheck) + if (!justCheck) { me.msg("You can't use %s in the wilderness.", TextUtil.getMaterialName(material)); + } return false; - } else if (otherFaction.isSafeZone()) { - if (!Conf.safeZoneDenyUseage || Permission.MANAGE_SAFE_ZONE.has(player)) - return true; + } + else if (otherFaction.isSafeZone()) { + if (!Conf.safeZoneDenyUseage || Permission.MANAGE_SAFE_ZONE.has(player)) { return true; } - if (!justCheck) - me.msg("You can't use %s in a safe zone.", TextUtil.getMaterialName(material)); + if (!justCheck) { me.msg("You can't use %s in a safe zone.", TextUtil.getMaterialName(material)); } return false; - } else if (otherFaction.isWarZone()) { - if (!Conf.warZoneDenyUseage || Permission.MANAGE_WAR_ZONE.has(player)) - return true; + } + else if (otherFaction.isWarZone()) { + if (!Conf.warZoneDenyUseage || Permission.MANAGE_WAR_ZONE.has(player)) { return true; } - if (!justCheck) - me.msg("You can't use %s in a war zone.", TextUtil.getMaterialName(material)); + if (!justCheck) { me.msg("You can't use %s in a war zone.", TextUtil.getMaterialName(material)); } return false; } @@ -243,16 +251,18 @@ public class FactionsPlayerListener implements Listener { // Cancel if we are not in our own territory if (rel.confDenyUseage()) { - if (!justCheck) + if (!justCheck) { me.msg("You can't use %s in the territory of %s.", TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); + } return false; } // Also cancel if player doesn't have ownership rights for this claim if (Conf.ownedAreasEnabled && Conf.ownedAreaDenyUseage && !otherFaction.playerHasOwnershipRights(me, loc)) { - if (!justCheck) + if (!justCheck) { me.msg("You can't use %s in this territory, it is owned by: %s.", TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc)); + } return false; } @@ -261,26 +271,24 @@ public class FactionsPlayerListener implements Listener { } public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) { - if (Conf.playersWhoBypassAllProtection.contains(player.getName())) return true; + if (Conf.playersWhoBypassAllProtection.contains(player.getName())) { return true; } FPlayer me = FPlayers.i.get(player); - if (me.isAdminBypassing()) return true; + if (me.isAdminBypassing()) { return true; } Material material = block.getType(); FLocation loc = new FLocation(block); Faction otherFaction = Board.getFactionAt(loc); // no door/chest/whatever protection in wilderness, war zones, or safe zones - if (!otherFaction.isNormal()) - return true; + if (!otherFaction.isNormal()) { return true; } // We only care about some material types. if (otherFaction.hasPlayersOnline()) { - if (!Conf.territoryProtectedMaterials.contains(material)) - return true; - } else { - if (!Conf.territoryProtectedMaterialsWhenOffline.contains(material)) - return true; + if (!Conf.territoryProtectedMaterials.contains(material)) { return true; } + } + else { + if (!Conf.territoryProtectedMaterialsWhenOffline.contains(material)) { return true; } } Faction myFaction = me.getFaction(); @@ -288,16 +296,18 @@ public class FactionsPlayerListener implements Listener { // You may use any block unless it is another faction's territory... if (rel.isNeutral() || (rel.isEnemy() && Conf.territoryEnemyProtectMaterials) || (rel.isAlly() && Conf.territoryAllyProtectMaterials)) { - if (!justCheck) + if (!justCheck) { me.msg("You can't %s %s in the territory of %s.", (material == Material.SOIL ? "trample" : "use"), TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); + } return false; } // Also cancel if player doesn't have ownership rights for this claim if (Conf.ownedAreasEnabled && Conf.ownedAreaProtectMaterials && !otherFaction.playerHasOwnershipRights(me, loc)) { - if (!justCheck) + if (!justCheck) { me.msg("You can't use %s in this territory, it is owned by: %s.", TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc)); + } return false; } @@ -334,7 +344,7 @@ public class FactionsPlayerListener implements Listener { // but these separate bucket events below always fire without fail @EventHandler(priority = EventPriority.NORMAL) public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } Block block = event.getBlockClicked(); Player player = event.getPlayer(); @@ -347,7 +357,7 @@ public class FactionsPlayerListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void onPlayerBucketFill(PlayerBucketFillEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } Block block = event.getBlockClicked(); Player player = event.getPlayer(); @@ -359,16 +369,16 @@ public class FactionsPlayerListener implements Listener { } public static boolean preventCommand(String fullCmd, Player player) { - if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty() && Conf.permanentFactionMemberDenyCommands.isEmpty())) + if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty() && Conf.permanentFactionMemberDenyCommands.isEmpty())) { return false; + } fullCmd = fullCmd.toLowerCase(); FPlayer me = FPlayers.i.get(player); String shortCmd; // command without the slash at the beginning - if (fullCmd.startsWith("/")) - shortCmd = fullCmd.substring(1); + if (fullCmd.startsWith("/")) { shortCmd = fullCmd.substring(1); } else { shortCmd = fullCmd; fullCmd = "/" + fullCmd; @@ -422,15 +432,14 @@ public class FactionsPlayerListener implements Listener { } cmdCheck = cmdCheck.toLowerCase(); - if (fullCmd.startsWith(cmdCheck) || shortCmd.startsWith(cmdCheck)) - return true; + if (fullCmd.startsWith(cmdCheck) || shortCmd.startsWith(cmdCheck)) { return true; } } return false; } @EventHandler(priority = EventPriority.NORMAL) public void onPlayerKick(PlayerKickEvent event) { - if (event.isCancelled()) return; + if (event.isCancelled()) { return; } FPlayer badGuy = FPlayers.i.get(event.getPlayer()); if (badGuy == null) { @@ -439,8 +448,7 @@ public class FactionsPlayerListener implements Listener { // if player was banned (not just kicked), get rid of their stored info if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) { - if (badGuy.getRole() == Role.ADMIN) - badGuy.getFaction().promoteNewLeader(); + if (badGuy.getRole() == Role.ADMIN) { badGuy.getFaction().promoteNewLeader(); } badGuy.leave(false); badGuy.detach(); diff --git a/src/main/java/com/massivecraft/factions/struct/ChatMode.java b/src/main/java/com/massivecraft/factions/struct/ChatMode.java index 38befe2f..80456c16 100644 --- a/src/main/java/com/massivecraft/factions/struct/ChatMode.java +++ b/src/main/java/com/massivecraft/factions/struct/ChatMode.java @@ -27,8 +27,8 @@ public enum ChatMode { } public ChatMode getNext() { - if (this == PUBLIC) return ALLIANCE; - if (this == ALLIANCE) return FACTION; + if (this == PUBLIC) { return ALLIANCE; } + if (this == ALLIANCE) { return FACTION; } return PUBLIC; } } diff --git a/src/main/java/com/massivecraft/factions/struct/Relation.java b/src/main/java/com/massivecraft/factions/struct/Relation.java index abf617e2..08df93fb 100644 --- a/src/main/java/com/massivecraft/factions/struct/Relation.java +++ b/src/main/java/com/massivecraft/factions/struct/Relation.java @@ -48,78 +48,55 @@ public enum Relation { } public ChatColor getColor() { - if (this == MEMBER) - return Conf.colorMember; - else if (this == ALLY) - return Conf.colorAlly; - else if (this == NEUTRAL) - return Conf.colorNeutral; - else - return Conf.colorEnemy; + if (this == MEMBER) { return Conf.colorMember; } + else if (this == ALLY) { return Conf.colorAlly; } + else if (this == NEUTRAL) { return Conf.colorNeutral; } + else { return Conf.colorEnemy; } } // return appropriate Conf setting for DenyBuild based on this relation and their online status public boolean confDenyBuild(boolean online) { - if (isMember()) - return false; + if (isMember()) { return false; } if (online) { - if (isEnemy()) - return Conf.territoryEnemyDenyBuild; - else if (isAlly()) - return Conf.territoryAllyDenyBuild; - else - return Conf.territoryDenyBuild; - } else { - if (isEnemy()) - return Conf.territoryEnemyDenyBuildWhenOffline; - else if (isAlly()) - return Conf.territoryAllyDenyBuildWhenOffline; - else - return Conf.territoryDenyBuildWhenOffline; + if (isEnemy()) { return Conf.territoryEnemyDenyBuild; } + else if (isAlly()) { return Conf.territoryAllyDenyBuild; } + else { return Conf.territoryDenyBuild; } + } + else { + if (isEnemy()) { return Conf.territoryEnemyDenyBuildWhenOffline; } + else if (isAlly()) { return Conf.territoryAllyDenyBuildWhenOffline; } + else { return Conf.territoryDenyBuildWhenOffline; } } } // return appropriate Conf setting for PainBuild based on this relation and their online status public boolean confPainBuild(boolean online) { - if (isMember()) - return false; + if (isMember()) { return false; } if (online) { - if (isEnemy()) - return Conf.territoryEnemyPainBuild; - else if (isAlly()) - return Conf.territoryAllyPainBuild; - else - return Conf.territoryPainBuild; - } else { - if (isEnemy()) - return Conf.territoryEnemyPainBuildWhenOffline; - else if (isAlly()) - return Conf.territoryAllyPainBuildWhenOffline; - else - return Conf.territoryPainBuildWhenOffline; + if (isEnemy()) { return Conf.territoryEnemyPainBuild; } + else if (isAlly()) { return Conf.territoryAllyPainBuild; } + else { return Conf.territoryPainBuild; } + } + else { + if (isEnemy()) { return Conf.territoryEnemyPainBuildWhenOffline; } + else if (isAlly()) { return Conf.territoryAllyPainBuildWhenOffline; } + else { return Conf.territoryPainBuildWhenOffline; } } } // return appropriate Conf setting for DenyUseage based on this relation public boolean confDenyUseage() { - if (isMember()) - return false; - else if (isEnemy()) - return Conf.territoryEnemyDenyUseage; - else if (isAlly()) - return Conf.territoryAllyDenyUseage; - else - return Conf.territoryDenyUseage; + if (isMember()) { return false; } + else if (isEnemy()) { return Conf.territoryEnemyDenyUseage; } + else if (isAlly()) { return Conf.territoryAllyDenyUseage; } + else { return Conf.territoryDenyUseage; } } public double getRelationCost() { - if (isEnemy()) - return Conf.econCostEnemy; - else if (isAlly()) - return Conf.econCostAlly; - else - return Conf.econCostNeutral; + if (isEnemy()) { return Conf.econCostEnemy; } + else if (isAlly()) { return Conf.econCostAlly; } + else { return Conf.econCostNeutral; } } } diff --git a/src/main/java/com/massivecraft/factions/util/AsciiCompass.java b/src/main/java/com/massivecraft/factions/util/AsciiCompass.java index 519d8798..7d167d40 100644 --- a/src/main/java/com/massivecraft/factions/util/AsciiCompass.java +++ b/src/main/java/com/massivecraft/factions/util/AsciiCompass.java @@ -33,29 +33,18 @@ public class AsciiCompass { public static AsciiCompass.Point getCompassPointForDirection(double inDegrees) { double degrees = (inDegrees - 180) % 360; - if (degrees < 0) - degrees += 360; + if (degrees < 0) { degrees += 360; } - if (0 <= degrees && degrees < 22.5) - return AsciiCompass.Point.N; - else if (22.5 <= degrees && degrees < 67.5) - return AsciiCompass.Point.NE; - else if (67.5 <= degrees && degrees < 112.5) - return AsciiCompass.Point.E; - else if (112.5 <= degrees && degrees < 157.5) - return AsciiCompass.Point.SE; - else if (157.5 <= degrees && degrees < 202.5) - return AsciiCompass.Point.S; - else if (202.5 <= degrees && degrees < 247.5) - return AsciiCompass.Point.SW; - else if (247.5 <= degrees && degrees < 292.5) - return AsciiCompass.Point.W; - else if (292.5 <= degrees && degrees < 337.5) - return AsciiCompass.Point.NW; - else if (337.5 <= degrees && degrees < 360.0) - return AsciiCompass.Point.N; - else - return null; + if (0 <= degrees && degrees < 22.5) { return AsciiCompass.Point.N; } + else if (22.5 <= degrees && degrees < 67.5) { return AsciiCompass.Point.NE; } + else if (67.5 <= degrees && degrees < 112.5) { return AsciiCompass.Point.E; } + else if (112.5 <= degrees && degrees < 157.5) { return AsciiCompass.Point.SE; } + else if (157.5 <= degrees && degrees < 202.5) { return AsciiCompass.Point.S; } + else if (202.5 <= degrees && degrees < 247.5) { return AsciiCompass.Point.SW; } + else if (247.5 <= degrees && degrees < 292.5) { return AsciiCompass.Point.W; } + else if (292.5 <= degrees && degrees < 337.5) { return AsciiCompass.Point.NW; } + else if (337.5 <= degrees && degrees < 360.0) { return AsciiCompass.Point.N; } + else { return null; } } public static ArrayList getAsciiCompass(Point point, ChatColor colorActive, String colorDefault) { diff --git a/src/main/java/com/massivecraft/factions/util/AutoLeaveProcessTask.java b/src/main/java/com/massivecraft/factions/util/AutoLeaveProcessTask.java index 2bd8df64..4c4bd352 100644 --- a/src/main/java/com/massivecraft/factions/util/AutoLeaveProcessTask.java +++ b/src/main/java/com/massivecraft/factions/util/AutoLeaveProcessTask.java @@ -27,7 +27,7 @@ public class AutoLeaveProcessTask extends BukkitRunnable { return; } - if (!readyToGo) return; + if (!readyToGo) { return; } // this is set so it only does one iteration at a time, no matter how frequently the timer fires readyToGo = false; // and this is tracked to keep one iteration from dragging on too long and possibly choking the system if there are a very large number of players to go through @@ -44,14 +44,14 @@ public class AutoLeaveProcessTask extends BukkitRunnable { FPlayer fplayer = iterator.next(); if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis) { - if (Conf.logFactionLeave || Conf.logFactionKick) + if (Conf.logFactionLeave || Conf.logFactionKick) { P.p.log("Player " + fplayer.getName() + " was auto-removed due to inactivity."); + } // if player is faction admin, sort out the faction since he's going away if (fplayer.getRole() == Role.ADMIN) { Faction faction = fplayer.getFaction(); - if (faction != null) - fplayer.getFaction().promoteNewLeader(); + if (faction != null) { fplayer.getFaction().promoteNewLeader(); } } fplayer.leave(false); diff --git a/src/main/java/com/massivecraft/factions/util/AutoLeaveTask.java b/src/main/java/com/massivecraft/factions/util/AutoLeaveTask.java index 42bf9609..f85a0629 100644 --- a/src/main/java/com/massivecraft/factions/util/AutoLeaveTask.java +++ b/src/main/java/com/massivecraft/factions/util/AutoLeaveTask.java @@ -12,14 +12,12 @@ public class AutoLeaveTask implements Runnable { } public synchronized void run() { - if (task != null && !task.isFinished()) - return; + if (task != null && !task.isFinished()) { return; } task = new AutoLeaveProcessTask(); task.runTaskTimer(P.p, 1, 1); // maybe setting has been changed? if so, restart this task at new rate - if (this.rate != Conf.autoLeaveRoutineRunsEveryXMinutes) - P.p.startAutoLeaveTask(true); + if (this.rate != Conf.autoLeaveRoutineRunsEveryXMinutes) { P.p.startAutoLeaveTask(true); } } } diff --git a/src/main/java/com/massivecraft/factions/util/LazyLocation.java b/src/main/java/com/massivecraft/factions/util/LazyLocation.java index eec522ce..1b6dcd0f 100644 --- a/src/main/java/com/massivecraft/factions/util/LazyLocation.java +++ b/src/main/java/com/massivecraft/factions/util/LazyLocation.java @@ -57,11 +57,11 @@ public class LazyLocation { // This initializes the Location private void initLocation() { // if location is already initialized, simply return - if (location != null) return; + if (location != null) { return; } // get World; hopefully it's initialized at this point World world = Bukkit.getWorld(worldName); - if (world == null) return; + if (world == null) { return; } // store the Location for future calls, and pass it on location = new Location(world, x, y, z, yaw, pitch); diff --git a/src/main/java/com/massivecraft/factions/util/Metrics.java b/src/main/java/com/massivecraft/factions/util/Metrics.java index 06b32fa1..aaf5057b 100644 --- a/src/main/java/com/massivecraft/factions/util/Metrics.java +++ b/src/main/java/com/massivecraft/factions/util/Metrics.java @@ -301,7 +301,8 @@ public final class Metrics { // It does not reroute POST requests so we need to go around it if (isMineshafterPresent()) { connection = url.openConnection(Proxy.NO_PROXY); - } else { + } + else { connection = url.openConnection(); } @@ -339,7 +340,8 @@ public final class Metrics { if (response == null || response.startsWith("ERR") || response.startsWith("7")) { if (response == null) { response = "null"; - } else if (response.startsWith("7")) { + } + else if (response.startsWith("7")) { response = response.substring(response.startsWith("7,") ? 2 : 1); } @@ -419,7 +421,8 @@ public final class Metrics { if (isValueNumeric) { json.append(value); - } else { + } + else { json.append(escapeJSON(value)); } } @@ -460,7 +463,8 @@ public final class Metrics { if (chr < ' ') { String t = "000" + Integer.toHexString(chr); builder.append("\\u").append(t.substring(t.length() - 4)); - } else { + } + else { builder.append(chr); } break; diff --git a/src/main/java/com/massivecraft/factions/util/MiscUtil.java b/src/main/java/com/massivecraft/factions/util/MiscUtil.java index 086e132f..0cd63695 100644 --- a/src/main/java/com/massivecraft/factions/util/MiscUtil.java +++ b/src/main/java/com/massivecraft/factions/util/MiscUtil.java @@ -39,10 +39,10 @@ public class MiscUtil { /// TODO create tag whitelist!! public static HashSet substanceChars = new HashSet(Arrays.asList(new String[]{ - "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", - "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", - "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", - "s", "t", "u", "v", "w", "x", "y", "z" + "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", + "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", + "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", + "s", "t", "u", "v", "w", "x", "y", "z" })); public static String getComparisonString(String str) { diff --git a/src/main/java/com/massivecraft/factions/util/RelationUtil.java b/src/main/java/com/massivecraft/factions/util/RelationUtil.java index 79da7375..e2299708 100644 --- a/src/main/java/com/massivecraft/factions/util/RelationUtil.java +++ b/src/main/java/com/massivecraft/factions/util/RelationUtil.java @@ -13,7 +13,9 @@ public class RelationUtil { String ret = ""; Faction thatFaction = getFaction(that); - if (thatFaction == null) return "ERROR"; // ERROR + if (thatFaction == null) { + return "ERROR"; // ERROR + } Faction myFaction = getFaction(me); // if (myFaction == null) return that.describeTo(null); // no relation, but can show basic name or tag @@ -21,16 +23,20 @@ public class RelationUtil { if (that instanceof Faction) { if (me instanceof FPlayer && myFaction == thatFaction) { ret = "your faction"; - } else { + } + else { ret = thatFaction.getTag(); } - } else if (that instanceof FPlayer) { + } + else if (that instanceof FPlayer) { FPlayer fplayerthat = (FPlayer) that; if (that == me) { ret = "you"; - } else if (thatFaction == myFaction) { + } + else if (thatFaction == myFaction) { ret = fplayerthat.getNameAndTitle(); - } else { + } + else { ret = fplayerthat.getNameAndTag(); } } @@ -52,10 +58,14 @@ public class RelationUtil { public static Relation getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) { Faction fthat = getFaction(that); - if (fthat == null) return Relation.NEUTRAL; // ERROR + if (fthat == null) { + return Relation.NEUTRAL; // ERROR + } Faction fme = getFaction(me); - if (fme == null) return Relation.NEUTRAL; // ERROR + if (fme == null) { + return Relation.NEUTRAL; // ERROR + } if (!fthat.isNormal() || !fme.isNormal()) { return Relation.NEUTRAL; diff --git a/src/main/java/com/massivecraft/factions/util/SpiralTask.java b/src/main/java/com/massivecraft/factions/util/SpiralTask.java index d8fa6374..e5c8ef6b 100644 --- a/src/main/java/com/massivecraft/factions/util/SpiralTask.java +++ b/src/main/java/com/massivecraft/factions/util/SpiralTask.java @@ -98,19 +98,18 @@ public abstract class SpiralTask implements Runnable { */ public final void setTaskID(int ID) { - if (ID == -1) - this.stop(); + if (ID == -1) { this.stop(); } taskID = ID; } public final void run() { - if (!this.valid() || !readyToGo) return; + if (!this.valid() || !readyToGo) { return; } // this is set so it only does one iteration at a time, no matter how frequently the timer fires readyToGo = false; // make sure we're still inside the specified radius - if (!this.insideRadius()) return; + if (!this.insideRadius()) { return; } // track this to keep one iteration from dragging on too long and possibly choking the system long loopStartTime = now(); @@ -124,8 +123,7 @@ public abstract class SpiralTask implements Runnable { } // move on to next chunk in spiral - if (!this.moveToNext()) - return; + if (!this.moveToNext()) { return; } } // ready for the next iteration to run @@ -134,15 +132,16 @@ public abstract class SpiralTask implements Runnable { // step through chunks in spiral pattern from center; returns false if we're done, otherwise returns true public final boolean moveToNext() { - if (!this.valid()) return false; + if (!this.valid()) { return false; } // make sure we don't need to turn down the next leg of the spiral if (current < length) { current++; // if we're outside the radius, we're done - if (!this.insideRadius()) return false; - } else { // one leg/side of the spiral down... + if (!this.insideRadius()) { return false; } + } + else { // one leg/side of the spiral down... current = 0; isZLeg ^= true; // every second leg (between X and Z legs, negative or positive), length increases @@ -153,18 +152,15 @@ public abstract class SpiralTask implements Runnable { } // move one chunk further in the appropriate direction - if (isZLeg) - z += (isNeg) ? -1 : 1; - else - x += (isNeg) ? -1 : 1; + if (isZLeg) { z += (isNeg) ? -1 : 1; } + else { x += (isNeg) ? -1 : 1; } return true; } public final boolean insideRadius() { boolean inside = current < limit; - if (!inside) - this.finish(); + if (!inside) { this.finish(); } return inside; } @@ -176,7 +172,7 @@ public abstract class SpiralTask implements Runnable { // we're done, whether finished or cancelled public final void stop() { - if (!this.valid()) return; + if (!this.valid()) { return; } readyToGo = false; Bukkit.getServer().getScheduler().cancelTask(taskID); diff --git a/src/main/java/com/massivecraft/factions/zcore/FCommandHandler.java b/src/main/java/com/massivecraft/factions/zcore/FCommandHandler.java index f94a63c8..e12ffa69 100644 --- a/src/main/java/com/massivecraft/factions/zcore/FCommandHandler.java +++ b/src/main/java/com/massivecraft/factions/zcore/FCommandHandler.java @@ -11,8 +11,9 @@ public class FCommandHandler implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (P.p.handleCommand(sender, cmd.getName() + args)) { - if (P.p.logPlayerCommands()) + if (P.p.logPlayerCommands()) { Bukkit.getLogger().info("[PLAYER_COMMAND] " + sender.getName() + ": " + cmd.getName() + args); + } } return false; } diff --git a/src/main/java/com/massivecraft/factions/zcore/MCommand.java b/src/main/java/com/massivecraft/factions/zcore/MCommand.java index 93dad59f..6b54c6cb 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MCommand.java +++ b/src/main/java/com/massivecraft/factions/zcore/MCommand.java @@ -91,7 +91,8 @@ public abstract class MCommand { if (sender instanceof Player) { this.me = (Player) sender; this.senderIsConsole = false; - } else { + } + else { this.me = null; this.senderIsConsole = true; } @@ -110,9 +111,9 @@ public abstract class MCommand { } } - if (!validCall(this.sender, this.args)) return; + if (!validCall(this.sender, this.args)) { return; } - if (!this.isEnabled()) return; + if (!this.isEnabled()) { return; } perform(); } @@ -164,7 +165,7 @@ public abstract class MCommand { } public boolean validSenderPermissions(CommandSender sender, boolean informSenderIfNot) { - if (this.permission == null) return true; + if (this.permission == null) { return true; } return p.perm.has(sender, this.permission, informSenderIfNot); } @@ -219,7 +220,8 @@ public abstract class MCommand { String val = optionalArg.getValue(); if (val == null) { val = ""; - } else { + } + else { val = "=" + val; } args.add("[" + optionalArg.getKey() + val + "]"); @@ -290,7 +292,7 @@ public abstract class MCommand { // INT ====================== public Integer strAsInt(String str, Integer def) { - if (str == null) return def; + if (str == null) { return def; } try { Integer ret = Integer.parseInt(str); return ret; @@ -309,7 +311,7 @@ public abstract class MCommand { // Double ====================== public Double strAsDouble(String str, Double def) { - if (str == null) return def; + if (str == null) { return def; } try { Double ret = Double.parseDouble(str); return ret; @@ -338,7 +340,7 @@ public abstract class MCommand { public Boolean argAsBool(int idx, boolean def) { String str = this.argAsString(idx); - if (str == null) return def; + if (str == null) { return def; } return strAsBool(str); } diff --git a/src/main/java/com/massivecraft/factions/zcore/MPlugin.java b/src/main/java/com/massivecraft/factions/zcore/MPlugin.java index 97bebe87..aecbc57b 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MPlugin.java +++ b/src/main/java/com/massivecraft/factions/zcore/MPlugin.java @@ -90,8 +90,7 @@ public abstract class MPlugin extends JavaPlugin { // reference command will be used to prevent "unknown command" console messages try { Map> refCmd = this.getDescription().getCommands(); - if (refCmd != null && !refCmd.isEmpty()) - this.refCommand = (String) (refCmd.keySet().toArray()[0]); + if (refCmd != null && !refCmd.isEmpty()) { this.refCommand = (String) (refCmd.keySet().toArray()[0]); } } catch (ClassCastException ex) { } @@ -186,8 +185,7 @@ public abstract class MPlugin extends JavaPlugin { saveTask = null; } // only save data if plugin actually loaded successfully - if (loadSuccessful) - EM.saveAllToDisc(); + if (loadSuccessful) { EM.saveAllToDisc(); } log("Disabled"); } @@ -204,10 +202,10 @@ public abstract class MPlugin extends JavaPlugin { public GsonBuilder getGsonBuilder() { return new GsonBuilder() - .setPrettyPrinting() - .disableHtmlEscaping() - .serializeNulls() - .excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE); + .setPrettyPrinting() + .disableHtmlEscaping() + .serializeNulls() + .excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE); } // -------------------------------------------- // @@ -237,7 +235,7 @@ public abstract class MPlugin extends JavaPlugin { }.getType(); Map tagsFromFile = this.persist.load(type, "tags"); - if (tagsFromFile != null) this.rawTags.putAll(tagsFromFile); + if (tagsFromFile != null) { this.rawTags.putAll(tagsFromFile); } this.persist.save(this.rawTags, "tags"); for (Entry rawTag : this.rawTags.entrySet()) { @@ -266,17 +264,17 @@ public abstract class MPlugin extends JavaPlugin { } for (final MCommand command : this.getBaseCommands()) { - if (noSlash && !command.allowNoSlashAccess) continue; + if (noSlash && !command.allowNoSlashAccess) { continue; } for (String alias : command.aliases) { // disallow double-space after alias, so specific commands can be prevented (preventing "f home" won't prevent "f home") - if (commandString.startsWith(alias + " ")) return false; + if (commandString.startsWith(alias + " ")) { return false; } if (commandString.startsWith(alias + " ") || commandString.equals(alias)) { final List args = new ArrayList(Arrays.asList(commandString.split("\\s+"))); args.remove(0); - if (testOnly) return true; + if (testOnly) { return true; } if (async) { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { @@ -285,8 +283,8 @@ public abstract class MPlugin extends JavaPlugin { command.execute(sender, args); } }); - } else - command.execute(sender, args); + } + else { command.execute(sender, args); } return true; } diff --git a/src/main/java/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java b/src/main/java/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java index 79937618..87275147 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/zcore/MPluginSecretPlayerListener.java @@ -26,8 +26,9 @@ public class MPluginSecretPlayerListener implements Listener { //@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { if (p.handleCommand(event.getPlayer(), event.getMessage())) { - if (p.logPlayerCommands()) + if (p.logPlayerCommands()) { Bukkit.getLogger().info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage()); + } event.setCancelled(true); } } @@ -35,8 +36,9 @@ public class MPluginSecretPlayerListener implements Listener { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerChat(AsyncPlayerChatEvent event) { if (p.handleCommand(event.getPlayer(), event.getMessage(), false, true)) { - if (p.logPlayerCommands()) + if (p.logPlayerCommands()) { Bukkit.getLogger().info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage()); + } event.setCancelled(true); } diff --git a/src/main/java/com/massivecraft/factions/zcore/MPluginSecretServerListener.java b/src/main/java/com/massivecraft/factions/zcore/MPluginSecretServerListener.java index ee43b002..5fe9e619 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MPluginSecretServerListener.java +++ b/src/main/java/com/massivecraft/factions/zcore/MPluginSecretServerListener.java @@ -14,7 +14,7 @@ public class MPluginSecretServerListener implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onServerCommand(ServerCommandEvent event) { - if (event.getCommand().length() == 0) return; + if (event.getCommand().length() == 0) { return; } if (p.handleCommand(event.getSender(), event.getCommand())) { event.setCommand(p.refCommand); diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/EntityCollection.java b/src/main/java/com/massivecraft/factions/zcore/persist/EntityCollection.java index 58e9b9bf..99a315a3 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/EntityCollection.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/EntityCollection.java @@ -99,24 +99,24 @@ public abstract class EntityCollection { } public E get(String id) { - if (this.creative) return this.getCreative(id); + if (this.creative) { return this.getCreative(id); } return id2entity.get(id); } public E getCreative(String id) { E e = id2entity.get(id); - if (e != null) return e; + if (e != null) { return e; } return this.create(id); } public boolean exists(String id) { - if (id == null) return false; + if (id == null) { return false; } return id2entity.get(id) != null; } public E getBestIdMatch(String pattern) { String id = TextUtil.getBestStartWithCI(this.id2entity.keySet(), pattern); - if (id == null) return null; + if (id == null) { return null; } return this.id2entity.get(id); } @@ -129,7 +129,7 @@ public abstract class EntityCollection { } public synchronized E create(String id) { - if (!this.isIdFree(id)) return null; + if (!this.isIdFree(id)) { return null; } E e = null; try { @@ -150,7 +150,7 @@ public abstract class EntityCollection { // -------------------------------------------- // public void attach(E entity) { - if (entity.getId() != null) return; + if (entity.getId() != null) { return; } entity.setId(this.getNextId()); this.entities.add(entity); this.id2entity.put(entity.getId(), entity); @@ -165,7 +165,7 @@ public abstract class EntityCollection { public void detach(String id) { E entity = this.id2entity.get(id); - if (entity == null) return; + if (entity == null) { return; } this.detach(entity); } @@ -185,7 +185,7 @@ public abstract class EntityCollection { private boolean saveIsRunning = false; public boolean saveToDisc() { - if (saveIsRunning) return true; + if (saveIsRunning) { return true; } saveIsRunning = true; Map entitiesThatShouldBeSaved = new HashMap(); @@ -205,7 +205,7 @@ public abstract class EntityCollection { public boolean loadFromDisc() { Map id2entity = this.loadCore(); - if (id2entity == null) return false; + if (id2entity == null) { return false; } this.entities.clear(); this.entities.addAll(id2entity.values()); this.id2entity.clear(); @@ -289,7 +289,8 @@ public abstract class EntityCollection { Bukkit.getLogger().log(Level.INFO, "Done converting players.json to UUID."); } return (Map) data; - } else { + } + else { Map data = this.gson.fromJson(content, type); // Do we have any names that need updating in claims or invites? diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/PlayerEntity.java b/src/main/java/com/massivecraft/factions/zcore/persist/PlayerEntity.java index e5f944ec..cbe00c6e 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/PlayerEntity.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/PlayerEntity.java @@ -8,7 +8,7 @@ import java.util.List; public class PlayerEntity extends Entity { public Player getPlayer() { for (Player player : Bukkit.getServer().getOnlinePlayers()) { - if (player.getUniqueId().toString().equals(this.getId())) return player; + if (player.getUniqueId().toString().equals(this.getId())) { return player; } } return null; } @@ -33,7 +33,7 @@ public class PlayerEntity extends Entity { public void sendMessage(String msg) { Player player = this.getPlayer(); - if (player == null) return; + if (player == null) { return; } player.sendMessage(msg); } diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/SaveTask.java b/src/main/java/com/massivecraft/factions/zcore/persist/SaveTask.java index 10ca14ba..c18fe83d 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/SaveTask.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/SaveTask.java @@ -12,7 +12,7 @@ public class SaveTask implements Runnable { } public void run() { - if (!p.getAutoSave() || running) return; + if (!p.getAutoSave() || running) { return; } running = true; p.preAutoSave(); EM.saveAllToDisc(); diff --git a/src/main/java/com/massivecraft/factions/zcore/util/PermUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/PermUtil.java index 2cc449b1..c322b5f1 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/PermUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/PermUtil.java @@ -47,7 +47,7 @@ public class PermUtil { * This method tests if me has a certain permission and returns true if me has. Otherwise false */ public boolean has(CommandSender me, String perm) { - if (me == null) return false; + if (me == null) { return false; } if (!(me instanceof Player)) { return me.hasPermission(perm); @@ -59,19 +59,20 @@ public class PermUtil { public boolean has(CommandSender me, String perm, boolean informSenderIfNot) { if (has(me, perm)) { return true; - } else if (informSenderIfNot && me != null) { + } + else if (informSenderIfNot && me != null) { me.sendMessage(this.getForbiddenMessage(perm)); } return false; } public T pickFirstVal(CommandSender me, Map perm2val) { - if (perm2val == null) return null; + if (perm2val == null) { return null; } T ret = null; for (Entry entry : perm2val.entrySet()) { ret = entry.getValue(); - if (has(me, entry.getKey())) break; + if (has(me, entry.getKey())) { break; } } return ret; diff --git a/src/main/java/com/massivecraft/factions/zcore/util/Persist.java b/src/main/java/com/massivecraft/factions/zcore/util/Persist.java index cc670b36..435fae7e 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/Persist.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/Persist.java @@ -77,7 +77,7 @@ public class Persist { // backup bad file, so user can attempt to recover their changes from it File backup = new File(file.getPath() + "_bad"); - if (backup.exists()) backup.delete(); + if (backup.exists()) { backup.delete(); } p.log(Level.WARNING, "Backing up copy of bad file to: " + backup); file.renameTo(backup); diff --git a/src/main/java/com/massivecraft/factions/zcore/util/SmokeUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/SmokeUtil.java index 985c9108..be586a53 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/SmokeUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/SmokeUtil.java @@ -31,7 +31,7 @@ public class SmokeUtil { // Single ======== public static void spawnSingle(Location location, int direction) { - if (location == null) return; + if (location == null) { return; } location.getWorld().playEffect(location.clone(), Effect.SMOKE, direction); } diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index 6a0f8bd0..22603317 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -38,7 +38,7 @@ public enum TL { /** * Lang enum constructor. * - * @param path The string path. + * @param path The string path. * @param start The default string. */ TL(String path, String start) { diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java index 40e40c6a..ed0fdd98 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java @@ -44,7 +44,8 @@ public class TextUtil { String repl = tags.get(tag); if (repl == null) { matcher.appendReplacement(ret, "<" + tag + ">"); - } else { + } + else { matcher.appendReplacement(ret, repl); } } @@ -72,34 +73,34 @@ public class TextUtil { public static String parseColorAcc(String string) { return string.replace("`e", "") - .replace("`r", ChatColor.RED.toString()).replace("`R", ChatColor.DARK_RED.toString()) - .replace("`y", ChatColor.YELLOW.toString()).replace("`Y", ChatColor.GOLD.toString()) - .replace("`g", ChatColor.GREEN.toString()).replace("`G", ChatColor.DARK_GREEN.toString()) - .replace("`a", ChatColor.AQUA.toString()).replace("`A", ChatColor.DARK_AQUA.toString()) - .replace("`b", ChatColor.BLUE.toString()).replace("`B", ChatColor.DARK_BLUE.toString()) - .replace("`p", ChatColor.LIGHT_PURPLE.toString()).replace("`P", ChatColor.DARK_PURPLE.toString()) - .replace("`k", ChatColor.BLACK.toString()).replace("`s", ChatColor.GRAY.toString()) - .replace("`S", ChatColor.DARK_GRAY.toString()).replace("`w", ChatColor.WHITE.toString()); + .replace("`r", ChatColor.RED.toString()).replace("`R", ChatColor.DARK_RED.toString()) + .replace("`y", ChatColor.YELLOW.toString()).replace("`Y", ChatColor.GOLD.toString()) + .replace("`g", ChatColor.GREEN.toString()).replace("`G", ChatColor.DARK_GREEN.toString()) + .replace("`a", ChatColor.AQUA.toString()).replace("`A", ChatColor.DARK_AQUA.toString()) + .replace("`b", ChatColor.BLUE.toString()).replace("`B", ChatColor.DARK_BLUE.toString()) + .replace("`p", ChatColor.LIGHT_PURPLE.toString()).replace("`P", ChatColor.DARK_PURPLE.toString()) + .replace("`k", ChatColor.BLACK.toString()).replace("`s", ChatColor.GRAY.toString()) + .replace("`S", ChatColor.DARK_GRAY.toString()).replace("`w", ChatColor.WHITE.toString()); } public static String parseColorTags(String string) { return string.replace("", "") - .replace("", "\u00A70") - .replace("", "\u00A71") - .replace("", "\u00A72") - .replace("", "\u00A73") - .replace("", "\u00A74") - .replace("", "\u00A75") - .replace("", "\u00A76") - .replace("", "\u00A77") - .replace("", "\u00A78") - .replace("", "\u00A79") - .replace("", "\u00A7a") - .replace("", "\u00A7b") - .replace("", "\u00A7c") - .replace("", "\u00A7d") - .replace("", "\u00A7e") - .replace("", "\u00A7f"); + .replace("", "\u00A70") + .replace("", "\u00A71") + .replace("", "\u00A72") + .replace("", "\u00A73") + .replace("", "\u00A74") + .replace("", "\u00A75") + .replace("", "\u00A76") + .replace("", "\u00A77") + .replace("", "\u00A78") + .replace("", "\u00A79") + .replace("", "\u00A7a") + .replace("", "\u00A7b") + .replace("", "\u00A7c") + .replace("", "\u00A7d") + .replace("", "\u00A7e") + .replace("", "\u00A7f"); } // -------------------------------------------- // @@ -122,8 +123,8 @@ public class TextUtil { } public static String repeat(String s, int times) { - if (times <= 0) return ""; - else return s + repeat(s, times - 1); + if (times <= 0) { return ""; } + else { return s + repeat(s, times - 1); } } // -------------------------------------------- // @@ -152,10 +153,10 @@ public class TextUtil { int eatLeft = (centerlen / 2) - titleizeBalance; int eatRight = (centerlen - eatLeft) + titleizeBalance; - if (eatLeft < pivot) + if (eatLeft < pivot) { return parseTags("") + titleizeLine.substring(0, pivot - eatLeft) + center + titleizeLine.substring(pivot + eatRight); - else - return parseTags("") + center; + } + else { return parseTags("") + center; } } public ArrayList getPage(List lines, int pageHumanBased, String title) { @@ -169,7 +170,8 @@ public class TextUtil { if (pagecount == 0) { ret.add(this.parseTags("Sorry. No Pages available.")); return ret; - } else if (pageZeroBased < 0 || pageHumanBased > pagecount) { + } + else if (pageZeroBased < 0 || pageHumanBased > pagecount) { ret.add(this.parseTags("Invalid page. Must be between 1 and " + pagecount)); return ret; } @@ -192,8 +194,8 @@ public class TextUtil { start = start.toLowerCase(); int minlength = start.length(); for (String candidate : candidates) { - if (candidate.length() < minlength) continue; - if (!candidate.toLowerCase().startsWith(start)) continue; + if (candidate.length() < minlength) { continue; } + if (!candidate.toLowerCase().startsWith(start)) { continue; } // The closer to zero the better int lendiff = candidate.length() - minlength;