mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-25 15:35:11 +01:00
Updated to new eco display system
This commit is contained in:
parent
2437fc2753
commit
3b2677edd3
@ -77,8 +77,8 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
|
||||
|
||||
return EnchantDisplay.displayEnchantments(itemStack, hideEnchants);
|
||||
}, 500, this.getPluginName()));
|
||||
|
||||
Display.registerRevertModule(EnchantDisplay::revertDisplay);
|
||||
Display.registerFinalizeModule(EnchantDisplay::addV);
|
||||
|
||||
this.getExtensionLoader().loadExtensions();
|
||||
|
||||
|
@ -43,13 +43,6 @@ public class EnchantDisplay {
|
||||
*/
|
||||
public static final NamespacedKey KEY_SKIP = PLUGIN.getNamespacedKeyFactory().create("ecoenchantlore-skip");
|
||||
|
||||
/**
|
||||
* The meta key to notify the server that an item is from a villager trade.
|
||||
* <p>
|
||||
* Bit of a bodge - plan on making it better.
|
||||
*/
|
||||
public static final NamespacedKey KEY_V = PLUGIN.getNamespacedKeyFactory().create("ecoenchantlore-v");
|
||||
|
||||
/**
|
||||
* The prefix for all enchantment lines to have in lore.
|
||||
*/
|
||||
@ -69,25 +62,6 @@ public class EnchantDisplay {
|
||||
EnchantmentCache.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bodge to fix hidden enchantments from villagers.
|
||||
* <p>
|
||||
* It isn't recommended to mess with this unless you <b>really</b> know your way around EcoEnchants.
|
||||
*
|
||||
* @param item The item to modify.
|
||||
* @return The item, with KEY_V.
|
||||
*/
|
||||
public static ItemStack addV(@Nullable final ItemStack item) {
|
||||
if (item == null || !EnchantmentTarget.ALL.getMaterials().contains(item.getType()) || item.getItemMeta() == null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.getPersistentDataContainer().set(KEY_V, PersistentDataType.INTEGER, 1);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert display.
|
||||
*
|
||||
@ -112,9 +86,6 @@ public class EnchantDisplay {
|
||||
itemLore = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (meta.getPersistentDataContainer().has(KEY_V, PersistentDataType.INTEGER)) {
|
||||
meta.getPersistentDataContainer().remove(KEY_V);
|
||||
}
|
||||
itemLore.removeIf(s -> s.startsWith(PREFIX));
|
||||
|
||||
if (!meta.getPersistentDataContainer().has(KEY_SKIP, PersistentDataType.INTEGER)) {
|
||||
@ -144,22 +115,15 @@ public class EnchantDisplay {
|
||||
* Show all enchantments in item lore.
|
||||
*
|
||||
* @param item The item to update.
|
||||
* @param hideEnchants If enchantments should be hidden.
|
||||
* @param hide If enchantments should be hidden.
|
||||
* @return The item, updated.
|
||||
*/
|
||||
public static ItemStack displayEnchantments(@Nullable final ItemStack item,
|
||||
final boolean hideEnchants) {
|
||||
boolean hide = hideEnchants;
|
||||
final boolean hide) {
|
||||
if (item == null || item.getItemMeta() == null || !EnchantmentTarget.ALL.getMaterials().contains(item.getType())) {
|
||||
return item;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getPersistentDataContainer().has(KEY_V, PersistentDataType.INTEGER) && hideEnchants) {
|
||||
hide = false;
|
||||
}
|
||||
|
||||
revertDisplay(item);
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) {
|
||||
return item;
|
||||
@ -203,9 +167,7 @@ public class EnchantDisplay {
|
||||
OPTIONS.getSorter().sortEnchantments(unsorted);
|
||||
|
||||
enchantments.clear();
|
||||
unsorted.forEach(enchantment -> {
|
||||
enchantments.put(enchantment, tempEnchantments.get(enchantment));
|
||||
});
|
||||
unsorted.forEach(enchantment -> enchantments.put(enchantment, tempEnchantments.get(enchantment)));
|
||||
|
||||
enchantments.forEach((enchantment, level) -> {
|
||||
if (EcoEnchants.getFromEnchantment(enchantment) == null) {
|
||||
|
@ -1,2 +1,2 @@
|
||||
version = 6.3.0
|
||||
version = 6.3.1
|
||||
plugin-name = EcoEnchants
|
Loading…
Reference in New Issue
Block a user