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


Java FileConfiguration.getDouble方法代码示例

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


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

示例1: PowerTask

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
/**Constructor, passes arguments to super class and loads special values from config.
 * @param parent	The Room this Task belongs to
 * @param conf		Given config file of this room has entries on tasks.
 * @param taskNr	Task number is needed to load keys correctly.
 */
public PowerTask(Room parent, FileConfiguration conf, int taskNr) {
	super(parent, conf, taskNr);
	this.type = TaskType.POWER;
	
	// loading values for this Task type:
	String path = "tasks.task" + this.taskNr + ".";
	onTime  = conf.getDouble(path + "onTime", 0.0);
}
 
开发者ID:TheRoot89,项目名称:DungeonGen,代码行数:14,代码来源:PowerTask.java

示例2: storeNewData

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public void storeNewData(Learn learn, KnownCheating knownCheating) {
	final FileConfiguration fc = getConfig();

	// Generate a UUID for this check (its identifier).
	UUID uuid = UUID.randomUUID();

	while (fc.isConfigurationSection(uuid.toString())) {
		uuid = UUID.randomUUID();
	}

	// The path to put the data in the file.
	String cheatPath = getCheatPath(knownCheating);

	// Get general values.
	final double currentMean = fc.getDouble(cheatPath + "CurrentMean");
	final double currentLowRange = fc.getDouble(cheatPath + "CurrentLowRange");
	final double currentHighRange = fc.getDouble(cheatPath + "CurrentHighRange");
	final long totalSamples = fc.getLong(cheatPath + "TotalSamples");

	if (currentLowRange == 0.0 || learn.getValue() < currentLowRange) {
		fc.set(cheatPath + "CurrentLowRange", learn.getValue());
	} else if (learn.getValue() > currentHighRange) {
		fc.set(cheatPath + "CurrentHighRange", learn.getValue());
	}

	// Calculate the new average.
	double updateMean = (currentMean + learn.getValue()) / 2.0;

	fc.set(cheatPath + "CurrentMean", updateMean);
	fc.set(cheatPath + "TotalSamples", totalSamples + 1);

	// Save the file.
	save(fc);
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:35,代码来源:LearnData.java

示例3: RoomTask

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
/**Constructor takes a back-reference to do actions and loads itself via config and TaskNr.
 * @param parent	The Room this Task belongs to
 * @param conf		Given config file of this room has entries on tasks.
 * @param taskNr	Task number is needed to load keys correctly.
 */
public RoomTask(Room parent, FileConfiguration conf,int taskNr) {
	this.parent = parent;
	this.taskNr = taskNr;
	
	// Load RoomTask values for Task i values from config:
	String path = "tasks.task" + this.taskNr + ".";
	
	type   =   			TaskType.valueOf(conf.getString(path + "type").trim().toUpperCase());
	delay  =  							 conf.getDouble(path + "delay",  0);
	period = 							 conf.getDouble(path + "period", 0);
	targetRegion = new CuboidRegion(BukkitUtil.toVector(conf.getVector(path + "regionCorner1",new org.bukkit.util.Vector())),
			                        BukkitUtil.toVector(conf.getVector(path + "regionCorner2",new org.bukkit.util.Vector())));
}
 
开发者ID:TheRoot89,项目名称:DungeonGen,代码行数:19,代码来源:RoomTask.java

示例4: DragonDeathRunnable

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
/**
 * Construct a new DragonDeathRunnable object
 * 
 * @param plugin an instance of the DragonEggDrop plugin
 * @param worldWrapper the world in which the dragon death is taking place
 * @param dragon the dragon dying in this runnable
 */
public DragonDeathRunnable(DragonEggDrop plugin, EndWorldWrapper worldWrapper, EnderDragon dragon) {
	this.plugin = plugin;
	this.worldWrapper = worldWrapper;
	this.world = worldWrapper.getWorld();
	this.dragon = dragon;
	
	FileConfiguration config = plugin.getConfig();
	this.particleType = Particle.valueOf(config.getString("Particles.type", "FLAME").toUpperCase());
	this.particleAmount = config.getInt("Particles.amount", 4);
	this.particleExtra = config.getDouble("Particles.extra", 0.0D);
	this.particleMultiplier = config.getDouble("Particles.speed-multiplier", 0.0D);
	this.particleStreamInterval = 360 / Math.max(1, config.getInt("Particles.stream-count"));
	this.xOffset = config.getDouble("Particles.xOffset");
	this.yOffset = config.getDouble("Particles.yOffset");
	this.zOffset = config.getDouble("Particles.zOffset");
	this.particleInterval = config.getLong("Particles.interval", 1L);
	this.lightningAmount = config.getInt("lightning-amount");
	
	// Portal location
	DragonBattle dragonBattle = plugin.getNMSAbstract().getEnderDragonBattleFromDragon(dragon);
	Location portalLocation = dragonBattle.getEndPortalLocation();
	this.currentY = config.getDouble("Particles.egg-start-y");
	this.location = new Location(world, portalLocation.getX(), this.currentY, portalLocation.getZ());
	
	// Expression parsing
	String shape = config.getString("Particles.Advanced.preset-shape");
	String xCoordExpressionString = config.getString("Particles.Advanced.x-coord-expression");
	String zCoordExpressionString = config.getString("Particles.Advanced.z-coord-expression");
	
	if (shape.equalsIgnoreCase("BALL")) {
		this.particleShape = new ParticleShapeDefinition(location, "x", "z");
	}
	else if (shape.equalsIgnoreCase("HELIX")) {
		this.particleShape = new ParticleShapeDefinition(location, "cos(theta) * 1.2", "sin(theta) * 1.2");
	}
	else if (shape.equalsIgnoreCase("OPEN_END_HELIX")) {
		this.particleShape = new ParticleShapeDefinition(location, "cos(theta) * (100 / t)", "sin(theta) * (100 / t)");
	}
	else { // CUSTOM or default
		this.particleShape = new ParticleShapeDefinition(location, xCoordExpressionString, zCoordExpressionString);
	}

	this.respawnDragon = config.getBoolean("respawn-on-death", false);
	this.runTaskTimer(plugin, 0, this.particleInterval);
	
	BattleStateChangeEvent bscEventCrystals = new BattleStateChangeEvent(dragonBattle, dragon, BattleState.BATTLE_END, BattleState.PARTICLES_START);
	Bukkit.getPluginManager().callEvent(bscEventCrystals);
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:56,代码来源:DragonDeathRunnable.java

示例5: parseDragonLoot

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的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.file.FileConfiguration.getDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。