prioritize paper nms on paper servers

This commit is contained in:
alexcrea 2026-03-09 22:43:57 +01:00
parent 6afe51acca
commit f59071f504
Signed by: alexcrea
GPG key ID: E346CD16413450E3
2 changed files with 12 additions and 5 deletions

View file

@ -26,7 +26,6 @@ import org.bukkit.plugin.RegisteredListener
import xyz.alexcrea.cuanvil.dependency.DependencyManager
import xyz.alexcrea.cuanvil.dependency.packet.NoPacketManager
import xyz.alexcrea.cuanvil.dependency.packet.ProtocoLibWrapper
import xyz.alexcrea.cuanvil.dependency.packet.versions.PaperPacketManager
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener
import xyz.alexcrea.cuanvil.util.MetricsUtil

View file

@ -8,14 +8,22 @@ import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
import xyz.alexcrea.cuanvil.update.UpdateUtils
object PacketManagerSelector {
private const val PAPER_CRAFT_PLAYER_CLASS = "org.bukkit.craftbukkit.entity.CraftPlayer"
fun selectPacketManager(forceProtocolib: Boolean): PacketManager {
// Try to find version
return if (forceProtocolib)
protocolibIfPresent
else
reobfPacketManager ?:
if(PlatformUtil.isPaper) PaperPacketManager()
else protocolibIfPresent
else {
try {
Class.forName(PAPER_CRAFT_PLAYER_CLASS)
return PaperPacketManager()
} catch (_: ClassNotFoundException) {
return reobfPacketManager ?: protocolibIfPresent
}
}
}
private val protocolibIfPresent: PacketManager