fix(spigot): support Mojang-mapped NMS classes (Paper 1.20.5+ / Spigot 1.20.5+)#23
Merged
robinbraemer merged 1 commit intoconnectfrom May 1, 2026
Merged
Conversation
Paper has shipped Mojang mappings by default since 1.20.5, so the NMS class names our reflection bootstrap looked up (NetworkManager, ServerConnection, PacketHandshakingInSetProtocol, PacketLoginInStart, LoginListener, LoginListener$LoginHandler) no longer exist on modern Paper builds. The static block in ClassNames threw on load and the plugin failed to inject. Try the Mojang-mapped name first for each class, falling back to the old Spigot name and then the version-prefixed NMS name: NetworkManager -> Connection ServerConnection -> ServerConnectionListener PacketHandshakingInSetProtocol -> ClientIntentionPacket PacketLoginInStart -> ServerboundHelloPacket LoginListener -> ServerLoginPacketListenerImpl LoginListener$LoginHandler -> ServerLoginPacketListenerImpl$LoginHandler Same pattern for the handshake packet field names: try the Mojang names protocolVersion/port/intention, fall back to obfuscated a/c/d (or b/d on the 1.20.5 obfuscated stream-codec layout). Cross-checked against Floodgate master, which uses the same Mojang class names. Backward compatible with older Spigot/Paper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Spigot/Paper plugin failed to enable on modern Paper, Spigot, and Mojang-mapped servers with:
Since Paper 1.20.5, NMS classes ship under their Mojang names. Our reflection bootstrap in
ClassNamesonly looked up the old Spigot names, so the static initializer threw on every server that didn't transparently remap the JAR for us.Stock Paper has been hiding the bug at runtime by auto-rewriting the FQN string literals via its
PluginRemapper, but the moment the remapper is bypassed (Spigot, Paper forks, plugins built withapi-version >= 1.20.5orpaperweight-mappings-namespace: mojang, or-Dpaper.disablePluginRemapping=true) the bug is exposed.This change tries the Mojang name first for each NMS class, falls back to the old Spigot name, and finally to the version-prefixed NMS name — so we resolve correctly without depending on Paper's remapper.
Class lookups
NetworkManagerConnectionServerConnectionServerConnectionListenerPacketHandshakingInSetProtocolClientIntentionPacketPacketLoginInStartServerboundHelloPacketLoginListenerServerLoginPacketListenerImplLoginListener$LoginHandlerServerLoginPacketListenerImpl$LoginHandlerSame pattern for the handshake packet field names — try Mojang
protocolVersion/port/intentionfirst, fall back to obfuscateda/c/d(1.20.2–1.20.4) orb/d(1.20.5 stream-codec layout).Cross-checked against Floodgate master — same Mojang names, same fallback strategy.
Builds on the partial Mojmap fix in 4b026ae (which only patched
packetListener/qandstartClientVerification/b).Verification
Tested locally on Paper 1.21.11 (build 69, Java 21):
-Dpaper.disablePluginRemapping=true)ClassNotFoundException: net.minecraft.server.ServerConnectionConfiguration 2 reproduces the original user report; configuration 3 proves the fix stands on its own merits.
Credits
Diagnosis based on a v26.1.2 patch shared by ChannyAnh in our community Discord.