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


Java DataContainer.set方法代码示例

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


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

示例1: serializeInventory

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static List<DataView> serializeInventory(Inventory inventory) {
	DataContainer container;
	List<DataView> slots = new LinkedList<>();

	int i = 0;
	Optional<ItemStack> stack;

	for (Inventory inv : inventory.slots()) {
		stack = inv.peek();

		if (stack.isPresent()) {
			container = new org.spongepowered.api.data.MemoryDataContainer();

			container.set(SLOT, i);
			container.set(STACK, serializeItemStack(stack.get()));

			slots.add(container);
		}

		i++;
	}

	return slots;
}
 
开发者ID:AuraDevelopmentTeam,项目名称:InvSync,代码行数:26,代码来源:InventorySerializer.java

示例2: serialize

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
public static DataContainer serialize(VirtualChestPlugin plugin, VirtualChestItem item) throws InvalidDataException
{
    DataContainer container = new MemoryDataContainer();
    container.set(ITEM, item.serializedStack);
    item.primaryAction.getObjectForSerialization().ifPresent(o -> container.set(PRIMARY_ACTION, o));
    item.secondaryAction.getObjectForSerialization().ifPresent(o -> container.set(SECONDARY_ACTION, o));
    if (!item.requirements.getFirst().isEmpty())
    {
        container.set(REQUIREMENTS, item.requirements.getFirst());
    }
    if (!item.ignoredPermissions.isEmpty())
    {
        container.set(IGNORED_PERMISSIONS, item.ignoredPermissions);
    }
    return container;
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:17,代码来源:VirtualChestItem.java

示例3: toContainer

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
@Override
public DataContainer toContainer() {
    List<String> ownerContainers = new ArrayList<String>();
    for (GameProfile profile : owners) {
        ownerContainers.add(profile.getUniqueId().toString());
    }

    DataContainer data = new MemoryDataContainer();
    data.set(DataQueries.Uuid, uuid.toString());
    data.set(DataQueries.ZoneName, name);
    data.set(DataQueries.Owners, ownerContainers);
    data.set(DataQueries.ZonePermissions, permissions);

    // Zone permissions
    Map<String, DataContainer> profileMap = new HashMap<String, DataContainer>();
    for (Entry<GameProfile, ZonePermissions> entry : userPermissions.entrySet()) {
        profileMap.put(entry.getKey().getUniqueId().toString(), entry.getValue().toContainer());
    }

    data.set(DataQueries.UserPermissions, profileMap);

    // Volume
    data.set(DataQueries.Volume, volume.toContainer());

    return data;
}
 
开发者ID:prism,项目名称:SafeGuard,代码行数:27,代码来源:Zone.java

示例4: toContainer

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
@Override
public DataContainer toContainer() {
    // Volume
    DataContainer data = new MemoryDataContainer();

    // Min Coord
    DataContainer minData = new MemoryDataContainer();
    minData.set(DataQueries.X, min.getX());
    minData.set(DataQueries.Y, min.getY());
    minData.set(DataQueries.Z, min.getZ());
    data.set(DataQueries.Min, minData);

    // Max Coord
    DataContainer maxData = new MemoryDataContainer();
    maxData.set(DataQueries.X, max.getX());
    maxData.set(DataQueries.Y, max.getY());
    maxData.set(DataQueries.Z, max.getZ());
    data.set(DataQueries.Max, maxData);

    // World
    data.set(DataQueries.World, extent.getUniqueId().toString());

    return data;
}
 
开发者ID:prism,项目名称:SafeGuard,代码行数:25,代码来源:CuboidVolume.java

示例5: translate

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
@Override
public DataContainer translate(ConfigurationNode node) throws InvalidDataException {
    checkNotNull(node, "node");
    final DataContainer container = DataContainer.createNew(DataView.SafetyMode.NO_DATA_CLONED);
    final Object value = node.getValue();
    final Object key = node.getKey();
    if (value != null) {
        if (key == null || value instanceof Map || value instanceof List) {
            if (value instanceof Map) {
                //noinspection unchecked
                for (Map.Entry<Object, Object> entry : ((Map<Object, Object>) value).entrySet()) {
                    container.set(DataQuery.of('.', entry.getKey().toString()), entry.getValue());
                }
            } else if (key != null) {
                container.set(DataQuery.of(key.toString()), value);
            }
        } else {
            container.set(DataQuery.of('.', key.toString()), value);
        }
    }
    return container;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:23,代码来源:ConfigurateTranslator.java

示例6: toContainer

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
public static DataContainer toContainer(IValueContainer valueContainer) {
    final DataContainer dataContainer = DataContainer.createNew();
    final ValueCollection valueCollection = valueContainer.getValueCollection();
    final LanternDataManager dataManager = Lantern.getGame().getDataManager();
    for (KeyRegistration<?,?> registration : valueCollection.getAll()) {
        if (!(registration instanceof Element)) {
            continue;
        }
        final Key<?> key = registration.getKey();
        final DataQuery dataQuery = key.getQuery();
        final TypeToken<?> typeToken = key.getElementToken();
        final DataTypeSerializer typeSerializer = dataManager.getTypeSerializer(typeToken)
                .orElseThrow(() -> new IllegalStateException("Wasn't able to find a type serializer for the element type: " + typeToken.toString()));
        final DataTypeSerializerContext context = dataManager.getTypeSerializerContext();
        // The value's shouldn't be null inside a data manipulator,
        // since it doesn't support removal of values
        dataContainer.set(dataQuery, typeSerializer.serialize(typeToken, context,
                checkNotNull(((Element) registration).get(), "element")));
    }
    return dataContainer;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:22,代码来源:DataHelper.java

示例7: serialize

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<DataView> serialize(TypeToken<?> type, DataTypeSerializerContext ctx, Multimap<?, ?> obj) throws InvalidDataException {
    final TypeToken<?> keyType = type.resolveType(this.keyTypeVariable);
    final TypeToken<?> valueType = type.resolveType(this.valueTypeVariable);
    final DataTypeSerializer keySerial = ctx.getSerializers().getTypeSerializer(keyType)
            .orElseThrow(() -> new IllegalStateException("Wasn't able to find a type serializer for: " + keyType.toString()));
    final DataTypeSerializer valueSerial = ctx.getSerializers().getTypeSerializer(valueType)
            .orElseThrow(() -> new IllegalStateException("Wasn't able to find a type serializer for: " + valueType.toString()));
    final List<DataView> dataViews = new ArrayList<>();
    for (Object key : obj.keySet()) {
        final DataContainer dataContainer = DataContainer.createNew();
        dataContainer.set(KEY, keySerial.serialize(keyType, ctx, key));
        final Collection<Object> values = ((Multimap) obj).get(key);
        if (values.size() == 1) {
            dataContainer.set(VALUE, valueSerial.serialize(valueType, ctx, values.iterator().next()));
        } else {
            dataContainer.set(ENTRIES, values.stream().map(v -> valueSerial.serialize(valueType, ctx, v)).collect(Collectors.toList()));
        }
        dataViews.add(dataContainer);
    }
    return dataViews;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:24,代码来源:DataTypeSerializers.java

示例8: load

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
public static void load(Path dataFolder, AbstractUser player) throws IOException {
    final String fileName = player.getUniqueId().toString() + ".dat";

    // Search for the player data and load it
    Path dataFile = dataFolder.resolve(PLAYER_DATA_FOLDER).resolve(fileName);
    if (Files.exists(dataFile)) {
        final DataContainer dataContainer = NbtStreamUtils.read(Files.newInputStream(dataFile), true);

        // Load sponge data if present and attach it to the main data
        dataFile = dataFolder.resolve(SPONGE_PLAYER_DATA_FOLDER).resolve(fileName);
        if (Files.exists(dataFile)) {
            final DataContainer spongeDataContainer = NbtStreamUtils.read(Files.newInputStream(dataFile), true);
            dataContainer.set(DataQueries.EXTENDED_SPONGE_DATA, spongeDataContainer);
        }

        final ObjectStore<AbstractUser> objectStore = ObjectStoreRegistry.get().get(AbstractUser.class).get();
        objectStore.deserialize(player, dataContainer);
    }

    final Path statisticsFile = dataFolder.resolve(STATISTICS_FOLDER).resolve(player.getUniqueId().toString() + ".json");
    if (Files.exists(statisticsFile)) {
        player.getStatisticMap().load(statisticsFile);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:25,代码来源:UserIO.java

示例9: toContainer

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
@Override
public DataContainer toContainer() {
    final DataContainer container = DataContainer.createNew()
            .set(UNIQUE_ID, this.uniqueId.toString());
    if (this.name != null) {
        container.set(NAME, this.name);
    }
    if (!this.properties.isEmpty()) {
        final DataContainer propertiesMap = DataContainer.createNew();
        for (String key : this.properties.keySet()) {
            final List<DataContainer> entries = new ArrayList<>();
            for (ProfileProperty property : this.properties.get(key)) {
                final DataContainer entry = DataContainer.createNew()
                        .set(VALUE, property.getValue());
                property.getSignature().ifPresent(signature -> entry.set(SIGNATURE, signature));
                entries.add(entry);
            }
            propertiesMap.set(DataQuery.of(key), entries);
        }
        container.set(PROPERTIES, propertiesMap);
    }
    return container;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:24,代码来源:LanternGameProfile.java

示例10: toContainer

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
@Override
public DataContainer toContainer() {
	DataContainer container = new MemoryDataContainer();
	if (restrictions != null) {
		container = container.set(NKeys.CUSTOM_ITEM_DATA_RESTRICTIONS.getQuery(), this.restrictions);
	}
	if (enchantements != null) {
		container = container.set(NKeys.CUSTOM_ITEM_DATA_ENCHANTEMENTS.getQuery(), this.enchantements);
	}
	if (itemLevel != null) {
		container = container.set(NKeys.CUSTOM_ITEM_DATA_ITEM_LEVEL.getQuery(), this.itemLevel);
	}

	if (rarity != null) {
		container = container.set(NKeys.ITEM_RARITY.getQuery(), this.rarity);
	}

	if (socketCount != null) {
		container = container.set(NKeys.CUSTOM_ITEM_DATA_SOCKET_COUNT.getQuery(), this.socketCount);
	}
	return container;
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:23,代码来源:CustomItemData.java

示例11: toContainer

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
@Override
public DataContainer toContainer() {
	DataContainer c = super.toContainer();
	
	c.set(UPDATE_TIME, this.lastUpdate);
	c.set(AGE, this.age);
	
	return c;
}
 
开发者ID:TBlueF,项目名称:RottenFood,代码行数:10,代码来源:RottenData.java

示例12: toContainer

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
@Override
public DataContainer toContainer() {
	DataContainer c = super.toContainer();
	
	c.set(RottenData.UPDATE_TIME, this.lastUpdate);
	c.set(RottenData.AGE, this.age);
	
	return c;
}
 
开发者ID:TBlueF,项目名称:RottenFood,代码行数:10,代码来源:ImmutableRottenData.java

示例13: toContainer

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
@Override
public DataContainer toContainer() {
    DataContainer permsissions = new MemoryDataContainer();

    for (Entry<String, Boolean> entry : permissions.entrySet()) {
        permsissions.set(DataQuery.of(entry.getKey()), entry.getValue());
    }

    return permsissions;
}
 
开发者ID:prism,项目名称:SafeGuard,代码行数:11,代码来源:ZonePermissions.java

示例14: serialize

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
@Override
public DataView serialize(LanternItemStack object) {
    final DataContainer dataContainer = DataContainer.createNew(DataView.SafetyMode.NO_DATA_CLONED);
    dataContainer.set(IDENTIFIER, object.getType().getId());
    serialize(object, dataContainer);
    return dataContainer;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:ItemStackStore.java

示例15: toContainer

import org.spongepowered.api.data.DataContainer; //导入方法依赖的package包/类
@Override
public DataContainer toContainer() {
    final DataContainer dataContainer = DataContainer.createNew();
    dataContainer.set(DataQuery.of("BlockType"), this.baseState.getBlockType().getId());
    for (Map.Entry<BlockTrait<?>, Comparable<?>> entry : this.traitValues.entrySet()) {
        final Object value = entry.getValue();
        dataContainer.set(((LanternBlockTrait) entry.getKey()).getKey().getQuery(), value);
    }
    return dataContainer;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:LanternBlockState.java


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