/** * Creates a new {@link YamlConfiguration}, loading from the given reader. * <p> * Any errors loading the Configuration will be logged and then ignored. * If the specified input is not a valid config, a blank config will be * returned. * * @param reader input * @return resulting configuration * @throws IllegalArgumentException Thrown if stream is null */ public static YamlConfiguration loadConfiguration(Reader reader) { Validate.notNull(reader, "Stream cannot be null"); YamlConfiguration config = new YamlConfiguration(); try { config.load(reader); } catch (IOException ex) { Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex); } catch (InvalidConfigurationException ex) { Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex); } return config; } }
/** * Creates a new {@link YamlConfiguration}, loading from the given stream. * <p> * Any errors loading the Configuration will be logged and then ignored. * If the specified input is not a valid config, a blank config will be * returned. * * @param stream Input stream * @return Resulting configuration * @throws IllegalArgumentException Thrown if stream is null * @deprecated does not properly consider encoding * @see #load(InputStream) * @see #loadConfiguration(Reader) */ @Deprecated public static YamlConfiguration loadConfiguration(InputStream stream) { Validate.notNull(stream, "Stream cannot be null"); YamlConfiguration config = new YamlConfiguration(); try { config.load(stream); } catch (IOException ex) { Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex); } catch (InvalidConfigurationException ex) { Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex); } return config; }
/** * Creates a new {@link YamlConfiguration}, loading from the given file. * <p> * Any errors loading the Configuration will be logged and then ignored. * If the specified input is not a valid config, a blank config will be * returned. * <p> * The encoding used may follow the system dependent default. * * @param file Input file * @return Resulting configuration * @throws IllegalArgumentException Thrown if file is null */ public static YamlConfiguration loadConfiguration(File file) { Validate.notNull(file, "File cannot be null"); YamlConfiguration config = new YamlConfiguration(); try { config.load(file); } catch (FileNotFoundException ex) { } catch (IOException ex) { Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex); } catch (InvalidConfigurationException ex) { Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file , ex); } return config; }
conf.load(file); } catch (IOException e) { GlowServer.logger.log(Level.SEVERE, "Failed to read config: " + file, e);
config.load(configFile); } catch (IOException e) { GlowServer.logger.log(Level.SEVERE, "Failed to read config: " + configFile, e);
config.load(configFile); } catch (IOException e) { GlowServer.logger.log(Level.SEVERE, "Failed to read config: " + configFile, e);
YamlConfiguration bukkit = new YamlConfiguration(); try { bukkit.load(bukkitYml); } catch (InvalidConfigurationException e) { report(bukkitYml, e);
public YamlWrapper(File file) { super(); try { if (!file.exists()) { file.getParentFile().mkdirs(); file.createNewFile(); } super.load(file); } catch (Exception e) { e.printStackTrace(); } this.file = file; }
public static ConfigurationSection loadConfiguration(File file) throws IOException, InvalidConfigurationException { YamlConfiguration configuration = new YamlConfiguration(); try { configuration.load(file); } catch (FileNotFoundException fileNotFound) { } return configuration; }
public static YamlConfiguration loadConfiguration(InputStream stream) throws IOException, InvalidConfigurationException { YamlConfiguration configuration = new YamlConfiguration(); try { configuration.load(new InputStreamReader(stream, "UTF-8")); } catch (FileNotFoundException fileNotFound) { } return configuration; }
public static ConfigurationSection loadConfiguration(String fileName) throws IOException, InvalidConfigurationException { YamlConfiguration configuration = new YamlConfiguration(); try { configuration.load(fileName); } catch (FileNotFoundException fileNotFound) { } return configuration; }
public YamlStorage(LukkitPlugin plugin, String path) { super(plugin, path, Storage.YAML); this.yamlConfiguration = new YamlConfiguration(); try { this.yamlConfiguration.load(new FileReader(this.getStorageFile())); } catch (IOException | InvalidConfigurationException e) { e.printStackTrace(); } }
@NonNull private YamlConfiguration addonDescription(@NonNull JarFile jar) throws InvalidAddonFormatException, IOException, InvalidConfigurationException { // Obtain the addon.yml file JarEntry entry = jar.getJarEntry("addon.yml"); if (entry == null) { throw new InvalidAddonFormatException("Addon '" + jar.getName() + "' doesn't contains addon.yml file"); } // Open a reader to the jar BufferedReader reader = new BufferedReader(new InputStreamReader(jar.getInputStream(entry))); // Grab the description in the addon.yml file YamlConfiguration data = new YamlConfiguration(); data.load(reader); return data; }
YamlConfiguration config = new YamlConfiguration(); File[] files = this.getDataFolder().listFiles(); for(File file : files){ try { config.load(file); if(config.contains("Path")){ //What you need to do. } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (InvalidConfigurationException e) { e.printStackTrace(); } }
/** * Loads the given file * @param file * @param locale * @return If any language keys were added * @throws IOException * @throws InvalidConfigurationException */ public boolean loadYamlLanguageFile(File file, Locale locale) throws IOException, InvalidConfigurationException { YamlConfiguration yamlConfiguration = new YamlConfiguration(); yamlConfiguration.load(file); return loadLanguage(yamlConfiguration, locale); }
private FileConfiguration loadConfiguration() throws IOException, InvalidConfigurationException { File folder = createDataFolder(); File file = new File(folder, "config.yml"); if (!file.exists()) { plugin.getLogger().info("No config-file found. Creating default..."); plugin.saveDefaultConfig(); } YamlConfiguration yaml = new YamlConfiguration(); yaml.load(file); return yaml; }
public boolean isOptOut() { synchronized (optOutLock) { try { // Reload the metrics file configuration.load(getConfigFile()); } catch (IOException | InvalidConfigurationException ex) { if (debug) { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); } return true; } return configuration.getBoolean("opt-out", false); } }
/** * Loads a file out of the plugins data folder by the given name * @param file * @param locale * @return If any language keys were added * @throws IOException * @throws InvalidConfigurationException */ public boolean loadYamlLanguageFile(String file, Locale locale) throws IOException, InvalidConfigurationException { YamlConfiguration yamlConfiguration = new YamlConfiguration(); yamlConfiguration.load(new File(this.manager.plugin.getDataFolder(), file)); return loadLanguage(yamlConfiguration, locale); }
private ConfigDefaults(InputStream defaultConfig) { try { defaults = new YamlConfiguration(); final InputStreamReader isr = new InputStreamReader(defaultConfig); defaults.load(isr); isr.close(); } catch (IOException ex) { FLog.severe(ex); } catch (InvalidConfigurationException ex) { FLog.severe(ex); } }
TARDISGeneralInstanceKeeper(TARDIS plugin) { this.plugin = plugin; roomArgs = buildRoomArgs(); transparent = buildTransparent(); doorListener = new TARDISDoorListener(plugin); sign_lookup = buildSignLookup(); setRechargers(); InputStream is = plugin.getResource("plugin.yml"); InputStreamReader reader = new InputStreamReader(is); pluginYAML = new YamlConfiguration(); try { pluginYAML.load(reader); } catch (IOException | InvalidConfigurationException ex) { Logger.getLogger(TARDISCommandHelper.class.getName()).log(Level.SEVERE, null, ex); } }