Enforce userdata save on player dispose.

This commit is contained in:
KHobbits 2014-05-27 04:50:12 +01:00
parent 2ac1ce4f56
commit 4590e7ea26
3 changed files with 22 additions and 1 deletions

View File

@ -320,6 +320,10 @@ public class EssentialsConf extends YamlConfiguration
{
try
{
if (pendingDiskWrites.get() > 0)
{
pendingDiskWrites.set(0);
}
Future<?> future = delayedSave(configFile);
if (future != null)
{
@ -336,6 +340,14 @@ public class EssentialsConf extends YamlConfiguration
}
}
public synchronized void cleanup()
{
if (pendingDiskWrites.get() > 0)
{
forceSave();
}
}
private Future<?> delayedSave(final File file)
{
if (file == null)
@ -350,7 +362,10 @@ public class EssentialsConf extends YamlConfiguration
return null;
}
pendingDiskWrites.incrementAndGet();
if (pendingDiskWrites.incrementAndGet() < 0)
{
pendingDiskWrites.set(1);
}
Future<?> future = EXECUTOR_SERVICE.submit(new WriteRunner(configFile, data, pendingDiskWrites));

View File

@ -242,6 +242,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
{
this.base = new OfflinePlayer(base.getUniqueId(), ess.getServer());
}
cleanup();
}
@Override

View File

@ -53,6 +53,11 @@ public abstract class UserData extends PlayerExtension implements IConf
ess.getUserMap().removeUser(this.getBase().getName());
}
public final void cleanup()
{
config.cleanup();
}
@Override
public final void reloadConfig()
{