当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurationSection.getDouble方法代码示例

本文整理汇总了Java中org.bukkit.configuration.ConfigurationSection.getDouble方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationSection.getDouble方法的具体用法?Java ConfigurationSection.getDouble怎么用?Java ConfigurationSection.getDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.configuration.ConfigurationSection的用法示例。


在下文中一共展示了ConfigurationSection.getDouble方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:20,代码来源:LobbyModule.java

示例2: PetType

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
PetType(ConfigurationSection config) {
    super(config, config.getString("item"));

    this.name = StringUtils.coloredLine(config.getString("name"));
    this.itemName = StringUtils.coloredLine(config.getString("item-name"));
    this.lore = StringUtils.coloredLines(config.getStringList("lore"));

    this.role = Role.valueOf(config.getString("type", "COMPANION"));
    this.skin = role.getPossibleSkin(config.getString("skin"));

    this.health = config.getDouble("health");
    this.damage = config.getDouble("damage", 0);
    this.speed = config.getDouble("speed");

    this.attackMobs = config.getBoolean("attack-mobs", false);
    this.attackPlayers = config.getBoolean("attack-players", false);
    this.revival = config.getBoolean("revival", true);
    this.cooldown = this.revival ? config.getInt("cooldown") : 0;

    this.createSpawnItem(config.getName());
    this.storeFeatures(config.getStringList("features"));
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:23,代码来源:PetType.java

示例3: setupConfiguration

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
private void setupConfiguration(final ConfigurationSection section) {
    if (section.isConfigurationSection("worlds")) {
        final ConfigurationSection wSection = section
                .getConfigurationSection("worlds");

        for (String wName : wSection.getKeys(false)) {
            final int centerX = wSection.getInt(wName + ".centerX", 0);
            final int centerZ = wSection.getInt(wName + ".centerZ", 0);
            final int distance = wSection.getInt(
                    wName + ".distance", DEFAULT_DISTANCE);
            final double knockback = wSection.getDouble(
                    wName + ".knockback-distance", DEFAULT_KNOCKBACK);

            WorldBorder wb = new BasicWorldBorder(
                    centerX, centerZ, distance);
            wb.setKnockbackDistance(knockback);
            this.worldBorders.put(wName, wb);

            this.plugin.getLogger().log(Level.INFO, "Created border"
                    + " for world '" + wName + "'!" + lineSeparator()
                    + "Knockback=" + knockback + lineSeparator()
                    + "Distance = " + distance
            );
        }
    }
}
 
开发者ID:Mystiflow,项目名称:WorldBorder,代码行数:27,代码来源:BasicWorldBorderHandler.java

示例4: 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;
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:19,代码来源:Currency.java

示例5: loadLocation

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public static Location loadLocation(ConfigurationSection c){
	if(c == null){
		ErrorLogger.addError("Invalid Location");
		return null;
	}
	double x,y,z = 0.0;
	float yaw,pitch = 0F;
	World world;
	world = Bukkit.getWorld(c.getString("WORLD","world"));
	if( world == null){
		ErrorLogger.addError("Invalid world name !");
		return null;
	}
	x = c.getDouble("X", 0.0);
	y = c.getDouble("Y", 0.0);
	z = c.getDouble("Z", 0.0);
	yaw = (float) c.getDouble("YAW", 0.0);
	pitch = (float) c.getDouble("PITCH", 0.0);
	return new Location(world, x, y, z, yaw, pitch);
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:21,代码来源:ConfigUtils.java

示例6: getPercentage

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
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;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:8,代码来源:ConfigUtils.java

示例7: PetFood

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
PetFood(ConfigurationSection config) {
    super(config.getString("item"));

    this.name = StringUtils.coloredLine(config.getString("name"));
    this.lore = StringUtils.coloredLines(config.getStringList("lore"));
    this.value = config.getDouble("value");
    this.eaters = config.getStringList("eaters");

    this.createFoodItem(config.getName());
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:11,代码来源:PetFood.java

示例8: FoodStatus

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
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);
	}
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:29,代码来源:ExtraManager.java

示例9: RequirementCurrency

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
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"));
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:14,代码来源:RequirementCurrency.java

示例10: RewardCurrency

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public RewardCurrency(ConfigurationSection section, MComponentManager manager) {
	this.currency = VanillaPlusCore.getCurrencyManager().get((short) section.getInt(Node.ID.get()));
	double amount = section.getDouble(Node.AMOUNT.get());
	if(amount < 0) {
		amount = - amount;
		ErrorLogger.addError("Amount can't be negative.");
	}else if(amount == 0) {
		ErrorLogger.addError("Amount can't be 0.");
	}
	this.amount = amount;
	this.force = section.getBoolean(Node.FORCE.get(), false);
	this.format = manager.get(section.getString(Node.FORMAT.get(), "REWARD.CURRENCY"));
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:14,代码来源:RewardCurrency.java

示例11: ModifierConfig

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public ModifierConfig(ConfigurationSection config) {
	if (config == null) return; // leave as no-op default.
	chanceMod = config.getDouble("chance", chanceMod);
	stackExpand = config.getInt("expand", stackExpand);
	stackAdjust = config.getInt("adjust", stackAdjust);
}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:7,代码来源:RootConfig.java

示例12: Damage

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public Damage(ConfigurationSection section) {
	if(section == null)return;
	amount = section.getDouble(Node.AMOUNT.get(),0);
	if(amount <= 0)
		Error.INVALID.add();
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:7,代码来源:Damage.java

示例13: Heal

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public Heal(ConfigurationSection section) {
	if(section == null)return;
	amount = section.getDouble(Node.AMOUNT.get(),0);
	if(amount <= 0)
		Error.INVALID.add();
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:7,代码来源:Heal.java

示例14: 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);
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:74,代码来源:DragonLoot.java


注:本文中的org.bukkit.configuration.ConfigurationSection.getDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。