Undo/Settings

Fix some disk and undo issues
FaweQueue uses Settings instance
This commit is contained in:
Jesse Boyd 2017-01-15 18:45:12 +11:00
parent 9d2e9212fa
commit 812c12fce4
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
53 changed files with 389 additions and 298 deletions

View File

@ -203,8 +203,8 @@ public class FaweBukkit implements IFawe, Listener {
return plugin.getQueue(world); return plugin.getQueue(world);
} catch (Throwable ignore) { } catch (Throwable ignore) {
// Disable incompatible settings // Disable incompatible settings
Settings.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level
Settings.HISTORY.COMBINE_STAGES = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI Settings.IMP.HISTORY.COMBINE_STAGES = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI
if (hasNMS) { if (hasNMS) {
ignore.printStackTrace(); ignore.printStackTrace();
debug("====== NO NMS BLOCK PLACER FOUND ======"); debug("====== NO NMS BLOCK PLACER FOUND ======");
@ -256,8 +256,8 @@ public class FaweBukkit implements IFawe, Listener {
} catch (Throwable ignore) { } catch (Throwable ignore) {
} }
// Disable incompatible settings // Disable incompatible settings
Settings.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level
Settings.HISTORY.COMBINE_STAGES = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI Settings.IMP.HISTORY.COMBINE_STAGES = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI
if (hasNMS) { if (hasNMS) {
debug("====== NO NMS BLOCK PLACER FOUND ======"); debug("====== NO NMS BLOCK PLACER FOUND ======");
debug("FAWE couldn't find a fast block placer"); debug("FAWE couldn't find a fast block placer");

View File

@ -206,7 +206,7 @@ public class BukkitChunk_All extends CharFaweChunk<Chunk, BukkitQueue_All> {
continue; continue;
} }
if (light != place) { if (light != place) {
light = light && Settings.LIGHTING.MODE != 0; light = light && Settings.IMP.LIGHTING.MODE != 0;
if (light) { if (light) {
parent.enableLighting(disableResult); parent.enableLighting(disableResult);
} }

View File

@ -21,19 +21,19 @@ public class BukkitQueue_All extends BukkitQueue_0<Chunk, Chunk, Chunk> {
public BukkitQueue_All(com.sk89q.worldedit.world.World world) { public BukkitQueue_All(com.sk89q.worldedit.world.World world) {
super(world); super(world);
if (Settings.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) { if (Settings.IMP.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) {
ALLOCATE = Settings.QUEUE.EXTRA_TIME_MS; ALLOCATE = Settings.IMP.QUEUE.EXTRA_TIME_MS;
Settings.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE; Settings.IMP.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE;
Settings.QUEUE.PARALLEL_THREADS = 1; Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
} }
} }
public BukkitQueue_All(String world) { public BukkitQueue_All(String world) {
super(world); super(world);
if (Settings.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) { if (Settings.IMP.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) {
ALLOCATE = Settings.QUEUE.EXTRA_TIME_MS; ALLOCATE = Settings.IMP.QUEUE.EXTRA_TIME_MS;
Settings.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE; Settings.IMP.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE;
Settings.QUEUE.PARALLEL_THREADS = 1; Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
} }
} }

View File

@ -27,7 +27,7 @@ public class ChunkListener implements Listener {
int rateLimit = 0; int rateLimit = 0;
public ChunkListener() { public ChunkListener() {
if (Settings.TICK_LIMITER.ENABLED) { if (Settings.IMP.TICK_LIMITER.ENABLED) {
Bukkit.getPluginManager().registerEvents(ChunkListener.this, Fawe.<FaweBukkit>imp().getPlugin()); Bukkit.getPluginManager().registerEvents(ChunkListener.this, Fawe.<FaweBukkit>imp().getPlugin());
TaskManager.IMP.repeat(new Runnable() { TaskManager.IMP.repeat(new Runnable() {
@Override @Override
@ -38,11 +38,11 @@ public class ChunkListener implements Listener {
counter.clear(); counter.clear();
lastZ = Integer.MIN_VALUE; lastZ = Integer.MIN_VALUE;
for (Long badChunk : badChunks) { for (Long badChunk : badChunks) {
counter.put(badChunk, new IntegerTrio(Settings.TICK_LIMITER.PHYSICS, Settings.TICK_LIMITER.ITEMS, Settings.TICK_LIMITER.FALLING)); counter.put(badChunk, new IntegerTrio(Settings.IMP.TICK_LIMITER.PHYSICS, Settings.IMP.TICK_LIMITER.ITEMS, Settings.IMP.TICK_LIMITER.FALLING));
} }
badChunks.clear(); badChunks.clear();
} }
}, Settings.TICK_LIMITER.INTERVAL); }, Settings.IMP.TICK_LIMITER.INTERVAL);
} }
} }
@ -92,7 +92,7 @@ public class ChunkListener implements Listener {
int cx = x >> 4; int cx = x >> 4;
int cz = z >> 4; int cz = z >> 4;
IntegerTrio count = getCount(cx, cz); IntegerTrio count = getCount(cx, cz);
if (count.x >= Settings.TICK_LIMITER.PHYSICS) { if (count.x >= Settings.IMP.TICK_LIMITER.PHYSICS) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -100,7 +100,7 @@ public class ChunkListener implements Listener {
int y = block.getY(); int y = block.getY();
if (y != lastPhysY) { if (y != lastPhysY) {
lastPhysY = y; lastPhysY = y;
if (++count.x == Settings.TICK_LIMITER.PHYSICS) { if (++count.x == Settings.IMP.TICK_LIMITER.PHYSICS) {
badChunks.add(MathMan.pairInt(cx, cz)); badChunks.add(MathMan.pairInt(cx, cz));
if (rateLimit <= 0) { if (rateLimit <= 0) {
rateLimit = 120; rateLimit = 120;
@ -127,9 +127,9 @@ public class ChunkListener implements Listener {
int cx = x >> 4; int cx = x >> 4;
int cz = z >> 4; int cz = z >> 4;
IntegerTrio count = getCount(cx, cz); IntegerTrio count = getCount(cx, cz);
if (++count.y >= Settings.TICK_LIMITER.FALLING) { if (++count.y >= Settings.IMP.TICK_LIMITER.FALLING) {
if (count.y == Settings.TICK_LIMITER.FALLING) { if (count.y == Settings.IMP.TICK_LIMITER.FALLING) {
count.x = Settings.TICK_LIMITER.PHYSICS; count.x = Settings.IMP.TICK_LIMITER.PHYSICS;
badChunks.add(MathMan.pairInt(cx, cz)); badChunks.add(MathMan.pairInt(cx, cz));
Fawe.debug("[Tick Limiter] Detected and cancelled falling block lag source at " + block.getLocation()); Fawe.debug("[Tick Limiter] Detected and cancelled falling block lag source at " + block.getLocation());
} }
@ -149,9 +149,9 @@ public class ChunkListener implements Listener {
int cx = loc.getBlockX() >> 4; int cx = loc.getBlockX() >> 4;
int cz = loc.getBlockZ() >> 4; int cz = loc.getBlockZ() >> 4;
IntegerTrio count = getCount(cx, cz); IntegerTrio count = getCount(cx, cz);
if (++count.z >= Settings.TICK_LIMITER.ITEMS) { if (++count.z >= Settings.IMP.TICK_LIMITER.ITEMS) {
if (count.z == Settings.TICK_LIMITER.ITEMS) { if (count.z == Settings.IMP.TICK_LIMITER.ITEMS) {
count.x = Settings.TICK_LIMITER.PHYSICS; count.x = Settings.IMP.TICK_LIMITER.PHYSICS;
cleanup(loc.getChunk()); cleanup(loc.getChunk());
badChunks.add(MathMan.pairInt(cx, cz)); badChunks.add(MathMan.pairInt(cx, cz));
if (rateLimit <= 0) { if (rateLimit <= 0) {

View File

@ -80,6 +80,10 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
this(parent, FaweAPI.createQueue(parent.getName(), autoQueue)); this(parent, FaweAPI.createQueue(parent.getName(), autoQueue));
} }
public AsyncWorld(String world, boolean autoQueue) {
this(Bukkit.getWorld(world), autoQueue);
}
/** /**
* @deprecated use {@link #wrap(org.bukkit.World)} instead * @deprecated use {@link #wrap(org.bukkit.World)} instead
* @param parent * @param parent

View File

@ -227,11 +227,11 @@ public class Fawe {
* Implementation dependent stuff * Implementation dependent stuff
*/ */
this.setupConfigs(); this.setupConfigs();
MainUtil.deleteOlder(MainUtil.getFile(IMP.getDirectory(), Settings.PATHS.HISTORY), TimeUnit.DAYS.toMillis(Settings.HISTORY.DELETE_AFTER_DAYS)); MainUtil.deleteOlder(MainUtil.getFile(IMP.getDirectory(), Settings.IMP.PATHS.HISTORY), TimeUnit.DAYS.toMillis(Settings.IMP.HISTORY.DELETE_AFTER_DAYS));
MainUtil.deleteOlder(MainUtil.getFile(IMP.getDirectory(), Settings.PATHS.CLIPBOARD), TimeUnit.DAYS.toMillis(Settings.CLIPBOARD.DELETE_AFTER_DAYS)); MainUtil.deleteOlder(MainUtil.getFile(IMP.getDirectory(), Settings.IMP.PATHS.CLIPBOARD), TimeUnit.DAYS.toMillis(Settings.IMP.CLIPBOARD.DELETE_AFTER_DAYS));
TaskManager.IMP = this.IMP.getTaskManager(); TaskManager.IMP = this.IMP.getTaskManager();
if (Settings.METRICS) { if (Settings.IMP.METRICS) {
this.IMP.startMetrics(); this.IMP.startMetrics();
} }
this.setupCommands(); this.setupCommands();
@ -258,7 +258,7 @@ public class Fawe {
TaskManager.IMP.repeat(timer, 1); TaskManager.IMP.repeat(timer, 1);
if (Settings.UPDATE) { if (Settings.IMP.UPDATE) {
// Delayed updating // Delayed updating
TaskManager.IMP.async(new Runnable() { TaskManager.IMP.async(new Runnable() {
@Override @Override
@ -310,19 +310,18 @@ public class Fawe {
public void setupConfigs() { public void setupConfigs() {
// Setting up config.yml // Setting up config.yml
File file = new File(this.IMP.getDirectory(), "config.yml"); File file = new File(this.IMP.getDirectory(), "config.yml");
Settings.PLATFORM = IMP.getPlatform().replace("\"", ""); Settings.IMP.PLATFORM = IMP.getPlatform().replace("\"", "");
try { try {
InputStream stream = getClass().getResourceAsStream("/fawe.properties"); InputStream stream = getClass().getResourceAsStream("/fawe.properties");
java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A"); java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A");
String versionString = scanner.next().trim(); String versionString = scanner.next().trim();
scanner.close(); scanner.close();
this.version = new FaweVersion(versionString); this.version = new FaweVersion(versionString);
Settings.DATE = new Date(100 + version.year, version.month, version.day).toGMTString(); Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toGMTString();
Settings.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit/" + version.build; Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit/" + version.build;
Settings.COMMIT = "https://github.com/boy0001/FastAsyncWorldedit/commit/" + Integer.toHexString(version.hash); Settings.IMP.COMMIT = "https://github.com/boy0001/FastAsyncWorldedit/commit/" + Integer.toHexString(version.hash);
} catch (Throwable ignore) {} } catch (Throwable ignore) {}
Settings.load(file); Settings.IMP.reload(file);
Settings.save(file);
// Setting up message.yml // Setting up message.yml
BBC.load(new File(this.IMP.getDirectory(), "message.yml")); BBC.load(new File(this.IMP.getDirectory(), "message.yml"));
} }
@ -483,9 +482,9 @@ public class Fawe {
try { try {
com.github.luben.zstd.util.Native.load(); com.github.luben.zstd.util.Native.load();
} catch (Throwable e) { } catch (Throwable e) {
if (Settings.CLIPBOARD.COMPRESSION_LEVEL > 6 || Settings.HISTORY.COMPRESSION_LEVEL > 6) { if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL > 6 || Settings.IMP.HISTORY.COMPRESSION_LEVEL > 6) {
Settings.CLIPBOARD.COMPRESSION_LEVEL = Math.min(6, Settings.CLIPBOARD.COMPRESSION_LEVEL); Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL);
Settings.HISTORY.COMPRESSION_LEVEL = Math.min(6, Settings.HISTORY.COMPRESSION_LEVEL); Settings.IMP.HISTORY.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.HISTORY.COMPRESSION_LEVEL);
debug("====== ZSTD COMPRESSION BINDING NOT FOUND ======"); debug("====== ZSTD COMPRESSION BINDING NOT FOUND ======");
debug(e); debug(e);
debug("==============================================="); debug("===============================================");
@ -525,7 +524,7 @@ public class Fawe {
} }
private void setupMemoryListener() { private void setupMemoryListener() {
if (Settings.MAX_MEMORY_PERCENT < 1 || Settings.MAX_MEMORY_PERCENT > 99) { if (Settings.IMP.MAX_MEMORY_PERCENT < 1 || Settings.IMP.MAX_MEMORY_PERCENT > 99) {
return; return;
} }
try { try {
@ -547,7 +546,7 @@ public class Fawe {
if (max < 0) { if (max < 0) {
continue; continue;
} }
final long alert = (max * Settings.MAX_MEMORY_PERCENT) / 100; final long alert = (max * Settings.IMP.MAX_MEMORY_PERCENT) / 100;
mp.setUsageThreshold(alert); mp.setUsageThreshold(alert);
} }
} }

View File

@ -231,7 +231,7 @@ public class FaweAPI {
if (!file.getName().toLowerCase().endsWith(".bd")) { if (!file.getName().toLowerCase().endsWith(".bd")) {
throw new IllegalArgumentException("Not a BD file!"); throw new IllegalArgumentException("Not a BD file!");
} }
if (Settings.HISTORY.USE_DISK) { if (Settings.IMP.HISTORY.USE_DISK) {
throw new IllegalArgumentException("History on disk not enabled!"); throw new IllegalArgumentException("History on disk not enabled!");
} }
String[] path = file.getPath().split(File.separator); String[] path = file.getPath().split(File.separator);
@ -261,12 +261,12 @@ public class FaweAPI {
* @param user - The uuid (may be null) * @param user - The uuid (may be null)
* @param radius - The radius from the origin of the edit * @param radius - The radius from the origin of the edit
* @param timediff - The max age of the file in milliseconds * @param timediff - The max age of the file in milliseconds
* @param shallow - If shallow is true, FAWE will only read the first Settings.BUFFER_SIZE bytes to obtain history info<br> * @param shallow - If shallow is true, FAWE will only read the first Settings.IMP.BUFFER_SIZE bytes to obtain history info<br>
* Reading only part of the file will result in unreliable bounds info for large edits * Reading only part of the file will result in unreliable bounds info for large edits
* @return * @return
*/ */
public static List<DiskStorageHistory> getBDFiles(FaweLocation origin, UUID user, int radius, long timediff, boolean shallow) { public static List<DiskStorageHistory> getBDFiles(FaweLocation origin, UUID user, int radius, long timediff, boolean shallow) {
File history = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.PATHS.HISTORY + File.separator + origin.world); File history = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + origin.world);
if (!history.exists()) { if (!history.exists()) {
return new ArrayList<>(); return new ArrayList<>();
} }

View File

@ -28,7 +28,7 @@ public class Rollback extends FaweCommand {
@Override @Override
public boolean execute(final FawePlayer player, final String... args) { public boolean execute(final FawePlayer player, final String... args) {
if (!Settings.HISTORY.USE_DATABASE) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
BBC.SETTING_DISABLE.send(player, "history.use-database"); BBC.SETTING_DISABLE.send(player, "history.use-database");
return false; return false;
} }

View File

@ -13,6 +13,7 @@ import java.lang.annotation.Target;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@ -28,7 +29,7 @@ public class Config {
* @param <T> * @param <T>
* @return * @return
*/ */
public static <T> T get(String key, Class root) { private <T> T get(String key, Class root) {
String[] split = key.split("\\."); String[] split = key.split("\\.");
Object instance = getInstance(split, root); Object instance = getInstance(split, root);
if (instance != null) { if (instance != null) {
@ -52,7 +53,7 @@ public class Config {
* @param value value * @param value value
* *
*/ */
public static void set(String key, Object value, Class root) { private void set(String key, Object value, Class root) {
String[] split = key.split("\\."); String[] split = key.split("\\.");
Object instance = getInstance(split, root); Object instance = getInstance(split, root);
if (instance != null) { if (instance != null) {
@ -75,7 +76,7 @@ public class Config {
Fawe.debug("Failed to set config option: " + key + ": " + value + " | " + instance + " | " + root.getSimpleName() + ".yml"); Fawe.debug("Failed to set config option: " + key + ": " + value + " | " + instance + " | " + root.getSimpleName() + ".yml");
} }
public static boolean load(File file, Class root) { public boolean load(File file) {
if (!file.exists()) { if (!file.exists()) {
return false; return false;
} }
@ -85,7 +86,7 @@ public class Config {
if (value instanceof MemorySection) { if (value instanceof MemorySection) {
continue; continue;
} }
set(key, value, root); set(key, value, getClass());
} }
return true; return true;
} }
@ -94,16 +95,19 @@ public class Config {
* Set all values in the file (load first to avoid overwriting) * Set all values in the file (load first to avoid overwriting)
* @param file * @param file
*/ */
public static void save(File file, Class root) { public void save(File file) {
Class<? extends Config> root = getClass();
try { try {
if (!file.exists()) { if (!file.exists()) {
file.getParentFile().mkdirs(); File parent = file.getParentFile();
if (parent != null) {
file.getParentFile().mkdirs();
}
file.createNewFile(); file.createNewFile();
} }
PrintWriter writer = new PrintWriter(file); PrintWriter writer = new PrintWriter(file);
Class clazz = root; Object instance = this;
Object instance = root.newInstance(); save(writer, getClass(), instance, 0);
save(writer, clazz, instance, 0);
writer.close(); writer.close();
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
@ -180,7 +184,7 @@ public class Config {
* @param clazz * @param clazz
* @return * @return
*/ */
public static Map<String, Object> getFields(Class clazz) { private Map<String, Object> getFields(Class clazz) {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
for (Field field : clazz.getFields()) { for (Field field : clazz.getFields()) {
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) { if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
@ -194,7 +198,7 @@ public class Config {
return map; return map;
} }
private static String toYamlString(Object value, String spacing) { private String toYamlString(Object value, String spacing) {
if (value instanceof List) { if (value instanceof List) {
Collection<?> listValue = (Collection<?>) value; Collection<?> listValue = (Collection<?>) value;
if (listValue.isEmpty()) { if (listValue.isEmpty()) {
@ -216,11 +220,16 @@ public class Config {
return value != null ? value.toString() : "null"; return value != null ? value.toString() : "null";
} }
private static void save(PrintWriter writer, Class clazz, Object instance, int indent) { private void save(PrintWriter writer, Class clazz, Object instance, int indent) {
try { try {
String CTRF = System.lineSeparator(); String CTRF = System.lineSeparator();
String spacing = StringMan.repeat(" ", indent); String spacing = StringMan.repeat(" ", indent);
HashMap<Class, Object> instances = new HashMap<>();
for (Field field : clazz.getFields()) { for (Field field : clazz.getFields()) {
if (field.getAnnotation(Ignore.class) != null) {
continue;
}
Class<?> current = field.getType();
if (field.getAnnotation(Ignore.class) != null) { if (field.getAnnotation(Ignore.class) != null) {
continue; continue;
} }
@ -230,61 +239,58 @@ public class Config {
writer.write(spacing + "# " + commentLine + CTRF); writer.write(spacing + "# " + commentLine + CTRF);
} }
} }
if (current == ConfigBlock.class) {
current = (Class<?>) ((ParameterizedType) (field.getGenericType())).getActualTypeArguments()[0];
comment = current.getAnnotation(Comment.class);
if (comment != null) {
for (String commentLine : comment.value()) {
writer.write(spacing + "# " + commentLine + CTRF);
}
}
BlockName blockNames = current.getAnnotation(BlockName.class);
if (blockNames != null) {
writer.write(spacing + toNodeName(current.getSimpleName()) + ":" + CTRF);
ConfigBlock configBlock = (ConfigBlock) field.get(instance);
if (configBlock == null || configBlock.getInstances().isEmpty()) {
configBlock = new ConfigBlock();
field.set(instance, configBlock);
for (String blockName : blockNames.value()) {
configBlock.put(blockName, current.newInstance());
}
}
// Save each instance
for (Map.Entry<String, Object> entry : ((Map<String, Object>) configBlock.getRaw()).entrySet()) {
String key = entry.getKey();
writer.write(spacing + " " + toNodeName(key) + ":" + CTRF);
save(writer, current, entry.getValue(), indent + 4);
}
}
continue;
}
Create create = field.getAnnotation(Create.class); Create create = field.getAnnotation(Create.class);
if (create != null) { if (create != null) {
Object value = field.get(instance); Object value = field.get(instance);
if (value == null && field.getType() != ConfigBlock.class) { setAccessible(field);
setAccessible(field); if (indent == 0) {
Class<?>[] classes = clazz.getDeclaredClasses(); writer.write(CTRF);
for (Class current : classes) { }
if (StringMan.isEqual(current.getSimpleName(), field.getName())) { comment = current.getAnnotation(Comment.class);
field.set(instance, current.newInstance()); if (comment != null) {
break; for (String commentLine : comment.value()) {
} writer.write(spacing + "# " + commentLine + CTRF);
} }
} }
writer.write(spacing + toNodeName(current.getSimpleName()) + ":" + CTRF);
if (value == null) {
field.set(instance, value = current.newInstance());
instances.put(current, value);
}
save(writer, current, value, indent + 2);
continue; continue;
} else { } else {
writer.write(spacing + toNodeName(field.getName() + ": ") + toYamlString(field.get(instance), spacing) + CTRF); writer.write(spacing + toNodeName(field.getName() + ": ") + toYamlString(field.get(instance), spacing) + CTRF);
} }
} }
for (Class<?> current : clazz.getClasses()) {
if (current.isInterface() || current.getAnnotation(Ignore.class) != null) {
continue;
}
if (indent == 0) {
writer.write(CTRF);
}
Comment comment = current.getAnnotation(Comment.class);
if (comment != null) {
for (String commentLine : comment.value()) {
writer.write(spacing + "# " + commentLine + CTRF);
}
}
writer.write(spacing + toNodeName(current.getSimpleName()) + ":" + CTRF);
BlockName blockNames = current.getAnnotation(BlockName.class);
if (blockNames != null) {
Field instanceField = clazz.getDeclaredField(toFieldName(current.getSimpleName()));
setAccessible(instanceField);
ConfigBlock value = (ConfigBlock) instanceField.get(instance);
if (value == null) {
value = new ConfigBlock();
instanceField.set(instance, value);
for (String blockName : blockNames.value()) {
value.put(blockName, current.newInstance());
}
}
// Save each instance
for (Map.Entry<String, Object> entry: ((Map<String, Object>) value.getRaw()).entrySet()) {
String key = entry.getKey();
writer.write(spacing + " " + toNodeName(key) + ":" + CTRF);
save(writer, current, entry.getValue(), indent + 4);
}
continue;
} else {
save(writer, current, current.newInstance(), indent + 2);
}
}
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -295,7 +301,7 @@ public class Config {
* @param split the node (split by period) * @param split the node (split by period)
* @return * @return
*/ */
private static Field getField(String[] split, Class root) { private Field getField(String[] split, Class root) {
Object instance = getInstance(split, root); Object instance = getInstance(split, root);
if (instance == null) { if (instance == null) {
return null; return null;
@ -310,7 +316,7 @@ public class Config {
* @param instance the instance * @param instance the instance
* @return * @return
*/ */
private static Field getField(String[] split, Object instance) { private Field getField(String[] split, Object instance) {
try { try {
Field field = instance.getClass().getField(toFieldName(split[split.length - 1])); Field field = instance.getClass().getField(toFieldName(split[split.length - 1]));
setAccessible(field); setAccessible(field);
@ -321,15 +327,22 @@ public class Config {
} }
} }
private Object getInstance(Object instance, Class clazz) throws IllegalAccessException, InstantiationException {
try {
Field instanceField = clazz.getDeclaredField(clazz.getSimpleName());
} catch (Throwable ignore) {}
return clazz.newInstance();
}
/** /**
* Get the instance for a specific config node * Get the instance for a specific config node
* @param split the node (split by period) * @param split the node (split by period)
* @return The instance or null * @return The instance or null
*/ */
private static Object getInstance(String[] split, Class root) { private Object getInstance(String[] split, Class root) {
try { try {
Class<?> clazz = root == null ? MethodHandles.lookup().lookupClass() : root; Class<?> clazz = root == null ? MethodHandles.lookup().lookupClass() : root;
Object instance = clazz.newInstance(); Object instance = this;
while (split.length > 0) { while (split.length > 0) {
switch (split.length) { switch (split.length) {
case 1: case 1:
@ -391,7 +404,7 @@ public class Config {
* @param node * @param node
* @return * @return
*/ */
private static String toFieldName(String node) { private String toFieldName(String node) {
return node.toUpperCase().replaceAll("-","_"); return node.toUpperCase().replaceAll("-","_");
} }
@ -400,7 +413,7 @@ public class Config {
* @param field * @param field
* @return * @return
*/ */
private static String toNodeName(String field) { private String toNodeName(String field) {
return field.toLowerCase().replace("_","-"); return field.toLowerCase().replace("_","-");
} }
@ -410,7 +423,7 @@ public class Config {
* @throws NoSuchFieldException * @throws NoSuchFieldException
* @throws IllegalAccessException * @throws IllegalAccessException
*/ */
private static void setAccessible(Field field) throws NoSuchFieldException, IllegalAccessException { private void setAccessible(Field field) throws NoSuchFieldException, IllegalAccessException {
field.setAccessible(true); field.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers"); Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true); modifiersField.setAccessible(true);

View File

@ -9,49 +9,70 @@ import java.util.Collection;
import java.util.List; import java.util.List;
public class Settings extends Config { public class Settings extends Config {
@Ignore
public static final Settings IMP = new Settings();
@Comment("These first 6 aren't configurable") // This is a comment @Comment("These first 6 aren't configurable") // This is a comment
@Final // Indicates that this value isn't configurable @Final // Indicates that this value isn't configurable
public static final String ISSUES = "https://github.com/boy0001/FastAsyncWorldedit/issues"; public final String ISSUES = "https://github.com/boy0001/FastAsyncWorldedit/issues";
@Final @Final
public static final String WIKI = "https://github.com/boy0001/FastAsyncWorldedit/wiki/"; public final String WIKI = "https://github.com/boy0001/FastAsyncWorldedit/wiki/";
@Final @Final
public static String DATE = null; // These values are set from FAWE before loading public String DATE = null; // These values are set from FAWE before loading
@Final @Final
public static String BUILD = null; // These values are set from FAWE before loading public String BUILD = null; // These values are set from FAWE before loading
@Final @Final
public static String COMMIT = null; // These values are set from FAWE before loading public String COMMIT = null; // These values are set from FAWE before loading
@Final @Final
public static String PLATFORM = null; // These values are set from FAWE before loading public String PLATFORM = null; // These values are set from FAWE before loading
@Comment("Allow the plugin to update") @Comment("Allow the plugin to update")
public static boolean UPDATE = true; public boolean UPDATE = true;
@Comment("Send anonymous usage statistics to MCStats.org") @Comment("Send anonymous usage statistics to MCStats.org")
public static boolean METRICS = true; public boolean METRICS = true;
@Comment("FAWE will skip chunks when there's not enough memory available") @Comment("FAWE will skip chunks when there's not enough memory available")
public static boolean PREVENT_CRASHES = false; public boolean PREVENT_CRASHES = false;
@Comment({ @Comment({
"Set true to enable WorldEdit restrictions per region (e.g. PlotSquared or WorldGuard).", "Set true to enable WorldEdit restrictions per region (e.g. PlotSquared or WorldGuard).",
"To be allowed to WorldEdit in a region, users need the appropriate", "To be allowed to WorldEdit in a region, users need the appropriate",
"fawe.<plugin> permission. See the Permissions page for supported region plugins." "fawe.<plugin> permission. See the Permissions page for supported region plugins."
}) })
public static boolean REGION_RESTRICTIONS = true; public boolean REGION_RESTRICTIONS = true;
@Comment({ @Comment({
"FAWE will cancel non admin edits when memory consumption exceeds this %", "FAWE will cancel non admin edits when memory consumption exceeds this %",
" - Bypass with `/wea` or `//fast` or `fawe.bypass`", " - Bypass with `/wea` or `//fast` or `fawe.bypass`",
" - Disable with 100 or -1." " - Disable with 100 or -1."
}) })
public static int MAX_MEMORY_PERCENT = 95; public int MAX_MEMORY_PERCENT = 95;
@Create
public CLIPBOARD CLIPBOARD = null;
@Create
public LIGHTING LIGHTING = null;
@Create
public TICK_LIMITER TICK_LIMITER = null;
@Create
public WEB WEB = null;
@Create
public EXTENT EXTENT = null;
@Create
public EXPERIMENTAL EXPERIMENTAL = null;
@Create
public QUEUE QUEUE = null;
@Create
public HISTORY HISTORY = null;
@Create
public PATHS PATHS = null;
@Comment("Paths for various directories") @Comment("Paths for various directories")
public static final class PATHS { public static final class PATHS {
public static String HISTORY = "history"; public String HISTORY = "history";
public static String CLIPBOARD = "clipboard"; public String CLIPBOARD = "clipboard";
} }
@Create // This value will be generated automatically @Create // This value will be generated automatically
public static ConfigBlock<LIMITS> LIMITS = null; public ConfigBlock<LIMITS> LIMITS = null;
@Comment({ @Comment({
"The \"default\" limit group affects those without a specific limit permission.", "The \"default\" limit group affects those without a specific limit permission.",
@ -60,7 +81,7 @@ public class Settings extends Config {
"permission node with that limit name (e.g. fawe.limit.newbie )" "permission node with that limit name (e.g. fawe.limit.newbie )"
}) })
@BlockName("default") // The name for the default block @BlockName("default") // The name for the default block
public static final class LIMITS extends ConfigBlock { public static class LIMITS extends ConfigBlock {
@Comment("Max actions that can be run concurrently (i.e. commands)") @Comment("Max actions that can be run concurrently (i.e. commands)")
public int MAX_ACTIONS = 1; public int MAX_ACTIONS = 1;
@Comment("Max number of block changes (e.g. by `//set stone`).") @Comment("Max number of block changes (e.g. by `//set stone`).")
@ -96,11 +117,11 @@ public class Settings extends Config {
"1 = Inventory for removing and placing (freebuild)", "1 = Inventory for removing and placing (freebuild)",
"2 = Inventory for placing (survival)", "2 = Inventory for placing (survival)",
}) })
public static int INVENTORY_MODE = 0; public int INVENTORY_MODE = 0;
@Comment({ @Comment({
"Place chunks instead of individual blocks" "Place chunks instead of individual blocks"
}) })
public static boolean FAST_PLACEMENT = true; public boolean FAST_PLACEMENT = true;
} }
public static class HISTORY { public static class HISTORY {
@ -111,18 +132,18 @@ public class Settings extends Config {
" - Unlimited undo", " - Unlimited undo",
" - Enables the rollback command" " - Enables the rollback command"
}) })
public static boolean USE_DISK = true; public boolean USE_DISK = true;
@Comment({ @Comment({
"Use a database to store disk storage summaries:", "Use a database to store disk storage summaries:",
" - Faster lookups and rollback from disk", " - Faster lookups and rollback from disk",
}) })
public static boolean USE_DATABASE = true; public boolean USE_DATABASE = true;
@Comment({ @Comment({
"Record history with dispatching:", "Record history with dispatching:",
" - Faster as it avoids duplicate block checks", " - Faster as it avoids duplicate block checks",
" - Worse compression since dispatch order is different" " - Worse compression since dispatch order is different"
}) })
public static boolean COMBINE_STAGES = true; public boolean COMBINE_STAGES = true;
@Comment({ @Comment({
"Higher compression reduces the size of history at the expense of CPU", "Higher compression reduces the size of history at the expense of CPU",
"0 = Uncompressed byte array (fastest)", "0 = Uncompressed byte array (fastest)",
@ -137,12 +158,12 @@ public class Settings extends Config {
"9 = 1 x high, 1 x medium, 3 x fast (best compression)", "9 = 1 x high, 1 x medium, 3 x fast (best compression)",
"NOTE: If using disk, do some compression (3+) as smaller files save faster" "NOTE: If using disk, do some compression (3+) as smaller files save faster"
}) })
public static int COMPRESSION_LEVEL = 3; public int COMPRESSION_LEVEL = 3;
@Comment({ @Comment({
"The buffer size for compression:", "The buffer size for compression:",
" - Larger = better ratio but uses more upfront memory" " - Larger = better ratio but uses more upfront memory"
}) })
public static int BUFFER_SIZE = 531441; public int BUFFER_SIZE = 531441;
@Comment({ @Comment({
@ -161,46 +182,48 @@ public class Settings extends Config {
" or increase chunk-wait-ms.", " or increase chunk-wait-ms.",
"A value of 0 is faster simply because it doesn't bother loading the chunks or waiting.", "A value of 0 is faster simply because it doesn't bother loading the chunks or waiting.",
}) })
public static int CHUNK_WAIT_MS = 1000; public int CHUNK_WAIT_MS = 1000;
@Comment("Delete history on disk after a number of days") @Comment("Delete history on disk after a number of days")
public static int DELETE_AFTER_DAYS = 7; public int DELETE_AFTER_DAYS = 7;
@Comment("Delete history in memory on logout (does not effect disk)") @Comment("Delete history in memory on logout (does not effect disk)")
public static boolean DELETE_ON_LOGOUT = true; public boolean DELETE_ON_LOGOUT = true;
@Comment({ @Comment({
"If history should be enabled by default for plugins using WorldEdit:", "If history should be enabled by default for plugins using WorldEdit:",
" - It is faster to have disabled", " - It is faster to have disabled",
" - Use of the FAWE API will not be effected" " - Use of the FAWE API will not be effected"
}) })
public static boolean ENABLE_FOR_CONSOLE = true; public boolean ENABLE_FOR_CONSOLE = true;
@Comment({ @Comment({
"Should redo information be stored:", "Should redo information be stored:",
" - History is about 20% larger", " - History is about 20% larger",
" - Enables use of /redo", " - Enables use of /redo",
}) })
public static boolean STORE_REDO = true; public boolean STORE_REDO = true;
@Comment({ @Comment({
"Assumes all edits are smaller than 4096x256x4096:", "Assumes all edits are smaller than 4096x256x4096:",
" - Reduces history size by ~10%", " - Reduces history size by ~10%",
}) })
public static boolean SMALL_EDITS = false; public boolean SMALL_EDITS = false;
} }
public static class QUEUE { public static class QUEUE {
@Create
public static PROGRESS PROGRESS = null;
@Comment({ @Comment({
"If no blocks from completed edits are queued, and if the global queue has more available ", "If no blocks from completed edits are queued, and if the global queue has more available ",
"chunks to place from still-processing edits than the target size setting, it will begin", "chunks to place from still-processing edits than the target size setting, it will begin",
"placing available blocks from edits still in the preprocessing stage." "placing available blocks from edits still in the preprocessing stage."
}) })
public static int TARGET_SIZE = 64; public int TARGET_SIZE = 64;
@Comment({ @Comment({
"This should equal the number of processors you have" "This should equal the number of processors you have"
}) })
public static int PARALLEL_THREADS = Math.max(1, Runtime.getRuntime().availableProcessors()); public int PARALLEL_THREADS = Math.max(1, Runtime.getRuntime().availableProcessors());
@Comment({ @Comment({
"The time in milliseconds that the global queue can be idle before it is forced to start", "The time in milliseconds that the global queue can be idle before it is forced to start",
"on edits which are still in the preprocessing stage." "on edits which are still in the preprocessing stage."
}) })
public static int MAX_WAIT_MS = 1000; public int MAX_WAIT_MS = 1000;
@Comment({ @Comment({
"Increase or decrease queue intensity (0 = balance of performance / stability)", "Increase or decrease queue intensity (0 = balance of performance / stability)",
@ -208,7 +231,7 @@ public class Settings extends Config {
"will probably cause the server to freeze, and decreasing it (negative value)", "will probably cause the server to freeze, and decreasing it (negative value)",
"may reduce load on the server but should not be necessary." "may reduce load on the server but should not be necessary."
}) })
public static int EXTRA_TIME_MS = 0; public int EXTRA_TIME_MS = 0;
@Comment({ @Comment({
"Discard edits which have been idle for a certain amount of time (ms) (e.g. a plugin creates", "Discard edits which have been idle for a certain amount of time (ms) (e.g. a plugin creates",
@ -218,9 +241,9 @@ public class Settings extends Config {
public static class PROGRESS { public static class PROGRESS {
@Comment("Display constant titles about the progress of a user's edit") @Comment("Display constant titles about the progress of a user's edit")
public static boolean DISPLAY = false; public boolean DISPLAY = false;
@Comment("How often edit progress is displayed") @Comment("How often edit progress is displayed")
public static int INTERVAL = 1; public int INTERVAL = 1;
} }
} }
@ -229,41 +252,41 @@ public class Settings extends Config {
@Comment({ @Comment({
"Directly modify the region files.", "Directly modify the region files.",
}) })
public static boolean ANVIL_QUEUE_MODE = false; public boolean ANVIL_QUEUE_MODE = false;
} }
public static class WEB { public static class WEB {
@Comment("I am already hosting a web interface for you here") @Comment("I am already hosting a web interface for you here")
public static String URL = "http://empcraft.com/fawe/"; public String URL = "http://empcraft.com/fawe/";
} }
public static class EXTENT { public static class EXTENT {
@Comment({ @Comment({
"Don't bug console when these plugins slow down WorldEdit operations" "Don't bug console when these plugins slow down WorldEdit operations"
}) })
public static List<String> ALLOWED_PLUGINS = new ArrayList<>(); public List<String> ALLOWED_PLUGINS = new ArrayList<>();
@Comment("Disable the messages completely") @Comment("Disable the messages completely")
public static boolean DEBUG = true; public boolean DEBUG = true;
} }
@Comment("Generic tick limiter (not necessarily WorldEdit related, but useful to stop abuse)") @Comment("Generic tick limiter (not necessarily WorldEdit related, but useful to stop abuse)")
public static class TICK_LIMITER { public static class TICK_LIMITER {
@Comment("Enable the limiter") @Comment("Enable the limiter")
public static boolean ENABLED = true; public boolean ENABLED = true;
@Comment("The interval in ticks") @Comment("The interval in ticks")
public static int INTERVAL = 1; public int INTERVAL = 1;
@Comment("Max falling blocks per interval (per chunk)") @Comment("Max falling blocks per interval (per chunk)")
public static int FALLING = 512; public int FALLING = 512;
@Comment("Max physics per interval (per chunk)") @Comment("Max physics per interval (per chunk)")
public static int PHYSICS = 512; public int PHYSICS = 512;
@Comment("Max item spawns per interval (per chunk)") @Comment("Max item spawns per interval (per chunk)")
public static int ITEMS = 128; public int ITEMS = 128;
} }
public static class CLIPBOARD { public static class CLIPBOARD {
@Comment("Store the clipboard on disk instead of memory") @Comment("Store the clipboard on disk instead of memory")
public static boolean USE_DISK = true; public boolean USE_DISK = true;
@Comment({ @Comment({
"Compress the clipboard to reduce the size:", "Compress the clipboard to reduce the size:",
" - TODO: Buffered random access with compression is not implemented on disk yet", " - TODO: Buffered random access with compression is not implemented on disk yet",
@ -271,16 +294,16 @@ public class Settings extends Config {
" - 1 = Fast compression", " - 1 = Fast compression",
" - 2-17 = Slower compression" " - 2-17 = Slower compression"
}) })
public static int COMPRESSION_LEVEL = 1; public int COMPRESSION_LEVEL = 1;
@Comment("Number of days to keep history on disk before deleting it") @Comment("Number of days to keep history on disk before deleting it")
public static int DELETE_AFTER_DAYS = 1; public int DELETE_AFTER_DAYS = 1;
} }
public static class LIGHTING { public static class LIGHTING {
@Comment({ @Comment({
"If packet sending should be delayed until relight is finished", "If packet sending should be delayed until relight is finished",
}) })
public static boolean DELAY_PACKET_SENDING = true; public boolean DELAY_PACKET_SENDING = true;
@Comment({ @Comment({
"The relighting mode to use:", "The relighting mode to use:",
" - 0 = None (Do no relighting)", " - 0 = None (Do no relighting)",
@ -290,18 +313,15 @@ public class Settings extends Config {
public static int MODE = 1; public static int MODE = 1;
} }
public static void save(File file) { public void reload(File file) {
save(file, Settings.class); load(file);
} save(file);
public static void load(File file) {
load(file, Settings.class);
if (HISTORY.USE_DISK) { if (HISTORY.USE_DISK) {
LocalSession.MAX_HISTORY_SIZE = Integer.MAX_VALUE; LocalSession.MAX_HISTORY_SIZE = Integer.MAX_VALUE;
} }
} }
public static FaweLimit getLimit(FawePlayer player) { public FaweLimit getLimit(FawePlayer player) {
FaweLimit limit; FaweLimit limit;
if (player.hasWorldEditBypass()) { if (player.hasWorldEditBypass()) {
limit = FaweLimit.MAX.copy(); limit = FaweLimit.MAX.copy();

View File

@ -50,7 +50,7 @@ public class RollbackDatabase {
this.prefix = ""; this.prefix = "";
this.worldName = Fawe.imp().getWorldName(world); this.worldName = Fawe.imp().getWorldName(world);
this.world = world; this.world = world;
this.dbLocation = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + "summary.db"); this.dbLocation = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + "summary.db");
connection = openConnection(); connection = openConnection();
CREATE_TABLE = "CREATE TABLE IF NOT EXISTS `" + prefix + "edits` (`player` BLOB(16) NOT NULL,`id` INT NOT NULL,`x1` INT NOT NULL,`y1` INT NOT NULL,`z1` INT NOT NULL,`x2` INT NOT NULL,`y2` INT NOT NULL,`z2` INT NOT NULL,`time` INT NOT NULL, PRIMARY KEY (player, id))"; CREATE_TABLE = "CREATE TABLE IF NOT EXISTS `" + prefix + "edits` (`player` BLOB(16) NOT NULL,`id` INT NOT NULL,`x1` INT NOT NULL,`y1` INT NOT NULL,`z1` INT NOT NULL,`x2` INT NOT NULL,`y2` INT NOT NULL,`z2` INT NOT NULL,`time` INT NOT NULL, PRIMARY KEY (player, id))";
INSERT_EDIT = "INSERT OR REPLACE INTO `" + prefix + "edits` (`player`,`id`,`x1`,`y1`,`z1`,`x2`,`y2`,`z2`,`time`) VALUES(?,?,?,?,?,?,?,?,?)"; INSERT_EDIT = "INSERT OR REPLACE INTO `" + prefix + "edits` (`player`,`id`,`x1`,`y1`,`z1`,`x2`,`y2`,`z2`,`time`) VALUES(?,?,?,?,?,?,?,?,?)";
@ -61,7 +61,7 @@ public class RollbackDatabase {
DELETE_EDITS_USER = "DELETE FROM `" + prefix + "edits` WHERE `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=? AND `time`>? AND `player`=?"; DELETE_EDITS_USER = "DELETE FROM `" + prefix + "edits` WHERE `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=? AND `time`>? AND `player`=?";
DELETE_EDIT_USER = "DELETE FROM `" + prefix + "edits` WHERE `player`=? AND `id`=?"; DELETE_EDIT_USER = "DELETE FROM `" + prefix + "edits` WHERE `player`=? AND `id`=?";
init(); init();
purge((int) TimeUnit.DAYS.toMillis(Settings.HISTORY.DELETE_AFTER_DAYS)); purge((int) TimeUnit.DAYS.toMillis(Settings.IMP.HISTORY.DELETE_AFTER_DAYS));
TaskManager.IMP.async(new Runnable() { TaskManager.IMP.async(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -38,13 +38,13 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
public MappedFaweQueue(final String world) { public MappedFaweQueue(final String world) {
super(world); super(world);
map = Settings.PREVENT_CRASHES ? new WeakFaweQueueMap(this) : new DefaultFaweQueueMap(this); map = Settings.IMP.PREVENT_CRASHES ? new WeakFaweQueueMap(this) : new DefaultFaweQueueMap(this);
} }
public MappedFaweQueue(final String world, IFaweQueueMap map) { public MappedFaweQueue(final String world, IFaweQueueMap map) {
super(world); super(world);
if (map == null) { if (map == null) {
map = Settings.PREVENT_CRASHES ? new WeakFaweQueueMap(this) : new DefaultFaweQueueMap(this); map = Settings.IMP.PREVENT_CRASHES ? new WeakFaweQueueMap(this) : new DefaultFaweQueueMap(this);
} }
this.map = map; this.map = map;
} }
@ -52,7 +52,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
public MappedFaweQueue(final World world, IFaweQueueMap map) { public MappedFaweQueue(final World world, IFaweQueueMap map) {
super(world); super(world);
if (map == null) { if (map == null) {
map = Settings.PREVENT_CRASHES ? new WeakFaweQueueMap(this) : new DefaultFaweQueueMap(this); map = Settings.IMP.PREVENT_CRASHES ? new WeakFaweQueueMap(this) : new DefaultFaweQueueMap(this);
} }
this.map = map; this.map = map;
} }
@ -281,9 +281,9 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
boolean sync = Thread.currentThread() == Fawe.get().getMainThread(); boolean sync = Thread.currentThread() == Fawe.get().getMainThread();
if (sync) { if (sync) {
loadChunk(getWorld(), cx, cz, true); loadChunk(getWorld(), cx, cz, true);
} else if (Settings.HISTORY.CHUNK_WAIT_MS > 0) { } else if (Settings.IMP.HISTORY.CHUNK_WAIT_MS > 0) {
loadChunk.value = new IntegerPair(cx, cz); loadChunk.value = new IntegerPair(cx, cz);
TaskManager.IMP.syncWhenFree(loadChunk, Settings.HISTORY.CHUNK_WAIT_MS); TaskManager.IMP.syncWhenFree(loadChunk, Settings.IMP.HISTORY.CHUNK_WAIT_MS);
if (!isChunkLoaded(cx, cz)) { if (!isChunkLoaded(cx, cz)) {
throw new FaweException.FaweChunkLoadException(); throw new FaweException.FaweChunkLoadException();
} }

View File

@ -50,7 +50,7 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
} }
} }
private final Relighter relighter = Settings.LIGHTING.MODE > 0 ? new NMSRelighter(this) : NullRelighter.INSTANCE; private final Relighter relighter = Settings.IMP.LIGHTING.MODE > 0 ? new NMSRelighter(this) : NullRelighter.INSTANCE;
@Override @Override
public Relighter getRelighter() { public Relighter getRelighter() {
@ -60,11 +60,11 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
@Override @Override
public void end(FaweChunk chunk) { public void end(FaweChunk chunk) {
super.end(chunk); super.end(chunk);
if (Settings.LIGHTING.MODE == 0) { if (Settings.IMP.LIGHTING.MODE == 0 || !Settings.IMP.LIGHTING.DELAY_PACKET_SENDING) {
sendChunk(chunk); sendChunk(chunk);
return; return;
} }
if (Settings.LIGHTING.MODE == 2) { if (Settings.IMP.LIGHTING.MODE == 2) {
relighter.addChunk(chunk.getX(), chunk.getZ(), null, chunk.getBitMask()); relighter.addChunk(chunk.getX(), chunk.getZ(), null, chunk.getBitMask());
return; return;
} }

View File

@ -85,9 +85,9 @@ public class CorruptSchematicStreamer {
if (width.get() == 0 || height.get() == 0 || length.get() == 0) { if (width.get() == 0 || height.get() == 0 || length.get() == 0) {
Fawe.debug("No dimensions found! Estimating based on factors:" + dimensions); Fawe.debug("No dimensions found! Estimating based on factors:" + dimensions);
} }
if (Settings.CLIPBOARD.USE_DISK) { if (Settings.IMP.CLIPBOARD.USE_DISK) {
fc = new DiskOptimizedClipboard(dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ(), uuid); fc = new DiskOptimizedClipboard(dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ(), uuid);
} else if (Settings.CLIPBOARD.COMPRESSION_LEVEL == 0) { } else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) {
fc = new CPUOptimizedClipboard(dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ()); fc = new CPUOptimizedClipboard(dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ());
} else { } else {
fc = new MemoryOptimizedClipboard(dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ()); fc = new MemoryOptimizedClipboard(dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ());

View File

@ -167,9 +167,9 @@ public class SchematicStreamer extends NBTStreamer {
} }
return fc; return fc;
} }
if (Settings.CLIPBOARD.USE_DISK) { if (Settings.IMP.CLIPBOARD.USE_DISK) {
return fc = new DiskOptimizedClipboard(size, 1, 1, uuid); return fc = new DiskOptimizedClipboard(size, 1, 1, uuid);
} else if (Settings.CLIPBOARD.COMPRESSION_LEVEL == 0) { } else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) {
return fc = new CPUOptimizedClipboard(size, 1, 1); return fc = new CPUOptimizedClipboard(size, 1, 1);
} else { } else {
return fc = new MemoryOptimizedClipboard(size, 1, 1); return fc = new MemoryOptimizedClipboard(size, 1, 1);

View File

@ -298,7 +298,12 @@ public class MCAFile {
raf.write((offsetMedium >> 8)); raf.write((offsetMedium >> 8));
raf.write((offsetMedium >> 0)); raf.write((offsetMedium >> 0));
raf.write(sizeByte); raf.write(sizeByte);
raf.seek(i + 4096);
if (offsetMedium == 0 && sizeByte == 0) {
raf.writeInt(0);
} else {
raf.writeInt((int) (System.currentTimeMillis() / 1000L));
}
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i+ 2] & 0xFF))) << 12; int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i+ 2] & 0xFF))) << 12;
int size = (locations[i + 3] & 0xFF) << 12; int size = (locations[i + 3] & 0xFF) << 12;
} }

View File

@ -5,6 +5,7 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.changeset.AbstractDelegateChangeSet; import com.boydti.fawe.object.changeset.AbstractDelegateChangeSet;
import com.boydti.fawe.object.changeset.FaweChangeSet; import com.boydti.fawe.object.changeset.FaweChangeSet;
import java.lang.reflect.Constructor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.primesoft.blockshub.IBlocksHubApi; import org.primesoft.blockshub.IBlocksHubApi;
import org.primesoft.blockshub.api.IPlayer; import org.primesoft.blockshub.api.IPlayer;
@ -12,6 +13,10 @@ import org.primesoft.blockshub.api.IWorld;
public class LoggingChangeSet extends AbstractDelegateChangeSet { public class LoggingChangeSet extends AbstractDelegateChangeSet {
public static void main(String[] args) {
}
private static boolean initialized = false; private static boolean initialized = false;
public static FaweChangeSet wrap(FawePlayer<Player> player, FaweChangeSet parent) { public static FaweChangeSet wrap(FawePlayer<Player> player, FaweChangeSet parent) {
@ -29,13 +34,24 @@ public class LoggingChangeSet extends AbstractDelegateChangeSet {
private final MutableVector loc; private final MutableVector loc;
private final IPlayer player; private final IPlayer player;
private final IWorld world; private IWorld world;
private final MutableBlockData oldBlock; private final MutableBlockData oldBlock;
private final MutableBlockData newBlock; private final MutableBlockData newBlock;
private LoggingChangeSet(FawePlayer player, FaweChangeSet parent) { private LoggingChangeSet(FawePlayer player, FaweChangeSet parent) {
super(parent); super(parent);
this.world = api.getWorld(player.getLocation().world); String world = player.getLocation().world;
try {
Class<?> classBukkitWorld = Class.forName("org.primesoft.blockshub.platform.bukkit.BukkitWorld");
Class<?> classAsyncWorld = Class.forName("com.boydti.fawe.bukkit.wrapper.AsyncWorld");
Object asyncWorld = classAsyncWorld.getConstructor(String.class, boolean.class).newInstance(world, false);
Constructor<?> constructor = classBukkitWorld.getDeclaredConstructors()[0];
constructor.setAccessible(true);
this.world = (IWorld) constructor.newInstance(asyncWorld);
} catch (Throwable ignore) {
ignore.printStackTrace();
this.world = api.getWorld(world);
}
this.loc = new MutableVector(); this.loc = new MutableVector();
this.oldBlock = new MutableBlockData(); this.oldBlock = new MutableBlockData();
this.newBlock = new MutableBlockData(); this.newBlock = new MutableBlockData();

View File

@ -100,7 +100,7 @@ public abstract class FawePlayer<T> extends Metadatable {
public FawePlayer(final T parent) { public FawePlayer(final T parent) {
this.parent = parent; this.parent = parent;
Fawe.get().register(this); Fawe.get().register(this);
if (Settings.CLIPBOARD.USE_DISK) { if (Settings.IMP.CLIPBOARD.USE_DISK) {
loadClipboardFromDisk(); loadClipboardFromDisk();
} }
} }
@ -205,7 +205,7 @@ public abstract class FawePlayer<T> extends Metadatable {
* - Should already be called if history on disk is enabled * - Should already be called if history on disk is enabled
*/ */
public void loadClipboardFromDisk() { public void loadClipboardFromDisk() {
File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.PATHS.CLIPBOARD + File.separator + getUUID() + ".bd"); File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.CLIPBOARD + File.separator + getUUID() + ".bd");
try { try {
if (file.exists() && file.length() > 5) { if (file.exists() && file.length() > 5) {
DiskOptimizedClipboard doc = new DiskOptimizedClipboard(file); DiskOptimizedClipboard doc = new DiskOptimizedClipboard(file);
@ -280,7 +280,7 @@ public abstract class FawePlayer<T> extends Metadatable {
* @return * @return
*/ */
public FaweLimit getLimit() { public FaweLimit getLimit() {
return Settings.getLimit(this); return Settings.IMP.getLimit(this);
} }
/** /**
@ -420,7 +420,7 @@ public abstract class FawePlayer<T> extends Metadatable {
* - Usually called on logout * - Usually called on logout
*/ */
public void unregister() { public void unregister() {
if (Settings.HISTORY.DELETE_ON_LOGOUT) { if (Settings.IMP.HISTORY.DELETE_ON_LOGOUT) {
session = getSession(); session = getSession();
WorldEdit.getInstance().removeSession(getPlayer()); WorldEdit.getInstance().removeSession(getPlayer());
session.setClipboard(null); session.setClipboard(null);

View File

@ -41,6 +41,7 @@ public abstract class FaweQueue {
private RunnableVal2<FaweChunk, FaweChunk> changeTask; private RunnableVal2<FaweChunk, FaweChunk> changeTask;
private RunnableVal2<ProgressType, Integer> progressTask; private RunnableVal2<ProgressType, Integer> progressTask;
private SetQueue.QueueStage stage; private SetQueue.QueueStage stage;
private Settings settings = Settings.IMP;
public FaweQueue(String world) { public FaweQueue(String world) {
this.world = world; this.world = world;
@ -69,6 +70,14 @@ public abstract class FaweQueue {
ALL, ALL,
} }
public Settings getSettings() {
return settings;
}
public void setSettings(Settings settings) {
this.settings = settings == null ? Settings.IMP : settings;
}
public void setWorld(String world) { public void setWorld(String world) {
this.world = world; this.world = world;
this.weWorld = null; this.weWorld = null;
@ -300,7 +309,7 @@ public abstract class FaweQueue {
@Deprecated @Deprecated
public boolean next() { public boolean next() {
int amount = Settings.QUEUE.PARALLEL_THREADS; int amount = Settings.IMP.QUEUE.PARALLEL_THREADS;
ExecutorCompletionService service = SetQueue.IMP.getCompleterService(); ExecutorCompletionService service = SetQueue.IMP.getCompleterService();
long time = 20; // 30ms long time = 20; // 30ms
return next(amount, service, time); return next(amount, service, time);

View File

@ -62,7 +62,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
player.print(BBC.getPrefix() + BBC.NO_PERM.f("worldedit.tool.inspect")); player.print(BBC.getPrefix() + BBC.NO_PERM.f("worldedit.tool.inspect"));
return false; return false;
} }
if (!Settings.HISTORY.USE_DATABASE) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
player.print(BBC.getPrefix() + BBC.SETTING_DISABLE.f("history.use-database")); player.print(BBC.getPrefix() + BBC.SETTING_DISABLE.f("history.use-database"));
return false; return false;
} }

View File

@ -1,6 +1,9 @@
package com.boydti.fawe.object.changeset; package com.boydti.fawe.object.changeset;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
@ -10,7 +13,6 @@ import com.sk89q.worldedit.history.change.EntityCreate;
import com.sk89q.worldedit.history.change.EntityRemove; import com.sk89q.worldedit.history.change.EntityRemove;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.Iterator; import java.util.Iterator;
import java.util.UUID;
public class AbstractDelegateChangeSet extends FaweChangeSet { public class AbstractDelegateChangeSet extends FaweChangeSet {
public final FaweChangeSet parent; public final FaweChangeSet parent;
@ -24,8 +26,14 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
return parent; return parent;
} }
public static FaweChangeSet getDefaultChangeSet(World world, UUID uuid) { @Override
return FaweChangeSet.getDefaultChangeSet(world, uuid); public String getWorldName() {
return parent.getWorldName();
}
@Override
public World getWorld() {
return parent.getWorld();
} }
@Override @Override
@ -93,6 +101,11 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
parent.delete(); parent.delete();
} }
@Override
public EditSession toEditSession(FawePlayer player) {
return parent.toEditSession(player);
}
@Override @Override
public void add(EntityCreate change) { public void add(EntityCreate change) {
parent.add(change); parent.add(change);
@ -123,8 +136,18 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
parent.add(x, y, z, from, to); parent.add(x, y, z, from, to);
} }
@Override
public boolean isEmpty() {
return parent.isEmpty();
}
@Override @Override
public void add(int x, int y, int z, int combinedFrom, BaseBlock to) { public void add(int x, int y, int z, int combinedFrom, BaseBlock to) {
parent.add(x, y, z, combinedFrom, to); parent.add(x, y, z, combinedFrom, to);
} }
@Override
public void addChangeTask(FaweQueue queue) {
parent.addChangeTask(queue);
}
} }

View File

@ -71,7 +71,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
} }
private void init(UUID uuid, String worldName) { private void init(UUID uuid, String worldName) {
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.PATHS.HISTORY + File.separator + worldName + File.separator + uuid); File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + worldName + File.separator + uuid);
int max = 0; int max = 0;
if (folder.exists()) { if (folder.exists()) {
for (File file : folder.listFiles()) { for (File file : folder.listFiles()) {
@ -122,14 +122,14 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
private void init(UUID uuid, int i) { private void init(UUID uuid, int i) {
this.uuid = uuid; this.uuid = uuid;
this.index = i; this.index = i;
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(getWorld()) + File.separator + uuid); File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(getWorld()) + File.separator + uuid);
initFiles(folder); initFiles(folder);
} }
public void delete() { public void delete() {
Fawe.debug("Deleting history: " + Fawe.imp().getWorldName(getWorld()) + "/" + uuid + "/" + index); Fawe.debug("Deleting history: " + Fawe.imp().getWorldName(getWorld()) + "/" + uuid + "/" + index);
deleteFiles(); deleteFiles();
if (Settings.HISTORY.USE_DATABASE) { if (Settings.IMP.HISTORY.USE_DATABASE) {
RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld()); RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld());
db.delete(uuid, index); db.delete(uuid, index);
} }
@ -348,7 +348,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
} }
byte[] buffer = new byte[9]; byte[] buffer = new byte[9];
int i = 0; int i = 0;
int amount = (Settings.HISTORY.BUFFER_SIZE - HEADER_SIZE) / 9; int amount = (Settings.IMP.HISTORY.BUFFER_SIZE - HEADER_SIZE) / 9;
while (!shallow && ++i < amount) { while (!shallow && ++i < amount) {
if (gis.read(buffer) == -1) { if (gis.read(buffer) == -1) {
fis.close(); fis.close();

View File

@ -35,13 +35,13 @@ public abstract class FaweChangeSet implements ChangeSet {
private final String worldName; private final String worldName;
private final boolean mainThread; private final boolean mainThread;
private final int layers; private final int layers;
private AtomicInteger waitingCombined = new AtomicInteger(0); protected final AtomicInteger waitingCombined = new AtomicInteger(0);
private AtomicInteger waitingAsync = new AtomicInteger(0); private final AtomicInteger waitingAsync = new AtomicInteger(0);
private Object lockCombined = new Object(); // private Object lockCombined = new Object();
private Object lockAsync = new Object(); // private Object lockAsync = new Object();
public static FaweChangeSet getDefaultChangeSet(World world, UUID uuid) { public static FaweChangeSet getDefaultChangeSet(World world, UUID uuid) {
if (Settings.HISTORY.USE_DISK) { if (Settings.IMP.HISTORY.USE_DISK) {
return new DiskStorageHistory(world, uuid); return new DiskStorageHistory(world, uuid);
} else { } else {
return new MemoryOptimizedHistory(world); return new MemoryOptimizedHistory(world);
@ -76,8 +76,8 @@ public abstract class FaweChangeSet implements ChangeSet {
@Override @Override
public void run() { public void run() {
waitingAsync.decrementAndGet(); waitingAsync.decrementAndGet();
synchronized (lockAsync) { synchronized (waitingAsync) {
lockAsync.notifyAll(); waitingAsync.notifyAll();
} }
flush(); flush();
} }
@ -89,14 +89,14 @@ public abstract class FaweChangeSet implements ChangeSet {
try { try {
if (!Fawe.isMainThread()) { if (!Fawe.isMainThread()) {
while (waitingAsync.get() > 0) { while (waitingAsync.get() > 0) {
synchronized (lockAsync) { synchronized (waitingAsync) {
lockAsync.wait(1000); waitingAsync.wait(1000);
} }
} }
} }
while (waitingCombined.get() > 0) { while (waitingCombined.get() > 0) {
synchronized (lockCombined) { synchronized (waitingCombined) {
lockCombined.wait(1000); waitingCombined.wait(1000);
} }
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -263,7 +263,7 @@ public abstract class FaweChangeSet implements ChangeSet {
default: default:
char combinedIdPrevious = previousLayer != null ? previousLayer[index] : 0; char combinedIdPrevious = previousLayer != null ? previousLayer[index] : 0;
if (combinedIdCurrent != combinedIdPrevious) { if (combinedIdCurrent != combinedIdPrevious) {
synchronized (lockCombined) { synchronized (this) {
add(xx, yy, zz, combinedIdPrevious, combinedIdCurrent); add(xx, yy, zz, combinedIdPrevious, combinedIdCurrent);
} }
} }
@ -277,14 +277,14 @@ public abstract class FaweChangeSet implements ChangeSet {
// Tiles created // Tiles created
Map<Short, CompoundTag> tiles = next.getTiles(); Map<Short, CompoundTag> tiles = next.getTiles();
for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) { for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) {
synchronized (lockCombined) { synchronized (this) {
addTileCreate(entry.getValue()); addTileCreate(entry.getValue());
} }
} }
// Tiles removed // Tiles removed
tiles = previous.getTiles(); tiles = previous.getTiles();
for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) { for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) {
synchronized (lockCombined) { synchronized (this) {
addTileRemove(entry.getValue()); addTileRemove(entry.getValue());
} }
} }
@ -294,14 +294,14 @@ public abstract class FaweChangeSet implements ChangeSet {
// Entities created // Entities created
Set<CompoundTag> entities = next.getEntities(); Set<CompoundTag> entities = next.getEntities();
for (CompoundTag entityTag : entities) { for (CompoundTag entityTag : entities) {
synchronized (lockCombined) { synchronized (this) {
addEntityCreate(entityTag); addEntityCreate(entityTag);
} }
} }
// Entities removed // Entities removed
entities = previous.getEntities(); entities = previous.getEntities();
for (CompoundTag entityTag : entities) { for (CompoundTag entityTag : entities) {
synchronized (lockCombined) { synchronized (this) {
addEntityRemove(entityTag); addEntityRemove(entityTag);
} }
} }

View File

@ -32,11 +32,11 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
private FaweStreamPositionDelegate posDel; private FaweStreamPositionDelegate posDel;
public FaweStreamChangeSet(World world) { public FaweStreamChangeSet(World world) {
this(world, Settings.HISTORY.COMPRESSION_LEVEL, Settings.HISTORY.STORE_REDO, Settings.HISTORY.SMALL_EDITS); this(world, Settings.IMP.HISTORY.COMPRESSION_LEVEL, Settings.IMP.HISTORY.STORE_REDO, Settings.IMP.HISTORY.SMALL_EDITS);
} }
public FaweStreamChangeSet(String world) { public FaweStreamChangeSet(String world) {
this(world, Settings.HISTORY.COMPRESSION_LEVEL, Settings.HISTORY.STORE_REDO, Settings.HISTORY.SMALL_EDITS); this(world, Settings.IMP.HISTORY.COMPRESSION_LEVEL, Settings.IMP.HISTORY.STORE_REDO, Settings.IMP.HISTORY.SMALL_EDITS);
} }
public FaweStreamChangeSet(String world, int compression, boolean storeRedo, boolean smallLoc) { public FaweStreamChangeSet(String world, int compression, boolean storeRedo, boolean smallLoc) {
@ -376,8 +376,10 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
idDel.readCombined(is, change, dir); idDel.readCombined(is, change, dir);
return change; return change;
} catch (EOFException ignoreOEF) { } catch (EOFException ignoreOEF) {
ignoreOEF.printStackTrace();
return null; return null;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
MainUtil.handleError(e); MainUtil.handleError(e);
} }
return null; return null;

View File

@ -118,7 +118,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
} }
synchronized (this) { synchronized (this) {
setOrigin(x, z); setOrigin(x, z);
idsStream = new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE); idsStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
idsStreamZip = getCompressedOS(idsStream); idsStreamZip = getCompressedOS(idsStream);
writeHeader(idsStreamZip, x, y, z); writeHeader(idsStreamZip, x, y, z);
return idsStreamZip; return idsStreamZip;
@ -140,7 +140,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
if (entCStreamZip != null) { if (entCStreamZip != null) {
return entCStreamZip; return entCStreamZip;
} }
entCStream = new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE); entCStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
return entCStreamZip = new NBTOutputStream(getCompressedOS(entCStream)); return entCStreamZip = new NBTOutputStream(getCompressedOS(entCStream));
} }
@ -149,7 +149,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
if (entRStreamZip != null) { if (entRStreamZip != null) {
return entRStreamZip; return entRStreamZip;
} }
entRStream = new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE); entRStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
return entRStreamZip = new NBTOutputStream(getCompressedOS(entRStream)); return entRStreamZip = new NBTOutputStream(getCompressedOS(entRStream));
} }
@ -158,7 +158,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
if (tileCStreamZip != null) { if (tileCStreamZip != null) {
return tileCStreamZip; return tileCStreamZip;
} }
tileCStream = new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE); tileCStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
return tileCStreamZip = new NBTOutputStream(getCompressedOS(tileCStream)); return tileCStreamZip = new NBTOutputStream(getCompressedOS(tileCStream));
} }
@ -167,7 +167,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
if (tileRStreamZip != null) { if (tileRStreamZip != null) {
return tileRStreamZip; return tileRStreamZip;
} }
tileRStream = new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE); tileRStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
return tileRStreamZip = new NBTOutputStream(getCompressedOS(tileRStream)); return tileRStreamZip = new NBTOutputStream(getCompressedOS(tileRStream));
} }

View File

@ -58,7 +58,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
private int last; private int last;
public DiskOptimizedClipboard(int width, int height, int length, UUID uuid) { public DiskOptimizedClipboard(int width, int height, int length, UUID uuid) {
this(width, height, length, MainUtil.getFile(Fawe.imp().getDirectory(), Settings.PATHS.CLIPBOARD + File.separator + uuid + ".bd")); this(width, height, length, MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.CLIPBOARD + File.separator + uuid + ".bd"));
} }
public DiskOptimizedClipboard(File file) { public DiskOptimizedClipboard(File file) {
@ -183,7 +183,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
} }
public DiskOptimizedClipboard(int width, int height, int length) { public DiskOptimizedClipboard(int width, int height, int length) {
this(width, height, length, MainUtil.getFile(Fawe.imp().getDirectory(), Settings.PATHS.CLIPBOARD + File.separator + UUID.randomUUID() + ".bd")); this(width, height, length, MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.CLIPBOARD + File.separator + UUID.randomUUID() + ".bd"));
} }
public void close() { public void close() {

View File

@ -59,7 +59,7 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
private int compressionLevel; private int compressionLevel;
public MemoryOptimizedClipboard(int width, int height, int length) { public MemoryOptimizedClipboard(int width, int height, int length) {
this(width, height, length, Settings.CLIPBOARD.COMPRESSION_LEVEL); this(width, height, length, Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL);
} }
public MemoryOptimizedClipboard(int width, int height, int length, int compressionLevel) { public MemoryOptimizedClipboard(int width, int height, int length, int compressionLevel) {

View File

@ -64,7 +64,7 @@ public class DefaultProgressTracker extends RunnableVal2<FaweQueue.ProgressType,
private final void send() { private final void send() {
// Avoid duplicates // Avoid duplicates
long currentTick = System.currentTimeMillis() / 50; long currentTick = System.currentTimeMillis() / 50;
if (currentTick > lastTick + Settings.QUEUE.PROGRESS.INTERVAL) { if (currentTick > lastTick + Settings.IMP.QUEUE.PROGRESS.INTERVAL) {
lastTick = currentTick; lastTick = currentTick;
TaskManager.IMP.task(new Runnable() { // Run on main thread TaskManager.IMP.task(new Runnable() { // Run on main thread
@Override @Override

View File

@ -135,7 +135,7 @@ public class FaweFormat implements ClipboardReader, ClipboardWriter {
} else { } else {
ox = in.readInt(); ox = in.readInt();
oz = in.readInt(); oz = in.readInt();
FaweOutputStream tmp = new FaweOutputStream(new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE)); FaweOutputStream tmp = new FaweOutputStream(new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE));
int width = 0; int width = 0;
int height = 0; int height = 0;
int length = 0; int length = 0;

View File

@ -28,7 +28,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
setupBlockQueue(); setupBlockQueue();
setupSchematicHandler(); setupSchematicHandler();
setupChunkManager(); setupChunkManager();
if (Settings.PLATFORM.equals("Bukkit")) { if (Settings.PLATFORM.equalsIgnoreCase("bukkit")) {
new FaweTrim(); new FaweTrim();
} }
if (MainCommand.getInstance().getCommand("generatebiome") == null) { if (MainCommand.getInstance().getCommand("generatebiome") == null) {

View File

@ -114,7 +114,7 @@ public class EditSessionBuilder {
public EditSessionBuilder changeSet(boolean disk, @Nullable UUID uuid, int compression) { public EditSessionBuilder changeSet(boolean disk, @Nullable UUID uuid, int compression) {
if (world == null) { if (world == null) {
if (disk) { if (disk) {
if (Settings.HISTORY.USE_DATABASE) { if (Settings.IMP.HISTORY.USE_DATABASE) {
this.changeSet = new RollbackOptimizedHistory(worldName, uuid); this.changeSet = new RollbackOptimizedHistory(worldName, uuid);
} else { } else {
this.changeSet = new DiskStorageHistory(worldName, uuid); this.changeSet = new DiskStorageHistory(worldName, uuid);
@ -123,7 +123,7 @@ public class EditSessionBuilder {
this.changeSet = new MemoryOptimizedHistory(worldName); this.changeSet = new MemoryOptimizedHistory(worldName);
} }
} else if (disk) { } else if (disk) {
if (Settings.HISTORY.USE_DATABASE) { if (Settings.IMP.HISTORY.USE_DATABASE) {
this.changeSet = new RollbackOptimizedHistory(world, uuid); this.changeSet = new RollbackOptimizedHistory(world, uuid);
} else { } else {
this.changeSet = new DiskStorageHistory(world, uuid); this.changeSet = new DiskStorageHistory(world, uuid);

View File

@ -192,7 +192,7 @@ public class MainUtil {
} }
public static FaweOutputStream getCompressedOS(OutputStream os) throws IOException { public static FaweOutputStream getCompressedOS(OutputStream os) throws IOException {
return getCompressedOS(os, Settings.HISTORY.COMPRESSION_LEVEL); return getCompressedOS(os, Settings.IMP.HISTORY.COMPRESSION_LEVEL);
} }
public static long getSize(ChangeSet changeSet) { public static long getSize(ChangeSet changeSet) {
@ -209,7 +209,7 @@ public class MainUtil {
} }
public static FaweOutputStream getCompressedOS(OutputStream os, int amount) throws IOException { public static FaweOutputStream getCompressedOS(OutputStream os, int amount) throws IOException {
return getCompressedOS(os, amount, Settings.HISTORY.BUFFER_SIZE); return getCompressedOS(os, amount, Settings.IMP.HISTORY.BUFFER_SIZE);
} }
private static final LZ4Factory FACTORY = LZ4Factory.fastestInstance(); private static final LZ4Factory FACTORY = LZ4Factory.fastestInstance();
@ -273,7 +273,7 @@ public class MainUtil {
} }
public static FaweInputStream getCompressedIS(InputStream is) throws IOException { public static FaweInputStream getCompressedIS(InputStream is) throws IOException {
return getCompressedIS(is, Settings.HISTORY.BUFFER_SIZE); return getCompressedIS(is, Settings.IMP.HISTORY.BUFFER_SIZE);
} }
public static FaweInputStream getCompressedIS(InputStream is, int buffer) throws IOException { public static FaweInputStream getCompressedIS(InputStream is, int buffer) throws IOException {
@ -306,15 +306,15 @@ public class MainUtil {
final String website; final String website;
if (uuid == null) { if (uuid == null) {
uuid = UUID.randomUUID(); uuid = UUID.randomUUID();
website = Settings.WEB.URL + "upload.php?" + uuid; website = Settings.IMP.WEB.URL + "upload.php?" + uuid;
filename = "plot." + extension; filename = "plot." + extension;
} else { } else {
website = Settings.WEB.URL + "save.php?" + uuid; website = Settings.IMP.WEB.URL + "save.php?" + uuid;
filename = file + '.' + extension; filename = file + '.' + extension;
} }
final URL url; final URL url;
try { try {
url = new URL(Settings.WEB.URL + "?key=" + uuid + "&type=" + extension); url = new URL(Settings.IMP.WEB.URL + "?key=" + uuid + "&type=" + extension);
String boundary = Long.toHexString(System.currentTimeMillis()); String boundary = Long.toHexString(System.currentTimeMillis());
URLConnection con = new URL(website).openConnection(); URLConnection con = new URL(website).openConnection();
con.setDoOutput(true); con.setDoOutput(true);

View File

@ -35,7 +35,7 @@ public class MemUtil {
} }
final long heapFreeSize = Runtime.getRuntime().freeMemory(); final long heapFreeSize = Runtime.getRuntime().freeMemory();
final int size = (int) ((heapFreeSize * 100) / heapMaxSize); final int size = (int) ((heapFreeSize * 100) / heapMaxSize);
if (size > (100 - Settings.MAX_MEMORY_PERCENT)) { if (size > (100 - Settings.IMP.MAX_MEMORY_PERCENT)) {
memoryPlentifulTask(); memoryPlentifulTask();
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
} }

View File

@ -73,7 +73,7 @@ public class SetQueue {
@Override @Override
public void run() { public void run() {
try { try {
targetTPS = 18 - Math.max(Settings.QUEUE.EXTRA_TIME_MS * 0.05, 0); targetTPS = 18 - Math.max(Settings.IMP.QUEUE.EXTRA_TIME_MS * 0.05, 0);
do { do {
Runnable task = tasks.poll(); Runnable task = tasks.poll();
if (task != null) { if (task != null) {
@ -90,7 +90,7 @@ public class SetQueue {
if (!MemUtil.isMemoryFree()) { if (!MemUtil.isMemoryFree()) {
final int mem = MemUtil.calculateMemory(); final int mem = MemUtil.calculateMemory();
if (mem != Integer.MAX_VALUE) { if (mem != Integer.MAX_VALUE) {
if ((mem <= 1) && Settings.PREVENT_CRASHES) { if ((mem <= 1) && Settings.IMP.PREVENT_CRASHES) {
for (FaweQueue queue : getAllQueues()) { for (FaweQueue queue : getAllQueues()) {
queue.saveMemory(); queue.saveMemory();
} }
@ -111,17 +111,17 @@ public class SetQueue {
if (Thread.currentThread() != Fawe.get().getMainThread()) { if (Thread.currentThread() != Fawe.get().getMainThread()) {
throw new IllegalStateException("This shouldn't be possible for placement to occur off the main thread"); throw new IllegalStateException("This shouldn't be possible for placement to occur off the main thread");
} }
long time = Settings.QUEUE.EXTRA_TIME_MS + 50 + Math.min((50 + SetQueue.this.last) - (SetQueue.this.last = System.currentTimeMillis()), SetQueue.this.secondLast - System.currentTimeMillis()); long time = Settings.IMP.QUEUE.EXTRA_TIME_MS + 50 + Math.min((50 + SetQueue.this.last) - (SetQueue.this.last = System.currentTimeMillis()), SetQueue.this.secondLast - System.currentTimeMillis());
// Disable the async catcher as it can't discern async vs parallel // Disable the async catcher as it can't discern async vs parallel
boolean parallel = Settings.QUEUE.PARALLEL_THREADS > 1; boolean parallel = Settings.IMP.QUEUE.PARALLEL_THREADS > 1;
queue.startSet(parallel); queue.startSet(parallel);
try { try {
if (!queue.next(Settings.QUEUE.PARALLEL_THREADS, getCompleterService(), time) && queue.getStage() == QueueStage.ACTIVE) { if (!queue.next(Settings.IMP.QUEUE.PARALLEL_THREADS, getCompleterService(), time) && queue.getStage() == QueueStage.ACTIVE) {
queue.setStage(QueueStage.NONE); queue.setStage(QueueStage.NONE);
queue.runTasks(); queue.runTasks();
} }
} catch (Throwable e) { } catch (Throwable e) {
pool.awaitQuiescence(Settings.QUEUE.DISCARD_AFTER_MS, TimeUnit.MILLISECONDS); pool.awaitQuiescence(Settings.IMP.QUEUE.DISCARD_AFTER_MS, TimeUnit.MILLISECONDS);
completer = new ExecutorCompletionService(pool); completer = new ExecutorCompletionService(pool);
e.printStackTrace(); e.printStackTrace();
} }
@ -214,11 +214,11 @@ public class SetQueue {
} }
public void flush(FaweQueue queue) { public void flush(FaweQueue queue) {
queue.startSet(Settings.QUEUE.PARALLEL_THREADS > 1); queue.startSet(Settings.IMP.QUEUE.PARALLEL_THREADS > 1);
try { try {
queue.next(Settings.QUEUE.PARALLEL_THREADS, getCompleterService(), Long.MAX_VALUE); queue.next(Settings.IMP.QUEUE.PARALLEL_THREADS, getCompleterService(), Long.MAX_VALUE);
} catch (Throwable e) { } catch (Throwable e) {
pool.awaitQuiescence(Settings.QUEUE.DISCARD_AFTER_MS, TimeUnit.MILLISECONDS); pool.awaitQuiescence(Settings.IMP.QUEUE.DISCARD_AFTER_MS, TimeUnit.MILLISECONDS);
completer = new ExecutorCompletionService(pool); completer = new ExecutorCompletionService(pool);
MainUtil.handleError(e); MainUtil.handleError(e);
} finally { } finally {
@ -251,7 +251,7 @@ public class SetQueue {
long age = now - queue.getModified(); long age = now - queue.getModified();
total += queue.size(); total += queue.size();
if (queue.size() == 0) { if (queue.size() == 0) {
if (age > Settings.QUEUE.DISCARD_AFTER_MS) { if (age > Settings.IMP.QUEUE.DISCARD_AFTER_MS) {
queue.setStage(QueueStage.NONE); queue.setStage(QueueStage.NONE);
queue.runTasks(); queue.runTasks();
iter.remove(); iter.remove();
@ -261,11 +261,11 @@ public class SetQueue {
if (firstNonEmpty == null) { if (firstNonEmpty == null) {
firstNonEmpty = queue; firstNonEmpty = queue;
} }
if (total > Settings.QUEUE.TARGET_SIZE) { if (total > Settings.IMP.QUEUE.TARGET_SIZE) {
firstNonEmpty.setModified(now); firstNonEmpty.setModified(now);
return firstNonEmpty; return firstNonEmpty;
} }
if (age > Settings.QUEUE.MAX_WAIT_MS) { if (age > Settings.IMP.QUEUE.MAX_WAIT_MS) {
queue.setModified(now); queue.setModified(now);
return queue; return queue;
} }
@ -293,20 +293,20 @@ public class SetQueue {
} }
if (inactiveQueues.size() > 0) { if (inactiveQueues.size() > 0) {
ArrayList<FaweQueue> tmp = new ArrayList<>(inactiveQueues); ArrayList<FaweQueue> tmp = new ArrayList<>(inactiveQueues);
if (Settings.QUEUE.MAX_WAIT_MS != -1) { if (Settings.IMP.QUEUE.MAX_WAIT_MS != -1) {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (lastSuccess == 0) { if (lastSuccess == 0) {
lastSuccess = now; lastSuccess = now;
} }
long diff = now - lastSuccess; long diff = now - lastSuccess;
if (diff > Settings.QUEUE.MAX_WAIT_MS) { if (diff > Settings.IMP.QUEUE.MAX_WAIT_MS) {
for (FaweQueue queue : tmp) { for (FaweQueue queue : tmp) {
boolean result = queue.next(); boolean result = queue.next();
if (result) { if (result) {
return result; return result;
} }
} }
if (diff > Settings.QUEUE.DISCARD_AFTER_MS) { if (diff > Settings.IMP.QUEUE.DISCARD_AFTER_MS) {
// These edits never finished // These edits never finished
for (FaweQueue queue : tmp) { for (FaweQueue queue : tmp) {
queue.setStage(QueueStage.NONE); queue.setStage(QueueStage.NONE);
@ -317,12 +317,12 @@ public class SetQueue {
return false; return false;
} }
} }
if (Settings.QUEUE.TARGET_SIZE != -1) { if (Settings.IMP.QUEUE.TARGET_SIZE != -1) {
int total = 0; int total = 0;
for (FaweQueue queue : tmp) { for (FaweQueue queue : tmp) {
total += queue.size(); total += queue.size();
} }
if (total > Settings.QUEUE.TARGET_SIZE) { if (total > Settings.IMP.QUEUE.TARGET_SIZE) {
for (FaweQueue queue : tmp) { for (FaweQueue queue : tmp) {
boolean result = queue.next(); boolean result = queue.next();
if (result) { if (result) {

View File

@ -92,7 +92,7 @@ public abstract class TaskManager {
return; return;
} }
if (numThreads == null) { if (numThreads == null) {
numThreads = Settings.QUEUE.PARALLEL_THREADS; numThreads = Settings.IMP.QUEUE.PARALLEL_THREADS;
} }
if (numThreads <= 1) { if (numThreads <= 1) {
for (Runnable run : runnables) { for (Runnable run : runnables) {
@ -274,7 +274,7 @@ public abstract class TaskManager {
synchronized (running) { synchronized (running) {
while (running.get()) { while (running.get()) {
running.wait(timout); running.wait(timout);
if (running.get() && System.currentTimeMillis() - start > Settings.QUEUE.DISCARD_AFTER_MS) { if (running.get() && System.currentTimeMillis() - start > Settings.IMP.QUEUE.DISCARD_AFTER_MS) {
new RuntimeException("FAWE is taking a long time to execute a task (might just be a symptom): ").printStackTrace(); new RuntimeException("FAWE is taking a long time to execute a task (might just be a symptom): ").printStackTrace();
Fawe.debug("For full debug information use: /fawe threads"); Fawe.debug("For full debug information use: /fawe threads");
} }

View File

@ -72,7 +72,7 @@ public class WEManager {
* @return * @return
*/ */
public RegionWrapper[] getMask(final FawePlayer<?> player, FaweMaskManager.MaskType type) { public RegionWrapper[] getMask(final FawePlayer<?> player, FaweMaskManager.MaskType type) {
if (player.hasPermission("fawe.bypass") || !Settings.REGION_RESTRICTIONS) { if (player.hasPermission("fawe.bypass") || !Settings.IMP.REGION_RESTRICTIONS) {
return new RegionWrapper[] {new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE)}; return new RegionWrapper[] {new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE)};
} }
HashSet<RegionWrapper> mask = new HashSet<>(); HashSet<RegionWrapper> mask = new HashSet<>();

View File

@ -218,14 +218,14 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
} }
this.player = player; this.player = player;
if (changeSet == null) { if (changeSet == null) {
if (Settings.HISTORY.USE_DISK) { if (Settings.IMP.HISTORY.USE_DISK) {
UUID uuid = player == null ? CONSOLE : player.getUUID(); UUID uuid = player == null ? CONSOLE : player.getUUID();
if (Settings.HISTORY.USE_DATABASE) { if (Settings.IMP.HISTORY.USE_DATABASE) {
changeSet = new RollbackOptimizedHistory(world, uuid); changeSet = new RollbackOptimizedHistory(world, uuid);
} else { } else {
changeSet = new DiskStorageHistory(world, uuid); changeSet = new DiskStorageHistory(world, uuid);
} }
} else if (Settings.HISTORY.COMBINE_STAGES && Settings.HISTORY.COMPRESSION_LEVEL == 0 && !(queue instanceof MCAQueue)) { } else if (Settings.IMP.HISTORY.COMBINE_STAGES && Settings.IMP.HISTORY.COMPRESSION_LEVEL == 0 && !(queue instanceof MCAQueue)) {
changeSet = new CPUOptimizedChangeSet(world); changeSet = new CPUOptimizedChangeSet(world);
} else { } else {
changeSet = new MemoryOptimizedHistory(world); changeSet = new MemoryOptimizedHistory(world);
@ -248,7 +248,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
} }
if (fastmode == null) { if (fastmode == null) {
if (player == null) { if (player == null) {
fastmode = Settings.HISTORY.ENABLE_FOR_CONSOLE; fastmode = Settings.IMP.HISTORY.ENABLE_FOR_CONSOLE;
} else { } else {
fastmode = player.getSession().hasFastMode(); fastmode = player.getSession().hasFastMode();
} }
@ -257,7 +257,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
checkMemory = player != null && !fastmode; checkMemory = player != null && !fastmode;
} }
if (combineStages == null) { if (combineStages == null) {
combineStages = Settings.HISTORY.COMBINE_STAGES && !(queue instanceof MCAQueue); combineStages = Settings.IMP.HISTORY.COMBINE_STAGES && !(queue instanceof MCAQueue);
} }
if (checkMemory) { if (checkMemory) {
if (MemUtil.isMemoryLimitedSlow()) { if (MemUtil.isMemoryLimitedSlow()) {
@ -277,12 +277,12 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
queue = SetQueue.IMP.getNewQueue(this, fastmode || limit.FAST_PLACEMENT, autoQueue); queue = SetQueue.IMP.getNewQueue(this, fastmode || limit.FAST_PLACEMENT, autoQueue);
} }
} }
if (Settings.EXPERIMENTAL.ANVIL_QUEUE_MODE && !(queue instanceof MCAQueue)) { if (Settings.IMP.EXPERIMENTAL.ANVIL_QUEUE_MODE && !(queue instanceof MCAQueue)) {
queue = new MCAQueue(queue); queue = new MCAQueue(queue);
} }
this.queue = queue; this.queue = queue;
this.queue.addEditSession(this); this.queue.addEditSession(this);
if (Settings.QUEUE.PROGRESS.DISPLAY && player != null) { if (Settings.IMP.QUEUE.PROGRESS.DISPLAY && player != null) {
this.queue.setProgressTask(new DefaultProgressTracker(player)); this.queue.setProgressTask(new DefaultProgressTracker(player));
} }
this.bypassAll = wrapExtent(new FastWorldEditExtent(world, queue), bus, event, Stage.BEFORE_CHANGE); this.bypassAll = wrapExtent(new FastWorldEditExtent(world, queue), bus, event, Stage.BEFORE_CHANGE);
@ -482,13 +482,13 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
} }
if (toReturn != extent) { if (toReturn != extent) {
String className = toReturn.getClass().getName().toLowerCase(); String className = toReturn.getClass().getName().toLowerCase();
for (String allowed : Settings.EXTENT.ALLOWED_PLUGINS) { for (String allowed : Settings.IMP.EXTENT.ALLOWED_PLUGINS) {
if (className.contains(allowed.toLowerCase())) { if (className.contains(allowed.toLowerCase())) {
this.wrapped = true; this.wrapped = true;
return (AbstractDelegateExtent) toReturn; return (AbstractDelegateExtent) toReturn;
} }
} }
if (Settings.EXTENT.DEBUG) { if (Settings.IMP.EXTENT.DEBUG) {
Fawe.debug("&cPotentially unsafe extent blocked: " + toReturn.getClass().getName()); Fawe.debug("&cPotentially unsafe extent blocked: " + toReturn.getClass().getName());
Fawe.debug("&8 - &7For area restrictions, it is recommended to use the FaweAPI"); Fawe.debug("&8 - &7For area restrictions, it is recommended to use the FaweAPI");
Fawe.debug("&8 - &7For block logging, it is recommended to use use BlocksHub"); Fawe.debug("&8 - &7For block logging, it is recommended to use use BlocksHub");
@ -1316,7 +1316,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
queue.flush(); queue.flush();
} }
if (getChangeSet() != null) { if (getChangeSet() != null) {
if (Settings.HISTORY.COMBINE_STAGES) { if (Settings.IMP.HISTORY.COMBINE_STAGES) {
((FaweChangeSet) getChangeSet()).flushAsync(); ((FaweChangeSet) getChangeSet()).flushAsync();
} else { } else {
((FaweChangeSet) getChangeSet()).flush(); ((FaweChangeSet) getChangeSet()).flush();

View File

@ -198,7 +198,7 @@ public class LocalSession {
if (world == null || uuid == null) { if (world == null || uuid == null) {
return false; return false;
} }
if (Settings.HISTORY.USE_DISK) { if (Settings.IMP.HISTORY.USE_DISK) {
MAX_HISTORY_SIZE = Integer.MAX_VALUE; MAX_HISTORY_SIZE = Integer.MAX_VALUE;
} }
if (!world.equals(currentWorld)) { if (!world.equals(currentWorld)) {
@ -219,7 +219,7 @@ public class LocalSession {
private boolean loadHistoryChangeSets(UUID uuid, World world) { private boolean loadHistoryChangeSets(UUID uuid, World world) {
final List<Integer> editIds = new ArrayList<>(); final List<Integer> editIds = new ArrayList<>();
final File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid); final File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid);
if (folder.isDirectory()) { if (folder.isDirectory()) {
final FileNameExtensionFilter filter = new FileNameExtensionFilter("BlockData files","bd"); final FileNameExtensionFilter filter = new FileNameExtensionFilter("BlockData files","bd");
folder.listFiles(new FileFilter() { folder.listFiles(new FileFilter() {
@ -249,7 +249,7 @@ public class LocalSession {
@Deprecated @Deprecated
private void deleteOldFiles(UUID uuid, World world, long maxBytes) throws IOException { private void deleteOldFiles(UUID uuid, World world, long maxBytes) throws IOException {
final File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid); final File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid);
final ArrayList<Integer> ids = new ArrayList<Integer>(); final ArrayList<Integer> ids = new ArrayList<Integer>();
final HashMap<Integer, ArrayDeque<Path>> paths = new HashMap<>(); final HashMap<Integer, ArrayDeque<Path>> paths = new HashMap<>();
@ -298,10 +298,10 @@ public class LocalSession {
} }
private void loadHistoryNegativeIndex(UUID uuid, World world) { private void loadHistoryNegativeIndex(UUID uuid, World world) {
if (!Settings.HISTORY.USE_DISK) { if (!Settings.IMP.HISTORY.USE_DISK) {
return; return;
} }
File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid + File.separator + "index"); File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid + File.separator + "index");
if (file.exists()) { if (file.exists()) {
try { try {
FaweInputStream is = new FaweInputStream(new FileInputStream(file)); FaweInputStream is = new FaweInputStream(new FileInputStream(file));
@ -316,10 +316,10 @@ public class LocalSession {
} }
private void saveHistoryNegativeIndex(UUID uuid, World world) { private void saveHistoryNegativeIndex(UUID uuid, World world) {
if (world == null || !Settings.HISTORY.USE_DISK) { if (world == null || !Settings.IMP.HISTORY.USE_DISK) {
return; return;
} }
File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid + File.separator + "index"); File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid + File.separator + "index");
if (getHistoryNegativeIndex() != 0) { if (getHistoryNegativeIndex() != 0) {
try { try {
if (!file.exists()) { if (!file.exists()) {
@ -487,7 +487,7 @@ public class LocalSession {
} else { } else {
history.add(0, changeSet); history.add(0, changeSet);
} }
while (((!Settings.HISTORY.USE_DISK && history.size() > MAX_HISTORY_SIZE) || (historySize >> 20) > limitMb) && history.size() > 1) { while (((!Settings.IMP.HISTORY.USE_DISK && history.size() > MAX_HISTORY_SIZE) || (historySize >> 20) > limitMb) && history.size() > 1) {
FaweChangeSet item = (FaweChangeSet) history.remove(0); FaweChangeSet item = (FaweChangeSet) history.remove(0);
item.delete(); item.delete();
long size = MainUtil.getSize(item); long size = MainUtil.getSize(item);
@ -517,7 +517,7 @@ public class LocalSession {
checkNotNull(player); checkNotNull(player);
loadSessionHistoryFromDisk(player.getUniqueId(), player.getWorld()); loadSessionHistoryFromDisk(player.getUniqueId(), player.getWorld());
if (getHistoryNegativeIndex() < history.size()) { if (getHistoryNegativeIndex() < history.size()) {
FaweChangeSet changeSet = (FaweChangeSet) history.get(getHistoryIndex()); FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
final FawePlayer fp = FawePlayer.wrap(player); final FawePlayer fp = FawePlayer.wrap(player);
EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld()) EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld())
.allowedRegionsEverywhere() .allowedRegionsEverywhere()
@ -566,7 +566,7 @@ public class LocalSession {
if (getHistoryNegativeIndex() > 0) { if (getHistoryNegativeIndex() > 0) {
setDirty(); setDirty();
historyNegativeIndex--; historyNegativeIndex--;
FaweChangeSet changeSet = (FaweChangeSet) history.get(getHistoryIndex()); FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
final FawePlayer fp = FawePlayer.wrap(player); final FawePlayer fp = FawePlayer.wrap(player);
EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld()) EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld())
.allowedRegionsEverywhere() .allowedRegionsEverywhere()

View File

@ -294,7 +294,7 @@ public class BrushCommands {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
FawePlayer fp = FawePlayer.wrap(player); FawePlayer fp = FawePlayer.wrap(player);
FaweLimit limit = Settings.getLimit(fp); FaweLimit limit = Settings.IMP.getLimit(fp);
iterations = Math.min(limit.MAX_ITERATIONS, iterations); iterations = Math.min(limit.MAX_ITERATIONS, iterations);
BrushTool tool = session.getBrushTool(player.getItemInHand()); BrushTool tool = session.getBrushTool(player.getItemInHand());
tool.setSize(radius); tool.setSize(radius);

View File

@ -81,7 +81,7 @@ public class HistoryCommands {
) )
@CommandPermissions("worldedit.history.rollback") @CommandPermissions("worldedit.history.rollback")
public void faweRollback(final Player player, LocalSession session, final String user, @Optional("0") int radius, @Optional("0") String time) throws WorldEditException { public void faweRollback(final Player player, LocalSession session, final String user, @Optional("0") int radius, @Optional("0") String time) throws WorldEditException {
if (!Settings.HISTORY.USE_DATABASE) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
BBC.SETTING_DISABLE.send(player, "history.use-database"); BBC.SETTING_DISABLE.send(player, "history.use-database");
return; return;
} }
@ -92,7 +92,7 @@ public class HistoryCommands {
BBC.NO_PERM.send(player, "fawe.rollback.import"); BBC.NO_PERM.send(player, "fawe.rollback.import");
return; return;
} }
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.PATHS.HISTORY); File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY);
if (!folder.exists()) { if (!folder.exists()) {
return; return;
} }

View File

@ -105,7 +105,7 @@ public class SchematicCommands {
return; return;
} }
UUID uuid = UUID.fromString(filename.substring(4)); UUID uuid = UUID.fromString(filename.substring(4));
URL base = new URL(Settings.WEB.URL); URL base = new URL(Settings.IMP.WEB.URL);
URL url = new URL(base, "uploads/" + uuid + ".schematic"); URL url = new URL(base, "uploads/" + uuid + ".schematic");
ReadableByteChannel rbc = Channels.newChannel(url.openStream()); ReadableByteChannel rbc = Channels.newChannel(url.openStream());
in = Channels.newInputStream(rbc); in = Channels.newInputStream(rbc);

View File

@ -67,7 +67,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent {
checkNotNull(region); checkNotNull(region);
this.region = region.clone(); this.region = region.clone();
this.size = getDimensions(); this.size = getDimensions();
this.IMP = Settings.CLIPBOARD.USE_DISK ? new DiskOptimizedClipboard(size.getBlockX(), size.getBlockY(), size.getBlockZ()) : new MemoryOptimizedClipboard(size.getBlockX(), size.getBlockY(), size.getBlockZ()); this.IMP = Settings.IMP.CLIPBOARD.USE_DISK ? new DiskOptimizedClipboard(size.getBlockX(), size.getBlockY(), size.getBlockZ()) : new MemoryOptimizedClipboard(size.getBlockX(), size.getBlockY(), size.getBlockZ());
this.origin = region.getMinimumPoint(); this.origin = region.getMinimumPoint();
this.mx = origin.getBlockX(); this.mx = origin.getBlockX();
this.my = origin.getBlockY(); this.my = origin.getBlockY();
@ -85,7 +85,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent {
checkNotNull(region); checkNotNull(region);
this.region = region.clone(); this.region = region.clone();
this.size = getDimensions(); this.size = getDimensions();
this.IMP = Settings.CLIPBOARD.USE_DISK ? new DiskOptimizedClipboard(size.getBlockX(), size.getBlockY(), size.getBlockZ(), clipboardId) : new MemoryOptimizedClipboard(size.getBlockX(), size.getBlockY(), size.getBlockZ()); this.IMP = Settings.IMP.CLIPBOARD.USE_DISK ? new DiskOptimizedClipboard(size.getBlockX(), size.getBlockY(), size.getBlockZ(), clipboardId) : new MemoryOptimizedClipboard(size.getBlockX(), size.getBlockY(), size.getBlockZ());
this.origin = region.getMinimumPoint(); this.origin = region.getMinimumPoint();
this.mx = origin.getBlockX(); this.mx = origin.getBlockX();
this.my = origin.getBlockY(); this.my = origin.getBlockY();

View File

@ -357,7 +357,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
@Override @Override
public Iterator<BlockVector> iterator() { public Iterator<BlockVector> iterator() {
if (Settings.HISTORY.COMPRESSION_LEVEL >= 9) { if (Settings.IMP.HISTORY.COMPRESSION_LEVEL >= 9) {
return iterator_old(); return iterator_old();
} }
final MutableBlockVector mutable = new MutableBlockVector(0,0,0); final MutableBlockVector mutable = new MutableBlockVector(0,0,0);

View File

@ -21,12 +21,12 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
@Override @Override
public void sendTitle(String head, String sub) { // Not supported public void sendTitle(String head, String sub) { // Not supported
Settings.QUEUE.PROGRESS.DISPLAY = false; Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
} }
@Override @Override
public void resetTitle() { // Not supported public void resetTitle() { // Not supported
Settings.QUEUE.PROGRESS.DISPLAY = false; Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
} }
@Override @Override

View File

@ -21,12 +21,12 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
@Override @Override
public void sendTitle(String head, String sub) { // Not supported public void sendTitle(String head, String sub) { // Not supported
Settings.QUEUE.PROGRESS.DISPLAY = false; Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
} }
@Override @Override
public void resetTitle() { // Not supported public void resetTitle() { // Not supported
Settings.QUEUE.PROGRESS.DISPLAY = false; Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
} }
@Override @Override

View File

@ -21,12 +21,12 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
@Override @Override
public void sendTitle(String head, String sub) { // Not supported public void sendTitle(String head, String sub) { // Not supported
Settings.QUEUE.PROGRESS.DISPLAY = false; Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
} }
@Override @Override
public void resetTitle() { // Not supported public void resetTitle() { // Not supported
Settings.QUEUE.PROGRESS.DISPLAY = false; Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
} }
@Override @Override

View File

@ -22,12 +22,12 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
@Override @Override
public void sendTitle(String head, String sub) { // Not supported public void sendTitle(String head, String sub) { // Not supported
Settings.QUEUE.PROGRESS.DISPLAY = false; Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
} }
@Override @Override
public void resetTitle() { // Not supported public void resetTitle() { // Not supported
Settings.QUEUE.PROGRESS.DISPLAY = false; Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
} }
@Override @Override

View File

@ -22,12 +22,12 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
@Override @Override
public void sendTitle(String head, String sub) { // Not supported public void sendTitle(String head, String sub) { // Not supported
Settings.QUEUE.PROGRESS.DISPLAY = false; Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
} }
@Override @Override
public void resetTitle() { // Not supported public void resetTitle() { // Not supported
Settings.QUEUE.PROGRESS.DISPLAY = false; Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
} }
@Override @Override

View File

@ -76,7 +76,7 @@ public class NukkitWorldEdit extends PluginBase {
try { try {
Fawe.set(new FaweNukkit(this)); Fawe.set(new FaweNukkit(this));
Fawe.setupInjector(); Fawe.setupInjector();
Settings.HISTORY.COMBINE_STAGES = false; Settings.IMP.HISTORY.COMBINE_STAGES = false;
logger = Logger.getLogger(NukkitWorldEdit.class.getCanonicalName()); logger = Logger.getLogger(NukkitWorldEdit.class.getCanonicalName());
createDefaultConfiguration("config-basic.yml"); createDefaultConfiguration("config-basic.yml");
config = new NukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-basic.yml"), true), this); config = new NukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-basic.yml"), true), this);

View File

@ -28,9 +28,9 @@ public class FaweNukkit implements IFawe, Listener {
private final NukkitWorldEdit plugin; private final NukkitWorldEdit plugin;
public FaweNukkit(NukkitWorldEdit mod) { public FaweNukkit(NukkitWorldEdit mod) {
Settings.HISTORY.USE_DISK = true; Settings.IMP.HISTORY.USE_DISK = true;
Settings.CLIPBOARD.USE_DISK = true; Settings.IMP.CLIPBOARD.USE_DISK = true;
Settings.HISTORY.COMPRESSION_LEVEL = 9; Settings.IMP.HISTORY.COMPRESSION_LEVEL = 9;
this.plugin = mod; this.plugin = mod;
FaweChunk.HEIGHT = 128; FaweChunk.HEIGHT = 128;
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
@ -97,13 +97,13 @@ public class FaweNukkit implements IFawe, Listener {
@Override @Override
public FaweQueue getNewQueue(World world, boolean fast) { public FaweQueue getNewQueue(World world, boolean fast) {
Settings.HISTORY.COMBINE_STAGES = false; Settings.IMP.HISTORY.COMBINE_STAGES = false;
return new NukkitQueue(this, world); return new NukkitQueue(this, world);
} }
@Override @Override
public FaweQueue getNewQueue(String world, boolean fast) { public FaweQueue getNewQueue(String world, boolean fast) {
Settings.HISTORY.COMBINE_STAGES = false; Settings.IMP.HISTORY.COMBINE_STAGES = false;
return new NukkitQueue(this, world); return new NukkitQueue(this, world);
} }

View File

@ -50,9 +50,9 @@ public class NukkitQueue extends NMSMappedFaweQueue<Level, BaseFullChunk, BaseFu
private void init(FaweNukkit fn) { private void init(FaweNukkit fn) {
this.faweNukkit = fn; this.faweNukkit = fn;
this.world = faweNukkit.getPlugin().getServer().getLevelByName(getWorldName()); this.world = faweNukkit.getPlugin().getServer().getLevelByName(getWorldName());
if (Settings.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) { if (Settings.IMP.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) {
ALLOCATE = Settings.QUEUE.EXTRA_TIME_MS; ALLOCATE = Settings.IMP.QUEUE.EXTRA_TIME_MS;
Settings.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE; Settings.IMP.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE;
} }
} }

View File

@ -49,7 +49,7 @@ public class SpongeMain {
public void onGamePreInit(GamePreInitializationEvent event) { public void onGamePreInit(GamePreInitializationEvent event) {
this.server = this.game.getServer(); this.server = this.game.getServer();
new FaweSponge(this); new FaweSponge(this);
Settings.QUEUE.PARALLEL_THREADS = 1; Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
} }
@Listener @Listener

View File

@ -238,7 +238,7 @@ public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.wor
@Override @Override
public boolean setComponents(FaweChunk fc, RunnableVal<FaweChunk> changeTask) { public boolean setComponents(FaweChunk fc, RunnableVal<FaweChunk> changeTask) {
if (changeTask != null) { if (changeTask != null) {
Settings.HISTORY.COMBINE_STAGES = false; Settings.IMP.HISTORY.COMBINE_STAGES = false;
throw new UnsupportedOperationException("Combine stages not supported"); throw new UnsupportedOperationException("Combine stages not supported");
} }
SpongeChunk_1_8 fs = (SpongeChunk_1_8) fc; SpongeChunk_1_8 fs = (SpongeChunk_1_8) fc;
@ -298,7 +298,7 @@ public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.wor
@Override @Override
public CharFaweChunk getPrevious(CharFaweChunk fs, ExtendedBlockStorage[] sections, Map<?, ?> tilesGeneric, Collection<?>[] entitiesGeneric, Set<UUID> createdEntities, boolean all) throws Exception { public CharFaweChunk getPrevious(CharFaweChunk fs, ExtendedBlockStorage[] sections, Map<?, ?> tilesGeneric, Collection<?>[] entitiesGeneric, Set<UUID> createdEntities, boolean all) throws Exception {
Settings.HISTORY.COMBINE_STAGES = false; Settings.IMP.HISTORY.COMBINE_STAGES = false;
throw new UnsupportedOperationException("Combine stages not supported"); throw new UnsupportedOperationException("Combine stages not supported");
} }