mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-28 13:45:36 +01:00
Undo/Settings
Fix some disk and undo issues FaweQueue uses Settings instance
This commit is contained in:
parent
9d2e9212fa
commit
812c12fce4
@ -203,8 +203,8 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
return plugin.getQueue(world);
|
||||
} catch (Throwable ignore) {
|
||||
// Disable incompatible settings
|
||||
Settings.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.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level
|
||||
Settings.IMP.HISTORY.COMBINE_STAGES = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI
|
||||
if (hasNMS) {
|
||||
ignore.printStackTrace();
|
||||
debug("====== NO NMS BLOCK PLACER FOUND ======");
|
||||
@ -256,8 +256,8 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
// Disable incompatible settings
|
||||
Settings.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.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level
|
||||
Settings.IMP.HISTORY.COMBINE_STAGES = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI
|
||||
if (hasNMS) {
|
||||
debug("====== NO NMS BLOCK PLACER FOUND ======");
|
||||
debug("FAWE couldn't find a fast block placer");
|
||||
|
@ -206,7 +206,7 @@ public class BukkitChunk_All extends CharFaweChunk<Chunk, BukkitQueue_All> {
|
||||
continue;
|
||||
}
|
||||
if (light != place) {
|
||||
light = light && Settings.LIGHTING.MODE != 0;
|
||||
light = light && Settings.IMP.LIGHTING.MODE != 0;
|
||||
if (light) {
|
||||
parent.enableLighting(disableResult);
|
||||
}
|
||||
|
@ -21,19 +21,19 @@ public class BukkitQueue_All extends BukkitQueue_0<Chunk, Chunk, Chunk> {
|
||||
|
||||
public BukkitQueue_All(com.sk89q.worldedit.world.World world) {
|
||||
super(world);
|
||||
if (Settings.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) {
|
||||
ALLOCATE = Settings.QUEUE.EXTRA_TIME_MS;
|
||||
Settings.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE;
|
||||
Settings.QUEUE.PARALLEL_THREADS = 1;
|
||||
if (Settings.IMP.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) {
|
||||
ALLOCATE = Settings.IMP.QUEUE.EXTRA_TIME_MS;
|
||||
Settings.IMP.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE;
|
||||
Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public BukkitQueue_All(String world) {
|
||||
super(world);
|
||||
if (Settings.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) {
|
||||
ALLOCATE = Settings.QUEUE.EXTRA_TIME_MS;
|
||||
Settings.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE;
|
||||
Settings.QUEUE.PARALLEL_THREADS = 1;
|
||||
if (Settings.IMP.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) {
|
||||
ALLOCATE = Settings.IMP.QUEUE.EXTRA_TIME_MS;
|
||||
Settings.IMP.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE;
|
||||
Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class ChunkListener implements Listener {
|
||||
int rateLimit = 0;
|
||||
|
||||
public ChunkListener() {
|
||||
if (Settings.TICK_LIMITER.ENABLED) {
|
||||
if (Settings.IMP.TICK_LIMITER.ENABLED) {
|
||||
Bukkit.getPluginManager().registerEvents(ChunkListener.this, Fawe.<FaweBukkit>imp().getPlugin());
|
||||
TaskManager.IMP.repeat(new Runnable() {
|
||||
@Override
|
||||
@ -38,11 +38,11 @@ public class ChunkListener implements Listener {
|
||||
counter.clear();
|
||||
lastZ = Integer.MIN_VALUE;
|
||||
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();
|
||||
}
|
||||
}, Settings.TICK_LIMITER.INTERVAL);
|
||||
}, Settings.IMP.TICK_LIMITER.INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class ChunkListener implements Listener {
|
||||
int cx = x >> 4;
|
||||
int cz = z >> 4;
|
||||
IntegerTrio count = getCount(cx, cz);
|
||||
if (count.x >= Settings.TICK_LIMITER.PHYSICS) {
|
||||
if (count.x >= Settings.IMP.TICK_LIMITER.PHYSICS) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -100,7 +100,7 @@ public class ChunkListener implements Listener {
|
||||
int y = block.getY();
|
||||
if (y != lastPhysY) {
|
||||
lastPhysY = y;
|
||||
if (++count.x == Settings.TICK_LIMITER.PHYSICS) {
|
||||
if (++count.x == Settings.IMP.TICK_LIMITER.PHYSICS) {
|
||||
badChunks.add(MathMan.pairInt(cx, cz));
|
||||
if (rateLimit <= 0) {
|
||||
rateLimit = 120;
|
||||
@ -127,9 +127,9 @@ public class ChunkListener implements Listener {
|
||||
int cx = x >> 4;
|
||||
int cz = z >> 4;
|
||||
IntegerTrio count = getCount(cx, cz);
|
||||
if (++count.y >= Settings.TICK_LIMITER.FALLING) {
|
||||
if (count.y == Settings.TICK_LIMITER.FALLING) {
|
||||
count.x = Settings.TICK_LIMITER.PHYSICS;
|
||||
if (++count.y >= Settings.IMP.TICK_LIMITER.FALLING) {
|
||||
if (count.y == Settings.IMP.TICK_LIMITER.FALLING) {
|
||||
count.x = Settings.IMP.TICK_LIMITER.PHYSICS;
|
||||
badChunks.add(MathMan.pairInt(cx, cz));
|
||||
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 cz = loc.getBlockZ() >> 4;
|
||||
IntegerTrio count = getCount(cx, cz);
|
||||
if (++count.z >= Settings.TICK_LIMITER.ITEMS) {
|
||||
if (count.z == Settings.TICK_LIMITER.ITEMS) {
|
||||
count.x = Settings.TICK_LIMITER.PHYSICS;
|
||||
if (++count.z >= Settings.IMP.TICK_LIMITER.ITEMS) {
|
||||
if (count.z == Settings.IMP.TICK_LIMITER.ITEMS) {
|
||||
count.x = Settings.IMP.TICK_LIMITER.PHYSICS;
|
||||
cleanup(loc.getChunk());
|
||||
badChunks.add(MathMan.pairInt(cx, cz));
|
||||
if (rateLimit <= 0) {
|
||||
|
@ -80,6 +80,10 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
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
|
||||
* @param parent
|
||||
|
@ -227,11 +227,11 @@ public class Fawe {
|
||||
* Implementation dependent stuff
|
||||
*/
|
||||
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.PATHS.CLIPBOARD), TimeUnit.DAYS.toMillis(Settings.CLIPBOARD.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.IMP.PATHS.CLIPBOARD), TimeUnit.DAYS.toMillis(Settings.IMP.CLIPBOARD.DELETE_AFTER_DAYS));
|
||||
|
||||
TaskManager.IMP = this.IMP.getTaskManager();
|
||||
if (Settings.METRICS) {
|
||||
if (Settings.IMP.METRICS) {
|
||||
this.IMP.startMetrics();
|
||||
}
|
||||
this.setupCommands();
|
||||
@ -258,7 +258,7 @@ public class Fawe {
|
||||
|
||||
TaskManager.IMP.repeat(timer, 1);
|
||||
|
||||
if (Settings.UPDATE) {
|
||||
if (Settings.IMP.UPDATE) {
|
||||
// Delayed updating
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
@ -310,19 +310,18 @@ public class Fawe {
|
||||
public void setupConfigs() {
|
||||
// Setting up config.yml
|
||||
File file = new File(this.IMP.getDirectory(), "config.yml");
|
||||
Settings.PLATFORM = IMP.getPlatform().replace("\"", "");
|
||||
Settings.IMP.PLATFORM = IMP.getPlatform().replace("\"", "");
|
||||
try {
|
||||
InputStream stream = getClass().getResourceAsStream("/fawe.properties");
|
||||
java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A");
|
||||
String versionString = scanner.next().trim();
|
||||
scanner.close();
|
||||
this.version = new FaweVersion(versionString);
|
||||
Settings.DATE = new Date(100 + version.year, version.month, version.day).toGMTString();
|
||||
Settings.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit/" + version.build;
|
||||
Settings.COMMIT = "https://github.com/boy0001/FastAsyncWorldedit/commit/" + Integer.toHexString(version.hash);
|
||||
Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toGMTString();
|
||||
Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit/" + version.build;
|
||||
Settings.IMP.COMMIT = "https://github.com/boy0001/FastAsyncWorldedit/commit/" + Integer.toHexString(version.hash);
|
||||
} catch (Throwable ignore) {}
|
||||
Settings.load(file);
|
||||
Settings.save(file);
|
||||
Settings.IMP.reload(file);
|
||||
// Setting up message.yml
|
||||
BBC.load(new File(this.IMP.getDirectory(), "message.yml"));
|
||||
}
|
||||
@ -483,9 +482,9 @@ public class Fawe {
|
||||
try {
|
||||
com.github.luben.zstd.util.Native.load();
|
||||
} catch (Throwable e) {
|
||||
if (Settings.CLIPBOARD.COMPRESSION_LEVEL > 6 || Settings.HISTORY.COMPRESSION_LEVEL > 6) {
|
||||
Settings.CLIPBOARD.COMPRESSION_LEVEL = Math.min(6, Settings.CLIPBOARD.COMPRESSION_LEVEL);
|
||||
Settings.HISTORY.COMPRESSION_LEVEL = Math.min(6, Settings.HISTORY.COMPRESSION_LEVEL);
|
||||
if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL > 6 || Settings.IMP.HISTORY.COMPRESSION_LEVEL > 6) {
|
||||
Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL);
|
||||
Settings.IMP.HISTORY.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.HISTORY.COMPRESSION_LEVEL);
|
||||
debug("====== ZSTD COMPRESSION BINDING NOT FOUND ======");
|
||||
debug(e);
|
||||
debug("===============================================");
|
||||
@ -525,7 +524,7 @@ public class Fawe {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
try {
|
||||
@ -547,7 +546,7 @@ public class Fawe {
|
||||
if (max < 0) {
|
||||
continue;
|
||||
}
|
||||
final long alert = (max * Settings.MAX_MEMORY_PERCENT) / 100;
|
||||
final long alert = (max * Settings.IMP.MAX_MEMORY_PERCENT) / 100;
|
||||
mp.setUsageThreshold(alert);
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ public class FaweAPI {
|
||||
if (!file.getName().toLowerCase().endsWith(".bd")) {
|
||||
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!");
|
||||
}
|
||||
String[] path = file.getPath().split(File.separator);
|
||||
@ -261,12 +261,12 @@ public class FaweAPI {
|
||||
* @param user - The uuid (may be null)
|
||||
* @param radius - The radius from the origin of the edit
|
||||
* @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
|
||||
* @return
|
||||
*/
|
||||
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()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class Rollback extends FaweCommand {
|
||||
|
||||
@Override
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import java.lang.annotation.Target;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@ -28,7 +29,7 @@ public class Config {
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> T get(String key, Class root) {
|
||||
private <T> T get(String key, Class root) {
|
||||
String[] split = key.split("\\.");
|
||||
Object instance = getInstance(split, root);
|
||||
if (instance != null) {
|
||||
@ -52,7 +53,7 @@ public class Config {
|
||||
* @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("\\.");
|
||||
Object instance = getInstance(split, root);
|
||||
if (instance != null) {
|
||||
@ -75,7 +76,7 @@ public class Config {
|
||||
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()) {
|
||||
return false;
|
||||
}
|
||||
@ -85,7 +86,7 @@ public class Config {
|
||||
if (value instanceof MemorySection) {
|
||||
continue;
|
||||
}
|
||||
set(key, value, root);
|
||||
set(key, value, getClass());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -94,16 +95,19 @@ public class Config {
|
||||
* Set all values in the file (load first to avoid overwriting)
|
||||
* @param file
|
||||
*/
|
||||
public static void save(File file, Class root) {
|
||||
public void save(File file) {
|
||||
Class<? extends Config> root = getClass();
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
File parent = file.getParentFile();
|
||||
if (parent != null) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
file.createNewFile();
|
||||
}
|
||||
PrintWriter writer = new PrintWriter(file);
|
||||
Class clazz = root;
|
||||
Object instance = root.newInstance();
|
||||
save(writer, clazz, instance, 0);
|
||||
Object instance = this;
|
||||
save(writer, getClass(), instance, 0);
|
||||
writer.close();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
@ -180,7 +184,7 @@ public class Config {
|
||||
* @param clazz
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Object> getFields(Class clazz) {
|
||||
private Map<String, Object> getFields(Class clazz) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
for (Field field : clazz.getFields()) {
|
||||
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
|
||||
@ -194,7 +198,7 @@ public class Config {
|
||||
return map;
|
||||
}
|
||||
|
||||
private static String toYamlString(Object value, String spacing) {
|
||||
private String toYamlString(Object value, String spacing) {
|
||||
if (value instanceof List) {
|
||||
Collection<?> listValue = (Collection<?>) value;
|
||||
if (listValue.isEmpty()) {
|
||||
@ -216,11 +220,16 @@ public class Config {
|
||||
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 {
|
||||
String CTRF = System.lineSeparator();
|
||||
String spacing = StringMan.repeat(" ", indent);
|
||||
HashMap<Class, Object> instances = new HashMap<>();
|
||||
for (Field field : clazz.getFields()) {
|
||||
if (field.getAnnotation(Ignore.class) != null) {
|
||||
continue;
|
||||
}
|
||||
Class<?> current = field.getType();
|
||||
if (field.getAnnotation(Ignore.class) != null) {
|
||||
continue;
|
||||
}
|
||||
@ -230,61 +239,58 @@ public class Config {
|
||||
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);
|
||||
if (create != null) {
|
||||
Object value = field.get(instance);
|
||||
if (value == null && field.getType() != ConfigBlock.class) {
|
||||
setAccessible(field);
|
||||
Class<?>[] classes = clazz.getDeclaredClasses();
|
||||
for (Class current : classes) {
|
||||
if (StringMan.isEqual(current.getSimpleName(), field.getName())) {
|
||||
field.set(instance, current.newInstance());
|
||||
break;
|
||||
}
|
||||
setAccessible(field);
|
||||
if (indent == 0) {
|
||||
writer.write(CTRF);
|
||||
}
|
||||
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);
|
||||
if (value == null) {
|
||||
field.set(instance, value = current.newInstance());
|
||||
instances.put(current, value);
|
||||
}
|
||||
save(writer, current, value, indent + 2);
|
||||
continue;
|
||||
} else {
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -295,7 +301,7 @@ public class Config {
|
||||
* @param split the node (split by period)
|
||||
* @return
|
||||
*/
|
||||
private static Field getField(String[] split, Class root) {
|
||||
private Field getField(String[] split, Class root) {
|
||||
Object instance = getInstance(split, root);
|
||||
if (instance == null) {
|
||||
return null;
|
||||
@ -310,7 +316,7 @@ public class Config {
|
||||
* @param instance the instance
|
||||
* @return
|
||||
*/
|
||||
private static Field getField(String[] split, Object instance) {
|
||||
private Field getField(String[] split, Object instance) {
|
||||
try {
|
||||
Field field = instance.getClass().getField(toFieldName(split[split.length - 1]));
|
||||
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
|
||||
* @param split the node (split by period)
|
||||
* @return The instance or null
|
||||
*/
|
||||
private static Object getInstance(String[] split, Class root) {
|
||||
private Object getInstance(String[] split, Class root) {
|
||||
try {
|
||||
Class<?> clazz = root == null ? MethodHandles.lookup().lookupClass() : root;
|
||||
Object instance = clazz.newInstance();
|
||||
Object instance = this;
|
||||
while (split.length > 0) {
|
||||
switch (split.length) {
|
||||
case 1:
|
||||
@ -391,7 +404,7 @@ public class Config {
|
||||
* @param node
|
||||
* @return
|
||||
*/
|
||||
private static String toFieldName(String node) {
|
||||
private String toFieldName(String node) {
|
||||
return node.toUpperCase().replaceAll("-","_");
|
||||
}
|
||||
|
||||
@ -400,7 +413,7 @@ public class Config {
|
||||
* @param field
|
||||
* @return
|
||||
*/
|
||||
private static String toNodeName(String field) {
|
||||
private String toNodeName(String field) {
|
||||
return field.toLowerCase().replace("_","-");
|
||||
}
|
||||
|
||||
@ -410,7 +423,7 @@ public class Config {
|
||||
* @throws NoSuchFieldException
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
private static void setAccessible(Field field) throws NoSuchFieldException, IllegalAccessException {
|
||||
private void setAccessible(Field field) throws NoSuchFieldException, IllegalAccessException {
|
||||
field.setAccessible(true);
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
modifiersField.setAccessible(true);
|
||||
|
@ -9,49 +9,70 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class Settings extends Config {
|
||||
@Ignore
|
||||
public static final Settings IMP = new Settings();
|
||||
|
||||
@Comment("These first 6 aren't configurable") // This is a comment
|
||||
@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
|
||||
public static final String WIKI = "https://github.com/boy0001/FastAsyncWorldedit/wiki/";
|
||||
public final String WIKI = "https://github.com/boy0001/FastAsyncWorldedit/wiki/";
|
||||
@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
|
||||
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
|
||||
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
|
||||
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")
|
||||
public static boolean UPDATE = true;
|
||||
public boolean UPDATE = true;
|
||||
@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")
|
||||
public static boolean PREVENT_CRASHES = false;
|
||||
public boolean PREVENT_CRASHES = false;
|
||||
@Comment({
|
||||
"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",
|
||||
"fawe.<plugin> permission. See the Permissions page for supported region plugins."
|
||||
})
|
||||
public static boolean REGION_RESTRICTIONS = true;
|
||||
public boolean REGION_RESTRICTIONS = true;
|
||||
@Comment({
|
||||
"FAWE will cancel non admin edits when memory consumption exceeds this %",
|
||||
" - Bypass with `/wea` or `//fast` or `fawe.bypass`",
|
||||
" - 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")
|
||||
public static final class PATHS {
|
||||
public static String HISTORY = "history";
|
||||
public static String CLIPBOARD = "clipboard";
|
||||
public String HISTORY = "history";
|
||||
public String CLIPBOARD = "clipboard";
|
||||
}
|
||||
|
||||
|
||||
@Create // This value will be generated automatically
|
||||
public static ConfigBlock<LIMITS> LIMITS = null;
|
||||
public ConfigBlock<LIMITS> LIMITS = null;
|
||||
|
||||
@Comment({
|
||||
"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 )"
|
||||
})
|
||||
@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)")
|
||||
public int MAX_ACTIONS = 1;
|
||||
@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)",
|
||||
"2 = Inventory for placing (survival)",
|
||||
})
|
||||
public static int INVENTORY_MODE = 0;
|
||||
public int INVENTORY_MODE = 0;
|
||||
@Comment({
|
||||
"Place chunks instead of individual blocks"
|
||||
})
|
||||
public static boolean FAST_PLACEMENT = true;
|
||||
public boolean FAST_PLACEMENT = true;
|
||||
}
|
||||
|
||||
public static class HISTORY {
|
||||
@ -111,18 +132,18 @@ public class Settings extends Config {
|
||||
" - Unlimited undo",
|
||||
" - Enables the rollback command"
|
||||
})
|
||||
public static boolean USE_DISK = true;
|
||||
public boolean USE_DISK = true;
|
||||
@Comment({
|
||||
"Use a database to store disk storage summaries:",
|
||||
" - Faster lookups and rollback from disk",
|
||||
})
|
||||
public static boolean USE_DATABASE = true;
|
||||
public boolean USE_DATABASE = true;
|
||||
@Comment({
|
||||
"Record history with dispatching:",
|
||||
" - Faster as it avoids duplicate block checks",
|
||||
" - Worse compression since dispatch order is different"
|
||||
})
|
||||
public static boolean COMBINE_STAGES = true;
|
||||
public boolean COMBINE_STAGES = true;
|
||||
@Comment({
|
||||
"Higher compression reduces the size of history at the expense of CPU",
|
||||
"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)",
|
||||
"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({
|
||||
"The buffer size for compression:",
|
||||
" - Larger = better ratio but uses more upfront memory"
|
||||
})
|
||||
public static int BUFFER_SIZE = 531441;
|
||||
public int BUFFER_SIZE = 531441;
|
||||
|
||||
|
||||
@Comment({
|
||||
@ -161,46 +182,48 @@ public class Settings extends Config {
|
||||
" or increase chunk-wait-ms.",
|
||||
"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")
|
||||
public static int DELETE_AFTER_DAYS = 7;
|
||||
public int DELETE_AFTER_DAYS = 7;
|
||||
@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({
|
||||
"If history should be enabled by default for plugins using WorldEdit:",
|
||||
" - It is faster to have disabled",
|
||||
" - Use of the FAWE API will not be effected"
|
||||
})
|
||||
public static boolean ENABLE_FOR_CONSOLE = true;
|
||||
public boolean ENABLE_FOR_CONSOLE = true;
|
||||
@Comment({
|
||||
"Should redo information be stored:",
|
||||
" - History is about 20% larger",
|
||||
" - Enables use of /redo",
|
||||
})
|
||||
public static boolean STORE_REDO = true;
|
||||
public boolean STORE_REDO = true;
|
||||
@Comment({
|
||||
"Assumes all edits are smaller than 4096x256x4096:",
|
||||
" - Reduces history size by ~10%",
|
||||
})
|
||||
public static boolean SMALL_EDITS = false;
|
||||
public boolean SMALL_EDITS = false;
|
||||
}
|
||||
|
||||
public static class QUEUE {
|
||||
@Create
|
||||
public static PROGRESS PROGRESS = null;
|
||||
@Comment({
|
||||
"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",
|
||||
"placing available blocks from edits still in the preprocessing stage."
|
||||
})
|
||||
public static int TARGET_SIZE = 64;
|
||||
public int TARGET_SIZE = 64;
|
||||
@Comment({
|
||||
"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({
|
||||
"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."
|
||||
})
|
||||
public static int MAX_WAIT_MS = 1000;
|
||||
public int MAX_WAIT_MS = 1000;
|
||||
|
||||
@Comment({
|
||||
"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)",
|
||||
"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({
|
||||
"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 {
|
||||
@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")
|
||||
public static int INTERVAL = 1;
|
||||
public int INTERVAL = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,41 +252,41 @@ public class Settings extends Config {
|
||||
@Comment({
|
||||
"Directly modify the region files.",
|
||||
})
|
||||
public static boolean ANVIL_QUEUE_MODE = false;
|
||||
public boolean ANVIL_QUEUE_MODE = false;
|
||||
}
|
||||
|
||||
public static class WEB {
|
||||
@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 {
|
||||
@Comment({
|
||||
"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")
|
||||
public static boolean DEBUG = true;
|
||||
public boolean DEBUG = true;
|
||||
}
|
||||
|
||||
@Comment("Generic tick limiter (not necessarily WorldEdit related, but useful to stop abuse)")
|
||||
public static class TICK_LIMITER {
|
||||
@Comment("Enable the limiter")
|
||||
public static boolean ENABLED = true;
|
||||
public boolean ENABLED = true;
|
||||
@Comment("The interval in ticks")
|
||||
public static int INTERVAL = 1;
|
||||
public int INTERVAL = 1;
|
||||
@Comment("Max falling blocks per interval (per chunk)")
|
||||
public static int FALLING = 512;
|
||||
public int FALLING = 512;
|
||||
@Comment("Max physics per interval (per chunk)")
|
||||
public static int PHYSICS = 512;
|
||||
public int PHYSICS = 512;
|
||||
@Comment("Max item spawns per interval (per chunk)")
|
||||
public static int ITEMS = 128;
|
||||
public int ITEMS = 128;
|
||||
|
||||
}
|
||||
|
||||
public static class CLIPBOARD {
|
||||
@Comment("Store the clipboard on disk instead of memory")
|
||||
public static boolean USE_DISK = true;
|
||||
public boolean USE_DISK = true;
|
||||
@Comment({
|
||||
"Compress the clipboard to reduce the size:",
|
||||
" - TODO: Buffered random access with compression is not implemented on disk yet",
|
||||
@ -271,16 +294,16 @@ public class Settings extends Config {
|
||||
" - 1 = Fast 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")
|
||||
public static int DELETE_AFTER_DAYS = 1;
|
||||
public int DELETE_AFTER_DAYS = 1;
|
||||
}
|
||||
|
||||
public static class LIGHTING {
|
||||
@Comment({
|
||||
"If packet sending should be delayed until relight is finished",
|
||||
})
|
||||
public static boolean DELAY_PACKET_SENDING = true;
|
||||
public boolean DELAY_PACKET_SENDING = true;
|
||||
@Comment({
|
||||
"The relighting mode to use:",
|
||||
" - 0 = None (Do no relighting)",
|
||||
@ -290,18 +313,15 @@ public class Settings extends Config {
|
||||
public static int MODE = 1;
|
||||
}
|
||||
|
||||
public static void save(File file) {
|
||||
save(file, Settings.class);
|
||||
}
|
||||
|
||||
public static void load(File file) {
|
||||
load(file, Settings.class);
|
||||
public void reload(File file) {
|
||||
load(file);
|
||||
save(file);
|
||||
if (HISTORY.USE_DISK) {
|
||||
LocalSession.MAX_HISTORY_SIZE = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
public static FaweLimit getLimit(FawePlayer player) {
|
||||
public FaweLimit getLimit(FawePlayer player) {
|
||||
FaweLimit limit;
|
||||
if (player.hasWorldEditBypass()) {
|
||||
limit = FaweLimit.MAX.copy();
|
||||
|
@ -50,7 +50,7 @@ public class RollbackDatabase {
|
||||
this.prefix = "";
|
||||
this.worldName = Fawe.imp().getWorldName(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();
|
||||
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(?,?,?,?,?,?,?,?,?)";
|
||||
@ -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_EDIT_USER = "DELETE FROM `" + prefix + "edits` WHERE `player`=? AND `id`=?";
|
||||
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() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -38,13 +38,13 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
||||
|
||||
public MappedFaweQueue(final String 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) {
|
||||
super(world);
|
||||
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;
|
||||
}
|
||||
@ -52,7 +52,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
||||
public MappedFaweQueue(final World world, IFaweQueueMap map) {
|
||||
super(world);
|
||||
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;
|
||||
}
|
||||
@ -281,9 +281,9 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
||||
boolean sync = Thread.currentThread() == Fawe.get().getMainThread();
|
||||
if (sync) {
|
||||
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);
|
||||
TaskManager.IMP.syncWhenFree(loadChunk, Settings.HISTORY.CHUNK_WAIT_MS);
|
||||
TaskManager.IMP.syncWhenFree(loadChunk, Settings.IMP.HISTORY.CHUNK_WAIT_MS);
|
||||
if (!isChunkLoaded(cx, cz)) {
|
||||
throw new FaweException.FaweChunkLoadException();
|
||||
}
|
||||
|
@ -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
|
||||
public Relighter getRelighter() {
|
||||
@ -60,11 +60,11 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
||||
@Override
|
||||
public void end(FaweChunk chunk) {
|
||||
super.end(chunk);
|
||||
if (Settings.LIGHTING.MODE == 0) {
|
||||
if (Settings.IMP.LIGHTING.MODE == 0 || !Settings.IMP.LIGHTING.DELAY_PACKET_SENDING) {
|
||||
sendChunk(chunk);
|
||||
return;
|
||||
}
|
||||
if (Settings.LIGHTING.MODE == 2) {
|
||||
if (Settings.IMP.LIGHTING.MODE == 2) {
|
||||
relighter.addChunk(chunk.getX(), chunk.getZ(), null, chunk.getBitMask());
|
||||
return;
|
||||
}
|
||||
|
@ -85,9 +85,9 @@ public class CorruptSchematicStreamer {
|
||||
if (width.get() == 0 || height.get() == 0 || length.get() == 0) {
|
||||
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);
|
||||
} else if (Settings.CLIPBOARD.COMPRESSION_LEVEL == 0) {
|
||||
} else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) {
|
||||
fc = new CPUOptimizedClipboard(dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ());
|
||||
} else {
|
||||
fc = new MemoryOptimizedClipboard(dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ());
|
||||
|
@ -167,9 +167,9 @@ public class SchematicStreamer extends NBTStreamer {
|
||||
}
|
||||
return fc;
|
||||
}
|
||||
if (Settings.CLIPBOARD.USE_DISK) {
|
||||
if (Settings.IMP.CLIPBOARD.USE_DISK) {
|
||||
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);
|
||||
} else {
|
||||
return fc = new MemoryOptimizedClipboard(size, 1, 1);
|
||||
|
@ -298,7 +298,12 @@ public class MCAFile {
|
||||
raf.write((offsetMedium >> 8));
|
||||
raf.write((offsetMedium >> 0));
|
||||
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 size = (locations[i + 3] & 0xFF) << 12;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.changeset.AbstractDelegateChangeSet;
|
||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||
import java.lang.reflect.Constructor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.primesoft.blockshub.IBlocksHubApi;
|
||||
import org.primesoft.blockshub.api.IPlayer;
|
||||
@ -12,6 +13,10 @@ import org.primesoft.blockshub.api.IWorld;
|
||||
|
||||
public class LoggingChangeSet extends AbstractDelegateChangeSet {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
private static boolean initialized = false;
|
||||
|
||||
public static FaweChangeSet wrap(FawePlayer<Player> player, FaweChangeSet parent) {
|
||||
@ -29,13 +34,24 @@ public class LoggingChangeSet extends AbstractDelegateChangeSet {
|
||||
|
||||
private final MutableVector loc;
|
||||
private final IPlayer player;
|
||||
private final IWorld world;
|
||||
private IWorld world;
|
||||
private final MutableBlockData oldBlock;
|
||||
private final MutableBlockData newBlock;
|
||||
|
||||
private LoggingChangeSet(FawePlayer player, FaweChangeSet 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.oldBlock = new MutableBlockData();
|
||||
this.newBlock = new MutableBlockData();
|
||||
|
@ -100,7 +100,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
public FawePlayer(final T parent) {
|
||||
this.parent = parent;
|
||||
Fawe.get().register(this);
|
||||
if (Settings.CLIPBOARD.USE_DISK) {
|
||||
if (Settings.IMP.CLIPBOARD.USE_DISK) {
|
||||
loadClipboardFromDisk();
|
||||
}
|
||||
}
|
||||
@ -205,7 +205,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
* - Should already be called if history on disk is enabled
|
||||
*/
|
||||
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 {
|
||||
if (file.exists() && file.length() > 5) {
|
||||
DiskOptimizedClipboard doc = new DiskOptimizedClipboard(file);
|
||||
@ -280,7 +280,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
* @return
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public void unregister() {
|
||||
if (Settings.HISTORY.DELETE_ON_LOGOUT) {
|
||||
if (Settings.IMP.HISTORY.DELETE_ON_LOGOUT) {
|
||||
session = getSession();
|
||||
WorldEdit.getInstance().removeSession(getPlayer());
|
||||
session.setClipboard(null);
|
||||
|
@ -41,6 +41,7 @@ public abstract class FaweQueue {
|
||||
private RunnableVal2<FaweChunk, FaweChunk> changeTask;
|
||||
private RunnableVal2<ProgressType, Integer> progressTask;
|
||||
private SetQueue.QueueStage stage;
|
||||
private Settings settings = Settings.IMP;
|
||||
|
||||
public FaweQueue(String world) {
|
||||
this.world = world;
|
||||
@ -69,6 +70,14 @@ public abstract class FaweQueue {
|
||||
ALL,
|
||||
}
|
||||
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public void setSettings(Settings settings) {
|
||||
this.settings = settings == null ? Settings.IMP : settings;
|
||||
}
|
||||
|
||||
public void setWorld(String world) {
|
||||
this.world = world;
|
||||
this.weWorld = null;
|
||||
@ -300,7 +309,7 @@ public abstract class FaweQueue {
|
||||
|
||||
@Deprecated
|
||||
public boolean next() {
|
||||
int amount = Settings.QUEUE.PARALLEL_THREADS;
|
||||
int amount = Settings.IMP.QUEUE.PARALLEL_THREADS;
|
||||
ExecutorCompletionService service = SetQueue.IMP.getCompleterService();
|
||||
long time = 20; // 30ms
|
||||
return next(amount, service, time);
|
||||
|
@ -62,7 +62,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
|
||||
player.print(BBC.getPrefix() + BBC.NO_PERM.f("worldedit.tool.inspect"));
|
||||
return false;
|
||||
}
|
||||
if (!Settings.HISTORY.USE_DATABASE) {
|
||||
if (!Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
player.print(BBC.getPrefix() + BBC.SETTING_DISABLE.f("history.use-database"));
|
||||
return false;
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
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.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
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.world.World;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AbstractDelegateChangeSet extends FaweChangeSet {
|
||||
public final FaweChangeSet parent;
|
||||
@ -24,8 +26,14 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public static FaweChangeSet getDefaultChangeSet(World world, UUID uuid) {
|
||||
return FaweChangeSet.getDefaultChangeSet(world, uuid);
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
return parent.getWorldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return parent.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,6 +101,11 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
|
||||
parent.delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditSession toEditSession(FawePlayer player) {
|
||||
return parent.toEditSession(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(EntityCreate change) {
|
||||
parent.add(change);
|
||||
@ -123,8 +136,18 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
|
||||
parent.add(x, y, z, from, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return parent.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int x, int y, int z, int combinedFrom, BaseBlock to) {
|
||||
parent.add(x, y, z, combinedFrom, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChangeTask(FaweQueue queue) {
|
||||
parent.addChangeTask(queue);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
}
|
||||
|
||||
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;
|
||||
if (folder.exists()) {
|
||||
for (File file : folder.listFiles()) {
|
||||
@ -122,14 +122,14 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
private void init(UUID uuid, int i) {
|
||||
this.uuid = uuid;
|
||||
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);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
Fawe.debug("Deleting history: " + Fawe.imp().getWorldName(getWorld()) + "/" + uuid + "/" + index);
|
||||
deleteFiles();
|
||||
if (Settings.HISTORY.USE_DATABASE) {
|
||||
if (Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld());
|
||||
db.delete(uuid, index);
|
||||
}
|
||||
@ -348,7 +348,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
}
|
||||
byte[] buffer = new byte[9];
|
||||
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) {
|
||||
if (gis.read(buffer) == -1) {
|
||||
fis.close();
|
||||
|
@ -35,13 +35,13 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
private final String worldName;
|
||||
private final boolean mainThread;
|
||||
private final int layers;
|
||||
private AtomicInteger waitingCombined = new AtomicInteger(0);
|
||||
private AtomicInteger waitingAsync = new AtomicInteger(0);
|
||||
private Object lockCombined = new Object();
|
||||
private Object lockAsync = new Object();
|
||||
protected final AtomicInteger waitingCombined = new AtomicInteger(0);
|
||||
private final AtomicInteger waitingAsync = new AtomicInteger(0);
|
||||
// private Object lockCombined = new Object();
|
||||
// private Object lockAsync = new Object();
|
||||
|
||||
public static FaweChangeSet getDefaultChangeSet(World world, UUID uuid) {
|
||||
if (Settings.HISTORY.USE_DISK) {
|
||||
if (Settings.IMP.HISTORY.USE_DISK) {
|
||||
return new DiskStorageHistory(world, uuid);
|
||||
} else {
|
||||
return new MemoryOptimizedHistory(world);
|
||||
@ -76,8 +76,8 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
@Override
|
||||
public void run() {
|
||||
waitingAsync.decrementAndGet();
|
||||
synchronized (lockAsync) {
|
||||
lockAsync.notifyAll();
|
||||
synchronized (waitingAsync) {
|
||||
waitingAsync.notifyAll();
|
||||
}
|
||||
flush();
|
||||
}
|
||||
@ -89,14 +89,14 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
try {
|
||||
if (!Fawe.isMainThread()) {
|
||||
while (waitingAsync.get() > 0) {
|
||||
synchronized (lockAsync) {
|
||||
lockAsync.wait(1000);
|
||||
synchronized (waitingAsync) {
|
||||
waitingAsync.wait(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (waitingCombined.get() > 0) {
|
||||
synchronized (lockCombined) {
|
||||
lockCombined.wait(1000);
|
||||
synchronized (waitingCombined) {
|
||||
waitingCombined.wait(1000);
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
@ -263,7 +263,7 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
default:
|
||||
char combinedIdPrevious = previousLayer != null ? previousLayer[index] : 0;
|
||||
if (combinedIdCurrent != combinedIdPrevious) {
|
||||
synchronized (lockCombined) {
|
||||
synchronized (this) {
|
||||
add(xx, yy, zz, combinedIdPrevious, combinedIdCurrent);
|
||||
}
|
||||
}
|
||||
@ -277,14 +277,14 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
// Tiles created
|
||||
Map<Short, CompoundTag> tiles = next.getTiles();
|
||||
for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) {
|
||||
synchronized (lockCombined) {
|
||||
synchronized (this) {
|
||||
addTileCreate(entry.getValue());
|
||||
}
|
||||
}
|
||||
// Tiles removed
|
||||
tiles = previous.getTiles();
|
||||
for (Map.Entry<Short, CompoundTag> entry : tiles.entrySet()) {
|
||||
synchronized (lockCombined) {
|
||||
synchronized (this) {
|
||||
addTileRemove(entry.getValue());
|
||||
}
|
||||
}
|
||||
@ -294,14 +294,14 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
// Entities created
|
||||
Set<CompoundTag> entities = next.getEntities();
|
||||
for (CompoundTag entityTag : entities) {
|
||||
synchronized (lockCombined) {
|
||||
synchronized (this) {
|
||||
addEntityCreate(entityTag);
|
||||
}
|
||||
}
|
||||
// Entities removed
|
||||
entities = previous.getEntities();
|
||||
for (CompoundTag entityTag : entities) {
|
||||
synchronized (lockCombined) {
|
||||
synchronized (this) {
|
||||
addEntityRemove(entityTag);
|
||||
}
|
||||
}
|
||||
|
@ -32,11 +32,11 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
private FaweStreamPositionDelegate posDel;
|
||||
|
||||
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) {
|
||||
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) {
|
||||
@ -376,8 +376,10 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
idDel.readCombined(is, change, dir);
|
||||
return change;
|
||||
} catch (EOFException ignoreOEF) {
|
||||
ignoreOEF.printStackTrace();
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
return null;
|
||||
|
@ -118,7 +118,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
}
|
||||
synchronized (this) {
|
||||
setOrigin(x, z);
|
||||
idsStream = new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE);
|
||||
idsStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
|
||||
idsStreamZip = getCompressedOS(idsStream);
|
||||
writeHeader(idsStreamZip, x, y, z);
|
||||
return idsStreamZip;
|
||||
@ -140,7 +140,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
if (entCStreamZip != null) {
|
||||
return entCStreamZip;
|
||||
}
|
||||
entCStream = new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE);
|
||||
entCStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
|
||||
return entCStreamZip = new NBTOutputStream(getCompressedOS(entCStream));
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
if (entRStreamZip != null) {
|
||||
return entRStreamZip;
|
||||
}
|
||||
entRStream = new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE);
|
||||
entRStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
|
||||
return entRStreamZip = new NBTOutputStream(getCompressedOS(entRStream));
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
if (tileCStreamZip != null) {
|
||||
return tileCStreamZip;
|
||||
}
|
||||
tileCStream = new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE);
|
||||
tileCStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
|
||||
return tileCStreamZip = new NBTOutputStream(getCompressedOS(tileCStream));
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
if (tileRStreamZip != null) {
|
||||
return tileRStreamZip;
|
||||
}
|
||||
tileRStream = new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE);
|
||||
tileRStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
|
||||
return tileRStreamZip = new NBTOutputStream(getCompressedOS(tileRStream));
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
private int last;
|
||||
|
||||
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) {
|
||||
@ -183,7 +183,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
}
|
||||
|
||||
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() {
|
||||
|
@ -59,7 +59,7 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
||||
private int compressionLevel;
|
||||
|
||||
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) {
|
||||
|
@ -64,7 +64,7 @@ public class DefaultProgressTracker extends RunnableVal2<FaweQueue.ProgressType,
|
||||
private final void send() {
|
||||
// Avoid duplicates
|
||||
long currentTick = System.currentTimeMillis() / 50;
|
||||
if (currentTick > lastTick + Settings.QUEUE.PROGRESS.INTERVAL) {
|
||||
if (currentTick > lastTick + Settings.IMP.QUEUE.PROGRESS.INTERVAL) {
|
||||
lastTick = currentTick;
|
||||
TaskManager.IMP.task(new Runnable() { // Run on main thread
|
||||
@Override
|
||||
|
@ -135,7 +135,7 @@ public class FaweFormat implements ClipboardReader, ClipboardWriter {
|
||||
} else {
|
||||
ox = 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 height = 0;
|
||||
int length = 0;
|
||||
|
@ -28,7 +28,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
setupBlockQueue();
|
||||
setupSchematicHandler();
|
||||
setupChunkManager();
|
||||
if (Settings.PLATFORM.equals("Bukkit")) {
|
||||
if (Settings.PLATFORM.equalsIgnoreCase("bukkit")) {
|
||||
new FaweTrim();
|
||||
}
|
||||
if (MainCommand.getInstance().getCommand("generatebiome") == null) {
|
||||
|
@ -114,7 +114,7 @@ public class EditSessionBuilder {
|
||||
public EditSessionBuilder changeSet(boolean disk, @Nullable UUID uuid, int compression) {
|
||||
if (world == null) {
|
||||
if (disk) {
|
||||
if (Settings.HISTORY.USE_DATABASE) {
|
||||
if (Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
this.changeSet = new RollbackOptimizedHistory(worldName, uuid);
|
||||
} else {
|
||||
this.changeSet = new DiskStorageHistory(worldName, uuid);
|
||||
@ -123,7 +123,7 @@ public class EditSessionBuilder {
|
||||
this.changeSet = new MemoryOptimizedHistory(worldName);
|
||||
}
|
||||
} else if (disk) {
|
||||
if (Settings.HISTORY.USE_DATABASE) {
|
||||
if (Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
this.changeSet = new RollbackOptimizedHistory(world, uuid);
|
||||
} else {
|
||||
this.changeSet = new DiskStorageHistory(world, uuid);
|
||||
|
@ -192,7 +192,7 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -209,7 +209,7 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
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();
|
||||
@ -273,7 +273,7 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -306,15 +306,15 @@ public class MainUtil {
|
||||
final String website;
|
||||
if (uuid == null) {
|
||||
uuid = UUID.randomUUID();
|
||||
website = Settings.WEB.URL + "upload.php?" + uuid;
|
||||
website = Settings.IMP.WEB.URL + "upload.php?" + uuid;
|
||||
filename = "plot." + extension;
|
||||
} else {
|
||||
website = Settings.WEB.URL + "save.php?" + uuid;
|
||||
website = Settings.IMP.WEB.URL + "save.php?" + uuid;
|
||||
filename = file + '.' + extension;
|
||||
}
|
||||
final URL url;
|
||||
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());
|
||||
URLConnection con = new URL(website).openConnection();
|
||||
con.setDoOutput(true);
|
||||
|
@ -35,7 +35,7 @@ public class MemUtil {
|
||||
}
|
||||
final long heapFreeSize = Runtime.getRuntime().freeMemory();
|
||||
final int size = (int) ((heapFreeSize * 100) / heapMaxSize);
|
||||
if (size > (100 - Settings.MAX_MEMORY_PERCENT)) {
|
||||
if (size > (100 - Settings.IMP.MAX_MEMORY_PERCENT)) {
|
||||
memoryPlentifulTask();
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class SetQueue {
|
||||
@Override
|
||||
public void run() {
|
||||
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 {
|
||||
Runnable task = tasks.poll();
|
||||
if (task != null) {
|
||||
@ -90,7 +90,7 @@ public class SetQueue {
|
||||
if (!MemUtil.isMemoryFree()) {
|
||||
final int mem = MemUtil.calculateMemory();
|
||||
if (mem != Integer.MAX_VALUE) {
|
||||
if ((mem <= 1) && Settings.PREVENT_CRASHES) {
|
||||
if ((mem <= 1) && Settings.IMP.PREVENT_CRASHES) {
|
||||
for (FaweQueue queue : getAllQueues()) {
|
||||
queue.saveMemory();
|
||||
}
|
||||
@ -111,17 +111,17 @@ public class SetQueue {
|
||||
if (Thread.currentThread() != Fawe.get().getMainThread()) {
|
||||
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
|
||||
boolean parallel = Settings.QUEUE.PARALLEL_THREADS > 1;
|
||||
boolean parallel = Settings.IMP.QUEUE.PARALLEL_THREADS > 1;
|
||||
queue.startSet(parallel);
|
||||
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.runTasks();
|
||||
}
|
||||
} 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);
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -214,11 +214,11 @@ public class SetQueue {
|
||||
}
|
||||
|
||||
public void flush(FaweQueue queue) {
|
||||
queue.startSet(Settings.QUEUE.PARALLEL_THREADS > 1);
|
||||
queue.startSet(Settings.IMP.QUEUE.PARALLEL_THREADS > 1);
|
||||
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) {
|
||||
pool.awaitQuiescence(Settings.QUEUE.DISCARD_AFTER_MS, TimeUnit.MILLISECONDS);
|
||||
pool.awaitQuiescence(Settings.IMP.QUEUE.DISCARD_AFTER_MS, TimeUnit.MILLISECONDS);
|
||||
completer = new ExecutorCompletionService(pool);
|
||||
MainUtil.handleError(e);
|
||||
} finally {
|
||||
@ -251,7 +251,7 @@ public class SetQueue {
|
||||
long age = now - queue.getModified();
|
||||
total += queue.size();
|
||||
if (queue.size() == 0) {
|
||||
if (age > Settings.QUEUE.DISCARD_AFTER_MS) {
|
||||
if (age > Settings.IMP.QUEUE.DISCARD_AFTER_MS) {
|
||||
queue.setStage(QueueStage.NONE);
|
||||
queue.runTasks();
|
||||
iter.remove();
|
||||
@ -261,11 +261,11 @@ public class SetQueue {
|
||||
if (firstNonEmpty == null) {
|
||||
firstNonEmpty = queue;
|
||||
}
|
||||
if (total > Settings.QUEUE.TARGET_SIZE) {
|
||||
if (total > Settings.IMP.QUEUE.TARGET_SIZE) {
|
||||
firstNonEmpty.setModified(now);
|
||||
return firstNonEmpty;
|
||||
}
|
||||
if (age > Settings.QUEUE.MAX_WAIT_MS) {
|
||||
if (age > Settings.IMP.QUEUE.MAX_WAIT_MS) {
|
||||
queue.setModified(now);
|
||||
return queue;
|
||||
}
|
||||
@ -293,20 +293,20 @@ public class SetQueue {
|
||||
}
|
||||
if (inactiveQueues.size() > 0) {
|
||||
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();
|
||||
if (lastSuccess == 0) {
|
||||
lastSuccess = now;
|
||||
}
|
||||
long diff = now - lastSuccess;
|
||||
if (diff > Settings.QUEUE.MAX_WAIT_MS) {
|
||||
if (diff > Settings.IMP.QUEUE.MAX_WAIT_MS) {
|
||||
for (FaweQueue queue : tmp) {
|
||||
boolean result = queue.next();
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (diff > Settings.QUEUE.DISCARD_AFTER_MS) {
|
||||
if (diff > Settings.IMP.QUEUE.DISCARD_AFTER_MS) {
|
||||
// These edits never finished
|
||||
for (FaweQueue queue : tmp) {
|
||||
queue.setStage(QueueStage.NONE);
|
||||
@ -317,12 +317,12 @@ public class SetQueue {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (Settings.QUEUE.TARGET_SIZE != -1) {
|
||||
if (Settings.IMP.QUEUE.TARGET_SIZE != -1) {
|
||||
int total = 0;
|
||||
for (FaweQueue queue : tmp) {
|
||||
total += queue.size();
|
||||
}
|
||||
if (total > Settings.QUEUE.TARGET_SIZE) {
|
||||
if (total > Settings.IMP.QUEUE.TARGET_SIZE) {
|
||||
for (FaweQueue queue : tmp) {
|
||||
boolean result = queue.next();
|
||||
if (result) {
|
||||
|
@ -92,7 +92,7 @@ public abstract class TaskManager {
|
||||
return;
|
||||
}
|
||||
if (numThreads == null) {
|
||||
numThreads = Settings.QUEUE.PARALLEL_THREADS;
|
||||
numThreads = Settings.IMP.QUEUE.PARALLEL_THREADS;
|
||||
}
|
||||
if (numThreads <= 1) {
|
||||
for (Runnable run : runnables) {
|
||||
@ -274,7 +274,7 @@ public abstract class TaskManager {
|
||||
synchronized (running) {
|
||||
while (running.get()) {
|
||||
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();
|
||||
Fawe.debug("For full debug information use: /fawe threads");
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class WEManager {
|
||||
* @return
|
||||
*/
|
||||
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)};
|
||||
}
|
||||
HashSet<RegionWrapper> mask = new HashSet<>();
|
||||
|
@ -218,14 +218,14 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
}
|
||||
this.player = player;
|
||||
if (changeSet == null) {
|
||||
if (Settings.HISTORY.USE_DISK) {
|
||||
if (Settings.IMP.HISTORY.USE_DISK) {
|
||||
UUID uuid = player == null ? CONSOLE : player.getUUID();
|
||||
if (Settings.HISTORY.USE_DATABASE) {
|
||||
if (Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
changeSet = new RollbackOptimizedHistory(world, uuid);
|
||||
} else {
|
||||
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);
|
||||
} else {
|
||||
changeSet = new MemoryOptimizedHistory(world);
|
||||
@ -248,7 +248,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
}
|
||||
if (fastmode == null) {
|
||||
if (player == null) {
|
||||
fastmode = Settings.HISTORY.ENABLE_FOR_CONSOLE;
|
||||
fastmode = Settings.IMP.HISTORY.ENABLE_FOR_CONSOLE;
|
||||
} else {
|
||||
fastmode = player.getSession().hasFastMode();
|
||||
}
|
||||
@ -257,7 +257,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
checkMemory = player != null && !fastmode;
|
||||
}
|
||||
if (combineStages == null) {
|
||||
combineStages = Settings.HISTORY.COMBINE_STAGES && !(queue instanceof MCAQueue);
|
||||
combineStages = Settings.IMP.HISTORY.COMBINE_STAGES && !(queue instanceof MCAQueue);
|
||||
}
|
||||
if (checkMemory) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (Settings.EXPERIMENTAL.ANVIL_QUEUE_MODE && !(queue instanceof MCAQueue)) {
|
||||
if (Settings.IMP.EXPERIMENTAL.ANVIL_QUEUE_MODE && !(queue instanceof MCAQueue)) {
|
||||
queue = new MCAQueue(queue);
|
||||
}
|
||||
this.queue = queue;
|
||||
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.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) {
|
||||
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())) {
|
||||
this.wrapped = true;
|
||||
return (AbstractDelegateExtent) toReturn;
|
||||
}
|
||||
}
|
||||
if (Settings.EXTENT.DEBUG) {
|
||||
if (Settings.IMP.EXTENT.DEBUG) {
|
||||
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 block logging, it is recommended to use use BlocksHub");
|
||||
@ -1316,7 +1316,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
queue.flush();
|
||||
}
|
||||
if (getChangeSet() != null) {
|
||||
if (Settings.HISTORY.COMBINE_STAGES) {
|
||||
if (Settings.IMP.HISTORY.COMBINE_STAGES) {
|
||||
((FaweChangeSet) getChangeSet()).flushAsync();
|
||||
} else {
|
||||
((FaweChangeSet) getChangeSet()).flush();
|
||||
|
@ -198,7 +198,7 @@ public class LocalSession {
|
||||
if (world == null || uuid == null) {
|
||||
return false;
|
||||
}
|
||||
if (Settings.HISTORY.USE_DISK) {
|
||||
if (Settings.IMP.HISTORY.USE_DISK) {
|
||||
MAX_HISTORY_SIZE = Integer.MAX_VALUE;
|
||||
}
|
||||
if (!world.equals(currentWorld)) {
|
||||
@ -219,7 +219,7 @@ public class LocalSession {
|
||||
|
||||
private boolean loadHistoryChangeSets(UUID uuid, World world) {
|
||||
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()) {
|
||||
final FileNameExtensionFilter filter = new FileNameExtensionFilter("BlockData files","bd");
|
||||
folder.listFiles(new FileFilter() {
|
||||
@ -249,7 +249,7 @@ public class LocalSession {
|
||||
|
||||
@Deprecated
|
||||
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 HashMap<Integer, ArrayDeque<Path>> paths = new HashMap<>();
|
||||
@ -298,10 +298,10 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
private void loadHistoryNegativeIndex(UUID uuid, World world) {
|
||||
if (!Settings.HISTORY.USE_DISK) {
|
||||
if (!Settings.IMP.HISTORY.USE_DISK) {
|
||||
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()) {
|
||||
try {
|
||||
FaweInputStream is = new FaweInputStream(new FileInputStream(file));
|
||||
@ -316,10 +316,10 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
private void saveHistoryNegativeIndex(UUID uuid, World world) {
|
||||
if (world == null || !Settings.HISTORY.USE_DISK) {
|
||||
if (world == null || !Settings.IMP.HISTORY.USE_DISK) {
|
||||
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) {
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
@ -487,7 +487,7 @@ public class LocalSession {
|
||||
} else {
|
||||
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);
|
||||
item.delete();
|
||||
long size = MainUtil.getSize(item);
|
||||
@ -517,7 +517,7 @@ public class LocalSession {
|
||||
checkNotNull(player);
|
||||
loadSessionHistoryFromDisk(player.getUniqueId(), player.getWorld());
|
||||
if (getHistoryNegativeIndex() < history.size()) {
|
||||
FaweChangeSet changeSet = (FaweChangeSet) history.get(getHistoryIndex());
|
||||
FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
|
||||
final FawePlayer fp = FawePlayer.wrap(player);
|
||||
EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld())
|
||||
.allowedRegionsEverywhere()
|
||||
@ -566,7 +566,7 @@ public class LocalSession {
|
||||
if (getHistoryNegativeIndex() > 0) {
|
||||
setDirty();
|
||||
historyNegativeIndex--;
|
||||
FaweChangeSet changeSet = (FaweChangeSet) history.get(getHistoryIndex());
|
||||
FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
|
||||
final FawePlayer fp = FawePlayer.wrap(player);
|
||||
EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld())
|
||||
.allowedRegionsEverywhere()
|
||||
|
@ -294,7 +294,7 @@ public class BrushCommands {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
|
||||
FawePlayer fp = FawePlayer.wrap(player);
|
||||
FaweLimit limit = Settings.getLimit(fp);
|
||||
FaweLimit limit = Settings.IMP.getLimit(fp);
|
||||
iterations = Math.min(limit.MAX_ITERATIONS, iterations);
|
||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||
tool.setSize(radius);
|
||||
|
@ -81,7 +81,7 @@ public class HistoryCommands {
|
||||
)
|
||||
@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 {
|
||||
if (!Settings.HISTORY.USE_DATABASE) {
|
||||
if (!Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
BBC.SETTING_DISABLE.send(player, "history.use-database");
|
||||
return;
|
||||
}
|
||||
@ -92,7 +92,7 @@ public class HistoryCommands {
|
||||
BBC.NO_PERM.send(player, "fawe.rollback.import");
|
||||
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()) {
|
||||
return;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class SchematicCommands {
|
||||
return;
|
||||
}
|
||||
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");
|
||||
ReadableByteChannel rbc = Channels.newChannel(url.openStream());
|
||||
in = Channels.newInputStream(rbc);
|
||||
|
@ -67,7 +67,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent {
|
||||
checkNotNull(region);
|
||||
this.region = region.clone();
|
||||
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.mx = origin.getBlockX();
|
||||
this.my = origin.getBlockY();
|
||||
@ -85,7 +85,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent {
|
||||
checkNotNull(region);
|
||||
this.region = region.clone();
|
||||
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.mx = origin.getBlockX();
|
||||
this.my = origin.getBlockY();
|
||||
|
@ -357,7 +357,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
if (Settings.HISTORY.COMPRESSION_LEVEL >= 9) {
|
||||
if (Settings.IMP.HISTORY.COMPRESSION_LEVEL >= 9) {
|
||||
return iterator_old();
|
||||
}
|
||||
final MutableBlockVector mutable = new MutableBlockVector(0,0,0);
|
||||
|
@ -21,12 +21,12 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
|
||||
|
||||
@Override
|
||||
public void sendTitle(String head, String sub) { // Not supported
|
||||
Settings.QUEUE.PROGRESS.DISPLAY = false;
|
||||
Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTitle() { // Not supported
|
||||
Settings.QUEUE.PROGRESS.DISPLAY = false;
|
||||
Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,12 +21,12 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
|
||||
|
||||
@Override
|
||||
public void sendTitle(String head, String sub) { // Not supported
|
||||
Settings.QUEUE.PROGRESS.DISPLAY = false;
|
||||
Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTitle() { // Not supported
|
||||
Settings.QUEUE.PROGRESS.DISPLAY = false;
|
||||
Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,12 +21,12 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
|
||||
|
||||
@Override
|
||||
public void sendTitle(String head, String sub) { // Not supported
|
||||
Settings.QUEUE.PROGRESS.DISPLAY = false;
|
||||
Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTitle() { // Not supported
|
||||
Settings.QUEUE.PROGRESS.DISPLAY = false;
|
||||
Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,12 +22,12 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
|
||||
|
||||
@Override
|
||||
public void sendTitle(String head, String sub) { // Not supported
|
||||
Settings.QUEUE.PROGRESS.DISPLAY = false;
|
||||
Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTitle() { // Not supported
|
||||
Settings.QUEUE.PROGRESS.DISPLAY = false;
|
||||
Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,12 +22,12 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
|
||||
|
||||
@Override
|
||||
public void sendTitle(String head, String sub) { // Not supported
|
||||
Settings.QUEUE.PROGRESS.DISPLAY = false;
|
||||
Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTitle() { // Not supported
|
||||
Settings.QUEUE.PROGRESS.DISPLAY = false;
|
||||
Settings.IMP.QUEUE.PROGRESS.DISPLAY = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,7 +76,7 @@ public class NukkitWorldEdit extends PluginBase {
|
||||
try {
|
||||
Fawe.set(new FaweNukkit(this));
|
||||
Fawe.setupInjector();
|
||||
Settings.HISTORY.COMBINE_STAGES = false;
|
||||
Settings.IMP.HISTORY.COMBINE_STAGES = false;
|
||||
logger = Logger.getLogger(NukkitWorldEdit.class.getCanonicalName());
|
||||
createDefaultConfiguration("config-basic.yml");
|
||||
config = new NukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-basic.yml"), true), this);
|
||||
|
@ -28,9 +28,9 @@ public class FaweNukkit implements IFawe, Listener {
|
||||
private final NukkitWorldEdit plugin;
|
||||
|
||||
public FaweNukkit(NukkitWorldEdit mod) {
|
||||
Settings.HISTORY.USE_DISK = true;
|
||||
Settings.CLIPBOARD.USE_DISK = true;
|
||||
Settings.HISTORY.COMPRESSION_LEVEL = 9;
|
||||
Settings.IMP.HISTORY.USE_DISK = true;
|
||||
Settings.IMP.CLIPBOARD.USE_DISK = true;
|
||||
Settings.IMP.HISTORY.COMPRESSION_LEVEL = 9;
|
||||
this.plugin = mod;
|
||||
FaweChunk.HEIGHT = 128;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
@ -97,13 +97,13 @@ public class FaweNukkit implements IFawe, Listener {
|
||||
|
||||
@Override
|
||||
public FaweQueue getNewQueue(World world, boolean fast) {
|
||||
Settings.HISTORY.COMBINE_STAGES = false;
|
||||
Settings.IMP.HISTORY.COMBINE_STAGES = false;
|
||||
return new NukkitQueue(this, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweQueue getNewQueue(String world, boolean fast) {
|
||||
Settings.HISTORY.COMBINE_STAGES = false;
|
||||
Settings.IMP.HISTORY.COMBINE_STAGES = false;
|
||||
return new NukkitQueue(this, world);
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,9 @@ public class NukkitQueue extends NMSMappedFaweQueue<Level, BaseFullChunk, BaseFu
|
||||
private void init(FaweNukkit fn) {
|
||||
this.faweNukkit = fn;
|
||||
this.world = faweNukkit.getPlugin().getServer().getLevelByName(getWorldName());
|
||||
if (Settings.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) {
|
||||
ALLOCATE = Settings.QUEUE.EXTRA_TIME_MS;
|
||||
Settings.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE;
|
||||
if (Settings.IMP.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) {
|
||||
ALLOCATE = Settings.IMP.QUEUE.EXTRA_TIME_MS;
|
||||
Settings.IMP.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class SpongeMain {
|
||||
public void onGamePreInit(GamePreInitializationEvent event) {
|
||||
this.server = this.game.getServer();
|
||||
new FaweSponge(this);
|
||||
Settings.QUEUE.PARALLEL_THREADS = 1;
|
||||
Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
|
||||
}
|
||||
|
||||
@Listener
|
||||
|
@ -238,7 +238,7 @@ public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.wor
|
||||
@Override
|
||||
public boolean setComponents(FaweChunk fc, RunnableVal<FaweChunk> changeTask) {
|
||||
if (changeTask != null) {
|
||||
Settings.HISTORY.COMBINE_STAGES = false;
|
||||
Settings.IMP.HISTORY.COMBINE_STAGES = false;
|
||||
throw new UnsupportedOperationException("Combine stages not supported");
|
||||
}
|
||||
SpongeChunk_1_8 fs = (SpongeChunk_1_8) fc;
|
||||
@ -298,7 +298,7 @@ public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.wor
|
||||
|
||||
@Override
|
||||
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");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user