diff options
author | SHsuperCM <shsupercm@gmail.com> | 2021-08-30 05:41:03 +0300 |
---|---|---|
committer | SHsuperCM <shsupercm@gmail.com> | 2021-08-30 05:41:03 +0300 |
commit | a7dc9b7c96178a5646d3451902730cddf28b3a60 (patch) | |
tree | aefdea36f74aaeed65c333e3929de159fecf51c8 /src/main/java/shcm | |
parent | f3200b65a7ca4cbd6160b032979056164d23eed3 (diff) | |
download | CITResewn-a7dc9b7c96178a5646d3451902730cddf28b3a60.tar.gz CITResewn-a7dc9b7c96178a5646d3451902730cddf28b3a60.tar.bz2 CITResewn-a7dc9b7c96178a5646d3451902730cddf28b3a60.zip |
v0.4.1: Fixed nbt name/lore requiring json
Diffstat (limited to 'src/main/java/shcm')
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java | 19 |
1 files changed, 15 insertions, 4 deletions
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<NbtCompound>() { public boolean test(NbtElement nbtElement, int index) { |