org.bukkit.block.banner.Pattern#org.bukkit.configuration.ConfigurationSection源码实例Demo

下面列出了org.bukkit.block.banner.Pattern#org.bukkit.configuration.ConfigurationSection 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Guilds   文件: GuildHandler.java
/**
 * Load all the roles
 */
private void loadRoles() {
    final YamlConfiguration conf = YamlConfiguration.loadConfiguration(new File(guildsPlugin.getDataFolder(), "roles.yml"));
    final ConfigurationSection roleSec = conf.getConfigurationSection("roles");

    for (String s : roleSec.getKeys(false)) {
        final String path = s + ".permissions.";
        final String name = roleSec.getString(s + ".name");
        final String perm = roleSec.getString(s + ".permission-node");
        final int level = Integer.parseInt(s);

        final GuildRole role = new GuildRole(name, perm, level);

        for (GuildRolePerm rolePerm: GuildRolePerm.values()) {
            final String valuePath = path + rolePerm.name().replace("_", "-").toLowerCase();
            if (roleSec.getBoolean(valuePath)) {
                role.addPerm(rolePerm);
            }
        }
        this.roles.add(role);
    }
}
 
源代码2 项目: ExploitFixer   文件: PacketsModule.java
final public void reload(final Configuration configYml) {
	final ConfigurationSection configurationSection = configYml.getConfigurationSection("packets.multipliers");
	final String name = "packets";

	this.name = "Packets";
	this.enabled = configYml.getBoolean(name + ".enabled");
	this.cancelVls = configYml.getDouble(name + ".cancel_vls");
	this.reduceVls = configYml.getDouble(name + ".reduce_vls");
	this.offline = configYml.getBoolean(name + ".offline");
	this.dataVls = configYml.getDouble(name + ".data.vls");
	this.dataBytes = configYml.getInt(name + ".data.bytes", 24000);
	this.dataBytesBook = configYml.getInt(name + ".data.bytes_book", 268);
	this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign", 47);
	this.dataBytesDivider = configYml.getInt(name + ".data.bytes_divider", 200);
	this.windowClick = configYml.getDouble(name + ".window_click");
	this.blockPlaceVls = configYml.getDouble(name + ".block_place");
	this.blockDigVls = configYml.getDouble(name + ".block_dig");
	this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot");
	this.violations = new Violations(configYml.getConfigurationSection(name + ".violations"));

	for (final String key : configurationSection.getKeys(false))
		multipliers.put(key, configurationSection.getDouble(key));
}
 
源代码3 项目: AreaShop   文件: GeneralRegion.java
/**
 * Checks an event and handles saving to and restoring from schematic for it.
 * @param type The type of event
 */
public void handleSchematicEvent(RegionEvent type) {
	// Check the individual>group>default setting
	if(!isRestoreEnabled()) {
		AreaShop.debug("Schematic operations for " + getName() + " not enabled, skipped");
		return;
	}
	// Get the safe and restore names
	ConfigurationSection profileSection = getConfigurationSectionSetting("general.schematicProfile", "schematicProfiles");
	if(profileSection == null) {
		return;
	}

	String save = profileSection.getString(type.getValue() + ".save");
	String restore = profileSection.getString(type.getValue() + ".restore");
	// Save the region if needed
	if(save != null && !save.isEmpty()) {
		save = Message.fromString(save).replacements(this).getSingle();
		saveRegionBlocks(save);
	}
	// Restore the region if needed
	if(restore != null && !restore.isEmpty()) {
		restore = Message.fromString(restore).replacements(this).getSingle();
		restoreRegionBlocks(restore);
	}
}
 
源代码4 项目: AreaShop   文件: GeneralRegion.java
/**
 * Get a configuration section setting for this region, defined as follows
 * - If the region has the setting in its own file (/regions/regionName.yml), use that
 * - If the region has groups, use the setting defined by the most important group, if any
 * - Otherwise fallback to the default.yml file setting
 * @param path The path to get the setting of
 * @return The value of the setting
 */
public ConfigurationSection getConfigurationSectionSetting(String path) {
	if(config.isSet(path)) {
		return config.getConfigurationSection(path);
	}
	ConfigurationSection result = null;
	int priority = Integer.MIN_VALUE;
	boolean found = false;
	for(RegionGroup group : plugin.getFileManager().getGroups()) {
		if(group.isMember(this) && group.getSettings().isSet(path) && group.getPriority() > priority) {
			result = group.getSettings().getConfigurationSection(path);
			priority = group.getPriority();
			found = true;
		}
	}
	if(found) {
		return result;
	}

	if(this.getFileManager().getRegionSettings().isSet(path)) {
		return this.getFileManager().getRegionSettings().getConfigurationSection(path);
	} else {
		return this.getFileManager().getFallbackRegionSettings().getConfigurationSection(path);
	}
}
 
源代码5 项目: AreaShop   文件: SignsFeature.java
/**
 * Constructor.
 * @param region The region to bind to
 */
public SignsFeature(GeneralRegion region) {
	setRegion(region);
	signs = new HashMap<>();
	// Setup current signs
	ConfigurationSection signSection = region.getConfig().getConfigurationSection("general.signs");
	if(signSection != null) {
		for(String signKey : signSection.getKeys(false)) {
			RegionSign sign = new RegionSign(this, signKey);
			Location location = sign.getLocation();
			if(location == null) {
				AreaShop.warn("Sign with key " + signKey + " of region " + region.getName() + " does not have a proper location");
				continue;
			}
			signs.put(sign.getStringLocation(), sign);
			signsByChunk.computeIfAbsent(sign.getStringChunk(), key -> new ArrayList<>())
					.add(sign);
		}
		allSigns.putAll(signs);
	}
}
 
源代码6 项目: Shopkeepers   文件: PriceOffer.java
public static List<PriceOffer> loadFromConfigOld(ConfigurationSection config, String node) {
	List<PriceOffer> offers = new ArrayList<PriceOffer>();
	ConfigurationSection offersSection = config.getConfigurationSection(node);
	if (offersSection != null) {
		for (String key : offersSection.getKeys(false)) {
			ConfigurationSection offerSection = offersSection.getConfigurationSection(key);
			ItemStack item = offerSection.getItemStack("item");
			if (item != null) {
				// legacy: the amount was stored separately from the item
				item.setAmount(offerSection.getInt("amount", 1));
				if (offerSection.contains("attributes")) {
					String attributes = offerSection.getString("attributes");
					if (attributes != null && !attributes.isEmpty()) {
						item = NMSManager.getProvider().loadItemAttributesFromString(item, attributes);
					}
				}
			}
			int price = offerSection.getInt("cost");
			if (Utils.isEmpty(item) || price < 0) continue; // invalid offer
			offers.add(new PriceOffer(item, price));
		}
	}
	return offers;
}
 
源代码7 项目: NyaaUtils   文件: Configuration.java
@Override
public void serialize(ConfigurationSection config) {
    // general values save & standalone config save
    ISerializable.serialize(config, this);

    // Enchantment Max Level constraint
    ConfigurationSection list = config.createSection("enchant.max_level");
    for (Enchantment k : enchantMaxLevel.keySet()) {
        if (k == null || k.getKey() == null || k.getKey().getKey() == null) continue;
        list.set(k.getKey().getKey(), enchantMaxLevel.get(k));
    }
    config.set("particles.limits", null);
    for (ParticleType type : particlesLimits.keySet()) {
        particlesLimits.get(type).serialize(config.createSection("particles.limits." + type.name()));
    }
}
 
源代码8 项目: NyaaUtils   文件: EnchantSrcConfig.java
@Override
public void deserialize(ConfigurationSection config) {
    ISerializable.deserialize(config, this);

    enchantSrc = new ArrayList<>();
    if (config.isConfigurationSection("enchantSrc")) {
        ConfigurationSection src = config.getConfigurationSection("enchantSrc");
        for (String key : src.getKeys(false)) {
            if (src.isConfigurationSection(key)) {
                BasicItemMatcher tmp = new BasicItemMatcher();
                tmp.deserialize(src.getConfigurationSection(key));
                enchantSrc.add(tmp);
            }
        }
    }
}
 
源代码9 项目: HeavySpleef   文件: GeneralSection.java
public GeneralSection(ConfigurationSection section) {
	String prefix = section.getString("spleef-prefix");
	if (prefix != null) {
		this.spleefPrefix = ChatColor.translateAlternateColorCodes(TRANSLATE_CHAR, prefix);
	} else {
		this.spleefPrefix = ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + ChatColor.BOLD + "Spleef" + ChatColor.DARK_GRAY + "]";
	}
	
	this.whitelistedCommands = section.getStringList("command-whitelist");
	String vipPrefix = section.getString("vip-prefix");
	if (vipPrefix != null) {
		this.vipPrefix = ChatColor.translateAlternateColorCodes(TRANSLATE_CHAR, vipPrefix);
	} else {
		this.vipPrefix = ChatColor.RED.toString();
	}
	
	this.vipJoinFull = section.getBoolean("vip-join-full", true);
	this.pvpTimer = section.getInt("pvp-timer", 0);
	this.broadcastGameStart = section.getBoolean("broadcast-game-start", true);
	this.broadcastGameStartBlacklist = section.getStringList("broadcast-game-start-blacklist");
	this.winMessageToAll = section.getBoolean("win-message-to-all", true);
       this.warmupMode = section.getBoolean("warmup-mode", false);
       this.warmupTime = section.getInt("warmup-time", 10);
       this.adventureMode = section.getBoolean("adventure-mode", true);
}
 
源代码10 项目: uSkyBlock   文件: LevelConfigYmlReader.java
private BlockLevelConfig readBlockSection(ConfigurationSection section, BlockMatch blockMatch, BlockLevelConfigBuilder defaultBuilder) {
    BlockLevelConfigBuilder builder = defaultBuilder.copy()
            .base(blockMatch);
    double score = section.getDouble("score", -1);
    if (score >= 0) {
        builder.scorePerBlock(score);
    }
    int limit = section.getInt("limit", -1);
    if (limit >= 0) {
        builder.limit(limit);
    }
    int diminishingReturns = section.getInt("diminishingReturns", -1);
    if (diminishingReturns >= 0) {
        builder.diminishingReturns(diminishingReturns);
    }
    int negativeReturns = section.getInt("negativeReturns", -1);
    if (negativeReturns >= 0) {
        builder.negativeReturns(negativeReturns);
    }
    List<String> additionBlocks = section.getStringList("additionalBlocks");
    if (!additionBlocks.isEmpty()) {
        builder.additionalBlocks(additionBlocks.stream().map(s -> getBlockMatch(s)).collect(Collectors.toList()).toArray(new BlockMatch[0]));
    }
    return builder.build();
}
 
源代码11 项目: BetonQuest   文件: Config.java
/**
 * Returns the ID of a conversation assigned to specified NPC, across all
 * packages. If there are multiple assignments for the same value, the first
 * one will be returned.
 *
 * @param value the name of the NPC (as defined in <i>main.yml</i>)
 * @return the ID of the conversation assigned to this NPC or null if there
 * isn't one
 */
public static String getNpc(String value) {
    // load npc assignments from all packages
    for (String packName : packages.keySet()) {
        ConfigPackage pack = packages.get(packName);
        ConfigurationSection assignments = pack.getMain().getConfig().getConfigurationSection("npcs");
        if (assignments != null) {
            for (String assignment : assignments.getKeys(false)) {
                if (assignment.equalsIgnoreCase(value)) {
                    return packName + "." + assignments.getString(assignment);
                }
            }
        }
    }
    return null;
}
 
源代码12 项目: AreaShop   文件: RegionSign.java
/**
 * Check if the sign needs to update periodically.
 * @return true if it needs periodic updates, otherwise false
 */
public boolean needsPeriodicUpdate() {
	ConfigurationSection signConfig = getProfile();
	if(signConfig == null || !signConfig.isSet(getRegion().getState().getValue().toLowerCase())) {
		return false;
	}

	ConfigurationSection stateConfig = signConfig.getConfigurationSection(getRegion().getState().getValue().toLowerCase());
	if(stateConfig == null) {
		return false;
	}

	// Check the lines for the timeleft tag
	for(int i = 1; i <= 4; i++) {
		String line = stateConfig.getString("line" + i);
		if(line != null && !line.isEmpty() && line.contains(Message.VARIABLE_START + AreaShop.tagTimeLeft + Message.VARIABLE_END)) {
			return true;
		}
	}
	return false;
}
 
源代码13 项目: AnnihilationPro   文件: XPMain.java
public void loadXPVars(ConfigurationSection section)
{
	assert section != null;

	int nexusHitXP = section.getInt("Nexus-Hit-XP");
	int killXP = section.getInt("Player-Kill-XP");
	String gaveXPMessage = section.getString("Gave-XP-Message");
	String myXPMessage = section.getString("MyXP-Command-Message");
	int[] teamXPs = new int[4];
	teamXPs[0] = section.getInt("Winning-Team-XP");
	teamXPs[1] = section.getInt("Second-Place-Team-XP");
	teamXPs[2] = section.getInt("Third-Place-Team-XP");
	teamXPs[3] = section.getInt("Last-Place-Team-XP");
	
	XPListeners listeners = new XPListeners(this.xpSystem,gaveXPMessage,killXP,nexusHitXP,teamXPs);
	MyXPCommand command = new MyXPCommand(this.xpSystem,myXPMessage);
	
	//AnniEvent.registerListener(listeners);
	Bukkit.getPluginManager().registerEvents(listeners, this);
	this.getCommand("MyXP").setExecutor(command);
}
 
源代码14 项目: HeavySpleef   文件: SignLayoutConfiguration.java
@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");
	}
}
 
源代码15 项目: QuickShop-Reremake   文件: JSONConfiguration.java
protected void convertMapsToSections(
        @NotNull Map<?, ?> input, @NotNull ConfigurationSection section) {
    final Object result = SerializationHelper.deserialize(input);

    if (result instanceof Map) {
        input = (Map<?, ?>) result;

        for (Map.Entry<?, ?> entry : input.entrySet()) {
            final String key = entry.getKey().toString();
            final Object value = entry.getValue();

            if (value instanceof Map) {
                convertMapsToSections((Map<?, ?>) value, section.createSection(key));
            } else {
                section.set(key, value);
            }
        }
    } else {
        section.set("", result);
    }
}
 
源代码16 项目: BetonQuest   文件: QuestCommand.java
/**
 * Returns a list including all possible options for tab complete of the
 * /betonquest vector command
 *
 * @param sender
 * @param args
 * @return
 */
private List<String> completeVector(CommandSender sender, String[] args) {
    if (args.length == 2) {
        if (args[1] == null || !args[1].contains(".")) {
            return completePackage(sender, args);
        }
        String pack = args[1].substring(0, args[1].indexOf("."));
        ConfigPackage configPack = Config.getPackages().get(pack);
        if (configPack == null)
            return new ArrayList<>();
        ConfigurationSection section = configPack.getMain().getConfig().getConfigurationSection("variables");
        Collection<String> keys = section.getKeys(false);
        if (keys.isEmpty())
            return new ArrayList<>();
        return new ArrayList<>(keys);
    }
    return new ArrayList<>();
}
 
源代码17 项目: ChestCommands   文件: IconSerializer.java
public static Coords loadCoordsFromSection(ConfigurationSection section) {
	Validate.notNull(section, "ConfigurationSection cannot be null");

	Integer x = null;
	Integer y = null;

	if (section.isInt(Nodes.POSITION_X)) {
		x = section.getInt(Nodes.POSITION_X);
	}

	if (section.isInt(Nodes.POSITION_Y)) {
		y = section.getInt(Nodes.POSITION_Y);
	}

	return new Coords(x, y);
}
 
源代码18 项目: UHC   文件: WorldMatcher.java
public WorldMatcher(ConfigurationSection section, List<String> worldsDefault, boolean isWhitelistDefault) {
    if (!section.contains(WORLDS_KEY)) {
        section.set(WORLDS_KEY, worldsDefault);
    }

    if (!section.contains(IS_WHITELIST_KEY)) {
        section.set(IS_WHITELIST_KEY, isWhitelistDefault);
    }

    worlds = ImmutableSet.copyOf(
            Iterables.filter(
                    Iterables.transform(section.getStringList(WORLDS_KEY), TO_LOWER_CASE),
                    Predicates.notNull()
            )
    );
    isWhitelist = section.getBoolean(IS_WHITELIST_KEY);
}
 
源代码19 项目: uSkyBlock   文件: LevelConfigYmlWriter.java
private void writeToSection(ConfigurationSection section, BlockLevelConfig config, BlockLevelConfig mapDefault) {
    if (!config.getAdditionalBlocks().isEmpty()) {
        section.set("additionalBlocks", config.getAdditionalBlocks().stream().distinct().map(m -> m.toString()).collect(Collectors.toList()));
    }
    if (config.getScorePerBlock() >= 0 && config.getScorePerBlock() != mapDefault.getScorePerBlock()) {
        section.set("score", config.getScorePerBlock());
    }
    if (config.getLimit() >= 0 && config.getLimit() != mapDefault.getLimit()) {
        section.set("limit", config.getLimit());
    }
    if (config.getDiminishingReturns() > 0 && config.getLimit() != mapDefault.getDiminishingReturns()) {
        section.set("diminishingReturns", config.getDiminishingReturns());
    }
    if (config.getNegativeReturns() > 0 && config.getLimit() != mapDefault.getNegativeReturns()) {
        section.set("negativeReturns", config.getNegativeReturns());
    }
}
 
源代码20 项目: AnnihilationPro   文件: AnniSign.java
public void saveToConfig(ConfigurationSection configSection)
{
	if(configSection != null)
	{
		configSection.set("isSignPost", this.isSignPost());
		//ConfigManager.saveLocation(this.getLocation(), configSection.createSection("Location"));
		getLocation().saveToConfig(configSection.createSection("Location"));
		configSection.set("FacingDirection", this.getFacingDirection().name());	
		String data;
		if(this.getType().equals(SignType.Brewing))
			data = "Brewing";
		else if(this.getType().equals(SignType.Weapon))
			data = "Weapon";
		else
			data = "Team-"+this.getType().getTeam().getName();	
		configSection.set("Data", data);
	}
}
 
源代码21 项目: PlotMe-Core   文件: IServerBridge.java
public ConfigurationSection loadDefaultConfig(ConfigAccessor configFile, String world) {
    ConfigurationSection defaultWorld = getDefaultWorld();
    ConfigurationSection configSection;
    if (configFile.getConfig().contains(world)) {
        configSection = configFile.getConfig().getConfigurationSection(world);
    } else {
        configFile.getConfig().set(world, defaultWorld);
        configFile.saveConfig();
        configSection = configFile.getConfig().getConfigurationSection(world);
    }
    for (String path : defaultWorld.getKeys(true)) {
        configSection.addDefault(path, defaultWorld.get(path));
    }
    configFile.saveConfig();
    return configSection;
}
 
源代码22 项目: ShopChest   文件: HologramFormat.java
/**
 * @return Whether the hologram text has to change dynamically without reloading
 */
public boolean isDynamic() {
    int count = getLineCount();
    for (int i = 0; i < count; i++) {
        ConfigurationSection options = config.getConfigurationSection("lines." + i + ".options");

        for (String key : options.getKeys(false)) {
            ConfigurationSection option = options.getConfigurationSection(key);

            String format = option.getString("format");
            if (format.contains(Placeholder.STOCK.toString()) || format.contains(Placeholder.CHEST_SPACE.toString())) {
                return true;
            }

            for (String req : option.getStringList("requirements")) {
                if (req.contains(Requirement.IN_STOCK.toString()) || req.contains(Requirement.CHEST_SPACE.toString())) {
                    return true;
                }
            }
        }
    }

    return false;
}
 
源代码23 项目: Guilds   文件: GuildHandler.java
private void loadTiers() {
    final YamlConfiguration conf = YamlConfiguration.loadConfiguration(new File(guildsPlugin.getDataFolder(), "tiers.yml"));
    final ConfigurationSection tierSec = conf.getConfigurationSection("tiers.list");

    for (String key : tierSec.getKeys(false)) {
        tiers.add(GuildTier.builder()
                .level(tierSec.getInt(key + ".level"))
                .name(tierSec.getString(key + ".name"))
                .cost(tierSec.getDouble(key + ".cost", 1000))
                .maxMembers(tierSec.getInt(key + ".max-members", 10))
                .vaultAmount(tierSec.getInt(key + ".vault-amount", 1))
                .mobXpMultiplier(tierSec.getDouble(key + ".mob-xp-multiplier", 1.0))
                .damageMultiplier(tierSec.getDouble(key + ".damage-multiplier", 1.0))
                .maxBankBalance(tierSec.getDouble(key + ".max-bank-balance", 10000))
                .membersToRankup(tierSec.getInt(key + ".members-to-rankup", 5))
                .maxAllies(tierSec.getInt(key + ".max-allies", 10))
                .useBuffs(tierSec.getBoolean(key + ".use-buffs", true))
                .permissions(tierSec.getStringList(key + ".permissions"))
                .build());
    }
}
 
源代码24 项目: PlayTimeTracker   文件: Rule.java
public Rule(String name, ConfigurationSection s) {
    this.name = name;
    switch (s.getString("period")) {
        case "day": {
            period = PeriodType.DAY;
            break;
        }
        case "week": {
            period = PeriodType.WEEK;
            break;
        }
        case "month": {
            period = PeriodType.MONTH;
            break;
        }
        case "disposable": {
            period = PeriodType.DISPOSABLE;
            break;
        }
        case "session": {
            period = PeriodType.SESSION;
            break;
        }
        case "longtimenosee": {
            period = PeriodType.LONGTIMENOSEE;
            break;
        }
    }
    require = s.getLong("require");
    autoGive = s.getBoolean("auto-give");
    timeout = s.contains("timeout") ? s.getLong("timeout") : -1;
    group = s.contains("eligible-group") ? new HashSet<>(s.getStringList("eligible-group")) : null;
    reward = s.getString("reward");
}
 
源代码25 项目: EchoPet   文件: PetNames.java
public static boolean allow(String input, IPet pet) {
    YAMLConfig config = ConfigOptions.instance.getConfig();
    String nameToCheck = ChatColor.stripColor(input);
    ConfigurationSection cs = config.getConfigurationSection("petNames");
    if (cs != null) {
        for (String key : cs.getKeys(false)) {
            if (key.equalsIgnoreCase(nameToCheck)) {
                String value = config.getString("petNames." + key);
                return pet.getOwner().hasPermission("echopet.pet.name.override") || !(value.equalsIgnoreCase("deny") || value.equalsIgnoreCase("false"));
            }
        }
    }

    if (config.getBoolean("petNamesRegexMatching")) {
        List<Map<String, String>> csRegex = (List<Map<String, String>>) config.get("petNamesRegex");
        if (!csRegex.isEmpty()) {
            for (Map<String, String> regexMap : csRegex) {
                for (Map.Entry<String, String> entry : regexMap.entrySet()) {
                    if (nameToCheck.matches(entry.getKey())) {
                        return pet.getOwner().hasPermission("echopet.pet.name.override")
                                || !(entry.getValue().equalsIgnoreCase("deny")
                                || entry.getValue().equalsIgnoreCase("false"));
                    }
                }
            }
        }
    }
    return true;
}
 
源代码26 项目: ProjectAres   文件: ItemConfigurationParser.java
public ItemStack getItem(ConfigurationSection section, String key, Supplier<ItemStack> def) throws InvalidConfigurationException {
    if(section.isString(key)) {
        return new ItemStack(needItemType(section, key));
    }

    if(!section.isConfigurationSection(key)) {
        return def.get();
    }

    final ConfigurationSection itemSection = section.needSection(key);

    if(itemSection.isString("skull")) {
        return needSkull(itemSection, "skull");
    }

    final Material material = needItemType(itemSection, "id");

    final int damage = itemSection.getInt("damage", 0);
    if(damage < Short.MIN_VALUE || damage > Short.MAX_VALUE) {
        throw new InvalidConfigurationException(itemSection, "damage", "Item damage out of range");
    }

    final ItemStack stack = new ItemStack(material, 1, (short) damage);

    if(itemSection.isString("skin")) {
        needSkull(stack, itemSection, "skin");
    }

    return stack;
}
 
源代码27 项目: Civs   文件: Effect.java
public Effect(Spell spell,
              String key,
              Object target,
              Entity origin,
              int level,
              ConfigurationSection section) {
    super(spell, key, target, origin, level);
}
 
源代码28 项目: CombatLogX   文件: Rewards.java
private Reward setupReward(String rewardId, ConfigurationSection rewardInfo) {
    ICombatLogX plugin = getPlugin();
    Logger logger = getLogger();

    int chance = rewardInfo.getInt("chance");
    int maxChance = rewardInfo.getInt("max-chance");
    if(chance <= 0 || maxChance <= 0) {
        logger.info("Ignoring invalid reward '" + rewardId + "' with chance/max-chance 0.");
        return null;
    }

    if(chance > maxChance) {
        logger.info("Ignoring invalid reward '" + rewardId + "' with chance greater than max-chance.");
        return null;
    }

    List<String> commandList = rewardInfo.getStringList("commands");
    if(commandList.isEmpty()) {
        logger.info("Ignoring invalid reward '" + rewardId + "' with empty/null commands.");
        return null;
    }

    boolean mobWhiteList = rewardInfo.getBoolean("mob-whitelist");
    List<String> mobTypeList = rewardInfo.getStringList("mob-list");

    boolean worldWhiteList = rewardInfo.getBoolean("world-whitelist");
    List<String> worldNameList = rewardInfo.getStringList("world-list");

    boolean randomCommand = rewardInfo.getBoolean("random-command");
    return new Reward(plugin, chance, maxChance, mobWhiteList, worldWhiteList, randomCommand, mobTypeList, worldNameList, commandList);
}
 
源代码29 项目: TrMenu   文件: Maps.java
public static <T> T getSimilarOrDefault(Map<?, ?> map, String key, T def) {
    if (map == null || map.entrySet().size() <= 0) {
        return def;
    }
    Optional<? extends Map.Entry<?, ?>> find = map.entrySet().stream().filter(entry -> String.valueOf(entry.getKey()).matches("^(?i)" + key)).findFirst();
    if (!find.isPresent()) {
        return def;
    }
    if (find.get().getValue() instanceof ConfigurationSection && def instanceof Map) {
        return (T) sectionToMap(find.get().getValue());
    }
    return (T) find.get().getValue();
}
 
源代码30 项目: UhcCore   文件: GenerateVeinConfiguration.java
public boolean parseConfiguration(ConfigurationSection section){
	if (section == null){
		return false;
	}

	try{
		material = Material.valueOf(section.getName());
	}catch(IllegalArgumentException e){
		Bukkit.getLogger().warning("[UhcCore] Couldn't parse section '"+section.getName()+"' in generate-vein. This is not an existing block type.Ignoring it.");
		return false;
	}
	minVeinsPerChunk = section.getInt("min-veins-per-chunk",0);
	maxVeinsPerChunk = section.getInt("max-veins-per-chunk",5);
	if(minVeinsPerChunk < 0 || maxVeinsPerChunk < 0){
		Bukkit.getLogger().warning("[UhcCore] Couldn't parse section '"+section.getName()+"' in generate-vein. min and max-veins-per-chunk must be positive.");
		return false;
	}
	
	minBlocksPerVein = section.getInt("min-blocks-per-vein",5);
	maxBlocksPerVein = section.getInt("max-blocks-per-vein",10);
	if(minBlocksPerVein < 0 || maxBlocksPerVein < 0){
		Bukkit.getLogger().warning("[UhcCore] Couldn't parse section '"+section.getName()+"' in generate-vein. min and max-blocks-per-vein must be positive.");
		return false;
	}
	
	minY = section.getInt("min-y",0);
	maxY = section.getInt("max-y",65);
	if(minY < 0 || minY > 255 || maxY < 0 || maxY > 255){
		Bukkit.getLogger().warning("[UhcCore] Couldn't parse section '"+section.getName()+"' in generate-vein. The min and max Y must be between 0 and 255.");
		return false;
	}
	
	return true;
}