Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/main/java/com/extendedclip/deluxemenus/menu/MenuItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.extendedclip.deluxemenus.menu.options.CustomModelDataComponent;
import com.extendedclip.deluxemenus.utils.DebugLevel;
import com.extendedclip.deluxemenus.utils.ItemUtils;
import com.extendedclip.deluxemenus.utils.RegistryUtils;
import com.extendedclip.deluxemenus.utils.StringUtils;
import com.extendedclip.deluxemenus.utils.VersionHelper;
import com.google.common.collect.ImmutableMultimap;
Expand Down Expand Up @@ -341,8 +342,8 @@ public ItemStack getItemStack(@NotNull final MenuHolder holder) {
final Optional<String> trimPatternName = this.options.trimPattern();

if (trimMaterialName.isPresent() && trimPatternName.isPresent()) {
final TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.match(holder.setPlaceholdersAndArguments(trimMaterialName.get()));
final TrimPattern trimPattern = Registry.TRIM_PATTERN.match(holder.setPlaceholdersAndArguments(trimPatternName.get()));
final TrimMaterial trimMaterial = RegistryUtils.byNameOrKey(Registry.TRIM_MATERIAL, normalizeRegistryInput(holder.setPlaceholdersAndArguments(trimMaterialName.get())));
final TrimPattern trimPattern = RegistryUtils.byNameOrKey(Registry.TRIM_PATTERN, normalizeRegistryInput(holder.setPlaceholdersAndArguments(trimPatternName.get())));

if (trimMaterial != null && trimPattern != null) {
final ArmorTrim armorTrim = new ArmorTrim(trimMaterial, trimPattern);
Expand Down Expand Up @@ -417,7 +418,7 @@ public ItemStack getItemStack(@NotNull final MenuHolder holder) {
plugin.debug(
DebugLevel.HIGHEST,
Level.INFO,
"Failed to add enchantment " + entry.getKey().getName() + " to item " + itemStack.getType()
"Failed to add enchantment " + entry.getKey().getKey() + " to item " + itemStack.getType()
);
}
}
Expand Down Expand Up @@ -498,6 +499,14 @@ private boolean isHeadItem(@NotNull final String material) {
return headType.isPresent();
}

/**
* Applies the same normalization the deprecated {@code Registry#match} used (lower case, whitespace to
* underscores), so configured values keep resolving exactly as before.
*/
private static @NotNull String normalizeRegistryInput(@NotNull final String input) {
return input.toLowerCase(Locale.ROOT).replaceAll("\\s+", "_");
}

private @NotNull Optional<ItemStack> getItemFromHook(String hookName, String... args) {
return plugin.getItemHook(hookName).map(itemHook -> itemHook.getItem(args));
}
Expand Down