Java 类org.bukkit.configuration.ConfigurationSection 实例源码

项目:UltimateTs    文件:PlayerManager.java   
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);
}
项目:CropControl    文件:RootConfig.java   
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;
}
项目:VanillaPlus    文件:MinecraftUtils.java   
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);
}
项目:VanillaPlus    文件:CPChannelSet.java   
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();
}
项目:UltimateTs    文件:PlayerManager.java   
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);
        }
    }
}
项目:Uranium    文件:HelpYamlReader.java   
/**
 * 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;
}
项目:Uranium    文件:SpigotConfig.java   
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." );
    }
}
项目:VanillaPlus    文件:CPChannelState.java   
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();
}
项目:UltimateTs    文件:PlayerManager.java   
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);
}
项目:ProjectAres    文件:FileRotationProviderFactory.java   
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;
}
项目:VanillaPlus    文件:MinecraftUtils.java   
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();
}
项目:VanillaPlus    文件:CPGamemode.java   
@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();
}
项目:VanillaPlus    文件:Currency.java   
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;
}
项目:OpenUHC    文件:LobbyModule.java   
@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);
}
项目:UltimateTs    文件:PlayerManager.java   
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);
        }
    }
}
项目:VanillaPlus    文件:StatManager.java   
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();
}
项目:UltimateTs    文件:PlayerManager.java   
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;
}
项目:CropControl    文件:CropControlEventHandler.java   
/**
 * Bootstraps the standalone tools configurations, if any are defined.
 */
private void prefillToolList() {
    ToolConfig.clear();
    ConfigurationSection toolDefinitions = config.getConfigurationSection("tools");
    if (toolDefinitions != null) {
        for (String toolDefine : toolDefinitions.getKeys(false)) {
            ToolConfig.initTool(toolDefinitions.getConfigurationSection(toolDefine));
        }
    } else {
        CropControl.getPlugin().warning("No tools defined; if any crop configuration uses a tool config, it will result in a new warning.");
    }
}
项目:CropControl    文件:CropControlDatabaseHandler.java   
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;
}
项目:VanillaPlus    文件:RequirementTitle.java   
public RequirementTitle(ConfigurationSection section, MComponentManager manager) {
    ErrorLogger.addPrefix(Node.ID.get());
    this.title = VanillaPlusCore.getTitleManager().get(section.getInt(Node.ID.get()));
    ErrorLogger.removePrefix();
    boolean keep = section.getBoolean("KEEP", false);
    this.keep = keep;
    format = manager.get(section.getString(Node.FORMAT.get(), "REQUIREMENT.TITLE"));
}
项目:uppercore    文件:ScriptManager.java   
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());
}
项目:VanillaPlus    文件:CPMessageSend.java   
public CPMessageSend(ConfigurationSection section, MessageManager manager, String name){
    super(section, manager, name);
    message         = manager.get(section.getString(Node.MESSAGE.get()));
    all             = section.getBoolean("ALL", false);
    priv            = section.getBoolean("PRIVATE", false);
    other           = new Requirement(section.get(Node.OTHER_REQUIREMENT.get()), manager.getComponentManager());
    successOther    = manager.get(section.getString(Node.SUCCESS.getOther()));
}
项目:EchoPet    文件:PetManager.java   
@Override
public void loadRiderFromFile(String type, IPet pet) {
    if (pet.getOwner() != null) {
        String path = type + "." + pet.getOwnerIdentification();
        if (EchoPet.getConfig(EchoPet.ConfigType.DATA).get(path + ".rider.type") != null) {
            PetType riderPetType = PetType.valueOf(EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".rider.type"));
            String riderName = EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".rider.name");
            if (riderName.equalsIgnoreCase("") || riderName == null) {
                riderName = riderPetType.getDefaultName(pet.getNameOfOwner());
            }
            if (riderPetType == null) return;
            if (EchoPet.getOptions().allowRidersFor(pet.getPetType())) {
                IPet rider = pet.createRider(riderPetType, true);
    if(rider != null && rider.getEntityPet() != null){
                    rider.setPetName(riderName);
                    ArrayList<PetData> riderData = new ArrayList<PetData>();
                    ConfigurationSection mcs = EchoPet.getConfig(EchoPet.ConfigType.DATA).getConfigurationSection(path + ".rider.data");
                    if (mcs != null) {
                        for (String key : mcs.getKeys(false)) {
                            if (GeneralUtil.isEnumType(PetData.class, key.toUpperCase())) {
                                PetData pd = PetData.valueOf(key.toUpperCase());
                                riderData.add(pd);
                            } else {
                                Logger.log(Logger.LogLevel.WARNING, "Error whilst loading data Pet Rider Save Data for " + pet.getNameOfOwner() + ". Unknown enum type: " + key + ".", true);
                            }
                        }
                    }
                    if (!riderData.isEmpty()) {
                        setData(pet, riderData.toArray(new PetData[riderData.size()]), true);
                    }
                }
            }
        }
    }
}
项目:VanillaPlus    文件:CPOther.java   
public CPOther(ConfigurationSection section, MessageManager manager, String name){
    super(section, manager, name);
    this.otherRequirement       = new Requirement(section.get(Node.REQUIREMENT.getOther()), manager.getComponentManager());
    this.alreadyOther           = manager.get(section.getString(Node.ALREADY.getOther()));
    this.alreadyTo              = manager.get(section.getString(Node.ALREADY.get()+"_TO"));
    this.successOther           = manager.get(section.getString(Node.SUCCESS.getOther()));
    this.successTo              = manager.get(section.getString(Node.SUCCESS.get()+"_TO"));
}
项目:helper    文件:MongoDatabaseCredentials.java   
@Nonnull
public static MongoDatabaseCredentials fromConfig(@Nonnull ConfigurationSection config) {
    return of(
            config.getString("address", "localhost"),
            config.getInt("port", 27017),
            config.getString("database", "minecraft"),
            config.getString("username", "root"),
            config.getString("password", "passw0rd")
    );
}
项目:helper    文件:DatabaseCredentials.java   
@Nonnull
public static DatabaseCredentials fromConfig(@Nonnull ConfigurationSection config) {
    return of(
            config.getString("address", "localhost"),
            config.getInt("port", 3306),
            config.getString("database", "minecraft"),
            config.getString("username", "root"),
            config.getString("password", "passw0rd")
    );
}
项目:Ourtown    文件:PlayerConfig.java   
@Override
public void serialize(ConfigurationSection config) {
    config.set("spawn", null);
    ISerializable.serialize(config, this);
    ConfigurationSection cfg = config.createSection("spawn");
    for (UUID uuid : playerSpawn.keySet()) {
        cfg.set(uuid.toString(), playerSpawn.get(uuid));
    }
}
项目:KevsPermissions    文件:ConfigDataManger.java   
@Override
public HashMap<String, Object> fetchGroupByName(String name) {
    ConfigurationSection section = config.getConfigurationSection("groups." + name);
    if (section == null)
        return null;
    return (HashMap<String, Object>) section.getValues(true);
}
项目:KevsPermissions    文件:ConfigDataManger.java   
@Override
public HashMap<String, Object> getGroupList() {
    ConfigurationSection section = config.getConfigurationSection("groups");
    if (section == null)
        return null;
    return (HashMap<String, Object>) section.getValues(false);
}
项目:VanillaPlus    文件:RequirementCurrency.java   
public RequirementCurrency(ConfigurationSection section, MComponentManager manager) {
    ErrorLogger.addPrefix(Node.ID.get());
    this.money = VanillaPlusCore.getCurrencyManager().get((short) section.getInt(Node.ID.get()));
    ErrorLogger.removePrefix();
    boolean keep = section.getBoolean("KEEP", false);
    this.amount = ((int)(section.getDouble(Node.AMOUNT.get(), 0)*1000))/1000.0;
    if(amount <= 0){
        ErrorLogger.addError(Node.AMOUNT.get() + " " + Error.INVALID.getMessage());
        keep = true;
    }
    this.keep = keep;
    format = manager.get(section.getString(Node.FORMAT.get(), "REQUIREMENT.CURRENCY"));
}
项目:ProjectAres    文件:ItemConfigurationParser.java   
public Skin needSkin(String text) {
    return MapUtils.computeIfAbsent(skins, text, t -> {
        final ConfigurationSection skinSection = root.getConfigurationSection("skins");
        if(skinSection != null) {
            final String referenced = skinSection.getString(text);
            if(referenced != null && !referenced.equals(text)) {
                return needSkin(referenced);
            }
        }
        return new Skin(text, null);
    });
}
项目:ProjectAres    文件:ItemConfigurationParser.java   
public Material needItemType(ConfigurationSection section, String key) throws InvalidConfigurationException {
    final Material item = NMSHacks.materialByKey(section.needString(key));
    if(item == null) {
        throw new InvalidConfigurationException(section, key, "Unknown item type '" + key + "'");
    }
    return item;
}
项目:ProjectAres    文件:ItemConfigurationParser.java   
public void needSkull(ItemStack stack, ConfigurationSection section, String key) throws InvalidConfigurationException {
    final ItemMeta meta = stack.getItemMeta();
    if(!(meta instanceof SkullMeta)) {
        throw new InvalidConfigurationException(section, key, "Item type " + NMSHacks.getKey(stack.getType()) + " cannot be skinned");
    }
    ((SkullMeta) meta).setOwner("SkullOwner", UUID.randomUUID(), needSkin(section.needString(key)));
    stack.setItemMeta(meta);
}
项目:VanillaPlus    文件:MinecraftUtils.java   
public static PotionEffect craftPotionEffect(ConfigurationSection section) {
    if(section == null){
        Error.MISSING.add();
        return null;
    }
    return craftPotionEffect(section.getString(Node.EFFECT.get()), section);
}
项目:VanillaPlus    文件:ExtraManager.java   
FoodStatus(ConfigurationSection section){
    abso = section.getInt(Node.ABSORPTION.get(), -1);
    defaultAbso = abso;
    food = section.getInt(Node.FOOD.get(), 0);
    defaultFood = food;
    saturation = section.getInt(Node.SATURATION.get(), 0);
    defaultSaturation = saturation;
    volume = (float) section.getDouble("VOLUME", 1);
    pitch = (float) section.getDouble("SPEED", 1);
    sound = Utils.matchEnum(Sound.values(), section.getString("SOUND"), true);
    ConfigurationSection potion = section.getConfigurationSection(Node.EFFECT.getList());
    effects = new ArrayList<PotionEffect>();
    if(potion == null)
        return;
    for(String key : potion.getKeys(false)){
        ConfigurationSection sub = potion.getConfigurationSection(key);
        if(sub == null){
            ErrorLogger.addError(key + " invalid !");
            continue;
        }
        PotionEffect effect = MinecraftUtils.craftPotionEffect(key, sub);
        if(effect.getType().equals(PotionEffectType.ABSORPTION)) {
            absoEffect = effect;
            reset();
        }else
            this.effects.add(effect);
    }
}
项目:ProjectAres    文件:ConfigUtils.java   
public static double getPercentage(ConfigurationSection config, String key, double def) {
    double percent = config.getDouble(key, def);
    if(percent < 0 || percent > 1) {
        throw new IllegalArgumentException("Config value " + key + ": percentage must be between 0 and 1");
    }
    return percent;
}
项目:VanillaPlus    文件:AchievementManager.java   
public void init(VanillaPlusExtension extension) {
    ConfigurationSection section = ConfigUtils.getYaml(extension.getInstance(), "Achievement", false);
    if(section == null)return;
    ErrorLogger.addPrefix("Achievement.yml");
    ConfigurationSection achievementSub = section.getConfigurationSection(Node.ACHIEVEMENT.getList());
    ErrorLogger.addPrefix(Node.ACHIEVEMENT.getList());
    if(achievementSub != null){
        for(String key : achievementSub.getKeys(false)){
            ErrorLogger.addPrefix(key);
            ConfigurationSection sub = achievementSub.getConfigurationSection(key);
            if(sub == null){
                Error.INVALID.add();
            }else{
                int id = Utils.parseInt(key, 0, true);
                if(id< Short.MIN_VALUE || id == 0 || id > Short.MAX_VALUE || achievements.containsKey((short)id)){
                    Error.INVALID.add();
                }else{
                    if(id>bigger)
                        bigger = id;
                    Achievement achievement = new Achievement((short) id, sub, extension.getMessageCManager());
                    achievements.put(achievement.getID(), achievement);
                }
            }
            ErrorLogger.removePrefix();
        }

    }
    ErrorLogger.removePrefix();
    ErrorLogger.removePrefix();
}
项目:VanillaPlus    文件:MenuManager.java   
@Deprecated
public void postIconInit() {
    if(toInit == null)return;
    for (Entry<String, MediumEntry<MessageManager, Menu, ConfigurationSection>> entry : toInit.entrySet()) {
        ErrorLogger.addPrefix(entry.getKey());
        entry.getValue().getValue().init(entry.getValue().getKey(), entry.getValue().getExtraValue());
        ErrorLogger.removePrefix();
    }
    toInit = null;
}
项目:VanillaPlus    文件:CPCurrencySet.java   
public CPCurrencySet(ConfigurationSection section, MessageManager manager, String name){
    super(section, manager, name);
    defaultCurrency = VanillaPlusCore.getCurrencyManager().get((short) section.getInt(Node.CURRENCY.get()));
    if(defaultCurrency == null){
        ErrorLogger.addError(Node.CURRENCY.get());
        Error.INVALID.add();
    }
    set  = section.getBoolean("SET", false);
    if(!set) remove = section.getBoolean(Node.REMOVE.get(), false);
    else remove = false;
    alreadyOther = manager.get(section.getString(Node.ALREADY.getOther()));
    argumentRequired = 1;
}
项目:libmanager    文件:Config.java   
private static Authentication readAuthentication(ConfigurationSection config) {
    String username = config.getString("username");
    String password = config.getString("password");
    return new AuthenticationBuilder()
            .addUsername(username)
            .addPassword(password)
            .build();
}