當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。