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


Java NumberConversions.toInt方法代码示例

本文整理汇总了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)));
}
 
开发者ID:t7seven7t,项目名称:CraftFX,代码行数:26,代码来源:SlotData.java

示例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;
}
 
开发者ID:t7seven7t,项目名称:CraftFX,代码行数:24,代码来源:PotionEffectUtil.java

示例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();
}
 
开发者ID:wackyls6,项目名称:StorageSign,代码行数:21,代码来源:StorageSign.java

示例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")));
}
 
开发者ID:GameBoxx,项目名称:GameBoxx,代码行数:9,代码来源:Cuboid.java

示例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;
}
 
开发者ID:t7seven7t,项目名称:CraftFX,代码行数:30,代码来源:SlotData.java

示例6: asInt

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

示例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);
}
 
开发者ID:DPOH-VAR,项目名称:VarScript,代码行数:6,代码来源:BootHelper.java

示例8: getTweakkitDataAsInt

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


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