From 67ed1f82941705dc730f4b8566d2f0e4837ec263 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sat, 18 Sep 2021 14:51:11 +0100 Subject: [PATCH] Updated EssentialsX to use proper API (several months after it was introduced) --- build.gradle | 1 + eco-core/core-plugin/build.gradle | 2 +- .../registration/plugins/IntegrationEssentials.java | 11 +++-------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index bc0e0a3a..46a0a383 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,7 @@ allprojects { maven { url "https://oss.sonatype.org/content/repositories/snapshots" } maven { url 'https://oss.sonatype.org/content/groups/public/' } maven { url 'https://maven.enginehub.org/repo/' } + maven { url 'https://repo.essentialsx.net/releases/' } maven { url 'https://ci.ender.zone/plugin/repository/project/' } maven { url 'https://ci.ender.zone/plugin/repository/everything/' } maven { url 'https://repo.md-5.net/content/repositories/snapshots/' } diff --git a/eco-core/core-plugin/build.gradle b/eco-core/core-plugin/build.gradle index 9432f089..9c53c42f 100644 --- a/eco-core/core-plugin/build.gradle +++ b/eco-core/core-plugin/build.gradle @@ -6,7 +6,7 @@ dependencies { compileOnly 'org.spigotmc:spigot:1.17-R0.1-SNAPSHOT' compileOnly 'commons-io:commons-io:2.8.0' compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.0-SNAPSHOT' - compileOnly 'net.ess3:EssentialsX:2.18.1' + compileOnly 'net.essentialsx:EssentialsX:2.19.0' compileOnly 'com.destroystokyo.paper:paper-api:1.16.3-R0.1-SNAPSHOT' compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT' } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/registration/plugins/IntegrationEssentials.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/registration/plugins/IntegrationEssentials.java index 70927125..14398661 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/registration/plugins/IntegrationEssentials.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/registration/plugins/IntegrationEssentials.java @@ -9,17 +9,12 @@ import org.bukkit.enchantments.Enchantment; import java.util.Map; -@SuppressWarnings("unchecked") public class IntegrationEssentials implements RegistrationWrapper { @Override public void registerAllEnchantments() { - try { - for (EcoEnchant enchantment : EcoEnchants.values()) { - ((Map) FieldUtils.readDeclaredStaticField(Enchantments.class, "ENCHANTMENTS", true)).put(enchantment.getKey().getKey(), enchantment); - ((Map) FieldUtils.readDeclaredStaticField(Enchantments.class, "ENCHANTMENTS", true)).put(enchantment.getPermissionName(), enchantment); - } - } catch (IllegalAccessException ignored) { - // Ignore reflective errors that won't happen. + for (EcoEnchant enchantment : EcoEnchants.values()) { + Enchantments.registerEnchantment(enchantment.getKey().getKey(), enchantment); + Enchantments.registerAlias(enchantment.getPermissionName(), enchantment); } }