mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Generic gui tester and generic paper nms
This commit is contained in:
parent
f5a89fea7c
commit
fc94dbe169
12 changed files with 144 additions and 78 deletions
|
|
@ -0,0 +1,54 @@
|
|||
package xyz.alexcrea.cuanvil.dependency
|
||||
|
||||
import xyz.alexcrea.cuanvil.update.UpdateUtils
|
||||
|
||||
object MinecraftVersionUtil {
|
||||
|
||||
val craftbukkitVersion: String?
|
||||
get() {
|
||||
val versionParts = UpdateUtils.currentMinecraftVersionArray()
|
||||
if (versionParts[0] != 1) return null
|
||||
|
||||
return when (versionParts[1]) {
|
||||
17 -> when (versionParts[2]) {
|
||||
0, 1 -> "1_17R1"
|
||||
else -> null
|
||||
}
|
||||
|
||||
18 -> when (versionParts[2]) {
|
||||
0, 1 -> "1_18R1"
|
||||
2 -> "1_18R2"
|
||||
else -> null
|
||||
}
|
||||
|
||||
19 -> when (versionParts[2]) {
|
||||
0, 1, 2 -> "1_19R1"
|
||||
3 -> "1_19R2"
|
||||
4 -> "1_19R3"
|
||||
else -> null
|
||||
}
|
||||
|
||||
20 -> when (versionParts[2]) {
|
||||
0, 1 -> "1_20R1"
|
||||
2 -> "1_20R2"
|
||||
3, 4 -> "1_20R3"
|
||||
5, 6 -> "1_20R4"
|
||||
else -> null
|
||||
}
|
||||
|
||||
21 -> when (versionParts[2]) {
|
||||
0, 1 -> "1_21R1"
|
||||
2, 3 -> "1_21R2"
|
||||
4 -> "1_21R3"
|
||||
5 -> "1_21R4"
|
||||
6, 7, 8 -> "1_21R5"
|
||||
9, 10 -> "1_21R6"
|
||||
11 -> "1_21R7"
|
||||
else -> null
|
||||
}
|
||||
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.packet
|
||||
|
||||
import org.bukkit.Bukkit
|
||||
import su.nightexpress.nightcore.bridge.paper.PaperBridge
|
||||
import xyz.alexcrea.cuanvil.dependency.MinecraftVersionUtil
|
||||
import xyz.alexcrea.cuanvil.dependency.packet.versions.*
|
||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
||||
import xyz.alexcrea.cuanvil.update.UpdateUtils
|
||||
|
||||
object PacketManagerSelector {
|
||||
|
|
@ -10,7 +13,9 @@ object PacketManagerSelector {
|
|||
return if (forceProtocolib)
|
||||
protocolibIfPresent
|
||||
else
|
||||
versionSpecificManager ?: protocolibIfPresent
|
||||
reobfPacketManager ?:
|
||||
if(PlatformUtil.isPaper) PaperPacketManager()
|
||||
else protocolibIfPresent
|
||||
}
|
||||
|
||||
private val protocolibIfPresent: PacketManager
|
||||
|
|
@ -19,52 +24,21 @@ object PacketManagerSelector {
|
|||
ProtocoLibWrapper()
|
||||
else
|
||||
NoPacketManager()
|
||||
private val versionSpecificManager: PacketManagerBase?
|
||||
|
||||
// Reobfuscated packet manager for spigot or paper as it remap
|
||||
private val reobfPacketManager: PacketManagerBase?
|
||||
get() {
|
||||
val versionParts = UpdateUtils.currentMinecraftVersionArray()
|
||||
if (versionParts[0] != 1) return null
|
||||
|
||||
return when (versionParts[1]) {
|
||||
// Can't support 1.16.5 bc 1.16.5 paper userdev do not exist
|
||||
try {
|
||||
val clazz = Class.forName("xyz.alexcrea.cuanvil.dependency.packet.versions." +
|
||||
"V${MinecraftVersionUtil.craftbukkitVersion}_PacketManager")
|
||||
|
||||
17 -> when (versionParts[2]) {
|
||||
0, 1 -> V1_17R1_PacketManager()
|
||||
else -> null
|
||||
}
|
||||
|
||||
18 -> when (versionParts[2]) {
|
||||
0, 1 -> V1_18R1_PacketManager()
|
||||
2 -> V1_18R2_PacketManager()
|
||||
else -> null
|
||||
}
|
||||
|
||||
19 -> when (versionParts[2]) {
|
||||
0, 1, 2 -> V1_19R1_PacketManager()
|
||||
3 -> V1_19R2_PacketManager()
|
||||
4 -> V1_19R3_PacketManager()
|
||||
else -> null
|
||||
}
|
||||
|
||||
20 -> when (versionParts[2]) {
|
||||
0, 1 -> V1_20R1_PacketManager()
|
||||
2 -> V1_20R2_PacketManager()
|
||||
3, 4 -> V1_20R3_PacketManager()
|
||||
5, 6 -> V1_20R4_PacketManager()
|
||||
else -> null
|
||||
}
|
||||
|
||||
21 -> when (versionParts[2]) {
|
||||
0, 1 -> V1_21R1_PacketManager()
|
||||
2, 3 -> V1_21R2_PacketManager()
|
||||
4 -> V1_21R3_PacketManager()
|
||||
5 -> V1_21R4_PacketManager()
|
||||
6, 7, 8 -> V1_21R5_PacketManager()
|
||||
9, 10 -> V1_21R6_PacketManager()
|
||||
11 -> V1_21R7_PacketManager()
|
||||
else -> null
|
||||
}
|
||||
|
||||
else -> null
|
||||
val manager = clazz.getConstructor().newInstance()
|
||||
return manager as PacketManagerBase
|
||||
} catch (e: ClassNotFoundException) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ import org.bukkit.plugin.Plugin
|
|||
|
||||
class BukkitScheduler : TaskScheduler {
|
||||
|
||||
override fun scheduleGlobally(plugin: Plugin, task: Runnable, time: Long): Any? {
|
||||
override fun scheduleGlobally(plugin: Plugin, task: Runnable, time: Long): Any {
|
||||
return Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, task, time)
|
||||
}
|
||||
|
||||
|
||||
override fun scheduleOnEntity(plugin: Plugin, entity: Entity, task: Runnable, time: Long): Any? {
|
||||
override fun scheduleOnEntity(plugin: Plugin, entity: Entity, task: Runnable, time: Long): Any {
|
||||
return Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, task, time)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue