Java Code Examples for org.bukkit.configuration.file.FileConfiguration#getInt()
The following examples show how to use
org.bukkit.configuration.file.FileConfiguration#getInt() .
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: Beheading.java From MineTinker with 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 3
Source File: ArmorListener.java From MineTinker with GNU General Public License v3.0 | 6 votes |
private void expCalculation(boolean isBlocking, ItemStack tool, EntityDamageEvent event, Player player) { //Armor should not get Exp when successfully blocking if(isBlocking && !ToolType.SHIELD.contains(tool.getType()) && ToolType.ARMOR.contains(tool.getType())) return; //Shield should not get Exp when not successfully blocking when getting attacked if(!isBlocking && player.equals(event.getEntity()) && ToolType.SHIELD.contains(tool.getType())) return; FileConfiguration config = MineTinker.getPlugin().getConfig(); int amount = config.getInt("ExpPerEntityHit"); if (config.getBoolean("EnableDamageExp")) { amount = (int) Math.round(event.getDamage()); } if (config.getBoolean("DisableExpFromFalldamage", false) && event.getCause() == EntityDamageEvent.DamageCause.FALL) { return; } modManager.addExp(player, tool, amount); }
Example 4
Source File: KineticPlating.java From MineTinker with 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", "%GRAY%"); config.addDefault("MaxLevel", 5); config.addDefault("SlotCost", 1); config.addDefault("Amount", 20); //How much XP should be dropped when triggered config.addDefault("EnchantCost", 10); config.addDefault("Enchantable", false); config.addDefault("Recipe.Enabled", true); config.addDefault("Recipe.Top", "PIP"); config.addDefault("Recipe.Middle", "III"); config.addDefault("Recipe.Bottom", "PIP"); Map<String, String> recipeMaterials = new HashMap<>(); recipeMaterials.put("I", Material.IRON_BLOCK.name()); recipeMaterials.put("P", Material.PHANTOM_MEMBRANE.name()); config.addDefault("Recipe.Materials", recipeMaterials); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.IRON_BLOCK); this.amount = config.getInt("Amount", 1); this.description = this.description.replace("%amount", String.valueOf(this.amount)); }
Example 5
Source File: Poisonous.java From MineTinker with 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", "%DARK_GREEN%"); config.addDefault("MaxLevel", 5); config.addDefault("SlotCost", 1); config.addDefault("Duration", 120); //ticks INTEGER (20 ticks ~ 1 sec) config.addDefault("DurationMultiplier", 1.1); //Duration * (Multiplier^Level) DOUBLE config.addDefault("EffectAmplifier", 2); //per Level (Level 1 = 0, Level 2 = 2, Level 3 = 4, ...) INTEGER config.addDefault("DropRottenMeatIfPoisoned", true); config.addDefault("EffectHealsPlayer", true); config.addDefault("EnchantCost", 20); config.addDefault("Enchantable", true); config.addDefault("Recipe.Enabled", false); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.ROTTEN_FLESH); this.duration = config.getInt("Duration", 120); this.durationMultiplier = config.getDouble("DurationMultiplier", 1.1); this.effectAmplifier = config.getInt("EffectAmplifier", 2); this.dropPoisonedMeat = config.getBoolean("DropRottenMeatIfPoisoned", true); this.effectHealsPlayer = config.getBoolean("EffectHealsPlayer", true); this.description = this.description.replace("%duration", String.valueOf(this.duration)) .replace("%multiplier", String.valueOf(this.durationMultiplier)); }
Example 6
Source File: BedwarsRel.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
public Integer getRespawnProtectionTime() { FileConfiguration config = this.getConfig(); if (config.contains("respawn-protection") && config.isInt("respawn-protection")) { return config.getInt("respawn-protection"); } return 0; }
Example 7
Source File: DoubleDamageEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
public DoubleDamageEvent(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 = "DoubleDamageEvent"; slot = 15; material = new ItemStack(Material.DIAMOND_AXE, 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 8
Source File: CommonLevelLogic.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
CommonLevelLogic(uSkyBlock plugin, FileConfiguration config) { this.plugin = plugin; this.config = config; activateNetherAtLevel = config.getInt("nether.activate-at.level", 100); pointsPerLevel = config.getInt("general.pointsPerLevel"); load(); }
Example 9
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 10
Source File: ExtraModifier.java From MineTinker with 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", "%WHITE%"); config.addDefault("ExtraModifierGain", 1); //How much Slots should be added per Nether-Star config.addDefault("EnchantCost", 10); config.addDefault("Enchantable", false); config.addDefault("Recipe.Enabled", true); config.addDefault("Recipe.Top", " "); config.addDefault("Recipe.Middle", " N "); config.addDefault("Recipe.Bottom", " "); Map<String, String> recipeMaterials = new HashMap<>(); recipeMaterials.put("N", Material.NETHER_STAR.name()); config.addDefault("Recipe.Materials", recipeMaterials); config.addDefault("OverrideLanguagesystem", false); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.NETHER_STAR); this.slotCost = 0; this.gain = config.getInt("ExtraModifierGain", 1); this.description = this.description.replace("%amount", String.valueOf(this.gain)); }
Example 11
Source File: Shrouded.java From MineTinker with 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", "%DARK_GREEN%"); config.addDefault("MaxLevel", 2); config.addDefault("RadiusPerLevel", 1.5); config.addDefault("SlotCost", 1); config.addDefault("Duration", 120); //ticks INTEGER (20 ticks ~ 1 sec) config.addDefault("DurationMultiplier", 1.1); //Duration * (Multiplier^Level) DOUBLE config.addDefault("EnchantCost", 10); config.addDefault("Enchantable", false); config.addDefault("Recipe.Enabled", true); config.addDefault("Recipe.Top", " D "); config.addDefault("Recipe.Middle", "DTD"); config.addDefault("Recipe.Bottom", " D "); Map<String, String> recipeMaterials = new HashMap<>(); recipeMaterials.put("T", Material.TNT.name()); recipeMaterials.put("D", Material.DRAGON_BREATH.name()); config.addDefault("Recipe.Materials", recipeMaterials); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.DRAGON_BREATH); this.duration = config.getInt("Duration", 120); this.durationMultiplier = config.getDouble("DurationMultiplier", 1.1); this.radiusPerLevel = config.getDouble("RadiusPerLevel", 1.0); this.description = this.description.replace("%durationmin", String.valueOf(this.duration / 20)) .replace("%durationmax", String.valueOf(Math.round(this.duration * Math.pow(this.durationMultiplier, getMaxLvl() - 1) * 5) / 100.0)); }
Example 12
Source File: Glowing.java From MineTinker with 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", "%YELLOW%"); config.addDefault("MaxLevel", 3); config.addDefault("SlotCost", 1); config.addDefault("Duration", 200); //ticks INTEGER (20 ticks ~ 1 sec) config.addDefault("DurationMultiplier", 1.4); //Duration * (Multiplier^Level) DOUBLE config.addDefault("EnchantCost", 10); config.addDefault("Enchantable", false); config.addDefault("Recipe.Enabled", true); config.addDefault("Recipe.Top", "GGG"); config.addDefault("Recipe.Middle", "GEG"); config.addDefault("Recipe.Bottom", "GGG"); Map<String, String> recipeMaterials = new HashMap<>(); recipeMaterials.put("G", Material.GLOWSTONE_DUST.name()); recipeMaterials.put("E", Material.ENDER_EYE.name()); config.addDefault("Recipe.Materials", recipeMaterials); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.GLOWSTONE); this.duration = config.getInt("Duration", 200); this.durationMultiplier = config.getDouble("DurationMultiplier", 1.4); this.description = this.description.replaceAll("%durationmin", String.valueOf(this.duration / 20.0d)) .replaceAll("%durationmax", String.valueOf(Math.round(this.duration * Math.pow(this.durationMultiplier, this.getMaxLvl() - 1)) / 20.0d)); }
Example 13
Source File: Directing.java From MineTinker with 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("MaxLevel", 1); config.addDefault("SlotCost", 1); config.addDefault("WorksOnXP", true); config.addDefault("MinimumLevelToGetXP", 1); //Modifier-Level to give Player XP config.addDefault("WorkInPVP", true); config.addDefault("Color", "%GRAY%"); config.addDefault("EnchantCost", 10); config.addDefault("Enchantable", false); config.addDefault("Recipe.Enabled", true); config.addDefault("Recipe.Top", "ECE"); config.addDefault("Recipe.Middle", "CIC"); config.addDefault("Recipe.Bottom", "ECE"); Map<String, String> recipeMaterials = new HashMap<>(); recipeMaterials.put("C", Material.COMPASS.name()); recipeMaterials.put("E", Material.ENDER_PEARL.name()); recipeMaterials.put("I", Material.IRON_BLOCK.name()); config.addDefault("Recipe.Materials", recipeMaterials); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.COMPASS); this.workInPVP = config.getBoolean("WorkInPVP", true); this.workOnXP = config.getBoolean("WorksOnXP", true); this.minimumLevelForXP = config.getInt("MinimumLevelToGetXP", 1); }
Example 14
Source File: MapManagerPlugin.java From MapManager with MIT License | 5 votes |
void reload() { FileConfiguration config = getConfig(); ALLOW_VANILLA = config.getBoolean("allowVanilla", ALLOW_VANILLA); FORCED_OFFSET = config.getInt("forcedOffset", FORCED_OFFSET); CHECK_DUPLICATES = config.getBoolean("checkDuplicates", CHECK_DUPLICATES); CACHE_DATA = getConfig().getBoolean("cacheData", CACHE_DATA); Sender.DELAY = getConfig().getInt("sender.delay", Sender.DELAY); Sender.AMOUNT = getConfig().getInt("sender.amount", Sender.AMOUNT); Sender.ALLOW_QUEUE_BYPASS = getConfig().getBoolean("sender.allowQueueBypass", Sender.ALLOW_QUEUE_BYPASS); }
Example 15
Source File: PlayerStatsSession.java From Survival-Games with GNU General Public License v3.0 | 5 votes |
public void calcPoints(){ FileConfiguration c = SettingsManager.getInstance().getConfig(); int kpoints = kills * c.getInt("stats.points.kill"); int ppoints = pppoints * c.getInt("stats.points.position"); int kspoints = ksbon; points = kpoints + ppoints + kspoints + ksbon; //System.out.println(player+" "+kpoints +" "+ppoints+" "+kspoints); if(position == 1){ points = points + c.getInt("stats.points.win"); } }
Example 16
Source File: ProjectileSpleefEvent.java From SkyWarsReloaded with 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 17
Source File: Timber.java From MineTinker with 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("MaxLevel", 1); config.addDefault("SlotCost", 2); config.addDefault("Color", "%GREEN%"); config.addDefault("MaximumBlocksPerSwing", 2000); //-1 to disable it config.addDefault("EnchantCost", 10); config.addDefault("Enchantable", false); config.addDefault("Recipe.Enabled", true); config.addDefault("Recipe.Top", "LLL"); config.addDefault("Recipe.Middle", "LEL"); config.addDefault("Recipe.Bottom", "LLL"); Map<String, String> recipeMaterials = new HashMap<>(); recipeMaterials.put("L", Material.OAK_WOOD.name()); recipeMaterials.put("E", Material.EMERALD.name()); config.addDefault("Recipe.Materials", recipeMaterials); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.EMERALD); this.maxBlocks = config.getInt("MaximumBlocksPerSwing", 2000); this.maxBlocks = (this.maxBlocks == -1) ? Integer.MAX_VALUE : this.maxBlocks; }
Example 18
Source File: LevelManager.java From SkyWarsReloaded with GNU General Public License v3.0 | 4 votes |
public void loadWinSounds() { winSoundList.clear(); File soundFile = new File(SkyWarsReloaded.get().getDataFolder(), "winsounds.yml"); if (!soundFile.exists()) { if (SkyWarsReloaded.getNMS().getVersion() < 9) { SkyWarsReloaded.get().saveResource("winsounds18.yml", false); File sf = new File(SkyWarsReloaded.get().getDataFolder(), "winsounds18.yml"); if (sf.exists()) { sf.renameTo(new File(SkyWarsReloaded.get().getDataFolder(), "winsounds.yml")); } } else { SkyWarsReloaded.get().saveResource("winsounds.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) { winSoundList.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 winsounds.yml"); } } else { winSoundList.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 winsounds.yml"); } } } } Collections.<SoundItem>sort(winSoundList); }
Example 19
Source File: ResourceManagerRegionImpl.java From NovaGuilds with GNU General Public License v3.0 | 4 votes |
@Override public List<NovaRegion> load() { final List<NovaRegion> list = new ArrayList<>(); for(File regionFile : getFiles()) { FileConfiguration configuration = loadConfiguration(regionFile); String guildString = configuration.getString("name"); String[] homeSplit = StringUtils.split(configuration.getString("center"), ','); String worldString = homeSplit[0]; World world = plugin.getServer().getWorld(worldString); if(world == null) { LoggerUtils.info("Failed loading region for guild " + guildString + ", world does not exist."); continue; } int x = Integer.parseInt(homeSplit[1]); int y = Integer.parseInt(homeSplit[2]); int z = Integer.parseInt(homeSplit[3]); Location center = new Location(world, x, y, z); NovaGuild guild = ((YamlStorageImpl) getStorage()).guildMap.get(guildString); if(guild == null) { LoggerUtils.error("There's no guild matching region " + guildString); continue; } NovaRegion region = new NovaRegionImpl(UUID.randomUUID()); int size = configuration.getInt("size"); Location corner1 = center.clone().add(size, 0, size); Location corner2 = center.clone().subtract(size, 0, size); region.setAdded(); region.setCorner(0, corner1); region.setCorner(1, corner2); region.setWorld(center.getWorld()); guild.addRegion(region); region.setUnchanged(); list.add(region); } return list; }
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"); }