diff --git a/Core/pom.xml b/Core/pom.xml
index 5146a28..22aa57e 100644
--- a/Core/pom.xml
+++ b/Core/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.3.0
+ 3.3.0.2
4.0.0
@@ -45,27 +45,27 @@
su.nightexpress.excellentenchants
NMS
- 3.3.0
+ 3.3.0.2
su.nightexpress.excellentenchants
V1_17_R1
- 3.3.0
+ 3.3.0.2
su.nightexpress.excellentenchants
V1_18_R2
- 3.3.0
+ 3.3.0.2
su.nightexpress.excellentenchants
V1_19_R1
- 3.3.0
+ 3.3.0.2
su.nightexpress.excellentenchants
V1_19_R2
- 3.3.0
+ 3.3.0.2
fr.neatmonster
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java
index ab02777..51cc897 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java
@@ -32,19 +32,26 @@ import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
import java.util.stream.Stream;
public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEnchant {
public static final String ID = "silk_chest";
- private String chestName;
- private List chestLore;
- private final NamespacedKey keyChest;
+ private String chestName;
+ private List chestLore;
+ private final NamespacedKey keyChest;
+ @Deprecated private final Map keyItems;
public EnchantSilkChest(@NotNull ExcellentEnchants plugin) {
super(plugin, ID, EnchantPriority.HIGH);
this.keyChest = new NamespacedKey(plugin, ID + ".item");
+ this.keyItems = new TreeMap<>();
+ for (int pos = 0; pos < 27; pos++) {
+ this.getItemKey(pos);
+ }
}
@Override
@@ -58,6 +65,11 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha
"Use '" + Placeholders.GENERIC_AMOUNT + "' for items amount.").read(cfg);
}
+ @Deprecated
+ private NamespacedKey getItemKey(int pos) {
+ return this.keyItems.computeIfAbsent(pos, key -> new NamespacedKey(plugin, "silkchest_item_" + pos));
+ }
+
@Override
@NotNull
public FitItemType[] getFitItemTypes() {
@@ -71,7 +83,7 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha
}
public boolean isSilkChest(@NotNull ItemStack item) {
- return PDCUtil.getBooleanData(item, this.keyChest);
+ return PDCUtil.getBooleanData(item, this.keyChest) || PDCUtil.getStringData(item, this.getItemKey(0)) != null;
}
@NotNull
@@ -158,14 +170,14 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha
chest.setCustomName(null);
chest.update(true);
- //Inventory inventory = chest.getBlockInventory();
- /*for (int pos = 0; pos < inventory.getSize(); pos++) {
+ Inventory inventory = chest.getBlockInventory();
+ for (int pos = 0; pos < inventory.getSize(); pos++) {
String data = PDCUtil.getStringData(item, this.getItemKey(pos));
if (data == null) continue;
ItemStack itemInv = ItemUtil.fromBase64(data);
inventory.setItem(pos, itemInv);
- }*/
+ }
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantAnvilListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantAnvilListener.java
index 2cf3fb4..d302896 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantAnvilListener.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantAnvilListener.java
@@ -97,7 +97,7 @@ public class EnchantAnvilListener extends AbstractListener {
// Merge only if it's Item + Item, Item + Enchanted book or Enchanted Book + Enchanted Book
if (second.getType() == Material.ENCHANTED_BOOK || second.getType() == first.getType()) {
EnchantManager.getExcellentEnchantments(second).forEach((enchant, level) -> {
- enchantments.merge(enchant, level, (oldLvl, newLvl) -> (oldLvl.equals(newLvl)) ? (oldLvl + 1) : (Math.max(oldLvl, newLvl)));
+ enchantments.merge(enchant, level, (oldLvl, newLvl) -> (oldLvl.equals(newLvl)) ? (Math.min(enchant.getMaxLevel(), oldLvl + 1)) : (Math.max(oldLvl, newLvl)));
});
}
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/menu/EnchantmentsListMenu.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/menu/EnchantmentsListMenu.java
index 6d651c3..98e9019 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/menu/EnchantmentsListMenu.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/menu/EnchantmentsListMenu.java
@@ -101,7 +101,7 @@ public class EnchantmentsListMenu extends AbstractMenuAuto enchant.getMaxLevel()) levelHas = enchant.getStartLevel();
itemClick = this.getEnchantIcon(enchant, levelHas);
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/ProtocolHook.java b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/ProtocolHook.java
index 11ce9f1..5cd0ee7 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/ProtocolHook.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/ProtocolHook.java
@@ -16,9 +16,8 @@ import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant;
import su.nightexpress.excellentenchants.config.Config;
import su.nightexpress.excellentenchants.enchantment.EnchantManager;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
public class ProtocolHook {
@@ -94,6 +93,10 @@ public class ProtocolHook {
lore.removeAll(enchant.formatDescription(level));
});
}
+
+ enchants = enchants.entrySet().stream()
+ .sorted(Comparator.comparing(e -> e.getKey().getTier().getPriority()))
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (old,nev) -> nev, LinkedHashMap::new));
if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED.get() && !isCreative) {
enchants.forEach((enchant, level) -> {
lore.addAll(0, enchant.formatDescription(level));
diff --git a/NMS/pom.xml b/NMS/pom.xml
index 16d313f..f543476 100644
--- a/NMS/pom.xml
+++ b/NMS/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.3.0
+ 3.3.0.2
4.0.0
diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml
index b86ddf7..41bd7ab 100644
--- a/V1_17_R1/pom.xml
+++ b/V1_17_R1/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.3.0
+ 3.3.0.2
4.0.0
@@ -26,7 +26,7 @@
su.nightexpress.excellentenchants
NMS
- 3.3.0
+ 3.3.0.2
diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml
index c265265..56a51b5 100644
--- a/V1_18_R2/pom.xml
+++ b/V1_18_R2/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.3.0
+ 3.3.0.2
4.0.0
@@ -26,7 +26,7 @@
su.nightexpress.excellentenchants
NMS
- 3.3.0
+ 3.3.0.2
diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml
index 3c5889c..7fbd06e 100644
--- a/V1_19_R1/pom.xml
+++ b/V1_19_R1/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.3.0
+ 3.3.0.2
4.0.0
@@ -26,7 +26,7 @@
su.nightexpress.excellentenchants
NMS
- 3.3.0
+ 3.3.0.2
diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml
index 0cd1165..6a134be 100644
--- a/V1_19_R2/pom.xml
+++ b/V1_19_R2/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.3.0
+ 3.3.0.2
4.0.0
@@ -26,7 +26,7 @@
su.nightexpress.excellentenchants
NMS
- 3.3.0
+ 3.3.0.2
diff --git a/pom.xml b/pom.xml
index fce1012..e7cbd84 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
su.nightexpress.excellentenchants
ExcellentEnchants
pom
- 3.3.0
+ 3.3.0.2
Core
NMS