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


Java YamlConfiguration.loadConfiguration方法代码示例

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


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

示例1: updateConfig

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**
 * Update the configuration file
 * 
 * @param currentVersion the version of the configuration file
 */
public void updateConfig(int currentVersion) {
	InputStream in = plugin.getResource("config.yml");
	try (InputStreamReader inReader = new InputStreamReader(in)) {
		FileConfiguration defaultConfig = YamlConfiguration.loadConfiguration(inReader);
		
		if (defaultConfig.getInt("version") == currentVersion) {
			return;
		}
		
		Set<String> newKeys = defaultConfig.getKeys(false);
		for (String key : plugin.getConfig().getKeys(false)) {
			if (key.equalsIgnoreCase("version")) {
				continue;
			}
			if (newKeys.contains(key)) {
				defaultConfig.set(key, plugin.getConfig().get(key));
			}
		}
		
		defaultConfig.save(new File(plugin.getDataFolder() + "/config.yml"));
	} catch (IOException e) { e.printStackTrace(); }
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:28,代码来源:ConfigUtil.java

示例2: FileConfig

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public FileConfig(String fileName) {
    this.fileName = fileName;
    this.configFile = new File(PracticePlugin.getInstance().getDataFolder(), fileName);
    
    if (!this.configFile.exists()) {
        this.configFile.getParentFile().mkdirs();

        if (PracticePlugin.getInstance().getResource(fileName) == null) {
            try {
                this.configFile.createNewFile();
            }
            catch (IOException e) {
                PracticePlugin.getInstance().getLogger().severe("Failed to create new file " + fileName);
            }
        }
        else {
            PracticePlugin.getInstance().saveResource(fileName, false);
        }
    }

    this.config = YamlConfiguration.loadConfiguration(this.configFile);
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:23,代码来源:FileConfig.java

示例3: getYaml

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static YamlConfiguration getYaml(Plugin p, String path, boolean create){
	path = fixPath(path);
	File temp = new File(p.getDataFolder(), path);
	if(!temp.exists()){
		copyFile(path, p);
		if(!temp.exists()){
			if(create)
			try {
				temp.createNewFile();
			} catch (IOException e) {
				ErrorLogger.addError("Can't create " + path + " IO Exception !");
				e.printStackTrace();
			}
			else
				return null;
		}
	}
	YamlConfiguration file = YamlConfiguration.loadConfiguration(temp);
	return file;
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:21,代码来源:ConfigUtils.java

示例4: setup

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public void setup() {
    if (!plugin.getDataFolder().exists()) {
        plugin.getDataFolder().mkdir();
    }

    ranksFile = new File(plugin.getDataFolder(), "ranks.yml");

    if (!ranksFile.exists()) {
        try {
            ranksFile.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    ranksCFG = YamlConfiguration.loadConfiguration(ranksFile);
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:18,代码来源:ConfigManager.java

示例5: loadConfig

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static void loadConfig(Plugin plugin) {
    pl = plugin;

    file = new File(pl.getDataFolder(), "config.yml");
    Config = YamlConfiguration.loadConfiguration(file);

    if (!pl.getDataFolder().exists()) {
        pl.getDataFolder().mkdir();
    }

    create();

    int gamemode = Config.getInt("On-Join.Spawn.Gamemode.Gamemode");

    if ((gamemode != 0) && (gamemode != 1) && (gamemode != 2) && (gamemode != 3)) {
        Config.set("On-Join.Spawn.Gamemode.Gamemode", Integer.valueOf(0));
    }
}
 
开发者ID:DianoxDragon,项目名称:UltimateSpawn,代码行数:19,代码来源:ConfigGlobal.java

示例6: Map

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public Map(String title, String worldName, List<Location> spawns, Location specSpawn) {
       list.add(this);
	this.id = list.size();
	this.title = title;
	this.worldName = worldName;
	this.spawns = spawns;
	
	this.specSpawn = specSpawn;
       File file = new File(SurvivalGames.getInstance().getDataFolder() + File.separator + "maps", worldName + ".yml");
       if (!file.exists()) {
           try {
               file.createNewFile();
           }
           catch (IOException e) {
               e.printStackTrace();
           }
       }
       config = YamlConfiguration.loadConfiguration(file);
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:20,代码来源:Map.java

示例7: loadConfig

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static void loadConfig(Plugin plugin) {
    pl = plugin;

    file = new File(pl.getDataFolder(), "Config/Global/OnJoin/Cosmetics-OnJoin.yml");
    Config = YamlConfiguration.loadConfiguration(file);

    if (!pl.getDataFolder().exists()) {
        pl.getDataFolder().mkdir();
    }

    create();

    int gamemode = Config.getInt("On-Join.Spawn.Gamemode.Gamemode");

    if ((gamemode != 0) && (gamemode != 1) && (gamemode != 2) && (gamemode != 3)) {
        Config.set("Gamemode.Value", Integer.valueOf(0));
    }
}
 
开发者ID:DianoxDragon,项目名称:UltimateSpawn,代码行数:19,代码来源:ConfigGCos.java

示例8: signRemoved

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
@EventHandler
  public void signRemoved(BlockBreakEvent event) {
      Location blockLocation = event.getBlock().getLocation();
      World w = blockLocation.getWorld();
  	Block b = w.getBlockAt(blockLocation);
if(b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST){
   	Sign sign = (Sign) b.getState();
   	String line1 = ChatColor.stripColor(sign.getLine(0));
	if (line1.equalsIgnoreCase(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', new Messaging.MessageFormatter().format("signJoinSigns.line1"))))) {
          	 String world = blockLocation.getWorld().getName().toString();
       		 int x = blockLocation.getBlockX();
       		 int y = blockLocation.getBlockY();
       		 int z = blockLocation.getBlockZ();
       		 File signJoinFile = new File(SkyWarsReloaded.get().getDataFolder(), "signJoinGames.yml");
       		 if (signJoinFile.exists()) {
       			FileConfiguration storage = YamlConfiguration.loadConfiguration(signJoinFile);
                  for (String gameNumber : storage.getConfigurationSection("games.").getKeys(false)) {
                  	String world1 = storage.getString("games." + gameNumber + ".world");
                  	int x1 = storage.getInt("games." + gameNumber + ".x");
                  	int y1 = storage.getInt("games." + gameNumber + ".y");
                  	int z1 = storage.getInt("games." + gameNumber + ".z");
                  	if (x1 == x && y1 == y && z1 == z && world.equalsIgnoreCase(world1)) {
                  		if (event.getPlayer().hasPermission("swr.signs")) {
                        		SkyWarsReloaded.getGC().removeSignJoinGame(gameNumber);
                        	} else {
                        		event.setCancelled(true);
                          	event.getPlayer().sendMessage(ChatColor.RED + "YOU DO NOT HAVE PERMISSION TO DESTROY SWR SIGNS");
                  		}
                  	}
             	 	} 
       		 }
           }
}
  }
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:35,代码来源:SignListener.java

示例9: KingdomFactionsFile

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public KingdomFactionsFile(String name) {
	ConfigModule.getInstance().getFiles().add(this);
	this.name = name;
	file = new File(KingdomFactionsPlugin.getInstance().getDataFolder(), name);
	this.config = YamlConfiguration.loadConfiguration(file);
	if (this.file.exists()) {
		try {
			this.file.createNewFile();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:15,代码来源:KingdomFactionsFile.java

示例10: DataFile

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public DataFile(JavaPlugin plugin, String name) {
	file = new File(plugin.getDataFolder(), name + ".yml");

	if (!file.getParentFile().exists()) {
		file.getParentFile().mkdir();
	}

	plugin.saveResource(name + ".yml", false);

	configuration = YamlConfiguration.loadConfiguration(file);
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:12,代码来源:DataFile.java

示例11: ConfigAPI

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public ConfigAPI(File file, JavaPlugin plugin) {
 	if (!file.exists()) {
try {
	file.getParentFile().mkdirs();
	file.createNewFile();
} catch (IOException e) {
	e.printStackTrace();
}
 	}
     this.config = YamlConfiguration.loadConfiguration(file);
 }
 
开发者ID:thekeenant,项目名称:mczone,代码行数:12,代码来源:ConfigAPI.java

示例12: setRating

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static void setRating(UUID uuid, Ladder ladder, Integer rating, GenericCallback callback) {
    if (Bukkit.getPlayer(uuid) != null) {
        ManagerHandler.getPlayerManager().getPlayerProfile(uuid).setRating(ladder, 1000);
        ManagerHandler.getPlayerManager().getPlayerProfile(uuid).save(null);
        callback.call(true);
        return;
    }

    try {
        File file = new File(PracticePlugin.getInstance().getDataFolder() + "/playerdata/" + uuid.toString() + ".yml");

        if (!file.exists()) {
            callback.call(false);
            return;
        }

        YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);

        yml.set("ratings." + ladder.getName(), rating);
        yml.save(file);

        callback.call(true);
    }
    catch (Exception e) {
        callback.call(false);
        System.out.println("DataAccessor -> Failed method setRating");
        System.out.println(" * " + uuid.toString());
        System.out.println(" * " + ladder.getName());
        System.out.println(" * " + rating);
    }
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:32,代码来源:DataAccessor.java

示例13: onEnable

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
@Override
public void onEnable()
{
	instance = this;
	getDataFolder().mkdirs();
	
	cfgFile = new File(getDataFolder(), "cfg.yml");
	cfg = YamlConfiguration.loadConfiguration(cfgFile);
	
	
	
	setIf("lang", "en");
	setIf("bag_small_size", 27);
	setIf("bag_big_size", 54);
	try
	{
		cfg.save(cfgFile);
	}
	catch (IOException e)
	{
		e.printStackTrace();
	}
	Translation.initLangFiles();

	
	smallBag = new BagSmall();
	
	bigBag = new BagBig();
	
	craftingBag = new BagCrafting();
	enderBag = new BagEnder();
	enchantBag = new BagEnchant();
	anvilBag = new BagAnvil();
	
	
	recipesFile = new File(getDataFolder(), "recipes.yml");
	recipes = YamlConfiguration.loadConfiguration(recipesFile);
	
	
	
	Bukkit.getPluginManager().registerEvents(new CraftListener(), this);
	RecipeManager.initRecipes();

	CustomRegistry.registerItem(smallBag, this);
	CustomRegistry.registerItem(bigBag, this);
	CustomRegistry.registerItem(craftingBag, this);
	CustomRegistry.registerItem(enderBag, this);
	CustomRegistry.registerItem(enchantBag, this);
	CustomRegistry.registerItem(anvilBag, this);
	
	
	CustomRegistry.registerGUI(bagGUI, this);
	
}
 
开发者ID:benfah,项目名称:Bags2,代码行数:55,代码来源:Bags2.java

示例14: getKills

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static Integer getKills(String p) {
	File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
	FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
	int kills = pConfig.getInt("Kills");
	return Integer.valueOf(kills);
}
 
开发者ID:MohibMirza,项目名称:RPGPlus,代码行数:7,代码来源:Datafiles.java

示例15: getStone

import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public YamlConfiguration getStone() {
    return YamlConfiguration.loadConfiguration(fileStone);
}
 
开发者ID:cadox8,项目名称:PA,代码行数:4,代码来源:Files.java


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