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


Java DataView.contains方法代码示例

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


在下文中一共展示了DataView.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: buildContent

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
protected Optional<ParticleEffect> buildContent(DataView container) throws InvalidDataException {
    if (!container.contains(DataQueries.PARTICLE_TYPE, DataQueries.PARTICLE_OPTIONS)) {
        return Optional.empty();
    }
    ParticleType particleType = container.getCatalogType(DataQueries.PARTICLE_TYPE, ParticleType.class).get();
    Map<ParticleOption<?>, Object> options = new HashMap<>();
    container.getViewList(DataQueries.PARTICLE_OPTIONS).get().forEach(view -> {
        ParticleOption option = view.getCatalogType(DataQueries.PARTICLE_OPTION_KEY, ParticleOption.class).get();
        Object value;
        if (option.getValueType().isAssignableFrom(DataSerializable.class)) {
            value = view.getSerializable(DataQueries.PARTICLE_OPTION_VALUE, option.getValueType()).get();
        } else {
            value = view.getObject(DataQueries.PARTICLE_OPTION_VALUE, option.getValueType()).get();
        }
        options.put(option, value);
    });
    return Optional.of(new LanternParticleEffect((LanternParticleType) particleType, options));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:20,代码来源:LanternParticleEffectBuilder.java

示例3: buildContent

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
protected Optional<PotionEffect> buildContent(DataView container) throws InvalidDataException {
    checkNotNull(container);
    if (!container.contains(DataQueries.POTION_TYPE) || !container.contains(DataQueries.POTION_DURATION)
            || !container.contains(DataQueries.POTION_AMPLIFIER) || !container.contains(DataQueries.POTION_AMBIANCE)
            || !container.contains(DataQueries.POTION_SHOWS_PARTICLES)) {
        return Optional.empty();
    }
    String effectName = container.getString(DataQueries.POTION_TYPE).get();
    Optional<PotionEffectType> optional = Sponge.getRegistry().getType(PotionEffectType.class, effectName);
    if (!optional.isPresent()) {
        throw new InvalidDataException("The container has an invalid potion type name: " + effectName);
    }
    int duration = container.getInt(DataQueries.POTION_DURATION).get();
    int amplifier = container.getInt(DataQueries.POTION_AMPLIFIER).get();
    boolean ambient = container.getBoolean(DataQueries.POTION_AMBIANCE).get();
    boolean showParticles = container.getBoolean(DataQueries.POTION_SHOWS_PARTICLES).get();
    return Optional.of(new LanternPotionEffect(optional.get(), duration, amplifier, ambient, showParticles));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:20,代码来源:LanternPotionEffectBuilder.java

示例4: from

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
public Optional<CustomItemData> from(DataView view) {
	if (view.contains(NKeys.CUSTOM_ITEM_DATA_RESTRICTIONS.getQuery())) {
		this.restrictions = (List<String>) view.getList(NKeys.CUSTOM_ITEM_DATA_RESTRICTIONS.getQuery()).orElseGet(() -> new ArrayList<>());
	}
	if (view.contains(NKeys.CUSTOM_ITEM_DATA_ENCHANTEMENTS.getQuery())) {
		Optional map = view.getMap(NKeys.CUSTOM_ITEM_DATA_ENCHANTEMENTS.getQuery());
		enchantements = (Map<String, String>) map.orElseGet(() -> new HashMap<>());
	}

	if (view.contains(NKeys.CUSTOM_ITEM_DATA_ITEM_LEVEL.getQuery())) {
		this.itemLevel = view.getObject(NKeys.CUSTOM_ITEM_DATA_ITEM_LEVEL.getQuery(), Integer.class).orElse(0);

	}
	if (view.contains(NKeys.ITEM_RARITY)) {
		this.rarity = view.getObject(NKeys.ITEM_RARITY.getQuery(), Text.class).orElse(Text.EMPTY);
	}
	if (view.contains(NKeys.CUSTOM_ITEM_DATA_SOCKET_COUNT)) {
		this.socketCount = view.getObject(NKeys.CUSTOM_ITEM_DATA_SOCKET_COUNT.getQuery(), Integer.class).orElse(0);
	}

	return Optional.of(this);

}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:24,代码来源:CustomItemData.java

示例5: build

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public Optional<RottenData> build(DataView container) throws InvalidDataException {
	if (!container.contains(RottenData.UPDATE_TIME.getQuery(), RottenData.AGE.getQuery())) {
           return Optional.empty();
	}
	
	long lastUpdate = container.getLong(RottenData.UPDATE_TIME.getQuery()).get();
	long age = container.getLong(RottenData.AGE.getQuery()).get();
	
	return Optional.of(new RottenData(lastUpdate, age));
}
 
开发者ID:TBlueF,项目名称:RottenFood,代码行数:12,代码来源:RottenDataBuilder.java

示例6: buildContent

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
protected Optional<TrailData> buildContent(DataView container) throws InvalidDataException {
    if (container.contains(TRAIL.getQuery())) {
        final Trail trail = container.getCatalogType(TRAIL.getQuery(), Trail.class).orElse(TrailRegistry.getInstance().getDefaultTrail());
        return Optional.of(new TrailData(trail));
    }
    return Optional.empty();
}
 
开发者ID:gabizou,项目名称:HappyTrails,代码行数:9,代码来源:TrailData.java

示例7: build

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public Optional<InvincibilityData> build(DataView container) throws InvalidDataException {
    if (container.contains(BedrockKeys.IS_INVINCIBLE)) {
        final boolean invincible = container.getBoolean(BedrockKeys.IS_INVINCIBLE.getQuery()).get();
        return Optional.of(new InvincibilityData(invincible));
    }
    return Optional.empty();
}
 
开发者ID:prism,项目名称:Bedrock,代码行数:9,代码来源:InvincibilityDataManipulatorBuilder.java

示例8: fromContainer

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
static Optional<PlayerMountDataCommon> fromContainer(DataView dataContainer)
{
    if (!dataContainer.contains(
            MountKeys.TYPE.getQuery(),
            MountKeys.SPAWN_ITEM.getQuery(),
            MountKeys.LEASH_ITEM.getQuery(),
            MountKeys.CAN_FLY.getQuery(),
            MountKeys.INVINCIBLE.getQuery(),
            MountKeys.MOVE_SPEED.getQuery(),
            MountKeys.LEASH_SPEED.getQuery()))
    {
        return Optional.empty();
    }
    return Optional.of(new PlayerMountDataCommon().set(dataContainer));
}
 
开发者ID:dags-,项目名称:Mounts,代码行数:16,代码来源:PlayerMountDataCommon.java

示例9: buildContent

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
protected Optional<Enchantment> buildContent(DataView container) throws InvalidDataException {
    checkNotNull(container, "The data view cannot be null!");
    if (!container.contains(Queries.ENCHANTMENT_ID, Queries.LEVEL)) {
        return Optional.empty();
    }
    final Optional<EnchantmentType> enchantmentType = container.getCatalogType(Queries.ENCHANTMENT_ID, EnchantmentType.class);
    final int level = container.getInt(Queries.LEVEL).get();
    return enchantmentType.map(t -> Enchantment.builder().type(t).level(level).build());
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:LanternEnchantmentBuilder.java

示例10: checkDataExists

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
public static DataView checkDataExists(DataView dataView, DataQuery query) throws InvalidDataException {
    checkNotNull(dataView);
    checkNotNull(query);
    if (!dataView.contains(query)) {
        throw new InvalidDataException("Missing data for query: " + query.asString('.'));
    } else {
        return dataView;
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:10,代码来源:DataHelper.java

示例11: buildContent

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
protected Optional<BlockState> buildContent(DataView container) throws InvalidDataException {
    if (!container.contains(DataQueries.BLOCK_STATE)) {
        return Optional.empty();
    }
    checkDataExists(container, DataQueries.BLOCK_STATE);
    try {
        return container.getCatalogType(DataQueries.BLOCK_STATE, BlockState.class);
    } catch (Exception e) {
        throw new InvalidDataException("Could not retrieve a block state!", e);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:13,代码来源:LanternBlockStateBuilder.java

示例12: build

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public Optional<ShootingItemData> build(DataView container) throws InvalidDataException {
  if (container.contains(SHOOTING_ITEM_DATA_KEY)) {
    final ItemStackSnapshot snapshot = container.getSerializable(SHOOTING_ITEM_DATA_KEY.getQuery(), ItemStackSnapshot.class).orElse(null);
    return Optional.of(new ShootingItemData(snapshot));
  }

  return Optional.empty();
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:10,代码来源:ShootingItemDataManipulatorBuilder.java

示例13: build

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public Optional<WarpData> build(DataView container) throws InvalidDataException {
    if (!container.contains(WARP.getQuery())) {
        return Optional.empty();
    }
    Warp warp = container.getSerializable(WARP.getQuery(), Warp.class).get();
    return Optional.of(new WarpData(warp));
}
 
开发者ID:RobertHerhold,项目名称:BLWarps,代码行数:9,代码来源:WarpDataManipulatorBuilder.java

示例14: build

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public Optional<Warp> build(DataView container) throws InvalidDataException {
    if (container.contains(NAME, WORLD, X, Y, Z, OWNER)) {
        Warp warp = new Warp(container.getString(OWNER).get(),
                container.getString(NAME).get(),
                container.getString(WORLD).get(),
                new Vector3d(
                        container.getInt(X).get().intValue(),
                        container.getInt(Y).get().intValue(),
                        container.getInt(Z).get().intValue()));
        return Optional.of(warp);
    }
    return Optional.empty();
}
 
开发者ID:RobertHerhold,项目名称:BLWarps,代码行数:15,代码来源:WarpBuilder.java

示例15: build

import org.spongepowered.api.data.DataView; //导入方法依赖的package包/类
@Override
public Optional<SignJobData> build(DataView container) throws InvalidDataException {
    if (container.contains(LiteKeys.JOB_NAME.getQuery())) {
        final String jobName = container.getString(LiteKeys.JOB_NAME.getQuery()).get();
        return Optional.of(new SignJobData(jobName));
    }
    return Optional.empty();
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:9,代码来源:SignJobDataManipulatorBuilder.java


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