From 672e115d8b5474da3d3c515fefd3dcdee360c870 Mon Sep 17 00:00:00 2001 From: drtshock Date: Tue, 1 Jul 2014 13:46:30 -0500 Subject: [PATCH] Update default factions description and tags if changed in the lang file. --- src/.DS_Store | Bin 0 -> 6148 bytes .../com/massivecraft/factions/FPlayer.java | 20 ++----- .../com/massivecraft/factions/Faction.java | 2 +- .../com/massivecraft/factions/Factions.java | 19 ++++++ .../listeners/FactionsPlayerListener.java | 56 +++--------------- 5 files changed, 33 insertions(+), 64 deletions(-) create mode 100644 src/.DS_Store diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5cceccfcd62f2ebbd7c93fbcfeb5404241f34b5e GIT binary patch literal 6148 zcmeHK%}N6?5Kh{vyA^Z=LA~YXrH9rE_2yFR$&0XJ4=Qz+Eq0-9O1rg(TG*q%@8C`J zi3DH9nItVr_2NOK%)sQEOlA`D?UG3tW4ziAON=>;F$)wiV?*LM&f0KT+A4_h*7m3%hLuXOAhvhPqmlDuTN|6@-Ge}0-`w8aKRiCa zXr4Lzl1f$#j^P!I$(FCYZrqmf1^CAC<2XWMfEXYKW|jeS;8}|^yF=O-F+dFbmH|8; z1Sq0wFx9Az4ruWDh~qg#6tM9vfhY{R22+hN0>X7FpibrHiNSR`_=Smc4W=4(I^$|( zn8&Ql%?pLA)xj@RIODEHYKZ}2;41@J-F2}3@BjS%|C&TSVt^Q!DF%41=GCgOB~x3c xHixxVfS!Y*U|gzkk^+V*#Sn|7cpX#;_yrn(uEA6zctGePplG0m82D2LJ^Limit reached. You can't claim more land!"); } 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 + } else if (Conf.claimsMustBeConnected && !this.isAdminBypassing() && myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.isConnectedLocation(flocation, myFaction) - && (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal()) - ) { + && (!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 @@ -762,9 +756,7 @@ 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 5e376812..16b32016 100644 --- a/src/main/java/com/massivecraft/factions/Faction.java +++ b/src/main/java/com/massivecraft/factions/Faction.java @@ -461,7 +461,7 @@ public class Faction extends Entity implements EconomyParticipator { for (Player player : P.p.getServer().getOnlinePlayers()) { FPlayer fplayer = FPlayers.i.get(player); - if (fplayer.getFaction() == this) { + if (fplayer != null && fplayer.getFaction() == this) { return true; } } diff --git a/src/main/java/com/massivecraft/factions/Factions.java b/src/main/java/com/massivecraft/factions/Factions.java index cdf7f4d2..30e42003 100644 --- a/src/main/java/com/massivecraft/factions/Factions.java +++ b/src/main/java/com/massivecraft/factions/Factions.java @@ -40,6 +40,13 @@ public class Factions extends EntityCollection { Faction faction = this.create("0"); faction.setTag(TL.WILDERNESS.toString()); faction.setDescription(TL.WILDERNESS_DESCRIPTION.toString()); + } else { + if (!this.get("0").getTag().equalsIgnoreCase(TL.WILDERNESS.toString())) { + get("0").setTag(TL.WILDERNESS.toString()); + } + if (!this.get("0").getDescription().equalsIgnoreCase(TL.WILDERNESS_DESCRIPTION.toString())) { + get("0").setDescription(TL.WILDERNESS_DESCRIPTION.toString()); + } } // Make sure the safe zone faction exists @@ -48,6 +55,12 @@ public class Factions extends EntityCollection { faction.setTag(TL.SAFEZONE.toString()); faction.setDescription(TL.SAFEZONE_DESCRIPTION.toString()); } else { + if (!getSafeZone().getTag().equalsIgnoreCase(TL.SAFEZONE.toString())) { + getSafeZone().setTag(TL.SAFEZONE.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(" ")) @@ -60,6 +73,12 @@ public class Factions extends EntityCollection { faction.setTag(TL.WARZONE.toString()); faction.setDescription(TL.WARZONE_DESCRIPTION.toString()); } else { + if (!getWarZone().getTag().equalsIgnoreCase(TL.WARZONE.toString())) { + getWarZone().setTag(TL.WARZONE.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(" ")) diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index b975718f..f43ee3e4 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -60,14 +60,9 @@ public class FactionsPlayerListener implements Listener { 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() - ) + 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(); @@ -97,35 +92,16 @@ public class FactionsPlayerListener implements Listener { if (me.isMapAutoUpdating()) { me.sendMessage(Board.getMap(me.getFaction(), to, player.getLocation().getYaw())); - } 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()) @@ -423,30 +399,12 @@ public class FactionsPlayerListener implements Listener { return false; } - if - ( - rel.isNeutral() - && - !Conf.territoryNeutralDenyCommands.isEmpty() - && - !me.isAdminBypassing() - && - isCommandInList(fullCmd, shortCmd, Conf.territoryNeutralDenyCommands.iterator()) - ) { + if (rel.isNeutral() && !Conf.territoryNeutralDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryNeutralDenyCommands.iterator())) { me.msg("You can't use the command \"" + fullCmd + "\" in neutral territory."); return true; } - if - ( - rel.isEnemy() - && - !Conf.territoryEnemyDenyCommands.isEmpty() - && - !me.isAdminBypassing() - && - isCommandInList(fullCmd, shortCmd, Conf.territoryEnemyDenyCommands.iterator()) - ) { + if (rel.isEnemy() && !Conf.territoryEnemyDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryEnemyDenyCommands.iterator())) { me.msg("You can't use the command \"" + fullCmd + "\" in enemy territory."); return true; }