DenizenMC

Rewires

Swap a word, a line or a whole message you can't edit anywhere else, including Minecraft's own, and find out where any text comes from.

Some messages just can't be changed: plugins that hardcode their text, and Minecraft's own messages. Rewires catch those on their way out and swap them for whatever you'd rather serve.

Two kinds of rules

Each top-level key in any file inside plugins/Lightning/rewires/ is one rule, and there are two kinds:

  • Replace rules swap just a word or a line, and leave the rest of the message exactly as it was, colors included.
  • Message rules swap the whole message.

Replace rules

Made for tab lists, menu titles, item lore, holograms and dialogs, where you only want to touch one part.

KeyMatches
replaceA piece of text, ignoring capitals
patternA Java regular expression. {0} is the whole match, {1} and up are its groups
rewires/server.yml
server-name:
  replace: "My Server"
  surfaces: [tablist, inventories]
  to: "<spark:name>"

Every replace rule that matches is applied, top to bottom. They also reach vanilla text: Lightning writes it out in English to look for a match, and only keeps the English version when a rule actually changed something.

One colored piece at a time

Replace rules match within one colored piece of text. If a plugin colors half a word differently, or splits a line into pieces, the words aren't in one piece anymore and won't match. /lightning inspect shows you how a message is split.

Renaming vanilla items

A plain item like sand doesn't carry a name, the player's game fills it in. When any rule watches items, Lightning hands those items their vanilla name as a translation, so you can rename them by key:

rewires/items.yml
sand:
  lang: block.minecraft.sand
  surfaces: [items]
  to: "<gold>Desert Sand"

/lightning inspect items shows the key of anything in your inventory.

Test items in survival

Items are skipped for players in creative, so switch to survival when testing item rules.

Message rules

Message rules replace the whole message. They're checked in the order they're written, and the first match wins.

Pick how to match

KeyMatches
textThe whole message, ignoring colors and case. Vanilla messages are read in English
containsPart of the message, ignoring colors and case
regexA Java regular expression on the plain text. {0} is the full match, {1} and up are its groups
langA vanilla translation key. {1} and up are its arguments, colors included

Pick what happens

KeyWhat it does
toReplaces the message. MiniMessage, sparks and bolts all work, and {text} is the original message with its colors
drop: trueHides the message completely

Pick where it watches

surfaces lists where a rule looks, like [chat, bossbars]. Leave it out to watch chat only. This works the same way for replace rules.

Message rule examples

rewires/server.yml
# vanilla's unknown command error, restyled
unknown-command:
  lang: command.unknown.command
  to: "<spark:alert>That command doesn't exist.</spark> <spark:soft>Try /help</spark>"

# a hardcoded protection message, moved out of chat
region-deny:
  regex: "Hey! Sorry, but you can't (.+) here\\."
  to: "<actionbar><red>You can't {1} here.<sound:entity.villager.no>"

# the same message, now in every player's language
greeting:
  contains: "welcome to the server"
  to: "<spark:welcome-line>"

# a message nobody needs to see
quiet:
  text: "Saving the game (this may take a moment!)"
  drop: true

# a boss bar from a plugin you can't configure
event-bar:
  contains: "event starting"
  surfaces: [bossbars]
  to: "<gradient:#FFE259:#FFA751>{text}</gradient>"

Vanilla messages need lang

Minecraft translates its own messages on the player's side, so text and contains never see the English words. Use lang with the translation key instead. lang also matches when the server has already turned a message into plain English, like Paper's ban screen.

Safe with player names

Anything taken from the original message, like regex groups, is always shown as plain text. A player name containing < can never turn into a tag through a rewire.

Rewires run before smart detection, so they work on messages with no tags at all. A surface without rewires costs nothing extra. One with rewires reads each message's plain text once, which is cheap, but keep regex rules to the surfaces that really need them.

Inspect

To write a rewire, you need to know exactly what a message says, or which translation key it uses. /lightning inspect tells you.

Turn it on

Run /lightning inspect. From now on, a small ⚡ line appears under every chat message you receive. Add a surface to look somewhere else: /lightning inspect tablist, items, entities, dialogs, inventories, scoreboards and the rest all work.

Trigger the message

Do whatever makes the message appear, like walking into a protected region or typing a wrong command.

Hover the ⚡ line

Hover it to see where the message came from:

  • the surface it arrived through
  • every translation key in it
  • which rewire matched, if any
  • whether Lightning charged it
  • the plain text
  • the exact MiniMessage Lightning read. If a tag shows up as text in game, this tells you why

Each line has a Copy text button, and a Copy key button when the message has a translation key. Run the same command again to switch it off.

Only you see it

Inspect only affects you. Other players never see the ⚡ lines. Outside chat, each different text is reported once, and action bars only report when the text actually changes, so a refreshing tab list or bar never floods you.

Testing kick and ban screens

Kick screens can't be inspected in game, since you're not in the game anymore. Test the rule with /lightning parse kicks, using \n for line breaks:

/lightning parse kicks You are banned from this server.\nReason: Griefing

If it works there, the rule is fine. To see what a real kick sends, run /lightning debug, get kicked, and the console prints the exact text and translation key Lightning saw.

Did this page help?

Last updated on