parsedMaterials = new HashSet<>();
- for (Object value : materials) {
- if (!(value instanceof String string)) {
- continue;
- }
-
- parsedMaterials.addAll(loadMaterialString(string));
- }
- return parsedMaterials;
- }
-
- /**
- * Parses a string representing a material or a material tag
- *
- * @param materialString The material string to parse
- * @return The materials defined by the material string, or an empty list if none were found
- */
- public static @NotNull Set loadMaterialString(@NotNull String materialString) {
- Set parsedMaterials = new HashSet<>();
- // Try to parse a material tag first
- if (parseMaterialTag(parsedMaterials, materialString)) {
- return parsedMaterials;
- }
-
- // Try to parse a material name
- Material matched = Material.matchMaterial(materialString);
- if (matched != null) {
- parsedMaterials.add(matched);
- } else {
- Launchpad.getInstance().getStringFormatter().replacePlaceholder(
- LaunchpadMessage.ERROR_MATERIAL_NOT_PARSE_ABLE, "{material}", materialString);
- }
- return parsedMaterials;
- }
-
- /**
- * Tries to parse the material tag in the specified material name
- *
- * @param targetSet The set all parsed materials should be added to
- * @param materialName The material name that might be a material tag
- * @return True if a tag was found
- */
- private static boolean parseMaterialTag(@NotNull Set targetSet, @NotNull String materialName) {
- Pattern pattern = Pattern.compile("^\\+([a-zA-Z_]+)");
- Matcher matcher = pattern.matcher(materialName);
- if (matcher.find()) {
- // The material is a material tag
- Tag tag = Bukkit.getTag(Tag.REGISTRY_BLOCKS, NamespacedKey.minecraft(
- matcher.group(1).toLowerCase()), Material.class);
- if (tag != null) {
- targetSet.addAll(tag.getValues());
- } else {
- Launchpad.getInstance().getStringFormatter().replacePlaceholder(
- LaunchpadMessage.ERROR_MATERIAL_NOT_PARSE_ABLE, "{material}", materialName);
- }
- return true;
- }
- return false;
- }
-
-}
diff --git a/src/main/java/net/knarcraft/launchpad/util/TabCompleteHelper.java b/src/main/java/net/knarcraft/launchpad/util/TabCompleteHelper.java
deleted file mode 100644
index aa13d13..0000000
--- a/src/main/java/net/knarcraft/launchpad/util/TabCompleteHelper.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package net.knarcraft.launchpad.util;
-
-import org.jetbrains.annotations.NotNull;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A helper-class for common tab-completions
- */
-public final class TabCompleteHelper {
-
- private TabCompleteHelper() {
-
- }
-
- /**
- * Finds tab complete values that contain the typed text
- *
- * @param values The values to filter
- * @param typedText The text the player has started typing
- * @return The given string values that contain the player's typed text
- */
- public static List filterMatchingContains(@NotNull List values, @NotNull String typedText) {
- List configValues = new ArrayList<>();
- for (String value : values) {
- if (value.toLowerCase().contains(typedText.toLowerCase())) {
- configValues.add(value);
- }
- }
- return configValues;
- }
-
-}
diff --git a/src/main/resources/strings.yml b/src/main/resources/strings.yml
index f898245..dedca28 100644
--- a/src/main/resources/strings.yml
+++ b/src/main/resources/strings.yml
@@ -1,7 +1,6 @@
en:
ERROR_PLAYER_ONLY: "&cThis command must be used by a player"
ERROR_NOT_WHITELISTED: "&cThe block could not be modified, as it's not whitelisted. If you want to abort changing a launchpad, use \"/launchpad abort\""
- ERROR_MATERIAL_NOT_PARSE_ABLE: "&cUnable to parse material: {material}"
SUCCESS_PLUGIN_RELOADED: "&aPlugin reloaded!"
SUCCESS_MODIFICATIONS_CLEARED: "&aCleared your launchpad modification queue"
SUCCESS_CLICK_BLOCK: "&aClick the launchpad you want to create or modify"