From 2828901927d57ad5bccd0a56fa5a79538b2c6bc3 Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Fri, 26 May 2023 21:51:11 -0400 Subject: [PATCH] Fix variables in kits having underscores replaced with spaces (#5366) --- .../main/java/com/earth2me/essentials/MetaItemStack.java | 8 ++++---- .../earth2me/essentials/textreader/KeywordReplacer.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java b/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java index d1edb3e02..77176583c 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java +++ b/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java @@ -194,14 +194,14 @@ public class MetaItemStack { final Material WRITTEN_BOOK = EnumUtil.getMaterial("WRITTEN_BOOK"); if (split.length > 1 && split[0].equalsIgnoreCase("name") && hasMetaPermission(sender, "name", false, true, ess)) { - final String displayName = FormatUtil.replaceFormat(split[1].replace('_', ' ')); + final String displayName = FormatUtil.replaceFormat(split[1].replaceAll("(? 1 && (split[0].equalsIgnoreCase("lore") || split[0].equalsIgnoreCase("desc")) && hasMetaPermission(sender, "lore", false, true, ess)) { final List lore = new ArrayList<>(); for (final String line : split[1].split("(? 1 && split[0].equalsIgnoreCase("title") && stack.getType() == WRITTEN_BOOK && hasMetaPermission(sender, "title", false, true, ess)) { - final String title = FormatUtil.replaceFormat(split[1].replace('_', ' ')); + final String title = FormatUtil.replaceFormat(split[1].replaceAll("(? pages = meta.hasPages() ? new ArrayList<>(meta.getPages()) : new ArrayList<>(); final List lines = new ArrayList<>(); for (final String line : split[1].split("(?= pages.size()) { diff --git a/Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java index f53d62940..8edbfd124 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java +++ b/Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java @@ -375,7 +375,7 @@ public class KeywordReplacer implements IText { } if (this.replaceSpacesWithUnderscores) { - replacer = replacer.replaceAll("\\s", "_"); + replacer = replacer.replace("_", "\\_").replaceAll("\\s", "_"); } //If this is just a regular keyword, lets throw it into the cache