Skip to content

Commit 97f583e

Browse files
authored
Fix {USERNAME} underscore escaping in kit items (#6514)
The underscore-to-backslash escaping in KeywordReplacer is needed for item names/lores where underscores represent spaces, but Minecraft usernames never contain spaces and their underscores must stay literal. Skip the escaping for USERNAME keywords so player:{USERNAME} resolves correctly for names like Player_Name. Fixes #6296
1 parent 5546a1d commit 97f583e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,10 @@ private String replaceLine(String line, final String fullMatch, final String[] m
380380
}
381381

382382
if (this.replaceSpacesWithUnderscores) {
383-
// Don't replace spaces with underscores in command nor escape underscores.
384-
if (!line.startsWith("/")) {
383+
// Don't replace spaces with underscores in commands, and skip escaping
384+
// for USERNAME since Minecraft names never contain spaces but can
385+
// contain underscores that must stay literal (e.g. player:{USERNAME}).
386+
if (!line.startsWith("/") && validKeyword != KeywordType.USERNAME) {
385387
replacer = replacer.replace("_", "\\_").replaceAll("\\s", "_");
386388
}
387389
}

0 commit comments

Comments
 (0)