本文整理汇总了Java中org.bukkit.configuration.ConfigurationSection.getString方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationSection.getString方法的具体用法?Java ConfigurationSection.getString怎么用?Java ConfigurationSection.getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.configuration.ConfigurationSection
的用法示例。
在下文中一共展示了ConfigurationSection.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Currency
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public Currency(int id, ConfigurationSection section, MComponentManager manager){
this.id = id;
this.name = manager.get(section.getString(Node.NAME.get()));
this.single = manager.get(section.getString("SINGLE"));
this.alias = section.getString("ALIAS");
int type = section.getInt("FORMAT_TYPE", 0);
this.format = (DecimalFormat) NumberFormat.getNumberInstance( type == 0 ? Locale.GERMAN : type == 1 ? Locale.ENGLISH : Locale.FRENCH);
format.applyPattern(section.getString("FORMAT", "###,###.### "));
this.step = section.getDouble("STEP", 0.001);
double temp = ((int)(step*1000))/1000.0;
if(step < 0.001 || temp != step)
ErrorLogger.addError("Invalid step amount : " + step);
this.min = ((int)section.getDouble("MIN", 0)/step)*step;
this.max = ((int)section.getDouble("MAX", 9999999999.999)/step)*step;
this.allowPay = section.getBoolean("ALLOW_PAY", false);
this.useServer = section.getBoolean("USE_SERVER", false);
this.booster = 1.0;
}
示例2: CPTeleportLocation
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public CPTeleportLocation(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
online = section.getBoolean("ONLINE", false);
if(section.contains(Node.LOCATION.get())) {
ConfigurationSection temp = section.getConfigurationSection(Node.LOCATION.get());
ErrorLogger.addPrefix(Node.LOCATION.get());
loc = ConfigUtils.loadLocation(temp);
ErrorLogger.removePrefix();
}else if(section.contains(Node.WORLD.get())){
ErrorLogger.addPrefix(Node.WORLD.get());
String world = section.getString(Node.WORLD.get());
ErrorLogger.removePrefix();
if(world != null) {
World w = Bukkit.getWorld(world);
if(w != null) {
loc = w.getSpawnLocation();
}else
ErrorLogger.addError("World `" + world + "` wasn't found.");
}else
Error.INVALID.add();
}
}
示例3: readRemoteRepository
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
private static RemoteRepository readRemoteRepository(String id, ConfigurationSection config) {
String url = config.getString("url");
RemoteRepository.Builder builder = new RemoteRepository.Builder(id, "default", url);
ConfigurationSection authConfig = config.getConfigurationSection("authentication");
if (authConfig != null)
builder = builder.setAuthentication(readAuthentication(authConfig));
ConfigurationSection releasePolicyConfig = config.getConfigurationSection("release_policy");
if (releasePolicyConfig != null)
builder = builder.setReleasePolicy(readRepositoryPolicy(releasePolicyConfig));
ConfigurationSection snapshotPolicyConfig = config.getConfigurationSection("snapshot_policy");
if (snapshotPolicyConfig != null)
builder = builder.setSnapshotPolicy(readRepositoryPolicy(snapshotPolicyConfig));
return builder.build();
}
示例4: configureData
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
private boolean configureData(ConfigurationSection config) {
String host = config.getString("host", "localhost");
int port = config.getInt("port", 3306);
String dbname = config.getString("database", "cropcontrol");
String username = config.getString("user");
String password = config.getString("password");
int poolsize = config.getInt("poolsize", 5);
long connectionTimeout = config.getLong("connection_timeout", 10000l);
long idleTimeout = config.getLong("idle_timeout", 600000l);
long maxLifetime = config.getLong("max_lifetime", 7200000l);
try {
data = new ManagedDatasource(CropControl.getPlugin(), username, password, host, port, dbname,
poolsize, connectionTimeout, idleTimeout, maxLifetime);
data.getConnection().close();
} catch (Exception se) {
CropControl.getPlugin().info("Failed to initialize Database connection");
return false;
}
initializeTables();
stageUpdates();
long begin_time = System.currentTimeMillis();
try {
CropControl.getPlugin().info("Update prepared, starting database update.");
if (!data.updateDatabase()) {
CropControl.getPlugin().info( "Update failed, disabling plugin.");
return false;
}
} catch (Exception e) {
CropControl.getPlugin().severe("Update failed, disabling plugin. Cause:", e);
return false;
}
CropControl.getPlugin().info(String.format("Database update took %d seconds", (System.currentTimeMillis() - begin_time) / 1000));
activateDirtySave(config.getConfigurationSection("dirtysave"));
return true;
}
示例5: CPMenuOpen
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public CPMenuOpen(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
close = section.getBoolean("CLOSE", false);
if(close)return;
String menuName = section.getString(Node.MENU.get());
if(menuName == null || menuName.isEmpty()){
Error.MISSING_NODE.add(Node.MENU.get());
}else{
menu = VanillaPlusCore.getMenuManager().get(section.getString(Node.MENU.get()), true);
}
view = section.getBoolean("VIEW", false);
if(view)
argumentRequired = 1;
}
示例6: getGenerator
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public ChunkGenerator getGenerator(String world) {
ConfigurationSection section = configuration.getConfigurationSection("worlds");
ChunkGenerator result = null;
if (section != null) {
section = section.getConfigurationSection(world);
if (section != null) {
String name = section.getString("generator");
if ((name != null) && (!name.equals(""))) {
String[] split = name.split(":", 2);
String id = (split.length > 1) ? split[1] : null;
Plugin plugin = pluginManager.getPlugin(split[0]);
if (plugin == null) {
getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + split[0] + "' does not exist");
} else if (!plugin.isEnabled()) {
getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' is not enabled yet (is it load:STARTUP?)");
} else {
try {
result = plugin.getDefaultWorldGenerator(world, id);
if (result == null) {
getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName() + "' lacks a default world generator");
}
} catch (Throwable t) {
plugin.getLogger().log(Level.SEVERE, "Could not set generator for default world '" + world + "': Plugin '" + plugin.getDescription().getFullName(), t);
}
}
}
}
}
return result;
}
示例7: StatFood
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public StatFood(Short id, ConfigurationSection section, MComponentManager manager) {
super(id, section, manager);
food = section.getString("FOOD");
if(food == null || food.isEmpty()){
Error.MISSING_NODE.add("FOOD");
return;
}
Bukkit.getServer().getPluginManager().registerEvents(this, VanillaPlus.getInstance());
}
示例8: load
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
void load(ConfigurationSection config) throws InvalidConfigurationException {
final boolean enabled;
final BaseComponent title;
final ItemStack openButtonIcon;
final Map<Slot.Container, Button> buttons = new HashMap<>();
try {
enabled = config.getBoolean("enabled", false);
title = new TranslatableComponent(config.getString("title", "navigator.title"));
final ItemConfigurationParser itemParser = new ItemConfigurationParser(config);
openButtonIcon = itemParser.getItem(config, "icon", () -> new ItemStack(Material.SIGN));
if(enabled) {
final ConfigurationSection buttonSection = config.getSection("buttons");
for(String key : buttonSection.getKeys()) {
final Button button = new Button(buttonSection.getSection(key), itemParser);
buttons.put(button.slot, button);
}
}
} catch(InvalidConfigurationException e) {
buttons.values().forEach(Button::release);
throw e;
}
clear();
NavigatorInterface.this.enabled = enabled;
NavigatorInterface.this.title = title;
NavigatorInterface.this.openButtonIcon = openButtonIcon;
NavigatorInterface.this.buttons = ImmutableMap.copyOf(buttons);
NavigatorInterface.this.height = buttons.values()
.stream()
.mapToInt(button -> button.slot.getRow() + 1)
.max()
.orElse(0);
}
示例9: load
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public static void load(ConfigurationSection servers) {
for (String name : servers.getKeys(false)) {
String title = servers.getString(name + ".title");
String line_1 = servers.getString(name + ".line_1");
String line_2 = servers.getString(name + ".line_2");
String address = servers.getString(name + ".address");
new Game(Chat.colors(title), line_1, line_2, address);
}
Chat.log("Loaded " + Game.getList().size() + " games!");
}
示例10: Icon
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public Icon(ConfigurationSection section, MessageManager manager) {
if(section.getConfigurationSection(Node.ITEM.get())!=null){
ErrorLogger.addPrefix(Node.ITEM.get());
item = MinecraftUtils.loadItem(section.getConfigurationSection(Node.ITEM.get()));
ErrorLogger.removePrefix();
}
skullSelf = section.getBoolean("SKULL_SELF", false);
closeOnClick = section.getBoolean(Node.CLOSE.get(), false);
canMove = section.getBoolean(Node.MOVE.get(), false);
if(!canMove && item != null && item.getType() != Material.AIR)
item = MinecraftUtils.setExtra(item, FREEZE, "1");
if(item == null)
item = air;
if(skullSelf && item.getType() != Material.SKULL_ITEM)
skullSelf = false;
if(skullSelf)
item.setDurability((short) 3);
if(section.contains(Node.NAME_PATH.get())){
name = manager.getComponentManager().get(section.getString(Node.NAME_PATH.get()));
if(isStatic && name != null)
isStatic = false;
}
if(section.contains(Node.LORE_PATH.get())){
lore = new ArrayList<MComponent>();
if(!section.getStringList(Node.LORE_PATH.get()).isEmpty()) {
for(String key : section.getStringList(Node.LORE_PATH.get())){
MComponent temp = manager.getComponentManager().get(key);
if(temp == null)
continue;
lore.add(temp);
if(isStatic)
isStatic = false;
}
}else if(section.getString(Node.LORE_PATH.get()) != null) {
lore.add(manager.getComponentManager().get(section.getString(Node.LORE_PATH.get())));
}
}
}
示例11: BackpackType
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
BackpackType(ConfigurationSection config) {
super(config.getString("item"));
this.id = config.getName();
this.name = StringUtils.coloredLine(config.getString("name"));
this.lore = StringUtils.coloredLines(config.getStringList("lore"));
this.size = config.getInt("size") < 56 ? config.getInt("size") : 56;
this.createItem();
}
示例12: CPNick
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public CPNick(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
reset = manager.get(section.getString("RESET"));
resetOther = manager.get(section.getString("RESET_OTHER"));
resetTo = manager.get(section.getString("RESET_TO"));
allowColor = new Requirement(section.get("COLOR"), manager.getComponentManager());
allowCustomChar = new Requirement(section.get("CUSTOM_CHAR"), manager.getComponentManager());
prefix = section.getString("PREFIX", "");
argumentRequired = 1;
}
示例13: readRepositoryPolicy
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
private static RepositoryPolicy readRepositoryPolicy(ConfigurationSection config) {
boolean enabled = config.getBoolean("enabled", true);
String updatePolicy = config.getString("update", DEFAULT_POLICY.getUpdatePolicy());
String checksumPolicy = config.getString("checksum", DEFAULT_POLICY.getChecksumPolicy());
return new RepositoryPolicy(enabled, updatePolicy, checksumPolicy);
}
示例14: Stat
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public Stat(Short id, ConfigurationSection section, MComponentManager manager){
this.id = id;
this.alias = section.getString(Node.ALIAS.get());
this.name = manager.get(section.getString(Node.NAME_PATH.get()));
}
示例15: parseDragonLoot
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的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);
}
}