Skip to content

Commit

Permalink
couldMatchItem: include all new matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 7, 2021
1 parent 535a657 commit 5d1a96a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Expand Up @@ -274,9 +274,15 @@ public boolean couldMatchVehicle(String text) {
}

public boolean couldMatchBlockOrItem(String text) {
if (text.equals("block") || text.equals("material") || text.equals("item") || text.equals("potion") || text.startsWith("item_flagged:") || text.startsWith("vanilla_tagged:")) {
if (text.equals("block") || text.equals("material") || text.equals("item") || text.equals("potion")) {
return true;
}
int colon = text.indexOf(':');
if (colon != -1) {
if (itemCouldMatchPrefixes.contains(text.substring(0, colon))) {
return true;
}
}
if (MaterialTag.matches(text)) {
MaterialTag mat = MaterialTag.valueOf(text, CoreUtilities.noDebugContext);
if (mat == null) {
Expand Down Expand Up @@ -338,12 +344,17 @@ public boolean couldMatchBlock(String text, Function<Material, Boolean> requirem
return false;
}

public static HashSet<String> itemCouldMatchPrefixes = new HashSet<>(Arrays.asList("item_flagged", "vanilla_tagged", "item_enchanted", "material_flagged", "raw_exact"));

public boolean couldMatchItem(String text) {
if (text.equals("item") || text.equals("potion")) {
return true;
}
if (text.startsWith("item_flagged:") || text.startsWith("vanilla_tagged:")) {
return true;
int colon = text.indexOf(':');
if (colon != -1) {
if (itemCouldMatchPrefixes.contains(text.substring(0, colon))) {
return true;
}
}
if (MaterialTag.matches(text)) {
MaterialTag mat = MaterialTag.valueOf(text, CoreUtilities.noDebugContext);
Expand Down
Expand Up @@ -61,7 +61,7 @@ public boolean couldMatch(ScriptPath path) {
if (!(middleWord.equals("raises") || middleWord.equals("lowers") || middleWord.equals("toggles"))) {
return false;
}
if (!path.eventArgLowerAt(2).equals("item") && !couldMatchItem(path.eventArgLowerAt(2))) {
if (!couldMatchItem(path.eventArgLowerAt(2))) {
return false;
}
return true;
Expand Down

0 comments on commit 5d1a96a

Please sign in to comment.