diff options
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsConf.java | 17 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/User.java | 1 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/UserData.java | 5 |
3 files changed, 22 insertions, 1 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials/src/com/earth2me/essentials/EssentialsConf.java index d59ab9e84..ce3d43280 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsConf.java @@ -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)); diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 8ca3e18cc..8d35201c1 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -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 diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 8678f6f40..a60e2f0dc 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -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() { |