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


Java CommentedYamlConfiguration类代码示例

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


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

示例1: getItemAmount

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
/**
 * Extracts the item reward amount from the configuration.
 *
 * @param path
 * @return the amount for an item reward
 */
private int getItemAmount(String path) {
	CommentedYamlConfiguration config = plugin.getPluginConfig();
	int itemAmount = 0;
	if (config.getKeys(true).contains(path + ".Item.Amount")) {
		// Old config syntax.
		itemAmount = config.getInt(path + ".Item.Amount", 0);
	} else if (config.getKeys(true).contains(path + ".Item")) {
		// New config syntax. Name of item and quantity are on the same line, separated by a space.
		String materialAndQty = config.getString(path + ".Item", "");
		int indexOfAmount = materialAndQty.indexOf(' ');
		if (indexOfAmount != -1) {
			String intString = materialAndQty.substring(indexOfAmount + 1).trim();
			int indexOfName = intString.indexOf(' ');
			if (indexOfName != -1) {
				itemAmount = Integer.parseInt(intString.split(" ")[0]);
			} else {
				itemAmount = Integer.parseInt(intString);
			}
		}
	}
	return itemAmount;
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:29,代码来源:RewardParser.java

示例2: extractDisabledCategories

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
/**
 * Extracts disabled categories from the configuration file.
 * 
 * @param config
 * 
 * @return the set containing the names of the disabled categories
 */
public Set<String> extractDisabledCategories(CommentedYamlConfiguration config) {
	Set<String> disabledCategorySet = new HashSet<>(config.getList("DisabledCategories"));
	// Need PetMaster with a minimum version of 1.4 for PetMasterGive and PetMasterReceive categories.
	if ((!disabledCategorySet.contains(NormalAchievements.PETMASTERGIVE.toString())
			|| !disabledCategorySet.contains(NormalAchievements.PETMASTERRECEIVE.toString()))
			&& (!Bukkit.getPluginManager().isPluginEnabled("PetMaster")
					|| Integer.parseInt(Character.toString(Bukkit.getPluginManager().getPlugin("PetMaster")
							.getDescription().getVersion().charAt(2))) < 4)) {
		disabledCategorySet.add(NormalAchievements.PETMASTERGIVE.toString());
		disabledCategorySet.add(NormalAchievements.PETMASTERRECEIVE.toString());
		getLogger().warning("Overriding configuration: disabling PetMasterGive and PetMasterReceive categories.");
		getLogger().warning(
				"Ensure you have placed Pet Master with a minimum version of 1.4 in your plugins folder or add PetMasterGive and PetMasterReceive to the DisabledCategories list in config.yml.");
	}
	// Elytras introduced in Minecraft 1.9.
	if (!disabledCategorySet.contains(NormalAchievements.DISTANCEGLIDING.toString()) && version < 9) {
		disabledCategorySet.add(NormalAchievements.DISTANCEGLIDING.toString());
		getLogger().warning("Overriding configuration: disabling DistanceGliding category.");
		getLogger().warning(
				"Elytra are not available in your Minecraft version, please add DistanceGliding to the DisabledCategories list in config.yml.");
	}
	// Llamas introduced in Minecraft 1.11.
	if (!disabledCategorySet.contains(NormalAchievements.DISTANCELLAMA.toString()) && version < 11) {
		disabledCategorySet.add(NormalAchievements.DISTANCELLAMA.toString());
		getLogger().warning("Overriding configuration: disabling DistanceLlama category.");
		getLogger().warning(
				"Llamas not available in your Minecraft version, please add DistanceLlama to the DisabledCategories list in config.yml.");
	}
	// Breeding event introduced in Spigot 1319 (Minecraft 1.10.2).
	if (!disabledCategorySet.contains(MultipleAchievements.BREEDING.toString()) && version < 10) {
		disabledCategorySet.add(MultipleAchievements.BREEDING.toString());
		getLogger().warning("Overriding configuration: disabling Breeding category.");
		getLogger().warning(
				"The breeding event is not available in your server version, please add Breeding to the DisabledCategories list in config.yml.");
	}

	return disabledCategorySet;
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:46,代码来源:AdvancedAchievements.java

示例3: updateOldGUI

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
/**
 * Updates GUI file from older plugin versions by adding missing parameters. New configuration file introduced in
 * version 5.0 of the plugin.
 *
 * @param gui
 */
public void updateOldGUI(CommentedYamlConfiguration gui) {
	updatePerformed = false;

	// Added in version 5.2.5:
	updateSetting(gui, "Breeding.Item", "wheat");
	updateSetting(gui, "Breeding.Metadata", 0);

	// Added in version 5.3:
	updateSetting(gui, "AchievementNotStarted.Item", "stained_clay");
	updateSetting(gui, "AchievementNotStarted.Metadata", 14);
	updateSetting(gui, "AchievementStarted.Item", "stained_clay");
	updateSetting(gui, "AchievementStarted.Metadata", 4);
	updateSetting(gui, "AchievementReceived.Item", "stained_clay");
	updateSetting(gui, "AchievementReceived.Metadata", 5);
	updateSetting(gui, "BackButton.Item", "book");
	updateSetting(gui, "BackButton.Metadata", 0);
	updateSetting(gui, "PreviousButton.Item", "wood_button");
	updateSetting(gui, "PreviousButton.Metadata", 0);
	updateSetting(gui, "NextButton.Item", "stone_button");
	updateSetting(gui, "NextButton.Metadata", 0);

	// Added in version 5.5:
	updateSetting(gui, "Custom.Item", "feather");
	updateSetting(gui, "Custom.Metadata", 0);

	if (updatePerformed) {
		// Changes in the gui file: save and do a fresh load.
		try {
			gui.saveConfiguration();
			gui.loadConfiguration();
		} catch (IOException | InvalidConfigurationException e) {
			plugin.getLogger().log(Level.SEVERE, "Error while saving changes to the gui file:", e);
		}
	}
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:42,代码来源:FileUpdater.java

示例4: addNewCategory

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
/**
 * Adds a new category to the configuration file, and includes it in the DisabledCategories list.
 *
 * @param config
 * @param categoryName
 * @param categoryComment
 */
private void addNewCategory(CommentedYamlConfiguration config, String categoryName, String categoryComment) {
	if (!config.getKeys(false).contains(categoryName)) {
		Map<Object, Object> emptyMap = new HashMap<>();
		config.set(categoryName, emptyMap, categoryComment);
		// As no achievements are set, we initially disable this new category.
		List<String> disabledCategories = config.getList("DisabledCategories");
		disabledCategories.add(categoryName);
		config.set("DisabledCategories", disabledCategories);
		updatePerformed = true;
	}
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:19,代码来源:FileUpdater.java

示例5: getPluginConfig

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
public CommentedYamlConfiguration getPluginConfig() {
	return config;
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:4,代码来源:AdvancedAchievements.java

示例6: setPluginConfig

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
public void setPluginConfig(CommentedYamlConfiguration config) {
	this.config = config;
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:4,代码来源:AdvancedAchievements.java

示例7: getPluginLang

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
public CommentedYamlConfiguration getPluginLang() {
	return lang;
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:4,代码来源:AdvancedAchievements.java

示例8: setPluginLang

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
public void setPluginLang(CommentedYamlConfiguration lang) {
	this.lang = lang;
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:4,代码来源:AdvancedAchievements.java

示例9: getPluginGui

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
public CommentedYamlConfiguration getPluginGui() {
	return gui;
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:4,代码来源:AdvancedAchievements.java

示例10: setGui

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
public void setGui(CommentedYamlConfiguration gui) {
	this.gui = gui;
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:4,代码来源:AdvancedAchievements.java

示例11: updateLang

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
private void updateLang(CommentedYamlConfiguration file, Lang lang) {
	updateSetting(file, lang.toLangKey(), lang.toLangDefault());
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:4,代码来源:FileUpdater.java

示例12: executeCommand

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
@Override
protected void executeCommand(CommandSender sender, String[] args) {
	plugin.reloadConfig();

	try {
		CommentedYamlConfiguration config = plugin.loadAndBackupFile("config.yml");

		// Compare the DisabledCategories configuration list in the previous configuration file and the new one.
		Set<String> disabledCategorySet = plugin.extractDisabledCategories(config);
		if (!disabledCategorySet.equals(plugin.getDisabledCategorySet())) {
			if (sender instanceof Player) {
				sender.sendMessage(langServerRestartReload);
			}
			plugin.getLogger().warning("DisabledCategories list was modified. " +
					"Server must be fully reloaded or restarted for your changes to take effect.");
			plugin.getLogger().warning("Aborting plugin reload.");
			return;
		}

		plugin.setPluginConfig(config);
		String langFileName = plugin.getPluginConfig().getString("LanguageFileName", "lang.yml");
		plugin.setPluginLang(plugin.loadAndBackupFile(langFileName));
		plugin.setGui(plugin.loadAndBackupFile("gui.yml"));
	} catch (PluginLoadError e) {
		if (sender instanceof Player) {
			sender.sendMessage(langConfigReloadFailed);
		}
		plugin.getLogger().log(Level.SEVERE,
				"A non recoverable error was encountered while reloading the plugin, disabling it:", e);
		Bukkit.getServer().getPluginManager().disablePlugin(plugin);
		return;
	}

	// Reload all observers.
	reloadableObservers.forEach(Reloadable::extractConfigurationParameters);

	if (sender instanceof Player) {
		sender.sendMessage(langConfigSuccessfullyReloaded);
	}
	plugin.getLogger().info("Configuration successfully reloaded.");

}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:43,代码来源:ReloadCommand.java

示例13: withPluginConfig

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
public MockUtility withPluginConfig(String fileName) throws Exception {
	withPluginFile(fileName);
	CommentedYamlConfiguration config = new CommentedYamlConfiguration(fileName, pluginMock);
	when(pluginMock.getPluginConfig()).thenReturn(config);
	return this;
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:7,代码来源:MockUtility.java

示例14: withPluginLang

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
public MockUtility withPluginLang() throws Exception {
	withPluginFile("lang.yml");
	CommentedYamlConfiguration lang = new CommentedYamlConfiguration("lang.yml", pluginMock);
	when(pluginMock.getPluginLang()).thenReturn(lang);
	return this;
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:7,代码来源:MockUtility.java

示例15: updateSetting

import com.hm.mcshared.file.CommentedYamlConfiguration; //导入依赖的package包/类
/**
 * Updates the configuration file to include a new setting with its default value and its comments (each comment
 * String corresponding to a separate line).
 *
 * @param file
 * @param name
 * @param value
 * @param comments
 */
private void updateSetting(CommentedYamlConfiguration file, String name, Object value, String... comments) {
	if (!file.getKeys(true).contains(name)) {
		file.set(name, value, comments);
		updatePerformed = true;
	}
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:16,代码来源:FileUpdater.java


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