Skip to content

Commit

Permalink
Command load problem fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Nov 9, 2024
1 parent e3b7049 commit 6fff0e1
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ public interface NMS extends VolatileCodeHandler {
@NotNull NMSVersion getVersion();

void registerCommand(@NotNull CommandModule<BetterCommandSource> module);
void syncCommands(@NotNull Player player);
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class BukkitBootstrapImpl : BukkitBootstrap, JavaPlugin() {
@Volatile
var skipInitialReload = false

override fun onEnable() {
override fun onLoad() {
val pluginManager = Bukkit.getPluginManager()
nms = when (MinecraftVersion.current) {
MinecraftVersion.version1_21_2, MinecraftVersion.version1_21_3 -> kr.toxicity.hud.nms.v1_21_R2.NMSImpl()
Expand All @@ -188,6 +188,11 @@ class BukkitBootstrapImpl : BukkitBootstrap, JavaPlugin() {
return
}
}
nms.registerCommand(CommandManager.module)
}

override fun onEnable() {
val pluginManager = Bukkit.getPluginManager()
bedrockAdapter = if (pluginManager.isPluginEnabled("Geyser-Spigot")) {
GeyserAdapter()
} else if (pluginManager.isPluginEnabled("floodgate")) {
Expand Down Expand Up @@ -268,7 +273,6 @@ class BukkitBootstrapImpl : BukkitBootstrap, JavaPlugin() {
}
}
}
nms.registerCommand(CommandManager.module)
core.start()
scheduler.asyncTask {
if (!skipInitialReload) core.reload()
Expand All @@ -295,7 +299,7 @@ class BukkitBootstrapImpl : BukkitBootstrap, JavaPlugin() {
DatabaseManagerImpl.currentDatabase.load(impl)
task {
sendResourcePack(impl)
nms.syncCommands(player)
player.updateCommands()
HudPlayerJoinEvent(impl).call()
}
}
Expand Down
7 changes: 3 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ plugins {
}

val minecraft = project.properties["minecraft_version"]!!.toString()
val folia = "1.20.6" // TODO bumps version to 1.21.1
val adventure = "4.17.0"
val platform = "4.3.4"
val targetJavaVersion = 21
val velocity = "3.4.0"
val bStats = "3.1.0"
val betterCommand = "1.0"
val betterCommand = "168d199954"

val supportedMinecraftVersions = listOf(
//1.17
Expand Down Expand Up @@ -122,7 +121,7 @@ allprojects {
}
compileKotlin {
compilerOptions {
freeCompilerArgs.addAll(listOf("-jvm-target", "17"))
freeCompilerArgs.addAll(listOf("-jvm-target", "17", "-java-parameters"))
}
}
}
Expand Down Expand Up @@ -186,7 +185,7 @@ fun Project.velocity() = also {
it.dependencies.compileOnly("com.velocitypowered:velocity-proxy:$velocity-SNAPSHOT")
it.dependencies.annotationProcessor("com.velocitypowered:velocity-api:$velocity-SNAPSHOT")
}
fun Project.folia() = dependency("dev.folia:folia-api:$folia-R0.1-SNAPSHOT")
fun Project.folia() = dependency("io.papermc.paper:paper-api:$minecraft-R0.1-SNAPSHOT")
fun Project.adventure() = dependency("net.kyori:adventure-api:$adventure")
.dependency("net.kyori:adventure-text-minimessage:$adventure")
.dependency("net.kyori:adventure-text-serializer-legacy:$adventure")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ class NMSImpl : NMS {
return (player.handle() as CraftPlayer).handle.gameProfile.properties.get("textures").first().value
}

override fun syncCommands(player: Player) {
(Bukkit.getServer() as CraftServer).server.commands.sendCommands((player as CraftPlayer).handle)
}
override fun registerCommand(module: CommandModule<BetterCommandSource>) {
val dispatcher = (Bukkit.getServer() as CraftServer).server.commands.dispatcher
module.build { s: CommandSourceStack ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ class NMSImpl : NMS {
return (player.handle() as CraftPlayer).handle.gameProfile.properties.get("textures").first().value
}

override fun syncCommands(player: Player) {
(Bukkit.getServer() as CraftServer).server.commands.sendCommands((player as CraftPlayer).handle)
}
override fun registerCommand(module: CommandModule<BetterCommandSource>) {
val dispatcher = (Bukkit.getServer() as CraftServer).server.commands.dispatcher
module.build { s: CommandSourceStack ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ class NMSImpl : NMS {
return (player.handle() as CraftPlayer).handle.gameProfile.properties.get("textures").first().value
}

override fun syncCommands(player: Player) {
(Bukkit.getServer() as CraftServer).server.commands.sendCommands((player as CraftPlayer).handle)
}
override fun registerCommand(module: CommandModule<BetterCommandSource>) {
val dispatcher = (Bukkit.getServer() as CraftServer).server.commands.dispatcher
module.build { s: CommandSourceStack ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import net.minecraft.commands.CommandSourceStack
import net.minecraft.network.Connection
import net.minecraft.network.FriendlyByteBuf
import net.minecraft.network.protocol.game.ClientboundBossEventPacket
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.network.ServerGamePacketListenerImpl
import net.minecraft.world.BossEvent
Expand Down Expand Up @@ -112,9 +111,6 @@ class NMSImpl : NMS {
return (player.handle() as CraftPlayer).handle.gameProfile.properties.get("textures").first().value
}

override fun syncCommands(player: Player) {
MinecraftServer.getServer().commands.sendCommands((player as CraftPlayer).handle)
}
override fun registerCommand(module: CommandModule<BetterCommandSource>) {
val dispatcher = (Bukkit.getServer() as CraftServer).server.commands.dispatcher
module.build { s: CommandSourceStack ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import net.minecraft.commands.CommandSourceStack
import net.minecraft.network.Connection
import net.minecraft.network.FriendlyByteBuf
import net.minecraft.network.protocol.game.ClientboundBossEventPacket
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.network.ServerGamePacketListenerImpl
import net.minecraft.world.BossEvent
Expand Down Expand Up @@ -112,9 +111,6 @@ class NMSImpl : NMS {
return (player.handle() as CraftPlayer).handle.gameProfile.properties.get("textures").first().value
}

override fun syncCommands(player: Player) {
MinecraftServer.getServer().commands.sendCommands((player as CraftPlayer).handle)
}
override fun registerCommand(module: CommandModule<BetterCommandSource>) {
val dispatcher = (Bukkit.getServer() as CraftServer).server.commands.dispatcher
module.build { s: CommandSourceStack ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import net.minecraft.commands.CommandSourceStack
import net.minecraft.network.Connection
import net.minecraft.network.FriendlyByteBuf
import net.minecraft.network.protocol.game.ClientboundBossEventPacket
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.network.ServerGamePacketListenerImpl
import net.minecraft.world.BossEvent
Expand Down Expand Up @@ -112,9 +111,6 @@ class NMSImpl : NMS {
return (player.handle() as CraftPlayer).handle.gameProfile.properties.get("textures").first().value
}

override fun syncCommands(player: Player) {
MinecraftServer.getServer().commands.sendCommands((player as CraftPlayer).handle)
}
override fun registerCommand(module: CommandModule<BetterCommandSource>) {
val dispatcher = (Bukkit.getServer() as CraftServer).server.commands.dispatcher
module.build { s: CommandSourceStack ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import net.minecraft.commands.CommandSourceStack
import net.minecraft.network.Connection
import net.minecraft.network.FriendlyByteBuf
import net.minecraft.network.protocol.game.ClientboundBossEventPacket
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.network.ServerGamePacketListenerImpl
import net.minecraft.world.BossEvent
Expand Down Expand Up @@ -112,9 +111,6 @@ class NMSImpl : NMS {
return (player.handle() as CraftPlayer).handle.gameProfile.properties.get("textures").first().value
}

override fun syncCommands(player: Player) {
MinecraftServer.getServer().commands.sendCommands((player as CraftPlayer).handle)
}
override fun registerCommand(module: CommandModule<BetterCommandSource>) {
val dispatcher = (Bukkit.getServer() as CraftServer).server.commands.dispatcher
module.build { s: CommandSourceStack ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import net.minecraft.commands.CommandSourceStack
import net.minecraft.network.Connection
import net.minecraft.network.FriendlyByteBuf
import net.minecraft.network.protocol.game.ClientboundBossEventPacket
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.network.ServerCommonPacketListenerImpl
import net.minecraft.server.network.ServerGamePacketListenerImpl
Expand Down Expand Up @@ -114,9 +113,6 @@ class NMSImpl : NMS {
return (player.handle() as CraftPlayer).handle.gameProfile.properties.get("textures").first().value
}

override fun syncCommands(player: Player) {
MinecraftServer.getServer().commands.sendCommands((player as CraftPlayer).handle)
}
override fun registerCommand(module: CommandModule<BetterCommandSource>) {
val dispatcher = (Bukkit.getServer() as CraftServer).server.commands.dispatcher
module.build { s: CommandSourceStack ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import net.minecraft.commands.CommandSourceStack
import net.minecraft.network.Connection
import net.minecraft.network.FriendlyByteBuf
import net.minecraft.network.protocol.game.ClientboundBossEventPacket
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.network.ServerCommonPacketListenerImpl
import net.minecraft.server.network.ServerGamePacketListenerImpl
Expand Down Expand Up @@ -113,9 +112,6 @@ class NMSImpl : NMS {
return (player.handle() as CraftPlayer).handle.gameProfile.properties.get("textures").first().value
}

override fun syncCommands(player: Player) {
MinecraftServer.getServer().commands.sendCommands((player as CraftPlayer).handle)
}
override fun registerCommand(module: CommandModule<BetterCommandSource>) {
val dispatcher = (Bukkit.getServer() as CraftServer).server.commands.dispatcher
module.build { s: CommandSourceStack ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import net.minecraft.network.Connection
import net.minecraft.network.RegistryFriendlyByteBuf
import net.minecraft.network.chat.ComponentSerialization
import net.minecraft.network.protocol.game.ClientboundBossEventPacket
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.network.ServerCommonPacketListenerImpl
import net.minecraft.server.network.ServerGamePacketListenerImpl
Expand Down Expand Up @@ -119,9 +118,6 @@ class NMSImpl : NMS {
return (player.handle() as CraftPlayer).handle.gameProfile.properties.get("textures").first().value
}

override fun syncCommands(player: Player) {
MinecraftServer.getServer().commands.sendCommands((player as CraftPlayer).handle)
}
override fun registerCommand(module: CommandModule<BetterCommandSource>) {
val dispatcher = (Bukkit.getServer() as CraftServer).server.commands.dispatcher
module.build { s: CommandSourceStack ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import net.minecraft.network.Connection
import net.minecraft.network.RegistryFriendlyByteBuf
import net.minecraft.network.chat.ComponentSerialization
import net.minecraft.network.protocol.game.ClientboundBossEventPacket
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.network.ServerCommonPacketListenerImpl
import net.minecraft.server.network.ServerGamePacketListenerImpl
Expand Down Expand Up @@ -119,9 +118,6 @@ class NMSImpl : NMS {
return (player.handle() as CraftPlayer).handle.gameProfile.properties.get("textures").first().value
}

override fun syncCommands(player: Player) {
MinecraftServer.getServer().commands.sendCommands((player as CraftPlayer).handle)
}
override fun registerCommand(module: CommandModule<BetterCommandSource>) {
val dispatcher = (Bukkit.getServer() as CraftServer).server.commands.dispatcher
module.build { s: CommandSourceStack ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import net.minecraft.network.Connection
import net.minecraft.network.RegistryFriendlyByteBuf
import net.minecraft.network.chat.ComponentSerialization
import net.minecraft.network.protocol.game.ClientboundBossEventPacket
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.network.ServerCommonPacketListenerImpl
import net.minecraft.server.network.ServerGamePacketListenerImpl
Expand Down Expand Up @@ -119,9 +118,6 @@ class NMSImpl : NMS {
return (player.handle() as CraftPlayer).handle.gameProfile.properties.get("textures").first().value
}

override fun syncCommands(player: Player) {
MinecraftServer.getServer().commands.sendCommands((player as CraftPlayer).handle)
}

override fun registerCommand(module: CommandModule<BetterCommandSource>) {
val dispatcher = (Bukkit.getServer() as CraftServer).server.commands.dispatcher
Expand Down

0 comments on commit 6fff0e1

Please sign in to comment.