mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 10:05:59 +00:00
Save and remove player entries on leave
Removed timer for player loading, applied to plugin instead
This commit is contained in:
parent
b6d3e5baca
commit
0240b65fad
@ -1,4 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Tue Aug 26 18:22:59 CEST 2014
|
#Wed Aug 27 00:27:30 CEST 2014
|
||||||
build.number=935
|
build.number=939
|
||||||
|
|
||||||
|
@ -733,41 +733,33 @@ public class TFM_PlayerListener implements Listener
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerKick(PlayerKickEvent event)
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
playerLeave(event.getPlayer());
|
||||||
|
|
||||||
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player))
|
|
||||||
{
|
|
||||||
TotalFreedomMod.fuckoffEnabledFor.remove(player);
|
|
||||||
}
|
|
||||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
|
||||||
playerdata.disarmMP44();
|
|
||||||
if (playerdata.isCaged())
|
|
||||||
{
|
|
||||||
playerdata.regenerateHistory();
|
|
||||||
playerdata.clearHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
TFM_Log.info("[EXIT] " + player.getName() + " left the game.", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
playerLeave(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playerLeave(Player player)
|
||||||
|
{
|
||||||
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player))
|
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player))
|
||||||
{
|
{
|
||||||
TotalFreedomMod.fuckoffEnabledFor.remove(player);
|
TotalFreedomMod.fuckoffEnabledFor.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||||
|
|
||||||
playerdata.disarmMP44();
|
playerdata.disarmMP44();
|
||||||
|
|
||||||
if (playerdata.isCaged())
|
if (playerdata.isCaged())
|
||||||
{
|
{
|
||||||
playerdata.regenerateHistory();
|
playerdata.regenerateHistory();
|
||||||
playerdata.clearHistory();
|
playerdata.clearHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TFM_PlayerList.removeEntry(player);
|
||||||
TFM_Log.info("[EXIT] " + player.getName() + " left the game.", true);
|
TFM_Log.info("[EXIT] " + player.getName() + " left the game.", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class TFM_PlayerList
|
public class TFM_PlayerList
|
||||||
{
|
{
|
||||||
private static final Map<UUID, TFM_Player> playerList = new HashMap<UUID, TFM_Player>();
|
private static final Map<UUID, TFM_Player> PLAYER_LIST = new HashMap<UUID, TFM_Player>();
|
||||||
|
|
||||||
private TFM_PlayerList()
|
private TFM_PlayerList()
|
||||||
{
|
{
|
||||||
@ -22,15 +22,12 @@ public class TFM_PlayerList
|
|||||||
|
|
||||||
public static Set<TFM_Player> getAllPlayers()
|
public static Set<TFM_Player> getAllPlayers()
|
||||||
{
|
{
|
||||||
return Collections.unmodifiableSet(Sets.newHashSet(playerList.values()));
|
return Collections.unmodifiableSet(Sets.newHashSet(PLAYER_LIST.values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void load()
|
public static void load()
|
||||||
{
|
{
|
||||||
final TFM_Util.MethodTimer timer = new TFM_Util.MethodTimer();
|
PLAYER_LIST.clear();
|
||||||
timer.start();
|
|
||||||
|
|
||||||
playerList.clear();
|
|
||||||
|
|
||||||
// Load online players
|
// Load online players
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
@ -38,14 +35,12 @@ public class TFM_PlayerList
|
|||||||
getEntry(player);
|
getEntry(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
timer.update();
|
TFM_Log.info("Loaded playerdata for " + PLAYER_LIST.size() + " players");
|
||||||
|
|
||||||
TFM_Log.info("Loaded playerdata for " + playerList.size() + " players in " + timer.getTotal() + " ms");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveAll()
|
public static void saveAll()
|
||||||
{
|
{
|
||||||
for (TFM_Player entry : playerList.values())
|
for (TFM_Player entry : PLAYER_LIST.values())
|
||||||
{
|
{
|
||||||
save(entry);
|
save(entry);
|
||||||
}
|
}
|
||||||
@ -54,9 +49,9 @@ public class TFM_PlayerList
|
|||||||
// May return null
|
// May return null
|
||||||
public static TFM_Player getEntry(UUID uuid)
|
public static TFM_Player getEntry(UUID uuid)
|
||||||
{
|
{
|
||||||
if (playerList.containsKey(uuid))
|
if (PLAYER_LIST.containsKey(uuid))
|
||||||
{
|
{
|
||||||
return playerList.get(uuid);
|
return PLAYER_LIST.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
final File configFile = getConfigFile(uuid);
|
final File configFile = getConfigFile(uuid);
|
||||||
@ -70,7 +65,7 @@ public class TFM_PlayerList
|
|||||||
|
|
||||||
if (entry.isComplete())
|
if (entry.isComplete())
|
||||||
{
|
{
|
||||||
playerList.put(uuid, entry);
|
PLAYER_LIST.put(uuid, entry);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -101,11 +96,25 @@ public class TFM_PlayerList
|
|||||||
entry.addIp(TFM_Util.getIp(player));
|
entry.addIp(TFM_Util.getIp(player));
|
||||||
|
|
||||||
save(entry);
|
save(entry);
|
||||||
playerList.put(uuid, entry);
|
PLAYER_LIST.put(uuid, entry);
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeEntry(Player player)
|
||||||
|
{
|
||||||
|
final UUID uuid = TFM_Util.getUniqueId(player);
|
||||||
|
|
||||||
|
if (!PLAYER_LIST.containsKey(uuid))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
save(PLAYER_LIST.get(uuid));
|
||||||
|
|
||||||
|
PLAYER_LIST.remove(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean existsEntry(Player player)
|
public static boolean existsEntry(Player player)
|
||||||
{
|
{
|
||||||
return existsEntry(TFM_Util.getUniqueId(player));
|
return existsEntry(TFM_Util.getUniqueId(player));
|
||||||
@ -123,10 +132,10 @@ public class TFM_PlayerList
|
|||||||
throw new IllegalArgumentException("Cannot set new UUID: UUIDs match");
|
throw new IllegalArgumentException("Cannot set new UUID: UUIDs match");
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean reAdd = playerList.containsKey(entry.getUniqueId());
|
final boolean reAdd = PLAYER_LIST.containsKey(entry.getUniqueId());
|
||||||
playerList.remove(entry.getUniqueId());
|
PLAYER_LIST.remove(entry.getUniqueId());
|
||||||
|
|
||||||
final TFM_Player newPlayer = new TFM_Player(
|
final TFM_Player newEntry = new TFM_Player(
|
||||||
newUuid,
|
newUuid,
|
||||||
entry.getFirstLoginName(),
|
entry.getFirstLoginName(),
|
||||||
entry.getLastLoginName(),
|
entry.getLastLoginName(),
|
||||||
@ -136,10 +145,10 @@ public class TFM_PlayerList
|
|||||||
|
|
||||||
if (reAdd)
|
if (reAdd)
|
||||||
{
|
{
|
||||||
playerList.put(newUuid, newPlayer);
|
PLAYER_LIST.put(newUuid, newEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
newPlayer.save();
|
newEntry.save();
|
||||||
|
|
||||||
if (!getConfigFile(entry.getUniqueId()).delete())
|
if (!getConfigFile(entry.getUniqueId()).delete())
|
||||||
{
|
{
|
||||||
|
@ -70,6 +70,9 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
TFM_Log.info("Made by Madgeek1450 and DarthSalamon");
|
TFM_Log.info("Made by Madgeek1450 and DarthSalamon");
|
||||||
TFM_Log.info("Compiled " + buildDate + " by " + buildCreator);
|
TFM_Log.info("Compiled " + buildDate + " by " + buildCreator);
|
||||||
|
|
||||||
|
final TFM_Util.MethodTimer timer = new TFM_Util.MethodTimer();
|
||||||
|
timer.start();
|
||||||
|
|
||||||
if (!TFM_ServerInterface.COMPILE_NMS_VERSION.equals(TFM_Util.getNmsVersion()))
|
if (!TFM_ServerInterface.COMPILE_NMS_VERSION.equals(TFM_Util.getNmsVersion()))
|
||||||
{
|
{
|
||||||
TFM_Log.warning(pluginName + " is compiled for " + TFM_ServerInterface.COMPILE_NMS_VERSION + " but the server is running "
|
TFM_Log.warning(pluginName + " is compiled for " + TFM_ServerInterface.COMPILE_NMS_VERSION + " but the server is running "
|
||||||
@ -155,7 +158,9 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
TFM_HTTPD_Manager.start();
|
TFM_HTTPD_Manager.start();
|
||||||
TFM_FrontDoor.start();
|
TFM_FrontDoor.start();
|
||||||
|
|
||||||
TFM_Log.info("Version " + pluginVersion + " for " + TFM_ServerInterface.COMPILE_NMS_VERSION + " enabled");
|
timer.update();
|
||||||
|
|
||||||
|
TFM_Log.info("Version " + pluginVersion + " for " + TFM_ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
||||||
|
|
||||||
// Metrics @ http://mcstats.org/plugin/TotalFreedomMod
|
// Metrics @ http://mcstats.org/plugin/TotalFreedomMod
|
||||||
try
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user