Skip to content

Commit d4101aa

Browse files
fix: handle commands with no package defined
1 parent 736b05f commit d4101aa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/NamespacedCommands.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,17 @@ object NamespacedCommands {
8484
val owner = owners.firstOrNull()
8585

8686
val prefix = owner?.modId ?: owner?.name ?: "unknown"
87-
87+
8888
val helper = "${prefix}:${command.commandName}"
8989
cch.commandMap[helper] = command
9090

9191
aliasMap[command] = helper
9292
}
9393

9494
fun getCommandModOwner(command: Class<*>) : List<ModContainer> {
95-
val packageName = command.`package`.name ?: return emptyList()
95+
val idx = command.name.lastIndexOf(".")
96+
if (idx == -1) return emptyList()
97+
val packageName = command.name.substring(0, idx)
9698
return Loader.instance().modList.filter { packageName in it.ownedPackages }
9799
}
98100

0 commit comments

Comments
 (0)