Updated EssentialsX to use proper API (several months after it was introduced)

This commit is contained in:
Auxilor 2021-09-18 14:51:11 +01:00
parent 0bd73ea2ec
commit 67ed1f8294
3 changed files with 5 additions and 9 deletions

View File

@ -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/' }

View File

@ -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'
}

View File

@ -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<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.
for (EcoEnchant enchantment : EcoEnchants.values()) {
Enchantments.registerEnchantment(enchantment.getKey().getKey(), enchantment);
Enchantments.registerAlias(enchantment.getPermissionName(), enchantment);
}
}