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


Java IntNode类代码示例

本文整理汇总了Java中org.cubeengine.converter.node.IntNode的典型用法代码示例。如果您正苦于以下问题:Java IntNode类的具体用法?Java IntNode怎么用?Java IntNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: toNode

import org.cubeengine.converter.node.IntNode; //导入依赖的package包/类
@Override
public Node toNode(ItemStack itemStack) throws ConversionException
{
    if (itemStack == null || itemStack.getItem() == Material.AIR)
    {
        return NullNode.emptyNode();
    }

    MapNode item = MapNode.emptyMap();
    item.set("Count", new IntNode(itemStack.getAmount()));
    item.set("Damage", new IntNode(itemStack.getDurability()));
    item.set("Item", StringNode.of(itemStack.getType().name()));
    net.minecraft.server.v1_8_R2.ItemStack nmsCopy = CraftItemStack.asNMSCopy(itemStack);
    if (nmsCopy == null)
    {
        CubeEngine.getLog().error("NMSCopy is unexpectedly null! " + itemStack);
        return null;
    }
    NBTTagCompound tag = nmsCopy.getTag();
    item.set("tag", tag == null ? MapNode.emptyMap() : NBTUtils.convertNBTToNode(tag));
    return item;
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:23,代码来源:ItemStackConverter.java

示例2: fromNode

import org.cubeengine.converter.node.IntNode; //导入依赖的package包/类
@Override
public Integer fromNode(Node node) throws ConversionException
{
    if (node instanceof IntNode)
    {
        return ((IntNode)node).getValue();
    }
    String s = node.asText();
    try
    {
        return Integer.parseInt(s);
    }
    catch (NumberFormatException e)
    {
        throw ConversionException.of(this, node, "Node incompatible with Integer!", e);
    }
}
 
开发者ID:CubeEngine,项目名称:ReflecT,代码行数:18,代码来源:IntegerConverter.java

示例3: fromNode

import org.cubeengine.converter.node.IntNode; //导入依赖的package包/类
@Override
public ItemStack fromNode(Node node) throws ConversionException
{
    if (node instanceof MapNode)
    {
        Node count = ((MapNode)node).get("Count");
        Node damage = ((MapNode)node).get("Damage");
        Node item = ((MapNode)node).get("Item");
        Node tag = ((MapNode)node).get("tag");
        if (count instanceof IntNode && damage instanceof IntNode &&
            item instanceof StringNode && (tag instanceof MapNode))
        {
            try
            {
                ItemStack itemStack = new ItemStack(Material.valueOf(item.asText()));
                itemStack.setDurability(((IntNode)damage).getValue().shortValue());
                itemStack.setAmount(((IntNode)count).getValue());
                net.minecraft.server.v1_8_R2.ItemStack nms = CraftItemStack.asNMSCopy(itemStack);
                nms.setTag(((MapNode)tag).isEmpty() ? null : (NBTTagCompound)NBTUtils.convertNodeToNBT(tag));
                return CraftItemStack.asBukkitCopy(nms);
            }
            catch (IllegalArgumentException e)
            {
                throw ConversionException.of(this, item, "Unknown Material!");
            }
        }
        else
        {
            throw ConversionException.of(this, node, "Invalid SubNodes!");
        }
    }
    else if (node instanceof NullNode)
    {
        return null;
    }
    else
    {
        throw ConversionException.of(this, node, "Node is not a MapNode!");
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:41,代码来源:ItemStackConverter.java

示例4: toNode

import org.cubeengine.converter.node.IntNode; //导入依赖的package包/类
@Override
public Node toNode(Integer object) throws ConversionException
{
    return new IntNode(object);
}
 
开发者ID:CubeEngine,项目名称:ReflecT,代码行数:6,代码来源:IntegerConverter.java

示例5: convertValue

import org.cubeengine.converter.node.IntNode; //导入依赖的package包/类
private Tag<?> convertValue(String name, Node value)
{
    if (value instanceof MapNode)
    {
        CompoundMap map = new CompoundMap();
        this.convertMap(map, ((MapNode)value).getValue(), (MapNode)value);
        return new CompoundTag(name, map);
    }
    else if (value instanceof ListNode)
    {
        List<Tag> tagList = new ArrayList<Tag>();
        java.lang.Integer i = 0;
        for (Node node : ((ListNode)value).getValue())
        {
            i++;
            tagList.add(this.convertValue(i.toString(), node));
        }
        if (tagList.size() == 0)
        {
            return new ListTag(name, CompoundTag.class, tagList);
        }
        return new ListTag(name, tagList.get(0).getClass(), tagList);
    }
    else if (value instanceof BooleanNode)
    {
        return new ByteTag(name, (Boolean)value.getValue());
    }
    else if (value instanceof ByteNode)
    {
        return new ByteTag(name, (Byte)value.getValue());
    }
    else if (value instanceof CharNode)
    {
        return new StringTag(name, value.getValue().toString());
    }
    else if (value instanceof DoubleNode)
    {
        return new DoubleTag(name, (Double)value.getValue());
    }
    else if (value instanceof FloatNode)
    {
        return new FloatTag(name, (Float)value.getValue());
    }
    else if (value instanceof IntNode)
    {
        return new IntTag(name, (Integer)value.getValue());
    }
    else if (value instanceof LongNode)
    {
        return new LongTag(name, (Long)value.getValue());
    }
    else if (value instanceof ShortNode)
    {
        return new ShortTag(name, (Short)value.getValue());
    }
    else if (value instanceof StringNode)
    {
        return new StringTag(name, (String)value.getValue());
    }
    else if (value instanceof NullNode)
    {
        return new EndTag();
    }
    throw new IllegalStateException("Unknown Node! " + value.getClass().getName());
}
 
开发者ID:CubeEngine,项目名称:ReflecT,代码行数:66,代码来源:NBTCodec.java


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