Java Code Examples for org.bukkit.configuration.file.FileConfiguration
The following examples show how to use
org.bukkit.configuration.file.FileConfiguration.
These examples are extracted from open source projects.
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 Project: Civs Author: Multitallented File: RegionsTests.java License: GNU General Public License v3.0 | 6 votes |
public static void loadRegionTypeCobble3() { FileConfiguration config = new YamlConfiguration(); config.set("max", 1); ArrayList<String> reqs = new ArrayList<>(); reqs.add("cobblestone*2"); reqs.add("g:glass*1"); config.set("build-reqs", reqs); ArrayList<String> effects = new ArrayList<>(); effects.add("block_place"); effects.add("block_break"); config.set("effects", effects); config.set("effect-radius", 7); config.set("period", 100); ArrayList<String> reagents = new ArrayList<>(); reagents.add("IRON_PICKAXE"); reagents.add("GOLD_BLOCK"); reagents.add("IRON_BLOCK"); config.set("upkeep.0.input", reagents); ArrayList<String> outputs = new ArrayList<>(); outputs.add("COBBLESTONE"); config.set("upkeep.0.output", outputs); ItemManager.getInstance().loadRegionType(config, "cobble"); }
Example #2
Source Project: CombatLogX Author: SirBlobman File: ListenerLegacyItemPickup.java License: GNU General Public License v3.0 | 6 votes |
private void sendMessage(Player player) { if(player == null) return; UUID uuid = player.getUniqueId(); if(messageCooldownList.contains(uuid)) return; String message = this.plugin.getLanguageMessageColoredWithPrefix("cheat-prevention.items.no-pickup"); this.plugin.sendMessage(player, message); messageCooldownList.add(uuid); BukkitScheduler scheduler = Bukkit.getScheduler(); Runnable task = () -> messageCooldownList.remove(uuid); FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml"); long messageCooldown = 20L * config.getLong("message-cooldown"); scheduler.runTaskLater(this.plugin.getPlugin(), task, messageCooldown); }
Example #3
Source Project: StackMob-3 Author: Nathat23 File: ConfigLoader.java License: GNU General Public License v3.0 | 6 votes |
@Override public boolean updateConfig(){ // Get the latest version of the file from the jar. InputStream is = sm.getResource(filename + ".yml"); BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); FileConfiguration includedFile = YamlConfiguration.loadConfiguration(reader); // Load a copy of the current file to check for later. FileConfiguration originalFile = YamlConfiguration.loadConfiguration(file); // Loop through the values of the latest version and set any that are not present. for(String key : includedFile.getKeys(true)){ if(!(getCustomConfig().contains(key))){ getCustomConfig().set(key, includedFile.get(key)); } } // Save the changes made, copy the default file. if(!(getCustomConfig().saveToString().equals(originalFile.saveToString()))){ try { copyDefault(); fc.save(file); return true; }catch (IOException e){ return false; } } return false; }
Example #4
Source Project: CombatLogX Author: SirBlobman File: ListenerEssentials.java License: GNU General Public License v3.0 | 6 votes |
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true) public void onToggleFlight(FlyStatusChangeEvent e) { if(!e.getValue()) return; FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml"); if (!config.getBoolean("flight.prevent-flying")) return; IUser affectedUser = e.getAffected(); Player player = affectedUser.getBase(); ICombatManager manager = this.plugin.getCombatManager(); if (!manager.isInCombat(player)) return; e.setCancelled(true); String message = this.plugin.getLanguageMessageColoredWithPrefix("cheat-prevention.flight.no-flying"); this.plugin.sendMessage(player, message); }
Example #5
Source Project: MineTinker Author: Flo56958 File: Beheading.java License: GNU General Public License v3.0 | 6 votes |
@Override public void reload() { FileConfiguration config = getConfig(); config.options().copyDefaults(true); config.addDefault("Allowed", true); config.addDefault("Color", "%DARK_GRAY%"); config.addDefault("MaxLevel", 10); config.addDefault("SlotCost", 2); config.addDefault("PercentagePerLevel", 10); //= 100% at Level 10 config.addDefault("DropSpawnEggChancePerLevel", 0); config.addDefault("EnchantCost", 25); config.addDefault("Enchantable", true); config.addDefault("Recipe.Enabled", false); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.WITHER_SKELETON_SKULL); this.percentagePerLevel = config.getInt("PercentagePerLevel", 10); this.dropSpawneggChancePerLevel = config.getInt("DropSpawnEggChancePerLevel", 0); this.description = this.description.replace("%chance", String.valueOf(this.percentagePerLevel)); }
Example #6
Source Project: Crazy-Auctions Author: badbones69 File: CrazyAuctions.java License: MIT License | 6 votes |
public ArrayList<ItemStack> getItems(Player player, ShopType type) { FileConfiguration data = Files.DATA.getFile(); ArrayList<ItemStack> items = new ArrayList<>(); if (data.contains("Items")) { for (String i : data.getConfigurationSection("Items").getKeys(false)) { if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) { if (data.getBoolean("Items." + i + ".Biddable")) { if (type == ShopType.BID) { items.add(data.getItemStack("Items." + i + ".Item").clone()); } } else { if (type == ShopType.SELL) { items.add(data.getItemStack("Items." + i + ".Item").clone()); } } } } } return items; }
Example #7
Source Project: PerWorldInventory Author: EbonJaeger File: GroupManager.java License: GNU General Public License v3.0 | 6 votes |
/** * Clears the worlds.yml configuration file, then writes all of the groups currently in memory * to it. */ public void saveGroupsToDisk() { FileConfiguration groupsConfigFile = plugin.getWorldsConfig(); groupsConfigFile.set("groups", null); for (Group group : groups.values()) { String groupKey = "groups." + group.getName(); groupsConfigFile.set(groupKey, null); groupsConfigFile.set(groupKey + ".worlds", group.getWorlds()); // Saving gamemode regardless of management; might be saving after convert groupsConfigFile.set(groupKey + ".default-gamemode", group.getGameMode().name()); } try { groupsConfigFile.save(plugin.getDataFolder() + "/worlds.yml"); } catch (IOException ex) { ConsoleLogger.warning("Could not save the groups config to disk:", ex); } }
Example #8
Source Project: civcraft Author: netizen539 File: ConfigUnit.java License: GNU General Public License v2.0 | 6 votes |
public static void loadConfig(FileConfiguration cfg, Map<String, ConfigUnit> units){ units.clear(); List<Map<?, ?>> configUnits = cfg.getMapList("units"); for (Map<?, ?> b : configUnits) { ConfigUnit unit = new ConfigUnit(); unit.id = (String)b.get("id"); unit.name = (String)b.get("name"); unit.class_name = (String)b.get("class_name"); unit.require_tech = (String)b.get("require_tech"); unit.require_struct = (String)b.get("require_struct"); unit.require_upgrade = (String)b.get("require_upgrade"); unit.cost = (Double)b.get("cost"); unit.hammer_cost = (Double)b.get("hammer_cost"); unit.limit = (Integer)b.get("limit"); unit.item_id = (Integer)b.get("item_id"); unit.item_data = (Integer)b.get("item_data"); units.put(unit.id, unit); } CivLog.info("Loaded "+units.size()+" Units."); }
Example #9
Source Project: Slimefun4 Author: TheBusyBiscuit File: SlimefunLocalization.java License: GNU General Public License v3.0 | 6 votes |
public ItemStack getRecipeTypeItem(Player p, RecipeType recipeType) { Language language = getLanguage(p); ItemStack item = recipeType.toItem(); NamespacedKey key = recipeType.getKey(); if (language.getRecipeTypesFile() == null || !language.getRecipeTypesFile().contains(key.getNamespace() + "." + key.getKey())) { language = getLanguage("en"); } if (!language.getRecipeTypesFile().contains(key.getNamespace() + "." + key.getKey())) { return item; } FileConfiguration config = language.getRecipeTypesFile(); return new CustomItem(item, meta -> { meta.setDisplayName(ChatColor.AQUA + config.getString(key.getNamespace() + "." + key.getKey() + ".name")); List<String> lore = config.getStringList(key.getNamespace() + "." + key.getKey() + ".lore"); lore.replaceAll(line -> ChatColor.GRAY + line); meta.setLore(lore); meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); }); }
Example #10
Source Project: SkyWarsReloaded Author: walrusone File: ProjectileEffectOption.java License: GNU General Public License v3.0 | 6 votes |
private static void updateFile(File file, FileConfiguration storage) { ArrayList<Integer> placement = new ArrayList<>(Arrays.asList(0, 2, 4, 6, 8, 9, 11, 13, 15, 17, 18, 20, 22, 24, 26, 27, 29, 31, 33, 35, 36, 38, 40, 42, 44, 45, 47, 49, 51, 53)); storage.set("menuSize", 45); for (int i = 0; i < playerOptions.size(); i++) { playerOptions.get(i).setPosition(placement.get(i) % 45); playerOptions.get(i).setPage((Math.floorDiv(placement.get(i), 45))+1); playerOptions.get(i).setMenuSize(45); storage.set("effects." + playerOptions.get(i).getKey() + ".position", playerOptions.get(i).getPosition()); storage.set("effects." + playerOptions.get(i).getKey() + ".page", playerOptions.get(i).getPage()); } try { storage.save(file); } catch (IOException e) { e.printStackTrace(); } }
Example #11
Source Project: Civs Author: Multitallented File: TownManager.java License: GNU General Public License v3.0 | 6 votes |
public void loadAllTowns() { File townFolder = new File(Civs.dataLocation, "towns"); if (!townFolder.exists()) { townFolder.mkdir(); } try { for (File file : townFolder.listFiles()) { FileConfiguration config = new YamlConfiguration(); try { config.load(file); loadTown(config); } catch (Exception e) { Civs.logger.warning("Unable to read from towns/" + file.getName()); e.printStackTrace(); } } } catch (NullPointerException npe) { Civs.logger.severe("Unable to read from town folder!"); } }
Example #12
Source Project: civcraft Author: netizen539 File: ConfigBuff.java License: GNU General Public License v2.0 | 6 votes |
public static void loadConfig(FileConfiguration cfg, Map<String, ConfigBuff> buffs){ buffs.clear(); List<Map<?, ?>> configBuffs = cfg.getMapList("buffs"); for (Map<?, ?> b : configBuffs) { ConfigBuff buff = new ConfigBuff(); buff.id = (String)b.get("id"); buff.name = (String)b.get("name"); buff.description = (String)b.get("description"); buff.description = CivColor.colorize(buff.description); buff.value = (String)b.get("value"); buff.stackable = (Boolean)b.get("stackable"); buff.parent = (String)b.get("parent"); if (buff.parent == null) { buff.parent = buff.id; } buffs.put(buff.id, buff); } CivLog.info("Loaded "+buffs.size()+" Buffs."); }
Example #13
Source Project: NametagEdit Author: sgtcaze File: DatabaseConfig.java License: GNU General Public License v3.0 | 6 votes |
@Override public void load() { FileConfiguration config = handler.getConfig(); shutdown(); hikari = new HikariDataSource(); hikari.setMaximumPoolSize(config.getInt("MinimumPoolSize", 10)); hikari.setPoolName("NametagEdit Pool"); hikari.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource"); hikari.addDataSourceProperty("useSSL", false); hikari.addDataSourceProperty("requireSSL", false); hikari.addDataSourceProperty("verifyServerCertificate", false); hikari.addDataSourceProperty("serverName", config.getString("MySQL.Hostname")); hikari.addDataSourceProperty("port", config.getString("MySQL.Port")); hikari.addDataSourceProperty("databaseName", config.getString("MySQL.Database")); hikari.addDataSourceProperty("user", config.getString("MySQL.Username")); hikari.addDataSourceProperty("password", config.getString("MySQL.Password")); new DatabaseUpdater(handler, hikari, plugin).runTaskAsynchronously(plugin); }
Example #14
Source Project: SkyWarsReloaded Author: walrusone File: WinSoundOption.java License: GNU General Public License v3.0 | 6 votes |
private static void updateFile(File file, FileConfiguration storage) { ArrayList<Integer> placement = new ArrayList<>(Arrays.asList(0, 2, 4, 6, 8, 9, 11, 13, 15, 17, 18, 20, 22, 24, 26, 27, 29, 31, 33, 35, 36, 38, 40, 42, 44, 45, 47, 49, 51, 53)); storage.set("menuSize", 45); for (int i = 0; i < playerOptions.size(); i++) { playerOptions.get(i).setPosition(placement.get(i) % 45); playerOptions.get(i).setPage((Math.floorDiv(placement.get(i), 45))+1); playerOptions.get(i).setMenuSize(45); storage.set("sounds." + playerOptions.get(i).getKey() + ".position", playerOptions.get(i).getPosition()); storage.set("sounds." + playerOptions.get(i).getKey() + ".page", playerOptions.get(i).getPage()); } try { storage.save(file); } catch (IOException e) { e.printStackTrace(); } }
Example #15
Source Project: CombatLogX Author: SirBlobman File: ListenerTeleport.java License: GNU General Public License v3.0 | 6 votes |
@EventHandler(priority=EventPriority.HIGH, ignoreCancelled=true) public void onTeleport(PlayerTeleportEvent e) { FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml"); if(!config.getBoolean("teleportation.prevent-teleport")) return; Player player = e.getPlayer(); ICombatManager manager = this.plugin.getCombatManager(); if(!manager.isInCombat(player)) return; PlayerTeleportEvent.TeleportCause cause = e.getCause(); if(isAllowed(cause)) { if(cause == PlayerTeleportEvent.TeleportCause.ENDER_PEARL && config.getBoolean("teleportation.restart-timer-for-ender-pearl")) { manager.tag(player, null, PlayerPreTagEvent.TagType.UNKNOWN, PlayerPreTagEvent.TagReason.UNKNOWN); } return; } e.setCancelled(true); String message = this.plugin.getLanguageMessageColoredWithPrefix("cheat-prevention.teleportation.block-" + (cause == PlayerTeleportEvent.TeleportCause.ENDER_PEARL ? "pearl" : "other")); this.plugin.sendMessage(player, message); }
Example #16
Source Project: Civs Author: Multitallented File: GovernmentManager.java License: GNU General Public License v3.0 | 6 votes |
private void loadGovType(FileConfiguration config, String name) { if (!config.getBoolean("enabled", false)) { return; } String govTypeString = config.getString("inherit", name); GovernmentType governmentType = GovernmentType.valueOf(govTypeString.toUpperCase()); if (governmentType == GovernmentType.CYBERSYNACY) { new AIManager(); } CVItem cvItem = CVItem.createCVItemFromString(config.getString("icon", "STONE")); ArrayList<GovTransition> transitions = processTransitionList(config.getConfigurationSection("transition")); Government government = new Government(name, governmentType, getBuffs(config.getConfigurationSection("buffs")), cvItem, transitions); governments.put(name.toUpperCase(), government); }
Example #17
Source Project: CombatLogX Author: SirBlobman File: ListenerPunishChecks.java License: GNU General Public License v3.0 | 6 votes |
@EventHandler(priority=EventPriority.LOWEST, ignoreCancelled=true) public void beforePunish(PlayerPunishEvent e) { FileConfiguration config = this.plugin.getConfig("config.yml"); boolean punishOnQuit = config.getBoolean("punishments.on-quit"); boolean punishOnKick = config.getBoolean("punishments.on-kick"); boolean punishOnExpire = config.getBoolean("punishments.on-expire"); PlayerUntagEvent.UntagReason punishReason = e.getPunishReason(); if(punishReason.isExpire() && !punishOnExpire) { e.setCancelled(true); return; } if(punishReason == PlayerUntagEvent.UntagReason.KICK && !punishOnKick) { e.setCancelled(true); return; } if(punishReason == PlayerUntagEvent.UntagReason.QUIT && !punishOnQuit) { e.setCancelled(true); // return; } }
Example #18
Source Project: iDisguise Author: robingrether File: Language.java License: Creative Commons Attribution Share Alike 4.0 International | 6 votes |
public void loadData() { File languageFile = new File(plugin.getDataFolder(), "language.yml"); FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(languageFile); try { int fileVersion = UpdateCheck.extractVersionNumber(fileConfiguration.getString("version", "iDisguise 5.7.3")); for(Field field : getClass().getDeclaredFields()) { if(field.getType().equals(String.class)) { if((!field.isAnnotationPresent(LastUpdated.class) || field.getAnnotation(LastUpdated.class).value() <= fileVersion) && fileConfiguration.isString(field.getName().toLowerCase(Locale.ENGLISH).replace('_', '-'))) { field.set(this, fileConfiguration.getString(field.getName().toLowerCase(Locale.ENGLISH).replace('_', '-'))); } } } } catch(Exception e) { plugin.getLogger().log(Level.SEVERE, "An error occured while loading the language file.", e); } }
Example #19
Source Project: Crazy-Auctions Author: badbones69 File: GUI.java License: MIT License | 5 votes |
public static void openCategories(Player player, ShopType shop) { Methods.updateAuction(); FileConfiguration config = Files.CONFIG.getFile(); Inventory inv = Bukkit.createInventory(null, 54, Methods.color(config.getString("Settings.Categories"))); List<String> options = new ArrayList<>(); options.add("OtherSettings.Back"); options.add("OtherSettings.WhatIsThis.Categories"); options.add("Category-Settings.Armor"); options.add("Category-Settings.Weapons"); options.add("Category-Settings.Tools"); options.add("Category-Settings.Food"); options.add("Category-Settings.Potions"); options.add("Category-Settings.Blocks"); options.add("Category-Settings.Other"); options.add("Category-Settings.None"); for (String o : options) { if (config.contains("Settings.GUISettings." + o + ".Toggle")) { if (!config.getBoolean("Settings.GUISettings." + o + ".Toggle")) { continue; } } String id = config.getString("Settings.GUISettings." + o + ".Item"); String name = config.getString("Settings.GUISettings." + o + ".Name"); int slot = config.getInt("Settings.GUISettings." + o + ".Slot"); if (config.contains("Settings.GUISettings." + o + ".Lore")) { inv.setItem(slot - 1, Methods.makeItem(id, 1, name, config.getStringList("Settings.GUISettings." + o + ".Lore"))); } else { inv.setItem(slot - 1, Methods.makeItem(id, 1, name)); } } shopType.put(player, shop); player.openInventory(inv); }
Example #20
Source Project: SkyWarsReloaded Author: walrusone File: EnderDragonEvent.java License: 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 #21
Source Project: mcspring-boot Author: Alan-Gomes File: SpringSpigotTestInitializer.java License: MIT License | 5 votes |
private static Plugin mockPlugin() { Plugin plugin = mock(Plugin.class); when(plugin.getName()).thenReturn(PLUGIN_NAME); Server server = mockServer(); when(plugin.getServer()).thenReturn(server); FileConfiguration config = mockConfig(); when(plugin.getConfig()).thenReturn(config); when(server.getPluginManager().getPlugin(PLUGIN_NAME)).thenReturn(plugin); return plugin; }
Example #22
Source Project: CombatLogX Author: SirBlobman File: ListenerBlocks.java License: GNU General Public License v3.0 | 5 votes |
@EventHandler(priority=EventPriority.HIGH, ignoreCancelled=true) public void onBlockPlace(BlockPlaceEvent e) { FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml"); if(!config.getBoolean("blocks.prevent-placing")) return; Player player = e.getPlayer(); ICombatManager combatManager = this.plugin.getCombatManager(); if(!combatManager.isInCombat(player)) return; e.setCancelled(true); sendMessageWithCooldown(player, "cheat-prevention.blocks.no-placing"); }
Example #23
Source Project: Civs Author: Multitallented File: RegionsTests.java License: GNU General Public License v3.0 | 5 votes |
public static void loadRegionTypeCobble2() { FileConfiguration config = new YamlConfiguration(); ArrayList<String> reqs = new ArrayList<>(); reqs.add("cobblestone*3"); config.set("build-reqs", reqs); ArrayList<String> reagents = new ArrayList<>(); reagents.add("IRON_PICKAXE"); config.set("reagents", reagents); ArrayList<String> effects = new ArrayList<>(); effects.add("block_place"); effects.add("block_break"); config.set("effects", effects); config.set("effect-radius", 7); ItemManager.getInstance().loadRegionType(config, "cobble"); }
Example #24
Source Project: SuperVanish Author: MyzelYam File: ServerListPacketListener.java License: Mozilla Public License 2.0 | 5 votes |
public static boolean isEnabled(SuperVanish plugin) { final FileConfiguration config = plugin.getSettings(); return config.getBoolean( "ExternalInvisibility.ServerList.AdjustAmountOfOnlinePlayers") || config.getBoolean( "ExternalInvisibility.ServerList.AdjustListOfLoggedInPlayers"); }
Example #25
Source Project: CombatLogX Author: SirBlobman File: ListenerLegacyItemPickup.java License: GNU General Public License v3.0 | 5 votes |
@EventHandler(priority= EventPriority.HIGH, ignoreCancelled=true) public void onPickupItem(PlayerPickupItemEvent e) { FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml"); if(!config.getBoolean("items.prevent-item-pickup")) return; Player player = e.getPlayer(); ICombatManager combatManager = this.plugin.getCombatManager(); if(!combatManager.isInCombat(player)) return; e.setCancelled(true); sendMessage(player); }
Example #26
Source Project: Civs Author: Multitallented File: TownManager.java License: GNU General Public License v3.0 | 5 votes |
private void saveRevolt(Town town, FileConfiguration config) { ArrayList<String> uuidList = new ArrayList<>(); for (UUID uuid : town.getRevolt()) { uuidList.add(uuid.toString()); } config.set("revolt", uuidList); }
Example #27
Source Project: SkyWarsReloaded Author: walrusone File: ShrinkingBorderEvent.java License: 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 #28
Source Project: SkyWarsReloaded Author: walrusone File: ProjectileSpleefEvent.java License: GNU General Public License v3.0 | 5 votes |
public ProjectileSpleefEvent(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 = "ProjectileSpleefEvent"; slot = 13; material = new ItemStack(Material.EGG, 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.eggsToAdd = fc.getInt("events." + eventName + ".eggsAddedToInventory"); } }
Example #29
Source Project: MineTinker Author: Flo56958 File: SpidersBane.java License: GNU General Public License v3.0 | 5 votes |
@Override public void reload() { FileConfiguration config = getConfig(); config.options().copyDefaults(true); config.addDefault("Allowed", true); config.addDefault("Color", "%RED%"); config.addDefault("MaxLevel", 5); config.addDefault("SlotCost", 1); config.addDefault("EnchantCost", 10); config.addDefault("Enchantable", false); config.addDefault("Recipe.Enabled", true); config.addDefault("Recipe.Top", "ESE"); config.addDefault("Recipe.Middle", "SFS"); config.addDefault("Recipe.Bottom", "ESE"); Map<String, String> recipeMaterials = new HashMap<>(); recipeMaterials.put("E", Material.SPIDER_EYE.name()); recipeMaterials.put("S", Material.STRING.name()); recipeMaterials.put("F", Material.FERMENTED_SPIDER_EYE.name()); config.addDefault("Recipe.Materials", recipeMaterials); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.FERMENTED_SPIDER_EYE); }
Example #30
Source Project: Civs Author: Multitallented File: FallbackConfigUtil.java License: GNU General Public License v3.0 | 5 votes |
public static FileConfiguration getConfigFullPath(File originalFile, String url) { FileConfiguration config = new YamlConfiguration(); try { InputStream inputStream = FallbackConfigUtil.class.getResourceAsStream(url); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); config.load(reader); if (originalFile != null && originalFile.exists()) { FileConfiguration configOverride = new YamlConfiguration(); configOverride.load(originalFile); for (String key : configOverride.getKeys(true)) { if (configOverride.get(key) instanceof ConfigurationSection) { continue; } config.set(key, configOverride.get(key)); } } } catch (Exception e) { if (originalFile != null) { Civs.logger.log(Level.SEVERE, "File name: {0}", originalFile.getName()); } if (url != null) { Civs.logger.log(Level.SEVERE, "Resource path: {0}", url); } Civs.logger.log(Level.SEVERE, "Unable to load config", e); } return config; }