Java Code Examples for org.bukkit.configuration.file.FileConfiguration#getDouble()
The following examples show how to use
org.bukkit.configuration.file.FileConfiguration#getDouble() .
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: LevelConfigYmlReader.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
public BlockLevelConfigMap readLevelConfig(FileConfiguration config) { double defaultScore = config.getDouble("general.default", 10d); int defaultLimit = config.getInt("general.limit", Integer.MAX_VALUE); int defaultDiminishingReturns = config.getInt("general.diminishingReturns", 0); BlockLevelConfigBuilder defaultBuilder = new BlockLevelConfigBuilder() .scorePerBlock(defaultScore) .limit(defaultLimit) .diminishingReturns(defaultDiminishingReturns); List<BlockLevelConfig> blocks = new ArrayList<>(); addDefaults(blocks, defaultBuilder); ConfigurationSection section = config.getConfigurationSection("blocks"); if (section != null) { for (String key : section.getKeys(false)) { if (section.isConfigurationSection(key)) { BlockLevelConfig blockConfig = readBlockSection(section.getConfigurationSection(key), getBlockMatch(key), defaultBuilder); blocks.add(blockConfig); } } } return new BlockLevelConfigMap(blocks, defaultBuilder); }
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 | 5 votes |
public TownType loadTownType(FileConfiguration config, String name) throws NullPointerException { CVItem icon = CVItem.createCVItemFromString(config.getString("icon", Material.STONE.name())); HashMap<String, String> effects = new HashMap<>(); List<String> configEffects = config.getStringList("effects"); for (String effectString : configEffects) { if (effectString.contains(":")) { String[] effectSplit = effectString.split(":"); effects.put(effectSplit[0], effectSplit[1]); } else { effects.put(effectString, null); } } int buildRadius = config.getInt("build-radius", 20); TownType townType = new TownType( name, icon, CVItem.createCVItemFromString(config.getString("shop-icon", config.getString("icon", Material.CHEST.name()))), config.getStringList("pre-reqs"), config.getInt("qty", 0), config.getInt("min",0), config.getInt("max", -1), config.getDouble("price", 0), config.getString("permission"), convertListToMap(config.getStringList("build-reqs")), convertListToMap(config.getStringList("limits")), effects, buildRadius, config.getInt("build-radius-y", buildRadius), config.getStringList("critical-build-reqs"), config.getInt("power", 200), config.getInt("max-power", 1000), config.getStringList("groups"), config.getString("child"), config.getInt("child-population", 0), config.getBoolean("is-in-shop", true), config.getInt("level", 1)); townType.setDefaultGovType(config.getString("gov-type", ConfigManager.getInstance().getDefaultGovernmentType())); itemTypes.put(Util.getValidFileName(name).toLowerCase(), townType); return townType; }
Example 4
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 5
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 6
Source File: Speedy.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", "%BLUE%"); config.addDefault("MaxLevel", 5); config.addDefault("SlotCost", 1); config.addDefault("SpeedPerLevel", 0.01); config.addDefault("EnchantCost", 10); config.addDefault("Enchantable", false); config.addDefault("Recipe.Enabled", true); config.addDefault("Recipe.Top", "R R"); config.addDefault("Recipe.Middle", " H "); config.addDefault("Recipe.Bottom", "R R"); Map<String, String> recipeMaterials = new HashMap<>(); recipeMaterials.put("H", Material.RABBIT_HIDE.name()); recipeMaterials.put("R", Material.RABBIT_FOOT.name()); config.addDefault("Recipe.Materials", recipeMaterials); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); this.speedPerLevel = config.getDouble("SpeedPerLevel"); init(Material.RABBIT_HIDE); this.description = this.description.replace("%amount", String.valueOf(this.speedPerLevel * 100)); }
Example 7
Source File: Melting.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", "%GOLD%"); config.addDefault("MaxLevel", 3); config.addDefault("SlotCost", 1); config.addDefault("BonusMultiplier", 0.1); //Percent of Bonus-damage per Level or Damage-reduction on Armor config.addDefault("CancelBurningOnArmor", true); config.addDefault("EnchantCost", 10); config.addDefault("Enchantable", true); config.addDefault("Recipe.Enabled", false); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.MAGMA_BLOCK); this.bonusMultiplier = config.getDouble("BonusMultiplier", 0.1); this.cancelBurning = config.getBoolean("CancelBurningOnArmor", true); this.description = this.description.replaceAll("%amount", String.valueOf(this.bonusMultiplier * 100)); }
Example 8
Source File: CivSettings.java From civcraft with GNU General Public License v2.0 | 5 votes |
public static double getDouble(FileConfiguration cfg, String path) throws InvalidConfiguration { if (!cfg.contains(path)) { throw new InvalidConfiguration("Could not get configuration double "+path); } double data = cfg.getDouble(path); return data; }
Example 9
Source File: ConfigHelper.java From Hawk with GNU General Public License v3.0 | 5 votes |
public static double getOrSetDefault(double defaultValue, FileConfiguration config, String path) { double result; if (config.isSet(path)) { result = config.getDouble(path); } else { result = defaultValue; config.set(path, defaultValue); } return result; }
Example 10
Source File: Kit.java From Survival-Games with GNU General Public License v3.0 | 5 votes |
public void load(){ FileConfiguration c = SettingsManager.getInstance().getKits(); cost = c.getDouble("kits."+name+".cost", 0); icon = ItemReader.read(c.getString("kits."+name+".icon")); SurvivalGames.debug("[Kits] loading: " + icon); List<String>cont = c.getStringList("kits."+name+".contents"); for(String s:cont){ items.add(ItemReader.read(s)); } }
Example 11
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 12
Source File: SpawnLoader.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
/** * Build a {@link Location} object from the given path in the file configuration. * * @param configuration The file configuration to read from * @param pathPrefix The path to get the spawn point from * * @return Location corresponding to the values in the path */ private static Location getLocationFromConfiguration(FileConfiguration configuration, String pathPrefix) { if (containsAllSpawnFields(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 13
Source File: Propelling.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", "%GOLD%"); config.addDefault("MaxLevel", 3); config.addDefault("SlotCost", 1); config.addDefault("CooldownInSeconds", 5); config.addDefault("Elytra.DurabilityLoss", 10); config.addDefault("Elytra.SpeedPerLevel", 0.05); config.addDefault("Elytra.Sound", true); config.addDefault("Elytra.Particles", true); config.addDefault("ConsiderReinforced", true); //should Reinforced (Unbreaking) be considered config.addDefault("ReinforcedUseLessDurability", true); //should Reinforced lessen the durability damage or if false chance to dont use durability at all config.addDefault("EnchantCost", 25); config.addDefault("Enchantable", true); config.addDefault("Recipe.Enabled", false); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.FIREWORK_STAR); this.durabilityLoss = config.getInt("Elytra.DurabilityLoss", 10); this.speedPerLevel = config.getDouble("Elytra.SpeedPerLevel", 0.05); this.considerReinforced = config.getBoolean("ConsiderReinforced", true); this.useLessDurability = config.getBoolean("ReinforcedUseLessDurability", true); this.cooldownInSeconds = config.getInt("CooldownInSeconds", 5); this.sound = config.getBoolean("Elytra.Sound", true); this.particles = config.getBoolean("Elytra.Particles", true); }
Example 14
Source File: LevelManager.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
private void loadTaunts() { tauntList.clear(); File tauntFile = new File(SkyWarsReloaded.get().getDataFolder(), "taunts.yml"); if (!tauntFile.exists()) { if (SkyWarsReloaded.getNMS().getVersion() < 9) { SkyWarsReloaded.get().saveResource("taunts18.yml", false); File sf = new File(SkyWarsReloaded.get().getDataFolder(), "taunts18.yml"); if (sf.exists()) { sf.renameTo(new File(SkyWarsReloaded.get().getDataFolder(), "taunts.yml")); } } else { SkyWarsReloaded.get().saveResource("taunts.yml", false); } } if (tauntFile.exists()) { FileConfiguration storage = YamlConfiguration.loadConfiguration(tauntFile); if (storage.getConfigurationSection("taunts") != null) { for (String key: storage.getConfigurationSection("taunts").getKeys(false)) { String name = storage.getString("taunts." + key + ".name"); List<String> lore = storage.getStringList("taunts." + key + ".lore"); int level = storage.getInt("taunts." + key + ".level"); int cost = storage.getInt("taunts." + key + ".cost"); String message = storage.getString("taunts." + key + ".message"); String sound = storage.getString("taunts." + key + ".sound"); boolean useCustomSound = storage.getBoolean("taunts." + key + ".useCustomSound", false); double volume = storage.getDouble("taunts." + key + ".volume"); double pitch = storage.getDouble("taunts." + key + ".pitch"); double speed = storage.getDouble("taunts." + key + ".particleSpeed"); int density = storage.getInt("taunts." + key + ".particleDensity"); List<String> particles = storage.getStringList("taunts." + key + ".particles"); Material icon = Material.valueOf(storage.getString("taunts." + key + ".icon", "DIAMOND")); tauntList.add(new Taunt(key, name, lore, message, sound, useCustomSound, volume, pitch, speed, density, particles, icon, level, cost)); } } } Collections.<Taunt>sort(tauntList); }
Example 15
Source File: GunYMLLoader.java From QualityArmory with GNU General Public License v3.0 | 4 votes |
public static void loadMisc(QAMain main) { if (new File(main.getDataFolder(), "misc").exists()) { int items = 0; for (File f : new File(main.getDataFolder(), "misc").listFiles()) { try { 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 Misc: " + 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); final ItemStack[] materails = main .convertIngredients(f2.getStringList("craftingRequirements")); final String displayname = f2.contains("displayname") ? ChatColor.translateAlternateColorCodes('&', f2.getString("displayname")) : (ChatColor.WHITE + name); final List<String> rawLore = f2.contains("lore") ? f2.getStringList("lore") : null; final List<String> lore = new ArrayList<String>(); try { for (String lore2 : rawLore) { lore.add(ChatColor.translateAlternateColorCodes('&', lore2)); } } catch (Error | Exception re52) { } final int price = f2.contains("price") ? f2.getInt("price") : 100; int damage = f2.contains("damage") ? f2.getInt("damage") : 1; // int durib = f2.contains("durability") ? f2.getInt("durability") : 1000; WeaponType wt = WeaponType.getByName(f2.getString("MiscType")); double radius = f2.contains("radius") ? f2.getDouble("radius") : 0; items++; CustomBaseObject base = null; String soundEquip = f2.contains("sound_equip")? f2.getString("sound_equip"):null; String soundHit = f2.contains("sound_meleehit")? f2.getString("sound_meleehit"):null; if (wt == WeaponType.MEDKIT) QAMain.miscRegister.put(ms, base=new MedKit(ms, name, displayname, materails, price)); if (wt == WeaponType.MELEE) { QAMain.miscRegister.put(ms, base = new MeleeItems(ms, name, displayname, materails, price, damage)); base.setSoundOnEquip(soundEquip); base.setSoundOnHit(soundHit); base.setCustomLore(lore); } if (wt == WeaponType.GRENADES) QAMain.miscRegister.put(ms, base=new Grenade(materails, price, damage, radius, name, displayname, lore, ms)); if (wt == WeaponType.SMOKE_GRENADES) QAMain.miscRegister.put(ms, base=new SmokeGrenades(materails, price, damage, radius, name, displayname, lore, ms)); if (wt == WeaponType.INCENDARY_GRENADES) QAMain.miscRegister.put(ms, base=new IncendaryGrenades(materails, price, damage, radius, name, displayname, lore, ms)); if (wt == WeaponType.FLASHBANGS) QAMain.miscRegister.put(ms, base=new Flashbang(materails, price, damage, radius, name, displayname, lore, ms)); if(base!=null) { base.setCustomLore(lore); base.setIngredients(materails); } } } } catch (Exception e) { e.printStackTrace(); } } if(!QAMain.verboseLoadingLogging) main.getLogger().info("-Loaded "+items+" Misc."); } }
Example 16
Source File: GunYMLLoader.java From QualityArmory with GNU General Public License v3.0 | 4 votes |
public static void loadAmmo(QAMain main) { if (new File(main.getDataFolder(), "ammo").exists()) { int items = 0; for (File f : new File(main.getDataFolder(), "ammo").listFiles()) { try { if (f.getName().contains("yml")) { FileConfiguration f2 = YamlConfiguration.loadConfiguration(f); if ((!f2.contains("invalid")) || !f2.getBoolean("invalid")) { Material m = f2.contains("material") ? Material.matchMaterial(f2.getString("material")) : Material.DIAMOND_AXE; int variant = f2.contains("variant") ? f2.getInt("variant") : 0; final String name = f2.getString("name"); if(QAMain.verboseLoadingLogging) main.getLogger().info("-Loading AmmoType: " + name); String extraData = null; if (f2.contains("skull_owner")) { extraData = f2.getString("skull_owner"); } String ed2 = null; if (f2.contains("skull_owner_custom_url") && !f2.getString("skull_owner_custom_url").equals(Ammo.NO_SKIN_STRING)) { ed2 = f2.getString("skull_owner_custom_url"); } final MaterialStorage ms = MaterialStorage.getMS(m, f2.getInt("id"), variant, extraData, ed2); final ItemStack[] materails = main .convertIngredients(f2.getStringList("craftingRequirements")); final String displayname = f2.contains("displayname") ? ChatColor.translateAlternateColorCodes('&', f2.getString("displayname")) : (ChatColor.WHITE + 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) { } final double price = f2.contains("price") ? f2.getDouble("price") : 100; int amountA = f2.getInt("maxAmount"); double piercing = f2.getDouble("piercingSeverity"); Ammo da = new Ammo(name, displayname, extraLore, ms, amountA, false, 1, price, materails, piercing); da.setCustomLore(extraLore); QAMain.ammoRegister.put(ms, da); items++; if (extraData != null) { da.setSkullOwner(extraData); } if (ed2 != null) { da.setCustomSkin(ed2); } if (f2.contains("craftingReturnAmount")) { da.setCraftingReturn(f2.getInt("craftingReturnAmount")); } } } } catch (Exception e) { e.printStackTrace(); } } if(!QAMain.verboseLoadingLogging) main.getLogger().info("-Loaded "+items+" Ammo types."); } }
Example 17
Source File: Webbed.java From MineTinker with GNU General Public License v3.0 | 4 votes |
@Override public void reload() { FileConfiguration config = getConfig(); config.options().copyDefaults(true); config.addDefault("Allowed", true); config.addDefault("Color", "%WHITE%"); config.addDefault("MaxLevel", 3); config.addDefault("SlotCost", 1); config.addDefault("Duration", 60); //ticks (20 ticks ~ 1 sec) config.addDefault("DurationMultiplier", 1.2);//Duration * (Multiplier^Level) config.addDefault("EffectAmplifier", 2); //per Level (Level 1 = 0, Level 2 = 2, Level 3 = 4, ...) config.addDefault("GivesImmunityToEffect", true); config.addDefault("EnchantCost", 10); config.addDefault("Enchantable", false); config.addDefault("Recipe.Enabled", true); config.addDefault("Recipe.Top", "WWW"); config.addDefault("Recipe.Middle", "WBW"); config.addDefault("Recipe.Bottom", "WWW"); Map<String, String> recipeMaterials = new HashMap<>(); recipeMaterials.put("W", Material.COBWEB.name()); recipeMaterials.put("B", Material.BLUE_ICE.name()); config.addDefault("Recipe.Materials", recipeMaterials); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.COBWEB); this.duration = config.getInt("Duration", 60); this.durationMultiplier = config.getDouble("DurationMultiplier", 1.2); this.effectAmplifier = config.getInt("EffectAmplifier", 2); this.givesImmunity = config.getBoolean("GivesImmunityToEffect", true); this.description = this.description.replace("%duration", String.valueOf(this.duration)) .replace("%multiplier", String.valueOf(this.durationMultiplier)); }
Example 18
Source File: Magical.java From MineTinker with GNU General Public License v3.0 | 4 votes |
@Override public void reload() { FileConfiguration config = getConfig(); config.options().copyDefaults(true); config.addDefault("Allowed", true); config.addDefault("Color", "%DARK_PURPLE%"); config.addDefault("MaxLevel", 5); config.addDefault("SlotCost", 1); config.addDefault("MultiplierArrowSpeed", 0.3); config.addDefault("MultiplierArrowDamagePerLevel", 1.25); config.addDefault("ExperienceCost", 3); config.addDefault("HasKnockback", true); config.addDefault("EnchantCost", 10); config.addDefault("Enchantable", false); config.addDefault("Recipe.Enabled", true); //TODO: Change config.addDefault("Recipe.Top", "BPB"); config.addDefault("Recipe.Middle", "PAP"); config.addDefault("Recipe.Bottom", "BPB"); Map<String, String> recipeMaterials = new HashMap<>(); recipeMaterials.put("B", Material.DRAGON_BREATH.name()); recipeMaterials.put("A", Material.ARROW.name()); recipeMaterials.put("P", Material.BLAZE_POWDER.name()); config.addDefault("Recipe.Materials", recipeMaterials); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.ARROW); this.multiplierArrowSpeed = config.getDouble("MultiplierArrowSpeed", 0.3); this.multiplierDamagePerLevel = config.getDouble("MultiplierArrowDamagePerLevel", 1.25); this.experienceCost = config.getInt("ExperienceCost", 10); this.hasKnockback = config.getBoolean("HasKnockback", true); this.description = this.description.replace("%amount", String.valueOf(Math.round((1.0 - this.multiplierArrowSpeed) * 100))) .replace("%min", String.valueOf(Math.round((this.multiplierDamagePerLevel - 1.0) * 100))) .replace("%max", String.valueOf(Math.round((Math.pow(this.multiplierDamagePerLevel, this.getMaxLvl()) - 1.0) * 100))) .replace("%xp", String.valueOf(this.experienceCost)); }
Example 19
Source File: Evasive.java From MineTinker with GNU General Public License v3.0 | 4 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", 3); config.addDefault("PercentPerLevel", 10); config.addDefault("SneakMultiplier", 0.5); config.addDefault("SprintMultiplier", 2.0); config.addDefault("PvPMultiplier", 0.5); config.addDefault("CooldownInSeconds", 5); config.addDefault("Sound", true); config.addDefault("EnchantCost", 10); config.addDefault("Enchantable", false); config.addDefault("Recipe.Enabled", true); config.addDefault("Recipe.Top", "D D"); config.addDefault("Recipe.Middle", " F "); config.addDefault("Recipe.Bottom", "D D"); Map<String, String> recipeMaterials = new HashMap<>(); recipeMaterials.put("D", Material.DIAMOND.name()); recipeMaterials.put("F", Material.FEATHER.name()); config.addDefault("Recipe.Materials", recipeMaterials); ConfigurationManager.saveConfig(config); ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName()); init(Material.FEATHER); this.percentPerLevel = config.getInt("PercentPerLevel", 5); this.sneakMultiplier = config.getDouble("SneakMultiplier", 0.5); this.sprintMultiplier = config.getDouble("SprintMultiplier", 2.0); this.cooldownInSeconds = config.getInt("CooldownInSeconds", 5); this.pvpMultiplier = config.getDouble("PvPMultiplier", 1.0); this.description = this.description.replaceAll("%chance", String.valueOf(this.percentPerLevel)) .replaceAll("%sneak", String.valueOf(this.sneakMultiplier)) .replaceAll("%sprint", String.valueOf(this.sprintMultiplier)) .replaceAll("%pvp", String.valueOf(this.pvpMultiplier)); }
Example 20
Source File: SentinelTrait.java From Sentinel with MIT License | 4 votes |
/** * Called when the Sentinel trait is attached to the NPC - fills all default values from config. */ @Override public void onAttach() { FileConfiguration config = SentinelPlugin.instance.getConfig(); attackRate = config.getInt("sentinel defaults.attack rate", 30); healRate = config.getInt("sentinel defaults.heal rate", 100); respawnTime = config.getInt("sentinel defaults.respawn time", 100); rangedChase = config.getBoolean("sentinel defaults.ranged chase target", false); closeChase = config.getBoolean("sentinel defaults.close chase target", true); armor = config.getDouble("sentinel defaults.armor", -1); damage = config.getDouble("sentinel defaults.damage", -1); health = config.getDouble("sentinel defaults.health", 20); if (npc.isSpawned()) { getLivingEntity().setMaxHealth(health); getLivingEntity().setHealth(health); } setInvincible(config.getBoolean("sentinel defaults.invincible", false)); fightback = config.getBoolean("sentinel defaults.fightback", true); needsAmmo = config.getBoolean("sentinel defaults.needs ammo", false); safeShot = config.getBoolean("sentinel defaults.safe shot", true); enemyDrops = config.getBoolean("sentinel defaults.enemy drops", false); enemyTargetTime = config.getInt("sentinel defaults.enemy target time", 0); speed = config.getInt("sentinel defaults.speed", 1); if (speed <= 0) { speed = 1; } autoswitch = config.getBoolean("sentinel defaults.autoswitch", false); allIgnores.targets.add(SentinelTarget.OWNER.name()); allIgnores.recalculateTargetsCache(); reach = config.getDouble("sentinel defaults.reach", 3); projectileRange = config.getDouble("sentinel defaults.projectile range", 100); avoidRange = config.getDouble("sentinel defaults.avoid range", 10); runaway = config.getBoolean("sentinel defaults.runaway", false); greetRange = config.getDouble("sentinel defaults.greet range", 10); greetRate = config.getInt("sentinel defaults.greet rate", 100); retainTarget = config.getBoolean("random.retain target", false); guardDistanceMinimum = SentinelPlugin.instance.guardDistanceMinimum; guardSelectionRange = SentinelPlugin.instance.guardDistanceSelectionRange; if (npc.isSpawned()) { SentinelPlugin.instance.currentSentinelNPCs.add(this); lastEntityUUID = getLivingEntity().getUniqueId(); } }