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

项目:Minecordbot    文件:ConfigurationBuilder.java   
/**
 * Write in-memory changes of config to its file
 *
 * @param clazz The configuration class to sync.
 */
public static void sync(Class clazz) {
    Object config = configurations.get(clazz);

    if (config == null)
        return;

    String name = config.getClass().getDeclaredAnnotation(Configuration.class).value();
    File file = new File(JavaPlugin.getProvidingPlugin(clazz).getDataFolder(), String.format("%s.yml", name));
    FileConfiguration configFile = new YamlConfiguration();

    buildToConfig(config, configFile);

    try {
        configFile.save(file);
    } catch (IOException e) {
        Logger.err("Couldn't sync config " + name + " to its file!");
    }
}
项目:ZorahPractice    文件:ArenaManager.java   
private void initiateArenas() {
    FileConfiguration config = ManagerHandler.getConfig().getArenasConfig().getConfig();

    if (!config.contains("arenas")) return;

    for (String name : config.getConfigurationSection("arenas").getKeys(false)) {
        try {
            String displayName = config.getString("arenas." + name + ".display-name");
            Integer displayOrder = config.getInt("arenas." + name + ".display-order");
            Location location1 = LocationUtils.getLocation(config.getString("arenas." + name + ".location1"));
            Location location2 = LocationUtils.getLocation(config.getString("arenas." + name + ".location2"));
            Arena arena = new Arena(name, displayName, displayOrder, location1, location2);
            this.arenas.put(name, arena);
        }
        catch (Exception e) {
            PracticePlugin.getInstance().getLogger().severe("Failed to load arena '" + name + "', stack trace below:");
            PracticePlugin.getInstance().getLogger().severe("------------------------------------------------------");
            e.printStackTrace();
            PracticePlugin.getInstance().getLogger().severe("------------------------------------------------------");
        }
    }
}
项目:Minecordbot    文件:ConfigurationBuilder.java   
private static Object buildFromConfig(FileConfiguration config, Class clazz, Object instance) {
    for (String key : config.getKeys(false)) {
        try {
            Field field = clazz.getField(key);

            field.setAccessible(true);
            fieldSet(field, config, instance, key);
        } catch (NoSuchFieldException ignored) {
            Logger.log(Level.FINER, "A key in YAML was not found in the class it is being rebuilt to.");
        } catch (IllegalAccessException e) {
            Logger.err("Couldn't access a field when rebuilding a config!");
        }
    }

    return instance;
}
项目:ViperBot    文件:DDoSManager.java   
public void loadUsers(){
    allowedUsers.clear();
    FileConfiguration config = getConfig();
    for(String key : config.getKeys(false)){
        allowedUsers.put(key.replace("_(dot)_", "."), (Date) config.get(key));
    }
    ArrayList<String> toRemove = new ArrayList<>();
    for(Entry<String, Date> ent : allowedUsers.entrySet()){
        if(Calendar.getInstance().getTime().after(ent.getValue())){
            try {
                Core.send(Core.skype.getOrLoadContact(ent.getKey()).getPrivateConversation(), "You DDoS-Attack permission is over");
            } catch (ConnectionException | ChatNotFoundException e) {
                e.printStackTrace();
            }
            toRemove.add(ent.getKey());
        }
    }
    for(String user : toRemove){
        allowedUsers.remove(user);
    }
}
项目:StartupCommands    文件:Command.java   
/**
 * Loads all of the startup commands from the plugin's configuration file.
 * @param plugin the StartupCommands plugin instance
 */
public static void loadCommands(StartupCommands plugin) {
    FileConfiguration config = plugin.getConfig();

        if (config.getConfigurationSection("commands") == null) {
            plugin.getLogger().info("There are no startup commands present.");
        } else {
            int delay = 0;

            for (String command : config.getConfigurationSection("commands").getKeys(false)) {
                delay = config.getInt("commands." + command + ".delay", 0);

                // Try to create the command
                try {
                    plugin.getCommands().add(new Command(command, delay));
                } catch (IllegalArgumentException e) {
                    plugin.getLogger().severe(e.getMessage());
                }
            }
        }
}
项目:CaulCrafting    文件:CraftStorage.java   
public void removeCraft(int nb) {
try {
    //replacing in the file
    File craftfile = new File(plugin.getDataFolder(), "crafts.yml");
    craftfile.createNewFile();
    FileConfiguration craftconfig = YamlConfiguration.loadConfiguration(craftfile);
    int count = 0;
    for(String craftuuid : craftconfig.getConfigurationSection("Crafts").getKeys(false)) {
        if(nb == count) {
            craftconfig.set("Crafts." + craftuuid, null);
        }
        count++;
    }
    craftconfig.save(craftfile);
    } catch (Exception e) {
        //
    }
  }
项目:Minecordbot    文件:ConfigurationBuilder.java   
private static Object build(Class clazz) {
    Object object;

    try {
        object = clazz.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
        Logger.err("Failed to build a configuration - couldn't access the class!");
        return null;
    }

    String name = object.getClass().getDeclaredAnnotation(Configuration.class).value();
    File file = new File(JavaPlugin.getProvidingPlugin(clazz).getDataFolder(), String.format("%s.yml", name));
    FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);

    buildFromConfig(configFile, clazz, object);

    return object;
}
项目:OpenUHC    文件:LobbyModule.java   
@Override
public void onEnable() {
  world = Bukkit.createWorld(new WorldCreator(OpenUHC.WORLD_DIR_PREFIX + "lobby"));
  // Read lobby yml if it exists
  File lobbyFile = new File(OpenUHC.WORLD_DIR_PREFIX + "lobby/lobby.yml");
  if (lobbyFile.exists()) {
    FileConfiguration lobbyConfig = YamlConfiguration.loadConfiguration(lobbyFile);
    ConfigurationSection spawn = lobbyConfig.getConfigurationSection("spawn");
    if (spawn != null) {
      double x = spawn.getDouble("x", 0);
      double y = spawn.getDouble("y", 64);
      double z = spawn.getDouble("z", 0);
      double r = spawn.getDouble("r", 1);
      this.spawn = new Vector(x, y, z);
      radius = (float) r;
    }
  }
  OpenUHC.registerEvents(this);
}
项目:SkyWarsReloaded    文件:GameController.java   
public void removeSignJoinGame(String gameNumber) {
    File signJoinFile = new File(SkyWarsReloaded.get().getDataFolder(), "signJoinGames.yml");
    FileConfiguration storage = YamlConfiguration.loadConfiguration(signJoinFile);
        storage.set("games." + gameNumber, null);
        try {
        storage.save(signJoinFile);
    } catch (IOException e) {
        e.printStackTrace();
    }
       signJoinGames.remove(Integer.valueOf(gameNumber));
       Game game = getGame(Integer.valueOf(gameNumber));
       if (game != null) {
           if (game.getState() != GameState.PLAYING) {
            game.endGame();
           }
       }
}
项目:Arc-v2    文件:ArcConfiguration.java   
/**
 * Get the data from config file.
 *
 * @param config the configuration file.
 */
public void read(FileConfiguration config) {

    // read type and time.
    banType = BanList.Type.valueOf(config.getString("ban-type"));
    banTime = config.getInt("ban-time", banTime);

    // convert the days into a date.
    String days = config.getString("ban-days");
    if (Objects.isNull(days) || Objects.equals(days, "0")) {
        banDate = null;
    } else {
        GregorianCalendar c = new GregorianCalendar();
        c.add(GregorianCalendar.DATE, Integer.parseInt(days));
        banDate = c.getTime();
    }

    tpsLimit = config.getInt("tps-limit", tpsLimit);

    broadcastBan = config.getBoolean("broadcast-ban");
    if (broadcastBan) {
        String message = config.getString("broadcast-message");
        broadcastMessage = ChatColor.translateAlternateColorCodes('&', message);
    }

}
项目:mczone    文件:Map.java   
public boolean reload() {
    ConfigAPI api = new ConfigAPI(getConfig());
       FileConfiguration config = api.getConfig();
       String title = config.getString("info.title");
       String worldName = config.getString("info.worldName");

       List<Location> spawns = new ArrayList<Location>();
       for (String s : config.getConfigurationSection("spawns").getKeys(false)) {
        Location l = api.getLocation("spawns." + s);
            spawns.add(l);
       }
       Location specSpawn = api.getLocation("spawns.spec");

       this.title = title;
       this.worldName = worldName;
       this.specSpawn = specSpawn;
       this.spawns = spawns;
    return true;
}
项目:BlockBall    文件:BungeeCordController.java   
public void add(String server, Location location) {
    final BungeeCordSignInfo info = new BungeeCordSignInfo.Container(location, server);
    this.signs.add(info);
    final BungeeCordSignInfo[] signInfos = this.signs.toArray(new BungeeCordSignInfo[this.signs.size()]);
    this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, () -> {
        try {
            final FileConfiguration configuration = new YamlConfiguration();
            final File file = new File(BungeeCordController.this.plugin.getDataFolder(), "bungeecord_signs.yml");
            if (file.exists()) {
                if (!file.delete()) {
                    Bukkit.getLogger().log(Level.WARNING, "File cannot get deleted.");
                }
            }
            for (int i = 0; i < signInfos.length; i++) {
                configuration.set("signs." + i, signInfos[i].serialize());
            }
            configuration.save(file);
        } catch (final IOException e) {
            Bukkit.getLogger().log(Level.WARNING, "Save sign location.", e);
        }
    });
}
项目:BlockBall    文件:BungeeCordController.java   
private void load(JavaPlugin plugin) {
    try {
        final FileConfiguration configuration = new YamlConfiguration();
        final File file = new File(plugin.getDataFolder(), "bungeecord_signs.yml");
        if (!file.exists()) {
            if (!file.createNewFile()) {
                Bukkit.getLogger().log(Level.WARNING, "File cannot get created.");
            }
        }
        configuration.load(file);
        if (configuration.getConfigurationSection("signs") != null) {
            final Map<String, Object> data = configuration.getConfigurationSection("signs").getValues(false);
            for (final String s : data.keySet()) {
                this.signs.add(new BungeeCordSignInfo.Container(((ConfigurationSection) data.get(s)).getValues(true)));
            }
        }
    } catch (IOException | InvalidConfigurationException e) {
        Bukkit.getLogger().log(Level.WARNING, "Save load location.", e);
    }
}
项目:BlockBall    文件:ArenaFileManager.java   
void save(Arena item) {
    if (item != null && item.getName() != null) {
        try {
            final FileConfiguration configuration = new YamlConfiguration();
            final File file = new File(this.getFolder(), "arena_" + item.getName() + ".yml");
            if (file.exists()) {
                if (!file.delete())
                    throw new IllegalStateException("Cannot delete file!");
            }
            if (!file.createNewFile())
                throw new IllegalStateException("Cannot create file!");
            configuration.load(file);
            final Map<String, Object> data = item.serialize();
            for (final String key : data.keySet()) {
                configuration.set("arena." + key, data.get(key));
            }
            configuration.save(file);
        } catch (IOException | InvalidConfigurationException ex) {
            Bukkit.getLogger().log(Level.WARNING,"Cannot save arena." ,ex.getMessage());
        }
    }
}
项目:BlockBall    文件:ArenaFileManager.java   
Arena[] load() {
    final List<Arena> items = new ArrayList<>();
    for (int i = 0; (this.getFolder() != null) && (i < this.getFolder().list().length); i++) {
        final String s = this.getFolder().list()[i];
        try {
            if (s.contains("arena_")) {
                final FileConfiguration configuration = new YamlConfiguration();
                final File file = new File(this.getFolder(), s);
                configuration.load(file);
                final Map<String, Object> data = configuration.getConfigurationSection("arena").getValues(true);
                final Arena arenaEntity = new ArenaEntity(data, configuration.getStringList("arena.properties.wall-bouncing"));
                items.add(arenaEntity);
            }
        } catch (final Exception ex) {
            Bukkit.getLogger().log(Level.WARNING, "Cannot read arena file " + s + '.', ex);
        }
    }
    return items.toArray(new Arena[items.size()]);
}
项目:Crescent    文件:LearnData.java   
public void storeNewData(Learn learn, KnownCheating knownCheating) {
    final FileConfiguration fc = getConfig();

    // Generate a UUID for this check (its identifier).
    UUID uuid = UUID.randomUUID();

    while (fc.isConfigurationSection(uuid.toString())) {
        uuid = UUID.randomUUID();
    }

    // The path to put the data in the file.
    String cheatPath = getCheatPath(knownCheating);

    // Get general values.
    final double currentMean = fc.getDouble(cheatPath + "CurrentMean");
    final double currentLowRange = fc.getDouble(cheatPath + "CurrentLowRange");
    final double currentHighRange = fc.getDouble(cheatPath + "CurrentHighRange");
    final long totalSamples = fc.getLong(cheatPath + "TotalSamples");

    if (currentLowRange == 0.0 || learn.getValue() < currentLowRange) {
        fc.set(cheatPath + "CurrentLowRange", learn.getValue());
    } else if (learn.getValue() > currentHighRange) {
        fc.set(cheatPath + "CurrentHighRange", learn.getValue());
    }

    // Calculate the new average.
    double updateMean = (currentMean + learn.getValue()) / 2.0;

    fc.set(cheatPath + "CurrentMean", updateMean);
    fc.set(cheatPath + "TotalSamples", totalSamples + 1);

    // Save the file.
    save(fc);
}
项目:CropControl    文件:CropControlDatabaseHandler.java   
public CropControlDatabaseHandler(FileConfiguration config) {
    if (!configureData(config.getConfigurationSection("database"))) {
        throw new RuntimeException("Failed to configure Database for CropControl!");
    }
    CropControlDatabaseHandler.instance = this;
    this.dataAccessObject = new DAO(this);
}
项目:uppercore    文件:ScriptManager.java   
public void reloadConfig(File configFile) {
    extensionsToEngineName = new HashMap<>();

    FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
    ConfigurationSection section = config.getConfigurationSection("engines");
    for (Map.Entry<String, Object> obj : section.getValues(false).entrySet())
        extensionsToEngineName.put(obj.getKey(), obj.getValue().toString());
}
项目:ViperBot    文件:DDoSManager.java   
public void saveUsers(){
    File userFile = new File(mainFolder, "AllowedUsers.yml");
    FileConfiguration config = new YamlConfiguration();
    for(Entry<String, Date> ent : allowedUsers.entrySet()){
        config.set(ent.getKey().replace(".", "_(dot)_"), ent.getValue());
    }
    try {
        config.save(userFile);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:RPGPlus    文件:Datafiles.java   
public void createFile(Player p) {
    File pFileDir = new File(Main.getInstance().getDataFolder(), "Players");
    if (!pFileDir.exists()) {
        pFileDir.mkdir();
    }
    File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.getName().toLowerCase() + ".yml");
    if (!pFile.exists())
        try {
            pFile.createNewFile();
            List<String> combo = new ArrayList<String>();
            List<String> guilds = new ArrayList<String>();
            combo.add(0, "???");
            combo.add(1, "???");
            combo.add(2, "???");
            FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
            pConfig.set("User", p.getName());
            pConfig.set("Class", Default);
            pConfig.set("Race", Default);
            pConfig.set("Guilds", guilds);
            pConfig.set("Kills", Integer.valueOf(0));
            pConfig.set("Deaths", Integer.valueOf(0));

            pConfig.set("Counter", Integer.valueOf(1));
            pConfig.set("Combo", combo);

            // pConfig.set("Reader", Boolean[].class);
            /*
             * pConfig.set("ObservationHakiLevel", Integer.valueOf(0));
             * pConfig.set("ObservationHakiXP", Integer.valueOf(0));
             * pConfig.set("ConquerorsHaki", Boolean.valueOf(false));
             * pConfig.set("ConquerorHakiLevel", Integer.valueOf(0));
             * pConfig.set("ConquerorHakiXP", Integer.valueOf(0));
             */
            pConfig.save(pFile);
        } catch (Exception e) {
        }
}
项目:RPGPlus    文件:Datafiles.java   
public static void addKill(String p) {
    File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
    FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
    pConfig.set("Kills", Integer.valueOf(pConfig.getInt("Kills") + 1));
    try {
        pConfig.save(pFile);
    } catch (Exception e) {
    }
}
项目:EpicBanRequests    文件:BanRequest.java   
public void writeToConfig() {
    FileConfiguration c = Main.getInstance().getConfig();
    c.set("ban_requests." + id + ".timeOpened", timeOpened);
    c.set("ban_requests." + id + ".timeClosed", timeClosed);
    c.set("ban_requests." + id + ".openerUUID", openerUUID);
    c.set("ban_requests." + id + ".closerUUID", closerUUID);
    c.set("ban_requests." + id + ".timeOpenedFormatted", timeOpenedFormatted);
    c.set("ban_requests." + id + ".timeClosedFormatted", timeClosedFormatted);
    c.set("ban_requests." + id + ".closed", closed);
    c.set("ban_requests." + id + ".accepted", accepted);
    c.set("ban_requests." + id + ".denied", denied);
    c.set("ban_requests." + id + ".banReason", banReason);
    c.set("ban_requests." + id + ".playerToBanUUID", playerToBanUUID);
    Main.getInstance().saveConfig();
}
项目:RPGPlus    文件:Datafiles.java   
public void addPoints(String p, int amountAdded) {
    File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
    FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
    pConfig.set("Points", Integer.valueOf(pConfig.getInt("Points") + amountAdded));
    try {
        pConfig.save(pFile);
    } catch (Exception e) {
    }
}
项目:RPGPlus    文件:Datafiles.java   
public static void incrementCounter(String p) {
    File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
    FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
    pConfig.set("counter", Integer.valueOf(pConfig.getInt("counter") + 1));
    try {
        pConfig.save(pFile);
    } catch (Exception e) {
    }
}
项目:Recreator    文件:AzureAPI.java   
public static FileConfiguration loadOrCreateFile(File file) {
    if (!file.exists()) {
        try {
            file.createNewFile();
        } catch (IOException ex) {
        }
    }
    return YamlConfiguration.loadConfiguration(file);
}
项目:StartupCommands    文件:Command.java   
/**
 * Static method for removing a command from the configuration.
 * @param plugin The StartupCommands instance.
 * @param removeStr The String of the command to remove. If it is an Integer
 * the command will be removed by index, otherwise, the method looks for a matching
 * command String.
 * @return removeStr The command String of the removed command.
 * @throws IllegalArgumentException if the command doesn't exist, if the index provided 
 * is less than zero or greater than commands.size() - 1, or if the configuration file 
 * cannot be saved.
 */
public static String removeCommand(StartupCommands plugin, String removeStr) {
    FileConfiguration config = plugin.getConfig();

    // Find the command String if removeStr is an Integer
    if (StartupCommands.isInteger(removeStr)) {
        List<Command> commands = plugin.getCommands();
        int index = Integer.parseInt(removeStr) - 1;

        // Ensure index is valid
        if (index < 0 || index > commands.size() - 1) {
            throw new IllegalArgumentException("Index must be greater than 0 and less than the number of startup commands.");
        }

        removeStr = plugin.getCommands().remove(index).getCommand();
    }

    if (config.contains("commands." + removeStr)) {
        config.set("commands." + removeStr, null);

        // Try to save configuration
        try {
            config.save(plugin.getDataFolder() + File.separator + "config.yml");
        } catch (IOException e) {
            throw new IllegalArgumentException("Could not save configuration file.");
        }

        return removeStr;
    } else {
        throw new IllegalArgumentException("Could not identify command to remove by " + removeStr + ".");
    }
}
项目:Warzone    文件:MapLibrary.java   
public MapLibrary(FileConfiguration fileConfiguration, MapLoader mapLoader) {
    for (String s : fileConfiguration.getConfigurationSection("map").getStringList("sources")) {
        sources.add(new File(s));
        Bukkit.getLogger().info("Added map source: " + s);
    }

    this.mapLoader = mapLoader;
}
项目:Minecordbot    文件:ConfigurationBuilder.java   
private static void fieldSet(Field f, FileConfiguration config, Object instance, String key) throws IllegalAccessException {
    if (config.get(key) instanceof Boolean) {
        f.set(instance, config.getBoolean(key));
    } else if (config.get(key) instanceof Integer) {
        f.set(instance, config.getInt(key));
    } else if (config.get(key) instanceof ConfigurationSection) {
        f.set(instance, f.getType().cast(((ConfigurationSection) config.get(key)).getValues(false)));
    } else {
        f.set(instance, f.getType().cast(config.get(key)));
    }
}
项目:EscapeLag    文件:WorldSpawnLimiter.java   
@EventHandler
public void WorldSeterLimitor(WorldInitEvent event) {
    World world = event.getWorld();
    FileConfiguration config = EscapeLag.configOptimize.getValue();
    if (config.getBoolean("WorldSpawnLimitor." + world.getName() + ".enable")) {
        world.setMonsterSpawnLimit(config.getInt("WorldSpawnLimitor." + world.getName() + ".PerChunkMonsters"));
        world.setAnimalSpawnLimit(config.getInt("WorldSpawnLimitor." + world.getName() + ".PerChunkAnimals"));
        world.setAmbientSpawnLimit(config.getInt("WorldSpawnLimitor." + world.getName() + ".PerChunkAmbient"));
        EscapeLag.MainThis.getLogger().info("已为世界 " + world.getName() + " 设定了生物刷新速率~");
    }
}
项目:EmojiChat    文件:EmojiHandler.java   
/**
 * Loads the disabled emojis from the config.
 *
 * @param config The config to load disabled emojis from.
 * @param plugin The EmojiChat main class instance.
 */
private void loadDisabledEmojis(FileConfiguration config, EmojiChat plugin) {
    if (config.getBoolean("disable-emojis")) {
        for (String disabledEmoji : config.getStringList("disabled-emojis")) {
            if (disabledEmoji == null || !emojis.containsKey(disabledEmoji)) {
                plugin.getLogger().warning("Invalid emoji specified in 'disabled-emojis': '" + disabledEmoji + "'. Skipping...");
                continue;
            }
            disabledCharacters.add(emojis.remove(disabledEmoji)); // Remove disabled emojis from the emoji list
        }
    }
}
项目:ItemUtility    文件:Config.java   
public void save(FileConfiguration config, File file) {
    try {
        config.save(file);
    } catch (IOException e) {
        Bukkit.getLogger().throwing("Config","save",e);
    }
}
项目:CaulCrafting    文件:Language.java   
public void setLanguage(String loc) {
    try {
        File locfile = new File(plugin.getDataFolder(), "config_locale.yml");
        locfile.createNewFile();
        FileConfiguration locconfig = YamlConfiguration.loadConfiguration(locfile);
        locconfig.set("lang", loc);
        locconfig.save(locfile);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:EmojiChat    文件:EmojiHandler.java   
/**
 * Loads the emoji shortcuts from the config.
 *
 * @param config The config to load emoji shortcuts from.
 */
private void loadShortcuts(FileConfiguration config) {
    for (String key : config.getConfigurationSection("shortcuts").getKeys(false)) { // Gets all of the headers/keys in the shortcuts section
        for (String shortcutListItem : config.getStringList("shortcuts." + key)) { // Gets all of the shortcuts for the key
            shortcuts.put(shortcutListItem, ":" + key + ":");
        }
    }
}
项目:CaulCrafting    文件:CraftStorage.java   
@SuppressWarnings("unchecked")
public ArrayList<CraftArray> getCrafts(){
    ArrayList<CraftArray> craftlist = new ArrayList<CraftArray>();
    try {
        File craftfile = new File(plugin.getDataFolder(), "crafts.yml");
        craftfile.createNewFile();
        FileConfiguration craftconfig = YamlConfiguration.loadConfiguration(craftfile);
        if(craftconfig.isSet("Crafts")) {
            for(String craftpath : craftconfig.getConfigurationSection("Crafts").getKeys(false)) {
                craftpath = "Crafts." + craftpath;
                ArrayList<ItemStack> config_craft = (ArrayList<ItemStack>) craftconfig.getList(craftpath + ".craft");
                ArrayList<ItemStack> config_resultitems = (ArrayList<ItemStack>) craftconfig.getList(craftpath + ".result.items");
                ArrayList<Integer> config_resultprobs = (ArrayList<Integer>) craftconfig.getIntegerList(craftpath + ".result.probs");
                HashMap<ItemStack,Integer> config_result = new HashMap<ItemStack, Integer>();
                for(ItemStack resultitem : config_resultitems) {
                    config_result.put(resultitem, config_resultprobs.get(config_resultitems.indexOf(resultitem)));
                }
                ArrayList<String> config_cmds = (ArrayList<String>) craftconfig.getStringList(craftpath + ".cmds");
                boolean config_redstonepower = craftconfig.getBoolean(craftpath + ".redstonepower");
                int config_experience = craftconfig.getInt(craftpath + ".experience");
                CraftArray specraft = new CraftArray(config_craft, config_result, config_cmds, config_redstonepower, config_experience);
                craftlist.add(specraft);
            }
            return craftlist;
        } else {
            return craftlist;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return craftlist;
    }
   }
项目:EmojiChat    文件:EmojiHandler.java   
/**
 * Validates the config.
 *
 * @param config The config to validate.
 * @return True if the config is valid, false otherwise.
 */
private boolean validateConfig(FileConfiguration config) {
    try {
        return config.get("shortcuts") != null && config.get("disabled-emojis") != null
                && config.get("fix-emoji-coloring") != null && config.get("disable-emojis") != null
                && config.get("pack-variant") != null;
    } catch (Exception e) {
        return false;
    }
}
项目:RPGInventory    文件:BackpackManager.java   
public static boolean init(RPGInventory instance) {
    if (!isEnabled()) {
        return false;
    }

    try {
        Path petsFile = RPGInventory.getInstance().getDataPath().resolve("backpacks.yml");
        if (Files.notExists(petsFile)) {
            RPGInventory.getInstance().saveResource("backpacks.yml", false);
        }

        FileConfiguration petsConfig = YamlConfiguration.loadConfiguration(petsFile.toFile());

        BACKPACK_TYPES.clear();
        for (String key : petsConfig.getConfigurationSection("backpacks").getKeys(false)) {
            tryToAddBackpack(key, petsConfig.getConfigurationSection("backpacks." + key));
        }

        BackpackManager.loadBackpacks();
        RPGInventory.getPluginLogger().info(BACKPACK_TYPES.size() + " backpack type(s) has been loaded");
        RPGInventory.getPluginLogger().info(BACKPACKS.size() + " backpack(s) has been loaded");
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }

    if (BACKPACK_TYPES.size() == 0) {
        return false;
    }

    BACKPACK_LIMIT = Config.getConfig().getInt("backpacks.limit", 0);

    // Register events
    instance.getServer().getPluginManager().registerEvents(new BackpackListener(), instance);
    return true;
}
项目:FusePort    文件:FeedbackCreator.java   
private void loadLangFiles()
{
    languages = new HashMap<>();
    for(String lang : langFiles)
    {
        FileConfiguration data = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "languages" + File.separator + lang + ".yml"));

        TreeElement<String> langTree = new TreeElement<String>(lang, data);
        langTree.print();
        languages.put(lang, langTree);
    }
}
项目:duccks    文件:main.java   
public void onEnable()
/*    */   {
/* 12 */     System.out.println("Plugin enabled");
/*    */     
/* 14 */     FileConfiguration config = getConfig();
/* 15 */     saveDefaultConfig();
/* 16 */     config.addDefault("incorrect-usage", "&8[&3FlyCheck&8] &7Incorrect usage: &f/flycheck [player]");
/* 17 */     config.addDefault("not-online", "&8[&3FlyCheck&8] &7That player needs to be online to be checked!");
/* 18 */     config.addDefault("yes-access", "&8[&3FlyCheck&8] &f%player% &7has access to /fly!");
/* 19 */     config.addDefault("no-access", "&8[&3FlyCheck&8] &f%player% &7does not have access to /fly!");
/* 20 */     saveDefaultConfig();
/*    */   }
项目:AntiBots    文件:DataProvider.java   
private DataProvider() {
    FileConfiguration config = Main.config();

    this.protection = config.getBoolean(Main.PROTECTION_KEY);
    this.kickMessage = config.getString(Main.PLAYER_KICK_KEY);
    String root = config.getString(Main.VERIFICATION_ROOT_KEY);
    if (!root.endsWith("/")) root += '/';
    root = root.replace('\\', '/');
    this.verificationRoot = root;
    this.wipeKey = config.getString(Main.WIPE_KEY);
    this.whitelist = config.getStringList(Main.WHITELIST_KEY);

    this.formattedMessage = String.format(ChatColor.translateAlternateColorCodes('&', getKickMessage()), root);

}
项目:MCPluginDebuggerforMC    文件:MCPluginDebugger.java   
@Override
public void onEnable() {
    FileConfiguration config = this.getConfig();
    config.options().copyDefaults(true);
    this.saveConfig();
    String pluginName = config.getString("debug.pluginName");
    int port = config.getInt("debug.socketPort");
    socketThread = new Thread(new SocketRunnable(port, pluginName, this.getDataFolder().getParentFile()));
    socketThread.start();
    this.getLogger().info("Enabled MCPluginDebugger(target: " + pluginName + ", port: " + port + ")");
}