Added permission names to essentials

This commit is contained in:
Auxilor 2021-01-06 12:56:16 +00:00
parent 8f12323c00
commit 80f740cdea

View File

@ -1,6 +1,7 @@
package com.willfp.ecoenchants.integrations.essentials.plugins;
import com.earth2me.essentials.Enchantments;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.essentials.EssentialsWrapper;
import org.apache.commons.lang.reflect.FieldUtils;
@ -13,8 +14,9 @@ public class IntegrationEssentials implements EssentialsWrapper {
@Override
public void registerAllEnchantments() {
try {
for (Enchantment enchantment : EcoEnchants.values()) {
for (EcoEnchant enchantment : EcoEnchants.values()) {
((Map<String, Enchantment>) FieldUtils.readDeclaredStaticField(Enchantments.class, "ENCHANTMENTS", true)).put(enchantment.getKey().getKey(), enchantment);
((Map<String, Enchantment>) FieldUtils.readDeclaredStaticField(Enchantments.class, "ENCHANTMENTS", true)).put(enchantment.getPermissionName(), enchantment);
}
} catch (IllegalAccessException ignored) {
// Ignore reflective errors that won't happen.