WorldGuard icon indicating copy to clipboard operation
WorldGuard copied to clipboard

Added support for MiniMessage Components

Open Joo200 opened this issue 3 years ago • 0 comments

Paper 1.18.2 includes MiniMessage and Adventure 4.10.0.

With this PR I want to add MiniMessage support when available. E.g. /rg flag __global__ deny-message <rainbow>Hey, sorry! You can't <what> here. will display the deny-message in rainbow colors.

Every available old replacement (such as %name% or %online%) is replaced by a Placeholder from MiniMessage (<name> or <online>). Using MiniMessage to display a greeting message to a player is now /rg flag <id> greeting <yellow>Hello <name>, welcome to the region.

The existing StringFlag type is replaced by a ComponentFlag. ComponentFlag expands StringFlag (should be backwards compatible for most plugins) but has two default values. One default value with legacy formatting and one default value with MiniMessage formatting. When accessing the default value WorldGuard will pick the correct one.

A new command is added to migrate existing flags: /rg flag migratecomponents [-y] will convert every ComponentFlag to the new MiniMessage format when available. This will replace every tag (e.g. %name%) too.

Needed changes:

  • depend on Paper 1.18.2 and Java 17.
  • updated various compile time dependencies (e.g. Checkstyle and shadowjar)
  • Some added methods in Core and Bukkit module. Every change should be fully backwards compatible.

TODO:

  • [ ] add some way to add own TagResolvers when sending a MiniMessage's Component.
  • [x] add Warnings when using old color style on MiniMessage servers

Joo200 avatar Mar 05 '22 18:03 Joo200