@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()); }
@Override public boolean isValidMobType(String type) { return Sponge.getRegistry().getType(EntityType.class, type).isPresent(); }
/** * Creates a new {@link Builder} to build a new * {@link WanderAITask}. * * @return A new builder */ static Builder builder() { return Sponge.getRegistry().createBuilder(Builder.class); }
@Override public TextFormat deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException { TextColor color = TextColors.NONE; GameRegistry registry = Sponge.getRegistry(); String colorId = value.getNode(NODE_COLOR).getString(); if (colorId != null) { color = registry.getType(TextColor.class, colorId).orElseThrow(() -> new ObjectMappingException("Color not found: " + colorId)); } TextStyle style = TextStyles.NONE; ConfigurationNode styleNode = value.getNode(NODE_STYLE); for (TextStyle.Base component : registry.getAllOf(TextStyle.Base.class)) { if (styleNode.getNode(component.getId().toLowerCase()).getBoolean()) { style = style.and(component); } } return TextFormat.NONE.color(color).style(style); }
@SuppressWarnings("unchecked") @Override public Value<T> type() { return Sponge.getRegistry().getValueFactory().createValue((Key<Value<T>>) this.usedKey, this.value, this.defaultValue); }
/** * Gets all {@link CatalogType} for Sponge as a base mod. Note that * some {@link CatalogType}s are not originally from the game itself, and * may be provided by Sponge. * * @param typeClass The type of catalog type * @param <T> The type of catalog type * @return The collection of all known types of the requested catalog type */ default <T extends CatalogType> Collection<T> getAllForSponge(Class<T> typeClass) { return getAllFor(PluginManager.SPONGE_PLUGIN_ID, typeClass); }
/** * Gets a locale for the specified locale code, e.g. {@code en_US}. * * @param locale The locale to lookup (e.g. {@code en_US}. * @return The locale */ public static Locale of(String locale) { return Sponge.getRegistry().getLocale(locale); }
@SuppressWarnings("deprecation") static SelectorFactory getFactory() { return Sponge.getRegistry().getSelectorFactory(); }
@Override public final void parameters(final String[] par, final SnipeData v) { if (par.length == 0 || par[0].equalsIgnoreCase("info")) { v.sendMessage(TextColors.AQUA, "Available entity types:"); StringBuilder types = new StringBuilder(); for (EntityType type : Sponge.getRegistry().getAllOf(EntityType.class)) { types.append(", ").append(type.getId().replace("minecraft:", "")); } v.sendMessage(types.toString().substring(2)); } else { Optional<EntityType> selection = Sponge.getRegistry().getType(EntityType.class, par[0]); if (!selection.isPresent()) { v.sendMessage(TextColors.RED, "This is not a valid entity!"); } else { this.entityType = selection.get(); v.sendMessage(TextColors.GREEN, "Entity type set to " + this.entityType.getName()); } } }
@SuppressWarnings("unchecked") @Override protected Value<E> getValueGetter() { return Sponge.getRegistry().getValueFactory().createValue((Key<Value<E>>) this.usedKey, this.value, this.defaultValue); } }
/** * Gets all {@link CatalogType} for Minecraft as a base mod. Note that * some {@link CatalogType}s are not originally from the game itself, and * may be provided by Sponge. * * @param typeClass The type of catalog type * @param <T> The type of catalog type * @return The collection of all known types of the requested catalog type */ default <T extends CatalogType> Collection<T> getAllForMinecraft(Class<T> typeClass) { return getAllFor(PluginManager.MINECRAFT_PLUGIN_ID, typeClass); }
/** * Gets a locale for the specified locale code, e.g. {@code en_US}. * * @param locale The locale to lookup (e.g. {@code en_US}. * @return The locale */ public static Locale of(String locale) { return Sponge.getRegistry().getLocale(locale); }
@SuppressWarnings("deprecation") static SelectorFactory getFactory() { return Sponge.getRegistry().getSelectorFactory(); }
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 <T extends CatalogType> Optional<List<T>> getCatalogTypeList(DataQuery path, Class<T> catalogType) { checkNotNull(path, "path"); checkNotNull(catalogType, "catalogType"); return getStringList(path).map(list -> list.stream() .map(string -> Sponge.getRegistry().getType(catalogType, string)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()) ); }
@Override public final void parameters(final String[] args, final SnipeData v) { if (args[0].equalsIgnoreCase("info")) { v.sendMessage(TextColors.GOLD + "Biome Brush Parameters:"); String availableBiomes = ""; for (BiomeType biome : Sponge.getRegistry().getAllOf(BiomeType.class)) { availableBiomes += ", " + biome.getId(); } availableBiomes = availableBiomes.substring(2); v.sendMessage(TextColors.DARK_BLUE, "Available biomes: ", TextColors.DARK_GREEN, availableBiomes); } else { String biomeName = args[0]; Optional<BiomeType> biome = Sponge.getRegistry().getType(BiomeType.class, biomeName); if (!biome.isPresent()) { v.sendMessage(TextColors.RED, "Unknown biome type: ", TextColors.DARK_AQUA, biomeName); } else { this.selectedBiome = biome.get(); v.sendMessage(TextColors.GOLD, "Currently selected biome type: ", TextColors.DARK_GREEN, this.selectedBiome.getName()); } } }
/** * Creates a new {@link Builder} for constructing a new {@link FallingBlockDamageSource}. * * @return A new builder */ static Builder builder() { return Sponge.getRegistry().createBuilder(Builder.class); }
@SuppressWarnings("unchecked") @Override protected Value<Boolean> getValueGetter() { return Sponge.getRegistry().getValueFactory().createValue((Key<Value<Boolean>>) this.usedKey, this.value, this.defaultValue); }
default <T extends CatalogType> Collection<T> getAllForSponge(Class<T> typeClass) { return getAllFor(PluginManager.SPONGE_PLUGIN_ID, typeClass); }
@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; }