类org.bukkit.configuration.file.FileConfiguration源码实例Demo

下面列出了怎么用org.bukkit.configuration.file.FileConfiguration的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Civs   文件: RegionsTests.java
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");
}
 
源代码2 项目: CombatLogX   文件: ListenerLegacyItemPickup.java
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);
}
 
源代码3 项目: StackMob-3   文件: ConfigLoader.java
@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;
}
 
源代码4 项目: CombatLogX   文件: ListenerEssentials.java
@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);
}
 
源代码5 项目: MineTinker   文件: Beheading.java
@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));
}
 
源代码6 项目: Crazy-Auctions   文件: CrazyAuctions.java
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;
}
 
源代码7 项目: PerWorldInventory   文件: GroupManager.java
/**
 * 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);
    }
}
 
源代码8 项目: civcraft   文件: ConfigUnit.java
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.");
}
 
源代码9 项目: Slimefun4   文件: SlimefunLocalization.java
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);
    });
}
 
源代码10 项目: SkyWarsReloaded   文件: ProjectileEffectOption.java
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();
	}
}
 
源代码11 项目: Civs   文件: TownManager.java
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!");
    }
}
 
源代码12 项目: civcraft   文件: ConfigBuff.java
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.");
}
 
源代码13 项目: NametagEdit   文件: DatabaseConfig.java
@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);
}
 
源代码14 项目: SkyWarsReloaded   文件: WinSoundOption.java
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();
	}
}
 
源代码15 项目: CombatLogX   文件: ListenerTeleport.java
@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);
}
 
源代码16 项目: Civs   文件: GovernmentManager.java
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);
}
 
源代码17 项目: CombatLogX   文件: ListenerPunishChecks.java
@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;
    }
}
 
源代码18 项目: iDisguise   文件: Language.java
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);
	}
}
 
源代码19 项目: Crazy-Auctions   文件: GUI.java
public static void openCategories(Player player, ShopType shop) {
    Methods.updateAuction();
    FileConfiguration config = Files.CONFIG.getFile();
    Inventory inv = Bukkit.createInventory(null, 54, Methods.color(config.getString("Settings.Categories")));
    List<String> options = new ArrayList<>();
    options.add("OtherSettings.Back");
    options.add("OtherSettings.WhatIsThis.Categories");
    options.add("Category-Settings.Armor");
    options.add("Category-Settings.Weapons");
    options.add("Category-Settings.Tools");
    options.add("Category-Settings.Food");
    options.add("Category-Settings.Potions");
    options.add("Category-Settings.Blocks");
    options.add("Category-Settings.Other");
    options.add("Category-Settings.None");
    for (String o : options) {
        if (config.contains("Settings.GUISettings." + o + ".Toggle")) {
            if (!config.getBoolean("Settings.GUISettings." + o + ".Toggle")) {
                continue;
            }
        }
        String id = config.getString("Settings.GUISettings." + o + ".Item");
        String name = config.getString("Settings.GUISettings." + o + ".Name");
        int slot = config.getInt("Settings.GUISettings." + o + ".Slot");
        if (config.contains("Settings.GUISettings." + o + ".Lore")) {
            inv.setItem(slot - 1, Methods.makeItem(id, 1, name, config.getStringList("Settings.GUISettings." + o + ".Lore")));
        } else {
            inv.setItem(slot - 1, Methods.makeItem(id, 1, name));
        }
    }
    shopType.put(player, shop);
    player.openInventory(inv);
}
 
源代码20 项目: SkyWarsReloaded   文件: EnderDragonEvent.java
@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();
		}
    }
}
 
private static Plugin mockPlugin() {
    Plugin plugin = mock(Plugin.class);
    when(plugin.getName()).thenReturn(PLUGIN_NAME);

    Server server = mockServer();
    when(plugin.getServer()).thenReturn(server);

    FileConfiguration config = mockConfig();
    when(plugin.getConfig()).thenReturn(config);

    when(server.getPluginManager().getPlugin(PLUGIN_NAME)).thenReturn(plugin);
    return plugin;
}
 
源代码22 项目: CombatLogX   文件: ListenerBlocks.java
@EventHandler(priority=EventPriority.HIGH, ignoreCancelled=true)
public void onBlockPlace(BlockPlaceEvent e) {
    FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
    if(!config.getBoolean("blocks.prevent-placing")) return;

    Player player = e.getPlayer();
    ICombatManager combatManager = this.plugin.getCombatManager();
    if(!combatManager.isInCombat(player)) return;

    e.setCancelled(true);
    sendMessageWithCooldown(player, "cheat-prevention.blocks.no-placing");
}
 
源代码23 项目: Civs   文件: RegionsTests.java
public static void loadRegionTypeCobble2() {
    FileConfiguration config = new YamlConfiguration();
    ArrayList<String> reqs = new ArrayList<>();
    reqs.add("cobblestone*3");
    config.set("build-reqs", reqs);
    ArrayList<String> reagents = new ArrayList<>();
    reagents.add("IRON_PICKAXE");
    config.set("reagents", reagents);
    ArrayList<String> effects = new ArrayList<>();
    effects.add("block_place");
    effects.add("block_break");
    config.set("effects", effects);
    config.set("effect-radius", 7);
    ItemManager.getInstance().loadRegionType(config, "cobble");
}
 
源代码24 项目: SuperVanish   文件: ServerListPacketListener.java
public static boolean isEnabled(SuperVanish plugin) {
    final FileConfiguration config = plugin.getSettings();
    return config.getBoolean(
            "ExternalInvisibility.ServerList.AdjustAmountOfOnlinePlayers")
            || config.getBoolean(
            "ExternalInvisibility.ServerList.AdjustListOfLoggedInPlayers");
}
 
源代码25 项目: CombatLogX   文件: ListenerLegacyItemPickup.java
@EventHandler(priority= EventPriority.HIGH, ignoreCancelled=true)
public void onPickupItem(PlayerPickupItemEvent e) {
    FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
    if(!config.getBoolean("items.prevent-item-pickup")) return;

    Player player = e.getPlayer();
    ICombatManager combatManager = this.plugin.getCombatManager();
    if(!combatManager.isInCombat(player)) return;

    e.setCancelled(true);
    sendMessage(player);
}
 
源代码26 项目: Civs   文件: TownManager.java
private void saveRevolt(Town town, FileConfiguration config) {
    ArrayList<String> uuidList = new ArrayList<>();
    for (UUID uuid : town.getRevolt()) {
        uuidList.add(uuid.toString());
    }
    config.set("revolt", uuidList);
}
 
源代码27 项目: SkyWarsReloaded   文件: ShrinkingBorderEvent.java
public ShrinkingBorderEvent(GameMap map, boolean b) {
	this.gMap = map;
	this.enabled = b;
	File dataDirectory = SkyWarsReloaded.get().getDataFolder();
       File mapDataDirectory = new File(dataDirectory, "mapsData");

       if (!mapDataDirectory.exists() && !mapDataDirectory.mkdirs()) {
       	return;
       }
       
       File mapFile = new File(mapDataDirectory, gMap.getName() + ".yml");
    if (mapFile.exists()) {
    	eventName = "ShrinkingBorderEvent";
    	slot = 9;
    	material = new ItemStack(Material.BARRIER, 1);
        FileConfiguration fc = YamlConfiguration.loadConfiguration(mapFile);
        this.min = fc.getInt("events." + eventName + ".minStart");
        this.max = fc.getInt("events." + eventName + ".maxStart");
        this.length = fc.getInt("events." + eventName + ".length");
        this.chance = fc.getInt("events." + eventName + ".chance");
        this.title = fc.getString("events." + eventName + ".title");
        this.subtitle = fc.getString("events." + eventName + ".subtitle");
        this.startMessage = fc.getString("events." + eventName + ".startMessage");
        this.endMessage = fc.getString("events." + eventName + ".endMessage");
        this.announceEvent = fc.getBoolean("events." + eventName + ".announceTimer");
        this.repeatable = fc.getBoolean("events." + eventName + ".repeatable");
		this.borderSize = fc.getInt("events." + eventName + ".startingBorderSize");
		this.delay = fc.getInt("events." + eventName + ".shrinkRepeatDelay");
    }
}
 
源代码28 项目: SkyWarsReloaded   文件: ProjectileSpleefEvent.java
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");
    }
}
 
源代码29 项目: MineTinker   文件: SpidersBane.java
@Override
public void reload() {
	FileConfiguration config = getConfig();
	config.options().copyDefaults(true);

	config.addDefault("Allowed", true);
	config.addDefault("Color", "%RED%");
	config.addDefault("MaxLevel", 5);
	config.addDefault("SlotCost", 1);

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

	config.addDefault("Recipe.Enabled", true);
	config.addDefault("Recipe.Top", "ESE");
	config.addDefault("Recipe.Middle", "SFS");
	config.addDefault("Recipe.Bottom", "ESE");

	Map<String, String> recipeMaterials = new HashMap<>();
	recipeMaterials.put("E", Material.SPIDER_EYE.name());
	recipeMaterials.put("S", Material.STRING.name());
	recipeMaterials.put("F", Material.FERMENTED_SPIDER_EYE.name());

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

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

	init(Material.FERMENTED_SPIDER_EYE);
}
 
源代码30 项目: Civs   文件: FallbackConfigUtil.java
public static FileConfiguration getConfigFullPath(File originalFile, String url) {
    FileConfiguration config = new YamlConfiguration();
    try {
        InputStream inputStream = FallbackConfigUtil.class.getResourceAsStream(url);
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
        config.load(reader);
        if (originalFile != null && originalFile.exists()) {
            FileConfiguration configOverride = new YamlConfiguration();
            configOverride.load(originalFile);
            for (String key : configOverride.getKeys(true)) {
                if (configOverride.get(key) instanceof ConfigurationSection) {
                    continue;
                }
                config.set(key, configOverride.get(key));
            }
        }
    } catch (Exception e) {
        if (originalFile != null) {
            Civs.logger.log(Level.SEVERE, "File name: {0}", originalFile.getName());
        }
        if (url != null) {
            Civs.logger.log(Level.SEVERE, "Resource path: {0}", url);
        }
        Civs.logger.log(Level.SEVERE, "Unable to load config", e);
    }

    return config;
}
 
 类所在包
 同包方法