Optimised display + fixed codestyle from PR

This commit is contained in:
Auxilor 2021-05-16 23:02:55 +01:00
parent 6a14feadc8
commit 00efb2f30f
4 changed files with 10 additions and 12 deletions

View File

@ -17,7 +17,8 @@ import java.util.Map;
public final class FastGetEnchants implements FastGetEnchantsProxy {
@Override
public Map<Enchantment, Integer> getEnchantmentsOnItem(@NotNull final ItemStack itemStack, boolean checkStored) {
public Map<Enchantment, Integer> getEnchantmentsOnItem(@NotNull final ItemStack itemStack,
final boolean checkStored) {
net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagList enchantmentNBT = checkStored && nmsStack.getItem() == Items.ENCHANTED_BOOK ? ItemEnchantedBook.d(nmsStack) : nmsStack.getEnchantments();
HashMap<Enchantment, Integer> foundEnchantments = new HashMap<>();
@ -38,7 +39,7 @@ public final class FastGetEnchants implements FastGetEnchantsProxy {
@Override
public int getLevelOnItem(@NotNull final ItemStack itemStack,
@NotNull final Enchantment enchantment,
boolean checkStored) {
final boolean checkStored) {
net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagList enchantmentNBT = checkStored && nmsStack.getItem() == Items.ENCHANTED_BOOK ? ItemEnchantedBook.d(nmsStack) : nmsStack.getEnchantments();

View File

@ -17,7 +17,8 @@ import java.util.Map;
public final class FastGetEnchants implements FastGetEnchantsProxy {
@Override
public Map<Enchantment, Integer> getEnchantmentsOnItem(@NotNull final ItemStack itemStack, boolean checkStored) {
public Map<Enchantment, Integer> getEnchantmentsOnItem(@NotNull final ItemStack itemStack,
final boolean checkStored) {
net.minecraft.server.v1_16_R2.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagList enchantmentNBT = checkStored && nmsStack.getItem() == Items.ENCHANTED_BOOK ? ItemEnchantedBook.d(nmsStack) : nmsStack.getEnchantments();
HashMap<Enchantment, Integer> foundEnchantments = new HashMap<>();
@ -38,7 +39,7 @@ public final class FastGetEnchants implements FastGetEnchantsProxy {
@Override
public int getLevelOnItem(@NotNull final ItemStack itemStack,
@NotNull final Enchantment enchantment,
boolean checkStored) {
final boolean checkStored) {
net.minecraft.server.v1_16_R2.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagList enchantmentNBT = checkStored && nmsStack.getItem() == Items.ENCHANTED_BOOK ? ItemEnchantedBook.d(nmsStack) : nmsStack.getEnchantments();

View File

@ -17,7 +17,8 @@ import java.util.Map;
public final class FastGetEnchants implements FastGetEnchantsProxy {
@Override
public Map<Enchantment, Integer> getEnchantmentsOnItem(@NotNull final ItemStack itemStack, boolean checkStored) {
public Map<Enchantment, Integer> getEnchantmentsOnItem(@NotNull final ItemStack itemStack,
final boolean checkStored) {
net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagList enchantmentNBT = checkStored && nmsStack.getItem() == Items.ENCHANTED_BOOK ? ItemEnchantedBook.d(nmsStack) : nmsStack.getEnchantments();
HashMap<Enchantment, Integer> foundEnchantments = new HashMap<>();
@ -38,7 +39,7 @@ public final class FastGetEnchants implements FastGetEnchantsProxy {
@Override
public int getLevelOnItem(@NotNull final ItemStack itemStack,
@NotNull final Enchantment enchantment,
boolean checkStored) {
final boolean checkStored) {
net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagList enchantmentNBT = checkStored && nmsStack.getItem() == Items.ENCHANTED_BOOK ? ItemEnchantedBook.d(nmsStack) : nmsStack.getEnchantments();

View File

@ -112,14 +112,9 @@ public class EnchantDisplay extends DisplayModule {
List<String> lore = new ArrayList<>();
LinkedHashMap<Enchantment, Integer> enchantments = new LinkedHashMap<>();
List<Enchantment> forRemoval = new ArrayList<>();
if (meta instanceof EnchantmentStorageMeta) {
enchantments.putAll(((EnchantmentStorageMeta) meta).getStoredEnchants());
} else {
enchantments.putAll(meta.getEnchants());
}
LinkedHashMap<Enchantment, Integer> enchantments = new LinkedHashMap<>(ProxyUtils.getProxy(FastGetEnchantsProxy.class).getEnchantmentsOnItem(itemStack, true));
enchantments.entrySet().removeIf(enchantmentIntegerEntry -> enchantmentIntegerEntry.getValue().equals(0));