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


Java DataView.getString方法代码示例

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


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

示例1: buildContent

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected Optional<CustomInventoryData> buildContent(DataView container) throws InvalidDataException {
    if(!container.contains(CUSTOM_INVENTORY_ID, CUSTOM_INVENTORY_SLOT_ID_TO_ITEMSTACK,
            CUSTOM_INVENTORY_SLOT_ID_TO_FEATURE_ID)) {
        return Optional.empty();
    }

    Optional<String> id = container.getString(CUSTOM_INVENTORY_ID.getQuery());

    if(!id.isPresent())
        throw new InvalidDataException("Could not access the ID of the inventory data.");

    val slotIdToItemStack = (Map<String, ItemStackSnapshot>) container.getMap(
            CUSTOM_INVENTORY_SLOT_ID_TO_ITEMSTACK.getQuery()
    ).orElse(null);

    val slotIdToFeatureId = (Map<String, String>) container.getMap(
            CUSTOM_INVENTORY_SLOT_ID_TO_FEATURE_ID.getQuery()
    ).orElse(null);

    return Optional.of(new CustomInventoryData(id.get(), slotIdToItemStack, slotIdToFeatureId));
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:24,代码来源:CustomInventoryDataBuilder.java

示例2: deserializeUniqueId

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public UUID deserializeUniqueId(DataView dataView) {
    Optional<Long> uuidMost = dataView.getLong(UNIQUE_ID_MOST);
    Optional<Long> uuidLeast = dataView.getLong(UNIQUE_ID_LEAST);
    if (uuidMost.isPresent() && uuidLeast.isPresent()) {
        return new UUID(uuidMost.get(), uuidLeast.get());
    } else {
        // Try to convert from an older format
        uuidMost = dataView.getLong(OLD_UNIQUE_ID_MOST);
        uuidLeast = dataView.getLong(OLD_UNIQUE_ID_LEAST);
        if (uuidMost.isPresent() && uuidLeast.isPresent()) {
            return new UUID(uuidMost.get(), uuidLeast.get());
        } else {
            final Optional<String> uuidString = dataView.getString(UNIQUE_ID);
            if (uuidString.isPresent()) {
                return UUID.fromString(uuidString.get());
            }
        }
    }
    return UUID.randomUUID();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:22,代码来源:EntityStore.java

示例3: 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

示例4: buildContent

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
@Nonnull
protected Optional<CustomFeatureData> buildContent(@Nonnull DataView container) throws InvalidDataException {
    Optional<String> pluginId = container.getString(CustomItemLibraryKeys.CUSTOM_FEATURE_PLUGIN_ID.getQuery());
    Optional<String> typeId = container.getString(CustomItemLibraryKeys.CUSTOM_FEATURE_TYPE_ID.getQuery());
    Optional<String> model = container.getString(CustomItemLibraryKeys.CUSTOM_FEATURE_MODEL.getQuery());

    if(pluginId.isPresent() && typeId.isPresent() && model.isPresent()) {
        return Optional.of(new CustomFeatureData(pluginId.get(), typeId.get(), model.get()));
    } else {
        return Optional.empty();
    }
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:14,代码来源:CustomFeatureManipulatorBuilder.java

示例5: deserializeValues

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public void deserializeValues(LanternItemStack object, SimpleValueContainer valueContainer, DataView dataView) {
    final ItemTypeObjectSerializer serializer = this.itemTypeSerializers.get(object.getType());
    if (serializer != null) {
        serializer.deserializeValues(object, valueContainer, dataView);
    }
    final Optional<DataView> optDisplayView = dataView.getView(DISPLAY);
    if (optDisplayView.isPresent()) {
        final DataView displayView = optDisplayView.get();
        if (!valueContainer.get(Keys.DISPLAY_NAME).isPresent()) {
            Optional<String> name = displayView.getString(NAME);
            if (name.isPresent()) {
                valueContainer.set(Keys.DISPLAY_NAME, LanternTexts.fromLegacy(name.get()));
            } else if ((name = displayView.getString(LOCALIZED_NAME)).isPresent()) {
                valueContainer.set(Keys.DISPLAY_NAME, t(name.get()));
            }
        }
        dataView.getStringList(LORE).ifPresent(lore -> {
            if (!lore.isEmpty()) {
                valueContainer.set(Keys.ITEM_LORE,
                        lore.stream().map(LanternTexts::fromLegacy).collect(Collectors.toList()));
            }
        });
    }
    dataView.getStringList(CAN_DESTROY).ifPresent(types -> {
        if (!types.isEmpty()) {
            final Set<BlockType> blockTypes = new HashSet<>();
            types.forEach(type -> BlockRegistryModule.get().getById(type).ifPresent(blockTypes::add));
            valueContainer.set(Keys.BREAKABLE_BLOCK_TYPES, blockTypes);
        }
    });
    deserializeEnchantments(dataView, ENCHANTMENTS, Keys.ITEM_ENCHANTMENTS, valueContainer);
    deserializeEnchantments(dataView, STORED_ENCHANTMENTS, Keys.STORED_ENCHANTMENTS, valueContainer);
    super.deserializeValues(object, valueContainer, dataView);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:36,代码来源:ItemStackStore.java


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