use of com.mojang.brigadier.builder.ArgumentBuilder in project MinecraftForge by MinecraftForge.
the class DimensionsCommand method register.
static ArgumentBuilder<CommandSourceStack, ?> register() {
return Commands.literal("dimensions").requires(// permission
cs -> cs.hasPermission(0)).executes(ctx -> {
ctx.getSource().sendSuccess(new TranslatableComponent("commands.forge.dimensions.list"), true);
final Registry<DimensionType> reg = ctx.getSource().registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
Map<ResourceLocation, List<ResourceLocation>> types = new HashMap<>();
for (ServerLevel dim : ctx.getSource().getServer().getAllLevels()) {
types.computeIfAbsent(reg.getKey(dim.dimensionType()), k -> new ArrayList<>()).add(dim.dimension().location());
}
types.keySet().stream().sorted().forEach(key -> {
ctx.getSource().sendSuccess(new TextComponent(key + ": " + types.get(key).stream().map(ResourceLocation::toString).sorted().collect(Collectors.joining(", "))), false);
});
return 0;
});
}
Aggregations