When a player is kicked from their faction by the autoLeaveAfterDaysOfInactivity routine, the rest of their stored data is now dropped as well

When a player is banned from the server, they will now be kicked from their faction and have their stored data removed (only works on CB 1240 or newer)
This commit is contained in:
Brettflan 2011-10-05 00:33:15 -05:00
parent 7c249e1884
commit 149257f154
3 changed files with 32 additions and 4 deletions

View File

@ -51,6 +51,7 @@ public class FPlayer {
private transient boolean autoSafeZoneEnabled;
private transient boolean autoWarZoneEnabled;
private transient boolean loginPvpDisabled;
private transient boolean deleteMe;
private ChatMode chatMode;
// -------------------------------------------- //
@ -68,6 +69,7 @@ public class FPlayer {
this.autoSafeZoneEnabled = false;
this.autoWarZoneEnabled = false;
this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false;
this.deleteMe = false;
if (Conf.newPlayerStartingFactionID > 0 && Faction.exists(Conf.newPlayerStartingFactionID)) {
this.factionId = Conf.newPlayerStartingFactionID;
@ -227,6 +229,10 @@ public class FPlayer {
this.lastStoodAt = flocation;
}
public void markForDeletion(boolean delete) {
deleteMe = delete;
}
//----------------------------------------------//
// Title, Name, Faction Tag and Chat
//----------------------------------------------//
@ -720,9 +726,7 @@ public class FPlayer {
// -------------------------------------------- //
public boolean shouldBeSaved() {
// return this.factionId != 0;
// we now need to track all players, so they don't get stuck back into a default faction if factionless; also to keep track of lost power and such
return true;
return !deleteMe;
}
public static boolean save() {
@ -797,6 +801,7 @@ public class FPlayer {
for (FPlayer fplayer : FPlayer.getAll()) {
if (now - fplayer.getLastLoginTime() > toleranceMillis) {
fplayer.leave(false);
fplayer.markForDeletion(true);
}
}
}

View File

@ -594,6 +594,11 @@ public class Faction {
return false;
}
//----------------------------------------------//
// Bank functions
//----------------------------------------------//
public double getMoney() {
return this.money;
}

View File

@ -17,6 +17,7 @@ import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -510,4 +511,21 @@ public class FactionsPlayerListener extends PlayerListener{
return false;
}
@Override
public void onPlayerKick(PlayerKickEvent event) {
if (event.isCancelled()) {
return;
}
// if player was banned (not just kicked), get rid of their stored info
if (event.getReason().equals("Banned by admin.")) {
FPlayer badGuy = FPlayer.get(event.getPlayer());
if (badGuy == null) {
return;
}
badGuy.leave(false);
badGuy.markForDeletion(true);
}
}
}