本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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
}
}