From 1ec7842ed4326f396d7b42c0a8be3d86754abdbc Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Mon, 24 Oct 2011 03:15:08 +0200 Subject: [PATCH] Removed the strange usage of selective saving and implemented a good simple one. --- src/com/massivecraft/factions/FPlayer.java | 27 +++---------------- src/com/massivecraft/factions/FPlayers.java | 1 - .../listeners/FactionsPlayerListener.java | 3 +-- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index 8ef07fa2..b05e10e2 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -33,10 +33,9 @@ import com.nijikokun.register.payment.Method.MethodAccount; */ // TODO: The players are saved in non order. -// TODO: To many players are saved. There must be ways to improve the selective saving functionality. public class FPlayer extends PlayerEntity implements EconomyParticipator { - //private transient String playerName; + // FIELD: lastStoodAt private transient FLocation lastStoodAt = new FLocation(); // Where did this player stand the last time we checked? public FLocation getLastStoodAt() { return this.lastStoodAt; } public void setLastStoodAt(FLocation flocation) { this.lastStoodAt = flocation; } @@ -71,14 +70,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator // FIELD: lastLoginTime private long lastLoginTime; - - - - - - - - // FIELD: mapAutoUpdating private transient boolean mapAutoUpdating; public void setMapAutoUpdating(boolean mapAutoUpdating) { this.mapAutoUpdating = mapAutoUpdating; } @@ -96,11 +87,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator // FIELD: loginPvpDisabled private transient boolean loginPvpDisabled; - // FIELD: deleteMe - // TODO: This is not the way it is meant to be used... Check out the selective saving and improve it - private transient boolean deleteMe; - public void markForDeletion(boolean delete) { deleteMe = delete; } - // FIELD: chatMode private ChatMode chatMode; public void setChatMode(ChatMode chatMode) { this.chatMode = chatMode; } @@ -134,7 +120,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator this.mapAutoUpdating = false; this.autoClaimFor = null; this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false; - this.deleteMe = false; if ( ! Conf.newPlayerStartingFactionID.equals("0") && Factions.i.exists(Conf.newPlayerStartingFactionID)) { @@ -198,14 +183,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator //----------------------------------------------// // Title, Name, Faction Tag and Chat //----------------------------------------------// - - // Base: - - - public String getName() { - return getId(); // TODO: ... display name or remove completeley + return getId(); } public String getTag() @@ -669,7 +649,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator @Override public boolean shouldBeSaved() { - return ! this.deleteMe; + if (this.hasFaction()) return true; + return false; } public void msg(String str, Object... args) diff --git a/src/com/massivecraft/factions/FPlayers.java b/src/com/massivecraft/factions/FPlayers.java index 08d5b94d..d21d3bde 100644 --- a/src/com/massivecraft/factions/FPlayers.java +++ b/src/com/massivecraft/factions/FPlayers.java @@ -62,7 +62,6 @@ public class FPlayers extends PlayerEntityCollection if (now - fplayer.getLastLoginTime() > toleranceMillis) { fplayer.leave(false); - fplayer.markForDeletion(true); } } } diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 01e7c5d1..59ba6c0c 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -402,7 +402,7 @@ public class FactionsPlayerListener extends PlayerListener } return false; } - + @Override public void onPlayerKick(PlayerKickEvent event) { @@ -420,7 +420,6 @@ public class FactionsPlayerListener extends PlayerListener if (event.getReason().equals("Banned by admin.")) { badGuy.leave(false); - badGuy.markForDeletion(true); } } }