@Override protected Object getValue(String choice) throws IllegalArgumentException { final Optional<T> ret = Sponge.getGame().getRegistry().getType(this.catalogType, choice); if (!ret.isPresent()) { throw new IllegalArgumentException("Invalid input " + choice + " was found"); } return ret.get(); } }
@Override protected Iterable<String> getChoices(CommandSource source) { return Sponge.getGame().getRegistry().getAllOf(this.catalogType).stream() .<String>map(input -> { return input == null ? null : input.getId(); // TODO: ids or names? }) .collect(Collectors.toList()); }
/** * Gets a new Builder instance for {@link WorldArchetype}. * * @return A new builder instance */ static WorldArchetype.Builder builder() { return Sponge.getGame().getRegistry().createBuilder(Builder.class); }
protected Iterable<String> getCompletionChoices(CommandSource source) { return Iterables.concat(getChoices(source), ImmutableSet.of("#first", "#me"), Iterables.transform(Sponge.getGame().getRegistry() .getAllOf(DimensionType.class), input2 -> "#" + input2.getId())); }
@Override public List<BaseBiome> getBiomes() { List<BaseBiome> list = new ArrayList<>(); for (BiomeType biome : Sponge.getGame().getRegistry().getAllOf(BiomeType.class)) { list.add(new BaseBiome(SpongeWorldEdit.inst().getAdapter().resolve(biome))); } return list; }
@Override public void giveItem(BaseItemStack itemStack) { this.player.getInventory().offer( ItemStack.of(Sponge.getGame().getRegistry().getType(ItemType.class, itemStack.getType().getId()).get(), itemStack.getAmount()) ); }
public static GameRegistry getRegistry() { return getGame().getRegistry(); }
@Override protected Object getValue(String choice) throws IllegalArgumentException { final Optional<T> ret = Sponge.getGame().getRegistry().getType(this.catalogType, choice); if (!ret.isPresent()) { throw new IllegalArgumentException("Invalid input " + choice + " was found"); } return ret.get(); } }
@Override protected Iterable<String> getChoices(CommandSource source) { return Sponge.getGame().getRegistry().getAllOf(this.catalogType).stream() .<String>map(input -> { return input == null ? null : input.getId(); // TODO: ids or names? }) .collect(Collectors.toList()); }
/** * Gets a new Builder instance for {@link WorldArchetype}. * * @return A new builder instance */ static WorldArchetype.Builder builder() { return Sponge.getGame().getRegistry().createBuilder(Builder.class); }
public SpongeInventoryUtil() { builder = SpongeMain.THIS.getGame().getRegistry().createBuilder(ItemStack.Builder.class); }
public static BlockState getBlockStateFromString(String rule) { BlockType blockType; Map<String, String> traitSpecifics = new HashMap<>(); if(rule.contains("[") && rule.endsWith("]")) { String subRule = rule.substring(rule.indexOf('['), rule.length()-2); String[] parts = RegexUtil.COMMA_PATTERN.split(subRule); blockType = Sponge.getGame().getRegistry().getType(BlockType.class, rule.substring(0, rule.indexOf('['))).orElse(null); for(String part : parts) { String[] keyValue = RegexUtil.EQUALS_PATTERN.split(part); traitSpecifics.put(keyValue[0].toLowerCase(), keyValue[1]); } } else { blockType = Sponge.getGame().getRegistry().getType(BlockType.class, rule).orElse(null); } if(blockType == null) { return null; } BlockState state = blockType.getDefaultState(); for(Map.Entry<String, String> entry : traitSpecifics.entrySet()) { state.getTrait(entry.getKey()).ifPresent((trait) -> state.withTrait(trait, entry.getValue())); } return state; }
protected Iterable<String> getCompletionChoices(CommandSource source) { return Iterables.concat(getChoices(source), ImmutableSet.of("#first", "#me"), Iterables.transform(Sponge.getGame().getRegistry() .getAllOf(DimensionType.class), input2 -> "#" + input2.getId())); }
String[] parts = RegexUtil.COMMA_PATTERN.split(subRule); blockType = Sponge.getGame().getRegistry().getType(BlockType.class, getRule().substring(0, getRule().indexOf('['))).orElse(null); blockType = Sponge.getGame().getRegistry().getType(BlockType.class, getRule()).orElse(null);
@Override public void onInitialize() throws CraftBookException { super.onInitialize(); footprintParticle = Sponge.getGame().getRegistry().createBuilder(ParticleEffect.Builder.class).type(ParticleTypes.FOOTSTEP).build(); allowedBlocks.load(config); }
@Listener public void onServerAboutToStart(GameAboutToStartServerEvent event) { THIS = this; new PS(this, "Sponge"); this.server = this.game.getServer(); this.game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) PS.get().IMP.getDefaultGenerator().specify(null)); this.game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) new SingleWorldGenerator().specify(null)); if (Settings.Enabled_Components.WORLDS) { TaskManager.IMP.taskRepeat(new Runnable() { @Override public void run() { unload(); } }, 20); } }
@Override public GeneratorWrapper<?> getGenerator(String world, String name) { if (name == null) { return null; } Collection<WorldGeneratorModifier> wgms = this.game.getRegistry().getAllOf(WorldGeneratorModifier.class); for (WorldGeneratorModifier wgm : wgms) { if (StringMan.isEqualIgnoreCaseToAny(name, wgm.getName(), wgm.getId())) { if (wgm instanceof GeneratorWrapper<?>) { return (GeneratorWrapper<?>) wgm; } return new SpongePlotGenerator(wgm); } } return new SpongePlotGenerator(PS.get().IMP.getDefaultGenerator()); }
ItemStack itemStack = Sponge.getGame().getRegistry().createBuilder(ItemStack.Builder.class).itemType(ItemTypes.SKULL) .add(Keys.SKULL_TYPE, skullType).build(); if (profile != null) {