org.bukkit.configuration.file.FileConfiguration Java Examples

The following examples show how to use org.bukkit.configuration.file.FileConfiguration. 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: Language.java    From iDisguise with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
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 #2
Source File: ListenerTeleport.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
@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 #3
Source File: WinSoundOption.java    From SkyWarsReloaded with GNU General Public License v3.0 6 votes vote down vote up
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 #4
Source File: ListenerLegacyItemPickup.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
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 #5
Source File: GovernmentManager.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
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 #6
Source File: ConfigLoader.java    From StackMob-3 with GNU General Public License v3.0 6 votes vote down vote up
@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 #7
Source File: ListenerPunishChecks.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
@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 #8
Source File: RegionsTests.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
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 #9
Source File: DatabaseConfig.java    From NametagEdit with GNU General Public License v3.0 6 votes vote down vote up
@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 #10
Source File: ConfigBuff.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
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 #11
Source File: TownManager.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
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 File: ListenerEssentials.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
@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 #13
Source File: ProjectileEffectOption.java    From SkyWarsReloaded with GNU General Public License v3.0 6 votes vote down vote up
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 #14
Source File: Beheading.java    From MineTinker with GNU General Public License v3.0 6 votes vote down vote up
@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 #15
Source File: SlimefunLocalization.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
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 #16
Source File: ConfigUnit.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
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 #17
Source File: CrazyAuctions.java    From Crazy-Auctions with MIT License 6 votes vote down vote up
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 #18
Source File: GroupManager.java    From PerWorldInventory with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #19
Source File: ListenerCommandBlocker.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private void addCooldown(Player player) {
    if(player == null) return;

    FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
    long cooldownSeconds = config.getLong("command-blocker.delay-after-combat");
    if(cooldownSeconds <= 0) return;

    long cooldownMillis = TimeUnit.SECONDS.toMillis(cooldownSeconds);
    long systemTime = System.currentTimeMillis();
    long expireTime = (systemTime + cooldownMillis);

    UUID uuid = player.getUniqueId();
    cooldownMap.put(uuid, expireTime);
}
 
Example #20
Source File: ResourceManagerPlayerImpl.java    From NovaGuilds with GNU General Public License v3.0 5 votes vote down vote up
@Override
	public List<NovaPlayer> load() {
		final List<NovaPlayer> list = new ArrayList<>();

		for(File playerFile : getFiles()) {
			if(!playerFile.isFile()) {
				continue;
			}

			FileConfiguration configuration = loadConfiguration(playerFile);

			if(configuration != null) {
//				LoggerUtils.debug(playerFile.getName());
				NovaPlayer nPlayer = new NovaPlayerImpl(UUID.fromString(configuration.getString("uuid")));
				nPlayer.setAdded();
				nPlayer.setName(configuration.getString("name"));

//				List<String> invitedToStringList = configuration.getStringList("invitedto");
//				List<NovaGuild> invitedToList = new UUIDOrNameToGuildConverterImpl().convert(invitedToStringList);

//				nPlayer.setInvitedTo(invitedToList);
				nPlayer.setPoints(configuration.getInt("points"));
				nPlayer.setKills(configuration.getInt("kills"));
				nPlayer.setDeaths(configuration.getInt("deaths"));

				//Set the guild
				NovaGuild guild = ((YamlStorageImpl) getStorage()).playerGuildMap.get(nPlayer.getName());

				if(guild != null) {
					guild.addPlayer(nPlayer);
				}

				nPlayer.setUnchanged();
				list.add(nPlayer);
			}
		}

		return list;
	}
 
Example #21
Source File: ConfigTechPotion.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public static void loadConfig(FileConfiguration cfg, Map<Integer, ConfigTechPotion> techPotions) {
	techPotions.clear();
	List<Map<?, ?>> techs = cfg.getMapList("potions");
	for (Map<?, ?> confTech : techs) {
		ConfigTechPotion tech = new ConfigTechPotion();
		
		tech.name = (String)confTech.get("name");
		tech.data = (Integer)confTech.get("data");
		tech.require_tech = (String)confTech.get("require_tech");			
		techPotions.put(Integer.valueOf(tech.data), tech);
	}
	CivLog.info("Loaded "+techPotions.size()+" tech potions.");		
}
 
Example #22
Source File: CombatLogX.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void printDebug(String message) {
    if(message == null || message.isEmpty()) return;
    
    FileConfiguration config = getConfig("config.yml");
    if(!config.getBoolean("debug")) return;
    
    Logger logger = getLogger();
    logger.info("[Debug] " + message);
}
 
Example #23
Source File: ConfigHelper.java    From Hawk with GNU General Public License v3.0 5 votes vote down vote up
public static List<String> getOrSetDefault(List<String> defaultValue, FileConfiguration config, String path) {
    List<String> result;
    if (config.isSet(path)) {
        result = config.getStringList(path);
    } else {
        result = defaultValue;
        config.set(path, defaultValue);
    }
    return result;
}
 
Example #24
Source File: ChallengeCompletionLogic.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
private void saveToConfiguration(FileConfiguration configuration, Map<String, ChallengeCompletion> map) {
    for (Map.Entry<String, ChallengeCompletion> entry : map.entrySet()) {
        String challengeName = entry.getKey();
        ChallengeCompletion completion = entry.getValue();
        ConfigurationSection section = configuration.createSection(challengeName);
        section.set("firstCompleted", completion.getCooldownUntil());
        section.set("timesCompleted", completion.getTimesCompleted());
        section.set("timesCompletedSinceTimer", completion.getTimesCompletedInCooldown());
    }
}
 
Example #25
Source File: HelpTranslationGeneratorIntegrationTest.java    From AuthMeReloaded with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void shouldUpdateCurrentHelpFile() throws IOException {
    // given / when
    helpTranslationGenerator.updateHelpFile();

    // then
    FileConfiguration configuration = YamlConfiguration.loadConfiguration(helpMessagesFile);
    checkCommonEntries(configuration);
    checkSections(configuration);
    checkCommands(configuration);
}
 
Example #26
Source File: CondYamlExists.java    From skUtilities with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean check(Event e) {
  File pth = new File(skUtilities.getDefaultPath(path.getSingle(e)));
  FileConfiguration con = YamlConfiguration.loadConfiguration(pth);
  Boolean v = con.contains(yaml.getSingle(e));
  return (isNegated() ? !v : v);
}
 
Example #27
Source File: RegionsTests.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
public static void loadRegionTypeUtility() {
    FileConfiguration config = new YamlConfiguration();
    ArrayList<String> reqs = new ArrayList<>();
    config.set("build-reqs", reqs);
    ArrayList<String> effects = new ArrayList<>();
    config.set("effects", effects);
    config.set("build-radius", 5);
    config.set("upkeep.0.power-output", 96);
    ItemManager.getInstance().loadRegionType(config, "utility");
}
 
Example #28
Source File: Sunblazer.java    From MineTinker with GNU General Public License v3.0 5 votes vote down vote up
@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("DamageMultiplierPerLevel", 0.1);

	config.addDefault("EnchantCost", 10);
	config.addDefault("Enchantable", false);

	config.addDefault("Recipe.Enabled", true);
	config.addDefault("Recipe.Top", "GIG");
	config.addDefault("Recipe.Middle", "IDI");
	config.addDefault("Recipe.Bottom", "GIG");

	Map<String, String> recipeMaterials = new HashMap<>();
	recipeMaterials.put("G", Material.GOLD_BLOCK.name());
	recipeMaterials.put("D", Material.DAYLIGHT_DETECTOR.name());
	recipeMaterials.put("I", Material.GOLD_INGOT.name());

	config.addDefault("Recipe.Materials", recipeMaterials);

	ConfigurationManager.saveConfig(config);
	ConfigurationManager.loadConfig("Modifiers" + File.separator, getFileName());

	init(Material.DAYLIGHT_DETECTOR);
	this.damageMultiplierPerLevel = config.getDouble("DamageMultiplierPerLevel", 0.1);

	this.description = this.description
			.replaceAll("%amountmin", String.format("%.2f", (Math.pow(this.damageMultiplierPerLevel + 1.0, 1) - 1) * 100))
			.replaceAll("%amountmax", String.format("%.2f", (Math.pow(this.damageMultiplierPerLevel + 1.0, this.getMaxLvl()) - 1) * 100));
}
 
Example #29
Source File: EnderDragonEvent.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
@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 #30
Source File: EntityAPICore.java    From EntityAPI with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public FileConfiguration getConfig(ConfigType type) {
    switch (type) {
        default:
            return this.getConfig();
    }
}