From a7dc9b7c96178a5646d3451902730cddf28b3a60 Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Mon, 30 Aug 2021 05:41:03 +0300 Subject: v0.4.1: Fixed nbt name/lore requiring json --- .../shsupercm/fabric/citresewn/pack/cits/CIT.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/main/java/shcm/shsupercm') diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java index 19e7527..34f7155 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java @@ -166,13 +166,24 @@ public abstract class CIT { String matchProperty = StringEscapeUtils.unescapeJava(properties.getProperty(property)); final boolean caseSensitive = !matchProperty.startsWith("i"); if (matchProperty.startsWith(caseSensitive ? "pattern:" : "ipattern:")) { - final String pattern = caseSensitive ? matchProperty.substring(8) : matchProperty.substring(9).toLowerCase(Locale.ENGLISH); + matchProperty = caseSensitive ? matchProperty.substring(8) : matchProperty.substring(9).toLowerCase(Locale.ENGLISH); + if ((path[path.length - 1].equals("Name") || path[path.length - 1].equals("Lore")) && !matchProperty.startsWith("{")) + matchProperty = "{\"text\":\"" + matchProperty + "\"}"; + final String pattern = matchProperty; match = s -> matchesPattern(caseSensitive ? s : s.toLowerCase(), pattern, 0, s.length(), 0, pattern.length()); } else if (matchProperty.startsWith(caseSensitive ? "regex:" : "iregex:")) { - final Pattern pattern = Pattern.compile(caseSensitive ? matchProperty.substring(5) : matchProperty.substring(6).toLowerCase(Locale.ENGLISH)); + matchProperty = caseSensitive ? matchProperty.substring(5) : matchProperty.substring(6).toLowerCase(Locale.ENGLISH); + if ((path[path.length - 1].equals("Name") || path[path.length - 1].equals("Lore")) && !matchProperty.startsWith("{")) + matchProperty = "\\{\"text\":\"" + matchProperty + "\"}"; + final Pattern pattern = Pattern.compile(matchProperty); match = s -> pattern.matcher(caseSensitive ? s : s.toLowerCase()).matches(); - } else - match = s -> s.equals(matchProperty); + } else { + matchProperty = caseSensitive ? matchProperty.substring(5) : matchProperty.substring(6).toLowerCase(Locale.ENGLISH); + if ((path[path.length - 1].equals("Name") || path[path.length - 1].equals("Lore")) && !matchProperty.startsWith("{")) + matchProperty = "{\"text\":\"" + matchProperty + "\"}"; + final String pattern = matchProperty; + match = s -> s.equals(pattern); + } nbtPredicates.add(new Predicate() { public boolean test(NbtElement nbtElement, int index) { -- cgit