java类org.bukkit.configuration.ConfigurationSection的实例源码

ItemConfigurationParser.java 文件源码 项目:ProjectAres 阅读 23 收藏 0 点赞 0 评论 0
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);
    });
}
ItemConfigurationParser.java 文件源码 项目:ProjectAres 阅读 20 收藏 0 点赞 0 评论 0
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;
}
ItemConfigurationParser.java 文件源码 项目:ProjectAres 阅读 19 收藏 0 点赞 0 评论 0
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);
}
MinecraftUtils.java 文件源码 项目:VanillaPlus 阅读 22 收藏 0 点赞 0 评论 0
public static PotionEffect craftPotionEffect(ConfigurationSection section) {
    if(section == null){
        Error.MISSING.add();
        return null;
    }
    return craftPotionEffect(section.getString(Node.EFFECT.get()), section);
}
ExtraManager.java 文件源码 项目:VanillaPlus 阅读 27 收藏 0 点赞 0 评论 0
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);
    }
}
ConfigUtils.java 文件源码 项目:ProjectAres 阅读 23 收藏 0 点赞 0 评论 0
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;
}
AchievementManager.java 文件源码 项目:VanillaPlus 阅读 20 收藏 0 点赞 0 评论 0
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();
}
MenuManager.java 文件源码 项目:VanillaPlus 阅读 21 收藏 0 点赞 0 评论 0
@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;
}
CPCurrencySet.java 文件源码 项目:VanillaPlus 阅读 17 收藏 0 点赞 0 评论 0
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;
}
Config.java 文件源码 项目:libmanager 阅读 22 收藏 0 点赞 0 评论 0
private static Authentication readAuthentication(ConfigurationSection config) {
    String username = config.getString("username");
    String password = config.getString("password");
    return new AuthenticationBuilder()
            .addUsername(username)
            .addPassword(password)
            .build();
}


问题


面经


文章

微信
公众号

扫码关注公众号