当前位置: 首页>>代码示例>>Java>>正文


Java YamlConfiguration.load方法代码示例

本文整理汇总了Java中org.bukkit.configuration.file.YamlConfiguration.load方法的典型用法代码示例。如果您正苦于以下问题:Java YamlConfiguration.load方法的具体用法?Java YamlConfiguration.load怎么用?Java YamlConfiguration.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.configuration.file.YamlConfiguration的用法示例。


在下文中一共展示了YamlConfiguration.load方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadMessage

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
static public void loadMessage(){
	File messageFile = new File("plugins" + File.separator + "PVPAsWantedManager" + File.separator + "message.yml");
	if(!messageFile.exists()){
		if(Config.getConfig("language").equals("CN")){
			createCNMessage();
		}else if(Config.getConfig("language").equals("EN")){
			//TODO createENMessage();
		}else{
			createCNMessage();
		}
	}else{
        Bukkit.getConsoleSender().sendMessage("§8[§6PVPAsWantedManager§8] §aFind Message.yml");
	}
	messages = new YamlConfiguration();
	try {messages.load(messageFile);} catch (IOException | InvalidConfigurationException e) {e.printStackTrace();Bukkit.getConsoleSender().sendMessage("§8[§6PVPAsWantedManager§8] §a读取message时发生错误");}
}
 
开发者ID:Saukiya,项目名称:PVPAsWantedManager,代码行数:17,代码来源:Message.java

示例2: create

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static void create() throws IOException{
    File pluginFolder = DogTags.getInstance().getDataFolder();
    f = new File(pluginFolder, "config.yml");

    if(!f.exists()){
        f.getParentFile().mkdirs();
        DogTags.getInstance().saveResource(f.getName(), false);
        LogUtil.outputMsg("File &6%file% &fdoesn't exist, creating file!".replace("%file%", f.getName()));
    }
    fc = new YamlConfiguration();
    try {
        fc.load(f);
    } catch (InvalidConfigurationException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Chazmondo,项目名称:DogTags,代码行数:17,代码来源:ConfigManager.java

示例3: createFiles

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
private void createFiles() {
    configf = new File(getDataFolder(), "config.yml");

    if(!configf.exists()) {
        getLogger().info("[CFG] config.yml not found - never fear, Mr Java is here! Creating.");

        configf.getParentFile().mkdirs();
        saveResource("config.yml", false);
    }

    config = new YamlConfiguration();

    try {
        getLogger().info("[CFG] Awesome, we found the config.yml. Loading.");

        config.load(configf);
    } catch(Exception e) {
        getLogger().severe("[CFG] Houston, we have a problem (please report to the developer): " + e.getMessage());
    }
}
 
开发者ID:inventor02,项目名称:RLStaffChat,代码行数:21,代码来源:RLStaffChat.java

示例4: getConfig

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**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;
}
 
开发者ID:TheRoot89,项目名称:DungeonGen,代码行数:26,代码来源:Module.java

示例5: loadConfig

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
static public void loadConfig(){
	if(!configFile.exists()){
		createConfig();
		return;
	}else{
        Bukkit.getConsoleSender().sendMessage("§8[§6PVPAsWantedManager§8] §aFind Config.yml");
	}
	config = new YamlConfiguration();
	try {config.load(configFile);} catch (IOException | InvalidConfigurationException e) {e.printStackTrace();Bukkit.getConsoleSender().sendMessage("§8[§6PVPAsWantedManager§8] §a读取config时发生错误");}
}
 
开发者ID:Saukiya,项目名称:PVPAsWantedManager,代码行数:11,代码来源:Config.java

示例6: ConfigManager

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public ConfigManager() {
    try {
        config=new YamlConfiguration();
        f=new File(plugin.getDataFolder(),"config.yml");
        if(!f.exists()) {
            plugin.saveResource("config.yml",false);
        }
        config.load(new BufferedReader(new InputStreamReader(new FileInputStream(f), Charsets.UTF_8)));
    } catch(Exception e) {
        e.printStackTrace();
    }
    instance=this;
}
 
开发者ID:Soldier233,项目名称:GlobalPrefix,代码行数:14,代码来源:ConfigManager.java

示例7: load

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
private static YamlConfiguration load(String FileLocation)
   {
       File f = new File(FileLocation);
	YamlConfiguration cfg;
	cfg = setDefaults(); 
	if ( ! f.exists())
       {
		try 
           {
               if(f.getParentFile().mkdir() && f.createNewFile())
               {
                   Bukkit.getServer().getLogger().log(Level.INFO, "[PrisonPicks] New Config Created at: " + FileLocation);
                   cfg.save(new File(FileLocation));
               } else
               {
                   Bukkit.getServer().getLogger().log(Level.SEVERE, "[PrisonPicks] Failed to create Config file");
               }
		}catch (IOException e1)
           {
			e1.printStackTrace(); 
		}
	}else 
       {
		try 
           {
			cfg.load(f); 
		}catch (IOException | InvalidConfigurationException e)
           {
			e.printStackTrace(); 
		}
	}
	return cfg; 
}
 
开发者ID:ThePhilderbeast,项目名称:prisonPicks,代码行数:34,代码来源:Config.java

示例8: load

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public void load() {
    YamlConfiguration cfg = new YamlConfiguration();
    try {
        cfg.load(ensureFile());
    } catch (IOException | InvalidConfigurationException ex) {
        throw new RuntimeException(ex);
    }
    deserialize(cfg);
    save();
}
 
开发者ID:NyaaCat,项目名称:NyaaCore,代码行数:11,代码来源:FileConfigure.java

示例9: load

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static boolean load(){
    fc = new YamlConfiguration();
    try{
        fc.load(f);
        return true;
    }catch (IOException | InvalidConfigurationException e) {
        LogUtil.outputMsg("Error, "+e.getLocalizedMessage()+".");
        return false;
    }
}
 
开发者ID:Chazmondo,项目名称:DogTags,代码行数:11,代码来源:ConfigManager.java

示例10: Updater

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public Updater(Main plugin, int resourceID, boolean log)
  throws IOException
{
  if (plugin == null) {
    throw new IllegalArgumentException("Plugin cannot be null");
  }
  if (resourceID == 0) {
    throw new IllegalArgumentException("Resource ID cannot be null (0)");
  }
  m = plugin;
  this.id = resourceID;
  this.log = log;
  this.url = new URL("https://api.inventivetalent.org/spigot/resource-simple/" + resourceID);
  
  File configDir = new File(plugin.getDataFolder().getParentFile(), "HeadUpdater");
  File config = new File(configDir, "config.yml");
  YamlConfiguration yamlConfig = new YamlConfiguration();
  if (!configDir.exists()) {
    configDir.mkdirs();
  }
  if (!config.exists())
  {
    config.createNewFile();
    yamlConfig.options().header("Configuration for the HeadUpdater system\nit will inform you about new versions of all plugins which use this updater\n'enabled' specifies whether the system is enabled (affects all plugins)");
    
    yamlConfig.options().copyDefaults(true);
    yamlConfig.addDefault("enabled", Boolean.valueOf(true));
    yamlConfig.addDefault("enabledingame", Boolean.valueOf(true));
    yamlConfig.save(config);
  }
  try
  {
    yamlConfig.load(config);
  }
  catch (InvalidConfigurationException e)
  {
    e.printStackTrace();
    return;
  }
  this.enabled = yamlConfig.getBoolean("enabled");
  this.enabledingame = yamlConfig.getBoolean("enabledingame");
  
  super.start();
}
 
开发者ID:Weefle,项目名称:HeadGetter,代码行数:45,代码来源:Updater.java


注:本文中的org.bukkit.configuration.file.YamlConfiguration.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。