Java Code Examples for org.bukkit.configuration.file.FileConfiguration#getString()
The following examples show how to use
org.bukkit.configuration.file.FileConfiguration#getString() .
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: ConverterTask.java From NametagEdit with GNU General Public License v3.0 | 6 votes |
@Override public void run() { FileConfiguration config = plugin.getHandler().getConfig(); String connectionString = "jdbc:mysql://" + config.getString("MySQL.Hostname") + ":" + config.getInt("MySQL.Port") + "/" + config.getString("MySQL.Database"); try (Connection connection = DriverManager.getConnection(connectionString, config.getString("MySQL.Username"), config.getString("MySQL.Password"))) { if (databaseToFile) { convertDatabaseToFile(connection); } else { convertFilesToDatabase(connection); } } catch (SQLException e) { e.printStackTrace(); } finally { new BukkitRunnable() { @Override public void run() { plugin.getHandler().reload(); } }.runTask(plugin); } }
Example 2
Source File: ItemManager.java From Civs with GNU General Public License v3.0 | 6 votes |
public CivItem loadSpellType(FileConfiguration config, String name) { CVItem icon = CVItem.createCVItemFromString(config.getString("icon", Material.CHEST.name())); SpellType spellType = new SpellType( config.getStringList("reqs"), name, icon.getMat(), CVItem.createCVItemFromString(config.getString("shop-icon", config.getString("icon", Material.CHEST.name()))), config.getInt("qty", 0), config.getInt("min", 0), config.getInt("max", -1), config.getDouble("price", 0), config.getString("permission"), config.getStringList("groups"), config, config.getBoolean("is-in-shop", true), config.getInt("level", 1)); itemTypes.put(name.toLowerCase(), spellType); return spellType; }
Example 3
Source File: ItemManager.java From Civs with GNU General Public License v3.0 | 6 votes |
public CivItem loadClassType(FileConfiguration config, String name) { //TODO load classestype properly CVItem icon = CVItem.createCVItemFromString(config.getString("icon", Material.CHEST.name())); ClassType civItem = new ClassType( config.getStringList("reqs"), name, icon, CVItem.createCVItemFromString(config.getString("shop-icon", config.getString("icon", Material.CHEST.name()))), config.getDouble("price", 0), config.getString("permission"), config.getStringList("children"), config.getStringList("groups"), config.getInt("mana-per-second", 1), config.getInt("max-mana", 100), config.getBoolean("is-in-shop", true), config.getInt("level", 1)); itemTypes.put(name, civItem); return civItem; }
Example 4
Source File: GovernmentManager.java From Civs with 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 5
Source File: ConfigManager.java From Civs with GNU General Public License v3.0 | 5 votes |
private void getGovSettings(FileConfiguration config) { String defaultGovTypeString = config.getString("default-gov-type", "DICTATORSHIP"); if (defaultGovTypeString != null) { defaultGovernmentType = defaultGovTypeString.toUpperCase(); } else { defaultGovernmentType = GovernmentType.DICTATORSHIP.name(); } allowChangingOfGovType = config.getBoolean("allow-changing-gov-type", false); }
Example 6
Source File: GUI.java From Crazy-Auctions with MIT License | 5 votes |
public static ItemStack getBiddingItem(Player player, String ID) { FileConfiguration config = Files.CONFIG.getFile(); FileConfiguration data = Files.DATA.getFile(); String seller = data.getString("Items." + ID + ".Seller"); String topbidder = data.getString("Items." + ID + ".TopBidder"); ItemStack item = data.getItemStack("Items." + ID + ".Item"); List<String> lore = new ArrayList<>(); for (String l : config.getStringList("Settings.GUISettings.Bidding")) { lore.add(l.replace("%TopBid%", Methods.getPrice(ID, false)).replace("%topbid%", Methods.getPrice(ID, false)).replace("%Seller%", seller).replace("%seller%", seller).replace("%TopBidder%", topbidder).replace("%topbidder%", topbidder).replace("%Time%", Methods.convertToTime(data.getLong("Items." + ID + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + ID + ".Time-Till-Expire")))); } return Methods.addLore(item.clone(), lore); }
Example 7
Source File: MobSpawnEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
public MobSpawnEvent(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 = "MobSpawnEvent"; slot = 22; material = SkyWarsReloaded.getNMS().getMaterial("MOB_SPAWNER"); 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.minMobsPerPlayer = fc.getInt("events." + eventName + ".minMobsPerPlayer"); this.maxMobsPerPlayer = fc.getInt("events." + eventName + ".maxMobsPerPlayer"); this.mobs = fc.getStringList("events." + eventName + ".mobs"); } }
Example 8
Source File: CivSettings.java From civcraft with GNU General Public License v2.0 | 5 votes |
public static String getString(FileConfiguration cfg, String path) throws InvalidConfiguration { String data = cfg.getString(path); if (data == null) { throw new InvalidConfiguration("Could not get configuration string "+path); } return data; }
Example 9
Source File: ActionBarManager.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
private String getTimerMessage(Player player) { FileConfiguration config = this.expansion.getConfig("actionbar.yml"); String timerMessageFormat = config.getString("message-timer"); if(timerMessageFormat == null) return ""; String barsLeft = getBarsLeft(expansion, player); String barsRight = getBarsRight(expansion, player); String message = timerMessageFormat.replace("{bars_left}", barsLeft).replace("{bars_right}", barsRight); return MessageUtil.color(this.expansion.replacePlaceholders(player, message)); }
Example 10
Source File: SpawnLoader.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
/** * Build a {@link Location} object based on the CMI configuration. * * @param configuration The CMI file configuration to read from * * @return Location corresponding to the values in the path */ private static Location getLocationFromCmiConfiguration(FileConfiguration configuration) { final String pathPrefix = "Spawn.Main"; if (isLocationCompleteInCmiConfig(configuration, pathPrefix)) { String prefix = pathPrefix + "."; String worldName = configuration.getString(prefix + "World"); World world = Bukkit.getWorld(worldName); if (!StringUtils.isEmpty(worldName) && world != null) { return new Location(world, configuration.getDouble(prefix + "X"), configuration.getDouble(prefix + "Y"), configuration.getDouble(prefix + "Z"), getFloat(configuration, prefix + "Yaw"), getFloat(configuration, prefix + "Pitch")); } } return null; }
Example 11
Source File: ChestRefillEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
public ChestRefillEvent(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 = "ChestRefillEvent"; slot = 4; material = new ItemStack(Material.CHEST, 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"); } }
Example 12
Source File: ArrowRainEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
public ArrowRainEvent(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 = "ArrowRainEvent"; slot = 2; material = new ItemStack(Material.ARROW, 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.per2Tick = fc.getInt("events." + eventName + ".spawnPer2Tick"); } }
Example 13
Source File: BossBarManager.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
private String getTimerMessage(Player player) { FileConfiguration config = this.expansion.getConfig("bossbar.yml"); String timerMessageFormat = config.getString("message-timer"); if(timerMessageFormat == null) return ""; return MessageUtil.color(this.expansion.replacePlaceholders(player, timerMessageFormat)); }
Example 14
Source File: BedwarsRel.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
public String getStringConfig(String key, String defaultString) { FileConfiguration config = this.getConfig(); if (config.contains(key) && config.isString(key)) { return config.getString(key); } return defaultString; }
Example 15
Source File: NoEntryHandler.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
public NoEntryMode getNoEntryMode() { String fileName = getConfigFileName(); FileConfiguration config = this.expansion.getConfig(fileName); String modeString = config.getString("no-entry.mode", NoEntryMode.KNOCKBACK.name()); try {return NoEntryMode.valueOf(modeString);} catch(IllegalArgumentException | NullPointerException ex) {return NoEntryMode.KNOCKBACK;} }
Example 16
Source File: GroupManager.java From PerWorldInventory with GNU General Public License v3.0 | 5 votes |
/** * Loads the groups defined in a 'worlds.yml' file into memory. * * @param config The contents of the configuration file. */ public void loadGroupsToMemory(FileConfiguration config) { groups.clear(); for (String key : config.getConfigurationSection("groups.").getKeys(false)) { List<String> worlds; if (config.contains("groups." + key + ".worlds")) { worlds = config.getStringList("groups." + key + ".worlds"); } else { worlds = config.getStringList("groups." + key); config.set("groups." + key, null); config.set("groups." + key + ".worlds", worlds); if (settings.getProperty(PwiProperties.SEPARATE_GAMEMODE_INVENTORIES)) { config.set("groups." + key + ".default-gamemode", "SURVIVAL"); } } if (settings.getProperty(PwiProperties.MANAGE_GAMEMODES)) { GameMode gameMode = GameMode.SURVIVAL; if (config.getString("groups." + key + ".default-gamemode") != null) { gameMode = GameMode.valueOf(config.getString("groups." + key + ".default-gamemode").toUpperCase()); } addGroup(key, worlds, gameMode); } else { addGroup(key, worlds); } setDefaultsFile(key); } }
Example 17
Source File: LevelManager.java From SkyWarsReloaded with GNU General Public License v3.0 | 4 votes |
public void loadKillSounds() { killSoundList.clear(); File soundFile = new File(SkyWarsReloaded.get().getDataFolder(), "killsounds.yml"); if (!soundFile.exists()) { if (SkyWarsReloaded.getNMS().getVersion() < 8) { SkyWarsReloaded.get().saveResource("killsounds18.yml", false); File sf = new File(SkyWarsReloaded.get().getDataFolder(), "killsounds18.yml"); if (sf.exists()) { sf.renameTo(new File(SkyWarsReloaded.get().getDataFolder(), "killsounds.yml")); } } else { SkyWarsReloaded.get().saveResource("killsounds.yml", false); } } if (soundFile.exists()) { FileConfiguration storage = YamlConfiguration.loadConfiguration(soundFile); if (storage.getConfigurationSection("sounds") != null) { for (String key: storage.getConfigurationSection("sounds").getKeys(false)) { String sound = storage.getString("sounds." + key + ".sound"); String name = storage.getString("sounds." + key + ".displayName"); int volume = storage.getInt("sounds." + key + ".volume"); int pitch = storage.getInt("sounds." + key + ".pitch"); String material = storage.getString("sounds." + key + ".icon"); int level = storage.getInt("sounds." + key + ".level"); int cost = storage.getInt("sounds." + key + ".cost"); boolean isCustom = storage.getBoolean("sounds." + key + ".isCustomSound"); Material mat = Material.matchMaterial(material); if (mat != null) { if (!isCustom) { try { Sound s = Sound.valueOf(sound); if (s != null) { killSoundList.add(new SoundItem(key, sound, name, level, cost, volume, pitch, mat, isCustom)); } } catch (IllegalArgumentException e) { SkyWarsReloaded.get().getServer().getLogger().info(sound + " is not a valid sound in killsounds.yml"); } } else { killSoundList.add(new SoundItem(key, sound, name, level, cost, volume, pitch, mat, isCustom)); } } else { SkyWarsReloaded.get().getServer().getLogger().info(mat + " is not a valid Material in killsounds.yml"); } } } } Collections.<SoundItem>sort(killSoundList); }
Example 18
Source File: GunYMLLoader.java From QualityArmory with GNU General Public License v3.0 | 4 votes |
public static void loadGuns(QAMain main, File f) { if (f.getName().contains("yml")) { FileConfiguration f2 = YamlConfiguration.loadConfiguration(f); if ((!f2.contains("invalid")) || !f2.getBoolean("invalid")) { final String name = f2.getString("name"); if(QAMain.verboseLoadingLogging) main.getLogger().info("-Loading Gun: " + name); Material m = f2.contains("material") ? Material.matchMaterial(f2.getString("material")) : Material.DIAMOND_AXE; int variant = f2.contains("variant") ? f2.getInt("variant") : 0; final MaterialStorage ms = MaterialStorage.getMS(m, f2.getInt("id"), variant); WeaponType weatype = f2.contains("guntype") ? WeaponType.valueOf(f2.getString("guntype")) : WeaponType.valueOf(f2.getString("weapontype")); final ItemStack[] materails = main.convertIngredients(f2.getStringList("craftingRequirements")); final String displayname = f2.contains("displayname") ? ChatColor.translateAlternateColorCodes('&', f2.getString("displayname")) : (ChatColor.GOLD + name); final List<String> extraLore2 = f2.contains("lore") ? f2.getStringList("lore") : null; final List<String> extraLore = new ArrayList<String>(); try { for (String lore : extraLore2) { extraLore.add(ChatColor.translateAlternateColorCodes('&', lore)); } } catch (Error | Exception re52) { } if (weatype.isGun()) { Gun g = new Gun(name, ms); g.setDisplayname(displayname); g.setCustomLore(extraLore); g.setIngredients(materails); QAMain.gunRegister.put(ms, g); loadGunSettings(g, f2); } } } }
Example 19
Source File: GameMap.java From SkyWarsReloaded with GNU General Public License v3.0 | 4 votes |
private static void updateMapData() { File mapFile = new File(SkyWarsReloaded.get().getDataFolder(), "maps.yml"); if (mapFile.exists()) { FileConfiguration storage = YamlConfiguration.loadConfiguration(mapFile); if (storage.getConfigurationSection("maps") != null) { for (String key: storage.getConfigurationSection("maps").getKeys(false)) { String displayname = storage.getString("maps." + key + ".displayname"); int minplayers = storage.getInt("maps." + key + ".minplayers"); String creator = storage.getString("maps." + key + ".creator"); List<String> signs = storage.getStringList("maps." + key + ".signs"); boolean registered = storage.getBoolean("maps." + key + ".registered"); File dataDirectory = SkyWarsReloaded.get().getDataFolder(); File mapDataDirectory = new File(dataDirectory, "mapsData"); if (!mapDataDirectory.exists() && !mapDataDirectory.mkdirs()) { return; } File newMapFile = new File(mapDataDirectory, key + ".yml"); copyDefaults(newMapFile); FileConfiguration fc = YamlConfiguration.loadConfiguration(newMapFile); fc.set("displayname", displayname); fc.set("minplayers", minplayers); fc.set("creator", creator); fc.set("signs", signs); fc.set("registered", registered); fc.set("environment", "NORMAL"); fc.set("spectateSpawn", "0:95:0"); fc.set("deathMatchSpawns", null); fc.set("legacy", true); try { fc.save(newMapFile); } catch (IOException e) { e.printStackTrace(); } } } boolean result = mapFile.delete(); if (!result) { SkyWarsReloaded.get().getLogger().info("Failed to Delete Old MapData File"); } } }
Example 20
Source File: ConnectSettingsImpl.java From Bukkit-Connect with GNU General Public License v3.0 | 4 votes |
public ConnectSettingsImpl(FileConfiguration fileConfiguration) { this.outboundIp = fileConfiguration.getString("settings.address"); this.outboundPort = fileConfiguration.getInt("settings.port"); this.username = fileConfiguration.getString("settings.credentials.username"); this.password = fileConfiguration.getString("settings.credentials.password"); }