This commit is contained in:
BuildTools 2023-11-28 17:33:45 +05:00
parent e5efd3c199
commit daa3e40c65
17 changed files with 60 additions and 36 deletions

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>3.6.3</version> <version>3.6.4</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -72,27 +72,27 @@
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId> <artifactId>NMS</artifactId>
<version>3.6.3</version> <version>3.6.4</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.6.3</version> <version>3.6.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_19_R3</artifactId> <artifactId>V1_19_R3</artifactId>
<version>3.6.3</version> <version>3.6.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_20_R1</artifactId> <artifactId>V1_20_R1</artifactId>
<version>3.6.3</version> <version>3.6.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_20_R2</artifactId> <artifactId>V1_20_R2</artifactId>
<version>3.6.3</version> <version>3.6.4</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -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 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_TYPE = "%type%";
public static final String GENERIC_ITEM = "%item%"; public static final String GENERIC_ITEM = "%item%";
public static final String GENERIC_LEVEL = "%level%"; public static final String GENERIC_LEVEL = "%level%";
public static final String GENERIC_AMOUNT = "%amount%"; public static final String GENERIC_AMOUNT = "%amount%";
public static final String GENERIC_DESCRIPTION = "%description%"; public static final String GENERIC_DESCRIPTION = "%description%";
public static final String GENERIC_ENCHANT = "%enchant%"; public static final String GENERIC_ENCHANT = "%enchant%";

View File

@ -31,6 +31,7 @@ public class EnchantDefaults {
private boolean isTreasure; private boolean isTreasure;
private int levelMin; private int levelMin;
private int levelMax; private int levelMax;
private int maxMergeLevel;
private EnchantScaler levelByEnchantCost; private EnchantScaler levelByEnchantCost;
private EnchantScaler anvilMergeCost; private EnchantScaler anvilMergeCost;
private Set<String> conflicts; private Set<String> conflicts;
@ -51,6 +52,7 @@ public class EnchantDefaults {
this.setTreasure(false); this.setTreasure(false);
this.setLevelMin(1); this.setLevelMin(1);
this.setLevelMax(3); this.setLevelMax(3);
this.setMaxMergeLevel(-1);
this.setConflicts(new HashSet<>()); this.setConflicts(new HashSet<>());
this.setVisualEffects(true); this.setVisualEffects(true);
this.obtainChance = new HashMap<>(); 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", "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)); "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", this.setLevelByEnchantCost(EnchantScaler.read(enchant, ObtainType.ENCHANTING.getPathName() + ".Level_By_Exp_Cost",
(int)(30D / this.levelMax) + " * " + Placeholders.ENCHANTMENT_LEVEL, (int)(30D / this.levelMax) + " * " + Placeholders.ENCHANTMENT_LEVEL,
"Sets how much XP levels must be used in enchanting table to obtain this enchantment.", "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(), this.setChargesEnabled(JOption.create("Settings.Charges.Enabled", this.isChargesEnabled(),
"When 'true' enables the Charges system for this enchantment.", "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)); "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(), 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)); "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", this.setChargesMax(EnchantScaler.read(enchant, "Settings.Charges.Maximum", "100",
"Maximum amount of charges for the enchantment.")); "Maximum amount of charges for the enchantment."));
this.setChargesConsumeAmount(EnchantScaler.read(enchant, "Settings.Charges.Consume_Amount", "1", this.setChargesConsumeAmount(EnchantScaler.read(enchant, "Settings.Charges.Consume_Amount", "1",
"How many charges will be consumed when enchantment is triggered?")); "How many charges will be consumed when enchantment is triggered?"));
this.setChargesRechargeAmount(EnchantScaler.read(enchant, "Settings.Charges.Recharge_Amount", "25", this.setChargesRechargeAmount(EnchantScaler.read(enchant, "Settings.Charges.Recharge_Amount", "25",
"How many charges will be restored when using 'Fuel Item' in anvil?")); "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), 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.", "An item, that will be used to restore enchantment charges on anvils.",
"Item Options:" + Placeholders.URL_ENGINE_ITEMS) "Item Options:" + Placeholders.URL_ENGINE_ITEMS)
@ -206,6 +218,14 @@ public class EnchantDefaults {
return levelMax; return levelMax;
} }
public int getMaxMergeLevel() {
return this.maxMergeLevel;
}
public void setMaxMergeLevel(int maxMergeLevel) {
this.maxMergeLevel = Math.min(this.getLevelMax(), maxMergeLevel);
}
@NotNull @NotNull
public EnchantScaler getLevelByEnchantCost() { public EnchantScaler getLevelByEnchantCost() {
return levelByEnchantCost; return levelByEnchantCost;

View File

@ -222,6 +222,10 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme
return this.getDefaults().getLevelMin(); return this.getDefaults().getLevelMin();
} }
public int getMaxMergeLevel() {
return this.getDefaults().getMaxMergeLevel() < 0 ? this.getMaxLevel() : this.getDefaults().getMaxMergeLevel();
}
public int getLevelByEnchantCost(int expLevel) { public int getLevelByEnchantCost(int expLevel) {
int get = this.getDefaults().getLevelByEnchantCost().getValues().entrySet().stream() int get = this.getDefaults().getLevelByEnchantCost().getValues().entrySet().stream()
.filter(en -> expLevel >= en.getValue().intValue()).max(Comparator.comparingInt(Map.Entry::getKey)) .filter(en -> expLevel >= en.getValue().intValue()).max(Comparator.comparingInt(Map.Entry::getKey))

View File

@ -35,7 +35,7 @@ public class RegrowthEnchant extends ExcellentEnchant implements Chanced, Passiv
public RegrowthEnchant(@NotNull ExcellentEnchants plugin) { public RegrowthEnchant(@NotNull ExcellentEnchants plugin) {
super(plugin, ID); 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().setLevelMax(5);
this.getDefaults().setTier(0.7); this.getDefaults().setTier(0.7);
} }

View File

@ -27,7 +27,7 @@ public class SaturationEnchant extends ExcellentEnchant implements PassiveEnchan
public SaturationEnchant(@NotNull ExcellentEnchants plugin) { public SaturationEnchant(@NotNull ExcellentEnchants plugin) {
super(plugin, ID); 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().setLevelMax(3);
this.getDefaults().setTier(0.5); this.getDefaults().setTier(0.5);
} }

View File

@ -33,7 +33,7 @@ public class SoulboundEnchant extends ExcellentEnchant implements GenericEnchant
@NotNull @NotNull
@Override @Override
public EnchantmentTarget getItemTarget() { public EnchantmentTarget getItemTarget() {
return EnchantmentTarget.BREAKABLE; return EnchantmentTarget.WEARABLE;
} }
@EventHandler @EventHandler

View File

@ -109,7 +109,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()) {
EnchantUtils.getExcellents(second).forEach((enchant, level) -> { 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); charges.merge(enchant, enchant.getCharges(second), Integer::sum);
}); });
} }

View File

@ -150,26 +150,26 @@ public class EnchantGenericListener extends AbstractListener<ExcellentEnchants>
// --------------------------------------------------------------- // ---------------------------------------------------------------
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEnchantPopulateVillagerAcquire(VillagerAcquireTradeEvent event) { public void onEnchantPopulateVillagerAcquire(VillagerAcquireTradeEvent event) {
MerchantRecipe recipe = event.getRecipe(); MerchantRecipe origin = event.getRecipe();
ItemStack result = recipe.getResult(); ItemStack result = origin.getResult();
if (!EnchantUtils.isEnchantable(result)) return; if (!EnchantUtils.isEnchantable(result)) return;
EnchantPopulator populator = this.plugin.createPopulator(result, ObtainType.VILLAGER) EnchantPopulator populator = this.plugin.createPopulator(result, ObtainType.VILLAGER)
.withWorld(event.getEntity().getWorld()); .withWorld(event.getEntity().getWorld());
if (!populator.populate()) return; if (!populator.populate()) return;
int uses = recipe.getUses(); int uses = origin.getUses();
int maxUses = recipe.getMaxUses(); int maxUses = origin.getMaxUses();
boolean expReward = recipe.hasExperienceReward(); boolean expReward = origin.hasExperienceReward();
int villagerExperience = recipe.getVillagerExperience(); int villagerExperience = origin.getVillagerExperience();
float priceMultiplier = recipe.getPriceMultiplier(); float priceMultiplier = origin.getPriceMultiplier();
int demand = recipe.getDemand(); int demand = origin.getDemand();
int specialPrice = recipe.getSpecialPrice(); 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); priceMultiplier, demand, specialPrice);
recipe2.setIngredients(recipe.getIngredients()); recipe.setIngredients(origin.getIngredients());
event.setRecipe(recipe2); event.setRecipe(recipe);
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View File

@ -83,7 +83,7 @@ public class EnchantmentsListMenu extends ConfigMenu<ExcellentEnchants> implemen
public List<ExcellentEnchant> getObjects(@NotNull Player player) { public List<ExcellentEnchant> getObjects(@NotNull Player player) {
return new ArrayList<>(EnchantRegistry.getRegistered().stream() return new ArrayList<>(EnchantRegistry.getRegistered().stream()
.filter(Predicate.not(enchant -> enchant.getDefaults().isHiddenFromList())) .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 @Override

View File

@ -36,7 +36,7 @@ public enum FitItemType {
public boolean isIncluded(@NotNull ItemStack item) { public boolean isIncluded(@NotNull ItemStack item) {
return switch (this) { 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 HELMET -> ItemUtil.isHelmet(item);
case CHESTPLATE -> ItemUtil.isChestplate(item) || (Config.ENCHANTMENTS_ITEM_CHESTPLATE_ENCHANTS_TO_ELYTRA.get() && ELYTRA.isIncluded(item)); case CHESTPLATE -> ItemUtil.isChestplate(item) || (Config.ENCHANTMENTS_ITEM_CHESTPLATE_ENCHANTS_TO_ELYTRA.get() && ELYTRA.isIncluded(item));
case LEGGINGS -> ItemUtil.isLeggings(item); case LEGGINGS -> ItemUtil.isLeggings(item);

View File

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

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>3.6.3</version> <version>3.6.4</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.6.3</version> <version>3.6.4</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>3.6.3</version> <version>3.6.4</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.6.3</version> <version>3.6.4</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>3.6.3</version> <version>3.6.4</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.6.3</version> <version>3.6.4</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>3.6.3</version> <version>3.6.4</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.6.3</version> <version>3.6.4</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -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.6.3</version> <version>3.6.4</version>
<modules> <modules>
<module>Core</module> <module>Core</module>
<module>NMS</module> <module>NMS</module>