defConfig.loadFromString(text); } catch (final InvalidConfigurationException e) { getLogger().log(Level.SEVERE, "Cannot load configuration from jar", e);
private void load(Iterable<String> lines, YamlConfiguration newConf) throws InvalidConfigurationException { StringBuilder builder = new StringBuilder(); for (String line : lines) { //remove the silly tab error from yaml builder.append(line.replace("\t", " ")); //indicates a new line builder.append('\n'); } newConf.loadFromString(builder.toString()); }
public static YamlConfiguration getPluginYaml(ClassLoader loader) { try (InputStream stream = loader.getResourceAsStream("plugin.yml")) { YamlConfiguration config = new YamlConfiguration(); config.loadFromString(IOUtils.toString(stream, "UTF-8")); return config; } catch (IOException | InvalidConfigurationException e) { e.printStackTrace(); } return null; }
/** * Decodes an {@link ItemStack} from a Base64 String * @param string Base64 encoded String to decode * @return Decoded {@link ItemStack} */ public static ItemStack decode(String string) { YamlConfiguration config = new YamlConfiguration(); try { config.loadFromString(new String(Base64.getDecoder().decode(string), StandardCharsets.UTF_8)); } catch (IllegalArgumentException | InvalidConfigurationException e) { e.printStackTrace(); return null; } return config.getItemStack("i", null); }
public static YamlConfiguration loadYaml(Plugin plugin, File file) { YamlConfiguration configuration = new YamlConfiguration(); try { String yaml = Files.toString(file, Charset.forName("utf-8")); configuration.loadFromString(yaml); return configuration; } catch (Exception e) { TLocale.Logger.error("FILE-UTILS.FAIL-LOAD-CONFIGURATION", plugin.getName(), file.getName()); } return configuration; }
private static YamlConfiguration getLocaleAtStream(Plugin plugin, File localeFile) { InputStream localeInputSteam = FileUtils.getResource(plugin, "lang/" + localeFile.getName()); try { String yamlText = new String(IO.readFully(localeInputSteam), Charset.forName("utf-8")); YamlConfiguration yaml = new YamlConfiguration(); yaml.loadFromString(yamlText); return yaml; } catch (Exception ignored) { return null; } }
private TLib() { libsFolder = new File(Main.getInst().getDataFolder(), "/libs"); if (!libsFolder.exists()) { libsFolder.mkdirs(); } try { String yamlText = new String(IO.readFully(FileUtils.getResource("lang/internal.yml")), Charset.forName("utf-8")); internalLanguage = new YamlConfiguration(); internalLanguage.loadFromString(yamlText); } catch (IOException | InvalidConfigurationException ignored) { } }
public static ItemStack getReplacement(ItemStack itemStack) { String serialized = getMetaString(itemStack, "replacement"); if (serialized == null || serialized.isEmpty()) { return null; } YamlConfiguration configuration = new YamlConfiguration(); ItemStack replacement = null; try { configuration.loadFromString(serialized); replacement = configuration.getItemStack("item"); } catch (Exception ex) { ex.printStackTrace(); } return replacement; }
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(); } }
@Override public void loadFromString(String contents) throws InvalidConfigurationException { if (!loadHeaders) { super.loadFromString(contents); return; super.loadFromString(memoryData.toString());
defConfig.loadFromString(text); } catch (final InvalidConfigurationException e) { getLogger().log(Level.SEVERE, "Cannot load configuration from jar", e);
config.loadFromString(builder.toString()); } catch (InvalidConfigurationException ex) { throw new SkyConfigurationException("Couldn't load internal translation yaml file " + file, ex);
@Override public void load(DataKey data) { super.load(data); spellKey = data.getString("spell", null); npcCaster = data.getBoolean("caster", false); targetPlayer = data.getBoolean("target_player", true); messagePlayer = data.getBoolean("message_player", false); String parameterString = data.getString("parameters", null); parameters = new YamlConfiguration(); if (parameterString != null && !parameterString.isEmpty()) { if (!parameterString.contains(":")) { String[] simple = StringUtils.split(parameterString, ' '); if (simple.length > 0) { ConfigurationUtils.addParameters(simple, parameters); } } else { try { parameters.loadFromString(parameterString); } catch (Exception ex) { ex.printStackTrace(); } } } }
this.getSource().loadFromString(builder.toString()); } catch (InvalidConfigurationException e) { throw new IOException("YAML file is corrupt", e);
itemStorage = new YamlConfiguration(); String str = new String(data, StandardCharsets.UTF_8); itemStorage.loadFromString(str); } catch (IOException | InvalidConfigurationException e) { plugin.getLogger().log(Level.SEVERE, "Error opening " + f.getPath(), e);
yaml.loadFromString(input);
try { itemStorage.set("id", null); itemStorage.loadFromString(v); String origin = itemStorage.getString("name"); int uid = itemStorage.getInt("uid");