Skip to content

Add configurable messages.yml with HEX color support - #2338

Closed
demrodev wants to merge 1 commit into
EngineHub:version/7.0.xfrom
demrodev:contrib/configurable-messages
Closed

demrodev wants to merge 1 commit into
EngineHub:version/7.0.xfrom
demrodev:contrib/configurable-messages

Conversation

@demrodev

Copy link
Copy Markdown

Summary

This PR adds a configurable messages.yml for all player-facing WorldGuard messages.

WorldGuard currently keeps most player-facing strings in Java code. Server owners cannot translate or customize them without rebuilding the plugin. This PR introduces a message manager that loads defaults from the jar, creates a user-editable file on first startup, and reloads it with /wg reload.

What changed

  • Added com.sk89q.worldguard.util.Messages, which:
    • creates plugins/WorldGuard/messages.yml on first startup;
    • loads missing values from bundled defaults;
    • supports named placeholders such as {player}, {region}, and {prefix};
    • reloads safely with /wg reload.
  • Added English messages.yml and optional Russian messages_ru.yml resources.
  • Moved player-facing messages from commands, protection listeners, region UI, flags, and blacklist notifications into the messages file.
  • Added Legacy ampersand color support (&c), HEX support (&#ffaa00), Spigot HEX support (&x&f&f&a&a&0&0), and serialized section code support.
  • Added HEX support to region greeting, farewell, deny, and teleport messages through the existing color macro path.
  • Added configurable defaults for the deny, entry-deny, exit-deny, and teleport-message flags.
  • Added unit tests for color parsing, placeholder replacement, demotion to legacy colors, and file creation.
  • No plugin name, version, README, or release branding changes are included.

Behavior

  • Default messages are English.
  • Missing keys fall back to the bundled defaults.
  • Existing region flags and message behavior are preserved.
  • Server owners can set prefix to an empty string to disable the prefix.
  • Interactive components rendered through WorldEdit's legacy text API approximate HEX colors with the closest legacy color; normal chat messages keep exact HEX.

Testing

  • ./gradlew :worldguard-core:test
  • ./gradlew :worldguard-core:check :worldguard-bukkit:check
  • Built against the current version/7.0.x branch with Java 25 and Gradle 9.6.1.

Notes

This is a large feature and touches many message call sites. I am happy to split it into smaller PRs if preferred, for example:

  1. message manager and config format;
  2. color parser and region-flag message support;
  3. command and listener message migration.

Happy to adjust the design or scope based on maintainer feedback.

@Joo200

Joo200 commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Not sure why you made this PR without discussing it on the discord server first.
There are plans for localization of WorldGuard but not like this. Our plans include adapting the message system from WorldEdit so message bundles are managed on crowdin, language depends on the user's selected language.
Additionally: changing exception messages for major issues such as the missing worldedit dependency is a bad idea. We need English logs so we can debug issues. With changed messages we can't do that.

@me4502

me4502 commented Nov 30, 2026

Copy link
Copy Markdown
Member

it's probably worth taking a look at some of the comments on previous PRs about this topic :) -- #2241

i went into the design of the current translation system there, rather than adding an extra system on top.

although, as there's a transition from Text3 -> Adventure currently taking place, it might not be the best time to actually make this change

@demrodev

Copy link
Copy Markdown
Author

Not sure why you made this PR without discussing it on the discord server first. There are plans for localization of WorldGuard but not like this. Our plans include adapting the message system from WorldEdit so message bundles are managed on crowdin, language depends on the user's selected language. ionally: changing exception messages for major issues such as the missing worldedit dependency is a bad idea. We need English logs so we can debug issues. With changed messages we can't do that.

This is just an example of what could be done. No one is forcing developers or other users to touch error translations; error logging for user output can be done in the /logs/ folder, and error messages can be made formattable, since the plugin is used not only by an English‑speaking audience. You’re right about Crowdin — it’s possible to create translations for many languages around the world to simplify working with the plugin. But this doesn’t change the fact that it actually works and will be useful to many users, since I’ve noticed over the years that people fork the plugin just to translate a few lines that need to be found in hundreds of lines of code, and many of these people do it following guides from YouTube. Based on what was described above, for the Russian‑speaking audience of plugin users, this fork simplifies the customization of messages and translation, since the plugin doesn’t even support HEX and many other types of formatting — which would be very useful compared to other plugins that already include these features “out of the box,” even though WorldGuard is one of the oldest server plugins.

@demrodev

Copy link
Copy Markdown
Author

it's probably worth taking a look at some of the comments on previous PRs about this topic :) -- #2241

i went into the design of the current translation system there, rather than adding an extra system on top.

although, as there's a transition from Text3 -> Adventure currently taking place, it might not be the best time to actually make this change

I wouldn’t recommend interacting with users like BlackMinecraft, who sell nulled plugins for a Russian‑speaking audience on their website, lol.

@me4502

me4502 commented Nov 30, 2026

Copy link
Copy Markdown
Member

it's probably worth taking a look at some of the comments on previous PRs about this topic :) -- #2241

i went into the design of the current translation system there, rather than adding an extra system on top.

although, as there's a transition from Text3 -> Adventure currently taking place, it might not be the best time to actually make this change

I wouldn’t recommend interacting with users like BlackMinecraft, who sell nulled plugins for a Russian‑speaking audience on their website, lol.

I'm not familiar with who the author of that PR is, I was just referencing the comments in that PR which detail how the current translation system should be extended, rather than being replaced with a second system

@demrodev

Copy link
Copy Markdown
Author

By the way, I’ve read a few threads about this and I can skip translating the error messages in order to maintain support for WorldGuard.

@demrodev

demrodev commented Dec 1, 2026

Copy link
Copy Markdown
Author

it's probably worth taking a look at some of the comments on previous PRs about this topic :) -- #2241
i went into the design of the current translation system there, rather than adding an extra system on top.
although, as there's a transition from Text3 -> Adventure currently taking place, it might not be the best time to actually make this change

I wouldn’t recommend interacting with users like BlackMinecraft, who sell nulled plugins for a Russian‑speaking audience on their website, lol.

I'm not familiar with who the author of that PR is, I was just referencing the comments in that PR which detail how the current translation system should be extended, rather than being replaced with a second system

Thank you for your feedback. I’ll keep an eye on the updates, but until such features are added, I’ll continue developing the fork.

Add a messages.yml generated on first startup with English defaults and an optional Russian translation. All player-facing command, protection, region UI, flag, and listener messages can now be changed without editing code. Add legacy ampersand and HEX color support, including region greeting, farewell, deny, and teleport messages. Reload messages with /wg reload.

Includes unit tests for color parsing, placeholders, and message file creation.
@demrodev
demrodev force-pushed the contrib/configurable-messages branch from 6bf6824 to b79d07b Compare December 1, 2026 00:07
@me4502

me4502 commented Dec 1, 2026

Copy link
Copy Markdown
Member

I feel you misunderstood sorry, that feature already exists. It's just not used for any text currently because it hasn't made sense for us to spend time to widen usage of Text3 within WorldGuard, when Adventure is replacing it soonish (and it has some compatibility quirks).

If you are adding translations, it should be done with that system.

@demrodev

demrodev commented Dec 1, 2026

Copy link
Copy Markdown
Author

I feel you misunderstood sorry, that feature already exists. It's just not used for any text currently because it hasn't made sense for us to spend time to widen usage of Text3 within WorldGuard, when Adventure is replacing it soonish (and it has some compatibility quirks).

If you are adding translations, it should be done with that system.

OK, I see

@demrodev demrodev closed this Dec 1, 2026
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.

3 participants