Java Code Examples for org.bukkit.configuration.file.YamlConfiguration#loadConfiguration()
The following examples show how to use
org.bukkit.configuration.file.YamlConfiguration#loadConfiguration() .
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: ThermosConfig.java From Thermos with GNU General Public License v3.0 | 6 votes |
@Override protected void load() { try { config = YamlConfiguration.loadConfiguration(configFile); String header = ""; for (Setting<?> toggle : settings.values()) { if (!toggle.description.equals("")) header += "Setting: " + toggle.path + " Default: " + toggle.def + " # " + toggle.description + "\n"; config.addDefault(toggle.path, toggle.def); settings.get(toggle.path).setValue( config.getString(toggle.path)); } config.options().header(header); config.options().copyDefaults(true); save(); } catch (Exception ex) { MinecraftServer.getServer().logSevere( "Could not load " + this.configFile); ex.printStackTrace(); } }
Example 2
Source File: BungeemodeAddon.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
private boolean checkCopyConfig() throws IOException { File file = new File(getDataFolder(), CONFIG_FILE_NAME); if (file.exists()) { Configuration config = YamlConfiguration.loadConfiguration(file); int version = config.getInt("config-version"); if (version < BungeemodeConfig.CURRENT_CONFIG_VERSION) { Path dataFolderPath = getDataFolder().toPath(); Files.move(file.toPath(), dataFolderPath.resolve("config_old.yml"), StandardCopyOption.REPLACE_EXISTING); return true; } } else { return true; } return false; }
Example 3
Source File: RoyalAuthConverter.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@Override public void execute(CommandSender sender) { for (OfflinePlayer player : plugin.getServer().getOfflinePlayers()) { try { String name = player.getName().toLowerCase(); File file = new File(makePath(".", "plugins", "RoyalAuth", "userdata", name + ".yml")); if (dataSource.isAuthAvailable(name) || !file.exists()) { continue; } FileConfiguration configuration = YamlConfiguration.loadConfiguration(file); PlayerAuth auth = PlayerAuth.builder() .name(name) .password(configuration.getString(PASSWORD_PATH), null) .lastLogin(configuration.getLong(LAST_LOGIN_PATH)) .realName(player.getName()) .build(); dataSource.saveAuth(auth); dataSource.updateSession(auth); } catch (Exception e) { logger.logException("Error while trying to import " + player.getName() + " RoyalAuth data", e); } } }
Example 4
Source File: Metrics.java From EntityAPI with GNU Lesser General Public License v3.0 | 6 votes |
public Metrics(final Plugin plugin) throws IOException { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } this.plugin = plugin; // load the config configurationFile = getConfigFile(); configuration = YamlConfiguration.loadConfiguration(configurationFile); // add some defaults configuration.addDefault("opt-out", false); configuration.addDefault("guid", UUID.randomUUID().toString()); configuration.addDefault("debug", false); // Do we need to create the file? if (configuration.get("guid", null) == null) { configuration.options().header("http://mcstats.org").copyDefaults(true); configuration.save(configurationFile); } // Load the guid then guid = configuration.getString("guid"); debug = configuration.getBoolean("debug", false); }
Example 5
Source File: Leaderboard.java From SkyWarsReloaded with GNU General Public License v3.0 | 6 votes |
private void getSigns(LeaderType type) { File leaderboardsFile = new File(SkyWarsReloaded.get().getDataFolder(), "leaderboards.yml"); if (!leaderboardsFile.exists()) { SkyWarsReloaded.get().saveResource("leaderboards.yml", false); } if (leaderboardsFile.exists()) { FileConfiguration storage = YamlConfiguration.loadConfiguration(leaderboardsFile); for (int i = 1; i < 11; i++) { List<String> locations = storage.getStringList(type.toString().toLowerCase() + ".signs." + i); if (locations != null) { ArrayList<Location> locs = new ArrayList<>(); for (String location: locations) { Location loc = Util.get().stringToLocation(location); locs.add(loc); } signs.get(type).put(i, locs); } } } }
Example 6
Source File: TileEntityConfig.java From Thermos with GNU General Public License v3.0 | 5 votes |
public void load() { try { config = YamlConfiguration.loadConfiguration(configFile); String header = HEADER + "\n"; for (Setting toggle : settings.values()) { if (!toggle.description.equals("")) header += "Setting: " + toggle.path + " Default: " + toggle.def + " # " + toggle.description + "\n"; config.addDefault(toggle.path, toggle.def); settings.get(toggle.path).setValue(config.getString(toggle.path)); } config.options().header(header); config.options().copyDefaults(true); version = getInt("config-version", 1); set("config-version", 1); for (TileEntityCache teCache : CauldronHooks.tileEntityCache.values()) { teCache.tickNoPlayers = config.getBoolean( "world-settings." + teCache.worldName + "." + teCache.configPath + ".tick-no-players", config.getBoolean( "world-settings.default." + teCache.configPath + ".tick-no-players") ); teCache.tickInterval = config.getInt( "world-settings." + teCache.worldName + "." + teCache.configPath + ".tick-interval", config.getInt( "world-settings.default." + teCache.configPath + ".tick-interval") ); } this.saveWorldConfigs(); this.save(); } catch (Exception ex) { MinecraftServer.getServer().logSevere("Could not load " + this.configFile); ex.printStackTrace(); } }
Example 7
Source File: SpigotConfig.java From Thermos with GNU General Public License v3.0 | 5 votes |
public static void init() { config = YamlConfiguration.loadConfiguration( CONFIG_FILE ); config.options().header( HEADER ); config.options().copyDefaults( true ); commands = new HashMap<String, Command>(); version = getInt( "config-version", 7 ); set( "config-version", 7 ); readConfig( SpigotConfig.class, null ); }
Example 8
Source File: Leaderboard.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
public void saveSigns(LeaderType type) { File leaderboardsFile = new File(SkyWarsReloaded.get().getDataFolder(), "leaderboards.yml"); if (!leaderboardsFile.exists()) { SkyWarsReloaded.get().saveResource("leaderboards.yml", false); } if (leaderboardsFile.exists()) { FileConfiguration storage = YamlConfiguration.loadConfiguration(leaderboardsFile); for (int pos: signs.get(type).keySet()) { if (signs.get(type).get(pos) != null) { List<String> locs = new ArrayList<String>(); for (Location loc: signs.get(type).get(pos)) { locs.add(Util.get().locationToString(loc)); } storage.set(type.toString().toLowerCase() + ".signs." + pos, locs); } } try { storage.save(leaderboardsFile); } catch (IOException e) { } } if (loaded(type)) { updateSigns(type); } }
Example 9
Source File: TestResearchSetup.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Test @Order(value = 2) public void testResearchTranslations() throws IOException { try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/languages/researches_en.yml"), StandardCharsets.UTF_8))) { FileConfiguration config = YamlConfiguration.loadConfiguration(reader); for (Research research : SlimefunPlugin.getRegistry().getResearches()) { String path = research.getKey().getNamespace() + '.' + research.getKey().getKey(); Assertions.assertTrue(config.contains(path)); } } }
Example 10
Source File: SettingsManager.java From Survival-Games with GNU General Public License v3.0 | 5 votes |
public void reloadChest() { chest = YamlConfiguration.loadConfiguration(f5); if(chest.getInt("version", 0) != CHEST_VERSION){ moveFile(f5); loadFile("chest.yml"); reloadKits(); } }
Example 11
Source File: ShrinkingBorderEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
public ShrinkingBorderEvent(GameMap map, boolean b) { this.gMap = map; this.enabled = b; File dataDirectory = SkyWarsReloaded.get().getDataFolder(); File mapDataDirectory = new File(dataDirectory, "mapsData"); if (!mapDataDirectory.exists() && !mapDataDirectory.mkdirs()) { return; } File mapFile = new File(mapDataDirectory, gMap.getName() + ".yml"); if (mapFile.exists()) { eventName = "ShrinkingBorderEvent"; slot = 9; material = new ItemStack(Material.BARRIER, 1); FileConfiguration fc = YamlConfiguration.loadConfiguration(mapFile); this.min = fc.getInt("events." + eventName + ".minStart"); this.max = fc.getInt("events." + eventName + ".maxStart"); this.length = fc.getInt("events." + eventName + ".length"); this.chance = fc.getInt("events." + eventName + ".chance"); this.title = fc.getString("events." + eventName + ".title"); this.subtitle = fc.getString("events." + eventName + ".subtitle"); this.startMessage = fc.getString("events." + eventName + ".startMessage"); this.endMessage = fc.getString("events." + eventName + ".endMessage"); this.announceEvent = fc.getBoolean("events." + eventName + ".announceTimer"); this.repeatable = fc.getBoolean("events." + eventName + ".repeatable"); this.borderSize = fc.getInt("events." + eventName + ".startingBorderSize"); this.delay = fc.getInt("events." + eventName + ".shrinkRepeatDelay"); } }
Example 12
Source File: CauldronConfig.java From Thermos with GNU General Public License v3.0 | 5 votes |
public void load() { try { config = YamlConfiguration.loadConfiguration(configFile); String header = HEADER + "\n"; for (Setting toggle : settings.values()) { if (!toggle.description.equals("")) header += "Setting: " + toggle.path + " Default: " + toggle.def + " # " + toggle.description + "\n"; config.addDefault(toggle.path, toggle.def); settings.get(toggle.path).setValue(config.getString(toggle.path)); } config.options().header(header); config.options().copyDefaults(true); version = getInt("config-version", 1); set("config-version", 1); this.saveWorldConfigs(); this.save(); } catch (Exception ex) { MinecraftServer.getServer().logSevere("Could not load " + this.configFile); ex.printStackTrace(); } }
Example 13
Source File: DeathMatchEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public void saveEventData() { File dataDirectory = SkyWarsReloaded.get().getDataFolder(); File mapDataDirectory = new File(dataDirectory, "mapsData"); if (!mapDataDirectory.exists() && !mapDataDirectory.mkdirs()) { return; } File mapFile = new File(mapDataDirectory, gMap.getName() + ".yml"); if (mapFile.exists()) { FileConfiguration fc = YamlConfiguration.loadConfiguration(mapFile); fc.set("events." + eventName + ".enabled", this.enabled); fc.set("events." + eventName + ".minStart", this.min); fc.set("events." + eventName + ".maxStart", this.max); fc.set("events." + eventName + ".length", this.length); fc.set("events." + eventName + ".chance", this.chance); fc.set("events." + eventName + ".title", this.title); fc.set("events." + eventName + ".subtitle", this.subtitle); fc.set("events." + eventName + ".startMessage", this.startMessage); fc.set("events." + eventName + ".endMessage", this.endMessage); fc.set("events." + eventName + ".announceTimer", this.announceEvent); fc.set("events." + eventName + ".repeatable", this.repeatable); try { fc.save(mapFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
Example 14
Source File: SushchestvoConfig.java From Thermos with GNU General Public License v3.0 | 5 votes |
public void load() { try { config = YamlConfiguration.loadConfiguration(configFile); String header = HEADER + "\n"; for (Setting toggle : settings.values()) { if (!toggle.description.equals("")) header += "Setting: " + toggle.path + " Default: " + toggle.def + " # " + toggle.description + "\n"; config.addDefault(toggle.path, toggle.def); settings.get(toggle.path).setValue(config.getString(toggle.path)); } config.options().header(header); config.options().copyDefaults(true); version = getInt("config-version", 1); set("config-version", 1); for (SushchestvoCache seCache : CauldronHooks.sushchestvoCache.values()) { seCache.tickNoPlayers = config.getBoolean( "world-settings." + seCache.worldName + "." + seCache.configPath + ".tick-no-players", config.getBoolean( "world-settings.default." + seCache.configPath + ".tick-no-players") ); seCache.neverEverTick = config.getBoolean( "world-settings." + seCache.worldName + "." + seCache.configPath + ".never-ever-tick", config.getBoolean( "world-settings.default." + seCache.configPath + ".never-ever-tick") ); seCache.tickInterval = config.getInt( "world-settings." + seCache.worldName + "." + seCache.configPath + ".tick-interval", config.getInt( "world-settings.default." + seCache.configPath + ".tick-interval") ); } this.saveWorldConfigs(); this.save(); } catch (Exception ex) { MinecraftServer.getServer().logSevere("Could not load " + this.configFile); ex.printStackTrace(); } }
Example 15
Source File: ProjectileSpleefEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public void saveEventData() { File dataDirectory = SkyWarsReloaded.get().getDataFolder(); File mapDataDirectory = new File(dataDirectory, "mapsData"); if (!mapDataDirectory.exists() && !mapDataDirectory.mkdirs()) { return; } File mapFile = new File(mapDataDirectory, gMap.getName() + ".yml"); if (mapFile.exists()) { FileConfiguration fc = YamlConfiguration.loadConfiguration(mapFile); fc.set("events." + eventName + ".enabled", this.enabled); fc.set("events." + eventName + ".minStart", this.min); fc.set("events." + eventName + ".maxStart", this.max); fc.set("events." + eventName + ".length", this.length); fc.set("events." + eventName + ".chance", this.chance); fc.set("events." + eventName + ".title", this.title); fc.set("events." + eventName + ".subtitle", this.subtitle); fc.set("events." + eventName + ".startMessage", this.startMessage); fc.set("events." + eventName + ".endMessage", this.endMessage); fc.set("events." + eventName + ".announceTimer", this.announceEvent); fc.set("events." + eventName + ".repeatable", this.repeatable); try { fc.save(mapFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
Example 16
Source File: ShrinkingBorderEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public void saveEventData() { File dataDirectory = SkyWarsReloaded.get().getDataFolder(); File mapDataDirectory = new File(dataDirectory, "mapsData"); if (!mapDataDirectory.exists() && !mapDataDirectory.mkdirs()) { return; } File mapFile = new File(mapDataDirectory, gMap.getName() + ".yml"); if (mapFile.exists()) { FileConfiguration fc = YamlConfiguration.loadConfiguration(mapFile); fc.set("events." + eventName + ".enabled", this.enabled); fc.set("events." + eventName + ".minStart", this.min); fc.set("events." + eventName + ".maxStart", this.max); fc.set("events." + eventName + ".length", this.length); fc.set("events." + eventName + ".chance", this.chance); fc.set("events." + eventName + ".title", this.title); fc.set("events." + eventName + ".subtitle", this.subtitle); fc.set("events." + eventName + ".startMessage", this.startMessage); fc.set("events." + eventName + ".endMessage", this.endMessage); fc.set("events." + eventName + ".announceTimer", this.announceEvent); fc.set("events." + eventName + ".repeatable", this.repeatable); fc.set("events." + eventName + ".startingBorderSize", this.borderSize); fc.set("events." + eventName + ".shrinkRepeatDelay", this.delay); try { fc.save(mapFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
Example 17
Source File: HologramFormat.java From ShopChest with MIT License | 4 votes |
public HologramFormat(ShopChest plugin) { this.configFile = new File(plugin.getDataFolder(), "hologram-format.yml"); this.config = YamlConfiguration.loadConfiguration(configFile); this.plugin = plugin; }
Example 18
Source File: UCConfig.java From UltimateChat with GNU General Public License v3.0 | 4 votes |
private void loadChannels() throws IOException { File chfolder = new File(UChat.get().getDataFolder(), "channels"); if (!chfolder.exists()) { chfolder.mkdir(); UChat.get().getUCLogger().info("Created folder: " + chfolder.getPath()); } if (UChat.get().getChannels() == null) { UChat.get().setChannels(new HashMap<>()); } File[] listOfFiles = chfolder.listFiles(); YamlConfiguration channel; if (Objects.requireNonNull(listOfFiles).length == 0) { //create default channels File g = new File(chfolder, "global.yml"); channel = YamlConfiguration.loadConfiguration(g); channel.set("name", "Global"); channel.set("alias", "g"); channel.set("color", "&2"); channel.set("jedis", false); channel.set("dynmap.enable", true); channel.save(g); File l = new File(chfolder, "local.yml"); channel = YamlConfiguration.loadConfiguration(l); channel.set("name", "Local"); channel.set("alias", "l"); channel.set("color", "&e"); channel.set("jedis", false); channel.set("across-worlds", false); channel.set("distance", 40); channel.save(l); File ad = new File(chfolder, "admin.yml"); channel = YamlConfiguration.loadConfiguration(ad); channel.set("name", "Admin"); channel.set("alias", "ad"); channel.set("color", "&b"); channel.set("jedis", false); channel.save(ad); listOfFiles = chfolder.listFiles(); } for (File file : Objects.requireNonNull(listOfFiles)) { if (file.getName().endsWith(".yml")) { channel = YamlConfiguration.loadConfiguration(file); UCChannel ch = new UCChannel(channel.getValues(true)); try { addChannel(ch); } catch (IOException e) { e.printStackTrace(); } } } }
Example 19
Source File: LanguageFile.java From StaffPlus with GNU General Public License v3.0 | 4 votes |
public void setup() { langFile = new File(StaffPlus.get().getDataFolder() + "/lang/", FILE_NAME); lang = YamlConfiguration.loadConfiguration(langFile); }
Example 20
Source File: PlayerClass.java From DungeonsXL with GNU General Public License v3.0 | 2 votes |
/** * Creates a PlayerClass from a class YAML file. The name is taken from the file name. * * @param caliburn the CaliburnAPI instance * @param file the class config file */ public PlayerClass(CaliburnAPI caliburn, File file) { this(caliburn, file.getName().substring(0, file.getName().length() - 4), YamlConfiguration.loadConfiguration(file)); }