chime
chime copied to clipboard
Support wildcard or regexp matcher for NBT predicates
you can implement this by adding this to dev.emi.chime.ChimeClient#matchesJsonObject
:
// regex match
if (key.startsWith("chime:regex:")) {
// regex match can't capture non-existent predicates
if (element.isJsonNull()) return true;
String regex = key.substring(12);
return tag.getKeys()
.stream()
.filter(k -> k.matches(regex))
.anyMatch(k -> tag.contains(k) && matchesJsonElement(element, tag.get(k)));
}
this will interpret json labels like chime:regex:*****
as regex labels, and won't cause conflicts because we used chime:
namespace.
In this implementation regex labels will match all the NBT elements in tag that has a key matching the regex, and return true if any element matches.