Fixed GUI, anvil merging
This commit is contained in:
parent
046c11924f
commit
6cdd7b7dfc
12
Core/pom.xml
12
Core/pom.xml
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -45,27 +45,27 @@
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>NMS</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_17_R1</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_18_R2</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_19_R1</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_19_R2</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
|
@ -32,6 +32,8 @@ 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 {
|
||||
@ -41,10 +43,15 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha
|
||||
private String chestName;
|
||||
private List<String> chestLore;
|
||||
private final NamespacedKey keyChest;
|
||||
@Deprecated private final Map<Integer, NamespacedKey> 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)
|
||||
|
@ -97,7 +97,7 @@ public class EnchantAnvilListener extends AbstractListener<ExcellentEnchants> {
|
||||
// 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)));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class EnchantmentsListMenu extends AbstractMenuAuto<ExcellentEnchants, Ex
|
||||
if (itemClick == null) return;
|
||||
|
||||
int levelHas = PDCUtil.getIntData(itemClick, this.keyLevel);
|
||||
if (levelHas == 0) return;
|
||||
if (levelHas == 0) levelHas = enchant.getStartLevel();
|
||||
|
||||
if (++levelHas > enchant.getMaxLevel()) levelHas = enchant.getStartLevel();
|
||||
itemClick = this.getEnchantIcon(enchant, levelHas);
|
||||
|
@ -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));
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>NMS</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>NMS</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>NMS</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>NMS</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.3.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user