Added dual registration option for users using old versions prior to 7.3.0

This commit is contained in:
Auxilor
2021-04-29 08:48:39 +01:00
parent 280de8bd1e
commit e3861990a2
2 changed files with 10 additions and 0 deletions

View File

@@ -242,6 +242,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
Map<String, Enchantment> byName = (Map<String, Enchantment>) byNameField.get(null);
byKey.remove(this.getKey());
byName.remove(this.getName());
byName.remove(this.getDisplayName());
Map<String, Enchantment> byNameClone = new HashMap<>(byName);
for (Map.Entry<String, Enchantment> entry : byNameClone.entrySet()) {
@@ -250,6 +251,10 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
}
}
if (this.getPlugin().getConfigYml().getBool("advanced.dual-registration.enabled")) {
byName.put(this.getDisplayName(), this);
}
Field f = Enchantment.class.getDeclaredField("acceptingNew");
f.setAccessible(true);
f.set(null, true);

View File

@@ -130,4 +130,9 @@ advanced:
# Enabling this prevents the enchantments from being registered with the server at all when disabled.
# There may be some unknown problems with this, but will fix bugs with plugins such as Slimefun.
# Hard disabled enchantments will not update on /ecoreload. You will have to restart your server.
enabled: false
dual-registration:
# Fixes potential plugin conflicts/serialization issues when updating from a version before 7.3.0.
# Registers byName both the internal enchantment name (new method) and the display name (old method).
# There may be potential bugs with having duplicate enchantments, so enable this only if you need it.
enabled: false