本文整理汇总了Java中org.bukkit.configuration.Configuration.getConfigurationSection方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.getConfigurationSection方法的具体用法?Java Configuration.getConfigurationSection怎么用?Java Configuration.getConfigurationSection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.getConfigurationSection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: QuotaConfig
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
@Inject QuotaConfig(Configuration root) {
this.config = root.getConfigurationSection("match-quotas");
if(config == null) {
quotas = new TreeSet<>();
} else {
quotas = new TreeSet<>(Collections2.transform(
config.getKeys(false),
new Function<String, Entry>() {
@Override
public Entry apply(@Nullable String key) {
return new Entry(config.getConfigurationSection(key));
}
}
));
}
}
示例2: parse
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
public Set<RotationProviderInfo> parse(MapLibrary mapLibrary, Path dataPath, Configuration config) {
ConfigurationSection base = config.getConfigurationSection("rotation.providers.file");
if(base == null) return Collections.emptySet();
Set<RotationProviderInfo> providers = new HashSet<>();
for(String name : base.getKeys(false)) {
ConfigurationSection provider = base.getConfigurationSection(name);
Path rotationFile = Paths.get(provider.getString("path"));
if(!rotationFile.isAbsolute()) rotationFile = dataPath.resolve(rotationFile);
int priority = provider.getInt("priority", 0);
if(Files.isRegularFile(rotationFile)) {
providers.add(new RotationProviderInfo(new FileRotationProvider(mapLibrary, name, rotationFile, dataPath), name, priority));
} else if(minecraftService.getLocalServer().startup_visibility() == ServerDoc.Visibility.PUBLIC) {
// This is not a perfect way to decide whether or not to throw an error, but it's the best we can do right now
mapLibrary.getLogger().severe("Missing rotation file: " + rotationFile);
}
}
return providers;
}
示例3: loadConfig
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
public void loadConfig() {
Configuration configuration = YamlConfiguration.loadConfiguration(configFile);
ConfigurationSection bungeeSection;
if (configuration.contains("bungee")){
bungeeSection = configuration.getConfigurationSection("bungee");
} else {
getLogger().warning("The section 'bungee' in the configuration is not found, " +
"defaults will be assumed. Delete the config file and restart to have a " +
"clean valid configuration file.");
bungeeSection = configuration.createSection("bungee");
}
boolean serverSocketEnabled = configuration.getBoolean("server-socket", true);
boolean serverPortAuto = configuration.getBoolean("port-automatic", true);
int serverPort = configuration.getInt("port", 3112);
String host = bungeeSection.getString("host");
int port = bungeeSection.getInt("port");
char[] password = bungeeSection.getString("password", "").toCharArray();
int heartbeatSeconds = bungeeSection.getInt("heartbeat-seconds", 30);
int reconnectAttempts = bungeeSection.getInt("reconnect-attempts", 7);
bungeeMasterSpigotConfig = new BungeeMasterSpigotConfig(serverSocketEnabled, serverPortAuto, serverPort, host, port, password, heartbeatSeconds, reconnectAttempts);
}
示例4: ModConfig
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
/**
* Initialize mod config based on the configuration file
*
* @param config
*/
public ModConfig(Configuration config) {
m_isInitialized = false;
if (config == null) {
m_blocks = null;
m_mobs = null;
m_modIdRegex = null;
m_textureRes = 0;
m_versionRegex = null;
return;
}
m_name = config.getString("DisplayName", null);
m_blocks = config.getConfigurationSection("Blocks");
m_mobs = config.getConfigurationSection("Mobs");
m_modIdRegex = config.getString("ModId", null);
m_alternativeId = config.getString("ModIdAlternative", null);
m_versionRegex = config.getString("Version", null);
m_textureRes = config.getInt("TextureRes", 0);
}
示例5: inflateUnsafe
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
@Override
public void inflateUnsafe(Configuration config, Object[] args) throws ParseException {
List<String> lines = Lists.newArrayList();
ConfigurationSection layoutSection = config.getConfigurationSection("layout");
for (int i = 1; i <= SignLayout.LINE_COUNT; i++) {
String line = layoutSection.getString(String.valueOf(i));
lines.add(line);
}
layout = new SignLayout(lines);
if (config.contains("options")) {
options = config.getConfigurationSection("options");
}
}
示例6: inflate
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
@Override
public void inflate(Configuration config, Object... args) {
Validate.isTrue(args.length > 0, "args.length must be greater than 0");
Validate.isTrue(args[0] instanceof File, "args[0] must be an instance of " + File.class.getCanonicalName());
File baseDir = (File) args[0];
ConfigurationSection moduleSection = config.getConfigurationSection("database-modules");
this.statisticsEnabled = moduleSection.getBoolean("statistics.enabled");
this.maxStatisticCacheSize = moduleSection.getInt("statistics.max-cache-size", DEFAULT_MAX_CACHE_SIZE);
this.connections = Lists.newArrayList();
ConfigurationSection connectionsSection = config.getConfigurationSection("persistence-connection");
for (String key : connectionsSection.getKeys(false)) {
connections.add(new DatabaseConnection(connectionsSection.getConfigurationSection(key), baseDir));
}
}
示例7: inflateUnsafe
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
@Override
public final void inflateUnsafe(Configuration config, Object[] args) throws ParseException {
ConfigurationSection layoutSection = config.getConfigurationSection("layout");
String title;
List<String> lore;
if (layoutSection != null) {
title = layoutSection.getString("title", DEFAULT_TITLE);
lore = layoutSection.getStringList("lore");
if (lore == null || lore.isEmpty()) {
lore = DEFAULT_LORE;
}
} else {
title = DEFAULT_TITLE;
lore = DEFAULT_LORE;
}
layout = new InventoryEntryLayout(title, lore);
}
示例8: loadMapFromConfig
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
public static ConcurrentSkipListMap<String, String> loadMapFromConfig(Configuration config ,String sectionKeyName)
{
if (config == null)
{
return null;
}
if (sectionKeyName == null)
{
return null;
}
ConfigurationSection configSection =
config.getConfigurationSection(sectionKeyName);
if (configSection == null)
{
return null;
}
ConcurrentSkipListMap<String, String> resultMap =new ConcurrentSkipListMap<String, String>();
Map<String, Object> loadMap = configSection.getValues(false);
for (Map.Entry<String, Object> loadMapEntry : loadMap.entrySet())
{
resultMap.put(loadMapEntry.getKey(), (String)loadMapEntry.getValue());
}
return resultMap;
}
示例9: loadSets
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
/**
* Loads the CommandSets.
*
* @param config
* @return
*/
public static Map<String, CommandSet>[] loadSets(Configuration config) {
Map<String, CommandSet> sets = new HashMap<String, CommandSet>();
Map<String, CommandSet> commands = new HashMap<String, CommandSet>();
ConfigurationSection setsSection = config.getConfigurationSection("sets");
if (setsSection != null) {
for (String key : setsSection.getKeys(false)) {
// Get the set section
ConfigurationSection setSection = setsSection.getConfigurationSection(key);
CommandSet set = loadSet(key, setSection, commands);
if (set == null) {
log(Level.WARNING, "Invalid set configuration for set '" + key + "'. Skipping.");
continue;
}
sets.put(key, set);
// Add the commands to our mapping
for (String cmd : set.getCommands()) {
commands.put(cmd, set);
}
}
}
return new Map[]{sets, commands};
}
示例10: loadSetGroups
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
/**
* Loads all CommandSetGroups.
*
* @param config
* @param sets
* @return
*/
public static Map<String, CommandSetGroup> loadSetGroups(Configuration config, Map<String, CommandSet> sets) {
Map<String, CommandSetGroup> groups = new HashMap<String, CommandSetGroup>();
ConfigurationSection groupsSection = config.getConfigurationSection("groups");
if (groupsSection != null) {
for (String key : groupsSection.getKeys(false)) {
// Get the group section
ConfigurationSection groupSection = groupsSection.getConfigurationSection(key);
CommandSetGroup group = loadSetGroup(key, groupSection, sets);
if (group == null) {
log(Level.WARNING, "Invalid group configuration for group '" + key + "'. Skipping.");
continue;
}
groups.put(key, group);
}
}
if (!groups.containsKey("default")) {
log(Level.INFO, "There isn't a default group; creating one with no settings.");
groups.put("default", new CommandSetGroup("default", new HashMap<CommandSet, Integer>(), new HashMap<CommandSet, Integer>()));
}
return groups;
}
示例11: getPluginConfiguration
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
public List<String> getPluginConfiguration(String section) {
ArrayList<String> res = new ArrayList<String>();
Configuration config = SensibleToolboxPlugin.getInstance().getConfig();
ConfigurationSection cs = config.getRoot();
Set<String> items;
if (section == null) {
items = config.getDefaults().getKeys(true);
} else {
if (config.getDefaults().isConfigurationSection(section)) {
cs = config.getConfigurationSection(section);
items = config.getDefaults().getConfigurationSection(section).getKeys(true);
} else {
items = new HashSet<String>();
if (config.getDefaults().contains(section))
items.add(section);
}
}
for (String k : items) {
if (cs.isConfigurationSection(k))
continue;
res.add("&f" + k + "&- = '&e" + cs.get(k) + "&-'");
}
Collections.sort(res);
return res;
}
示例12: loadMessages
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
/**
* Loads messages from the config.
*
* @param config
* @return
*/
public static Map<String, String> loadMessages(Configuration config) {
Map<String, String> messages = new HashMap<String, String>();
ConfigurationSection messagesSection = config.getConfigurationSection("messages");
if (messagesSection != null) {
for (Map.Entry<String, Object> msg : messagesSection.getValues(false).entrySet()) {
messages.put(msg.getKey(), msg.getValue().toString());
}
}
return messages;
}
示例13: StartConfig
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
@Inject StartConfig(Configuration root) {
this.config = root.getConfigurationSection("start");
}
示例14: loadByConfiguration
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
public void loadByConfiguration(Configuration config) {
ConfigurationSection blockSection = config.getConfigurationSection("blocks");
acceptBlockData = ItemStackData.fromConfigString(blockSection.getString("accept", "ink_sack:10"), BLOCKDATA_SEPERATOR);
declineBlockData = ItemStackData.fromConfigString(blockSection.getString("decline", "ink_sack:1"), BLOCKDATA_SEPERATOR);
seperatorBlockData = ItemStackData.fromConfigString(blockSection.getString("seperator", "barrier"), BLOCKDATA_SEPERATOR);
moneyStatusBlockData = ItemStackData.fromConfigString(blockSection.getString("money-status", "gold_nugget"), BLOCKDATA_SEPERATOR);
moneyAddRemoveBlockData = ItemStackData.fromConfigString(blockSection.getString("money-add-remove", "gold_nugget"), BLOCKDATA_SEPERATOR);
xpStatusBlockData = ItemStackData.fromConfigString(blockSection.getString("xp-status", "exp_bottle"), BLOCKDATA_SEPERATOR);
xpAddRemoveBlockData = ItemStackData.fromConfigString(blockSection.getString("xp-add-remove", "exp_bottle"), BLOCKDATA_SEPERATOR);
ConfigurationSection localizationSection = config.getConfigurationSection("localization");
String localeString = localizationSection.getString("locale");
locale = parseLocale(localeString);
ConfigurationSection inventorySection = config.getConfigurationSection("inventory");
inventoryName = inventorySection.getString("name", "SimpleTrading - @p");
moneyValue1 = inventorySection.getInt("money-value-1", 50);
moneyValue2 = inventorySection.getInt("money-value-2", 100);
moneyValue3 = inventorySection.getInt("money-value-3", 500);
expValue1 = inventorySection.getInt("exp-value-1", 5);
expValue2 = inventorySection.getInt("exp-value-2", 50);
expValue3 = inventorySection.getInt("exp-value-3", 100);
ConfigurationSection globalSection = config.getConfigurationSection("global");
maximumTradeDistance = globalSection.getInt("max-distance", 15);
allowCreativeTrading = globalSection.getBoolean("creative-trading", true);
timeout = globalSection.getInt("timeout", 60);
useXpTrading = globalSection.getBoolean("use-xp-trading", true);
useMoneyTrading = globalSection.getBoolean("use-money-trading", true);
useShiftTrading = globalSection.getBoolean("use-shift-trading", true);
maxMoneyTrading = globalSection.getInt("max-money-trading", -1);
abortOnDecline = globalSection.getBoolean("abort-on-decline", false);
ConfigurationSection itemControlSection = config.getConfigurationSection("item-control");
itemControlMode = ControlMode.getMode(itemControlSection.getString("control-mode"), ControlMode.BLACKLIST);
List<String> controlItemStringList = itemControlSection.getStringList("item-list");
itemControlItems = Lists.newArrayList();
for (String controlItemString : controlItemStringList) {
itemControlItems.add(ItemStackData.fromConfigString(controlItemString, BLOCKDATA_SEPERATOR));
}
itemControlLores = itemControlSection.getStringList("item-lore");
ConfigurationSection worldControlSection = config.getConfigurationSection("world-control");
worldControlMode = ControlMode.getMode(worldControlSection.getString("control-mode"), ControlMode.BLACKLIST);
worldControlList = worldControlSection.getStringList("world-list");
}
示例15: validateWorldSection
import org.bukkit.configuration.Configuration; //导入方法依赖的package包/类
/**
* Validates a specific world's configuration.
*
* @param worldName The name of the world.
* @param config The root configuration.
* @param warnTo The player to complain to if something is wrong.
* @param plugin The instance of the plugin.
*/
private static void validateWorldSection(String worldName,
Configuration config, CommandSender warnTo, WDLCompanion plugin) {
String fullKey = "wdl.per-world." + worldName;
if (!config.isSet(fullKey)) {
warnTo.sendMessage("�e[WDL] WARNING: Per-world config validation " +
"issue -- tested wdl.per-world." + worldName + ", but it " +
"doesn't exist! This should NOT happen!");
return;
}
if (!config.isConfigurationSection(fullKey)) {
warnTo.sendMessage("�c[WDL] ERROR: Config setting " +
fullKey + " is not a mapping! The global values " +
"will be used instead!");
}
ConfigurationSection section = config.getConfigurationSection(fullKey);
validateIsBoolOrUnset("canDoNewThings", section, warnTo);
validateIsBoolOrUnset("canDownloadInGeneral", section, warnTo);
validateIsIntOrUnset("saveRadius", section, warnTo);
validateIsBoolOrUnset("canCacheChunks", section, warnTo);
validateIsBoolOrUnset("canSaveEntities", section, warnTo);
validateIsBoolOrUnset("canSaveTileEntities", section, warnTo);
validateIsBoolOrUnset("canSaveContainers", section, warnTo);
validateIsBoolOrUnset("sendEntityRanges", section, warnTo);
validateIsStringOrUnset("requestMessage", section, warnTo);
validateStringLength("requestMessage", section, 15000, warnTo);
List<String> keys = new ArrayList<>(section.getKeys(false));
keys.removeAll(worldConfigOptions);
if (!keys.isEmpty()) {
warnTo.sendMessage("�c[WDL] WARNING: There are config settings " +
"that are not recongised! They are:");
for (String key : keys) {
warnTo.sendMessage("�c[WDL] * " + section.getCurrentPath()
+ "." + key);
}
}
}