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


Java DataView.getInt方法代码示例

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


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

示例1: deserializeValues

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public void deserializeValues(ItemStack itemStack, SimpleValueContainer valueContainer, DataView dataView) {
    super.deserializeValues(itemStack, valueContainer, dataView);
    final Optional<Integer> dataValue = dataView.getInt(DATA_VALUE);
    if (dataValue.isPresent()) {
        int internalId = dataValue.get();
        if (this.dataValueToInternalId != null) {
            internalId = this.dataValueToInternalId.apply(internalId);
        }
        final Optional<T> catalogType = this.registryModule.getByInternalId(internalId);
        if (catalogType.isPresent()) {
            valueContainer.set(this.key, catalogType.get());
        } else {
            Lantern.getLogger().warn("Deserialize an unknown catalog type {} with internal id {}",
                    this.key.getElementToken(), internalId);
        }
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:19,代码来源:DataValueItemTypeObjectSerializer.java

示例2: build

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public Optional<VirtualChestInventory> build(DataView view) throws InvalidDataException
{
    this.items.clear();
    for (DataQuery key : view.getKeys(false))
    {
        String keyString = key.toString();
        if (keyString.startsWith(VirtualChestInventory.KEY_PREFIX))
        {
            SlotIndex slotIndex = VirtualChestInventory.keyToSlotIndex(keyString);
            for (DataView dataView : VirtualChestItem.getViewListOrSingletonList(key, view))
            {
                VirtualChestItem item = VirtualChestItem.deserialize(plugin, dataView);
                this.items.put(slotIndex, item);
            }
        }
    }

    this.title = view.getString(VirtualChestInventory.TITLE)
            .map(TextSerializers.FORMATTING_CODE::deserialize)
            .orElseThrow(() -> new InvalidDataException("Expected title"));

    this.height = view.getInt(VirtualChestInventory.HEIGHT)
            .orElseThrow(() -> new InvalidDataException("Expected height"));

    this.triggerItem = view.getView(VirtualChestInventory.TRIGGER_ITEM)
            .map(VirtualChestTriggerItem::new).orElseGet(VirtualChestTriggerItem::new);

    this.openActionCommand = view.getString(VirtualChestInventory.OPEN_ACTION_COMMAND);

    this.closeActionCommand = view.getString(VirtualChestInventory.CLOSE_ACTION_COMMAND);

    this.updateIntervalTick = view.getInt(VirtualChestInventory.UPDATE_INTERVAL_TICK).orElse(0);

    this.actionIntervalTick = view.getInt(VirtualChestInventory.ACCEPTABLE_ACTION_INTERVAL_TICK);

    return Optional.of(new VirtualChestInventory(this.plugin, this));
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:39,代码来源:VirtualChestInventoryBuilder.java

示例3: deserializeValues

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public void deserializeValues(LanternItem item, SimpleValueContainer valueContainer, DataView dataView) {
    valueContainer.set(Keys.REPRESENTED_ITEM, ObjectSerializerRegistry.get().get(LanternItemStack.class).get()
            .deserialize(dataView.getView(ITEM).get()).createSnapshot());
    valueContainer.set(Keys.PICKUP_DELAY, dataView.getInt(PICKUP_DELAY).orElse(0));
    final Optional<Integer> lifespan = dataView.getInt(LIFESPAN);
    final Optional<Integer> age = dataView.getInt(AGE);
    if (lifespan.isPresent() && age.isPresent()) {
        valueContainer.set(Keys.DESPAWN_DELAY, lifespan.get() - age.get());
    }
    super.deserializeValues(item, valueContainer, dataView);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:13,代码来源:ItemStore.java


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