File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,16 @@ import net.minecraftforge.client.ClientCommandHandler
3131import net.minecraftforge.fml.common.Loader
3232import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
3333
34+ /* *
35+ * Namespaced commands is a feature which generates namespaces for commands.
36+ *
37+ * For example, when a mod adds reparty, namespaced commands will generate
38+ * a command that includes the id/name of the mod
39+ *
40+ * `/mod:reparty`
41+ *
42+ * This is useful when multiple mods register a command with the same name
43+ */
3444object NamespacedCommands {
3545 val cch by lazy {
3646 ClientCommandHandler .instance as AccessorCommandHandler
@@ -61,6 +71,9 @@ object NamespacedCommands {
6171 }
6272 }
6373
74+ /* *
75+ * This method takes a command and registers the command's namespaced version.
76+ */
6477 fun registerCommandHelper (command : ICommand ) {
6578 val owners = Loader .instance().modList.filter { command.javaClass.`package`.name in it.ownedPackages }
6679 if (owners.size != 1 ) {
@@ -77,6 +90,12 @@ object NamespacedCommands {
7790 aliasMap[command] = helper
7891 }
7992
93+ /* *
94+ * Handles the actual sending of the command.
95+ *
96+ * When a command is sent using the `server` namespace, it is passed directly to the server
97+ * instead of running a client command.
98+ */
8099 @SubscribeEvent
81100 fun onSendChat (event : SendChatMessageEvent ) {
82101 if (event.message.startsWith(" /server:" )) {
You can’t perform that action at this time.
0 commit comments