From daa3e40c652d2fc2867e42ebd736e1edc336ba0e Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 28 Nov 2023 17:33:45 +0500 Subject: [PATCH] v3.6.4 --- Core/pom.xml | 12 +++++----- .../excellentenchants/Placeholders.java | 4 ++-- .../enchantment/config/EnchantDefaults.java | 20 ++++++++++++++++ .../enchantment/impl/ExcellentEnchant.java | 4 ++++ .../impl/armor/RegrowthEnchant.java | 2 +- .../impl/armor/SaturationEnchant.java | 2 +- .../impl/universal/SoulboundEnchant.java | 2 +- .../listener/EnchantAnvilListener.java | 2 +- .../listener/EnchantGenericListener.java | 24 +++++++++---------- .../menu/EnchantmentsListMenu.java | 2 +- .../enchantment/type/FitItemType.java | 2 +- NMS/pom.xml | 2 +- V1_18_R2/pom.xml | 4 ++-- V1_19_R3/pom.xml | 4 ++-- V1_20_R1/pom.xml | 4 ++-- V1_20_R2/pom.xml | 4 ++-- pom.xml | 2 +- 17 files changed, 60 insertions(+), 36 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 23e546e..8b8b0ca 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.3 + 3.6.4 4.0.0 @@ -72,27 +72,27 @@ su.nightexpress.excellentenchants NMS - 3.6.3 + 3.6.4 su.nightexpress.excellentenchants V1_18_R2 - 3.6.3 + 3.6.4 su.nightexpress.excellentenchants V1_19_R3 - 3.6.3 + 3.6.4 su.nightexpress.excellentenchants V1_20_R1 - 3.6.3 + 3.6.4 su.nightexpress.excellentenchants V1_20_R2 - 3.6.3 + 3.6.4 diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java index 6a45e4a..dcb3bc0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java @@ -8,8 +8,8 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders { public static final String URL_ENGINE_ITEMS = "https://github.com/nulli0n/NexEngine-spigot/wiki/Configuration-Tips#item-sections"; public static final String GENERIC_TYPE = "%type%"; - public static final String GENERIC_ITEM = "%item%"; - public static final String GENERIC_LEVEL = "%level%"; + public static final String GENERIC_ITEM = "%item%"; + public static final String GENERIC_LEVEL = "%level%"; public static final String GENERIC_AMOUNT = "%amount%"; public static final String GENERIC_DESCRIPTION = "%description%"; public static final String GENERIC_ENCHANT = "%enchant%"; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java index c7be3ac..fe4bcfb 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java @@ -31,6 +31,7 @@ public class EnchantDefaults { private boolean isTreasure; private int levelMin; private int levelMax; + private int maxMergeLevel; private EnchantScaler levelByEnchantCost; private EnchantScaler anvilMergeCost; private Set conflicts; @@ -51,6 +52,7 @@ public class EnchantDefaults { this.setTreasure(false); this.setLevelMin(1); this.setLevelMax(3); + this.setMaxMergeLevel(-1); this.setConflicts(new HashSet<>()); this.setVisualEffects(true); this.obtainChance = new HashMap<>(); @@ -89,6 +91,11 @@ public class EnchantDefaults { "Note: While you can 'bypass' this value by enchant commands, all level-dependant enchantment", "settings will have a limit up to this setting.").read(cfg)); + this.setMaxMergeLevel(JOption.create("Anvil.Max_Merge_Level", this.getMaxMergeLevel(), + "Sets max. enchantment level that can be obtained by combining 2 items with this enchantment.", + "Set this to '-1' to remove merge limit and just use 'Max Level' instead." + ).read(cfg)); + this.setLevelByEnchantCost(EnchantScaler.read(enchant, ObtainType.ENCHANTING.getPathName() + ".Level_By_Exp_Cost", (int)(30D / this.levelMax) + " * " + Placeholders.ENCHANTMENT_LEVEL, "Sets how much XP levels must be used in enchanting table to obtain this enchantment.", @@ -124,14 +131,19 @@ public class EnchantDefaults { this.setChargesEnabled(JOption.create("Settings.Charges.Enabled", this.isChargesEnabled(), "When 'true' enables the Charges system for this enchantment.", "When enchanted the first time on enchanting table, it will have maximum charges amount.").read(cfg)); + this.setChargesCustomFuel(JOption.create("Settings.Charges.Custom_Fuel", this.isChargesCustomFuel(), "When 'true' uses different (non-default) fuel item (from the 'Fuel_Item' setting) to recharge.").read(cfg)); + this.setChargesMax(EnchantScaler.read(enchant, "Settings.Charges.Maximum", "100", "Maximum amount of charges for the enchantment.")); + this.setChargesConsumeAmount(EnchantScaler.read(enchant, "Settings.Charges.Consume_Amount", "1", "How many charges will be consumed when enchantment is triggered?")); + this.setChargesRechargeAmount(EnchantScaler.read(enchant, "Settings.Charges.Recharge_Amount", "25", "How many charges will be restored when using 'Fuel Item' in anvil?")); + this.setChargesFuel(JOption.create("Settings.Charges.Fuel_Item", new ItemStack(Material.LAPIS_LAZULI), "An item, that will be used to restore enchantment charges on anvils.", "Item Options:" + Placeholders.URL_ENGINE_ITEMS) @@ -206,6 +218,14 @@ public class EnchantDefaults { return levelMax; } + public int getMaxMergeLevel() { + return this.maxMergeLevel; + } + + public void setMaxMergeLevel(int maxMergeLevel) { + this.maxMergeLevel = Math.min(this.getLevelMax(), maxMergeLevel); + } + @NotNull public EnchantScaler getLevelByEnchantCost() { return levelByEnchantCost; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index 54d1ec8..9db2208 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -222,6 +222,10 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme return this.getDefaults().getLevelMin(); } + public int getMaxMergeLevel() { + return this.getDefaults().getMaxMergeLevel() < 0 ? this.getMaxLevel() : this.getDefaults().getMaxMergeLevel(); + } + public int getLevelByEnchantCost(int expLevel) { int get = this.getDefaults().getLevelByEnchantCost().getValues().entrySet().stream() .filter(en -> expLevel >= en.getValue().intValue()).max(Comparator.comparingInt(Map.Entry::getKey)) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java index 87c9d38..de154b6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java @@ -35,7 +35,7 @@ public class RegrowthEnchant extends ExcellentEnchant implements Chanced, Passiv public RegrowthEnchant(@NotNull ExcellentEnchants plugin) { super(plugin, ID); - this.getDefaults().setDescription("Restores " + PLACEHOLDER_HEAL_AMOUNT + " hearts every " + Placeholders.ENCHANTMENT_INTERVAL + "s."); + this.getDefaults().setDescription("Restores " + PLACEHOLDER_HEAL_AMOUNT + " hearts every few seconds."); this.getDefaults().setLevelMax(5); this.getDefaults().setTier(0.7); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java index c9f42dd..b252295 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java @@ -27,7 +27,7 @@ public class SaturationEnchant extends ExcellentEnchant implements PassiveEnchan public SaturationEnchant(@NotNull ExcellentEnchants plugin) { super(plugin, ID); - this.getDefaults().setDescription("Restores " + PLACEHOLDER_SATURATION_AMOUNT + " food points every " + Placeholders.ENCHANTMENT_INTERVAL + "s."); + this.getDefaults().setDescription("Restores " + PLACEHOLDER_SATURATION_AMOUNT + " food points every few seconds."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.5); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java index 9fd8704..4f3dec1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java @@ -33,7 +33,7 @@ public class SoulboundEnchant extends ExcellentEnchant implements GenericEnchant @NotNull @Override public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.BREAKABLE; + return EnchantmentTarget.WEARABLE; } @EventHandler 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 997a83b..6e83676 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 @@ -109,7 +109,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()) { EnchantUtils.getExcellents(second).forEach((enchant, level) -> { - enchantments.merge(enchant, level, (oldLvl, newLvl) -> (oldLvl.equals(newLvl)) ? (Math.min(enchant.getMaxLevel(), oldLvl + 1)) : (Math.max(oldLvl, newLvl))); + enchantments.merge(enchant, level, (oldLvl, newLvl) -> (oldLvl.equals(newLvl)) ? (Math.min(enchant.getMaxMergeLevel(), oldLvl + 1)) : (Math.max(oldLvl, newLvl))); charges.merge(enchant, enchant.getCharges(second), Integer::sum); }); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantGenericListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantGenericListener.java index ea1f043..4202091 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantGenericListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantGenericListener.java @@ -150,26 +150,26 @@ public class EnchantGenericListener extends AbstractListener // --------------------------------------------------------------- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEnchantPopulateVillagerAcquire(VillagerAcquireTradeEvent event) { - MerchantRecipe recipe = event.getRecipe(); - ItemStack result = recipe.getResult(); + MerchantRecipe origin = event.getRecipe(); + ItemStack result = origin.getResult(); if (!EnchantUtils.isEnchantable(result)) return; EnchantPopulator populator = this.plugin.createPopulator(result, ObtainType.VILLAGER) .withWorld(event.getEntity().getWorld()); if (!populator.populate()) return; - int uses = recipe.getUses(); - int maxUses = recipe.getMaxUses(); - boolean expReward = recipe.hasExperienceReward(); - int villagerExperience = recipe.getVillagerExperience(); - float priceMultiplier = recipe.getPriceMultiplier(); - int demand = recipe.getDemand(); - int specialPrice = recipe.getSpecialPrice(); + int uses = origin.getUses(); + int maxUses = origin.getMaxUses(); + boolean expReward = origin.hasExperienceReward(); + int villagerExperience = origin.getVillagerExperience(); + float priceMultiplier = origin.getPriceMultiplier(); + int demand = origin.getDemand(); + int specialPrice = origin.getSpecialPrice(); - MerchantRecipe recipe2 = new MerchantRecipe(result, uses, maxUses, expReward, villagerExperience, + MerchantRecipe recipe = new MerchantRecipe(result, uses, maxUses, expReward, villagerExperience, priceMultiplier, demand, specialPrice); - recipe2.setIngredients(recipe.getIngredients()); - event.setRecipe(recipe2); + recipe.setIngredients(origin.getIngredients()); + event.setRecipe(recipe); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) 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 7e9a649..f4a6aea 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 @@ -83,7 +83,7 @@ public class EnchantmentsListMenu extends ConfigMenu implemen public List getObjects(@NotNull Player player) { return new ArrayList<>(EnchantRegistry.getRegistered().stream() .filter(Predicate.not(enchant -> enchant.getDefaults().isHiddenFromList())) - .sorted(Comparator.comparing(e -> Colorizer.strip(e.getDisplayName()))).toList()); + .sorted(Comparator.comparing(e -> Colorizer.restrip(e.getDisplayName()))).toList()); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java index ef32ade..392e94c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java @@ -36,7 +36,7 @@ public enum FitItemType { public boolean isIncluded(@NotNull ItemStack item) { return switch (this) { - case UNIVERSAL -> ARMOR.isIncluded(item) || WEAPON.isIncluded(item) || TOOL.isIncluded(item); + case UNIVERSAL -> ARMOR.isIncluded(item) || WEAPON.isIncluded(item) || TOOL.isIncluded(item) || BOW.isIncluded(item) || FISHING_ROD.isIncluded(item) || ELYTRA.isIncluded(item); case HELMET -> ItemUtil.isHelmet(item); case CHESTPLATE -> ItemUtil.isChestplate(item) || (Config.ENCHANTMENTS_ITEM_CHESTPLATE_ENCHANTS_TO_ELYTRA.get() && ELYTRA.isIncluded(item)); case LEGGINGS -> ItemUtil.isLeggings(item); diff --git a/NMS/pom.xml b/NMS/pom.xml index d4be4ab..997ff63 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.3 + 3.6.4 4.0.0 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index c3cf53a..4c5b33e 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.3 + 3.6.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.3 + 3.6.4 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 6a56530..c3bf3c0 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.3 + 3.6.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.3 + 3.6.4 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index b578b14..ba89518 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.3 + 3.6.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.3 + 3.6.4 diff --git a/V1_20_R2/pom.xml b/V1_20_R2/pom.xml index 62dcce1..d889b3b 100644 --- a/V1_20_R2/pom.xml +++ b/V1_20_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.3 + 3.6.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.3 + 3.6.4 diff --git a/pom.xml b/pom.xml index f61087e..33d0148 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.6.3 + 3.6.4 Core NMS