Java Code Examples for org.bukkit.configuration.file.FileConfiguration#setDefaults()
The following examples show how to use
org.bukkit.configuration.file.FileConfiguration#setDefaults() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalizationService.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
private FileConfiguration streamConfigFile(String file, FileConfiguration defaults) { String path = "/languages/" + file; if (plugin.getClass().getResourceAsStream(path) == null) { return new YamlConfiguration(); } try (BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getClass().getResourceAsStream(path), StandardCharsets.UTF_8))) { FileConfiguration config = YamlConfiguration.loadConfiguration(reader); if (defaults != null) { config.setDefaults(defaults); } return config; } catch (IOException e) { Slimefun.getLogger().log(Level.SEVERE, e, () -> "Failed to load language file into memory: \"" + path + "\""); return null; } }
Example 2
Source File: DataStorage.java From EnchantmentsEnhance with GNU General Public License v3.0 | 5 votes |
private void copyDefaults(File playerFile) { try { FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(playerFile); Reader defConfigStream = new InputStreamReader(Main.getMain().getResource("playerdata.yml")); YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); playerConfig.options().copyDefaults(true); playerConfig.setDefaults(defConfig); playerConfig.save(playerFile); } catch (Exception e) { } }
Example 3
Source File: GameMap.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
private static void copyDefaults(File mapFile) { FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(mapFile); Reader defConfigStream = new InputStreamReader(SkyWarsReloaded.get().getResource("mapFile.yml")); YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); playerConfig.options().copyDefaults(true); playerConfig.setDefaults(defConfig); try { playerConfig.save(mapFile); } catch (IOException e) { e.printStackTrace(); } }
Example 4
Source File: DataStorage.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
private void copyDefaults(File playerFile) { FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(playerFile); Reader defConfigStream = new InputStreamReader(SkyWarsReloaded.get().getResource("playerFile.yml")); YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); playerConfig.options().copyDefaults(true); playerConfig.setDefaults(defConfig); try { playerConfig.save(playerFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example 5
Source File: Messaging.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
private void copyDefaults(File playerFile) { FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(playerFile); Reader defConfigStream = new InputStreamReader(SkyWarsReloaded.get().getResource("messages.yml")); YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); playerConfig.options().copyDefaults(true); playerConfig.setDefaults(defConfig); try { playerConfig.save(playerFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example 6
Source File: DataStorage.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
private void copyDefaults(File playerFile) { FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(playerFile); Reader defConfigStream = new InputStreamReader(SkyWarsReloaded.get().getResource("playerFile.yml")); if (defConfigStream != null) { YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); playerConfig.options().copyDefaults(true); playerConfig.setDefaults(defConfig); try { playerConfig.save(playerFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
Example 7
Source File: Messaging.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
private void copyDefaults(File playerFile) { FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(playerFile); Reader defConfigStream = new InputStreamReader(SkyWarsReloaded.get().getResource("messages.yml")); if (defConfigStream != null) { YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); playerConfig.options().copyDefaults(true); playerConfig.setDefaults(defConfig); try { playerConfig.save(playerFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }