From 3bd67f502925dfb66422200743deb8b813711f06 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 3 Aug 2016 12:51:06 +0200 Subject: [PATCH] Previous commit gave duplicates. Lets try this. --- .../massivecraft/factions/entity/Faction.java | 4 +- .../massivecraft/factions/entity/MPlayer.java | 433 +++++++++--------- .../factions/entity/MPlayerColl.java | 16 +- 3 files changed, 225 insertions(+), 228 deletions(-) diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/com/massivecraft/factions/entity/Faction.java index ca6e3a27..666725de 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/com/massivecraft/factions/entity/Faction.java @@ -29,6 +29,7 @@ import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.collections.MassiveMapDef; +import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.collections.MassiveTreeSetDef; import com.massivecraft.massivecore.comparator.ComparatorCaseInsensitive; import com.massivecraft.massivecore.mixin.MixinMessage; @@ -1008,7 +1009,8 @@ public class Faction extends Entity implements EconomyParticipator, Nam // FOREIGN KEY: MPLAYER // -------------------------------------------- // - protected transient List mplayers = new ArrayList(); + protected transient Set mplayers = new MassiveSet(); + public void reindexMPlayers() { this.mplayers.clear(); diff --git a/src/com/massivecraft/factions/entity/MPlayer.java b/src/com/massivecraft/factions/entity/MPlayer.java index 38a6448f..24c8acea 100644 --- a/src/com/massivecraft/factions/entity/MPlayer.java +++ b/src/com/massivecraft/factions/entity/MPlayer.java @@ -33,22 +33,21 @@ import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.xlib.gson.annotations.SerializedName; - public class MPlayer extends SenderEntity implements EconomyParticipator { // -------------------------------------------- // // META // -------------------------------------------- // - + public static MPlayer get(Object oid) { return MPlayerColl.get().get(oid); } - + // -------------------------------------------- // // LOAD // -------------------------------------------- // - + @Override public MPlayer load(MPlayer that) { @@ -61,14 +60,14 @@ public class MPlayer extends SenderEntity implements EconomyParticipato this.setMapAutoUpdating(that.mapAutoUpdating); this.setOverriding(that.overriding); this.setTerritoryInfoTitles(that.territoryInfoTitles); - + return this; } - + // -------------------------------------------- // // IS DEFAULT // -------------------------------------------- // - + @Override public boolean isDefault() { @@ -81,50 +80,58 @@ public class MPlayer extends SenderEntity implements EconomyParticipato // if (this.isMapAutoUpdating()) return false; // Just having an auto updating map is not in itself reason enough for database storage. if (this.isOverriding()) return false; if (this.isTerritoryInfoTitles() != MConf.get().territoryInfoTitlesDefault) return false; - + return true; } - + // -------------------------------------------- // // UPDATE FACTION INDEXES // -------------------------------------------- // - - public void updateFactionIndexes(Faction before, Faction after) + + public void updateFactionIndexes(String beforeId, String afterId) { + // Really? + if (!Factions.get().isDatabaseInitialized()) return; + if (!this.attached()) return; + + // Fix IDs + if (beforeId == null) beforeId = MConf.get().defaultPlayerFactionId; + if (afterId == null) afterId = MConf.get().defaultPlayerFactionId; + // NoChange - if (MUtil.equals(before, after)) return; - - // Before + if (MUtil.equals(beforeId, afterId)) return; + + // Resolve + Faction before = Faction.get(beforeId); + Faction after = Faction.get(afterId); + + // Apply if (before != null) before.mplayers.remove(this); - - // After if (after != null) after.mplayers.add(this); } - + @Override public void postAttach(String id) { - if (!Factions.get().isDatabaseInitialized()) return; - Faction before = null; - Faction after = this.getFaction(); - this.updateFactionIndexes(before, after); + String beforeId = null; + String afterId = this.getFactionId(); + this.updateFactionIndexes(beforeId, afterId); } - + @Override public void preDetach(String id) { - if (!Factions.get().isDatabaseInitialized()) return; - Faction before = this.getFaction(); - Faction after = null; + String before = this.getFactionId(); + String after = null; this.updateFactionIndexes(before, after); } - + // -------------------------------------------- // // FIELDS: RAW // -------------------------------------------- // // In this section of the source code we place the field declarations only. // Each field has it's own section further down since just the getter and setter logic takes up quite some place. - + // The last known time of explicit player activity, such as login or logout. // This value is most importantly used for removing inactive players. // For that reason it defaults to the current time. @@ -132,70 +139,71 @@ public class MPlayer extends SenderEntity implements EconomyParticipato // There is actually more than one reason we store this data ourselves and don't use the OfflinePlayer#getLastPlayed. // 1. I don't trust that method. It's been very buggy or even completely broken in previous Bukkit versions. // 2. The method depends on the player.dat files being present. - // Server owners clear those files at times, or move their database data around between different servers. + // Server owners clear those files at times, or move their database data around between different servers. private long lastActivityMillis = System.currentTimeMillis(); - + // This is a foreign key. // Each player belong to a faction. // Null means default. private String factionId = null; - + // What role does the player have in the faction? // Null means default. private Rel role = null; - + // What title does the player have in the faction? // The title is just for fun. It's not connected to any game mechanic. // The player title is similar to the faction description. - // + // // Question: Can the title contain chat colors? // Answer: Yes but in such case the policy is that they already must be parsed using Txt.parse. - // If the title contains raw markup, such as "" instead of "§f" it will not be parsed and "" will be displayed. + // If the title contains raw markup, such as "" instead of "§f" it will not be parsed and "" will be displayed. // // Null means the player has no title. private String title = null; - + // Player usually do not have a powerboost. It defaults to 0. // The powerBoost is a custom increase/decrease to default and maximum power. // Note that player powerBoost and faction powerBoost are very similar. - private Double powerBoost = null; - + private Double powerBoost = null; + // Each player has an individual power level. // The power level for online players is occasionally updated by a recurring task and the power should stay the same for offline players. // For that reason the value is to be considered correct when you pick it. Do not call the power update method. // Null means default. private Double power = null; - + // Has this player requested an auto-updating ascii art map? // Null means false private Boolean mapAutoUpdating = null; - + // Is this player overriding? // Null means false @SerializedName(value = "usingAdminMode") private Boolean overriding = null; - + // Does this player use titles for territory info? // Null means default specified in MConf. private Boolean territoryInfoTitles = null; - + // The id for the faction this player is currently autoclaiming for. // Null means the player isn't auto claiming. // NOTE: This field will not be saved to the database ever. private transient Faction autoClaimFaction = null; + public Faction getAutoClaimFaction() { return this.autoClaimFaction; } public void setAutoClaimFaction(Faction autoClaimFaction) { this.autoClaimFaction = autoClaimFaction; } - + // Does the player have /f seechunk activated? // NOTE: This field will not be saved to the database ever. private transient boolean seeingChunk = false; public boolean isSeeingChunk() { return this.seeingChunk; } public void setSeeingChunk(boolean seeingChunk) { this.seeingChunk = seeingChunk; } - + // -------------------------------------------- // // CORE UTILITIES // -------------------------------------------- // - + public void resetFactionData() { // The default neutral faction @@ -204,53 +212,53 @@ public class MPlayer extends SenderEntity implements EconomyParticipato this.setTitle(null); this.setAutoClaimFaction(null); } - + // -------------------------------------------- // // FIELD: lastActivityMillis // -------------------------------------------- // - + public long getLastActivityMillis() { return this.lastActivityMillis; } - + public void setLastActivityMillis(long lastActivityMillis) { // Clean input long target = lastActivityMillis; - + // Detect Nochange if (MUtil.equals(this.lastActivityMillis, target)) return; - + // Apply this.lastActivityMillis = target; - + // Mark as changed this.changed(); } - + public void setLastActivityMillis() { this.setLastActivityMillis(System.currentTimeMillis()); } - + // -------------------------------------------- // // FIELD: factionId // -------------------------------------------- // - + @Deprecated public String getDefaultFactionId() { return MConf.get().defaultPlayerFactionId; } - + // This method never returns null public String getFactionId() { if (this.factionId == null) return MConf.get().defaultPlayerFactionId; return this.factionId; } - + // This method never returns null public Faction getFaction() { @@ -258,113 +266,96 @@ public class MPlayer extends SenderEntity implements EconomyParticipato if (ret == null) ret = Faction.get(MConf.get().defaultPlayerFactionId); return ret; } - + public boolean hasFaction() { return !this.getFactionId().equals(Factions.ID_NONE); } - - // This setter is so long because it search for default/null case and takes care of updating the faction member index + + // This setter is so long because it search for default/null case and takes + // care of updating the faction member index public void setFactionId(String factionId) { - // Clean input - String target = factionId; + // Before + String beforeId = this.factionId; + + // After + String afterId = factionId; + + // NoChange + if (MUtil.equals(beforeId, afterId)) return; - // Detect Nochange - if (MUtil.equals(this.factionId, target)) return; - - // Get the raw old value - String oldFactionId = this.factionId; - // Apply - this.factionId = target; - - // Must be attached and initialized + this.factionId = afterId; + + // Must be attached and initialized if (!this.attached()) return; if (!Factions.get().isDatabaseInitialized()) return; - - if (oldFactionId == null) oldFactionId = MConf.get().defaultPlayerFactionId; - + + if (beforeId == null) beforeId = MConf.get().defaultPlayerFactionId; + // Update index - Faction oldFaction = Faction.get(oldFactionId); - Faction faction = this.getFaction(); - - if (oldFaction != null) oldFaction.mplayers.remove(this); - if (faction != null) faction.mplayers.add(this); - - /* - String oldFactionIdDesc = "NULL"; - String oldFactionNameDesc = "NULL"; - if (oldFaction != null) - { - oldFactionIdDesc = oldFaction.getId(); - oldFactionNameDesc = oldFaction.getName(); - } - String factionIdDesc = "NULL"; - String factionNameDesc = "NULL"; - if (faction != null) - { - factionIdDesc = faction.getId(); - factionNameDesc = faction.getName(); - } - Factions.get().log(Txt.parse("setFactionId moved %s aka %s from %s aka %s to %s aka %s.", this.getId(), this.getDisplayName(IdUtil.getConsole()), oldFactionIdDesc, oldFactionNameDesc, factionIdDesc, factionNameDesc)); - */ - + Faction before = Faction.get(beforeId); + Faction after = this.getFaction(); + + if (before != null) before.mplayers.remove(this); + if (after != null) after.mplayers.add(this); + // Mark as changed this.changed(); } - + public void setFaction(Faction faction) { this.setFactionId(faction.getId()); } - + // -------------------------------------------- // // FIELD: role // -------------------------------------------- // - + @Deprecated public Rel getDefaultRole() { return MConf.get().defaultPlayerRole; } - + public Rel getRole() { if (this.role == null) return MConf.get().defaultPlayerRole; return this.role; } - + public void setRole(Rel role) { // Clean input Rel target = role; - + // Detect Nochange if (MUtil.equals(this.role, target)) return; - + // Apply this.role = target; - + // Mark as changed this.changed(); } - + // -------------------------------------------- // // FIELD: title // -------------------------------------------- // - + public boolean hasTitle() { return this.title != null; } - + public String getTitle() { if (this.hasTitle()) return this.title; return Lang.PLAYER_NOTITLE; } - + public void setTitle(String title) { // Clean input @@ -377,120 +368,122 @@ public class MPlayer extends SenderEntity implements EconomyParticipato target = null; } } - - // NOTE: That we parse the title here is considered part of the 1.8 --> 2.0 migration. - // This should be removed once the migration phase is considered to be over. + + // NOTE: That we parse the title here is considered part of the 1.8 --> + // 2.0 migration. + // This should be removed once the migration phase is considered to be + // over. if (target != null) { target = Txt.parse(target); } - + // Detect Nochange if (MUtil.equals(this.title, target)) return; - + // Apply this.title = target; - + // Mark as changed this.changed(); } - + // -------------------------------------------- // // FIELD: powerBoost // -------------------------------------------- // - + public double getPowerBoost() { Double ret = this.powerBoost; if (ret == null) ret = 0D; return ret; } - + public void setPowerBoost(Double powerBoost) { // Clean input Double target = powerBoost; if (target == null || target == 0) target = null; - + // Detect Nochange if (MUtil.equals(this.powerBoost, target)) return; - + // Apply this.powerBoost = target; - + // Mark as changed this.changed(); } - + public boolean hasPowerBoost() { return this.getPowerBoost() != 0D; } - + // -------------------------------------------- // // FIELD: power // -------------------------------------------- // - + // MIXIN: RAW - + public double getPowerMaxUniversal() { return Factions.get().getPowerMixin().getMaxUniversal(this); } - + public double getPowerMax() { return Factions.get().getPowerMixin().getMax(this); } - + public double getPowerMin() { return Factions.get().getPowerMixin().getMin(this); } - + public double getPowerPerHour() { return Factions.get().getPowerMixin().getPerHour(this); } - + public double getPowerPerDeath() { return Factions.get().getPowerMixin().getPerDeath(this); } - + // MIXIN: FINER - + public double getLimitedPower(double power) { power = Math.max(power, this.getPowerMin()); power = Math.min(power, this.getPowerMax()); - + return power; } - + public int getPowerMaxRounded() { return (int) Math.round(this.getPowerMax()); } - + public int getPowerMinRounded() { return (int) Math.round(this.getPowerMin()); } - + public int getPowerMaxUniversalRounded() { return (int) Math.round(this.getPowerMaxUniversal()); } - + // RAW - + @Deprecated public double getDefaultPower() { return MConf.get().defaultPlayerPower; } - + public double getPower() { Double ret = this.power; @@ -498,130 +491,130 @@ public class MPlayer extends SenderEntity implements EconomyParticipato ret = this.getLimitedPower(ret); return ret; } - + public void setPower(Double power) { // Clean input Double target = power; - + // Detect Nochange if (MUtil.equals(this.power, target)) return; - + // Apply this.power = target; - + // Mark as changed this.changed(); } - + // FINER - + public int getPowerRounded() { return (int) Math.round(this.getPower()); } - + // -------------------------------------------- // // FIELD: mapAutoUpdating // -------------------------------------------- // - + public boolean isMapAutoUpdating() { if (this.mapAutoUpdating == null) return false; if (this.mapAutoUpdating == false) return false; return true; } - + public void setMapAutoUpdating(Boolean mapAutoUpdating) { // Clean input Boolean target = mapAutoUpdating; if (MUtil.equals(target, false)) target = null; - + // Detect Nochange if (MUtil.equals(this.mapAutoUpdating, target)) return; - + // Apply this.mapAutoUpdating = target; - + // Mark as changed this.changed(); } - + // -------------------------------------------- // // FIELD: overriding // -------------------------------------------- // - + public boolean isOverriding() { if (this.overriding == null) return false; if (this.overriding == false) return false; - + if (!this.hasPermission(Perm.OVERRIDE, true)) { this.setOverriding(false); return false; } - + return true; } - + public void setOverriding(Boolean overriding) { // Clean input Boolean target = overriding; if (MUtil.equals(target, false)) target = null; - + // Detect Nochange if (MUtil.equals(this.overriding, target)) return; - + // Apply this.overriding = target; - + // Mark as changed this.changed(); } - + // -------------------------------------------- // // FIELD: territoryInfoTitles // -------------------------------------------- // - + public boolean isTerritoryInfoTitles() { - if ( ! MixinTitle.get().isAvailable()) return false; + if (!MixinTitle.get().isAvailable()) return false; if (this.territoryInfoTitles == null) return MConf.get().territoryInfoTitlesDefault; return this.territoryInfoTitles; } - + public void setTerritoryInfoTitles(Boolean territoryInfoTitles) { // Clean input Boolean target = territoryInfoTitles; if (MUtil.equals(target, MConf.get().territoryInfoTitlesDefault)) target = null; - + // Detect Nochange if (MUtil.equals(this.territoryInfoTitles, target)) return; - + // Apply this.territoryInfoTitles = target; - + // Mark as changed this.changed(); } - + // -------------------------------------------- // // TITLE, NAME, FACTION NAME AND CHAT // -------------------------------------------- // - + public String getFactionName() { Faction faction = this.getFaction(); if (faction.isNone()) return ""; return faction.getName(); } - + // Base concatenations: - + public String getNameAndSomething(String color, String something) { String ret = ""; @@ -636,12 +629,12 @@ public class MPlayer extends SenderEntity implements EconomyParticipato ret += this.getName(); return ret; } - + public String getNameAndFactionName() { return this.getNameAndSomething("", this.getFactionName()); } - + public String getNameAndTitle(String color) { if (this.hasTitle()) @@ -653,57 +646,58 @@ public class MPlayer extends SenderEntity implements EconomyParticipato return this.getNameAndSomething(color, null); } } - + // Colored concatenations: // These are used in information messages - + public String getNameAndTitle(Faction faction) { return this.getNameAndTitle(this.getColorTo(faction).toString()); } + public String getNameAndTitle(MPlayer mplayer) { return this.getNameAndTitle(this.getColorTo(mplayer).toString()); } - + // -------------------------------------------- // // RELATION AND RELATION COLORS // -------------------------------------------- // - + @Override public String describeTo(RelationParticipator observer, boolean ucfirst) { return RelationUtil.describeThatToMe(this, observer, ucfirst); } - + @Override public String describeTo(RelationParticipator observer) { return RelationUtil.describeThatToMe(this, observer); } - + @Override public Rel getRelationTo(RelationParticipator observer) { return RelationUtil.getRelationOfThatToMe(this, observer); } - + @Override public Rel getRelationTo(RelationParticipator observer, boolean ignorePeaceful) { return RelationUtil.getRelationOfThatToMe(this, observer, ignorePeaceful); } - + @Override public ChatColor getColorTo(RelationParticipator observer) { return RelationUtil.getColorOfThatToMe(this, observer); } - + // -------------------------------------------- // // HEALTH // -------------------------------------------- // - + public void heal(int amnt) { Player player = this.getPlayer(); @@ -713,11 +707,11 @@ public class MPlayer extends SenderEntity implements EconomyParticipato } player.setHealth(player.getHealth() + amnt); } - + // -------------------------------------------- // // TERRITORY // -------------------------------------------- // - + public boolean isInOwnTerritory() { PS ps = MixinSenderPs.get().getSenderPs(this.getId()); @@ -731,32 +725,33 @@ public class MPlayer extends SenderEntity implements EconomyParticipato if (ps == null) return false; return BoardColl.get().getFactionAt(ps).getRelationTo(this) == Rel.ENEMY; } - + // -------------------------------------------- // // INACTIVITY TIMEOUT // -------------------------------------------- // - + public long getRemovePlayerMillis(boolean async) { EventFactionsRemovePlayerMillis event = new EventFactionsRemovePlayerMillis(async, this); event.run(); return event.getMillis(); } - + public boolean considerRemovePlayerMillis(boolean async) { // This may or may not be required. - // Some users have been reporting a loop issue with the same player detaching over and over again. + // Some users have been reporting a loop issue with the same player + // detaching over and over again. // Maybe skipping ahead if the player is detached will solve the issue. if (this.detached()) return false; - + // Get the last activity millis. long lastActivityMillis = this.getLastActivityMillis(); - + // Consider long toleranceMillis = this.getRemovePlayerMillis(async); if (System.currentTimeMillis() - lastActivityMillis <= toleranceMillis) return false; - + // Inform if (MConf.get().logFactionLeave || MConf.get().logFactionKick) { @@ -764,7 +759,7 @@ public class MPlayer extends SenderEntity implements EconomyParticipato } // Apply - + // Promote a new leader if required. if (this.getRole() == Rel.LEADER) { @@ -777,20 +772,20 @@ public class MPlayer extends SenderEntity implements EconomyParticipato this.leave(); this.detach(); - + return true; } - + // -------------------------------------------- // // ACTIONS // -------------------------------------------- // - + public void leave() { Faction myFaction = this.getFaction(); boolean permanent = myFaction.getFlag(MFlag.getFlagPermanent()); - + if (myFaction.getMPlayers().size() > 1) { if (!permanent && this.getRole() == Rel.LEADER) @@ -798,7 +793,7 @@ public class MPlayer extends SenderEntity implements EconomyParticipato msg("You must give the leader role to someone else first."); return; } - + if (!MConf.get().canLeaveWithNegativePower && this.getPower() < 0) { msg("You cannot leave until your power is positive."); @@ -810,7 +805,7 @@ public class MPlayer extends SenderEntity implements EconomyParticipato EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE); membershipChangeEvent.run(); if (membershipChangeEvent.isCancelled()) return; - + if (myFaction.isNormal()) { for (MPlayer mplayer : myFaction.getMPlayersWhereOnline(true)) @@ -820,49 +815,49 @@ public class MPlayer extends SenderEntity implements EconomyParticipato if (MConf.get().logFactionLeave) { - Factions.get().log(this.getName()+" left the faction: "+myFaction.getName()); + Factions.get().log(this.getName() + " left the faction: " + myFaction.getName()); } } - + this.resetFactionData(); if (myFaction.isNormal() && !permanent && myFaction.getMPlayers().isEmpty()) { EventFactionsDisband eventFactionsDisband = new EventFactionsDisband(this.getSender(), myFaction); eventFactionsDisband.run(); - if ( ! eventFactionsDisband.isCancelled()) + if (!eventFactionsDisband.isCancelled()) { // Remove this faction this.msg("%s was disbanded since you were the last player.", myFaction.describeTo(this, true)); if (MConf.get().logFactionDisband) { - Factions.get().log("The faction "+myFaction.getName()+" ("+myFaction.getId()+") was disbanded due to the last player ("+this.getName()+") leaving."); + Factions.get().log("The faction " + myFaction.getName() + " (" + myFaction.getId() + ") was disbanded due to the last player (" + this.getName() + ") leaving."); } myFaction.detach(); - } + } } } - + // NEW public boolean tryClaim(Faction newFaction, Collection pss) { return this.tryClaim(newFaction, pss, null, null); } - + public boolean tryClaim(Faction newFaction, Collection pss, String formatOne, String formatMany) { // Args if (formatOne == null) formatOne = "%s %s %d chunk %s."; if (formatMany == null) formatMany = "%s %s %d chunks near %s."; - + if (newFaction == null) throw new NullPointerException("newFaction"); - + if (pss == null) throw new NullPointerException("pss"); final Set chunks = PS.getDistinctChunks(pss); - + // NoChange // We clean the chunks further by removing what does not change. - // This is also very suggested cleaning of EventFactionsChunksChange input. + // This is also very suggested cleaning of EventFactionsChunksChange input. Iterator iter = chunks.iterator(); while (iter.hasNext()) { @@ -875,7 +870,7 @@ public class MPlayer extends SenderEntity implements EconomyParticipato msg("%s already owns this land.", newFaction.describeTo(this, true)); return true; } - + // Event // NOTE: We listen to this event ourselves at LOW. // NOTE: That is where we apply the standard checks. @@ -892,13 +887,13 @@ public class MPlayer extends SenderEntity implements EconomyParticipato EventFactionsChunksChange event = new EventFactionsChunksChange(sender, chunks, newFaction); event.run(); if (event.isCancelled()) return false; - + // Apply for (PS chunk : chunks) { BoardColl.get().setFactionAt(chunk, newFaction); } - + // Inform for (Entry> entry : event.getOldFactionChunks().entrySet()) { @@ -907,44 +902,44 @@ public class MPlayer extends SenderEntity implements EconomyParticipato final PS oldChunk = oldChunks.iterator().next(); final Set informees = getClaimInformees(this, oldFaction, newFaction); final EventFactionsChunkChangeType type = EventFactionsChunkChangeType.get(oldFaction, newFaction, this.getFaction()); - + String chunkString = oldChunk.toString(PSFormatHumanSpace.get()); String typeString = type.past; - + for (MPlayer informee : informees) { informee.msg((oldChunks.size() == 1 ? formatOne : formatMany), this.describeTo(informee, true), typeString, oldChunks.size(), chunkString); informee.msg(" %s --> %s", oldFaction.describeTo(informee, true), newFaction.describeTo(informee, true)); } } - + // Success return true; } - + // -------------------------------------------- // // UTIL // -------------------------------------------- // - + public static Set getClaimInformees(MPlayer msender, Faction... factions) { Set ret = new HashSet(); - + if (msender != null) ret.add(msender); - + for (Faction faction : factions) { if (faction == null) continue; if (faction.isNone()) continue; ret.addAll(faction.getMPlayers()); } - + if (MConf.get().logLandClaims) { ret.add(MPlayer.get(IdUtil.getConsole())); } - + return ret; } - + } diff --git a/src/com/massivecraft/factions/entity/MPlayerColl.java b/src/com/massivecraft/factions/entity/MPlayerColl.java index 292e09cd..de2b4b0a 100644 --- a/src/com/massivecraft/factions/entity/MPlayerColl.java +++ b/src/com/massivecraft/factions/entity/MPlayerColl.java @@ -43,9 +43,9 @@ public class MPlayerColl extends SenderColl if (mplayer != null) { - Faction before = mplayer.getFaction(); - Faction after = null; - mplayer.updateFactionIndexes(before, after); + String beforeId = mplayer.getFactionId(); + String afterId = null; + mplayer.updateFactionIndexes(beforeId, afterId); } return super.removeAtLocalFixed(id); @@ -63,20 +63,20 @@ public class MPlayerColl extends SenderColl MPlayer mplayer = null; // Before - Faction before = null; + String beforeId = null; if (mplayer == null) mplayer = this.id2entity.get(id); - if (mplayer != null) before = mplayer.getFaction(); + if (mplayer != null) beforeId = mplayer.getFactionId(); // Super super.loadFromRemoteFixed(id, remoteEntry); // After - Faction after = null; + String afterId = null; if (mplayer == null) mplayer = this.id2entity.get(id); - if (mplayer != null) after = mplayer.getFaction(); + if (mplayer != null) afterId = mplayer.getFactionId(); // Perform - if (mplayer != null) mplayer.updateFactionIndexes(before, after); + if (mplayer != null) mplayer.updateFactionIndexes(beforeId, afterId); } // -------------------------------------------- //