本文整理汇总了Java中org.bukkit.configuration.ConfigurationSection类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationSection类的具体用法?Java ConfigurationSection怎么用?Java ConfigurationSection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationSection类属于org.bukkit.configuration包,在下文中一共展示了ConfigurationSection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: link
import org.bukkit.configuration.ConfigurationSection; //导入依赖的package包/类
public static void link(Player p, int tsDbId){
String uuid = p.getUniqueId().toString();
UtilsStorage storageType = Utils.getStorageType();
if(storageType == UtilsStorage.FILE){
if(!isLinked(p)){
ConfigurationSection cs = UltimateTs.linkedPlayers.getConfigurationSection("linked");
cs.set(uuid, tsDbId);
UltimateTs.linkedPlayers.save();
}
}else if(storageType == UtilsStorage.SQL){
if(!UltimateTs.main().sql.isUUIDLinked(uuid)){
UltimateTs.main().sql.validLink(uuid, tsDbId);
}
}
assignRanks(p, tsDbId);
}
示例2: from
import org.bukkit.configuration.ConfigurationSection; //导入依赖的package包/类
public static RootConfig from(String index) {
RootConfig config = rootConfigs.get(index);
if (config != null) {
return config;
}
config = new RootConfig();
config.index = index;
config.baseSection = CropControl.getPlugin().getConfig().getConfigurationSection(index);
if (config.baseSection != null) {
ConfigurationSection drops = config.baseSection.getConfigurationSection("drops");
if (drops != null) {
config.baseDrops = new ConcurrentHashMap<String, DropModifiers>();
for (String key : drops.getKeys(false)) {
DropConfig.byIdent(key); // preload it.
config.baseDrops.put(key, config.new DropModifiers(drops.getConfigurationSection(key)));
}
}
}
rootConfigs.put(index, config);
return config;
}
示例3: craftPotionEffect
import org.bukkit.configuration.ConfigurationSection; //导入依赖的package包/类
public static PotionEffect craftPotionEffect(String name, ConfigurationSection section) {
if(section == null){
Error.MISSING.add();
return null;
}
PotionEffectType effect = PotionEffectType.getByName(name);
if( effect == null ) {
ErrorLogger.addError(name + " is not a valid potion effect type !");
return null;
}
int duration = section.getInt(Node.DURATION.get(), 120)*20;
int amplifier = section.getInt(Node.LEVEL.get(), 1) - 1;
boolean ambient = section.getBoolean(Node.AMBIANT.get(), true);
boolean particles = section.getBoolean(Node.PARTICLE.get(), true);
return new PotionEffect(effect, duration, amplifier, ambient, particles);
}
示例4: CPChannelSet
import org.bukkit.configuration.ConfigurationSection; //导入依赖的package包/类
public CPChannelSet(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
channel = VanillaPlusCore.getChannelManager().get(section.getString(Node.CHANNEL.get()), true);
switchState = section.getBoolean(Node.SWITCH.get(), false);
if(!switchState)
leave = section.getBoolean(Node.LEAVE.get(), false);
if(leave || switchState) {
this.canceled = manager.get(section.getString("CANCELED"));
this.canceledOther = manager.get(section.getString("CANCELED_OTHER"));
this.canceledTo = manager.get(section.getString("CANCELED_TO"));
return;
}
join = section.getBoolean(Node.JOIN.get(), false);
set = section.getBoolean(Node.SET.get(), false);
if(!join && !set)
Error.INVALID.add();
}
示例5: unlink
import org.bukkit.configuration.ConfigurationSection; //导入依赖的package包/类
public static void unlink(Player p){
String uuid = p.getUniqueId().toString();
UtilsStorage storageType = Utils.getStorageType();
removeRanks(p);
if(storageType == UtilsStorage.FILE){
if(isLinked(p)){
ConfigurationSection cs = UltimateTs.linkedPlayers.getConfigurationSection("linked");
cs.set(uuid, 0);
UltimateTs.linkedPlayers.save();
}
}else if(storageType == UtilsStorage.SQL){
if(UltimateTs.main().sql.isUUIDLinked(uuid)){
UltimateTs.main().sql.unlink(uuid);
}
}
}
示例6: getIndexTopics
import org.bukkit.configuration.ConfigurationSection; //导入依赖的package包/类
/**
* Extracts a list of all index topics from help.yml
*
* @return A list of index topics.
*/
public List<HelpTopic> getIndexTopics() {
List<HelpTopic> topics = new LinkedList<HelpTopic>();
ConfigurationSection indexTopics = helpYaml.getConfigurationSection("index-topics");
if (indexTopics != null) {
for (String topicName : indexTopics.getKeys(false)) {
ConfigurationSection section = indexTopics.getConfigurationSection(topicName);
String shortText = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("shortText", ""));
String preamble = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("preamble", ""));
String permission = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("permission", ""));
List<String> commands = section.getStringList("commands");
topics.add(new CustomIndexHelpTopic(server.getHelpMap(), topicName, shortText, permission, commands, preamble));
}
}
return topics;
}
示例7: stats
import org.bukkit.configuration.ConfigurationSection; //导入依赖的package包/类
private static void stats()
{
disableStatSaving = getBoolean( "stats.disable-saving", false );
if ( !config.contains( "stats.forced-stats" ) ) {
config.createSection( "stats.forced-stats" );
}
ConfigurationSection section = config.getConfigurationSection( "stats.forced-stats" );
for ( String name : section.getKeys( true ) )
{
if ( section.isInt( name ) )
{
forcedStats.put( name, section.getInt( name ) );
}
}
if ( disableStatSaving && section.getInt( "achievement.openInventory", 0 ) < 1 )
{
Bukkit.getLogger().warning( "*** WARNING *** stats.disable-saving is true but stats.forced-stats.achievement.openInventory" +
" isn't set to 1. Disabling stat saving without forcing the achievement may cause it to get stuck on the player's " +
"screen." );
}
}
示例8: CPChannelState
import org.bukkit.configuration.ConfigurationSection; //导入依赖的package包/类
public CPChannelState(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
channel = VanillaPlusCore.getChannelManager().get(section.getString(Node.CHANNEL.get()), true);
switchIn = section.getBoolean("SWITCH_IN", false);
switchOut = section.getBoolean("SWITCH_OUT", false);
if(!switchIn){
muteIn = section.getBoolean("MUTE_IN", false);
if(!muteIn)
unmuteIn = section.getBoolean("UNMUTE_IN", false);
}
if(!switchOut){
muteOut = section.getBoolean("MUTE_OUT", false);
if(!muteOut)
unmuteOut = section.getBoolean("UNMUTE_OUT", false);
}
if(!( switchIn || switchOut || muteIn || muteOut || unmuteIn || unmuteOut ))
Error.INVALID.add();
}
示例9: parse
import org.bukkit.configuration.ConfigurationSection; //导入依赖的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;
}
示例10: addMeta
import org.bukkit.configuration.ConfigurationSection; //导入依赖的package包/类
public static ItemStack addMeta(ConfigurationSection section, ItemStack item){
NBTItem nbtItem = new NBTItem(item);
for(String key : section.getKeys(false)){
Object value = section.get(key);
if(value instanceof Integer){
nbtItem.setInteger(key, (int)value);
}else if(value instanceof Double){
nbtItem.setDouble(key, (double)value);
}else if(value instanceof Boolean){
nbtItem.setBoolean(key, (boolean)value);
}else if(value instanceof String){
nbtItem.setString(key, (String)value);
}else if(value instanceof ConfigurationSection) {
NBTCompound compound = nbtItem.getCompound(key);
if(compound == null)
compound = nbtItem.addCompound(key);
applyCompound((ConfigurationSection) value, compound);
}
}
return nbtItem.getItem();
}
示例11: CPGamemode
import org.bukkit.configuration.ConfigurationSection; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public CPGamemode(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
ErrorLogger.addPrefix("GAMEMODE");
Object o = section.get("GAMEMODE");
if(o instanceof Integer){
gm = GameMode.getByValue((int) o);
if(gm == null){
Error.INVALID.add();
}
}else if(o instanceof String){
gm = GameMode.valueOf((String) o);
if(gm == null){
Error.INVALID.add();
}
}else {
gm = GameMode.SURVIVAL;
Error.INVALID.add();
}
ErrorLogger.removePrefix();
}
示例12: 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;
}
示例13: onEnable
import org.bukkit.configuration.ConfigurationSection; //导入依赖的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);
}
示例14: init
import org.bukkit.configuration.ConfigurationSection; //导入依赖的package包/类
public void init(VanillaPlusCore core) {
ConfigurationSection section = ConfigUtils.getYaml(core.getInstance(), "Stat", false);
ErrorLogger.addPrefix("Stat.yml");
ConfigurationSection settings = section == null ? null : section.getConfigurationSection(Node.SETTINGS.get());
ErrorLogger.addPrefix(Node.SETTINGS.get());
if(settings==null){
startDataBase(VanillaPlusCore.getIConnectionManager().get(null));
}else{
startDataBase(VanillaPlusCore.getIConnectionManager().get(settings.getString("STORAGE")));
}
ErrorLogger.removePrefix();
if(!extensions.isEmpty()) {
new BukkitRunnable() {
@Override
public void run() {
for(VPPlayer player : VanillaPlusCore.getPlayerManager().getOnlinePlayers())
update(player);
}
}.runTaskTimer(VanillaPlus.getInstance(), 20*60, 20*60);
}
ErrorLogger.removePrefix();
}
示例15: isLinked
import org.bukkit.configuration.ConfigurationSection; //导入依赖的package包/类
public static boolean isLinked(Player p){
String uuid = p.getUniqueId().toString();
UtilsStorage storageType = Utils.getStorageType();
if(storageType == UtilsStorage.FILE){
if(UltimateTs.linkedPlayers.getConfigurationSection("linked") == null) UltimateTs.linkedPlayers.createSection("linked");
ConfigurationSection cs = UltimateTs.linkedPlayers.getConfigurationSection("linked");
if((cs.contains(uuid)) && (cs.getInt(uuid) > 0)) return true;
}else if(storageType == UtilsStorage.SQL){
if(UltimateTs.main().sql.isUUIDLinked(uuid)){
int linkedId = UltimateTs.main().sql.getLinkedId(uuid);
if(linkedId > 0){
return true;
}
}
}
return false;
}