• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Value类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.spongepowered.api.data.value.mutable.Value的典型用法代码示例。如果您正苦于以下问题:Java Value类的具体用法?Java Value怎么用?Java Value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Value类属于org.spongepowered.api.data.value.mutable包,在下文中一共展示了Value类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getImmutableValueFor

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
/**
 * Attempts to get a {@link ImmutableValue} for the given
 * {@link Key}. {@link Optional#empty()} will be returned
 * when it fails.
 *
 * @param key The key
 * @return The immutable value, if success
 */
default <E, R extends ImmutableValue<E>> Optional<R> getImmutableValueFor(Key<? extends BaseValue<E>> key) {
    checkNotNull(key, "key");
    final ImmutableContainerCache cache = getContainerCache();
    if (cache != null) {
        Object value = cache.values.get(key);
        if (value != null) {
            return value == ImmutableContainerCache.NONE ? Optional.empty() : Optional.of((R) value);
        }
    }
    Optional optValue = getRawValueFor((Key) key);
    if (optValue.isPresent() && !(optValue.get() instanceof ImmutableValue)) {
        optValue = Optional.of(((Value) optValue.get()).asImmutable());
    }
    if (cache != null) {
        cache.values.put(key, optValue.orElse(ImmutableContainerCache.NONE));
    }
    return Optional.empty();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:27,代码来源:IImmutableValueHolder.java


示例2: newVariantRegistrationFor

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <M extends VariantData<E, M, I>, I extends ImmutableVariantData<E, I, M>, E> DataManipulatorRegistration<M, I> newVariantRegistrationFor(
        PluginContainer pluginContainer, String id, String name, Class<M> manipulatorType, Class<I> immutableManipulatorType,
        Key<Value<E>> key, E defaultValue) {
    final Base<M, I> base = generateBase(this.abstractVariantDataTypeGenerator, pluginContainer, id, name,
            manipulatorType, immutableManipulatorType, null, null, null, null);
    try {
        base.mutableManipulatorTypeImpl.getField(AbstractVariantDataTypeGenerator.KEY).set(null, key);
        base.mutableManipulatorTypeImpl.getField(AbstractVariantDataTypeGenerator.VALUE).set(null, defaultValue);
        base.immutableManipulatorTypeImpl.getField(AbstractVariantDataTypeGenerator.KEY).set(null, key);
        base.immutableManipulatorTypeImpl.getField(AbstractVariantDataTypeGenerator.VALUE).set(null, defaultValue);
    } catch (IllegalAccessException | NoSuchFieldException e) {
        throw new RuntimeException(e);
    }
    return base.supplier.get();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:17,代码来源:DataManipulatorGenerator.java


示例3: LanternBlockState

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
LanternBlockState(LanternBlockStateMap baseState, ImmutableMap<BlockTrait<?>, Comparable<?>> traitValues) {
    this.traitValues = traitValues;
    this.baseState = baseState;

    ImmutableBiMap.Builder<Key<Value<?>>, BlockTrait<?>> builder = ImmutableBiMap.builder();
    for (BlockTrait trait : traitValues.keySet()) {
        builder.put(((LanternBlockTrait) trait).getKey(), trait);
    }
    this.keyToBlockTrait = builder.build();

    final StringBuilder idBuilder = new StringBuilder();
    idBuilder.append(baseState.getBlockType().getId().substring(baseState.getBlockType().getPluginId().length() + 1));
    if (!traitValues.isEmpty()) {
        idBuilder.append('[');
        final Joiner joiner = Joiner.on(',');
        final List<String> propertyValues = new ArrayList<>();
        for (Map.Entry<BlockTrait<?>, Comparable<?>> entry : traitValues.entrySet()) {
            propertyValues.add(entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase(Locale.ENGLISH));
        }
        idBuilder.append(joiner.join(propertyValues));
        idBuilder.append(']');
    }
    this.name = idBuilder.toString();
    this.id = baseState.getBlockType().getPluginId() + ':' + this.name;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:26,代码来源:LanternBlockState.java


示例4: getArguments

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
@Override
public CommandElement[] getArguments() {
    HashMap<String, Key<Value<Boolean>>> choices = new HashMap<>();
    choices.put("attribute", Keys.HIDE_ATTRIBUTES);
    choices.put("attributes", Keys.HIDE_ATTRIBUTES);
    choices.put("candestroy", Keys.HIDE_CAN_DESTROY);
    choices.put("canbreak", Keys.HIDE_CAN_DESTROY);
    choices.put("canplace", Keys.HIDE_CAN_PLACE);
    choices.put("canplaceon", Keys.HIDE_CAN_PLACE);
    choices.put("ench", Keys.HIDE_ENCHANTMENTS);
    choices.put("enchantment", Keys.HIDE_ENCHANTMENTS);
    choices.put("enchantments", Keys.HIDE_ENCHANTMENTS);
    choices.put("misc", Keys.HIDE_MISCELLANEOUS);
    choices.put("miscellaneous", Keys.HIDE_MISCELLANEOUS);
    choices.put("unbreakable", Keys.HIDE_UNBREAKABLE);

    return new CommandElement[]{
            Arguments.builder(new ChoicesArgument(Text.of("tag"), choices)).onlyOne().usage("attributes/candestroy/canplaceon/enchantments/miscellaneous/unbreakable").build(),
            Arguments.builder(new BooleanArgument(Text.of("enabled"))).usageKey("Enable/Disable").onlyOne().build()
    };
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:22,代码来源:ItemhidetagsCommand.java


示例5: execute

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
    checkIfPlayer(sender);
    checkPermission(sender, ItemPermissions.UC_ITEM_ITEMHIDETAGS_BASE);
    Player p = (Player) sender;

    if (!p.getItemInHand(HandTypes.MAIN_HAND).isPresent() || p.getItemInHand(HandTypes.MAIN_HAND).get().getItem().equals(ItemTypes.NONE)) {
        throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand"));
    }
    ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND).get();

    Key<Value<Boolean>> key = args.<Key<Value<Boolean>>>getOne("tag").get();
    boolean value = args.<Boolean>getOne("enabled").get();

    stack.offer(key, value);
    p.setItemInHand(HandTypes.MAIN_HAND, stack);
    Messages.send(sender, "item.command.itemhidetags.success", "%tag%", key.getName(), "%status%", Messages.getFormatted(value ? "item.command.itemhidetags.hidden" : "item.command.itemhidetags.shown"));
    return CommandResult.success();
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:20,代码来源:ItemhidetagsCommand.java


示例6: toggle

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
private boolean toggle(Player player, Key<Value<Boolean>> key, String settingName)
{
    Optional<PlayerMountDataMutable> optional = player.get(PlayerMountDataMutable.class);
    if (optional.isPresent())
    {
        PlayerMountDataMutable data = optional.get();
        Boolean value = !data.get(key).get();
        player.offer(data.set(key, value));
        messenger().info("Toggled ").stress(settingName).info(" " + (value ? "on" : "off")).tell(player);
        return true;
    }
    messenger().error("You must first create a mount before your can change its properties!").tell(player);
    return false;
}
 
开发者ID:dags-,项目名称:Mounts,代码行数:15,代码来源:UserCommands.java


示例7: set

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
private <T> boolean set(Player player, Key<Value<T>> key, T value)
{
    Optional<PlayerMountDataMutable> optional = player.get(PlayerMountDataMutable.class);
    if (optional.isPresent())
    {
        PlayerMountDataMutable data = optional.get();
        data.set(key, value);
        player.offer(data);
        return true;
    }
    messenger().error("You must first create a mount before your can change its properties!").tell(player);
    return false;
}
 
开发者ID:dags-,项目名称:Mounts,代码行数:14,代码来源:UserCommands.java


示例8: unwrap

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <E> Key<? extends BaseValue<E>> unwrap(Key<? extends BaseValue<Optional<E>>> key) {
    return (Key<Value<E>>) nonOptionalKey.computeIfAbsent(key, key1 -> {
        final TypeToken newElementType = key1.getElementToken().resolveType(optionalType);
        return makeValueKey(newElementType, DataQuery.of('.', key1.getQuery().asString('.') + "Required"),
                key1.getId() + "_required", key1.getName() + "Required");
    });
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:LanternOptionalValue.java


示例9: transform

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
@Override
public Value<T> transform(Function<T, T> function) {
    final T entity = checkNotNull(checkNotNull(function).apply(this.weakReference.get()));
    this.weakReference = new WeakReference<>(entity);
    this.entityId = checkNotNull(entity).getUniqueId();
    return this;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:LanternEntityValue.java


示例10: registerVariant

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
public <M extends VariantData<E, M, I>, I extends ImmutableVariantData<E, I, M>, E> DataManipulatorRegistration<M, I> registerVariant(
        PluginContainer pluginContainer, String id, String name, Class<M> manipulatorType, Class<I> immutableManipulatorType,
        Key<Value<E>> key, E defaultValue) {
    final DataManipulatorRegistration<M, I> registration = this.dataManipulatorGenerator.newVariantRegistrationFor(
            pluginContainer, id, name, manipulatorType, immutableManipulatorType, key, defaultValue);
    return register(registration);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:DataManipulatorRegistry.java


示例11: of

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
/**
 * Creates a new integer trait with the specified name and the possible values.
 * 
 * <p>The possible values array may not be empty.</p>
 * 
 * @param name the name
 * @param key the key that should be attached to the trait
 * @param possibleValues the possible values
 * @return the integer trait
 */
public static IntegerTrait of(String name, Key<? extends Value<Integer>> key, int... possibleValues) {
    checkNotNullOrEmpty(name, "name");
    checkNotNull(possibleValues, "possibleValues");
    checkNotNull(key, "key");
    checkState(possibleValues.length != 0, "possibleValues may not be empty");
    ImmutableSet.Builder<Integer> builder = ImmutableSet.builder();
    for (int possibleValue : possibleValues) {
        builder.add(possibleValue);
    }
    return new LanternIntegerTrait(name, key, builder.build());
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:22,代码来源:LanternIntegerTrait.java


示例12: main

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
public static void main(String... args) {
    test(new TypeToken<Key<?>>() {},
            new TypeToken<Key<BaseValue<?>>>() {});
    test(new TypeToken<Key<BaseValue<?>>>() {},
            new TypeToken<Key<BaseValue<?>>>() {});
    test(new TypeToken<Key<BaseValue<?>>>() {},
            new TypeToken<Key<BaseValue<CatalogType>>>() {});
    test(new TypeToken<Key<BaseValue<?>>>() {},
            new TypeToken<Key<BaseValue<? extends CatalogType>>>() {});
    test(new TypeToken<Key<BaseValue<?>>>() {},
            new TypeToken<Key<BaseValue<? extends Advancement>>>() {});
    test(new TypeToken<Key<BaseValue<Advancement>>>() {},
            new TypeToken<Key<BaseValue<Integer>>>() {});
    test(new TypeToken<Key<BaseValue<Slime>>>() {},
            new TypeToken<Key<BaseValue<? extends EnderDragon>>>() {});
    test(new TypeToken<Key<BaseValue<EnderDragon>>>() {},
            new TypeToken<Key<BaseValue<? extends Living>>>() {});
    test(new TypeToken<Key<BaseValue<EnderDragon>>>() {},
            new TypeToken<Key<BaseValue<? extends Living>>>() {});
    test(TypeToken.of(Key.class),
            new TypeToken<Key<BaseValue<? extends Living>>>() {});

    test(new TypeToken<DataRegistration>() {},
            new TypeToken<DataRegistration<?,?>>() {});
    test(new TypeToken<DataRegistration>() {},
            new TypeToken<DataRegistration<LoreData,?>>() {});
    test(new TypeToken<DataRegistration<?,?>>() {},
            new TypeToken<DataRegistration<LoreData,?>>() {});

    // Enclosing classes testing
    test(new TypeToken<A<Object>.B<Value<Double>>>() {},
            new TypeToken<A<Object>.B<Value<? extends Number>>>() {});
    test(new TypeToken<A<Key<BaseValue<EnderDragon>>>.B<Value<Double>>>() {},
            new TypeToken<A<Key<BaseValue<Slime>>>.B<Value<? extends Number>>>() {});
    test(new TypeToken<A<Key<BaseValue<EnderDragon>>>.B<Value<Double>>>() {},
            new TypeToken<A<Key<BaseValue<? extends Living>>>.B<Value<? extends Number>>>() {});
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:38,代码来源:TypeTokenHelper.java


示例13: isSameVariant

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static boolean isSameVariant(ItemStack itemStack1, ItemStack itemStack2) {
    if (itemStack1.getType() != itemStack2.getType()) {
        return false;
    }

    List<Key<? extends Value<? extends CatalogType>>> keys = Arrays.asList(Keys.BRICK_TYPE, Keys.COAL_TYPE, Keys.COOKED_FISH, Keys.DIRT_TYPE, Keys.DISGUISED_BLOCK_TYPE, Keys.DOUBLE_PLANT_TYPE, Keys.DYE_COLOR, Keys.FISH_TYPE, Keys.GOLDEN_APPLE_TYPE, Keys.PRISMARINE_TYPE, Keys.QUARTZ_TYPE, Keys.SAND_TYPE, Keys.SANDSTONE_TYPE, Keys.SHRUB_TYPE, Keys.STONE_TYPE, Keys.TREE_TYPE, Keys.WALL_TYPE);
    return !keys.stream().map(key -> (Key<Value<CatalogType>>) key).filter(key -> itemStack1.supports(key) && itemStack2.supports(key)).filter(key -> {
        Optional<? extends CatalogType> type1 = itemStack1.get(key);
        Optional<? extends CatalogType> type2 = itemStack2.get(key);
        return type1.isPresent() && type2.isPresent() && type1.get().getId().equals(type2.get().getId());

    }).collect(Collectors.toSet()).isEmpty();
}
 
开发者ID:Musician101,项目名称:ItemBank,代码行数:15,代码来源:IBUtils.java


示例14: world

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
public Value<String> world() {
    return Sponge.getRegistry().getValueFactory().createValue(VigilateKeys.OLD_LOCATION_WORLD, this.world);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:4,代码来源:ViewerData.java


示例15: locX

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
public Value<Double> locX() {
    return Sponge.getRegistry().getValueFactory().createValue(VigilateKeys.OLD_LOCATION_X, this.locX);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:4,代码来源:ViewerData.java


示例16: locY

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
public Value<Double> locY() {
    return Sponge.getRegistry().getValueFactory().createValue(VigilateKeys.OLD_LOCATION_Y, this.locY);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:4,代码来源:ViewerData.java


示例17: locZ

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
public Value<Double> locZ() {
    return Sponge.getRegistry().getValueFactory().createValue(VigilateKeys.OLD_LOCATION_Z, this.locZ);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:4,代码来源:ViewerData.java


示例18: camera

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
public Value<String> camera() {
    return Sponge.getRegistry().getValueFactory().createValue(VigilateKeys.CAMERA, this.camera);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:4,代码来源:ViewerData.java


示例19: gameMode

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
public Value<GameMode> gameMode() {
    return Sponge.getRegistry().getValueFactory().createValue(VigilateKeys.OLD_GAME_MODE, this.gameMode);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:4,代码来源:ViewerData.java


示例20: isFlying

import org.spongepowered.api.data.value.mutable.Value; //导入依赖的package包/类
public Value<Boolean> isFlying() {
    return Sponge.getRegistry().getValueFactory().createValue(VigilateKeys.OLD_IS_FLYING, this.isFlying);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:4,代码来源:ViewerData.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JSONObject类代码示例发布时间:2022-05-21
下一篇:
Java ParquetReader类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap