Skip to content

Fixed deprecated enchant names being used over keys#67

Closed
WillFP wants to merge 1 commit into
PlaceholderAPI:masterfrom
WillFP:patch-1
Closed

Fixed deprecated enchant names being used over keys#67
WillFP wants to merge 1 commit into
PlaceholderAPI:masterfrom
WillFP:patch-1

Conversation

@WillFP
Copy link
Copy Markdown

@WillFP WillFP commented Sep 5, 2022

No description provided.

@iGabyTM
Copy link
Copy Markdown
Member

iGabyTM commented Oct 1, 2022

@WillFP adding this means the expansion will support only 1.13+. Please add a version check and use the right method for legacy and 1.13+.

@iGabyTM
Copy link
Copy Markdown
Member

iGabyTM commented Jun 24, 2024

Covered in https://github.com/PlaceholderAPI/Player-Expansion/tree/feature/rewrite

public static @Nullable Enchantment getEnchantmentFromString(@NotNull final String string) {
if (VersionHelper.HAS_KEYED_API) {
final NamespacedKey key = (string.contains(":")) ? NamespacedKey.fromString(string) : NamespacedKey.minecraft(string);
return Optional.ofNullable(key)
.map(Enchantment::getByKey)
.orElseGet(() -> Enchantment.getByName(string));
}
return Enchantment.getByName(string);
}

@iGabyTM iGabyTM closed this Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants