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


Java YamlConfiguration类代码示例

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


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

示例1: copyDefaultNode

import org.bukkit.configuration.file.YamlConfiguration; //导入依赖的package包/类
public static void copyDefaultNode(YamlConfiguration configFile, Plugin plugin, String path, String nodPath){
	configFile.createSection(nodPath);
	path = fixPath(path);
	InputStream file = plugin.getResource(path.replace(File.separatorChar, '/'));
	if(file!=null){
		YamlConfiguration defaultFile = YamlConfiguration.loadConfiguration(new InputStreamReader(file));
		if(defaultFile.contains(nodPath))
			configFile.set(nodPath, defaultFile.get(path));
		else
			configFile.set(nodPath, Error.MISSING_NODE.getMessage());
	}
	File temp = new File(plugin.getDataFolder(), path);
	try {
		configFile.save(temp);
	} catch (IOException e) {
		e.printStackTrace();
		ErrorLogger.addError("I/O Exception for file : " + temp.getAbsolutePath());
	}
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:20,代码来源:ConfigUtils.java

示例2: getSpecialConfig

import org.bukkit.configuration.file.YamlConfiguration; //导入依赖的package包/类
/**
 * This method essentially imitates the getConfig method within the JavaPlugin class
 * but is used to create or grab special config files pertaining to the Wage Tables of
 * the plugin
 *
 * @param resource The file or resource to grab the Configuration for.
 *
 * @return The configuration of the resource.
 */
public YamlConfiguration getSpecialConfig (String resource)
{
    YamlConfiguration config = mWageConfigs.get (resource);

    if (config == null)
    {
        InputStream configStream = mPlugin.getResource (resource);
        config = YamlConfiguration.loadConfiguration (mWageFiles.get (resource));

        if (configStream != null)
        {
            config.setDefaults (YamlConfiguration.loadConfiguration (new InputStreamReader (configStream, Charsets.UTF_8)));
        }

        mWageConfigs.put (resource, config);
    }

    return config;
}
 
开发者ID:MagnaRisa,项目名称:CraftyProfessions,代码行数:29,代码来源:ConfigController.java

示例3: createConfig

import org.bukkit.configuration.file.YamlConfiguration; //导入依赖的package包/类
public void createConfig() {
	(new File("plugins" + File.separator + "AsgardAscension" + File.separator
			+ "")).mkdirs();
	file = new File("plugins" + File.separator + "AsgardAscension",
			"food.yml");
	config = YamlConfiguration.loadConfiguration(file);
	if(!file.exists()){
		config.options().header("Potion Effect Types: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionEffectType.html");
		config.addDefault("1.name", "Nidhogg�s Heart");
		config.addDefault("1.item", 372);
		config.addDefault("1.amount", 1);
		List<String> effects = new ArrayList<String>();
		effects.add("SPEED, 120, 2");
		config.addDefault("1.effects", effects);
		config.options().copyDefaults(true);
	}
	saveConfig();
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:19,代码来源:GodFoodFile.java

示例4: Menu

import org.bukkit.configuration.file.YamlConfiguration; //导入依赖的package包/类
public Menu(MessageManager messageManager, YamlConfiguration section) {
	ConfigurationSection settings = section.getConfigurationSection(Node.SETTINGS.get());
	if(settings == null){
		Error.MISSING_NODE.add(Node.SETTINGS.get());
		title = new MComponent(VanillaPlusCore.getDefaultLang(), " ");
		icons = new Icon[37];
		type = InventoryType.CHEST;
		refresh = 0;
		return;
	}else{
		title = messageManager.getComponentManager().get(settings.getString(Node.NAME_PATH.get()));
		type = InventoryType.valueOf(settings.getString(Node.TYPE.get(), "CHEST"));
		if(type == InventoryType.CHEST) {
			int size = settings.getInt("ROWS");
			if(size < 0 || size > 12)
				ErrorLogger.addError("ROWS must be between 0 and 12 inclulsive !");
			icons = new Icon[9*size+1];
		}
		else
			icons = new Icon[type.getDefaultSize()+1];
		refresh = (byte) settings.getInt("REFRESH", 0);
		
	}
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:25,代码来源:Menu.java

示例5: build

import org.bukkit.configuration.file.YamlConfiguration; //导入依赖的package包/类
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;
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:19,代码来源:ConfigurationBuilder.java

示例6: loadConfig

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

    file = new File(pl.getDataFolder(), "Config/Global/OnJoin/Gamemode-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,代码来源:ConfigGGM.java

示例7: savePlayersToDisk

import org.bukkit.configuration.file.YamlConfiguration; //导入依赖的package包/类
public void savePlayersToDisk() {
	YamlConfiguration config = file.returnYaml();
	if (mtPlayers.isEmpty())
		return;

	for (PlayerObject p : mtPlayers.values()) {
		String uuid = p.getUuid().toString();
		
		config.set(uuid + ".pk-state", p.getPkState().name());
		config.set(uuid + ".kills", p.getPlayerKills());
		config.set(uuid + ".ingame-name", p.getCurrentIngameName());
		config.set(uuid + ".in-geck-range", p.isPlayerInRangeOfGeck());
		config.set(uuid + ".last-player-kill", p.getLastPlayerKillTime());

		// if (config.get(uuid + ".first-join-time") == null)
		// config.set(uuid + ".first-join-time", p.getJoinTime());
	}
	mtPlayers.clear();
	file.save(config);
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:21,代码来源:PlayerManager.java

示例8: Metrics

import org.bukkit.configuration.file.YamlConfiguration; //导入依赖的package包/类
public Metrics() throws IOException {
    // load the config
    configurationFile = getConfigFile();
    configuration = YamlConfiguration.loadConfiguration(configurationFile);

    // add some defaults
    configuration.addDefault("opt-out", false);
    configuration.addDefault("guid", UUID.randomUUID().toString());
    configuration.addDefault("debug", false);

    // Do we need to create the file?
    if (configuration.get("guid", null) == null) {
        configuration.options().header("http://mcstats.org").copyDefaults(true);
        configuration.save(configurationFile);
    }

    // Load the guid then
    guid = configuration.getString("guid");
    debug = configuration.getBoolean("debug", false);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:21,代码来源:Metrics.java

示例9: 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

示例10: add

import org.bukkit.configuration.file.YamlConfiguration; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:23,代码来源:BungeeCordController.java

示例11: CheckAndDownloadPlugin

import org.bukkit.configuration.file.YamlConfiguration; //导入依赖的package包/类
public static void CheckAndDownloadPlugin() {
    if (ConfigMain.AutoUpdate == true) {
        try {
            // 整体获取
            File NetworkerFile = new File(EscapeLag.MainThis.getDataFolder(), "networkerlog");
            DowloadFile("http://www.relatev.com/files/EscapeLag/NetWorker.yml", NetworkerFile);
            YamlConfiguration URLLog = YamlConfiguration.loadConfiguration(NetworkerFile);
            // 检查插件并下载新版本
            EscapeLag.MainThis.getLogger().info("正在检查新版本插件,请稍等...");
            int NewVersion = URLLog.getInt("UpdateVersion");
            int NowVersion = Integer.valueOf("%BUILD_NUMBER%");
            if (NewVersion > NowVersion) {
                EscapeLag.MainThis.getLogger().info("插件检测到新版本 " + NewVersion + ",正在自动下载新版本插件...");
                DowloadFile("https://www.relatev.com/files/EscapeLag/EscapeLag.jar", EscapeLag.getPluginsFile());
                EscapeLag.MainThis.getLogger().info("插件更新版本下载完成!正在重启服务器!");
                Bukkit.shutdown();
            } else {
                EscapeLag.MainThis.getLogger().info("EscapeLag插件工作良好,暂无新版本检测更新。");
            }
            // 完成提示
            EscapeLag.MainThis.getLogger().info("全部网络工作都读取完毕了...");
        } catch (IOException ex) {
        }
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:26,代码来源:NetWorker.java

示例12: mockPlugin

import org.bukkit.configuration.file.YamlConfiguration; //导入依赖的package包/类
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    if (Bukkit.getServer() == null) {
        final Server server = mock(Server.class);
        when(server.getLogger()).thenReturn(Logger.getGlobal());
        Bukkit.setServer(server);
    }
    new File("PetBlocks.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("PetBlocks"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:24,代码来源:PlayerMetaSQLiteControllerIT.java

示例13: 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

示例14: save

import org.bukkit.configuration.file.YamlConfiguration; //导入依赖的package包/类
public boolean save(){
	YamlConfiguration recipe;
	 File f=new File(rs.getDataFolder()+File.separator+"SyntheticFormula"+File.separator+"FireCraftTable"+File.separator+name+".yml");
	if(!f.exists())try {f.createNewFile();} catch (IOException e1) {return false;}
	
	recipe=YamlConfiguration.loadConfiguration(f);
	recipe.set(name+".name", name);
	recipe.set(name+".time", time);
	recipe.set(name+".temperature", temperature);
	recipe.set(name+".maxTime", maxTime);
	recipe.set(name+".shape", shape);
	for(Character c:materials.keySet())
		recipe.set(name+".material."+c,materials.get(c) );
	for(int i=0;i<3;i++)
		recipe.set(name+".product."+i, product[i]);
	try {recipe.save(f);} catch (IOException e) {return false;}
	return true;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:19,代码来源:FireCraftTableRecipe.java

示例15: removeCraft

import org.bukkit.configuration.file.YamlConfiguration; //导入依赖的package包/类
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) {
  		//
  	}
  }
 
开发者ID:Slaymd,项目名称:CaulCrafting,代码行数:19,代码来源:CraftStorage.java


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