Module.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:DungeonGen 作者:
/**Static method to get a modules config alone, returns null if failed.
 * The loading is tested during the initial yml test and should therefore work during DunGen runtime.
 * @param parent    The parent plugin
 * @param name      The modules name for witch the config should be loaded (file 'name'.yml)
 * @return          The config object. Returns null if errors occured and sets plugin state to ERROR.
 */
public static YamlConfiguration getConfig(DunGen parent, String name) {
    File confFile = new File(parent.getDataFolder(),name+".yml");
    if (!confFile.exists()) {
        parent.setStateAndNotify(State.ERROR, "Config file for module " + name + " could not be found!");
        return null;
    }

    YamlConfiguration conf = new YamlConfiguration();
    try {
        conf.load(confFile);
    }catch (IOException | InvalidConfigurationException e) {
        parent.setStateAndNotify(State.ERROR, "Loading of config file for module " + name + " failed:");
        e.printStackTrace();
        return null;
    }
    // everything ok, if code reached here.
    parent.getLogger().info("YML file for module " + name + " loaded.");
    return conf;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号