Skip to content

Commit cfa4ab1

Browse files
committed
Added registry method to register annotated commands directly.
1 parent 6606d1d commit cfa4ab1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/com/github/thiagotgm/modular_commands/api/CommandRegistry.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.slf4j.Logger;
3131
import org.slf4j.LoggerFactory;
3232

33+
import com.github.thiagotgm.modular_commands.command.annotation.AnnotationParser;
3334
import com.github.thiagotgm.modular_commands.registry.ClientCommandRegistry;
3435
import com.github.thiagotgm.modular_commands.registry.ModuleCommandRegistry;
3536

@@ -595,6 +596,19 @@ public void registerAllCommands( CommandRegistry registry ) {
595596

596597
}
597598

599+
/**
600+
* Parses the annotated commands from the given object and registers the parsed main
601+
* commands into this registry.
602+
*
603+
* @param obj The object to parse commands from.
604+
*/
605+
public void registerAnnotatedCommands( Object obj ) {
606+
607+
AnnotationParser parser = new AnnotationParser( obj );
608+
registerAllCommands( parser.parse() ); // Parse an add all commands.
609+
610+
}
611+
598612
/**
599613
* Unregisters a command from this registry.
600614
*

0 commit comments

Comments
 (0)