本文整理匯總了Java中org.bukkit.configuration.file.FileConfiguration.getConfigurationSection方法的典型用法代碼示例。如果您正苦於以下問題:Java FileConfiguration.getConfigurationSection方法的具體用法?Java FileConfiguration.getConfigurationSection怎麽用?Java FileConfiguration.getConfigurationSection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.configuration.file.FileConfiguration
的用法示例。
在下文中一共展示了FileConfiguration.getConfigurationSection方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadCommands
import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
/**
* Loads all of the startup commands from the plugin's configuration file.
* @param plugin the StartupCommands plugin instance
*/
public static void loadCommands(StartupCommands plugin) {
FileConfiguration config = plugin.getConfig();
if (config.getConfigurationSection("commands") == null) {
plugin.getLogger().info("There are no startup commands present.");
} else {
int delay = 0;
for (String command : config.getConfigurationSection("commands").getKeys(false)) {
delay = config.getInt("commands." + command + ".delay", 0);
// Try to create the command
try {
plugin.getCommands().add(new Command(command, delay));
} catch (IllegalArgumentException e) {
plugin.getLogger().severe(e.getMessage());
}
}
}
}
示例2: onEnable
import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
@Override
public void onEnable() {
world = Bukkit.createWorld(new WorldCreator(OpenUHC.WORLD_DIR_PREFIX + "lobby"));
// Read lobby yml if it exists
File lobbyFile = new File(OpenUHC.WORLD_DIR_PREFIX + "lobby/lobby.yml");
if (lobbyFile.exists()) {
FileConfiguration lobbyConfig = YamlConfiguration.loadConfiguration(lobbyFile);
ConfigurationSection spawn = lobbyConfig.getConfigurationSection("spawn");
if (spawn != null) {
double x = spawn.getDouble("x", 0);
double y = spawn.getDouble("y", 64);
double z = spawn.getDouble("z", 0);
double r = spawn.getDouble("r", 1);
this.spawn = new Vector(x, y, z);
radius = (float) r;
}
}
OpenUHC.registerEvents(this);
}
示例3: load
import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
private void load(JavaPlugin plugin) {
try {
final FileConfiguration configuration = new YamlConfiguration();
final File file = new File(plugin.getDataFolder(), "bungeecord_signs.yml");
if (!file.exists()) {
if (!file.createNewFile()) {
Bukkit.getLogger().log(Level.WARNING, "File cannot get created.");
}
}
configuration.load(file);
if (configuration.getConfigurationSection("signs") != null) {
final Map<String, Object> data = configuration.getConfigurationSection("signs").getValues(false);
for (final String s : data.keySet()) {
this.signs.add(new BungeeCordSignInfo.Container(((ConfigurationSection) data.get(s)).getValues(true)));
}
}
} catch (IOException | InvalidConfigurationException e) {
Bukkit.getLogger().log(Level.WARNING, "Save load location.", e);
}
}
示例4: reloadConfig
import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
public void reloadConfig(File configFile) {
extensionsToEngineName = new HashMap<>();
FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
ConfigurationSection section = config.getConfigurationSection("engines");
for (Map.Entry<String, Object> obj : section.getValues(false).entrySet())
extensionsToEngineName.put(obj.getKey(), obj.getValue().toString());
}
示例5: loadConfig
import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
private void loadConfig() {
FileConfiguration config = new YamlConfiguration();
try {
config.load(new File(getDataFolder(), "config.yml"));
config.options().copyDefaults(true);
String user = config.getString("jdbc-username", "root");
String password = config.getString("jdbc-password", "password");
String jdbcUrl = config.getString("jdbc-url", "jdbc:mysql://localhost:3306/minecraft");
databaseManager = new DatabaseManager(jdbcUrl, user, password);
databaseManager.connect();
ConfigurationSection definitions = config.getConfigurationSection("definitions");
for (String definitionKey : definitions.getKeys(false)) {
ConfigurationSection definition = definitions.getConfigurationSection(definitionKey);
int priority = definition.getInt("priority", 1);
ImageType type = ImageType.valueOf(definition.getString("type", ImageType.OVERLAY.name()));
String permission = definition.getString("permission");
List<String> images = definition.getStringList("images");
SpigotImageDetails imageDetails = new SpigotImageDetails(priority, type, permission, images);
imageHandler.addImage(imageDetails);
}
config.save(new File(getDataFolder(), "config.yml"));
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}
示例6: CheckManager
import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
/**
* Handle getting all the check data.
*
* @param configuration the configuration file.
*/
public CheckManager(FileConfiguration configuration) {
this.configuration = configuration;
for (CheckType check : CheckType.values()) {
String checkName = check.getCheckName().toLowerCase();
ConfigurationSection section = configuration.getConfigurationSection(checkName);
boolean isEnabled = configuration.getBoolean(checkName + ".enabled");
// if were not enabled, continue.
if (!isEnabled) {
continue;
}
// collect the violation levels from the config.
int banViolations = section.getInt("ban");
int cancelViolations = section.getInt("cancel-vl");
int notifyViolations = section.getInt("notify");
// populate the map with the new check data.
boolean cancelCheck = section.getBoolean("cancel");
CheckData data = new CheckData(notifyViolations, cancelViolations, banViolations, cancelCheck, banViolations > 0);
CHECK_DATA.put(check, data);
Arc.getPlugin().getLogger().info("Finished getting data for check: " + checkName);
}
}
示例7: reload
import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
/**
* Reload the configuration.
*/
public void reload(FileConfiguration configuration) {
this.configuration = configuration;
for (CheckType check : CheckType.values()) {
String checkName = check.getCheckName().toLowerCase();
ConfigurationSection section = configuration.getConfigurationSection(checkName);
boolean isEnabled = configuration.getBoolean(checkName + ".enabled");
// if were not enabled, continue.
if (!isEnabled) {
continue;
}
// collect the violation levels from the config.
int banViolations = section.getInt("ban");
int cancelViolations = section.getInt("cancel-vl");
int notifyViolations = section.getInt("notify");
// populate the map with the new check data.
boolean cancelCheck = section.getBoolean("cancel");
CHECK_DATA.remove(check);
CheckData data = new CheckData(notifyViolations, cancelViolations, banViolations, cancelCheck, banViolations > 0);
CHECK_DATA.put(check, data);
Arc.getPlugin().getLogger().info("Finished getting data for check: " + checkName);
}
}
示例8: onEnable
import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
@Override
public void onEnable() {
tgm = this;
FileConfiguration fileConfiguration = getConfig();
saveDefaultConfig();
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(MapInfo.class, new MapInfoDeserializer());
this.gson = gsonBuilder.create();
ConfigurationSection apiConfig = fileConfiguration.getConfigurationSection("api");
if (apiConfig.getBoolean("enabled")) {
teamClient = new HttpClient(new HttpClientConfig() {
@Override
public String getBaseUrl() {
return apiConfig.getString("url");
}
@Override
public String getAuthToken() {
return apiConfig.getString("auth");
}
});
} else {
teamClient = new OfflineClient();
}
this.commands = new CommandsManager<CommandSender>() {
@Override
public boolean hasPermission(CommandSender sender, String perm) {
return sender instanceof ConsoleCommandSender || sender.hasPermission(perm);
}
};
matchManager = new MatchManager(fileConfiguration);
playerManager = new PlayerManager();
joinManager = new JoinManager();
// playerListManager = new PlayerListManager();
tracker = new TrackerPlugin(this);
grave = new GravePlugin(this);
apiManager = new ApiManager();
this.commandManager = new CommandsManagerRegistration(this, this.commands);
commandManager.register(CycleCommands.class);
GameRuleModule.setGameRules(Bukkit.getWorlds().get(0)); //Set gamerules in main unused world
try {
matchManager.cycleNextMatch();
} catch (IOException e) {
e.printStackTrace();
}
}
示例9: onLoad
import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
@SuppressWarnings("ResultOfMethodCallIgnored")
@Override
public void onLoad() {
instance = this;
if (!working) return;
dependencyFolder = new File(getDataFolder(), "Dependencies");
if (!dependencyFolder.exists()) dependencyFolder.mkdirs();
saveDefaultConfig();
FileConfiguration config = getConfig();
showDebug = config.getBoolean("options.showDebug", false);
enforceFileCheck = config.getBoolean("options.showDebug", true);
Urls.addRepositories(config.getStringList("options.repositories"));
PluginDescriptionFile pluginDesc = getDescription();
log(Level.INFO,
" ", " ",
blockBar(45),
"< ",
"< Dependency Loader " + pluginDesc.getVersion() + " by - " + pluginDesc.getAuthors(),
"< ",
"< Showing Debug Messages? -> " + showDebug,
"< Enforcing File Check? -> " + enforceFileCheck,
"< ",
blockBar(45),
" ", " ");
ConfigurationSection configDeps = config.getConfigurationSection("dependencies");
if (configDeps == null) return;
Set<String> keys = configDeps.getKeys(false);
keys.forEach(name -> {
String groupId = configDeps.getString(name + ".group", "");
String version = configDeps.getString(name + ".version", "");
String artifactId = configDeps.getString(name + ".artifact", "");
String customRepo = configDeps.getString(name + ".repository", "");
boolean alwaysUpdate = configDeps.getBoolean(name + ".always-update", false);
if (version.isEmpty() || groupId.isEmpty() || artifactId.isEmpty()) {
log(Level.SEVERE,
" ", " ",
blockBar(45),
"< ",
"< Dependency " + name + " has incomplete details",
"< Requires, case-sensitive",
"< 'version', 'group', 'artifact'",
"< ",
blockBar(45),
" ", " ");
} else {
final Dependency dependency = new Dependency(name.toLowerCase(), version, groupId, artifactId, customRepo, alwaysUpdate);
if (dependencies.containsValue(dependency)) debug("Dependency " + name + " has a duplicate");
debug("Attempting load of Dependency " + name + " From Config");
load(dependency);
}
});
}
示例10: loadLadders
import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
private void loadLadders() {
FileConfiguration config = gameConfig.getConfig();
if (config.getConfigurationSection("ladder") == null) {
PracticePlugin.getInstance().getLogger().info("There are no ladders stored in the configuration.");
return;
}
for (String s : config.getConfigurationSection("ladder").getKeys(false)) {
try {
Ladder ladder = new Ladder(s);
if (!config.contains("ladder." + s + ".displayName")) {
ladder.setDisplayName(s);
} else {
ladder.setDisplayName(config.getString("ladder." + s + ".displayName"));
}
if (config.contains("ladder." + s + ".displayIcon")) {
ladder.setDisplayIcon(InventoryUtils.itemStackFromString(config.getString("ladder." + s + ".displayIcon")));
} else {
ladder.setDisplayIcon(new ItemStack(Material.DIAMOND_SWORD));
}
if (config.contains("ladder." + s + ".displayOrder")) {
ladder.setDisplayOrder(config.getInt("ladder." + s + ".displayOrder"));
} else {
ladder.setDisplayOrder(0);
}
ladder.setDefaultInventory(InventoryUtils.playerInventoryFromString(config.getString("ladder." + s + ".defaultInventory")));
if (config.contains("ladder." + s + ".hitDelay")) {
ladder.setHitDelay(config.getInt("ladder." + s + ".hitDelay"));
}
if (config.getString("ladder." + s + ".allowEdit") != null) {
ladder.allowEdit(config.getBoolean("ladder." + s + ".allowEdit"));
}
if (config.getString("ladder." + s + ".allowHeal") != null) {
ladder.allowHeal(config.getBoolean("ladder." + s + ".allowHeal"));
}
if (config.getString("ladder." + s + ".allowHunger") != null) {
ladder.allowHunger(config.getBoolean("ladder." + s + ".allowHunger"));
}
ladders.put(s, ladder);
ManagerHandler.getStorageBackend().addColumn(ladder.getName());
}
catch (Exception e) {
PracticePlugin.getInstance().getLogger().severe("[ARENAS] Failed to load arena '" + s + "'!");
}
}
}
示例11: parseDragonLoot
import org.bukkit.configuration.file.FileConfiguration; //導入方法依賴的package包/類
private void parseDragonLoot() {
if (template.file == null) return; // No file to parse loot from
Logger logger = JavaPlugin.getPlugin(DragonEggDrop.class).getLogger();
FileConfiguration dragonFile = template.configFile;
// Parse the basic loot rewards (i.e. spawn chances & names)
this.eggSpawnChance = dragonFile.getDouble("egg-spawn-chance", 100.0);
this.eggName = ChatColor.translateAlternateColorCodes('&', dragonFile.getString("egg-name", "%dragon%&r's Egg"));
this.eggLore = dragonFile.getStringList("egg-lore").stream()
.map(s -> ChatColor.translateAlternateColorCodes('&', s))
.collect(Collectors.toList());
this.chestSpawnChance = dragonFile.getDouble("chest-spawn-chance", 0);
this.chestName = dragonFile.getString("chest-name", "Loot Chest");
this.minLootGen = dragonFile.getInt("min-loot");
this.maxLootGen = dragonFile.getInt("max-loot");
this.commands = dragonFile.getStringList("death-commands");
// Parse loot items
ConfigurationSection lootSection = dragonFile.getConfigurationSection("loot");
if (lootSection == null) return;
for (String itemKey : lootSection.getKeys(false)) {
// Parse root values (type, damage, amount and weight)
double weight = lootSection.getDouble(itemKey + ".weight");
Material type = EnumUtils.getEnum(Material.class, lootSection.getString(itemKey + ".type").toUpperCase());
byte data = (byte) lootSection.getInt(itemKey + ".data");
short damage = (short) lootSection.getInt(itemKey + ".damage");
int amount = lootSection.getInt(itemKey + ".amount");
if (type == null) {
logger.warning("Invalid material type \"" + lootSection.getString(itemKey + ".type") + "\". Ignoring loot value...");
continue;
}
// Create new item stack with passed values
@SuppressWarnings("deprecation")
ItemStack item = new ItemStack(type, 1, damage, data);
item.setAmount(amount);
// Parse meta
String displayName = lootSection.getString(itemKey + ".display-name");
List<String> lore = lootSection.getStringList(itemKey + ".lore");
Map<Enchantment, Integer> enchantments = new HashMap<>();
// Enchantment parsing
if (lootSection.contains(itemKey + ".enchantments")) {
for (String enchant : lootSection.getConfigurationSection(itemKey + ".enchantments").getKeys(false)) {
Enchantment enchantment = Enchantment.getByName(enchant);
int level = lootSection.getInt(itemKey + ".enchantments." + enchant);
if (enchantment == null || level == 0) {
logger.warning("Invalid enchantment \"" + enchant + "\" with level " + level);
continue;
}
enchantments.put(enchantment, level);
}
}
// Meta updating
ItemMeta meta = item.getItemMeta();
if (displayName != null) meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayName));
if (!lore.isEmpty()) meta.setLore(lore.stream().map(s -> ChatColor.translateAlternateColorCodes('&', s)).collect(Collectors.toList()));
enchantments.forEach((e, level) -> meta.addEnchant(e, level, true));
item.setItemMeta(meta);
this.loot.add(weight, item);
}
}