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


Java DataView.remove方法代码示例

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


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

示例1: remove

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public DataView remove(DataQuery path) {
    checkNotNull(path, "path");
    final List<String> parts = path.getParts();
    if (parts.size() > 1) {
        final String subKey = parts.get(0);
        final DataQuery subQuery = of(subKey);
        final Optional<DataView> subViewOptional = getUnsafeView(subQuery);
        if (!subViewOptional.isPresent()) {
            return this;
        }
        final DataView subView = subViewOptional.get();
        subView.remove(path.popFirst());
    } else {
        this.map.remove(parts.get(0));
    }
    return this;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:19,代码来源:MemoryDataView.java

示例2: applyEntityData

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void applyEntityData(Entity entity, BaseEntity baseEntity) {
    final ObjectStore store = ObjectStoreRegistry.get().get(entity.getClass())
            .orElseThrow(() -> new IllegalStateException("Missing object store for entity " + entity.getType()));
    final CompoundTag tag = baseEntity.getNbtData();
    final DataView dataView = tag == null ? DataContainer.createNew(DataView.SafetyMode.NO_DATA_CLONED) : DataViewNbt.from(tag);
    for (String field : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
        dataView.remove(DataQuery.of(field));
    }
    store.deserialize(entity, dataView);
}
 
开发者ID:LanternPowered,项目名称:LanternWorldEdit,代码行数:13,代码来源:LanternWEWorld.java

示例3: setRawData

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public void setRawData(DataView dataView) throws InvalidDataException {
    checkNotNull(dataView, "dataView");
    dataView.remove(DataQueries.FLUID_TYPE);
    this.volume = dataView.getInt(DataQueries.VOLUME).orElse(0);
    IAdditionalDataHolder.super.setRawData(dataView);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:LanternFluidStack.java

示例4: serialize

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public void serialize(T entity, DataView dataView) {
    super.serialize(entity, dataView);
    dataView.remove(HEAD_ROTATION);
    final LanternWorld world = entity.getWorld();
    final UUID uniqueId = world != null ? world.getUniqueId() :
            entity.getTempWorld() != null ? entity.getTempWorld().getUniqueId() : null;
    dataView.set(DIMENSION, uniqueId == null ? 0 : Lantern.getWorldManager().getWorldDimensionId(uniqueId).orElse(0));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:10,代码来源:UserStore.java

示例5: deserialize

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public LanternEntity deserialize(DataView dataView) throws InvalidDataException {
    String id0 = dataView.getString(ID).get();
    final String id;
    // Fast fail if the data isn't old
    if (dataView.getInt(DATA_VERSION).orElse(0) < 704) {
        id = fixEntityId(dataView, id0);
    } else {
        id = id0;
    }
    dataView.remove(ID);

    final LanternEntityType entityType = (LanternEntityType) Sponge.getRegistry().getType(EntityType.class, id).orElseThrow(
            () -> new InvalidDataException("Unknown entity id: " + id));
    //noinspection unchecked
    final ObjectStore<LanternEntity> store = (ObjectStore) ObjectStoreRegistry.get().get(entityType.getEntityClass()).get();
    final UUID uniqueId;
    if (store instanceof IdentifiableObjectStore) {
        uniqueId = ((IdentifiableObjectStore) store).deserializeUniqueId(dataView);
    } else {
        uniqueId = UUID.randomUUID();
    }
    //noinspection unchecked
    final LanternEntity entity = (LanternEntity) entityType.getEntityConstructor().apply(uniqueId);
    store.deserialize(entity, dataView);
    return entity;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:28,代码来源:EntitySerializer.java

示例6: deserialize

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public LanternTileEntity deserialize(DataView dataView) throws InvalidDataException {
    final String id = fixTileId(dataView, dataView.getString(ID).get());
    dataView.remove(ID);

    final LanternTileEntityType tileEntityType = (LanternTileEntityType) Sponge.getRegistry().getType(TileEntityType.class, id).orElseThrow(
            () -> new InvalidDataException("Unknown tile entity id: " + id));
    //noinspection unchecked
    final ObjectStore<LanternTileEntity> store = (ObjectStore)
            ObjectStoreRegistry.get().get(tileEntityType.getTileEntityType()).get();
    //noinspection unchecked
    final LanternTileEntity entity = (LanternTileEntity) tileEntityType.getTileEntityConstructor().get();
    store.deserialize(entity, dataView);
    return entity;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:16,代码来源:TileEntitySerializer.java

示例7: deserialize

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public void deserialize(T object, DataView dataView) {
    final List<DataView> itemViews = dataView.getViewList(ITEMS).orElse(null);
    if (itemViews != null) {
        dataView.remove(ITEMS);
        final OrderedInventory inventory = (OrderedInventory) object.getInventory();
        final ObjectSerializer<LanternItemStack> itemStackSerializer = ObjectSerializerRegistry.get().get(LanternItemStack.class).get();
        for (DataView itemView : itemViews) {
            final int slot = itemView.getByte(SLOT).get() & 0xff;
            final LanternItemStack itemStack = itemStackSerializer.deserialize(itemView);
            inventory.set(new SlotIndex(slot), itemStack);
        }
    }
    super.deserialize(object, dataView);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:16,代码来源:ContainerTileEntityStore.java

示例8: serialize

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public void serialize(LanternItemStack object, DataView dataView) {
    dataView.set(QUANTITY, (byte) object.getQuantity());
    final DataView tag = dataView.createView(TAG);
    super.serialize(object, tag);
    dataView.set(DATA, tag.getShort(ItemTypeObjectSerializer.DATA_VALUE).orElse((short) 0));
    tag.remove(ItemTypeObjectSerializer.DATA_VALUE);
    if (tag.isEmpty()) {
        dataView.remove(TAG);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:12,代码来源:ItemStackStore.java

示例9: setRawData

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public void setRawData(DataView dataView) throws InvalidDataException {
    checkNotNull(dataView, "dataView");
    dataView.remove(DataQueries.ITEM_TYPE);
    this.quantity = dataView.getInt(DataQueries.QUANTITY).orElse(1);
    IAdditionalDataHolder.super.setRawData(dataView);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:LanternItemStack.java

示例10: serialize

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void serialize(T object, DataView dataView) {
    if (object instanceof IValueContainer) {
        final IValueContainer<S> valueContainer = (IValueContainer<S>) object;
        final SimpleValueContainer simpleValueContainer = new SimpleValueContainer(new HashMap<>());

        for (KeyRegistration<?,?> registration : valueContainer.getValueCollection().getAll()) {
            if (!(registration instanceof Element)) {
                continue;
            }
            final Key key = registration.getKey();
            final Object element = ((Element) registration).get();
            if (element != null) {
                simpleValueContainer.set(key, element);
            }
        }

        // Serialize the values, all written values will be removed from
        // the simple value container
        serializeValues(object, simpleValueContainer, dataView);

        // Write the rest to the Values tag
        final Map<Key<?>, Object> values = simpleValueContainer.getValues();
        if (!values.isEmpty()) {
            final DataView valuesView = dataView.createView(VALUES);
            final DataTypeSerializerContext context = Lantern.getGame().getDataManager().getTypeSerializerContext();
            for (Map.Entry<Key<?>, Object> entry : values.entrySet()) {
                final TypeToken<?> typeToken = entry.getKey().getElementToken();
                final DataTypeSerializer dataTypeSerializer = Lantern.getGame().getDataManager().getTypeSerializer(typeToken).orElse(null);
                if (dataTypeSerializer == null) {
                    Lantern.getLogger().warn("Unable to serialize the data key value: " + entry.getKey());
                } else {
                    valuesView.set(DataQuery.of(entry.getKey().getId()),
                            dataTypeSerializer.serialize(typeToken, context, entry.getValue()));
                }
            }
            if (valuesView.isEmpty()) {
                dataView.remove(VALUES);
            }
        }

        DataHelper.serializeRawContainerData(getOrCreateView(dataView, DataQueries.SPONGE_DATA),
                valueContainer, DataQueries.CUSTOM_MANIPULATORS);
    } else {
        // Not sure what to do
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:49,代码来源:CompositeValueContainerStore.java


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