mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Significantly speed up player list loading.
This commit is contained in:
parent
01edfed307
commit
3d6be1cd51
@ -125,6 +125,11 @@ public class TFM_Player
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
save(true);
|
||||
}
|
||||
|
||||
public void save(boolean doConfigSave)
|
||||
{
|
||||
if (!isComplete())
|
||||
{
|
||||
@ -149,6 +154,9 @@ public class TFM_Player
|
||||
section.set("lastjoinunix", lastLoginUnix);
|
||||
section.set("ips", ips);
|
||||
|
||||
config.save();
|
||||
if (doConfigSave)
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import static me.StevenLawson.TotalFreedomMod.TFM_AdminList.save;
|
||||
import net.minecraft.util.com.google.common.collect.Sets;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -38,6 +37,9 @@ public class TFM_PlayerList
|
||||
|
||||
public static void load()
|
||||
{
|
||||
TFM_Util.TFMethodTimer timer = new TFM_Util.TFMethodTimer();
|
||||
timer.start();
|
||||
|
||||
playerList.clear();
|
||||
config.load();
|
||||
|
||||
@ -72,7 +74,9 @@ public class TFM_PlayerList
|
||||
// Save list
|
||||
saveAll();
|
||||
|
||||
TFM_Log.info("Loaded playerdata for " + playerList.size() + " players.");
|
||||
timer.update();
|
||||
|
||||
TFM_Log.info("Loaded playerdata for " + playerList.size() + " players in " + timer.getTotal() + " ms.");
|
||||
}
|
||||
|
||||
private static void saveAll()
|
||||
@ -80,8 +84,10 @@ public class TFM_PlayerList
|
||||
// Put entries
|
||||
for (TFM_Player entry : playerList.values())
|
||||
{
|
||||
entry.save();
|
||||
entry.save(false);
|
||||
}
|
||||
|
||||
getConfig().save();
|
||||
}
|
||||
|
||||
public static TFM_Player getEntry(String player)
|
||||
|
@ -1093,4 +1093,34 @@ public class TFM_Util
|
||||
{
|
||||
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE;
|
||||
}
|
||||
|
||||
public static class TFMethodTimer
|
||||
{
|
||||
private long lastStart;
|
||||
private long total = 0;
|
||||
|
||||
public TFMethodTimer()
|
||||
{
|
||||
}
|
||||
|
||||
public void start()
|
||||
{
|
||||
this.lastStart = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
this.total += (System.currentTimeMillis() - this.lastStart);
|
||||
}
|
||||
|
||||
public long getTotal()
|
||||
{
|
||||
return this.total;
|
||||
}
|
||||
|
||||
public void printTotalToLog(String timerName)
|
||||
{
|
||||
TFM_Log.info("DEBUG: " + timerName + " used " + this.getTotal() + " ms.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user