aboutsummaryrefslogtreecommitdiff
path: root/defaults/src/main/java
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-07-01 08:56:43 +0300
committerSHsuperCM <shsupercm@gmail.com>2022-07-01 08:56:43 +0300
commita11cb51ed936edab28369fa661d167c912abc5cd (patch)
tree5b823067ef7b7bab16c83e9582300b988a1e7dcd /defaults/src/main/java
parent5fec1bf8e1c1b51abd436f2130a5a7f8460f2d7b (diff)
downloadCITResewn-a11cb51ed936edab28369fa661d167c912abc5cd.tar.gz
CITResewn-a11cb51ed936edab28369fa661d167c912abc5cd.tar.bz2
CITResewn-a11cb51ed936edab28369fa661d167c912abc5cd.zip
The nbt condition will now check numbers against string matchers
Fixes #144
Diffstat (limited to 'defaults/src/main/java')
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionNBT.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionNBT.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionNBT.java
index ba73439..3157866 100644
--- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionNBT.java
+++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionNBT.java
@@ -121,20 +121,23 @@ public class ConditionNBT extends CITCondition {
try {
if (element instanceof NbtString nbtString) //noinspection ConstantConditions
return matchString.matches(nbtString.asString()) || matchString.matches(Text.Serializer.fromJson(nbtString.asString()).getString());
- else if (element instanceof NbtInt nbtInt)
+ else if (element instanceof NbtInt nbtInt && matchInteger != null)
return nbtInt.equals(matchInteger);
- else if (element instanceof NbtByte nbtByte)
+ else if (element instanceof NbtByte nbtByte && matchByte != null)
return nbtByte.equals(matchByte);
- else if (element instanceof NbtFloat nbtFloat)
+ else if (element instanceof NbtFloat nbtFloat && matchFloat != null)
return nbtFloat.equals(matchFloat);
- else if (element instanceof NbtDouble nbtDouble)
+ else if (element instanceof NbtDouble nbtDouble && matchDouble != null)
return nbtDouble.equals(matchDouble);
- else if (element instanceof NbtLong nbtLong)
+ else if (element instanceof NbtLong nbtLong && matchLong != null)
return nbtLong.equals(matchLong);
- else if (element instanceof NbtShort nbtShort)
+ else if (element instanceof NbtShort nbtShort && matchShort != null)
return nbtShort.equals(matchShort);
- else if (element instanceof NbtCompound nbtCompound)
+ else if (element instanceof NbtCompound nbtCompound && matchCompound != null)
return NbtHelper.matches(matchCompound, nbtCompound, true);
+
+ if (element instanceof AbstractNbtNumber nbtNumber && !(matchString instanceof StringMatcher.DirectMatcher))
+ return matchString.matches(String.valueOf(nbtNumber.numberValue()));
} catch (Exception ignored) { }
return false;
}