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>
|
<parent>
|
||||||
<artifactId>ExcellentEnchants</artifactId>
|
<artifactId>ExcellentEnchants</artifactId>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -45,27 +45,27 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<artifactId>NMS</artifactId>
|
<artifactId>NMS</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<artifactId>V1_17_R1</artifactId>
|
<artifactId>V1_17_R1</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<artifactId>V1_18_R2</artifactId>
|
<artifactId>V1_18_R2</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<artifactId>V1_19_R1</artifactId>
|
<artifactId>V1_19_R1</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<artifactId>V1_19_R2</artifactId>
|
<artifactId>V1_19_R2</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.neatmonster</groupId>
|
<groupId>fr.neatmonster</groupId>
|
||||||
|
@ -32,19 +32,26 @@ import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEnchant {
|
public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEnchant {
|
||||||
|
|
||||||
public static final String ID = "silk_chest";
|
public static final String ID = "silk_chest";
|
||||||
|
|
||||||
private String chestName;
|
private String chestName;
|
||||||
private List<String> chestLore;
|
private List<String> chestLore;
|
||||||
private final NamespacedKey keyChest;
|
private final NamespacedKey keyChest;
|
||||||
|
@Deprecated private final Map<Integer, NamespacedKey> keyItems;
|
||||||
|
|
||||||
public EnchantSilkChest(@NotNull ExcellentEnchants plugin) {
|
public EnchantSilkChest(@NotNull ExcellentEnchants plugin) {
|
||||||
super(plugin, ID, EnchantPriority.HIGH);
|
super(plugin, ID, EnchantPriority.HIGH);
|
||||||
this.keyChest = new NamespacedKey(plugin, ID + ".item");
|
this.keyChest = new NamespacedKey(plugin, ID + ".item");
|
||||||
|
this.keyItems = new TreeMap<>();
|
||||||
|
for (int pos = 0; pos < 27; pos++) {
|
||||||
|
this.getItemKey(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -58,6 +65,11 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha
|
|||||||
"Use '" + Placeholders.GENERIC_AMOUNT + "' for items amount.").read(cfg);
|
"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
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public FitItemType[] getFitItemTypes() {
|
public FitItemType[] getFitItemTypes() {
|
||||||
@ -71,7 +83,7 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSilkChest(@NotNull ItemStack item) {
|
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
|
@NotNull
|
||||||
@ -158,14 +170,14 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha
|
|||||||
chest.setCustomName(null);
|
chest.setCustomName(null);
|
||||||
chest.update(true);
|
chest.update(true);
|
||||||
|
|
||||||
//Inventory inventory = chest.getBlockInventory();
|
Inventory inventory = chest.getBlockInventory();
|
||||||
/*for (int pos = 0; pos < inventory.getSize(); pos++) {
|
for (int pos = 0; pos < inventory.getSize(); pos++) {
|
||||||
String data = PDCUtil.getStringData(item, this.getItemKey(pos));
|
String data = PDCUtil.getStringData(item, this.getItemKey(pos));
|
||||||
if (data == null) continue;
|
if (data == null) continue;
|
||||||
|
|
||||||
ItemStack itemInv = ItemUtil.fromBase64(data);
|
ItemStack itemInv = ItemUtil.fromBase64(data);
|
||||||
inventory.setItem(pos, itemInv);
|
inventory.setItem(pos, itemInv);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@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
|
// 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()) {
|
if (second.getType() == Material.ENCHANTED_BOOK || second.getType() == first.getType()) {
|
||||||
EnchantManager.getExcellentEnchantments(second).forEach((enchant, level) -> {
|
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;
|
if (itemClick == null) return;
|
||||||
|
|
||||||
int levelHas = PDCUtil.getIntData(itemClick, this.keyLevel);
|
int levelHas = PDCUtil.getIntData(itemClick, this.keyLevel);
|
||||||
if (levelHas == 0) return;
|
if (levelHas == 0) levelHas = enchant.getStartLevel();
|
||||||
|
|
||||||
if (++levelHas > enchant.getMaxLevel()) levelHas = enchant.getStartLevel();
|
if (++levelHas > enchant.getMaxLevel()) levelHas = enchant.getStartLevel();
|
||||||
itemClick = this.getEnchantIcon(enchant, levelHas);
|
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.config.Config;
|
||||||
import su.nightexpress.excellentenchants.enchantment.EnchantManager;
|
import su.nightexpress.excellentenchants.enchantment.EnchantManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.stream.Collectors;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ProtocolHook {
|
public class ProtocolHook {
|
||||||
|
|
||||||
@ -94,6 +93,10 @@ public class ProtocolHook {
|
|||||||
lore.removeAll(enchant.formatDescription(level));
|
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) {
|
if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED.get() && !isCreative) {
|
||||||
enchants.forEach((enchant, level) -> {
|
enchants.forEach((enchant, level) -> {
|
||||||
lore.addAll(0, enchant.formatDescription(level));
|
lore.addAll(0, enchant.formatDescription(level));
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ExcellentEnchants</artifactId>
|
<artifactId>ExcellentEnchants</artifactId>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ExcellentEnchants</artifactId>
|
<artifactId>ExcellentEnchants</artifactId>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -26,7 +26,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<artifactId>NMS</artifactId>
|
<artifactId>NMS</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ExcellentEnchants</artifactId>
|
<artifactId>ExcellentEnchants</artifactId>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -26,7 +26,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<artifactId>NMS</artifactId>
|
<artifactId>NMS</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ExcellentEnchants</artifactId>
|
<artifactId>ExcellentEnchants</artifactId>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -26,7 +26,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<artifactId>NMS</artifactId>
|
<artifactId>NMS</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ExcellentEnchants</artifactId>
|
<artifactId>ExcellentEnchants</artifactId>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -26,7 +26,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<artifactId>NMS</artifactId>
|
<artifactId>NMS</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
|||||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||||
<artifactId>ExcellentEnchants</artifactId>
|
<artifactId>ExcellentEnchants</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0.2</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>Core</module>
|
<module>Core</module>
|
||||||
<module>NMS</module>
|
<module>NMS</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user