v3.2.13 + engine update

This commit is contained in:
nulli0n 2022-12-26 22:10:54 +06:00
parent befeda87fb
commit 39ec13296e
46 changed files with 316 additions and 145 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.11</version>
<version>3.2.13</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -25,6 +25,10 @@
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
</repositories>
<dependencies>
@ -33,30 +37,35 @@
<artifactId>spigot-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>su.nexmedia.playerblocktracker</groupId>
<artifactId>PlayerBlockTracker</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.2.11</version>
<version>3.2.13</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_17_R1</artifactId>
<version>3.2.11</version>
<version>3.2.13</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_18_R2</artifactId>
<version>3.2.11</version>
<version>3.2.13</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_19_R1</artifactId>
<version>3.2.11</version>
<version>3.2.13</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_19_R2</artifactId>
<version>3.2.11</version>
<version>3.2.13</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
@ -70,6 +79,11 @@
<version>7.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
@ -84,6 +98,19 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<!-- Java 16 Fix -->
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.2</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>9.2</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>package</phase>
@ -95,8 +122,15 @@
<artifactSet>
<includes>
<include>su.nightexpress.excellentenchants*</include>
<include>su.nexmedia.playerblocktracker:*</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>su.nexmedia.playerblocktracker.</pattern>
<shadedPattern>su.nightexpress.excellentenchants.playerblocktracker.</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>

View File

@ -6,12 +6,14 @@ import su.nexmedia.engine.NexPlugin;
import su.nexmedia.engine.Version;
import su.nexmedia.engine.api.command.GeneralCommand;
import su.nexmedia.engine.command.list.ReloadSubCommand;
import su.nexmedia.engine.hooks.Hooks;
import su.nightexpress.excellentenchants.command.BookCommand;
import su.nightexpress.excellentenchants.command.EnchantCommand;
import su.nightexpress.excellentenchants.command.ListCommand;
import su.nightexpress.excellentenchants.command.TierbookCommand;
import su.nightexpress.excellentenchants.config.Config;
import su.nightexpress.excellentenchants.config.Lang;
import su.nightexpress.excellentenchants.hook.ProtocolHook;
import su.nightexpress.excellentenchants.manager.EnchantManager;
import su.nightexpress.excellentenchants.manager.type.FitItemType;
import su.nightexpress.excellentenchants.nms.EnchantNMS;
@ -87,7 +89,12 @@ public class ExcellentEnchants extends NexPlugin<ExcellentEnchants> {
@Override
public void registerHooks() {
if (Hooks.hasPlugin("ProtocolLib")) {
ProtocolHook.setup();
}
else {
this.warn("ProtocolLib is not installed. Enchantments won't be displayed on items.");
}
}
@Override

View File

@ -0,0 +1,25 @@
package su.nightexpress.excellentenchants;
public class Placeholders extends su.nexmedia.engine.utils.Placeholders {
public static final String URL_WIKI = "https://github.com/nulli0n/ExcellentEnchants-spigot/wiki/";
public static final String URL_PLACEHOLDERS = URL_WIKI + "Internal-Placeholders";
public static final String URL_ENGINE_SCALE = "https://github.com/nulli0n/NexEngine-spigot/wiki/Configuration-Tips#scalable-sections";
public static final String ENCHANTMENT_NAME = "%enchantment_name%";
public static final String ENCHANTMENT_NAME_FORMATTED = "%enchantment_name_formatted%";
public static final String ENCHANTMENT_DESCRIPTION = "%enchantment_description%";
public static final String ENCHANTMENT_LEVEL = "%enchantment_level%";
public static final String ENCHANTMENT_LEVEL_MIN = "%enchantment_level_min%";
public static final String ENCHANTMENT_LEVEL_MAX = "%enchantment_level_max%";
public static final String ENCHANTMENT_CONFLICTS = "%enchantment_conflicts%";
public static final String ENCHANTMENT_TARGET = "%enchantment_target%";
public static final String ENCHANTMENT_TIER = "%enchantment_tier%";
public static final String ENCHANTMENT_FIT_ITEM_TYPES = "%enchantment_fit_item_types%";
public static final String ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING = "%enchantment_obtain_chance_enchanting%";
public static final String ENCHANTMENT_OBTAIN_CHANCE_VILLAGER = "%enchantment_obtain_chance_villager%";
public static final String ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION = "%enchantment_obtain_chance_loot_generation%";
public static final String ENCHANTMENT_OBTAIN_CHANCE_FISHING = "%enchantment_obtain_chance_fishing%";
public static final String ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING = "%enchantment_obtain_chance_mob_spawning%";
public static final String ENCHANTMENT_COST_ITEM = "%enchantment_cost_item%";
}

View File

@ -11,9 +11,7 @@ import org.jetbrains.annotations.Nullable;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.api.manager.IListener;
import su.nexmedia.engine.lang.LangManager;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.*;
import su.nexmedia.engine.utils.data.Pair;
import su.nexmedia.engine.utils.random.Rnd;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.config.Config;
@ -23,6 +21,7 @@ import su.nightexpress.excellentenchants.manager.object.EnchantScaler;
import su.nightexpress.excellentenchants.manager.object.EnchantTier;
import su.nightexpress.excellentenchants.manager.type.FitItemType;
import su.nightexpress.excellentenchants.manager.type.ObtainType;
import su.nightexpress.excellentenchants.Placeholders;
import java.util.*;
import java.util.function.UnaryOperator;
@ -31,23 +30,6 @@ import java.util.stream.Stream;
public abstract class ExcellentEnchant extends Enchantment implements IListener {
public static final String PLACEHOLDER_NAME = "%enchantment_name%";
public static final String PLACEHOLDER_NAME_FORMATTED = "%enchantment_name_formatted%";
public static final String PLACEHOLDER_DESCRIPTION = "%enchantment_description%";
public static final String PLACEHOLDER_LEVEL = "%enchantment_level%";
public static final String PLACEHOLDER_LEVEL_MIN = "%enchantment_level_min%";
public static final String PLACEHOLDER_LEVEL_MAX = "%enchantment_level_max%";
public static final String PLACEHOLDER_CONFLICTS = "%enchantment_conflicts%";
public static final String PLACEHOLDER_TARGET = "%enchantment_target%";
public static final String PLACEHOLDER_TIER = "%enchantment_tier%";
public static final String PLACEHOLDER_FIT_ITEM_TYPES = "%enchantment_fit_item_types%";
public static final String PLACEHOLDER_OBTAIN_CHANCE_ENCHANTING = "%enchantment_obtain_chance_enchanting%";
public static final String PLACEHOLDER_OBTAIN_CHANCE_VILLAGER = "%enchantment_obtain_chance_villager%";
public static final String PLACEHOLDER_OBTAIN_CHANCE_LOOT_GENERATION = "%enchantment_obtain_chance_loot_generation%";
public static final String PLACEHOLDER_OBTAIN_CHANCE_FISHING = "%enchantment_obtain_chance_fishing%";
public static final String PLACEHOLDER_OBTAIN_CHANCE_MOB_SPAWNING = "%enchantment_obtain_chance_mob_spawning%";
public static final String PLACEHOLDER_COST_ITEM = "%enchantment_cost_item%";
protected final ExcellentEnchants plugin;
protected final JYML cfg;
protected final String id;
@ -113,6 +95,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener
this.costItem = cfg.getItem("Settings.Cost.Item");
}
@Deprecated
protected void updateConfig() {
cfg.addMissing("Is_Treasure", false);
cfg.addMissing("Conflicts", new ArrayList<String>());
@ -192,28 +175,34 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener
String conflicts = this.getConflicts().isEmpty() ? plugin.getMessage(Lang.OTHER_NONE).getLocalized() : this.getConflicts().stream().filter(Objects::nonNull).map(LangManager::getEnchantment).collect(Collectors.joining("\n"));
return str -> str
.replace(PLACEHOLDER_NAME, this.getDisplayName())
.replace(PLACEHOLDER_NAME_FORMATTED, this.getNameFormatted(level))
.replace(PLACEHOLDER_LEVEL, NumberUtil.toRoman(level))
.replace(PLACEHOLDER_LEVEL_MIN, String.valueOf(this.getStartLevel()))
.replace(PLACEHOLDER_LEVEL_MAX, String.valueOf(this.getMaxLevel()))
.replace(PLACEHOLDER_TARGET, plugin.getLangManager().getEnum(this.getItemTarget()))
.replace(PLACEHOLDER_TIER, this.getTier().getName())
.replace(PLACEHOLDER_CONFLICTS, conflicts)
.replace(PLACEHOLDER_FIT_ITEM_TYPES, String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList()))
.replace(PLACEHOLDER_OBTAIN_CHANCE_ENCHANTING, NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING)))
.replace(PLACEHOLDER_OBTAIN_CHANCE_VILLAGER, NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER)))
.replace(PLACEHOLDER_OBTAIN_CHANCE_LOOT_GENERATION, NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION)))
.replace(PLACEHOLDER_OBTAIN_CHANCE_FISHING, NumberUtil.format(this.getObtainChance(ObtainType.FISHING)))
.replace(PLACEHOLDER_OBTAIN_CHANCE_MOB_SPAWNING, NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING)))
.replace(PLACEHOLDER_COST_ITEM, this.hasCostItem() ? ItemUtil.getItemName(this.costItem) : plugin.getMessage(Lang.OTHER_NONE).getLocalized())
.replace(Placeholders.ENCHANTMENT_NAME, this.getDisplayName())
.replace(Placeholders.ENCHANTMENT_NAME_FORMATTED, this.getNameFormatted(level))
.replace(Placeholders.ENCHANTMENT_LEVEL, NumberUtil.toRoman(level))
.replace(Placeholders.ENCHANTMENT_LEVEL_MIN, String.valueOf(this.getStartLevel()))
.replace(Placeholders.ENCHANTMENT_LEVEL_MAX, String.valueOf(this.getMaxLevel()))
.replace(Placeholders.ENCHANTMENT_TARGET, plugin.getLangManager().getEnum(this.getItemTarget()))
.replace(Placeholders.ENCHANTMENT_TIER, this.getTier().getName())
.replace(Placeholders.ENCHANTMENT_CONFLICTS, conflicts)
.replace(Placeholders.ENCHANTMENT_FIT_ITEM_TYPES, String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList()))
.replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING, NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING)))
.replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_VILLAGER, NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER)))
.replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION, NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION)))
.replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_FISHING, NumberUtil.format(this.getObtainChance(ObtainType.FISHING)))
.replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING, NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING)))
.replace(Placeholders.ENCHANTMENT_COST_ITEM, this.hasCostItem() ? ItemUtil.getItemName(this.costItem) : plugin.getMessage(Lang.OTHER_NONE).getLocalized())
;
}
@Override
public void registerListeners() {
this.addConflicts();
this.plugin.getPluginManager().registerEvents(this, plugin);
}
@NotNull
public UnaryOperator<String> formatString(int level) {
return str -> this.replacePlaceholders(level).apply(str
.replace(PLACEHOLDER_DESCRIPTION, String.join("\n", Config.formatDescription(this.getDescription())))
.replace(Placeholders.ENCHANTMENT_DESCRIPTION, String.join("\n", Config.formatDescription(this.getDescription())))
);
}
@ -246,12 +235,6 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener
return !Config.isEnchantmentDisabled(this, entity.getWorld().getName());
}
@Override
public void registerListeners() {
this.addConflicts();
this.plugin.getPluginManager().registerEvents(this, plugin);
}
@NotNull
public JYML getConfig() {
return this.cfg;

View File

@ -2,10 +2,11 @@ package su.nightexpress.excellentenchants.api.enchantment;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nexmedia.engine.utils.random.Rnd;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.Placeholders;
import su.nightexpress.excellentenchants.manager.object.EnchantScaler;
import java.util.function.UnaryOperator;
@ -31,7 +32,7 @@ public abstract class IEnchantChanceTemplate extends ExcellentEnchant {
super.updateConfig();
if (cfg.contains("settings.enchant-trigger-chance")) {
String triggerChance = cfg.getString("settings.enchant-trigger-chance", "100").replace("%level%", PLACEHOLDER_LEVEL);
String triggerChance = cfg.getString("settings.enchant-trigger-chance", "100").replace("%level%", Placeholders.ENCHANTMENT_LEVEL);
cfg.set("Settings.Trigger_Chance", triggerChance);
cfg.set("settings.enchant-trigger-chance", null);

View File

@ -6,8 +6,8 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.lang.LangManager;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant;
import su.nightexpress.excellentenchants.manager.EnchantManager;
@ -21,7 +21,7 @@ public abstract class IEnchantPotionTemplate extends IEnchantChanceTemplate {
public static final String PLACEHOLDER_POTION_DURATION = "%enchantment_potion_duration%";
public static final String PLACEHOLDER_POTION_TYPE = "%enchantment_potion_type%";
protected PotionEffectType potionEffectType;
protected PotionEffectType potionEffectType;
protected final boolean potionParticles;
protected Scaler potionDuration;
protected Scaler potionLevel;

View File

@ -16,10 +16,10 @@ import su.nexmedia.engine.utils.random.Rnd;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.Perms;
import su.nightexpress.excellentenchants.config.Lang;
import su.nightexpress.excellentenchants.manager.EnchantManager;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class BookCommand extends AbstractCommand<ExcellentEnchants> {
@ -60,7 +60,7 @@ public class BookCommand extends AbstractCommand<ExcellentEnchants> {
}
@Override
public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) {
public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args, @NotNull Map<String, String> flags) {
if (args.length != 4) {
this.printUsage(sender);
return;
@ -90,7 +90,7 @@ public class BookCommand extends AbstractCommand<ExcellentEnchants> {
meta.addStoredEnchant(enchantment, level, true);
item.setItemMeta(meta);
EnchantManager.updateItemLoreEnchants(item);
//EnchantManager.updateItemLoreEnchants(item);
PlayerUtil.addItem(player, item);
plugin.getMessage(Lang.COMMAND_BOOK_DONE)

View File

@ -14,10 +14,10 @@ import su.nexmedia.engine.utils.random.Rnd;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.Perms;
import su.nightexpress.excellentenchants.config.Lang;
import su.nightexpress.excellentenchants.manager.EnchantManager;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class EnchantCommand extends AbstractCommand<ExcellentEnchants> {
@ -55,7 +55,7 @@ public class EnchantCommand extends AbstractCommand<ExcellentEnchants> {
}
@Override
public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) {
public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args, @NotNull Map<String, String> flags) {
if (args.length != 3) {
this.printUsage(sender);
return;
@ -99,7 +99,7 @@ public class EnchantCommand extends AbstractCommand<ExcellentEnchants> {
}
}
item.setItemMeta(meta);
EnchantManager.updateItemLoreEnchants(item);
//EnchantManager.updateItemLoreEnchants(item);
plugin.getMessage(Lang.COMMAND_ENCHANT_DONE).send(sender);
}

View File

@ -8,6 +8,8 @@ import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.Perms;
import su.nightexpress.excellentenchants.config.Lang;
import java.util.Map;
public class ListCommand extends AbstractCommand<ExcellentEnchants> {
public ListCommand(@NotNull ExcellentEnchants plugin) {
@ -32,7 +34,7 @@ public class ListCommand extends AbstractCommand<ExcellentEnchants> {
}
@Override
protected void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) {
protected void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args, @NotNull Map<String, String> flags) {
plugin.getEnchantManager().getEnchantsListGUI().open((Player) sender, 1);
}
}

View File

@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.manager.object.EnchantTier;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class TierbookCommand extends AbstractCommand<ExcellentEnchants> {
@ -58,7 +59,7 @@ public class TierbookCommand extends AbstractCommand<ExcellentEnchants> {
}
@Override
public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) {
public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args, @NotNull Map<String, String> flags) {
if (args.length != 4) {
this.printUsage(sender);
return;

View File

@ -0,0 +1,115 @@
package su.nightexpress.excellentenchants.hook;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import org.bukkit.GameMode;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.Nullable;
import su.nexmedia.engine.utils.ItemUtil;
import su.nightexpress.excellentenchants.ExcellentEnchantsAPI;
import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant;
import su.nightexpress.excellentenchants.config.Config;
import su.nightexpress.excellentenchants.manager.EnchantManager;
import java.util.List;
import java.util.Map;
public class ProtocolHook {
private static boolean isRegistered = false;
public static void setup() {
if (isRegistered) return;
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(ExcellentEnchantsAPI.PLUGIN, PacketType.Play.Server.SET_SLOT) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
ItemStack item = packet.getItemModifier().read(0);
boolean removeOld = event.getPlayer().getGameMode() == GameMode.CREATIVE;
if (removeOld) {
packet.getItemModifier().write(0, remove(item));
}
else {
packet.getItemModifier().write(0, update(item));
}
}
});
manager.addPacketListener(new PacketAdapter(ExcellentEnchantsAPI.PLUGIN, PacketType.Play.Server.WINDOW_ITEMS) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
List<ItemStack> items = packet.getItemListModifier().readSafely(0);
boolean removeOld = event.getPlayer().getGameMode() == GameMode.CREATIVE;
for (int index = 0; index < items.size(); index++) {
if (removeOld) {
items.set(index, remove(items.get(index)));
}
else {
items.set(index, update(items.get(index)));
}
}
packet.getItemListModifier().write(0, items);
}
});
isRegistered = true;
}
@Nullable
private static ItemStack update(@Nullable ItemStack item) {
if (item == null || item.getType().isAir()) return item;
ItemStack copy = new ItemStack(item);
ItemMeta meta = copy.getItemMeta();
if (meta == null) return item;
List<String> lore = ItemUtil.getLore(copy);
Map<ExcellentEnchant, Integer> enchants = EnchantManager.getItemCustomEnchants(item);
//if (enchants.keySet().stream().anyMatch(enchant -> ItemUtil.getLoreTag(item, enchant.getId()) != null)) {
// return item;
//}
if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED) {
enchants.forEach((enchant, integer) -> {
lore.addAll(0, Config.formatDescription(enchant.getDescription(integer)));
});
}
enchants.forEach((enchant, integer) -> {
lore.add(0, enchant.getNameFormatted(integer));
});
meta.setLore(lore);
copy.setItemMeta(meta);
return copy;
}
@Nullable
private static ItemStack remove(@Nullable ItemStack item) {
if (item == null || item.getType().isAir()) return item;
List<String> from = ItemUtil.getLore(item);
Map<ExcellentEnchant, Integer> enchants = EnchantManager.getItemCustomEnchants(item);
enchants.forEach((enchant, integer) -> {
from.removeIf(line -> line.equalsIgnoreCase(enchant.getNameFormatted(integer)));
from.removeAll(Config.formatDescription(enchant.getDescription(integer)));
});
ItemMeta meta = item.getItemMeta();
if (meta == null) return item;
meta.setLore(from);
item.setItemMeta(meta);
return item;
}
}

View File

@ -160,10 +160,11 @@ public class EnchantManager extends AbstractManager<ExcellentEnchants> {
return EnchantManager.getItemCustomEnchantsAmount(item) != enchantsHad;
}
@Deprecated
public static void updateItemLoreEnchants(@NotNull ItemStack item) {
EnchantRegister.ENCHANT_LIST.forEach(ench -> {
ItemUtil.delLore(item, ench.getId());
ItemUtil.delLore(item, ench.getId() + "_info");
//ItemUtil.delLore(item, ench.getId());
//ItemUtil.delLore(item, ench.getId() + "_info");
});
// Filter custom enchants and define map order.
@ -172,7 +173,7 @@ public class EnchantManager extends AbstractManager<ExcellentEnchants> {
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (has, add) -> add, LinkedHashMap::new));
excellents.forEach((excellent, level) -> {
ItemUtil.addLore(item, excellent.getId(), excellent.getNameFormatted(level), 0);
//ItemUtil.addLore(item, excellent.getId(), excellent.getNameFormatted(level), 0);
});
// Add enchantment description at the end of item lore.
@ -184,7 +185,7 @@ public class EnchantManager extends AbstractManager<ExcellentEnchants> {
List<String> desc = excellent.getDescription(excellents.get(excellent));
if (desc.isEmpty()) return;
ItemUtil.addLore(item, excellent.getId() + "_info", Config.formatDescription(desc), -1);
//ItemUtil.addLore(item, excellent.getId() + "_info", Config.formatDescription(desc), -1);
});
}
}
@ -194,9 +195,9 @@ public class EnchantManager extends AbstractManager<ExcellentEnchants> {
EnchantManager.removeEnchant(item, enchantment);
if (enchantment instanceof ExcellentEnchant excellentEnchant) {
ItemUtil.addLore(item, excellentEnchant.getId(), excellentEnchant.getNameFormatted(level), 0);
}
//if (enchantment instanceof ExcellentEnchant excellentEnchant) {
//ItemUtil.addLore(item, excellentEnchant.getId(), excellentEnchant.getNameFormatted(level), 0);
//}
ItemMeta meta = item.getItemMeta();
if (meta == null) return false;
@ -213,9 +214,9 @@ public class EnchantManager extends AbstractManager<ExcellentEnchants> {
}
public static void removeEnchant(@NotNull ItemStack item, @NotNull Enchantment enchantment) {
if (enchantment instanceof ExcellentEnchant excellentEnchant) {
ItemUtil.delLore(item, excellentEnchant.getId());
}
//if (enchantment instanceof ExcellentEnchant excellentEnchant) {
//ItemUtil.delLore(item, excellentEnchant.getId());
//}
ItemMeta meta = item.getItemMeta();
if (meta instanceof EnchantmentStorageMeta storageMeta) {

View File

@ -90,7 +90,7 @@ public class EnchantRegister {
static {
PLUGIN = ExcellentEnchants.getPlugin(ExcellentEnchants.class);
PLUGIN.getConfigManager().extract("enchants");
PLUGIN.getConfigManager().extractResources("/enchants/");
ENCHANT_LIST = new HashSet<>();
// Tool enchants

View File

@ -8,10 +8,10 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.ArrayUtil;
import su.nexmedia.engine.utils.EntityUtil;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;
@ -83,7 +83,7 @@ public class EnchantElementalProtection extends IEnchantChanceTemplate {
if (!this.isEnchantmentAvailable(victim)) return;
double protectionAmount = 0D;
for (ItemStack armor : EntityUtil.getArmor(victim)) {
for (ItemStack armor : EntityUtil.getEquippedArmor(victim).values()) {
if (armor == null || armor.getType().isAir()) continue;
int level = EnchantManager.getItemEnchantLevel(armor, this);

View File

@ -6,8 +6,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;

View File

@ -19,10 +19,11 @@ import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.api.manager.ICleanable;
import su.nexmedia.engine.api.task.AbstractTask;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.EffectUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nexmedia.engine.utils.random.Rnd;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.Placeholders;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;
import su.nightexpress.excellentenchants.api.enchantment.type.MoveEnchant;
@ -60,7 +61,7 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn
protected void updateConfig() {
super.updateConfig();
cfg.addMissing("Settings.Block_Decay", "5.0 + " + PLACEHOLDER_LEVEL + " * 2");
cfg.addMissing("Settings.Block_Decay", "5.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 2");
}
@Override

View File

@ -7,10 +7,10 @@ import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.api.manager.ICleanable;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.EffectUtil;
import su.nexmedia.engine.utils.EntityUtil;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant;
@ -30,7 +30,7 @@ public class EnchantRegrowth extends IEnchantChanceTemplate implements PassiveEn
private String particleData;
private long healthInterval;
private Scaler healthAmount;
private Task healthTask;
private Task healthTask;
private static final String PLACEHOLDER_HEALTH_AMOUNT = "%enchantment_health_amount%";
private static final String PLACEHOLDER_HEALTH_INTERVAL = "%enchantment_health_interval%";

View File

@ -6,8 +6,8 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.api.manager.ICleanable;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant;
@ -21,9 +21,9 @@ import java.util.function.UnaryOperator;
public class EnchantSaturation extends IEnchantChanceTemplate implements PassiveEnchant, ICleanable {
private long saturationInterval;
private long saturationInterval;
private Scaler saturationAmount;
private Task saturationTask;
private Task saturationTask;
public static final String ID = "saturation";

View File

@ -10,8 +10,8 @@ import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;

View File

@ -10,8 +10,8 @@ import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;

View File

@ -13,8 +13,8 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowTemplate;

View File

@ -12,8 +12,9 @@ import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.Placeholders;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
@ -23,7 +24,7 @@ import su.nightexpress.excellentenchants.manager.object.EnchantScaler;
public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant {
private boolean fireSpread;
private Scaler yield;
private Scaler yield;
public static final String ID = "ghast";
@ -43,7 +44,7 @@ public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant {
super.updateConfig();
cfg.addMissing("Settings.Fire_Spread", true);
cfg.addMissing("Settings.Yield", "1.0 * " + PLACEHOLDER_LEVEL);
cfg.addMissing("Settings.Yield", "1.0 * " + Placeholders.ENCHANTMENT_LEVEL);
}
public boolean isFireSpread() {

View File

@ -14,9 +14,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.Placeholders;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;
import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
@ -68,7 +69,7 @@ public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockB
protected void updateConfig() {
super.updateConfig();
cfg.addMissing("Settings.Min_Block_Strength", "1.5 - " + PLACEHOLDER_LEVEL + " / 10.0");
cfg.addMissing("Settings.Min_Block_Strength", "1.5 - " + Placeholders.ENCHANTMENT_LEVEL + " / 10.0");
}
@Override

View File

@ -8,8 +8,8 @@ import org.bukkit.event.player.PlayerItemDamageEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;

View File

@ -6,8 +6,8 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;

View File

@ -13,11 +13,11 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.api.manager.ICleanable;
import su.nexmedia.engine.manager.player.blocktracker.PlayerBlockTracker;
import su.nexmedia.engine.utils.EffectUtil;
import su.nexmedia.engine.utils.LocationUtil;
import su.nexmedia.engine.utils.MessageUtil;
import su.nexmedia.engine.utils.random.Rnd;
import su.nexmedia.playerblocktracker.PlayerBlockTracker;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
@ -42,7 +42,7 @@ public class EnchantTreasures extends IEnchantChanceTemplate implements CustomDr
public EnchantTreasures(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) {
super(plugin, cfg, EnchantPriority.MEDIUM);
PlayerBlockTracker.initialize();
PlayerBlockTracker.initialize(plugin);
PlayerBlockTracker.BLOCK_FILTERS.add(this.blockTracker = (block) -> {
return this.getTreasure(block.getType()) != null;
});

View File

@ -11,9 +11,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.EffectUtil;
import su.nexmedia.engine.utils.LocationUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;

View File

@ -9,9 +9,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.EffectUtil;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;
@ -23,10 +23,10 @@ import java.util.function.UnaryOperator;
public class EnchantBaneOfNetherspawn extends IEnchantChanceTemplate implements CombatEnchant {
private String particleName;
private String particleData;
private boolean damageModifier;
private Scaler damageFormula;
private String particleName;
private String particleData;
private boolean damageModifier;
private Scaler damageFormula;
private final Set<EntityType> entityTypes;
public static final String ID = "bane_of_netherspawn";

View File

@ -12,10 +12,10 @@ import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.EffectUtil;
import su.nexmedia.engine.utils.MessageUtil;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nexmedia.engine.utils.random.Rnd;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;

View File

@ -6,8 +6,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDeathEvent;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;

View File

@ -11,8 +11,8 @@ import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;

View File

@ -9,9 +9,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.EntityUtil;
import su.nexmedia.engine.utils.MessageUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;

View File

@ -9,11 +9,12 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.EffectUtil;
import su.nexmedia.engine.utils.EntityUtil;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.Placeholders;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
@ -23,9 +24,9 @@ import java.util.function.UnaryOperator;
public class EnchantVampire extends IEnchantChanceTemplate implements CombatEnchant {
private String particleName;
private String particleData;
private Scaler healAmount;
private String particleName;
private String particleData;
private Scaler healAmount;
private boolean healMultiplier;
public static final String ID = "vampire";
@ -60,7 +61,7 @@ public class EnchantVampire extends IEnchantChanceTemplate implements CombatEnch
cfg.remove("Settings.Heal_Of_Damage");
cfg.addMissing("Settings.Particle.Name", Particle.HEART.name());
cfg.addMissing("Settings.Particle.Data", "");
cfg.addMissing("Settings.Heal.Amount", "0.25 * " + PLACEHOLDER_LEVEL);
cfg.addMissing("Settings.Heal.Amount", "0.25 * " + Placeholders.ENCHANTMENT_LEVEL);
cfg.addMissing("Settings.Heal.As_Multiplier", false);
}

View File

@ -8,9 +8,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.EffectUtil;
import su.nexmedia.engine.utils.NumberUtil;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate;
@ -22,9 +22,9 @@ import java.util.function.UnaryOperator;
public class EnchantVillageDefender extends IEnchantChanceTemplate implements CombatEnchant {
private boolean damageMultiplier;
private Scaler damageAmount;
private String particleName;
private String particleData;
private Scaler damageAmount;
private String particleName;
private String particleData;
public static final String ID = "village_defender";
public static final String PLACEHOLDER_DAMAGE_AMOUNT = "%enchantment_damage_amount%";

View File

@ -102,7 +102,7 @@ public class EnchantGenericListener extends AbstractListener<ExcellentEnchants>
}
if (!first.equals(result)) {
EnchantManager.updateItemLoreEnchants(result);
//EnchantManager.updateItemLoreEnchants(result);
e.setResult(result);
// NMS ContainerAnvil will set level cost to 0 right after calling the event
@ -148,7 +148,7 @@ public class EnchantGenericListener extends AbstractListener<ExcellentEnchants>
curses.forEach((excellentEnchant, level) -> {
EnchantManager.addEnchant(result, excellentEnchant, level, true);
});
EnchantManager.updateItemLoreEnchants(result);
//EnchantManager.updateItemLoreEnchants(result);
});
}
@ -181,7 +181,7 @@ public class EnchantGenericListener extends AbstractListener<ExcellentEnchants>
result.setItemMeta(storageMeta);
}
EnchantManager.updateItemLoreEnchants(result);
//EnchantManager.updateItemLoreEnchants(result);
e.getInventory().setItem(0, result);
});
}

View File

@ -95,7 +95,7 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
ItemStack weaponDamager = equipDamager.getItemInMainHand();
for (ItemStack armor : EntityUtil.getArmor(victim)) {
for (ItemStack armor : EntityUtil.getEquippedArmor(victim).values()) {
if (armor == null || armor.getType().isAir()) continue;
EnchantManager.getItemCustomEnchants(armor, CombatEnchant.class).forEach((combatEnchant, level) -> {
@ -182,7 +182,7 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
@EventHandler(priority = EventPriority.HIGHEST)
public void onEnchantDeath(EntityDeathEvent e) {
LivingEntity dead = e.getEntity();
for (ItemStack armor : EntityUtil.getArmor(dead)) {
for (ItemStack armor : EntityUtil.getEquippedArmor(dead).values()) {
if (armor == null || armor.getType().isAir()) continue;
EnchantManager.getItemCustomEnchants(armor, DeathEnchant.class).forEach((deathEnchant, level) -> {

View File

@ -13,6 +13,7 @@ import su.nexmedia.engine.utils.CollectionsUtil;
import su.nexmedia.engine.utils.ItemUtil;
import su.nexmedia.engine.utils.PDCUtil;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.Placeholders;
import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant;
import su.nightexpress.excellentenchants.config.Lang;
import su.nightexpress.excellentenchants.manager.EnchantRegister;
@ -35,7 +36,7 @@ public class EnchantListGUI extends AbstractMenu<ExcellentEnchants> {
this.enchantIcon = cfg.getItem("Enchantments.Icon");
this.enchantSlots = cfg.getIntArray("Enchantments.Slots");
IMenuClick click = (p, type, e) -> {
MenuClick click = (p, type, e) -> {
if (type instanceof MenuItemType type2) {
switch (type2) {
case PAGE_NEXT -> this.open(p, this.getPage(p) + 1);
@ -46,10 +47,10 @@ public class EnchantListGUI extends AbstractMenu<ExcellentEnchants> {
};
for (String sId : cfg.getSection("Content")) {
IMenuItem menuItem = cfg.getMenuItem("Content." + sId);
MenuItem menuItem = cfg.getMenuItem("Content." + sId);
if (menuItem.getType() != null) {
menuItem.setClick(click);
menuItem.setClickHandler(click);
}
this.addItem(menuItem);
}
@ -69,13 +70,13 @@ public class EnchantListGUI extends AbstractMenu<ExcellentEnchants> {
: enchant.getConflicts().stream().filter(Objects::nonNull)
.map(LangManager::getEnchantment).toList();
ItemUtil.replaceLore(icon, ExcellentEnchant.PLACEHOLDER_CONFLICTS, conflicts);
ItemUtil.replaceLore(icon, Placeholders.ENCHANTMENT_CONFLICTS, conflicts);
ItemUtil.replace(icon, enchant.formatString(level));
return icon;
}
@Override
public void onPrepare(@NotNull Player player, @NotNull Inventory inventory) {
public boolean onPrepare(@NotNull Player player, @NotNull Inventory inventory) {
int page = this.getPage(player);
int length = this.enchantSlots.length;
List<ExcellentEnchant> list = new ArrayList<>(EnchantRegister.ENCHANT_LIST.stream().
@ -91,7 +92,7 @@ public class EnchantListGUI extends AbstractMenu<ExcellentEnchants> {
ItemStack icon = this.getEnchantIcon(enchant, 1);
PDCUtil.setData(icon, this.keyLevel, 1);
IMenuClick click = (p, type, e) -> {
MenuClick click = (p, type, e) -> {
if (!e.isLeftClick()) return;
ItemStack itemClick = e.getCurrentItem();
@ -107,16 +108,12 @@ public class EnchantListGUI extends AbstractMenu<ExcellentEnchants> {
e.setCurrentItem(itemClick);
};
IMenuItem menuItem = new MenuItem(icon, this.enchantSlots[count++]);
menuItem.setClick(click);
MenuItem menuItem = new MenuItem(icon, this.enchantSlots[count++]);
menuItem.setClickHandler(click);
this.addItem(player, menuItem);
}
this.setPage(player, page, pages);
}
@Override
public void onReady(@NotNull Player player, @NotNull Inventory inventory) {
return true;
}
@Override

View File

@ -1,12 +1,13 @@
package su.nightexpress.excellentenchants.manager.object;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.manager.leveling.Scaler;
import su.nexmedia.engine.utils.Scaler;
import su.nightexpress.excellentenchants.Placeholders;
import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant;
public class EnchantScaler extends Scaler {
public EnchantScaler(@NotNull ExcellentEnchant enchant, @NotNull String path) {
super(enchant.getConfig(), path, ExcellentEnchant.PLACEHOLDER_LEVEL, enchant.getStartLevel(), enchant.getMaxLevel());
super(enchant.getConfig(), path, Placeholders.ENCHANTMENT_LEVEL, enchant.getStartLevel(), enchant.getMaxLevel());
}
}

View File

@ -4,7 +4,7 @@ name: ExcellentEnchants
author: NightExpress
desciption: Vanilla-like enchants for your server.
depend: [ NexEngine ]
softdepend: [ Towny, Residence, WorldGuard, GriefPrevention, Lands ]
softdepend: [ ProtocolLib, Towny, Residence, WorldGuard, GriefPrevention, Lands ]
api-version: 1.17
load: STARTUP

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.11</version>
<version>3.2.13</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.11</version>
<version>3.2.13</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.2.11</version>
<version>3.2.13</version>
</dependency>
</dependencies>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.11</version>
<version>3.2.13</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.2.11</version>
<version>3.2.13</version>
</dependency>
</dependencies>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.11</version>
<version>3.2.13</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.2.11</version>
<version>3.2.13</version>
</dependency>
</dependencies>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.11</version>
<version>3.2.13</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.2.11</version>
<version>3.2.13</version>
</dependency>
</dependencies>

View File

@ -15,7 +15,7 @@ public class CustomEffectInstance extends MobEffectInstance {
private final Enchantment enchantment;
public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) {
super(effect, Integer.MAX_VALUE, amplifier);
super(effect, MIN * 2, amplifier);
this.enchantment = enchantment;
}

View File

@ -7,7 +7,7 @@
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>ExcellentEnchants</artifactId>
<packaging>pom</packaging>
<version>3.2.11</version>
<version>3.2.13</version>
<modules>
<module>Core</module>
<module>NMS</module>
@ -26,7 +26,7 @@
<dependency>
<groupId>su.nexmedia</groupId>
<artifactId>NexEngine</artifactId>
<version>2.2.7</version>
<version>2.2.8</version>
</dependency>
</dependencies>