Skip to content

fix(spigot): support Mojang-mapped NMS classes (Paper 1.20.5+ / Spigot 1.20.5+)#23

Merged
robinbraemer merged 1 commit intoconnectfrom
fix/paper-mojmap-classnames
May 1, 2026
Merged

fix(spigot): support Mojang-mapped NMS classes (Paper 1.20.5+ / Spigot 1.20.5+)#23
robinbraemer merged 1 commit intoconnectfrom
fix/paper-mojmap-classnames

Conversation

@robinbraemer
Copy link
Copy Markdown
Member

@robinbraemer robinbraemer commented May 1, 2026

Summary

The Spigot/Paper plugin failed to enable on modern Paper, Spigot, and Mojang-mapped servers with:

java.lang.ExceptionInInitializerError
Caused by: java.lang.ClassNotFoundException: net.minecraft.server.ServerConnection

Since Paper 1.20.5, NMS classes ship under their Mojang names. Our reflection bootstrap in ClassNames only 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 with api-version >= 1.20.5 or paperweight-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

Spigot (old) Mojang (Paper 1.20.5+)
NetworkManager Connection
ServerConnection ServerConnectionListener
PacketHandshakingInSetProtocol ClientIntentionPacket
PacketLoginInStart ServerboundHelloPacket
LoginListener ServerLoginPacketListenerImpl
LoginListener$LoginHandler ServerLoginPacketListenerImpl$LoginHandler

Same pattern for the handshake packet field names — try Mojang protocolVersion / port / intention first, fall back to obfuscated a / c / d (1.20.2–1.20.4) or b / 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/q and startClientVerification/b).

Verification

Tested locally on Paper 1.21.11 (build 69, Java 21):

Configuration Plugin code Auto-remapper Result
1 this PR enabled (default) ✅ plugin loads, login works (offline + via Connect tunnel)
2 old (origin/connect) disabled (-Dpaper.disablePluginRemapping=true) ❌ reproduces ClassNotFoundException: net.minecraft.server.ServerConnection
3 this PR disabled ✅ plugin loads cleanly without the remapper, login works

Configuration 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.

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.
@robinbraemer robinbraemer changed the title fix: Spigot ClassNames Mojang mappings for Paper 1.20.5+ fix(spigot): support Mojang-mapped NMS classes (Paper 1.20.5+ / Spigot 1.20.5+) May 1, 2026
@robinbraemer robinbraemer merged commit a99e2a1 into connect May 1, 2026
1 check passed
@robinbraemer robinbraemer deleted the fix/paper-mojmap-classnames branch May 2, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant