mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-18 12:31:26 +02:00
Allow to forceSave conf files
This commit is contained in:
@@ -9,8 +9,10 @@ import java.nio.charset.Charset;
|
|||||||
import java.nio.charset.CharsetDecoder;
|
import java.nio.charset.CharsetDecoder;
|
||||||
import java.nio.charset.CoderResult;
|
import java.nio.charset.CoderResult;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -249,6 +251,31 @@ public class EssentialsConf extends YamlConfiguration
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void save(final File file) throws IOException
|
public synchronized void save(final File file) throws IOException
|
||||||
|
{
|
||||||
|
delayedSave(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void forceSave()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Future<?> future = delayedSave(configFile);
|
||||||
|
if (future != null)
|
||||||
|
{
|
||||||
|
future.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (InterruptedException ex)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
catch (ExecutionException ex)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Future<?> delayedSave(final File file)
|
||||||
{
|
{
|
||||||
//long startTime = System.nanoTime();
|
//long startTime = System.nanoTime();
|
||||||
if (file == null)
|
if (file == null)
|
||||||
@@ -260,14 +287,16 @@ public class EssentialsConf extends YamlConfiguration
|
|||||||
|
|
||||||
if (data.length() == 0)
|
if (data.length() == 0)
|
||||||
{
|
{
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pendingDiskWrites.incrementAndGet();
|
pendingDiskWrites.incrementAndGet();
|
||||||
|
|
||||||
EXECUTOR_SERVICE.submit(new WriteRunner(configFile, data, pendingDiskWrites));
|
Future<?> future = EXECUTOR_SERVICE.submit(new WriteRunner(configFile, data, pendingDiskWrites));
|
||||||
|
|
||||||
//LOGGER.log(Level.INFO, configFile + " prepared for writing in " + (System.nanoTime() - startTime) + " nsec.");
|
//LOGGER.log(Level.INFO, configFile + " prepared for writing in " + (System.nanoTime() - startTime) + " nsec.");
|
||||||
|
|
||||||
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -230,7 +230,7 @@ public class EssentialsUpgrade
|
|||||||
config.removeProperty("home");
|
config.removeProperty("home");
|
||||||
config.setProperty("home.default", worldName);
|
config.setProperty("home.default", worldName);
|
||||||
config.setProperty("home.worlds." + worldName, loc);
|
config.setProperty("home.worlds." + worldName, loc);
|
||||||
config.save();
|
config.forceSave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ public class EssentialsUpgrade
|
|||||||
((Map<String, Object>)powertools).put(entry.getKey(), temp);
|
((Map<String, Object>)powertools).put(entry.getKey(), temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
config.save();
|
config.forceSave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (RuntimeException ex)
|
catch (RuntimeException ex)
|
||||||
@@ -358,7 +358,7 @@ public class EssentialsUpgrade
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
config.removeProperty("home");
|
config.removeProperty("home");
|
||||||
config.save();
|
config.forceSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ public final class Economy
|
|||||||
npcConfig.load();
|
npcConfig.load();
|
||||||
npcConfig.setProperty("npc", true);
|
npcConfig.setProperty("npc", true);
|
||||||
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
|
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
|
||||||
npcConfig.save();
|
npcConfig.forceSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteNPC(String name)
|
private static void deleteNPC(String name)
|
||||||
|
Reference in New Issue
Block a user