Is this the proper way to register multiple subcommands, or is there a cleaner form?
ServerCommandSource source = context.getSource();
source.sendFeedback(
() -> Text.literal("bling-physics mod by SethBling").formatted(Formatting.GREEN),
false
);
return 1;
}));
dispatcher.register(CommandManager.literal("physics")
.then(CommandManager.literal("spawn").executes(context -> {
ServerCommandSource source = context.getSource();
ServerWorld world = source.getWorld();
PhysicsWorld physicsWorld = physicsWorlds.get(world.getRegistryKey());
if (physicsWorld != null) {
physicsWorld.onSpawnCommand(source);
return 1;
} else {
source.sendFeedback(
() -> Text.literal("Physics world not found").formatted(Formatting.RED),
false
);
return -1;
}
})));
dispatcher.register(CommandManager.literal("physics")
.then(CommandManager.literal("clear").executes(context -> {
ServerCommandSource source = context.getSource();
// Iterate through all the worlds
for (PhysicsWorld physicsWorld : physicsWorlds.values()) {
physicsWorld.onClearCommand(source);
}
return 1;
})));```