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

Java GameRegistry类代码示例

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

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



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

示例1: parseValue

import org.spongepowered.api.GameRegistry; //导入依赖的package包/类
@Nullable
@Override
protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
    String arg = args.next().toLowerCase();

    // Try
    GameRegistry registry = Sponge.getRegistry();
    Optional<? extends CatalogType> catalogType = registry.getType(this.type, arg);
    if (!catalogType.isPresent() && !arg.contains(":")) {
        catalogType = registry.getType(this.type, "minecraft:" + arg);
        if (!catalogType.isPresent()) {
            catalogType = registry.getType(this.type, "happytrails:" + arg);
        }
    }

    final String trimmedId = catalogType
        .map(trail -> trail.getId().contains(":") ? trail.getId().split(":")[1] : trail.getId())
        .orElse("");
    if (catalogType.isPresent() && source.hasPermission(this.permissionPrefix + trimmedId)) {
        return catalogType.get();
    }

    throw args.createError(Text.of(TextColors.RED, ""));
}
 
开发者ID:gabizou,项目名称:HappyTrails,代码行数:25,代码来源:TrailCommands.java


示例2: onStart

import org.spongepowered.api.GameRegistry; //导入依赖的package包/类
@Listener
public void onStart(GameInitializationEvent event) {
    this.logger.info("Test Recipes plugin enabled!");

    final GameRegistry gameRegistry = Sponge.getGame().getRegistry();
    gameRegistry.getCraftingRecipeRegistry().register(CraftingRecipe.shapedBuilder()
            .aisle("xy", "yx")
            .where('x', Ingredient.of(ItemTypes.APPLE))
            .where('y', Ingredient.of(ItemTypes.GOLD_NUGGET))
            .result(ItemStack.of(ItemTypes.GOLDEN_APPLE, 2))
            .build("golden_apples", this));
    gameRegistry.getSmeltingRecipeRegistry().register(SmeltingRecipe.builder()
            .ingredient(ItemTypes.GOLDEN_APPLE)
            .result(ItemStack.of(ItemTypes.GOLD_NUGGET, 1))
            .build());
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:17,代码来源:TestRecipesPlugin.java


示例3: getOrCreateWorld

import org.spongepowered.api.GameRegistry; //导入依赖的package包/类
private World getOrCreateWorld(WorldConfig worldConfig) throws Throwable {
  String worldName = worldConfig.getName();
  Optional<World> optTargetWorld = Sponge.getServer().getWorld(worldName);
  if (optTargetWorld.isPresent()) {
    return optTargetWorld.get();
  }

  GameRegistry registry = Sponge.getRegistry();
  String archetypeName = worldConfig.getArchetype();
  WorldArchetype archetype = registry.getType(WorldArchetype.class, archetypeName).orElseThrow((Supplier<Throwable>) () -> {
    return new RuntimeException("No world archetype: " + archetypeName);
  });
  optTargetWorld = service.loadWorld(worldName, archetype);
  service.registerWorld(worldName);
  return optTargetWorld.get();
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:17,代码来源:WorldSystem.java


示例4: HappyTrails

import org.spongepowered.api.GameRegistry; //导入依赖的package包/类
@Inject
private HappyTrails(
        Logger logger,
        GameRegistry registry,
        PluginContainer container,
        @DefaultConfig(sharedRoot = false) Path defaultConfig,
        DataManager dataManager) {
    this.logger = logger;
    this.registry = registry;
    this.manager = dataManager;
    this.container = container;
    this.defaultConfig = defaultConfig;
    this.config = new TrailConfig();
    INSTANCE = this;
}
 
开发者ID:gabizou,项目名称:HappyTrails,代码行数:16,代码来源:HappyTrails.java


示例5: playSound

import org.spongepowered.api.GameRegistry; //导入依赖的package包/类
private static void playSound(String command, Player player, Location<World> location, double pitch)
{
    double volume;
    SoundType soundType;
    GameRegistry registry = Sponge.getRegistry();
    Optional<SoundType> soundTypeOptional = registry.getType(SoundType.class, command);
    if (soundTypeOptional.isPresent())
    {
        volume = 1;
        soundType = soundTypeOptional.get();
    }
    else
    {
        int index = command.lastIndexOf(':');
        String id = index > 0 ? command.substring(0, index).toLowerCase() : "";
        Supplier<RuntimeException> error = () -> new NoSuchElementException("No value available for " + id);
        soundType = registry.getType(SoundType.class, id).orElseThrow(error);
        volume = Double.parseDouble(command.substring(index + 1));
    }
    if (Double.isNaN(pitch))
    {
        player.playSound(soundType, soundCategory, location.getPosition(), volume);
    }
    else
    {
        player.playSound(soundType, soundCategory, location.getPosition(), volume, pitch);
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:29,代码来源:VirtualChestActions.java


示例6: updateWorldGenModifiers

import org.spongepowered.api.GameRegistry; //导入依赖的package包/类
public void updateWorldGenModifiers(List<String> modifiers) {
    final ImmutableSet.Builder<WorldGeneratorModifier> genModifiers = ImmutableSet.builder();
    final GameRegistry registry = Sponge.getRegistry();
    for (String modifier : modifiers) {
        Optional<WorldGeneratorModifier> genModifier = registry.getType(WorldGeneratorModifier.class, modifier);
        if (genModifier.isPresent()) {
            genModifiers.add(genModifier.get());
        } else {
            Lantern.getLogger().error("World generator modifier with id " + modifier +
                    " not found. Missing plugin?");
        }
    }
    this.generatorModifiers = genModifiers.build();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:15,代码来源:LanternWorldProperties.java


示例7: DebugGenerationPopulator

import org.spongepowered.api.GameRegistry; //导入依赖的package包/类
public DebugGenerationPopulator(GameRegistry registry) {
    checkNotNull(registry, "registry");
    final Set<BlockState> blockStates = Sets.newLinkedHashSet();
    for (BlockType blockType : registry.getAllOf(BlockType.class)) {
        blockStates.addAll(blockType.getAllBlockStates().stream()
                .filter(state -> !((LanternBlockState) state).isExtended())
                .collect(Collectors.toList()));
    }
    this.blockStateCache = blockStates.toArray(new BlockState[blockStates.size()]);
    this.size = (int) Math.ceil(Math.sqrt((double) this.blockStateCache.length));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:12,代码来源:DebugGenerationPopulator.java


示例8: getRegistry

import org.spongepowered.api.GameRegistry; //导入依赖的package包/类
@Override
public GameRegistry getRegistry() {
    return null;
}
 
开发者ID:InspireNXE,项目名称:Pulse,代码行数:5,代码来源:SpongeGame.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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