diff --git a/src/main/java/net/knarcraft/knarlib/util/MaterialHelper.java b/src/main/java/net/knarcraft/knarlib/util/MaterialHelper.java
index 3723e62..462bece 100644
--- a/src/main/java/net/knarcraft/knarlib/util/MaterialHelper.java
+++ b/src/main/java/net/knarcraft/knarlib/util/MaterialHelper.java
@@ -29,16 +29,18 @@ public final class MaterialHelper {
* Loads the materials specified in the given list
*
* @param materials
The list of material strings to load
+ * @param tagPrefix The prefix differentiating a tag from a material
* @param logger The logger to use for logging parsing errors
*/
- public static @NotNull Set loadMaterialList(@NotNull List> materials, @NotNull Logger logger) {
+ public static @NotNull Set loadMaterialList(@NotNull List> materials, @NotNull String tagPrefix,
+ @NotNull Logger logger) {
Set parsedMaterials = new HashSet<>();
for (Object value : materials) {
if (!(value instanceof String string)) {
continue;
}
- parsedMaterials.addAll(loadMaterialString(string, logger));
+ parsedMaterials.addAll(loadMaterialString(string, tagPrefix, logger));
}
return parsedMaterials;
}
@@ -47,13 +49,15 @@ public final class MaterialHelper {
* Parses a string representing a material or a material tag
*
* @param materialString The material string to parse
+ * @param tagPrefix The prefix differentiating a tag from a material
* @param logger The logger to use for logging parsing errors
* @return The materials defined by the material string, or an empty list if none were found
*/
- public static @NotNull Set loadMaterialString(@NotNull String materialString, @NotNull Logger logger) {
+ public static @NotNull Set loadMaterialString(@NotNull String materialString, @NotNull String tagPrefix,
+ @NotNull Logger logger) {
Set parsedMaterials = new HashSet<>();
// Try to parse a material tag first
- if (parseMaterialTag(parsedMaterials, materialString, logger)) {
+ if (parseMaterialTag(parsedMaterials, materialString, tagPrefix, logger)) {
return parsedMaterials;
}
@@ -73,12 +77,13 @@ public final class MaterialHelper {
*
* @param targetSet The set all parsed materials should be added to
* @param materialName The material name that might be a material tag
+ * @param tagPrefix The prefix differentiating a tag from a material
* @param logger The logger to use for logging parsing errors
* @return True if a tag was found
*/
private static boolean parseMaterialTag(@NotNull Set targetSet, @NotNull String materialName,
- @NotNull Logger logger) {
- Pattern pattern = Pattern.compile("^\\+([a-zA-Z_]+)");
+ @NotNull String tagPrefix, @NotNull Logger logger) {
+ Pattern pattern = Pattern.compile("^" + Pattern.quote(tagPrefix) + "([a-zA-Z_]+)");
Matcher matcher = pattern.matcher(materialName);
if (matcher.find()) {
// The material is a material tag