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


Java NumberConversions.toShort方法代码示例

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


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

示例1: StorageSign

import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
public StorageSign(ItemStack item) {
	String[] str = item.getItemMeta().getLore().get(0).split(" ");
	if(str[0].matches("Empty")) isEmpty = true;
	else {
		mat = getMaterial(str[0].split(":")[0]);
		if(mat == Material.ENCHANTED_BOOK){
			damage = NumberConversions.toShort(str[0].split(":")[2]);
			ench = Enchantment.getByName(str[0].split(":")[1]);//旧仕様も
			if(ench == null) ench = Enchantment.getById(NumberConversions.toInt(str[0].split(":")[1]));
		}
		else if(mat == Material.POTION || mat == Material.SPLASH_POTION || mat == Material.LINGERING_POTION){
			PotionInfo pi = new PotionInfo(mat, str[0].split(":"));
			mat = pi.getMaterial();
			damage = pi.getDamage();
			pot = pi.getPotionType();
		}else if(str[0].contains(":")) damage = NumberConversions.toShort(str[0].split(":")[1]);
		amount = NumberConversions.toInt(str[1]);
	}
	stack = item.getAmount();
}
 
开发者ID:wackyls6,项目名称:StorageSign,代码行数:21,代码来源:StorageSign.java

示例2: asShort

import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
public short asShort() {
    return NumberConversions.toShort(value());
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:4,代码来源:MetadataValueAdapter.java

示例3: getTweakkitDataAsShort

import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
public short getTweakkitDataAsShort(String key) {
    return NumberConversions.toShort(getTweakkitData(key));
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:4,代码来源:NBTMetadataStore.java

示例4: PotionInfo

import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
public PotionInfo(Material mat, String[] str){
	this.mat = mat;
	if(str.length == 2){//ダメージ値
		short old = NumberConversions.toShort(str[1]);
		if(old >= 16384) this.mat = Material.SPLASH_POTION;
		switch(old % 16){
		case 1:
			pot = PotionType.REGEN;
		    break;
		case 2:
			pot = PotionType.SPEED;
		    break;
		case 3:
			pot = PotionType.FIRE_RESISTANCE;
		    break;
		case 4:
			pot = PotionType.POISON;
		    break;
		case 5:
			pot = PotionType.INSTANT_HEAL;
		    break;
		case 6:
			pot = PotionType.NIGHT_VISION;
		    break;
		case 8:
			pot = PotionType.WEAKNESS;
		    break;
		case 9:
			pot = PotionType.STRENGTH;
		    break;
		case 10:
			pot = PotionType.SLOWNESS;
		    break;
		case 11:
			pot = PotionType.JUMP;
		    break;
		case 12:
			pot = PotionType.INSTANT_DAMAGE;
		    break;
		case 13:
			pot = PotionType.WATER_BREATHING;
			break;
		case 14:
			pot = PotionType.INVISIBILITY;
			break;

		default:
			if(old == 16) pot = PotionType.AWKWARD;
			else if(old == 32) pot = PotionType.THICK;
			else if(old == 64 || old == 8192 || old == 16384) pot = PotionType.MUNDANE;
			else pot = PotionType.WATER;
		}

		if(old % 8192 > 64 && pot.isExtendable()) damage = 1;//延長
		else if(old % 64 > 32 && pot.isUpgradeable()) damage = 2;//強化

	}else if(str.length == 1) pot = PotionType.WATER;

	else{
		pot = getType(str[1]);
		damage = NumberConversions.toShort(str[2]);
	}
}
 
开发者ID:wackyls6,项目名称:StorageSign,代码行数:64,代码来源:PotionInfo.java


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