/** * Save the current configuration file. */ public void saveAll() { if (valuesChanged) saveLastUpdate(lastUpdateTime); if (configChanged) plugin.saveConfig(); // And we're done valuesChanged = false; configChanged = false; } }
private static void process(Plugin plugin, String resource, ConfigurationSection section, boolean addOnlyIfEmpty, boolean removeObsolete) { YamlConfiguration defaults = resourceCache.computeIfAbsent(resource, res -> { InputStream is = plugin.getResource("res/" + res); if (is == null) { throw new IllegalStateException("Couldn't read " + res + " from jar, please re-install MobArena"); } Scanner scanner = new Scanner(is).useDelimiter("\\A"); if (!scanner.hasNext()) { throw new IllegalStateException("No content in " + res + " in jar, please re-install MobArena"); } String contents = scanner.next(); YamlConfiguration yaml = new YamlConfiguration(); try { yaml.loadFromString(contents); return yaml; } catch (InvalidConfigurationException e) { throw new IllegalStateException("Invalid contents in " + res + " in jar, please re-install MobArena", e); } }); boolean modified = process(defaults, section, addOnlyIfEmpty, removeObsolete); if (modified) { plugin.saveConfig(); } }
public BukkitConfigHandler(Plugin plugin) { this.config = plugin.getConfig(); if (!(new File("plugins/CouponCodes/config.yml").exists())) plugin.saveDefaultConfig(); if (!config.options().copyDefaults(true).configuration().equals(config)) plugin.saveConfig(); }
private void loadLimitMap(Plugin plugin) { // If the config-section is empty, create and populate it. if (limits.getKeys(false).isEmpty()) { for (ArenaClass ac : classes.values()) { limits.set(ac.getConfigName(), -1); } plugin.saveConfig(); } // Populate the limits map using the values in the config-file. for (ArenaClass ac : classes.values()) { classLimits.put(ac, new MutableInt(limits.getInt(ac.getConfigName(), -1))); } }
if (twa != null) { twa.getConfig().set("daleks.worlds.Skaro", 500); twa.saveConfig();