Skip to content

Commit

Permalink
minor item matching cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 27, 2021
1 parent 082c984 commit 93a1ea1
Showing 1 changed file with 14 additions and 17 deletions.
Expand Up @@ -1058,18 +1058,14 @@ else if (comparedto.startsWith("raw_exact:")) {
if (comparedto.equals("potion") && CoreUtilities.toLowerCase(item.getBukkitMaterial().name()).contains("potion")) {
return true;
}
MatchHelper matcher = createMatcher(comparedto);
if (item.isItemscript()) {
boolean isItemScript = item.isItemscript();
if (isItemScript) {
MatchHelper matcher = createMatcher(comparedto);
if (matcher.doesMatch(item.getScriptName())) {
return true;
}
}
else {
if (matcher.doesMatch(item.getMaterialName())) {
return true;
}
}
return tryMaterial(item.getMaterial(), comparedto);
return tryMaterialInternal(item.getBukkitMaterial(), comparedto, !isItemScript);
}

public static boolean tryLocation(Location location, String comparedto) {
Expand Down Expand Up @@ -1103,6 +1099,10 @@ public static boolean tryMaterial(MaterialTag mat, String comparedto) {
}

public static boolean tryMaterial(Material mat, String comparedto) {
return tryMaterialInternal(mat, comparedto, true);
}

public static boolean tryMaterialInternal(Material mat, String comparedto, boolean allowByMaterialName) {
if (comparedto == null || comparedto.isEmpty() || mat == null) {
return false;
}
Expand Down Expand Up @@ -1135,19 +1135,16 @@ else if (comparedto.startsWith("material_flagged:")) {
return coreFlaggedCheck(comparedto.substring("material_flagged:".length()), new MaterialTag(mat).getFlagTracker());
}
}
MaterialTag quickOf = MaterialTag.quickOfNamed(comparedto);
if (quickOf != null) {
if (quickOf.getMaterial() != mat) {
return false;
if (!allowByMaterialName) {
Material quickOf = Material.getMaterial(comparedto);
if (quickOf != null) {
return quickOf == mat;
}
if (quickOf.getMaterial().equals(mat)) {
MatchHelper matcher = createMatcher(comparedto);
if (matcher.doesMatch(mat.name())) {
return true;
}
}
MatchHelper matcher = createMatcher(comparedto);
if (matcher.doesMatch(mat.name())) {
return true;
}
return false;
}

Expand Down

0 comments on commit 93a1ea1

Please sign in to comment.