Skip to content

refactor!: strip shaded Adventure (Paper required for Adventure APIs)#44

Merged
demengc merged 2 commits into
mainfrom
refactor/strip-shaded-adventure
May 17, 2026
Merged

refactor!: strip shaded Adventure (Paper required for Adventure APIs)#44
demengc merged 2 commits into
mainfrom
refactor/strip-shaded-adventure

Conversation

@demengc
Copy link
Copy Markdown
Owner

@demengc demengc commented May 17, 2026

Summary

Modernizes Adventure handling and shrinks the shaded JAR by removing the bundled Adventure libraries. Adventure is now declared compileOnly and consumed from the Paper runtime instead.

  • Drops shaded adventure-api, adventure-platform-bukkit, and adventure-text-minimessage from the fat JAR; matching relocate(...) rules removed
  • Removes BukkitAudiences plumbing from BaseManager and BasePlugin
  • Adds BasePlugin#isPaper() backed by a testable detectPaper(Function<String, Class<?>>) predicate (looks for io.papermc.paper.ServerBuildInfo, shipped in Paper since 2024)
  • Isolates Adventure usage in Text behind a nested AdventureBridge class with a LinkageError -> UnsupportedOperationException boundary, so loading Text on Spigot does not eagerly trigger NoClassDefFoundError
  • Replaces the Text.MINI_MESSAGE static field with a Text.miniMessage() getter
  • Swaps BukkitComponentSerializer.legacy() for LegacyComponentSerializer.legacySection() (and casts Player to Audience directly, since Paper's Player implements it)
  • Adds happy-path unit tests for the Adventure path (TextAdventureTest) and Paper detection (BasePluginDetectionTest)

⚠️ Breaking change: Adventure APIs now require Paper

Previously, the shaded Adventure libraries meant that Text.parseMini, Text.tellComponent, Text.legacySerialize, Text.miniMessage(), and the "mini:" prefix in Text.tell/tellRaw/tellLocalized/tellLocalizedRaw worked on vanilla Spigot. After this PR they throw UnsupportedOperationException on Spigot (Adventure is not provided by vanilla Spigot at runtime).

Plugins that target both platforms should guard these calls with BasePlugin#isPaper() or catch UnsupportedOperationException. All non-Adventure Text APIs (colorize, legacy & codes, HEX, titles, broadcasts, localization, console output) remain Spigot-compatible.

Documentation has been updated to call this out in README.md, docs/README.md, and docs/core-features/text-and-localization.md. The Text class itself now carries a class-level Javadoc note listing every Paper-only method.

Bundled dependency bumps

This PR also bumps a number of unrelated dependency versions in gradle/libs.versions.toml that were pending: spotless, errorprone-core, nmcp, spigot-api, lombok, xseries, adventure-api, mongodb-driver, jedis, guava. These are not load-bearing for the refactor itself but are bundled here to keep the version catalog moving.

Test plan

  • ./gradlew build passes (all modules, including new tests)
  • TextAdventureTest exercises the happy path against Adventure on the build host
  • BasePluginDetectionTest covers true/false/unrelated-class branches of detectPaper
  • Manual smoke on Paper: mini: prefix and tellComponent send styled chat as expected
  • Manual smoke on Spigot: non-Adventure Text APIs work; Adventure methods throw UnsupportedOperationException with the documented message

- Remove the three shaded Adventure libraries (adventure-api,
  adventure-platform-bukkit, adventure-text-minimessage) and the
  three matching shadowJar relocations
- Declare adventure-api, adventure-text-minimessage, and
  adventure-text-serializer-legacy as compileOnly; Paper provides
  them at runtime, Spigot does not
- Delete BukkitAudiences plumbing from BaseManager and BasePlugin
- Add BasePlugin#isPaper() backed by a testable
  detectPaper(Function<String,Class<?>>) predicate
- Isolate Adventure usage in Text behind a private static
  AdventureBridge nested class with a LinkageError -> UnsupportedOperationException
  boundary, so loading Text on Spigot does not eagerly trigger
  NoClassDefFoundError
- Replace Text.MINI_MESSAGE field with Text.miniMessage() getter
- Use ((Audience) player).sendMessage(component) in tellComponent
  (Paper's Player implements Audience)
- Swap BukkitComponentSerializer.legacy() for
  LegacyComponentSerializer.legacySection() in legacySerialize
- Add testImplementation entries so Adventure happy-path tests can
  resolve types on the build host
@demengc demengc changed the title Refactor Adventure dependency management and isolate usage refactor!: strip shaded Adventure (Paper required for Adventure APIs) May 17, 2026
Calls out that Text.parseMini, Text.tellComponent, Text.miniMessage(),
Text.legacySerialize, Text.legacyParseMini, and the "mini:" prefix in
Text.tell/tellRaw/tellLocalized throw UnsupportedOperationException on
vanilla Spigot, since Adventure is no longer shaded.

- Text class-level Javadoc enumerates the six Paper-only entry points
- legacyParseMini Javadoc inherits the same caveat from its delegates
- BasePlugin#isPaper() Javadoc clarifies it is a downstream-facing guard
  (Text uses a LinkageError boundary internally) and notes the 2024
  ServerBuildInfo lower bound
- README and docs site call out the Paper requirement; stale upper
  version pin removed from docs/README.md
- Drop redundant non-null assertion from TextAdventureTest (the
  isSameAs identity check already covers it)
@demengc demengc merged commit 9738aba into main May 17, 2026
3 checks passed
@demengc demengc deleted the refactor/strip-shaded-adventure branch May 17, 2026 22:00
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