Java Examples for com.sk89q.worldedit.world.snapshot.SnapshotRepository
The following java examples will help you to understand the usage of com.sk89q.worldedit.world.snapshot.SnapshotRepository. These source code samples are taken from different open source projects.
Example 1
| Project: nailed-master File: WorldEditConfig.java View source code |
@Override
public void load() {
File file = new File("settings.conf");
logger.info("Loading config");
if (!file.exists() || file.length() == 0) {
ReadableByteChannel in = null;
FileChannel out = null;
try {
in = Channels.newChannel(WorldEditConfig.class.getResourceAsStream("/reference.conf"));
out = new FileOutputStream(file).getChannel();
out.transferFrom(in, 0, Long.MAX_VALUE);
} catch (Exception e) {
logger.error("Was not able to load WorldEdit config", e);
} finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
}
Config defaults = ConfigFactory.defaultReference().withOnlyPath("worldedit");
Config conf = ConfigFactory.parseFile(file).withFallback(defaults);
Config config;
try {
config = conf.getConfig("worldedit");
} catch (Exception e) {
logger.warn("Failed to load config, using defaults", e);
config = defaults.getConfig("worldedit");
}
profile = config.getBoolean("profile");
wandItem = config.getInt("wand-item");
defaultChangeLimit = Math.max(-1, config.getInt("limits.max-blocks-changed.default"));
maxChangeLimit = Math.max(-1, config.getInt("limits.max-blocks-changed.maximum"));
defaultMaxPolygonalPoints = Math.max(-1, config.getInt("limits.max-polygonal-points.default"));
maxPolygonalPoints = Math.max(-1, config.getInt("limits.max-polygonal-points.maximum"));
defaultMaxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.default"));
maxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.maximum"));
maxRadius = Math.max(-1, config.getInt("limits.max-radius"));
maxBrushRadius = config.getInt("limits.max-brush-radius");
maxSuperPickaxeSize = Math.max(1, config.getInt("limits.max-super-pickaxe-size"));
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default"));
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum"));
disallowedBlocks = new HashSet<Integer>(config.getIntList("limits.disallowed-blocks"));
allowedDataCycleBlocks = new HashSet<Integer>(config.getIntList("limits.allowed-data-cycle-blocks"));
registerHelp = config.getBoolean("register-help");
logCommands = config.getBoolean("logging.log-commands");
logFile = config.getString("logging.file");
superPickaxeDrop = config.getBoolean("super-pickaxe.drop-items");
superPickaxeManyDrop = config.getBoolean("super-pickaxe.many-drop-items");
noDoubleSlash = config.getBoolean("no-double-slash");
useInventory = config.getBoolean("use-inventory.enable");
useInventoryOverride = config.getBoolean("use-inventory.allow-override");
useInventoryCreativeOverride = config.getBoolean("use-inventory.creative-mode-overrides");
navigationWand = config.getInt("navigation-wand.item");
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance");
navigationUseGlass = config.getBoolean("navigation.use-glass");
scriptTimeout = config.getInt("scripting.timeout");
scriptsDir = config.getString("scripting.dir");
saveDir = config.getString("saving.dir");
allowSymlinks = config.getBoolean("files.allow-symbolic-links");
LocalSession.MAX_HISTORY_SIZE = Math.max(0, config.getInt("history.size"));
SessionManager.EXPIRATION_GRACE = config.getInt("history.expiration") * 60 * 1000;
showHelpInfo = config.getBoolean("show-help-on-first-use");
String snapshotsDir = config.getString("snapshots.directory");
if (!snapshotsDir.isEmpty()) {
snapshotRepo = new SnapshotRepository(snapshotsDir);
}
String typ = config.getString("shell-save-type").trim();
shellSaveType = typ.isEmpty() ? null : typ;
}Example 2
| Project: WorldEdit-master File: PropertiesConfiguration.java View source code |
@Override
public void load() {
InputStream stream = null;
try {
stream = new FileInputStream(path);
properties.load(stream);
} catch (FileNotFoundException ignored) {
} catch (IOException e) {
log.log(Level.WARNING, "Failed to read configuration", e);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException ignored) {
}
}
}
loadExtra();
profile = getBool("profile", profile);
disallowedBlocks = getIntSet("disallowed-blocks", defaultDisallowedBlocks);
defaultChangeLimit = getInt("default-max-changed-blocks", defaultChangeLimit);
maxChangeLimit = getInt("max-changed-blocks", maxChangeLimit);
defaultMaxPolygonalPoints = getInt("default-max-polygon-points", defaultMaxPolygonalPoints);
maxPolygonalPoints = getInt("max-polygon-points", maxPolygonalPoints);
defaultMaxPolyhedronPoints = getInt("default-max-polyhedron-points", defaultMaxPolyhedronPoints);
maxPolyhedronPoints = getInt("max-polyhedron-points", maxPolyhedronPoints);
shellSaveType = getString("shell-save-type", shellSaveType);
maxRadius = getInt("max-radius", maxRadius);
maxSuperPickaxeSize = getInt("max-super-pickaxe-size", maxSuperPickaxeSize);
maxBrushRadius = getInt("max-brush-radius", maxBrushRadius);
logCommands = getBool("log-commands", logCommands);
logFile = getString("log-file", logFile);
registerHelp = getBool("register-help", registerHelp);
wandItem = getInt("wand-item", wandItem);
superPickaxeDrop = getBool("super-pickaxe-drop-items", superPickaxeDrop);
superPickaxeManyDrop = getBool("super-pickaxe-many-drop-items", superPickaxeManyDrop);
noDoubleSlash = getBool("no-double-slash", noDoubleSlash);
useInventory = getBool("use-inventory", useInventory);
useInventoryOverride = getBool("use-inventory-override", useInventoryOverride);
useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride);
navigationWand = getInt("nav-wand-item", navigationWand);
navigationWandMaxDistance = getInt("nav-wand-distance", navigationWandMaxDistance);
navigationUseGlass = getBool("nav-use-glass", navigationUseGlass);
scriptTimeout = getInt("scripting-timeout", scriptTimeout);
saveDir = getString("schematic-save-dir", saveDir);
scriptsDir = getString("craftscript-dir", scriptsDir);
butcherDefaultRadius = getInt("butcher-default-radius", butcherDefaultRadius);
butcherMaxRadius = getInt("butcher-max-radius", butcherMaxRadius);
allowSymlinks = getBool("allow-symbolic-links", allowSymlinks);
LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15));
String snapshotsDir = getString("snapshots-dir", "");
if (!snapshotsDir.isEmpty()) {
snapshotRepo = new SnapshotRepository(snapshotsDir);
}
OutputStream output = null;
path.getParentFile().mkdirs();
try {
output = new FileOutputStream(path);
properties.store(output, "Don't put comments; they get removed");
} catch (FileNotFoundException e) {
log.log(Level.WARNING, "Failed to write configuration", e);
} catch (IOException e) {
log.log(Level.WARNING, "Failed to write configuration", e);
} finally {
if (output != null) {
try {
output.close();
} catch (IOException ignored) {
}
}
}
}