[Bug] ServerGamePacketListenerImpl#c field is not found
API version
2.5.4
Server software and version
Paper 1.21.7
Steps to reproduce
- SignGUI#open(Player)
Expected behaviour
open signgui
What is actually happening?
Unable to open signgui normally
Code snippets
java.lang.NoSuchFieldError: Class net.minecraft.server.level.ServerPlayer does not have member field 'net.minecraft.server.network.ServerGamePacketListenerImpl c'
at [REDACTED]-reobf-1756118630957.jar/de.rapha149.signgui.version.MojangWrapper1_21_R5.openSignEditor(MojangWrapper1_21_R5.java:73) ~[[REDACTED]-reobf-1756118630957.jar:?]
at [REDACTED]-reobf-1756118630957.jar/de.rapha149.signgui.SignGUI.open(SignGUI.java:70) ~[[REDACTED]-reobf-1756118630957.jar:?]
at [REDACTED]-reobf-1756118630957.jar/REDACTED.handleClick(REDACTED.kt:58) ~[[REDACTED]-reobf-1756118630957.jar:?]
My plugin is being executed by "ReobfServer" on server startup, I'm not sure if it has anything to do with that?
Any additional comments?
My plugin is being executed by "ReobfServer" on server startup, I'm not sure if it has anything to do with that?
[PluginInitializerManager] Initializing plugins...
[ReobfServer] Remapping server...
[ReobfServer] Done remapping server in 4566ms.
[PluginRemapper] Remapping plugin '[REDACTED]\build\libs\[REDACTED]-reobf.jar'...
[PluginRemapper] Done remapping plugin '[REDACTED]\build\libs\[REDACTED]-reobf.jar' in 3198ms.
Is your plugin a Spigot or Paper plugin?
My plugin is the spigot plugin, and I set paperweight-mappings-namespace to spigot
where/how do you set that namespace?
Here is a test sample that I have provided that can be reproduced directly
import de.rapha149.signgui.SignGUI
import de.rapha149.signgui.SignGUIAction
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerInteractEvent
import org.bukkit.inventory.EquipmentSlot
import org.bukkit.plugin.java.JavaPlugin
class TestSignGui : JavaPlugin() {
override fun onEnable() {
server.pluginManager.registerEvents(TestListener, this)
}
}
object TestListener : Listener {
@EventHandler
fun PlayerInteractEvent.onInteract() {
if (hand == EquipmentSlot.OFF_HAND) return
SignGUI.builder()
.setLine(1, "^^^^^^")
.setHandler { p, result ->
p.sendMessage("You wrote: ${result.linesWithoutColor[0]}")
return@setHandler listOf(SignGUIAction.run {
//...
})
}
.build()
.open(player)
}
}
plugins {
kotlin("jvm") version "2.2.0"
id("com.gradleup.shadow") version "8.3.0"
id("xyz.jpenilla.run-paper") version "2.3.1"
id("io.papermc.paperweight.userdev") version "2.0.0-beta.18"
}
group = "test"
version = "1.0.0"
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/") {
name = "papermc-repo"
}
}
paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.REOBF_PRODUCTION
dependencies {
paperweight.paperDevBundle("1.20.1-R0.1-SNAPSHOT")
// compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("de.rapha149.signgui:signgui:2.5.4")
}
val jvmArgsExternal = listOf(
"-Dcom.mojang.eula.agree=true"
)
tasks {
runServer {
minecraftVersion("1.21.7")
jvmArgs = jvmArgsExternal
}
}
tasks.shadowJar {
manifest {
attributes["paperweight-mappings-namespace"] = "spigot"
}
}
val targetJavaVersion = 21
kotlin {
jvmToolchain(targetJavaVersion)
}
tasks.build {
dependsOn("shadowJar")
}
tasks.processResources {
val props = mapOf("version" to version)
inputs.properties(props)
filteringCharset = "UTF-8"
filesMatching("plugin.yml") {
expand(props)
}
}
./gradlew runServer
Sorry that I'm answering so late. I haven't gotten around to testing this more and I'm going on vacation in a couple of days so unfortunately I won't get to it until after that. However, I quickly implement something that you can try:
I added a new SignGUI#builder method where you can submit a boolean value. If you set this to false the API won't use Mojang mappings (Paper version) but the normal Spigot mappings (only applies the first time you call the method, for subsequent times the value is ignored). I did that because I guess that the error is because you're creating a Paper plugin with Spigot mappings and my API doesn't detect that correctly. So, with this snapshot version you can try that out if you want. If it works I will either implement a better way to tell the API that you want to use Spigot mappings or, if it's possible, implement a check for Paper plugins using Spigot mappings.
Anyway, here is the snapshot version including sources/javadoc if you want to try it out: https://share.rapha149.de/s/qtEMn4xn2pEX
Using this method can be performed correctly and signgui is opened
I do use the spigot mapping to create the paper plugin, and since I need to be compatible with as many versions as possible, considering that the paper plugin 1.20.4 and below have always been spigot mappings, I don't have the option to use the mojnag mapping