mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 09:37:50 +01:00
Enforce userdata save on player dispose.
This commit is contained in:
parent
2ac1ce4f56
commit
4590e7ea26
@ -320,6 +320,10 @@ public class EssentialsConf extends YamlConfiguration
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (pendingDiskWrites.get() > 0)
|
||||||
|
{
|
||||||
|
pendingDiskWrites.set(0);
|
||||||
|
}
|
||||||
Future<?> future = delayedSave(configFile);
|
Future<?> future = delayedSave(configFile);
|
||||||
if (future != null)
|
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)
|
private Future<?> delayedSave(final File file)
|
||||||
{
|
{
|
||||||
if (file == null)
|
if (file == null)
|
||||||
@ -350,7 +362,10 @@ public class EssentialsConf extends YamlConfiguration
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pendingDiskWrites.incrementAndGet();
|
if (pendingDiskWrites.incrementAndGet() < 0)
|
||||||
|
{
|
||||||
|
pendingDiskWrites.set(1);
|
||||||
|
}
|
||||||
|
|
||||||
Future<?> future = EXECUTOR_SERVICE.submit(new WriteRunner(configFile, data, pendingDiskWrites));
|
Future<?> future = EXECUTOR_SERVICE.submit(new WriteRunner(configFile, data, pendingDiskWrites));
|
||||||
|
|
||||||
|
@ -242,6 +242,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
|
|||||||
{
|
{
|
||||||
this.base = new OfflinePlayer(base.getUniqueId(), ess.getServer());
|
this.base = new OfflinePlayer(base.getUniqueId(), ess.getServer());
|
||||||
}
|
}
|
||||||
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,6 +53,11 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||||||
ess.getUserMap().removeUser(this.getBase().getName());
|
ess.getUserMap().removeUser(this.getBase().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void cleanup()
|
||||||
|
{
|
||||||
|
config.cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void reloadConfig()
|
public final void reloadConfig()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user