本文整理汇总了Java中org.bukkit.util.NumberConversions.toInt方法的典型用法代码示例。如果您正苦于以下问题:Java NumberConversions.toInt方法的具体用法?Java NumberConversions.toInt怎么用?Java NumberConversions.toInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.util.NumberConversions
的用法示例。
在下文中一共展示了NumberConversions.toInt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDataHolderUpdate
import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
@Override
public void onDataHolderUpdate() {
final DataHolder holder = getHolder().get();
if (holder instanceof ConfigDataHolder) {
final ConfigDataHolder h = (ConfigDataHolder) holder;
if (h.getConfig().isList("slots")) {
final List<?> list = h.getConfig().getList("slots");
final Set<Integer> ints = new HashSet<>();
for (Object o : list) {
if (o instanceof String) {
ints.addAll(parseSlots((String) o));
} else {
int i = NumberConversions.toInt(o);
if (i < 0 || i > 36) continue;
ints.add(i);
}
}
slots = fromCollection(ints);
return;
}
}
final Optional<String> opt = holder.get("slots", String.class);
opt.ifPresent(s -> slots = fromCollection(parseSlots(s)));
}
示例2: getPotionEffects
import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
public static List<PotionEffect> getPotionEffects(
List<String> identifiers) throws IllegalArgumentException {
List<PotionEffect> potionEffectList = Lists.newArrayList();
for (String identifier : identifiers) {
String[] split = identifier.replaceAll("\\s+", "_").split("\\W");
if (split.length < 3) {
throw new IllegalArgumentException(
"Missing argument: potion effect, duration or amplifier");
}
PotionEffectType type = PotionEffectType.getByName(EnumUtil.enumify(split[0]));
if (type == null) {
throw new IllegalArgumentException(
"Potion effect '" + split[0] + "' is not a valid type.");
}
int duration = (int) TimeUtil.parseString(split[1]);
int amplifier = NumberConversions.toInt(split[2]);
potionEffectList.add(new PotionEffect(type, duration, amplifier));
}
return potionEffectList;
}
示例3: 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();
}
示例4: deserialize
import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
public static Cuboid deserialize(Map<String, Object> args) {
World world = Bukkit.getWorld((String)args.get("world"));
if (world == null) {
throw new IllegalArgumentException("unknown world");
}
return new Cuboid(world, NumberConversions.toInt(args.get("minX")), NumberConversions.toInt(args.get("minY")), NumberConversions.toInt(args.get("minZ")),
NumberConversions.toInt(args.get("minX")), NumberConversions.toInt(args.get("minY")), NumberConversions.toInt(args.get("minZ")));
}
示例5: parseSlots
import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
private Set<Integer> parseSlots(String str) {
final String[] parts = str.split(", ?");
final Set<Integer> ints = new HashSet<>();
handSlot = false;
loop:
for (String s : parts) {
s = s.toLowerCase();
switch (s) {
case "all":
ints.addAll(ALL_SLOTS);
break loop;
case "armor":
ints.addAll(ARMOR_SLOTS);
break;
case "hotbar":
ints.addAll(HOTBAR_SLOTS);
break;
case "hand":
handSlot = true;
break;
default:
int i = NumberConversions.toInt(s);
if (i < 0 || i > 36) break;
ints.add(i);
break;
}
}
return ints;
}
示例6: asInt
import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
public int asInt() {
return NumberConversions.toInt(value());
}
示例7: getConfigInt
import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
private static int getConfigInt(String path, int defValue){
loadConfigs();
Object value = fileConfig.get(path);
return value != null ? NumberConversions.toInt(value) : localConfig.getInt(path, defValue);
}
示例8: getTweakkitDataAsInt
import org.bukkit.util.NumberConversions; //导入方法依赖的package包/类
public int getTweakkitDataAsInt(String key) {
return NumberConversions.toInt(getTweakkitData(key));
}