Skip to content

fix: auto-patch legacy Citizens EmptyChannel metadata for Netty 4.1 compatibility - #166

Open
GamingOP69 wants to merge 1 commit into
Wind-Development:masterfrom
GamingOP69:fix/citizens-netty-compat
Open

fix: auto-patch legacy Citizens EmptyChannel metadata for Netty 4.1 compatibility#166
GamingOP69 wants to merge 1 commit into
Wind-Development:masterfrom
GamingOP69:fix/citizens-netty-compat

Conversation

@GamingOP69

Copy link
Copy Markdown

Summary

Fixes NullPointerException: metadata crashes when spawning NPCs with legacy Citizens 2.x builds on Netty 4.1, and removes the artificial 10-second startup delay.

Problem & Root Cause

  • WindSpigot runs Netty 4.1, where DefaultChannelConfig strictly requires channel.metadata() to be non-null (checkNotNull(metadata, "metadata")).
  • Older 1.8 builds of Citizens (< build 2396, such as Citizens 2.0.25 build 1770) implement EmptyChannel.metadata() returning null (which was permitted in Netty 4.0).
  • When Citizens loads and spawns an NPC, Netty throws java.lang.NullPointerException: metadata, completely breaking NPC rendering and causing errors on every NPC spawn attempt.
  • The previous workaround inserted an artificial 10-second Thread.sleep(10000) freeze on server startup without actually fixing the underlying bytecode incompatibility.

Solution

  • Added an automatic Javassist runtime bytecode patch in CraftServer.java when loading Citizens builds < 2396, modifying EmptyChannel.metadata() to return new ChannelMetadata(true).
  • Removed the 10-second startup sleep stall entirely so the server boots immediately without delays.
  • Added CitizensVersionDetectionTest to verify version detection across old and new builds.

@GamingOP69

Copy link
Copy Markdown
Author

Older Citizens 2.x builds implement EmptyChannel.metadata()
returning null That was fine in Netty 4.0, but Netty 4.1 added a checkNotNull on that
field in DefaultChannelConfig. So anytime Citizens tries to spawn an NPC, Netty throws
NullPointerException metadata and the NPC just doesn't work.
just fixed the actual incompatibility Server now boots immediately and NPCs work
properly with old Citizens builds.

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