bump 26.1
This commit is contained in:
parent
fa5142290c
commit
725ba737ae
|
|
@ -1,13 +1,14 @@
|
|||
import io.papermc.paperweight.userdev.ReobfArtifactConfiguration
|
||||
import net.minecrell.pluginyml.paper.PaperPluginDescription
|
||||
|
||||
group = "net.hareworks"
|
||||
version = "1.0"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "2.2.21"
|
||||
id("de.eldoria.plugin-yml.paper") version "0.8.0"
|
||||
kotlin("jvm") version "2.3.21"
|
||||
id("de.eldoria.plugin-yml.paper") version "0.9.0"
|
||||
id("com.gradleup.shadow") version "9.2.2"
|
||||
id("io.papermc.paperweight.userdev") version "2.0.0-beta.19"
|
||||
id("io.papermc.paperweight.userdev") version "2.0.0-beta.21"
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
|
@ -15,25 +16,27 @@ repositories {
|
|||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||
}
|
||||
|
||||
paperweight.reobfArtifactConfiguration = ReobfArtifactConfiguration.MOJANG_PRODUCTION
|
||||
|
||||
dependencies {
|
||||
compileOnly("me.clip:placeholderapi:2.11.6")
|
||||
paperweight.paperDevBundle("1.21.11-R0.1-SNAPSHOT")
|
||||
paperweight.paperDevBundle("26.1.2.build.49-beta")
|
||||
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:2.1.0")
|
||||
implementation("net.hareworks:kommand-lib:1.1")
|
||||
implementation("net.hareworks:permits-lib:1.1")
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.17.0")
|
||||
compileOnly("net.kyori:adventure-text-serializer-plain:4.17.0")
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.26.1")
|
||||
compileOnly("net.kyori:adventure-text-serializer-plain:4.26.1")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(21)
|
||||
jvmToolchain(25)
|
||||
}
|
||||
|
||||
paper {
|
||||
main = "net.hareworks.ghostdisplays.GhostDisplaysPlugin"
|
||||
name = "GhostDisplays"
|
||||
version = project.version as String
|
||||
apiVersion = "1.21"
|
||||
apiVersion = "26.1"
|
||||
foliaSupported = true
|
||||
description = "Invisible display entity controller library."
|
||||
authors = listOf("Hareworks")
|
||||
|
|
@ -63,7 +66,4 @@ tasks {
|
|||
exclude(dependency("org.jetbrains.kotlin:kotlin-stdlib-jdk7"))
|
||||
}
|
||||
}
|
||||
assemble {
|
||||
dependsOn(reobfJar)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 9e1ee75736bbbecc7ef69f229c2bb55a8f4fbce8
|
||||
Subproject commit 99ad5009154115833816ace9c3da5a28ecd77344
|
||||
|
|
@ -2,8 +2,8 @@ package net.hareworks.ghostdisplays.internal.nms
|
|||
|
||||
import io.netty.channel.ChannelDuplexHandler
|
||||
import io.netty.channel.ChannelHandlerContext
|
||||
import java.lang.invoke.MethodHandles
|
||||
import java.util.logging.Level
|
||||
import net.minecraft.network.protocol.game.ServerboundAttackPacket
|
||||
import net.minecraft.network.protocol.game.ServerboundInteractPacket
|
||||
import net.minecraft.world.InteractionHand
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer
|
||||
|
|
@ -35,18 +35,6 @@ internal class InteractionPacketListener(
|
|||
|
||||
companion object {
|
||||
private const val HANDLER_NAME = "ghostdisplays_interact"
|
||||
|
||||
private val ENTITY_ID_GETTER = run {
|
||||
val lookup = MethodHandles.privateLookupIn(
|
||||
ServerboundInteractPacket::class.java,
|
||||
MethodHandles.lookup()
|
||||
)
|
||||
lookup.findGetter(
|
||||
ServerboundInteractPacket::class.java,
|
||||
"entityId",
|
||||
Int::class.javaPrimitiveType
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun injectAll() {
|
||||
|
|
@ -83,46 +71,40 @@ internal class InteractionPacketListener(
|
|||
private fun createHandler(player: Player): ChannelDuplexHandler {
|
||||
return object : ChannelDuplexHandler() {
|
||||
override fun channelRead(ctx: ChannelHandlerContext, msg: Any) {
|
||||
if (msg is ServerboundInteractPacket) {
|
||||
try {
|
||||
val entityId = ENTITY_ID_GETTER.invoke(msg) as Int
|
||||
val data = extractAction(entityId, msg)
|
||||
onInteract(player, data)
|
||||
} catch (ex: Throwable) {
|
||||
plugin.logger.log(Level.WARNING, "Failed to handle interact packet", ex)
|
||||
try {
|
||||
when (msg) {
|
||||
is ServerboundInteractPacket -> {
|
||||
val pos = msg.location()
|
||||
onInteract(
|
||||
player,
|
||||
InteractData(
|
||||
entityId = msg.entityId(),
|
||||
action = InteractAction.INTERACT_AT,
|
||||
hand = toBukkit(msg.hand()),
|
||||
clickPosition = org.bukkit.util.Vector(pos.x, pos.y, pos.z),
|
||||
),
|
||||
)
|
||||
}
|
||||
is ServerboundAttackPacket -> {
|
||||
onInteract(
|
||||
player,
|
||||
InteractData(
|
||||
entityId = msg.entityId(),
|
||||
action = InteractAction.ATTACK,
|
||||
hand = null,
|
||||
clickPosition = null,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (ex: Throwable) {
|
||||
plugin.logger.log(Level.WARNING, "Failed to handle interact packet", ex)
|
||||
}
|
||||
super.channelRead(ctx, msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun extractAction(entityId: Int, packet: ServerboundInteractPacket): InteractData {
|
||||
var action = InteractAction.ATTACK
|
||||
var hand: EquipmentSlot? = null
|
||||
var clickPos: org.bukkit.util.Vector? = null
|
||||
|
||||
packet.dispatch(object : ServerboundInteractPacket.Handler {
|
||||
override fun onInteraction(nmsHand: InteractionHand) {
|
||||
action = InteractAction.INTERACT
|
||||
hand = toBukkit(nmsHand)
|
||||
}
|
||||
|
||||
override fun onInteraction(nmsHand: InteractionHand, pos: net.minecraft.world.phys.Vec3) {
|
||||
action = InteractAction.INTERACT_AT
|
||||
hand = toBukkit(nmsHand)
|
||||
clickPos = org.bukkit.util.Vector(pos.x, pos.y, pos.z)
|
||||
}
|
||||
|
||||
override fun onAttack() {
|
||||
action = InteractAction.ATTACK
|
||||
hand = null
|
||||
}
|
||||
})
|
||||
|
||||
return InteractData(entityId, action, hand, clickPos)
|
||||
}
|
||||
|
||||
private fun toBukkit(hand: InteractionHand): EquipmentSlot = when (hand) {
|
||||
InteractionHand.MAIN_HAND -> EquipmentSlot.HAND
|
||||
InteractionHand.OFF_HAND -> EquipmentSlot.OFF_HAND
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user