mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
prioritize paper nms on paper servers
This commit is contained in:
parent
6afe51acca
commit
f59071f504
2 changed files with 12 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue