本文整理汇总了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();
}
示例2: asShort
import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
public short asShort() {
return NumberConversions.toShort(value());
}
示例3: getTweakkitDataAsShort
import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
public short getTweakkitDataAsShort(String key) {
return NumberConversions.toShort(getTweakkitData(key));
}
示例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]);
}
}