use of com.plotsquared.core.configuration.file.YamlConfiguration in project PlotSquared by IntellectualSites.
the class Settings method convertLegacy.
public static boolean convertLegacy(File file) {
if (!file.exists()) {
return false;
}
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
// Protection
Redstone.DISABLE_OFFLINE = config.getBoolean("protection.redstone.disable-offline");
Redstone.DISABLE_UNOCCUPIED = config.getBoolean("protection.redstone.disable-unoccupied", Redstone.DISABLE_UNOCCUPIED);
// UUID
UUID.OFFLINE = config.getBoolean("UUID.offline", UUID.OFFLINE);
UUID.FORCE_LOWERCASE = config.getBoolean("UUID.force-lowercase", UUID.FORCE_LOWERCASE);
// Mob stuff
Enabled_Components.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs", Enabled_Components.KILL_ROAD_MOBS);
Enabled_Components.KILL_ROAD_VEHICLES = config.getBoolean("kill_road_vehicles", Enabled_Components.KILL_ROAD_VEHICLES);
// Clearing + Expiry
// FAST_CLEAR = config.getBoolean("clear.fastmode");
Enabled_Components.PLOT_EXPIRY = config.getBoolean("clear.auto.enabled", Enabled_Components.PLOT_EXPIRY);
if (Enabled_Components.PLOT_EXPIRY) {
Enabled_Components.BAN_DELETER = config.getBoolean("clear.on.ban");
AUTO_CLEAR = new ConfigBlock<>();
AUTO_CLEAR.put("task1", new Auto_Clear());
Auto_Clear task = AUTO_CLEAR.get("task1");
task.CALIBRATION = new Auto_Clear.CALIBRATION();
task.DAYS = config.getInt("clear.auto.days", task.DAYS);
task.THRESHOLD = config.getInt("clear.auto.threshold", task.THRESHOLD);
task.CONFIRMATION = config.getBoolean("clear.auto.confirmation", task.CONFIRMATION);
task.CALIBRATION.CHANGES = config.getInt("clear.auto.calibration.changes", task.CALIBRATION.CHANGES);
task.CALIBRATION.FACES = config.getInt("clear.auto.calibration.faces", task.CALIBRATION.FACES);
task.CALIBRATION.DATA = config.getInt("clear.auto.calibration.data", task.CALIBRATION.DATA);
task.CALIBRATION.AIR = config.getInt("clear.auto.calibration.air", task.CALIBRATION.AIR);
task.CALIBRATION.VARIETY = config.getInt("clear.auto.calibration.variety", task.CALIBRATION.VARIETY);
task.CALIBRATION.CHANGES_SD = config.getInt("clear.auto.calibration.changes_sd", task.CALIBRATION.CHANGES_SD);
task.CALIBRATION.FACES_SD = config.getInt("clear.auto.calibration.faces_sd", task.CALIBRATION.FACES_SD);
task.CALIBRATION.DATA_SD = config.getInt("clear.auto.calibration.data_sd", task.CALIBRATION.DATA_SD);
task.CALIBRATION.AIR_SD = config.getInt("clear.auto.calibration.air_sd", task.CALIBRATION.AIR_SD);
task.CALIBRATION.VARIETY_SD = config.getInt("clear.auto.calibration.variety_sd", task.CALIBRATION.VARIETY_SD);
}
// Done
Done.REQUIRED_FOR_RATINGS = config.getBoolean("approval.ratings.check-done", Done.REQUIRED_FOR_RATINGS);
Done.COUNTS_TOWARDS_LIMIT = config.getBoolean("approval.done.counts-towards-limit", Done.COUNTS_TOWARDS_LIMIT);
Done.RESTRICT_BUILDING = config.getBoolean("approval.done.restrict-building", Done.RESTRICT_BUILDING);
Done.REQUIRED_FOR_DOWNLOAD = config.getBoolean("approval.done.required-for-download", Done.REQUIRED_FOR_DOWNLOAD);
// Schematics
Paths.SCHEMATICS = config.getString("schematics.save_path", Paths.SCHEMATICS);
// Web
Web.URL = config.getString("web.url", Web.URL);
// Caching
Enabled_Components.RATING_CACHE = config.getBoolean("cache.ratings", Enabled_Components.RATING_CACHE);
// Rating system
Ratings.CATEGORIES = config.contains("ratings.categories") ? config.getStringList("ratings.categories") : Ratings.CATEGORIES;
// Update Notifications
Enabled_Components.UPDATE_NOTIFICATIONS = config.getBoolean("update-notifications", Enabled_Components.UPDATE_NOTIFICATIONS);
// Teleportation
Teleport.DELAY = config.getInt("teleport.delay", Teleport.DELAY);
Teleport.ON_LOGIN = config.getBoolean("teleport.on_login", Teleport.ON_LOGIN);
Teleport.ON_DEATH = config.getBoolean("teleport.on_death", Teleport.ON_DEATH);
Teleport.ON_CLEAR = config.getBoolean("teleport.on_clear", Teleport.ON_CLEAR);
Teleport.ON_DELETE = config.getBoolean("teleport.on_delete", Teleport.ON_DELETE);
// Chunk processor
Enabled_Components.CHUNK_PROCESSOR = config.getBoolean("chunk-processor.enabled", Enabled_Components.CHUNK_PROCESSOR);
Chunk_Processor.AUTO_TRIM = config.getBoolean("chunk-processor.auto-unload", Chunk_Processor.AUTO_TRIM);
Chunk_Processor.MAX_TILES = config.getInt("chunk-processor.max-blockstates", Chunk_Processor.MAX_TILES);
Chunk_Processor.MAX_ENTITIES = config.getInt("chunk-processor.max-entities", Chunk_Processor.MAX_ENTITIES);
Chunk_Processor.DISABLE_PHYSICS = config.getBoolean("chunk-processor.disable-physics", Chunk_Processor.DISABLE_PHYSICS);
// Comments
Enabled_Components.COMMENT_NOTIFIER = config.getBoolean("comments.notifications.enabled", Enabled_Components.COMMENT_NOTIFIER);
// Plot limits
Claim.MAX_AUTO_AREA = config.getInt("claim.max-auto-area", Claim.MAX_AUTO_AREA);
Limit.MAX_PLOTS = config.getInt("max_plots", Limit.MAX_PLOTS);
Limit.GLOBAL = config.getBoolean("global_limit", Limit.GLOBAL);
// Miscellaneous
DEBUG = config.getBoolean("debug", DEBUG);
Enabled_Components.DATABASE_PURGER = config.getBoolean("auto-purge", Enabled_Components.DATABASE_PURGER);
return true;
}
use of com.plotsquared.core.configuration.file.YamlConfiguration in project PlotSquared by IntellectualSites.
the class BukkitWorldManager method setGenerator.
protected void setGenerator(@Nullable final String worldName, @Nullable final String generator) {
if (generator == null) {
return;
}
File file = new File("bukkit.yml").getAbsoluteFile();
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
yml.set(String.format("worlds.%s.generator", worldName), generator);
try {
yml.save(file);
} catch (IOException e) {
e.printStackTrace();
}
}
use of com.plotsquared.core.configuration.file.YamlConfiguration in project PlotSquared by IntellectualSites.
the class Reload method onCommand.
@Override
public boolean onCommand(PlotPlayer<?> player, String[] args) {
try {
// The following won't affect world generation, as that has to be
// loaded during startup unfortunately.
PlotSquared.get().setupConfigs();
this.worldConfiguration = PlotSquared.get().getWorldConfiguration();
this.worldFile = PlotSquared.get().getWorldsFile();
PlotSquared.get().loadCaptionMap();
this.plotAreaManager.forEachPlotArea(area -> {
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection("worlds." + area.getWorldName());
if (worldSection == null) {
return;
}
if (area.getType() != PlotAreaType.PARTIAL || !worldSection.contains("areas")) {
area.saveConfiguration(worldSection);
area.loadDefaultConfiguration(worldSection);
} else {
ConfigurationSection areaSection = worldSection.getConfigurationSection("areas." + area.getId() + "-" + area.getMin() + "-" + area.getMax());
YamlConfiguration clone = new YamlConfiguration();
for (String key : areaSection.getKeys(true)) {
if (areaSection.get(key) instanceof MemorySection) {
continue;
}
if (!clone.contains(key)) {
clone.set(key, areaSection.get(key));
}
}
for (String key : worldSection.getKeys(true)) {
if (worldSection.get(key) instanceof MemorySection) {
continue;
}
if (!key.startsWith("areas") && !clone.contains(key)) {
clone.set(key, worldSection.get(key));
}
}
area.saveConfiguration(clone);
// netSections is the combination of
for (String key : clone.getKeys(true)) {
if (clone.get(key) instanceof MemorySection) {
continue;
}
if (!worldSection.contains(key)) {
worldSection.set(key, clone.get(key));
} else {
Object value = worldSection.get(key);
if (Objects.equals(value, clone.get(key))) {
areaSection.set(key, clone.get(key));
}
}
}
area.loadDefaultConfiguration(clone);
}
});
this.worldConfiguration.save(this.worldFile);
player.sendMessage(TranslatableCaption.of("reload.reloaded_configs"));
} catch (Exception e) {
e.printStackTrace();
player.sendMessage(TranslatableCaption.of("reload.reload_failed"));
}
return true;
}
Aggregations