Adds method for parsing a material without tag support
This commit is contained in:
parent
223c70b28e
commit
5c3c3045eb
@ -6,6 +6,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Tag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -62,14 +63,31 @@ public final class MaterialHelper {
|
||||
}
|
||||
|
||||
// Try to parse a material name
|
||||
Material matched = Material.matchMaterial(materialString);
|
||||
Material matched = loadMaterialString(materialString, logger);
|
||||
if (matched != null) {
|
||||
parsedMaterials.add(matched);
|
||||
}
|
||||
|
||||
return parsedMaterials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a string representing a material
|
||||
*
|
||||
* @param materialString <p>The material string to parse</p>
|
||||
* @param logger <p>The logger to use for logging parsing errors</p>
|
||||
* @return <p>The materials defined by the material string, or an empty list if none were found</p>
|
||||
*/
|
||||
public static @Nullable Material loadMaterialString(@NotNull String materialString, @NotNull Logger logger) {
|
||||
// Try to parse a material name
|
||||
Material matched = Material.matchMaterial(materialString.replace("-", "_"));
|
||||
if (matched != null) {
|
||||
return matched;
|
||||
} else {
|
||||
logger.log(Level.WARNING, StringFormatter.replacePlaceholder("Unable to parse material: {material}",
|
||||
"{material}", materialString));
|
||||
return null;
|
||||
}
|
||||
return parsedMaterials;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user