Only use nms classes when needed
This commit is contained in:
@@ -29,8 +29,9 @@ object BrigardierSupport {
|
|||||||
* and to manage and dispatch the brigardier commands for
|
* and to manage and dispatch the brigardier commands for
|
||||||
* all players on the server.
|
* all players on the server.
|
||||||
*/
|
*/
|
||||||
|
@Suppress("HasPlatformType") // do not refer non-lazily to the type in this class
|
||||||
@NMS_General
|
@NMS_General
|
||||||
val commandManager: net.minecraft.commands.CommandDispatcher by lazy {
|
val commandManager by lazy {
|
||||||
(server as CraftServer).server.commandDispatcher
|
(server as CraftServer).server.commandDispatcher
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,11 +46,14 @@ object BrigardierSupport {
|
|||||||
|
|
||||||
@NMS_General
|
@NMS_General
|
||||||
internal fun registerAll() {
|
internal fun registerAll() {
|
||||||
commands.forEach { commandDispatcher.register(it) }
|
|
||||||
executedDefaultRegistration = true
|
executedDefaultRegistration = true
|
||||||
|
|
||||||
|
if (commands.isNotEmpty()) {
|
||||||
|
commands.forEach { commandDispatcher.register(it) }
|
||||||
if (onlinePlayers.isNotEmpty())
|
if (onlinePlayers.isNotEmpty())
|
||||||
updateCommandTree()
|
updateCommandTree()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NMS_1_17
|
@NMS_1_17
|
||||||
fun updateCommandTree() {
|
fun updateCommandTree() {
|
||||||
|
Reference in New Issue
Block a user