本文整理汇总了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时发生错误");}
}
示例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();
}
}
示例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());
}
}
示例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;
}
示例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时发生错误");}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
}
示例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();
}