Removed the strange usage of selective saving and implemented a good simple one.

This commit is contained in:
Olof Larsson 2011-10-24 03:15:08 +02:00
parent 074be07510
commit 1ec7842ed4
3 changed files with 5 additions and 26 deletions

View File

@ -33,10 +33,9 @@ import com.nijikokun.register.payment.Method.MethodAccount;
*/ */
// TODO: The players are saved in non order. // 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 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? private transient FLocation lastStoodAt = new FLocation(); // Where did this player stand the last time we checked?
public FLocation getLastStoodAt() { return this.lastStoodAt; } public FLocation getLastStoodAt() { return this.lastStoodAt; }
public void setLastStoodAt(FLocation flocation) { this.lastStoodAt = flocation; } public void setLastStoodAt(FLocation flocation) { this.lastStoodAt = flocation; }
@ -71,14 +70,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
// FIELD: lastLoginTime // FIELD: lastLoginTime
private long lastLoginTime; private long lastLoginTime;
// FIELD: mapAutoUpdating // FIELD: mapAutoUpdating
private transient boolean mapAutoUpdating; private transient boolean mapAutoUpdating;
public void setMapAutoUpdating(boolean mapAutoUpdating) { this.mapAutoUpdating = mapAutoUpdating; } public void setMapAutoUpdating(boolean mapAutoUpdating) { this.mapAutoUpdating = mapAutoUpdating; }
@ -96,11 +87,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
// FIELD: loginPvpDisabled // FIELD: loginPvpDisabled
private transient boolean 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 // FIELD: chatMode
private ChatMode chatMode; private ChatMode chatMode;
public void setChatMode(ChatMode chatMode) { this.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.mapAutoUpdating = false;
this.autoClaimFor = null; this.autoClaimFor = null;
this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false; this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false;
this.deleteMe = false;
if ( ! Conf.newPlayerStartingFactionID.equals("0") && Factions.i.exists(Conf.newPlayerStartingFactionID)) 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 // Title, Name, Faction Tag and Chat
//----------------------------------------------// //----------------------------------------------//
// Base:
public String getName() public String getName()
{ {
return getId(); // TODO: ... display name or remove completeley return getId();
} }
public String getTag() public String getTag()
@ -669,7 +649,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
@Override @Override
public boolean shouldBeSaved() public boolean shouldBeSaved()
{ {
return ! this.deleteMe; if (this.hasFaction()) return true;
return false;
} }
public void msg(String str, Object... args) public void msg(String str, Object... args)

View File

@ -62,7 +62,6 @@ public class FPlayers extends PlayerEntityCollection<FPlayer>
if (now - fplayer.getLastLoginTime() > toleranceMillis) if (now - fplayer.getLastLoginTime() > toleranceMillis)
{ {
fplayer.leave(false); fplayer.leave(false);
fplayer.markForDeletion(true);
} }
} }
} }

View File

@ -402,7 +402,7 @@ public class FactionsPlayerListener extends PlayerListener
} }
return false; return false;
} }
@Override @Override
public void onPlayerKick(PlayerKickEvent event) public void onPlayerKick(PlayerKickEvent event)
{ {
@ -420,7 +420,6 @@ public class FactionsPlayerListener extends PlayerListener
if (event.getReason().equals("Banned by admin.")) if (event.getReason().equals("Banned by admin."))
{ {
badGuy.leave(false); badGuy.leave(false);
badGuy.markForDeletion(true);
} }
} }
} }