use of org.bukkit.configuration.ConfigurationSection in project Minigames by AddstarMC.
the class Rewards method save.
public void save(ConfigurationSection section) {
int index = 0;
for (RewardType item : items) {
ConfigurationSection itemSection = section.createSection(String.valueOf(index));
itemSection.set("type", item.getName());
itemSection.set("rarity", item.getRarity().name());
item.saveReward("data", itemSection);
index++;
}
for (RewardGroup group : groups) {
ConfigurationSection groupSection = section.createSection(group.getName());
group.save(groupSection);
}
}
use of org.bukkit.configuration.ConfigurationSection in project Minigames by AddstarMC.
the class ScoreboardData method loadDisplays.
public void loadDisplays(MinigameSave save, Minigame mgm) {
FileConfiguration con = save.getConfig();
ConfigurationSection root = con.getConfigurationSection(mgm.getName(false) + ".scoreboards");
if (root == null) {
return;
}
for (String key : root.getKeys(false)) {
ConfigurationSection displayConf = root.getConfigurationSection(key);
ScoreboardDisplay display = ScoreboardDisplay.load(mgm, displayConf);
if (display != null) {
addDisplay(display);
}
}
}
use of org.bukkit.configuration.ConfigurationSection in project Glowstone by GlowstoneMC.
the class CraftingManager method loadRecipes.
/**
* Load default recipes from built-in recipes.yml file.
*/
@SuppressWarnings("unchecked")
private void loadRecipes() {
// Load recipes from recipes.yml file
InputStream in = getClass().getClassLoader().getResourceAsStream("builtin/recipes.yml");
if (in == null) {
GlowServer.logger.warning("Could not find default recipes on classpath");
return;
}
ConfigurationSection config = YamlConfiguration.loadConfiguration(in);
// shaped
for (Map<?, ?> data : config.getMapList("shaped")) {
ItemStack resultStack = ItemStack.deserialize((Map<String, Object>) data.get("result"));
ShapedRecipe recipe = new ShapedRecipe(resultStack);
List<String> shape = (List<String>) data.get("shape");
recipe.shape(shape.toArray(new String[shape.size()]));
Map<String, Map<String, Object>> ingredients = (Map<String, Map<String, Object>>) data.get("ingredients");
for (Entry<String, Map<String, Object>> entry : ingredients.entrySet()) {
ItemStack stack = ItemStack.deserialize(entry.getValue());
recipe.setIngredient(entry.getKey().charAt(0), stack.getData());
}
shapedRecipes.add(recipe);
}
// shapeless
for (Map<?, ?> data : config.getMapList("shapeless")) {
ItemStack resultStack = ItemStack.deserialize((Map<String, Object>) data.get("result"));
ShapelessRecipe recipe = new ShapelessRecipe(resultStack);
List<Map<String, Object>> ingreds = (List<Map<String, Object>>) data.get("ingredients");
for (Map<String, Object> entry : ingreds) {
recipe.addIngredient(ItemStack.deserialize(entry).getData());
}
shapelessRecipes.add(recipe);
}
// furnace
for (Map<?, ?> data : config.getMapList("furnace")) {
ItemStack inputStack = ItemStack.deserialize((Map<String, Object>) data.get("input"));
ItemStack resultStack = ItemStack.deserialize((Map<String, Object>) data.get("result"));
float xp = ((Number) data.get("xp")).floatValue();
furnaceRecipes.add(new FurnaceRecipe(resultStack, inputStack.getType(), inputStack.getDurability(), xp));
}
}
use of org.bukkit.configuration.ConfigurationSection in project Glowstone by GlowstoneMC.
the class GlowHelpMap method loadConfig.
/**
* Reads the general topics from help.yml and adds them to the help index.
*
* @param config The configuration to read from.
*/
public void loadConfig(ConfigurationSection config) {
// general topics
ConfigurationSection general = config.getConfigurationSection("general-topics");
if (general != null) {
for (String key : general.getKeys(false)) {
ConfigurationSection topic = general.getConfigurationSection(key);
if (topic != null) {
String shortText = topic.getString("shortText", "");
String fullText = topic.getString("fullText", "");
if (!shortText.isEmpty()) {
if (fullText.isEmpty()) {
fullText = shortText;
} else {
fullText = shortText + "\n" + ChatColor.RESET + fullText;
}
}
addTopic(new GeneralHelpTopic(key, color(shortText), color(fullText), topic.getString("permission", null)));
}
}
}
// index topics
ConfigurationSection index = config.getConfigurationSection("index-topics");
if (index != null) {
for (String key : index.getKeys(false)) {
ConfigurationSection topic = index.getConfigurationSection(key);
if (topic != null) {
String shortText = color(topic.getString("shortText", ""));
String preamble = color(topic.getString("preamble", null));
String permission = topic.getString("permission", null);
HelpTopic helpTopic = new LazyIndexTopic(key, shortText, permission, topic.getStringList("commands"), preamble);
if (key.equals("Default")) {
defaultTopic = helpTopic;
} else {
addTopic(helpTopic);
}
}
}
}
// ignore plugins and command topics settings
ignoredPlugins.addAll(config.getStringList("ignore-plugins"));
commandsInIndex = config.getBoolean("command-topics-in-master-index", true);
}
use of org.bukkit.configuration.ConfigurationSection in project Glowstone by GlowstoneMC.
the class GlowServer method getCommandAliases.
@Override
public Map<String, String[]> getCommandAliases() {
Map<String, String[]> aliases = new HashMap<>();
ConfigurationSection section = config.getConfigFile(Key.COMMANDS_FILE).getConfigurationSection("aliases");
if (section == null) {
return aliases;
}
for (String key : section.getKeys(false)) {
List<String> list = section.getStringList(key);
aliases.put(key, list.toArray(new String[list.size()]));
}
return aliases;
}
Aggregations