From 9c2d0911f1600d9a0b6e321d73e330aae746fe9d Mon Sep 17 00:00:00 2001 From: nulli0n Date: Thu, 11 May 2023 17:59:23 +0600 Subject: [PATCH] v3.3.4 --- Core/pom.xml | 71 ++-- .../excellentenchants/ExcellentEnchants.java | 9 +- .../excellentenchants/Placeholders.java | 9 +- .../api/enchantment/IEnchantment.java | 2 +- .../api/enchantment/meta/Arrowed.java | 9 +- .../enchantment/template/PotionEnchant.java | 36 -- .../enchantment/type/BlockDropEnchant.java | 2 +- .../command/BookCommand.java | 38 +- .../command/EnchantCommand.java | 39 +- .../command/ListCommand.java | 24 +- .../command/TierbookCommand.java | 45 +-- .../excellentenchants/config/Config.java | 12 +- .../excellentenchants/config/Lang.java | 24 +- .../enchantment/EnchantManager.java | 343 +---------------- .../enchantment/EnchantPopulator.java | 18 +- ...hantRegister.java => EnchantRegistry.java} | 50 ++- .../enchantment/config/EnchantDefaults.java | 296 +++++++++++++++ .../enchantment/config/EnchantScaler.java | 2 +- .../impl}/ExcellentEnchant.java | 193 +++------- .../impl/armor/EnchantAquaman.java | 28 +- .../impl/armor/EnchantBunnyHop.java | 28 +- .../impl/armor/EnchantColdSteel.java | 29 +- .../armor/EnchantElementalProtection.java | 16 +- .../impl/armor/EnchantFireShield.java | 13 +- .../impl/armor/EnchantFlameWalker.java | 22 +- .../impl/armor/EnchantHardened.java | 28 +- .../impl/armor/EnchantIceShield.java | 31 +- .../impl/armor/EnchantNightVision.java | 28 +- .../impl/armor/EnchantRegrowth.java | 20 +- .../impl/armor/EnchantSaturation.java | 11 +- .../impl/armor/EnchantSelfDestruction.java | 13 +- .../enchantment/impl/armor/EnchantSonic.java | 28 +- .../enchantment/impl/bow/EnchantBomber.java | 23 +- .../impl/bow/EnchantConfusingArrows.java | 36 +- .../impl/bow/EnchantDragonfireArrows.java | 25 +- .../impl/bow/EnchantElectrifiedArrows.java | 27 +- .../enchantment/impl/bow/EnchantEnderBow.java | 20 +- .../impl/bow/EnchantExplosiveArrows.java | 23 +- .../enchantment/impl/bow/EnchantGhast.java | 23 +- .../enchantment/impl/bow/EnchantHover.java | 36 +- .../impl/bow/EnchantPoisonedArrows.java | 37 +- .../impl/bow/EnchantWitheredArrows.java | 37 +- .../impl/fishing/SpeedFishingEnchant.java | 5 + .../impl/meta/ArrowImplementation.java | 47 +-- .../impl/meta/ChanceImplementation.java | 11 +- .../impl/meta/PotionImplementation.java | 31 +- .../impl/tool/EnchantBlastMining.java | 25 +- .../impl/tool/EnchantCurseOfBreaking.java | 17 +- .../impl/tool/EnchantCurseOfMisfortune.java | 16 +- .../impl/tool/EnchantDivineTouch.java | 20 +- .../enchantment/impl/tool/EnchantHaste.java | 28 +- .../impl/tool/EnchantLuckyMiner.java | 13 +- .../impl/tool/EnchantReplanter.java | 9 +- .../impl/tool/EnchantSilkChest.java | 10 +- .../enchantment/impl/tool/EnchantSmelter.java | 52 +-- .../impl/tool/EnchantTelekinesis.java | 11 +- .../impl/tool/EnchantTreasures.java | 55 ++- .../enchantment/impl/tool/EnchantTunnel.java | 24 +- .../impl/tool/EnchantVeinminer.java | 49 ++- .../universal/EnchantCurseOfFragility.java | 17 +- .../impl/weapon/EnchantBaneOfNetherspawn.java | 14 +- .../impl/weapon/EnchantBlindness.java | 31 +- .../impl/weapon/EnchantConfusion.java | 32 +- .../enchantment/impl/weapon/EnchantCure.java | 15 +- .../impl/weapon/EnchantCutter.java | 19 +- .../impl/weapon/EnchantDecapitator.java | 123 +++++- .../impl/weapon/EnchantDoubleStrike.java | 15 +- .../impl/weapon/EnchantExhaust.java | 32 +- .../impl/weapon/EnchantExpHunter.java | 10 +- .../impl/weapon/EnchantIceAspect.java | 45 ++- .../impl/weapon/EnchantInfernus.java | 16 +- .../impl/weapon/EnchantNimble.java | 7 +- .../impl/weapon/EnchantParalyze.java | 31 +- .../enchantment/impl/weapon/EnchantRage.java | 31 +- .../impl/weapon/EnchantRocket.java | 44 ++- .../impl/weapon/EnchantScavenger.java | 28 +- .../impl/weapon/EnchantSurprise.java | 27 +- .../impl/weapon/EnchantTemper.java | 10 +- .../impl/weapon/EnchantThrifty.java | 18 +- .../impl/weapon/EnchantThunder.java | 11 +- .../impl/weapon/EnchantVampire.java | 19 +- .../enchantment/impl/weapon/EnchantVenom.java | 31 +- .../impl/weapon/EnchantVillageDefender.java | 13 +- .../impl/weapon/EnchantWither.java | 30 +- .../listener/EnchantAnvilListener.java | 34 +- .../listener/EnchantGenericListener.java | 39 +- .../listener/EnchantHandlerListener.java | 25 +- .../menu/EnchantmentsListMenu.java | 77 ++-- .../task/AbstractEnchantmentTask.java | 2 +- .../enchantment/task/ArrowTrailsTask.java | 19 +- .../enchantment/task/PotionEffectsTask.java | 4 +- .../util/EnchantDropContainer.java | 2 +- .../enchantment/util/EnchantPriority.java | 2 +- .../enchantment/util/EnchantUtils.java | 359 ++++++++++++++++++ .../excellentenchants/hook/HookId.java | 1 + .../hook/impl/MythicMobsHook.java | 14 + .../hook/impl/PlaceholderHook.java | 8 +- .../hook/impl/ProtocolHook.java | 8 +- .../excellentenchants/tier/Tier.java | 55 +-- .../excellentenchants/tier/TierManager.java | 26 +- Core/src/main/resources/config.yml | 4 +- Core/src/main/resources/enchants/aquaman.yml | 8 - .../enchants/bane_of_netherspawn.yml | 12 - .../main/resources/enchants/blast_mining.yml | 12 - .../src/main/resources/enchants/blindness.yml | 13 - Core/src/main/resources/enchants/bomber.yml | 22 -- .../src/main/resources/enchants/bunny_hop.yml | 8 - .../main/resources/enchants/cold_steel.yml | 13 - .../resources/enchants/confusing_arrows.yml | 22 -- .../src/main/resources/enchants/confusion.yml | 13 - Core/src/main/resources/enchants/cure.yml | 10 - .../resources/enchants/curse_of_breaking.yml | 12 - .../resources/enchants/curse_of_fragility.yml | 7 - .../enchants/curse_of_misfortune.yml | 12 - Core/src/main/resources/enchants/cutter.yml | 10 - .../main/resources/enchants/decapitator.yml | 82 ---- .../main/resources/enchants/divine_touch.yml | 11 - .../main/resources/enchants/double_strike.yml | 10 - .../resources/enchants/dragonfire_arrows.yml | 23 -- .../resources/enchants/electrified_arrows.yml | 23 -- .../enchants/elemental_protection.yml | 8 - .../src/main/resources/enchants/ender_bow.yml | 20 - Core/src/main/resources/enchants/exhaust.yml | 13 - .../main/resources/enchants/exp_hunter.yml | 10 - .../resources/enchants/explosive_arrows.yml | 23 -- .../main/resources/enchants/fire_shield.yml | 10 - .../main/resources/enchants/flame_walker.yml | 9 - Core/src/main/resources/enchants/ghast.yml | 20 - Core/src/main/resources/enchants/hardened.yml | 12 - Core/src/main/resources/enchants/haste.yml | 8 - Core/src/main/resources/enchants/hover.yml | 22 -- .../main/resources/enchants/ice_aspect.yml | 12 - .../main/resources/enchants/ice_shield.yml | 13 - Core/src/main/resources/enchants/infernus.yml | 10 - .../main/resources/enchants/lucky_miner.yml | 10 - .../main/resources/enchants/night_vision.yml | 7 - Core/src/main/resources/enchants/nimble.yml | 7 - Core/src/main/resources/enchants/paralyze.yml | 13 - .../resources/enchants/poisoned_arrows.yml | 22 -- Core/src/main/resources/enchants/rage.yml | 13 - Core/src/main/resources/enchants/regrowth.yml | 10 - .../src/main/resources/enchants/replanter.yml | 7 - Core/src/main/resources/enchants/rocket.yml | 10 - .../main/resources/enchants/saturation.yml | 8 - .../src/main/resources/enchants/scavenger.yml | 22 -- .../resources/enchants/self_destruction.yml | 11 - .../main/resources/enchants/silk_chest.yml | 8 - Core/src/main/resources/enchants/smelter.yml | 17 - Core/src/main/resources/enchants/sonic.yml | 8 - Core/src/main/resources/enchants/surprise.yml | 12 - .../main/resources/enchants/telekinesis.yml | 8 - Core/src/main/resources/enchants/temper.yml | 8 - Core/src/main/resources/enchants/thrifty.yml | 10 - Core/src/main/resources/enchants/thunder.yml | 9 - .../src/main/resources/enchants/treasures.yml | 33 -- Core/src/main/resources/enchants/tunnel.yml | 10 - Core/src/main/resources/enchants/vampire.yml | 10 - .../src/main/resources/enchants/veinminer.yml | 32 -- Core/src/main/resources/enchants/venom.yml | 13 - .../resources/enchants/village_defender.yml | 12 - Core/src/main/resources/enchants/wither.yml | 13 - .../resources/enchants/withered_arrows.yml | 22 -- .../src/main/resources/menu/enchants_list.yml | 1 + NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 +- V1_18_R2/pom.xml | 4 +- V1_19_R1/pom.xml | 4 +- V1_19_R2/pom.xml | 4 +- V1_19_R3/pom.xml | 4 +- pom.xml | 4 +- 170 files changed, 2298 insertions(+), 2182 deletions(-) delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/template/PotionEnchant.java rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/{EnchantRegister.java => EnchantRegistry.java} (91%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java rename Core/src/main/java/su/nightexpress/excellentenchants/{api/enchantment => enchantment/impl}/ExcellentEnchant.java (53%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SpeedFishingEnchant.java rename Core/src/main/java/su/nightexpress/excellentenchants/{api => }/enchantment/util/EnchantDropContainer.java (90%) rename Core/src/main/java/su/nightexpress/excellentenchants/{api => }/enchantment/util/EnchantPriority.java (53%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/MythicMobsHook.java delete mode 100644 Core/src/main/resources/enchants/aquaman.yml delete mode 100644 Core/src/main/resources/enchants/bane_of_netherspawn.yml delete mode 100644 Core/src/main/resources/enchants/blast_mining.yml delete mode 100644 Core/src/main/resources/enchants/blindness.yml delete mode 100644 Core/src/main/resources/enchants/bomber.yml delete mode 100644 Core/src/main/resources/enchants/bunny_hop.yml delete mode 100644 Core/src/main/resources/enchants/cold_steel.yml delete mode 100644 Core/src/main/resources/enchants/confusing_arrows.yml delete mode 100644 Core/src/main/resources/enchants/confusion.yml delete mode 100644 Core/src/main/resources/enchants/cure.yml delete mode 100644 Core/src/main/resources/enchants/curse_of_breaking.yml delete mode 100644 Core/src/main/resources/enchants/curse_of_fragility.yml delete mode 100644 Core/src/main/resources/enchants/curse_of_misfortune.yml delete mode 100644 Core/src/main/resources/enchants/cutter.yml delete mode 100644 Core/src/main/resources/enchants/decapitator.yml delete mode 100644 Core/src/main/resources/enchants/divine_touch.yml delete mode 100644 Core/src/main/resources/enchants/double_strike.yml delete mode 100644 Core/src/main/resources/enchants/dragonfire_arrows.yml delete mode 100644 Core/src/main/resources/enchants/electrified_arrows.yml delete mode 100644 Core/src/main/resources/enchants/elemental_protection.yml delete mode 100644 Core/src/main/resources/enchants/ender_bow.yml delete mode 100644 Core/src/main/resources/enchants/exhaust.yml delete mode 100644 Core/src/main/resources/enchants/exp_hunter.yml delete mode 100644 Core/src/main/resources/enchants/explosive_arrows.yml delete mode 100644 Core/src/main/resources/enchants/fire_shield.yml delete mode 100644 Core/src/main/resources/enchants/flame_walker.yml delete mode 100644 Core/src/main/resources/enchants/ghast.yml delete mode 100644 Core/src/main/resources/enchants/hardened.yml delete mode 100644 Core/src/main/resources/enchants/haste.yml delete mode 100644 Core/src/main/resources/enchants/hover.yml delete mode 100644 Core/src/main/resources/enchants/ice_aspect.yml delete mode 100644 Core/src/main/resources/enchants/ice_shield.yml delete mode 100644 Core/src/main/resources/enchants/infernus.yml delete mode 100644 Core/src/main/resources/enchants/lucky_miner.yml delete mode 100644 Core/src/main/resources/enchants/night_vision.yml delete mode 100644 Core/src/main/resources/enchants/nimble.yml delete mode 100644 Core/src/main/resources/enchants/paralyze.yml delete mode 100644 Core/src/main/resources/enchants/poisoned_arrows.yml delete mode 100644 Core/src/main/resources/enchants/rage.yml delete mode 100644 Core/src/main/resources/enchants/regrowth.yml delete mode 100644 Core/src/main/resources/enchants/replanter.yml delete mode 100644 Core/src/main/resources/enchants/rocket.yml delete mode 100644 Core/src/main/resources/enchants/saturation.yml delete mode 100644 Core/src/main/resources/enchants/scavenger.yml delete mode 100644 Core/src/main/resources/enchants/self_destruction.yml delete mode 100644 Core/src/main/resources/enchants/silk_chest.yml delete mode 100644 Core/src/main/resources/enchants/smelter.yml delete mode 100644 Core/src/main/resources/enchants/sonic.yml delete mode 100644 Core/src/main/resources/enchants/surprise.yml delete mode 100644 Core/src/main/resources/enchants/telekinesis.yml delete mode 100644 Core/src/main/resources/enchants/temper.yml delete mode 100644 Core/src/main/resources/enchants/thrifty.yml delete mode 100644 Core/src/main/resources/enchants/thunder.yml delete mode 100644 Core/src/main/resources/enchants/treasures.yml delete mode 100644 Core/src/main/resources/enchants/tunnel.yml delete mode 100644 Core/src/main/resources/enchants/vampire.yml delete mode 100644 Core/src/main/resources/enchants/veinminer.yml delete mode 100644 Core/src/main/resources/enchants/venom.yml delete mode 100644 Core/src/main/resources/enchants/village_defender.yml delete mode 100644 Core/src/main/resources/enchants/wither.yml delete mode 100644 Core/src/main/resources/enchants/withered_arrows.yml diff --git a/Core/pom.xml b/Core/pom.xml index a3238c8..60fd057 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.3 + 3.3.4 4.0.0 @@ -38,6 +38,23 @@ placeholderapi https://repo.extendedclip.com/content/repositories/placeholderapi/ + + false + + + + lumine-repo + https://mvn.lumine.io/repository/maven-public/ + + false + + + + lumine-snapshot + http://mvn.lumine.io/repository/maven-snapshots/ + + false + @@ -45,7 +62,7 @@ org.spigotmc spigot-api - 1.19.3-R0.1-SNAPSHOT + 1.19.4-R0.1-SNAPSHOT su.nexmedia.playerblocktracker @@ -55,32 +72,32 @@ su.nightexpress.excellentenchants NMS - 3.3.3 - - - su.nightexpress.excellentenchants - V1_17_R1 - 3.3.3 - - - su.nightexpress.excellentenchants - V1_18_R2 - 3.3.3 - - - su.nightexpress.excellentenchants - V1_19_R1 - 3.3.3 - - - su.nightexpress.excellentenchants - V1_19_R2 - 3.3.3 + 3.3.4 su.nightexpress.excellentenchants V1_19_R3 - 3.3.3 + 3.3.4 + + + su.nightexpress.excellentenchants + V1_19_R2 + 3.3.4 + + + su.nightexpress.excellentenchants + V1_19_R1 + 3.3.4 + + + su.nightexpress.excellentenchants + V1_18_R2 + 3.3.4 + + + su.nightexpress.excellentenchants + V1_17_R1 + 3.3.4 fr.neatmonster @@ -89,9 +106,9 @@ provided - com.sk89q.worldguard - worldguard-bukkit - 7.0.6 + io.lumine + Mythic-Dist + 5.0.1-SNAPSHOT provided diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 1e39860..949eaeb 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -41,11 +41,7 @@ public class ExcellentEnchants extends NexPlugin { @Override public void enable() { - if (!this.setNMS()) { - this.error("Could not setup internal NMS handler!"); - this.getPluginManager().disablePlugin(this); - return; - } + this.setNMS(); this.tierManager = new TierManager(this); this.tierManager.setup(); @@ -67,7 +63,7 @@ public class ExcellentEnchants extends NexPlugin { PlaceholderHook.shutdown(); } - private boolean setNMS() { + private void setNMS() { this.enchantNMS = switch (Version.CURRENT) { case V1_17_R1 -> new V1_17_R1(); case V1_18_R2 -> new V1_18_R2(); @@ -75,7 +71,6 @@ public class ExcellentEnchants extends NexPlugin { case V1_19_R2 -> new V1_19_R2(); case V1_19_R3 -> new V1_19_R3(); }; - return true; } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java index 101247d..8387f9c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java @@ -12,6 +12,11 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders { public static final String GENERIC_DESCRIPTION = "%description%"; public static final String GENERIC_ENCHANT = "%enchant%"; + public static final String ENCHANTMENT_CHANCE = "%enchantment_trigger_chance%"; + public static final String ENCHANTMENT_POTION_LEVEL = "%enchantment_potion_level%"; + public static final String ENCHANTMENT_POTION_DURATION = "%enchantment_potion_duration%"; + public static final String ENCHANTMENT_POTION_TYPE = "%enchantment_potion_type%"; + 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%"; @@ -31,5 +36,7 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders { public static final String ENCHANTMENT_CHARGES_FUEL_ITEM = "%enchantment_charges_fuel_item%"; public static final String TIER_ID = "%tier_id%"; - public static final String TIER_NAME = "%tier_name%"; + public static final String TIER_NAME = "%tier_name%"; + + } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantment.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantment.java index 962dd98..5cbdb86 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantment.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantment.java @@ -5,7 +5,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.tier.Tier; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Arrowed.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Arrowed.java index 7255e77..155e66b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Arrowed.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Arrowed.java @@ -1,8 +1,8 @@ package su.nightexpress.excellentenchants.api.enchantment.meta; -import org.bukkit.Particle; import org.bukkit.entity.Projectile; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.particle.SimpleParticle; import java.util.Optional; @@ -11,15 +11,10 @@ public interface Arrowed { @NotNull Arrowed getArrowImplementation(); @NotNull - default Optional getTrailParticle() { + default Optional getTrailParticle() { return this.getArrowImplementation().getTrailParticle(); } - @NotNull - default Optional getTrailData() { - return this.getArrowImplementation().getTrailData(); - } - default void addTrail(@NotNull Projectile projectile) { this.getArrowImplementation().addTrail(projectile); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/template/PotionEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/template/PotionEnchant.java deleted file mode 100644 index a0737a9..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/template/PotionEnchant.java +++ /dev/null @@ -1,36 +0,0 @@ -package su.nightexpress.excellentenchants.api.enchantment.template; - -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; - -public abstract class PotionEnchant extends ExcellentEnchant implements Potioned { - - private final PotionEffectType effectType; - private final boolean isPermanent; - - private PotionImplementation potionImplementation; - - public PotionEnchant(@NotNull ExcellentEnchants plugin, @NotNull String id, @NotNull EnchantPriority priority, - @NotNull PotionEffectType effectType, boolean isPermanent) { - super(plugin, id, priority); - this.effectType = effectType; - this.isPermanent = isPermanent; - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.potionImplementation = PotionImplementation.create(this, this.effectType, this.isPermanent); - } - - @Override - @NotNull - public Potioned getPotionImplementation() { - return this.potionImplementation; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockDropEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockDropEnchant.java index b45b3b8..777145d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockDropEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockDropEnchant.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantDropContainer; +import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface BlockDropEnchant extends IEnchantment { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java index 8a218a7..2843570 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java @@ -8,42 +8,26 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.command.AbstractCommand; +import su.nexmedia.engine.api.command.CommandResult; import su.nexmedia.engine.lang.LangManager; import su.nexmedia.engine.utils.CollectionsUtil; import su.nexmedia.engine.utils.PlayerUtil; -import su.nexmedia.engine.utils.StringUtil; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Perms; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.config.Lang; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.Arrays; import java.util.List; -import java.util.Map; public class BookCommand extends AbstractCommand { public BookCommand(@NotNull ExcellentEnchants plugin) { super(plugin, new String[]{"book"}, Perms.COMMAND_BOOK); - } - - @Override - @NotNull - public String getDescription() { - return plugin.getMessage(Lang.COMMAND_BOOK_DESC).getLocalized(); - } - - @Override - @NotNull - public String getUsage() { - return plugin.getMessage(Lang.COMMAND_BOOK_USAGE).getLocalized(); - } - - @Override - public boolean isPlayerOnly() { - return false; + this.setDescription(plugin.getMessage(Lang.COMMAND_BOOK_DESC)); + this.setUsage(plugin.getMessage(Lang.COMMAND_BOOK_USAGE)); } @Override @@ -62,32 +46,32 @@ public class BookCommand extends AbstractCommand { } @Override - public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args, @NotNull Map flags) { - if (args.length != 4) { + protected void onExecute(@NotNull CommandSender sender, @NotNull CommandResult result) { + if (result.length() < 4) { this.printUsage(sender); return; } - Player player = plugin.getServer().getPlayer(args[1]); + Player player = plugin.getServer().getPlayer(result.getArg(1)); if (player == null) { this.errorPlayer(sender); return; } - Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(args[2].toLowerCase())); + Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(result.getArg(2).toLowerCase())); if (enchantment == null) { plugin.getMessage(Lang.ERROR_NO_ENCHANT).send(sender); return; } - int level = StringUtil.getInteger(args[3], -1, true); + int level = result.getInt(3, -1); if (level < 1) { level = Rnd.get(enchantment.getStartLevel(), enchantment.getMaxLevel()); } ItemStack item = new ItemStack(Material.ENCHANTED_BOOK); - EnchantManager.addEnchantment(item, enchantment, level, true); - EnchantManager.updateEnchantmentsDisplay(item); + EnchantUtils.add(item, enchantment, level, true); + EnchantUtils.updateDisplay(item); PlayerUtil.addItem(player, item); plugin.getMessage(Lang.COMMAND_BOOK_DONE) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java index 531be7c..dc9e383 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java @@ -7,38 +7,23 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.command.AbstractCommand; -import su.nexmedia.engine.utils.StringUtil; +import su.nexmedia.engine.api.command.CommandResult; 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.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.Arrays; import java.util.List; -import java.util.Map; public class EnchantCommand extends AbstractCommand { public EnchantCommand(@NotNull ExcellentEnchants plugin) { super(plugin, new String[]{"enchant"}, Perms.COMMAND_ENCHANT); - } - - @Override - @NotNull - public String getDescription() { - return plugin.getMessage(Lang.COMMAND_ENCHANT_DESC).getLocalized(); - } - - @Override - @NotNull - public String getUsage() { - return plugin.getMessage(Lang.COMMAND_ENCHANT_USAGE).getLocalized(); - } - - @Override - public boolean isPlayerOnly() { - return true; + this.setDescription(plugin.getMessage(Lang.COMMAND_ENCHANT_DESC)); + this.setUsage(plugin.getMessage(Lang.COMMAND_ENCHANT_USAGE)); + this.setPlayerOnly(true); } @Override @@ -54,8 +39,8 @@ public class EnchantCommand extends AbstractCommand { } @Override - public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args, @NotNull Map flags) { - if (args.length != 3) { + protected void onExecute(@NotNull CommandSender sender, @NotNull CommandResult result) { + if (result.length() < 3) { this.printUsage(sender); return; } @@ -67,23 +52,23 @@ public class EnchantCommand extends AbstractCommand { return; } - Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(args[1].toLowerCase())); + Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(result.getArg(1).toLowerCase())); if (enchantment == null) { plugin.getMessage(Lang.ERROR_NO_ENCHANT).send(sender); return; } - int level = StringUtil.getInteger(args[2], -1, true); + int level = result.getInt(2, -1); if (level < 0) { level = Rnd.get(enchantment.getStartLevel(), enchantment.getMaxLevel()); } if (level > 0) { - EnchantManager.addEnchantment(item, enchantment, level, true); + EnchantUtils.add(item, enchantment, level, true); } - else EnchantManager.removeEnchantment(item, enchantment); + else EnchantUtils.remove(item, enchantment); - EnchantManager.updateEnchantmentsDisplay(item); + EnchantUtils.updateDisplay(item); plugin.getMessage(Lang.COMMAND_ENCHANT_DONE).send(sender); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/command/ListCommand.java b/Core/src/main/java/su/nightexpress/excellentenchants/command/ListCommand.java index 259dce4..cb1dcdb 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/ListCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/ListCommand.java @@ -4,37 +4,21 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.command.AbstractCommand; +import su.nexmedia.engine.api.command.CommandResult; 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 { public ListCommand(@NotNull ExcellentEnchants plugin) { super(plugin, new String[]{"list"}, Perms.COMMAND_LIST); + this.setDescription(plugin.getMessage(Lang.COMMAND_LIST_DESC)); + this.setPlayerOnly(true); } @Override - @NotNull - public String getUsage() { - return ""; - } - - @Override - @NotNull - public String getDescription() { - return plugin.getMessage(Lang.COMMAND_LIST_DESC).getLocalized(); - } - - @Override - public boolean isPlayerOnly() { - return true; - } - - @Override - protected void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args, @NotNull Map flags) { + protected void onExecute(@NotNull CommandSender sender, @NotNull CommandResult result) { plugin.getEnchantManager().getEnchantsListGUI().open((Player) sender, 1); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java b/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java index f39631a..f4768e6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java @@ -6,43 +6,29 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.command.AbstractCommand; +import su.nexmedia.engine.api.command.CommandResult; import su.nexmedia.engine.utils.CollectionsUtil; import su.nexmedia.engine.utils.Placeholders; import su.nexmedia.engine.utils.PlayerUtil; -import su.nexmedia.engine.utils.StringUtil; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Perms; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Lang; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.tier.Tier; import java.util.Arrays; import java.util.List; -import java.util.Map; +import java.util.Set; public class TierbookCommand extends AbstractCommand { public TierbookCommand(@NotNull ExcellentEnchants plugin) { super(plugin, new String[]{"tierbook"}, Perms.COMMAND_TIERBOOK); - } - - @Override - @NotNull - public String getDescription() { - return plugin.getMessage(Lang.COMMAND_TIER_BOOK_DESC).getLocalized(); - } - - @Override - @NotNull - public String getUsage() { - return plugin.getMessage(Lang.COMMAND_TIER_BOOK_USAGE).getLocalized(); - } - - @Override - public boolean isPlayerOnly() { - return false; + this.setDescription(plugin.getMessage(Lang.COMMAND_TIER_BOOK_DESC)); + this.setUsage(plugin.getMessage(Lang.COMMAND_TIER_BOOK_USAGE)); } @Override @@ -61,38 +47,39 @@ public class TierbookCommand extends AbstractCommand { } @Override - public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args, @NotNull Map flags) { - if (args.length != 4) { + protected void onExecute(@NotNull CommandSender sender, @NotNull CommandResult result) { + if (result.length() < 4) { this.printUsage(sender); return; } - Player player = plugin.getServer().getPlayer(args[1]); + Player player = plugin.getServer().getPlayer(result.getArg(1)); if (player == null) { this.errorPlayer(sender); return; } - Tier tier = plugin.getTierManager().getTierById(args[2].toLowerCase()); + Tier tier = plugin.getTierManager().getTierById(result.getArg(2).toLowerCase()); if (tier == null) { plugin.getMessage(Lang.COMMAND_TIER_BOOK_ERROR).send(sender); return; } - ExcellentEnchant enchant = Rnd.get(tier.getEnchants()); + Set enchants = EnchantRegistry.getOfTier(tier); + ExcellentEnchant enchant = enchants.isEmpty() ? null : Rnd.get(enchants); if (enchant == null) { plugin.getMessage(Lang.ERROR_NO_ENCHANT).send(sender); return; } - int level = StringUtil.getInteger(args[3], -1, true); + int level = result.getInt(3, -1); if (level < 1) { level = Rnd.get(enchant.getStartLevel(), enchant.getMaxLevel()); } ItemStack item = new ItemStack(Material.ENCHANTED_BOOK); - EnchantManager.addEnchantment(item, enchant, level, true); - EnchantManager.updateEnchantmentsDisplay(item); + EnchantUtils.add(item, enchant, level, true); + EnchantUtils.updateDisplay(item); PlayerUtil.addItem(player, item); plugin.getMessage(Lang.COMMAND_TIER_BOOK_DONE) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java index 0b75685..0003f82 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -19,13 +19,17 @@ import java.util.stream.Stream; public class Config { - public static final JOption TASKS_ARROW_TRAIL_TICKS_INTERVAL = JOption.create("Tasks.Arrow_Trail.Tick_Interval", 1L, - "Sets how often (in ticks) arrow trail particle effects will be spawned behind the arrow."); - public static final JOption TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL = JOption.create("Tasks.Passive_Potion_Effects.Apply_Interval", 100L, + public static final JOption TASKS_ARROW_TRAIL_TICKS_INTERVAL = JOption.create("Tasks.Arrow_Trail.Tick_Interval", + 1L, + "Sets how often (in ticks) arrow trail particle effects will be spawned behind the arrow." + ); + public static final JOption TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL = JOption.create("Tasks.Passive_Potion_Effects.Apply_Interval", + 100L, "Sets how often (in ticks) the plugin will apply permanent potion effects from enchanted items to an entity who wear them." ); - public static final JOption ENCHANTMENTS_CHARGES_ENABLED = JOption.create("Enchantments.Charges.Enabled", false, + public static final JOption ENCHANTMENTS_CHARGES_ENABLED = JOption.create("Enchantments.Charges.Enabled", + false, "Enables the enchantment Charges feature.", Placeholders.URL_WIKI + "Charges-System"); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java index 344586b..6ce89f2 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java @@ -6,21 +6,21 @@ import su.nightexpress.excellentenchants.Placeholders; public class Lang extends EngineLang { - public static final LangKey COMMAND_LIST_DESC = new LangKey("Command.List.Desc", "List of all custom enchantments."); + public static final LangKey COMMAND_LIST_DESC = LangKey.of("Command.List.Desc", "List of all custom enchantments."); - public static final LangKey COMMAND_ENCHANT_USAGE = new LangKey("Command.Enchant.Usage", " "); - public static final LangKey COMMAND_ENCHANT_DESC = new LangKey("Command.Enchant.Desc", "Enchants the item in your hand."); - public static final LangKey COMMAND_ENCHANT_DONE = new LangKey("Command.Enchant.Done", "&aSuccessfully enchanted!"); + public static final LangKey COMMAND_ENCHANT_USAGE = LangKey.of("Command.Enchant.Usage", " "); + public static final LangKey COMMAND_ENCHANT_DESC = LangKey.of("Command.Enchant.Desc", "Enchants the item in your hand."); + public static final LangKey COMMAND_ENCHANT_DONE = LangKey.of("Command.Enchant.Done", "&aSuccessfully enchanted!"); - public static final LangKey COMMAND_BOOK_USAGE = new LangKey("Command.Book.Usage", " "); - public static final LangKey COMMAND_BOOK_DESC = new LangKey("Command.Book.Desc", "Gives custom enchanted book."); - public static final LangKey COMMAND_BOOK_DONE = new LangKey("Command.Book.Done", "Given &6" + Placeholders.GENERIC_ENCHANT + "&7 enchanted book to &6" + Placeholders.Player.DISPLAY_NAME + "&7."); + public static final LangKey COMMAND_BOOK_USAGE = LangKey.of("Command.Book.Usage", " "); + public static final LangKey COMMAND_BOOK_DESC = LangKey.of("Command.Book.Desc", "Gives custom enchanted book."); + public static final LangKey COMMAND_BOOK_DONE = LangKey.of("Command.Book.Done", "Given &6" + Placeholders.GENERIC_ENCHANT + "&7 enchanted book to &6" + Placeholders.Player.DISPLAY_NAME + "&7."); - public static final LangKey COMMAND_TIER_BOOK_USAGE = new LangKey("Command.TierBook.Usage", " "); - public static final LangKey COMMAND_TIER_BOOK_DESC = new LangKey("Command.TierBook.Desc", "Gives an enchanted book."); - public static final LangKey COMMAND_TIER_BOOK_ERROR = new LangKey("Command.TierBook.Error", "&cInvalid tier!"); - public static final LangKey COMMAND_TIER_BOOK_DONE = new LangKey("Command.TierBook.Done", "Given &6" + Placeholders.TIER_NAME + "&7 enchanted book to &6" + Placeholders.Player.DISPLAY_NAME + "&7."); + public static final LangKey COMMAND_TIER_BOOK_USAGE = LangKey.of("Command.TierBook.Usage", " "); + public static final LangKey COMMAND_TIER_BOOK_DESC = LangKey.of("Command.TierBook.Desc", "Gives an enchanted book."); + public static final LangKey COMMAND_TIER_BOOK_ERROR = LangKey.of("Command.TierBook.Error", "&cInvalid tier!"); + public static final LangKey COMMAND_TIER_BOOK_DONE = LangKey.of("Command.TierBook.Done", "Given &6" + Placeholders.TIER_NAME + "&7 enchanted book to &6" + Placeholders.Player.DISPLAY_NAME + "&7."); - public static final LangKey ERROR_NO_ENCHANT = new LangKey("Error.NoEnchant", "&cInvalid enchantment."); + public static final LangKey ERROR_NO_ENCHANT = LangKey.of("Error.NoEnchant", "&cInvalid enchantment."); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java index d72f33d..569971f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java @@ -1,45 +1,19 @@ package su.nightexpress.excellentenchants.enchantment; -import org.bukkit.Material; -import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.EnchantmentStorageMeta; -import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.manager.AbstractManager; -import su.nexmedia.engine.utils.CollectionsUtil; -import su.nexmedia.engine.utils.EntityUtil; -import su.nexmedia.engine.utils.ItemUtil; -import su.nexmedia.engine.utils.PDCUtil; -import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; -import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; -import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.config.Config; -import su.nightexpress.excellentenchants.config.ObtainSettings; import su.nightexpress.excellentenchants.enchantment.listener.EnchantAnvilListener; import su.nightexpress.excellentenchants.enchantment.listener.EnchantGenericListener; import su.nightexpress.excellentenchants.enchantment.listener.EnchantHandlerListener; import su.nightexpress.excellentenchants.enchantment.menu.EnchantmentsListMenu; import su.nightexpress.excellentenchants.enchantment.task.ArrowTrailsTask; import su.nightexpress.excellentenchants.enchantment.task.PotionEffectsTask; -import su.nightexpress.excellentenchants.enchantment.type.ObtainType; -import su.nightexpress.excellentenchants.tier.Tier; - -import java.util.*; -import java.util.function.Function; -import java.util.stream.Stream; public class EnchantManager extends AbstractManager { + public static final String DIR_ENCHANTS = "/enchants/"; + private EnchantmentsListMenu enchantmentsListMenu; private ArrowTrailsTask arrowTrailsTask; @@ -51,7 +25,7 @@ public class EnchantManager extends AbstractManager { @Override protected void onLoad() { - EnchantRegister.setup(); + EnchantRegistry.setup(); this.enchantmentsListMenu = new EnchantmentsListMenu(this.plugin); this.addListener(new EnchantHandlerListener(this)); @@ -79,320 +53,11 @@ public class EnchantManager extends AbstractManager { this.potionEffectsTask.stop(); this.potionEffectsTask = null; } - EnchantRegister.shutdown(); + EnchantRegistry.shutdown(); } @NotNull public EnchantmentsListMenu getEnchantsListGUI() { return enchantmentsListMenu; } - - public static boolean isEnchantable(@NotNull ItemStack item) { - if (item.getType().isAir()) return false; - - return item.getType() == Material.ENCHANTED_BOOK || Stream.of(EnchantmentTarget.values()).anyMatch(target -> target.includes(item)); - } - - @NotNull - public static Map getEnchantsToPopulate(@NotNull ItemStack item, @NotNull ObtainType obtainType) { - return getEnchantsToPopulate(item, obtainType, new HashMap<>(), (enchant) -> enchant.generateLevel(obtainType)); - } - - @NotNull - public static Map getEnchantsToPopulate(@NotNull ItemStack item, @NotNull ObtainType obtainType, - @NotNull Map enchantsPrepared, - @NotNull Function levelFunc) { - Map enchantsToAdd = new HashMap<>(enchantsPrepared); - - ObtainSettings settings = Config.getObtainSettings(obtainType).orElse(null); - if (settings == null || !Rnd.chance(settings.getEnchantsCustomGenerationChance())) return enchantsToAdd; - - int enchMax = settings.getEnchantsTotalMax(); - int enchRoll = Rnd.get(settings.getEnchantsCustomMin(), settings.getEnchantsCustomMax()); - - // Класс для исключения неудачных попыток. - EnchantPopulator populator = new EnchantPopulator(obtainType, item); - - // Добавляем сколько можем, пока нужное количество не будет добавлено или не закончатся чары и/или тиры. - while (!populator.isEmpty() && enchRoll > 0) { - // Достигнут максимум чар (любых) для итема, заканчиваем. - if (enchantsToAdd.size() >= enchMax) break; - - Tier tier = populator.getTierByChance(); - if (tier == null) break; // Нет тира? - - ExcellentEnchant enchant = populator.getEnchantByChance(tier); - // В тире нет подходящих чар (вообще) для итема, исключаем и идем дальше. - if (enchant == null) { - populator.getEnchants().remove(tier); - continue; - } - - // Среди уже добавленных чар есть конфликты с тем, что нашли. - // Исключаем, идем дальше. - if (enchantsToAdd.keySet().stream().anyMatch(has -> has.conflictsWith(enchant) || enchant.conflictsWith(has))) { - populator.getEnchants(tier).remove(enchant); - continue; - } - - // Не получилось сгенерировать подходящий уровень. - // Исключаем, идем дальше. - int level = levelFunc.apply(enchant); - if (level < enchant.getStartLevel()) { - populator.getEnchants(tier).remove(enchant); - continue; - } - - // Добавляем чар, засчитываем попытку. - populator.getEnchants(tier).remove(enchant); - enchantsToAdd.put(enchant, level); - enchRoll--; - } - return enchantsToAdd; - } - - public static boolean populateEnchantments(@NotNull ItemStack item, @NotNull ObtainType obtainType) { - int enchantsHad = EnchantManager.getEnchantmentsAmount(item); - - EnchantManager.getEnchantsToPopulate(item, obtainType).forEach((enchantment, level) -> { - EnchantManager.addEnchantment(item, enchantment, level, false); - }); - EnchantManager.updateEnchantmentsDisplay(item); - - return EnchantManager.getEnchantmentsAmount(item) != enchantsHad; - } - - public static boolean addEnchantment(@NotNull ItemStack item, @NotNull Enchantment enchantment, int level, boolean force) { - if (!force && !enchantment.canEnchantItem(item)) return false; - - EnchantManager.removeEnchantment(item, enchantment); - - ItemMeta meta = item.getItemMeta(); - if (meta == null) return false; - - if (meta instanceof EnchantmentStorageMeta storageMeta) { - if (!storageMeta.addStoredEnchant(enchantment, level, true)) return false; - } - else { - if (!meta.addEnchant(enchantment, level, true)) return false; - } - item.setItemMeta(meta); - - return true; - } - - public static void removeEnchantment(@NotNull ItemStack item, @NotNull Enchantment enchantment) { - ItemMeta meta = item.getItemMeta(); - if (meta instanceof EnchantmentStorageMeta storageMeta) { - storageMeta.removeStoredEnchant(enchantment); - } - else { - meta.removeEnchant(enchantment); - } - item.setItemMeta(meta); - } - - public static final NamespacedKey KEY_LORE_SIZE = new NamespacedKey(ExcellentEnchantsAPI.PLUGIN, "lore_size"); - - public static boolean updateEnchantmentsDisplay(@NotNull ItemStack item) { - if (Config.ENCHANTMENTS_DISPLAY_MODE.get() != 1) return false; - - if (!isEnchantable(item)) { - PDCUtil.remove(item, KEY_LORE_SIZE); - return false; - } - - Map enchants = EnchantManager.getExcellentEnchantments(item); - - int sizeHas = PDCUtil.getInt(item, KEY_LORE_SIZE).orElse(0); - int sizeReal = enchants.size(); - - ItemMeta meta = item.getItemMeta(); - if (meta == null) return false; - - List lore = meta.getLore() == null ? new ArrayList<>() : meta.getLore(); - for (int index = 0; index < sizeHas && !lore.isEmpty(); index++) { - lore.remove(0); - } - //lore.removeIf(str -> enchants.keySet().stream().anyMatch(enchant -> str.contains(enchant.getDisplayName()))); - - if (!meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS)) { - if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED.get()) { - enchants.forEach((enchant, level) -> { - lore.addAll(0, enchant.formatDescription(level)); - }); - sizeReal += enchants.keySet().stream().map(ExcellentEnchant::getDescription).mapToInt(List::size).sum(); - } - enchants.forEach((enchant, level) -> { - lore.add(0, enchant.getNameFormatted(level, getEnchantmentCharges(meta, enchant))); - }); - } - else sizeReal = 0; - - meta.setLore(lore); - if (sizeReal > 0) { - PDCUtil.set(meta, KEY_LORE_SIZE, sizeReal); - } - item.setItemMeta(meta); - return true; - } - - @NotNull - public static Map getEnchantments(@NotNull ItemStack item) { - ItemMeta meta = item.getItemMeta(); - return meta == null ? Collections.emptyMap() : getEnchantments(meta); - } - - @NotNull - public static Map getEnchantments(@NotNull ItemMeta meta) { - return (meta instanceof EnchantmentStorageMeta meta2) ? meta2.getStoredEnchants() : meta.getEnchants(); - } - - public static int getEnchantmentsAmount(@NotNull ItemStack item) { - return EnchantManager.getEnchantments(item).size(); - } - - public static boolean hasEnchantment(@NotNull ItemStack item, @NotNull Enchantment enchantment) { - return EnchantManager.getEnchantmentLevel(item, enchantment) > 0; - } - - public static int getEnchantmentLevel(@NotNull ItemStack item, @NotNull Enchantment enchant) { - return EnchantManager.getEnchantments(item).getOrDefault(enchant, 0); - } - - public static int getEnchantmentCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { - return enchant.isChargesEnabled() ? PDCUtil.getInt(item, enchant.getChargesKey()).orElse(-0) : -1; - } - - public static int getEnchantmentCharges(@NotNull ItemMeta meta, @NotNull ExcellentEnchant enchant) { - return enchant.isChargesEnabled() ? PDCUtil.getInt(meta, enchant.getChargesKey()).orElse(0) : -1; - } - - public static boolean isEnchantmentOutOfCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { - return enchant.isChargesEnabled() && getEnchantmentCharges(item, enchant) == 0; - } - - public static boolean isEnchantmentFullOfCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { - if (!enchant.isChargesEnabled()) return true; - - int level = getEnchantmentLevel(item, enchant); - int max = enchant.getChargesMax(level); - return EnchantManager.getEnchantmentCharges(item, enchant) == max; - } - - public static void consumeEnchantmentCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { - if (!enchant.isChargesEnabled()) return; - - int level = getEnchantmentLevel(item, enchant); - int has = getEnchantmentCharges(item, enchant); - int use = enchant.getChargesConsumeAmount(level); - EnchantManager.setEnchantmentCharges(item, enchant, has - use); - } - - public static void restoreEnchantmentCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { - if (!enchant.isChargesEnabled()) return; - - int level = getEnchantmentLevel(item, enchant); - int max = enchant.getChargesMax(level); - EnchantManager.setEnchantmentCharges(item, enchant, max); - } - - public static void rechargeEnchantmentCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { - if (!enchant.isChargesEnabled()) return; - - int level = getEnchantmentLevel(item, enchant); - int recharge = enchant.getChargesRechargeAmount(level); - int has = getEnchantmentCharges(item, enchant); - EnchantManager.setEnchantmentCharges(item, enchant, has + recharge); - } - - public static void setEnchantmentCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int charges) { - if (!enchant.isChargesEnabled()) return; - - int level = getEnchantmentLevel(item, enchant); - int max = enchant.getChargesMax(level); - PDCUtil.set(item, enchant.getChargesKey(), Math.max(0, Math.min(charges, max))); - } - - public static int getExcellentEnchantmentsAmount(@NotNull ItemStack item) { - return EnchantManager.getExcellentEnchantments(item).size(); - } - - @NotNull - public static Map getExcellentEnchantments(@NotNull ItemStack item) { - return getExcellentEnchantments(EnchantManager.getEnchantments(item)); - } - - @NotNull - public static Map getExcellentEnchantments(@NotNull ItemMeta meta) { - return getExcellentEnchantments(EnchantManager.getEnchantments(meta)); - } - - @NotNull - private static Map getExcellentEnchantments(@NotNull Map enchants) { - Map map = new HashMap<>(); - enchants.forEach((enchantment, level) -> { - ExcellentEnchant excellent = EnchantRegister.get(enchantment.getKey()); - if (excellent != null) { - map.put(excellent, level); - } - }); - return map; - } - - @NotNull - public static Map getExcellentEnchantments(@NotNull ItemStack item, @NotNull Class clazz) { - Map map = new HashMap<>(); - EnchantManager.getEnchantments(item).forEach((enchantment, level) -> { - ExcellentEnchant excellent = EnchantRegister.get(enchantment.getKey()); - if (excellent == null || !clazz.isAssignableFrom(excellent.getClass())) return; - - map.put(clazz.cast(excellent), level); - }); - return CollectionsUtil.sort(map, Comparator.comparing(p -> p.getKey().getPriority(), Comparator.reverseOrder())); - } - - @NotNull - public static Map getEquipmentEnchanted(@NotNull LivingEntity entity) { - Map equipment = EntityUtil.getEquippedItems(entity); - equipment.entrySet().removeIf(entry -> { - ItemStack item = entry.getValue(); - EquipmentSlot slot = entry.getKey(); - if (item == null || item.getType().isAir() || item.getType() == Material.ENCHANTED_BOOK) return true; - if ((slot == EquipmentSlot.HAND || slot == EquipmentSlot.OFF_HAND) && ItemUtil.isArmor(item)) return true; - return !item.hasItemMeta(); - }); - return equipment; - } - - @NotNull - public static Map> getEquippedEnchants(@NotNull LivingEntity entity) { - Map> map = new HashMap<>(); - EnchantManager.getEquipmentEnchanted(entity).values().forEach(item -> { - map.computeIfAbsent(item, k -> new LinkedHashMap<>()).putAll(EnchantManager.getExcellentEnchantments(item)); - }); - return map; - } - - @NotNull - public static Map> getEquippedEnchants(@NotNull LivingEntity entity, @NotNull Class clazz) { - Map> map = new HashMap<>(); - EnchantManager.getEquipmentEnchanted(entity).values().forEach(item -> { - map.computeIfAbsent(item, k -> new LinkedHashMap<>()).putAll(EnchantManager.getExcellentEnchantments(item, clazz)); - }); - return map; - } - - public static void updateEquippedEnchantEffects(@NotNull LivingEntity entity) { - EnchantManager.getEquippedEnchants(entity, PassiveEnchant.class).forEach((item, enchants) -> { - enchants.forEach((enchant, level) -> { - if (enchant instanceof Potioned potioned) { - if (enchant.isOutOfCharges(item)) return; - if (enchant.onTrigger(entity, item, level)) { - enchant.consumeCharges(item); - } - } - }); - }); - } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java index dd423ab..97c830e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java @@ -5,8 +5,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.tier.Tier; import java.util.HashMap; @@ -24,8 +25,12 @@ public class EnchantPopulator { public EnchantPopulator(@NotNull ObtainType obtainType, @NotNull ItemStack item) { this.obtainType = obtainType; this.item = item; - this.enchants = ExcellentEnchantsAPI.getTierManager().getTiers().stream() - .collect(Collectors.toMap(k -> k, v -> v.getEnchants(obtainType, item), (prev, add) -> add, HashMap::new)); + this.enchants = new HashMap<>(); + + ExcellentEnchantsAPI.getTierManager().getTiers().forEach(tier -> { + Set enchants = EnchantRegistry.getOfTier(tier); + this.enchants.put(tier, EnchantUtils.populateFilter(enchants, obtainType, item)); + }); } public boolean isEmpty() { @@ -67,15 +72,14 @@ public class EnchantPopulator { @Nullable public Tier getTierByChance() { - Map map = this.getEnchants().keySet().stream() - .collect(Collectors.toMap(k -> k, v -> v.getChance(this.getObtainType()))); - return Rnd.get(map); + if (this.getEnchants().keySet().isEmpty()) return null; + return ExcellentEnchantsAPI.getTierManager().getTierByChance(this.getObtainType()); } @Nullable public ExcellentEnchant getEnchantByChance(@NotNull Tier tier) { Map map = this.getEnchants(tier).stream() .collect(Collectors.toMap(k -> k, v -> v.getObtainChance(this.getObtainType()))); - return map.isEmpty() ? null : Rnd.get(map); + return map.isEmpty() ? null : Rnd.getByWeight(map); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegister.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java similarity index 91% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegister.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java index 4daf1f5..ef6c937 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegister.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java @@ -7,22 +7,23 @@ import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.manager.ICleanable; import su.nexmedia.engine.utils.Reflex; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.armor.*; import su.nightexpress.excellentenchants.enchantment.impl.bow.*; import su.nightexpress.excellentenchants.enchantment.impl.tool.*; import su.nightexpress.excellentenchants.enchantment.impl.universal.EnchantCurseOfFragility; import su.nightexpress.excellentenchants.enchantment.impl.weapon.*; +import su.nightexpress.excellentenchants.tier.Tier; import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; -public class EnchantRegister { +public class EnchantRegistry { private static final ExcellentEnchants PLUGIN; - public static final Map ENCHANT_REGISTRY; + public static final Map REGISTRY_MAP; public static final EnchantBlastMining BLAST_MINING; public static final EnchantCurseOfBreaking CURSE_OF_BREAKING; @@ -92,8 +93,7 @@ public class EnchantRegister { static { PLUGIN = ExcellentEnchants.getPlugin(ExcellentEnchants.class); - PLUGIN.getConfigManager().extractResources("/enchants/"); - ENCHANT_REGISTRY = new HashMap<>(); + REGISTRY_MAP = new HashMap<>(); // Tool enchants BLAST_MINING = init(EnchantBlastMining.class, EnchantBlastMining.ID); @@ -170,17 +170,17 @@ public class EnchantRegister { public static void setup() { // Prevent to register enchantments during the runtime. if (ExcellentEnchants.isLoaded) { - ENCHANT_REGISTRY.values().forEach(ExcellentEnchant::loadConfig); + REGISTRY_MAP.values().forEach(ExcellentEnchant::loadConfig); return; } Reflex.setFieldValue(Enchantment.class, "acceptingNew", true); - for (Field field : EnchantRegister.class.getFields()) { + for (Field field : EnchantRegistry.class.getFields()) { if (!ExcellentEnchant.class.isAssignableFrom(field.getType())) continue; try { ExcellentEnchant enchant = (ExcellentEnchant) field.get(null); - EnchantRegister.register(enchant); + EnchantRegistry.register(enchant); } catch (Exception e) { e.printStackTrace(); @@ -188,7 +188,7 @@ public class EnchantRegister { } Enchantment.stopAcceptingRegistrations(); - PLUGIN.info("Enchantments Registered: " + ENCHANT_REGISTRY.size()); + PLUGIN.info("Enchantments Registered: " + REGISTRY_MAP.size()); ExcellentEnchants.isLoaded = true; } @@ -201,7 +201,7 @@ public class EnchantRegister { if (byKey == null || byName == null) return; - for (ExcellentEnchant enchant : ENCHANT_REGISTRY.values()) { + for (ExcellentEnchant enchant : REGISTRY_MAP.values()) { if (enchant instanceof ICleanable cleanable) { cleanable.clear(); } @@ -210,15 +210,10 @@ public class EnchantRegister { byName.remove(enchant.getName()); enchant.unregisterListeners(); } - ENCHANT_REGISTRY.clear(); + REGISTRY_MAP.clear(); PLUGIN.info("All enchants are unregistered."); } - @Nullable - public static ExcellentEnchant get(@NotNull NamespacedKey key) { - return ENCHANT_REGISTRY.get(key); - } - @Nullable private static T init(@NotNull Class clazz, @NotNull String id) { if (Config.ENCHANTMENTS_DISABLED.get().contains(id)) return null; @@ -236,10 +231,27 @@ public class EnchantRegister { if (enchant == null) return; Enchantment.registerEnchantment(enchant); - ENCHANT_REGISTRY.put(enchant.getKey(), enchant); + REGISTRY_MAP.put(enchant.getKey(), enchant); enchant.loadConfig(); enchant.getConfig().saveChanges(); enchant.registerListeners(); PLUGIN.info("Registered enchantment: " + enchant.getId()); } + + @Nullable + public static ExcellentEnchant get(@NotNull NamespacedKey key) { + return REGISTRY_MAP.get(key); + } + + @NotNull + public static Collection getRegistered() { + return REGISTRY_MAP.values(); + } + + @NotNull + public static Set getOfTier(@NotNull Tier tier) { + return getRegistered().stream().filter(enchant -> enchant.getTier() == tier) + .collect(Collectors.toCollection(HashSet::new)); + } + } 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 new file mode 100644 index 0000000..4daa453 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java @@ -0,0 +1,296 @@ +package su.nightexpress.excellentenchants.enchantment.config; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.api.config.JOption; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.Colorizer; +import su.nexmedia.engine.utils.StringUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.type.ObtainType; +import su.nightexpress.excellentenchants.tier.Tier; +import su.nightexpress.excellentenchants.tier.TierManager; + +import java.util.*; + +public class EnchantDefaults { + + private final Map obtainChance; + private final Map obtainLevelCap; + + private String displayName; + private Tier tier; + private List description; + private boolean isTreasure; + private int levelMin; + private int levelMax; + private EnchantScaler levelByEnchantCost; + private EnchantScaler anvilMergeCost; + private Set conflicts; + private boolean visualEffects; + + private boolean chargesEnabled; + private boolean chargesCustomFuel; + private EnchantScaler chargesMax; + private EnchantScaler chargesConsumeAmount; + private EnchantScaler chargesRechargeAmount; + private ItemStack chargesFuel; + + public EnchantDefaults(@NotNull ExcellentEnchant enchant) { + this.setDisplayName(StringUtil.capitalizeUnderscored(enchant.getId())); + this.setTier(0.1); + this.setDescription(new ArrayList<>()); + this.setTreasure(false); + this.setLevelMin(1); + this.setLevelMax(3); + this.setConflicts(new HashSet<>()); + this.setVisualEffects(true); + this.obtainChance = new HashMap<>(); + this.obtainLevelCap = new HashMap<>(); + } + + public void load(@NotNull ExcellentEnchant enchant) { + ExcellentEnchants plugin = ExcellentEnchantsAPI.PLUGIN; + JYML cfg = enchant.getConfig(); + + this.setDisplayName(JOption.create("Name", this.getDisplayName(), + "Enchantment display name. It will be shown in item lore.").read(cfg)); + + Tier tier = plugin.getTierManager().getTierById(JOption.create("Tier", this.getTier().getId(), + "Enchantment tier. Must be a valid tier identifier from the '" + TierManager.FILE_NAME + "'.").read(cfg)); + this.setTier(tier == null ? plugin.getTierManager().getMostCommon() : tier); + //this.getTier().getEnchants().add(enchant); + + this.setDescription(JOption.create("Description", this.getDescription(), + "Enchantment description. It will be shown in item lore under enchantment name.", + "You can use 'Enchantment' placeholders: " + Placeholders.URL_PLACEHOLDERS) + .read(cfg)); + + this.setTreasure(JOption.create("Is_Treasure", this.isTreasure(), + "Sets whether this enchantment is a treasure enchantment.", + "Treasure enchantments can only be received via looting, trading, or fishing.").read(cfg)); + + this.setLevelMin(JOption.create("Level.Min", this.getLevelMin(), + "Sets the minimal (start) enchantment level. Can not be less than 1.").read(cfg)); + + this.setLevelMax(JOption.create("Level.Max", this.getLevelMax(), + "Sets the maximal enchantment level. Can not be less than min. level.", + "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.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.", + "With a default formula '9 * %enchantment_level%' it will be [9, 18, 27] XP levels for [1, 2, 3] enchantment levels.")); + + this.setAnvilMergeCost(EnchantScaler.read(enchant, "Anvil.Merge_Cost", Placeholders.ENCHANTMENT_LEVEL, + "Sets how much XP levels will be added to the anvil cost when combining custom enchantments.")); + + for (ObtainType obtainType : ObtainType.values()) { + double obtainChance = JOption.create(obtainType.getPathName() + ".Chance", 50D, + "Chance for this enchantment to be obtained via " + obtainType.getPathName()).read(cfg); + this.getObtainChance().put(obtainType, obtainChance); + + int levelMin = JOption.create(obtainType.getPathName() + ".Level.Min", -1, + "Minimal level when obtained via " + obtainType.getPathName(), + "Can not be less than enchantment min. level. Set -1 to use enchantment min. level.").read(cfg); + int levelMax = JOption.create(obtainType.getPathName() + ".Level.Max", -1, + "Maximal level when obtained via " + obtainType.getPathName(), + "Can not be greater than enchantment max. level. Set -1 to use enchantment max. level.").read(cfg); + this.getObtainLevelCap().put(obtainType, new int[]{levelMin, levelMax}); + } + + + this.setConflicts(JOption.create("Conflicts", this.getConflicts(), + "A list of conflicting enchantment names.", + "Conflicting enchantments can not be combined on anvils and obtained together on the same item.").read(cfg)); + + this.setVisualEffects(JOption.create("Settings.Visual_Effects", this.isVisualEffects(), + "Enables/Disables enchantment visual effects, such as particles.").read(cfg)); + + + if (Config.ENCHANTMENTS_CHARGES_ENABLED.get()) { + 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) + .setWriter(JYML::setItem).read(cfg)); + } + } + + @NotNull + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(@NotNull String displayName) { + this.displayName = Colorizer.apply(displayName); + } + + @NotNull + public Tier getTier() { + return tier; + } + + public void setTier(double rarity) { + this.setTier(ExcellentEnchantsAPI.getTierManager().getByRarityModifier(rarity)); + } + + public void setTier(@NotNull Tier tier) { + this.tier = tier; + } + + public void setDescription(@NotNull String... description) { + this.setDescription(Arrays.asList(description)); + } + + public void setDescription(@NotNull List description) { + this.description = Colorizer.apply(description); + } + + @NotNull + public List getDescription() { + return description; + } + + public boolean isTreasure() { + return isTreasure; + } + + public void setTreasure(boolean treasure) { + isTreasure = treasure; + } + + public void setLevelMin(int levelMin) { + this.levelMin = Math.max(1, levelMin); + } + + public int getLevelMin() { + return levelMin; + } + + public void setLevelMax(int levelMax) { + this.levelMax = Math.max(1, levelMax); + } + + public int getLevelMax() { + return levelMax; + } + + @NotNull + public EnchantScaler getLevelByEnchantCost() { + return levelByEnchantCost; + } + + public void setLevelByEnchantCost(@NotNull EnchantScaler levelByEnchantCost) { + this.levelByEnchantCost = levelByEnchantCost; + } + + @NotNull + public EnchantScaler getAnvilMergeCost() { + return anvilMergeCost; + } + + public void setAnvilMergeCost(@NotNull EnchantScaler anvilMergeCost) { + this.anvilMergeCost = anvilMergeCost; + } + + @NotNull + public Map getObtainChance() { + return obtainChance; + } + + @NotNull + public Map getObtainLevelCap() { + return obtainLevelCap; + } + + public void setConflicts(@NotNull String... conflicts) { + this.setConflicts(new HashSet<>(Arrays.asList(conflicts))); + } + + public void setConflicts(@NotNull Set conflicts) { + this.conflicts = conflicts; + } + + @NotNull + public Set getConflicts() { + return conflicts; + } + + public boolean isVisualEffects() { + return visualEffects; + } + + public void setVisualEffects(boolean visualEffects) { + this.visualEffects = visualEffects; + } + + public boolean isChargesEnabled() { + return chargesEnabled; + } + + public void setChargesEnabled(boolean chargesEnabled) { + this.chargesEnabled = chargesEnabled; + } + + public boolean isChargesCustomFuel() { + return chargesCustomFuel; + } + + public void setChargesCustomFuel(boolean chargesCustomFuel) { + this.chargesCustomFuel = chargesCustomFuel; + } + + @NotNull + public EnchantScaler getChargesMax() { + return chargesMax; + } + + public void setChargesMax(@NotNull EnchantScaler chargesMax) { + this.chargesMax = chargesMax; + } + + @Nullable + public ItemStack getChargesFuel() { + return chargesFuel; + } + + public void setChargesFuel(@Nullable ItemStack chargesFuel) { + this.chargesFuel = chargesFuel; + } + + @NotNull + public EnchantScaler getChargesConsumeAmount() { + return chargesConsumeAmount; + } + + public void setChargesConsumeAmount(@NotNull EnchantScaler chargesConsumeAmount) { + this.chargesConsumeAmount = chargesConsumeAmount; + } + + @NotNull + public EnchantScaler getChargesRechargeAmount() { + return chargesRechargeAmount; + } + + public void setChargesRechargeAmount(@NotNull EnchantScaler chargesRechargeAmount) { + this.chargesRechargeAmount = chargesRechargeAmount; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantScaler.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantScaler.java index d61e032..811de83 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantScaler.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantScaler.java @@ -4,7 +4,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import java.util.ArrayList; import java.util.Arrays; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java similarity index 53% rename from Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index be97278..892310f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.api.enchantment; +package su.nightexpress.excellentenchants.enchantment.impl; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -8,24 +8,23 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.IListener; import su.nexmedia.engine.lang.LangManager; -import su.nexmedia.engine.utils.*; +import su.nexmedia.engine.utils.ItemUtil; +import su.nexmedia.engine.utils.NumberUtil; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.config.EnchantDefaults; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.config.Config; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; -import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; -import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; -import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.tier.Tier; import java.util.*; @@ -37,120 +36,23 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme protected final ExcellentEnchants plugin; protected final JYML cfg; protected final String id; - protected final EnchantPriority priority; - - protected String displayName; - protected Tier tier; - protected List description; - protected boolean isTreasure; - protected int levelMin; - protected int levelMax; - protected Scaler levelByEnchantCost; - protected Scaler anvilMergeCost; - protected Map obtainChance; - protected Set conflicts; - protected Map obtainLevelCap; - protected boolean hasVisualEffects; - - protected boolean chargesEnabled; - protected boolean chargesCustomFuel; - protected EnchantScaler chargesMax; - protected EnchantScaler chargesConsumeAmount; - protected EnchantScaler chargesRechargeAmount; - protected ItemStack chargesFuel; - protected final NamespacedKey chargesKey; + protected final EnchantPriority priority; + protected final EnchantDefaults defaults; + protected final NamespacedKey chargesKey; public ExcellentEnchant(@NotNull ExcellentEnchants plugin, @NotNull String id, @NotNull EnchantPriority priority) { super(NamespacedKey.minecraft(id.toLowerCase())); this.plugin = plugin; this.id = this.getKey().getKey(); - this.cfg = JYML.loadOrExtract(plugin, "/enchants/" + id + ".yml"); + this.cfg = new JYML(plugin.getDataFolder() + "/enchants/", id + ".yml"); this.priority = priority; - this.conflicts = new HashSet<>(); this.chargesKey = new NamespacedKey(plugin, this.getId() + ".charges"); + this.defaults = new EnchantDefaults(this); } public void loadConfig() { this.cfg.reload(); - - this.displayName = JOption.create("Name", StringUtil.capitalizeFully(this.getId().replace("_", " ")), - "Enchantment display name. It will be shown in item lore.") - .mapReader(Colorizer::apply).read(cfg); - - this.tier = plugin.getTierManager().getTierById(JOption.create("Tier", Placeholders.DEFAULT, - "Enchantment tier. Must be a valid tier identifier from the 'tiers.yml'.").read(cfg)); - if (this.tier == null) { - this.tier = Tier.DEFAULT; - } - this.tier.getEnchants().add(this); - - this.description = JOption.create("Description", new ArrayList<>(), - "Enchantment description. It will be shown in item lore under enchantment name.", - "You can use 'Enchantment' placeholders: " + Placeholders.URL_PLACEHOLDERS) - .mapReader(Colorizer::apply).read(cfg); - - this.isTreasure = JOption.create("Is_Treasure", false, - "Sets whether this enchantment is a treasure enchantment.", - "Treasure enchantments can only be received via looting, trading, or fishing.").read(cfg); - - this.levelMin = Math.max(1, JOption.create("Level.Min", 1, - "Sets the minimal (start) enchantment level. Can not be less than 1.").read(cfg)); - - this.levelMax = JOption.create("Level.Max", 3, - "Sets the maximal enchantment level. Can not be less than min. level.", - "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.levelByEnchantCost = EnchantScaler.read(this, 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.", - "With a default formula '9 * %enchantment_level%' it will be [9, 18, 27] XP levels for [1, 2, 3] enchantment levels."); - - this.anvilMergeCost = EnchantScaler.read(this, "Anvil.Merge_Cost", Placeholders.ENCHANTMENT_LEVEL, - "Sets how much XP levels will be added to the anvil cost when combining custom enchantments."); - - this.obtainChance = new HashMap<>(); - this.obtainLevelCap = new HashMap<>(); - for (ObtainType obtainType : ObtainType.values()) { - double obtainChance = JOption.create(obtainType.getPathName() + ".Chance", 50D, - "Chance for this enchantment to be obtained via " + obtainType.getPathName()).read(cfg); - this.obtainChance.put(obtainType, obtainChance); - - int levelMin = JOption.create(obtainType.getPathName() + ".Level.Min", -1, - "Minimal level when obtained via " + obtainType.getPathName(), - "Can not be less than enchantment min. level. Set -1 to use enchantment min. level.").read(cfg); - int levelMax = JOption.create(obtainType.getPathName() + ".Level.Max", -1, - "Maximal level when obtained via " + obtainType.getPathName(), - "Can not be greater than enchantment max. level. Set -1 to use enchantment max. level.").read(cfg); - this.obtainLevelCap.put(obtainType, new int[]{levelMin, levelMax}); - } - - - this.conflicts = JOption.create("Conflicts", new HashSet<>(), - "A list of conflicting enchantment names.", - "Conflicting enchantments can not be combined on anvils and obtained together on the same item.").read(cfg); - - this.hasVisualEffects = JOption.create("Settings.Visual_Effects", true, - "Enables/Disables enchantment visual effects, such as particles.").read(cfg); - - - if (Config.ENCHANTMENTS_CHARGES_ENABLED.get()) { - this.chargesEnabled = JOption.create("Settings.Charges.Enabled", false, - "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.chargesCustomFuel = JOption.create("Settings.Charges.Custom_Fuel", false, - "When 'true' uses different (non-default) fuel item (from the 'Fuel_Item' setting) to recharge.").read(cfg); - this.chargesMax = EnchantScaler.read(this, "Settings.Charges.Maximum", "100", - "Maximum amount of charges for the enchantment."); - this.chargesConsumeAmount = EnchantScaler.read(this, "Settings.Charges.Consume_Amount", "1", - "How many charges will be consumed when enchantment is triggered?"); - this.chargesRechargeAmount = EnchantScaler.read(this, "Settings.Charges.Recharge_Amount", "25", - "How many charges will be restored when using 'Fuel Item' in anvil?"); - this.chargesFuel = 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) - .setWriter(JYML::setItem).read(cfg); - } + this.getDefaults().load(this); } @NotNull @@ -181,13 +83,13 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme str = str.replace(Placeholders.ENCHANTMENT_DESCRIPTION, String.join("\n", this.getDescription())); if (this instanceof Chanced chanced) { - str = str.replace(ChanceImplementation.PLACEHOLDER_CHANCE, NumberUtil.format(chanced.getTriggerChance(level))); + str = str.replace(Placeholders.ENCHANTMENT_CHANCE, NumberUtil.format(chanced.getTriggerChance(level))); } if (this instanceof Potioned potioned) { str = str - .replace(PotionImplementation.PLACEHOLDER_POTION_LEVEL, NumberUtil.toRoman(potioned.getEffectAmplifier(level))) - .replace(PotionImplementation.PLACEHOLDER_POTION_DURATION, NumberUtil.format((double) potioned.getEffectDuration(level) / 20D)) - .replace(PotionImplementation.PLACEHOLDER_POTION_TYPE, LangManager.getPotionType(potioned.getEffectType())); + .replace(Placeholders.ENCHANTMENT_POTION_LEVEL, NumberUtil.toRoman(potioned.getEffectAmplifier(level))) + .replace(Placeholders.ENCHANTMENT_POTION_DURATION, NumberUtil.format((double) potioned.getEffectDuration(level) / 20D)) + .replace(Placeholders.ENCHANTMENT_POTION_TYPE, LangManager.getPotionType(potioned.getEffectType())); } return str; }; @@ -228,6 +130,11 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme return priority; } + @NotNull + public EnchantDefaults getDefaults() { + return defaults; + } + @NotNull @Override public String getName() { @@ -236,7 +143,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme @NotNull public String getDisplayName() { - return this.displayName; + return this.getDefaults().getDisplayName(); } @NotNull @@ -259,12 +166,12 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme @NotNull public List getDescription() { - return this.description; + return this.getDefaults().getDescription(); } @NotNull public List getDescription(int level) { - List description = new ArrayList<>(this.description); + List description = new ArrayList<>(this.getDescription()); description.replaceAll(this.replacePlaceholders(level)); return description; } @@ -278,26 +185,26 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme @NotNull public Set getConflicts() { - return conflicts; + return this.getDefaults().getConflicts(); } @NotNull public Tier getTier() { - return this.tier; + return this.getDefaults().getTier(); } @Override public int getMaxLevel() { - return this.levelMax; + return this.getDefaults().getLevelMax(); } @Override public int getStartLevel() { - return this.levelMin; + return this.getDefaults().getLevelMin(); } public int getLevelByEnchantCost(int expLevel) { - int get = this.levelByEnchantCost.getValues().entrySet().stream() + int get = this.getDefaults().getLevelByEnchantCost().getValues().entrySet().stream() .filter(en -> expLevel >= en.getValue().intValue()).max(Comparator.comparingInt(Map.Entry::getKey)) .map(Map.Entry::getKey).orElse(0); @@ -305,15 +212,15 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme } public double getObtainChance(@NotNull ObtainType obtainType) { - return this.obtainChance.getOrDefault(obtainType, 0D); + return this.getDefaults().getObtainChance().getOrDefault(obtainType, 0D); } public int getObtainLevelMin(@NotNull ObtainType obtainType) { - return this.obtainLevelCap.getOrDefault(obtainType, new int[]{-1, -1})[0]; + return this.getDefaults().getObtainLevelCap().getOrDefault(obtainType, new int[]{-1, -1})[0]; } public int getObtainLevelMax(@NotNull ObtainType obtainType) { - return this.obtainLevelCap.getOrDefault(obtainType, new int[]{-1, -1})[1]; + return this.getDefaults().getObtainLevelCap().getOrDefault(obtainType, new int[]{-1, -1})[1]; } public int fineLevel(int level, @NotNull ObtainType obtainType) { @@ -341,19 +248,19 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme } public int getAnvilMergeCost(int level) { - return (int) this.anvilMergeCost.getValue(level); + return (int) this.getDefaults().getAnvilMergeCost().getValue(level); } @Override public final boolean conflictsWith(@NotNull Enchantment enchantment) { - return this.conflicts.contains(enchantment.getKey().getKey()); + return this.getConflicts().contains(enchantment.getKey().getKey()); } @Override public final boolean canEnchantItem(@Nullable ItemStack item) { if (item == null || item.getType().isAir()) return false; - if (EnchantManager.getEnchantments(item).keySet().stream().anyMatch(e -> e.conflictsWith(this) || this.conflictsWith(e))) return false; - if (EnchantManager.getEnchantmentLevel(item, this) <= 0 && EnchantManager.getExcellentEnchantmentsAmount(item) >= Config.ENCHANTMENTS_ITEM_CUSTOM_MAX.get()) { + if (EnchantUtils.getAll(item).keySet().stream().anyMatch(e -> e.conflictsWith(this) || this.conflictsWith(e))) return false; + if (EnchantUtils.getLevel(item, this) <= 0 && EnchantUtils.getExcellentAmount(item) >= Config.ENCHANTMENTS_ITEM_CUSTOM_MAX.get()) { return false; } if (item.getType() == Material.BOOK || item.getType() == Material.ENCHANTED_BOOK) { @@ -369,36 +276,36 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme @Override public final boolean isTreasure() { - return this.isTreasure; + return this.getDefaults().isTreasure(); } public boolean hasVisualEffects() { - return this.hasVisualEffects; + return this.getDefaults().isVisualEffects(); } public boolean isChargesEnabled() { - return Config.ENCHANTMENTS_CHARGES_ENABLED.get() && this.chargesEnabled; + return Config.ENCHANTMENTS_CHARGES_ENABLED.get() && this.getDefaults().isChargesEnabled(); } public boolean isChargesCustomFuel() { - return chargesCustomFuel; + return this.getDefaults().isChargesCustomFuel(); } public int getChargesMax(int level) { - return this.isChargesEnabled() ? (int) this.chargesMax.getValue(level) : 0; + return this.isChargesEnabled() ? (int) this.getDefaults().getChargesMax().getValue(level) : 0; } public int getChargesConsumeAmount(int level) { - return this.isChargesEnabled() ? (int) this.chargesConsumeAmount.getValue(level) : 0; + return this.isChargesEnabled() ? (int) this.getDefaults().getChargesConsumeAmount().getValue(level) : 0; } public int getChargesRechargeAmount(int level) { - return this.isChargesEnabled() ? (int) this.chargesRechargeAmount.getValue(level) : 0; + return this.isChargesEnabled() ? (int) this.getDefaults().getChargesRechargeAmount().getValue(level) : 0; } @NotNull public ItemStack getChargesFuel() { - ItemStack fuelHas = this.chargesFuel; + ItemStack fuelHas = this.getDefaults().getChargesFuel(); if (!this.isChargesCustomFuel() || fuelHas == null || fuelHas.getType().isAir()) { return Config.ENCHANTMENTS_CHARGES_FUEL_ITEM.get(); } @@ -416,22 +323,22 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme @Override public boolean isOutOfCharges(@NotNull ItemStack item) { - return EnchantManager.isEnchantmentOutOfCharges(item, this); + return EnchantUtils.isOutOfCharges(item, this); } @Override public boolean isFullOfCharges(@NotNull ItemStack item) { - return EnchantManager.isEnchantmentFullOfCharges(item, this); + return EnchantUtils.isFullOfCharges(item, this); } @Override public int getCharges(@NotNull ItemStack item) { - return EnchantManager.getEnchantmentCharges(item, this); + return EnchantUtils.getCharges(item, this); } @Override public void consumeCharges(@NotNull ItemStack item) { - EnchantManager.consumeEnchantmentCharges(item, this); - EnchantManager.updateEnchantmentsDisplay(item); + EnchantUtils.consumeCharges(item, this); + EnchantUtils.updateDisplay(item); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantAquaman.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantAquaman.java index 86edb87..8784a88 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantAquaman.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantAquaman.java @@ -6,16 +6,36 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantAquaman extends PotionEnchant implements PassiveEnchant { +public class EnchantAquaman extends ExcellentEnchant implements Potioned, PassiveEnchant { public static final String ID = "aquaman"; + private PotionImplementation potionImplementation; + public EnchantAquaman(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.WATER_BREATHING, true); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(0.4); + this.getDefaults().setDescription("Grants permanent " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " effect."); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.WATER_BREATHING, true); + } + + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantBunnyHop.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantBunnyHop.java index eaae375..6ed17b8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantBunnyHop.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantBunnyHop.java @@ -6,16 +6,36 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantBunnyHop extends PotionEnchant implements PassiveEnchant { +public class EnchantBunnyHop extends ExcellentEnchant implements Potioned, PassiveEnchant { public static final String ID = "bunny_hop"; + private PotionImplementation potionImplementation; + public EnchantBunnyHop(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.JUMP, true); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.1); + this.getDefaults().setDescription("Grants permanent " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " effect."); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.JUMP, true); + } + + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantColdSteel.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantColdSteel.java index 721c386..548a0cc 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantColdSteel.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantColdSteel.java @@ -7,26 +7,39 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantColdSteel extends PotionEnchant implements Chanced, CombatEnchant { +public class EnchantColdSteel extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { public static final String ID = "cold_steel"; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantColdSteel(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.SLOW_DIGGING, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to apply " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) on attacker."); + this.getDefaults().setTier(0.3); + this.getDefaults().setLevelMax(3); + } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + + this.chanceImplementation = ChanceImplementation.create(this, + "60 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.SLOW_DIGGING, false, + "4 + " + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -35,6 +48,12 @@ public class EnchantColdSteel extends PotionEnchant implements Chanced, CombatEn return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @Override @NotNull public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantElementalProtection.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantElementalProtection.java index e96f8fd..53518aa 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantElementalProtection.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantElementalProtection.java @@ -11,10 +11,10 @@ import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.Set; import java.util.function.UnaryOperator; @@ -36,6 +36,9 @@ public class EnchantElementalProtection extends ExcellentEnchant { public EnchantElementalProtection(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Reduces Poison, Magic, Wither, Lightning, Freeze damage by " + PLACEHOLDER_PROTECTION_AMOUNT + "."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.2); } @Override @@ -51,7 +54,8 @@ public class EnchantElementalProtection extends ExcellentEnchant { public void loadConfig() { super.loadConfig(); - this.protectionAmount = EnchantScaler.read(this, "Settings.Protection.Amount", "0.05 * " + Placeholders.ENCHANTMENT_LEVEL, + this.protectionAmount = EnchantScaler.read(this, "Settings.Protection.Amount", + "0.05 * " + Placeholders.ENCHANTMENT_LEVEL, "How protection the enchantment will have?"); this.protectionCapacity = JOption.create("Settings.Protection.Capacity", 1D, "Maximal possible protection value from all armor pieces together.").read(cfg); @@ -85,8 +89,8 @@ public class EnchantElementalProtection extends ExcellentEnchant { if (!this.isAvailableToUse(entity)) return; double protectionAmount = 0D; - for (ItemStack armor : EnchantManager.getEquipmentEnchanted(entity).values()) { - int level = EnchantManager.getEnchantmentLevel(armor, this); + for (ItemStack armor : EnchantUtils.getEnchantedEquipment(entity).values()) { + int level = EnchantUtils.getLevel(armor, this); if (level <= 0) continue; protectionAmount += this.getProtectionAmount(level); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFireShield.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFireShield.java index 58de781..fbad30a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFireShield.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFireShield.java @@ -8,10 +8,10 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; @@ -27,6 +27,9 @@ public class EnchantFireShield extends ExcellentEnchant implements Chanced, Comb public EnchantFireShield(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to ignite the attacker for " + PLACEHOLDER_FIRE_DURATION + "s."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.4); } @Override @@ -41,8 +44,10 @@ public class EnchantFireShield extends ExcellentEnchant implements Chanced, Comb public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); - this.fireDuration = EnchantScaler.read(this, "Settings.Fire.Duration", "2.5 * " + Placeholders.ENCHANTMENT_LEVEL, + this.chanceImplementation = ChanceImplementation.create(this, + Placeholders.ENCHANTMENT_LEVEL + " * 15.0"); + this.fireDuration = EnchantScaler.read(this, "Settings.Fire.Duration", + "2.5 * " + Placeholders.ENCHANTMENT_LEVEL, "Sets the fire duration (in seconds).", "If entity's current fire ticks amount is less than this value, it will be set to this value.", "If entity's current fire ticks amount is greater than this value, it won't be changed."); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFlameWalker.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFlameWalker.java index f2ec964..a2633f6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFlameWalker.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFlameWalker.java @@ -5,6 +5,7 @@ import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -17,14 +18,14 @@ import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.manager.ICleanable; -import su.nexmedia.engine.api.task.AbstractTask; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; +import su.nexmedia.engine.api.server.AbstractTask; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -42,6 +43,10 @@ public class EnchantFlameWalker extends ExcellentEnchant implements ICleanable { public EnchantFlameWalker(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Ability to walk on lava and magma blocks without getting damage."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.7); + this.getDefaults().getConflicts().add(Enchantment.FROST_WALKER.getKey().getKey()); this.blockTickTask = new BlockTickTask(plugin); this.blockTickTask.start(); @@ -91,7 +96,7 @@ public class EnchantFlameWalker extends ExcellentEnchant implements ICleanable { ItemStack boots = player.getInventory().getBoots(); if (boots == null || boots.getType().isAir()) return; - int level = EnchantManager.getEnchantmentLevel(boots, this); + int level = EnchantUtils.getLevel(boots, this); if (level <= 0) return; Block bTo = to.getBlock().getRelative(BlockFace.DOWN); @@ -124,7 +129,7 @@ public class EnchantFlameWalker extends ExcellentEnchant implements ICleanable { ItemStack boots = equipment.getBoots(); if (boots == null || boots.getType().isAir()) return; - int level = EnchantManager.getEnchantmentLevel(boots, this); + int level = EnchantUtils.getLevel(boots, this); if (level <= 0) return; e.setCancelled(true); @@ -146,7 +151,8 @@ public class EnchantFlameWalker extends ExcellentEnchant implements ICleanable { long time = BLOCKS_TO_DESTROY.get(block); if (now >= time) { block.setType(Material.LAVA); - EffectUtil.playEffect(block.getLocation(), Particle.BLOCK_CRACK, Material.MAGMA_BLOCK.name(), 0.5, 0.7, 0.5, 0.03, 50); + SimpleParticle.of(Particle.BLOCK_CRACK, Material.MAGMA_BLOCK) + .play(block.getLocation(), 0.5, 0.7, 0.5, 0.03, 30); return true; } return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantHardened.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantHardened.java index ab546de..3653fbe 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantHardened.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantHardened.java @@ -7,26 +7,38 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantHardened extends PotionEnchant implements Chanced, CombatEnchant { +public class EnchantHardened extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { public static final String ID = "hardened"; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantHardened(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.DAMAGE_RESISTANCE, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to obtain " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) when damaged."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.4); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "30.0 * " + Placeholders.ENCHANTMENT_LEVEL); + + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.DAMAGE_RESISTANCE, false, + "3.0" + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -35,6 +47,12 @@ public class EnchantHardened extends PotionEnchant implements Chanced, CombatEnc return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @Override @NotNull public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantIceShield.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantIceShield.java index 328ffb9..0d2b3af 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantIceShield.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantIceShield.java @@ -8,28 +8,38 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -public class EnchantIceShield extends PotionEnchant implements Chanced, CombatEnchant { +public class EnchantIceShield extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { public static final String ID = "ice_shield"; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantIceShield(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.SLOW, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to freeze and apply " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) on attacker."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.1); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, "25.0 * " + Placeholders.ENCHANTMENT_LEVEL); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.SLOW, false, + "3.0 + " + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -44,6 +54,12 @@ public class EnchantIceShield extends PotionEnchant implements Chanced, CombatEn return this.chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; @@ -58,7 +74,8 @@ public class EnchantIceShield extends PotionEnchant implements Chanced, CombatEn damager.setFreezeTicks(damager.getMaxFreezeTicks()); if (this.hasVisualEffects()) { - EffectUtil.playEffect(damager.getEyeLocation(), Particle.BLOCK_CRACK, Material.ICE.name(), 0.25, 0.25, 0.25, 0.1f, 15); + SimpleParticle.of(Particle.BLOCK_CRACK, Material.ICE) + .play(damager.getEyeLocation(), 0.25, 0.1, 20); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantNightVision.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantNightVision.java index ce0cc87..fcf52cf 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantNightVision.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantNightVision.java @@ -6,16 +6,36 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantNightVision extends PotionEnchant implements PassiveEnchant { +public class EnchantNightVision extends ExcellentEnchant implements Potioned, PassiveEnchant { public static final String ID = "night_vision"; + private PotionImplementation potionImplementation; + public EnchantNightVision(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.NIGHT_VISION, true); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Grants permanent " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " effect."); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(0.7); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.NIGHT_VISION, true); + } + + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantRegrowth.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantRegrowth.java index dba573b..3552237 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantRegrowth.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantRegrowth.java @@ -8,18 +8,19 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.api.manager.ICleanable; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.task.AbstractEnchantmentTask; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.function.UnaryOperator; @@ -42,13 +43,16 @@ public class EnchantRegrowth extends ExcellentEnchant implements Chanced, Passiv public EnchantRegrowth(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); - + this.getDefaults().setDescription("Restores " + PLACEHOLDER_HEAL_AMOUNT + " hearts every " + PLACEHOLDER_HEAL_INTERVAL + "s."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.7); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "20.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); this.healInterval = JOption.create("Settings.Heal.Interval", 100, "How often (in ticks) enchantment will have effect? 1 second = 20 ticks.").read(cfg); this.healMinHealth = EnchantScaler.read(this, "Settings.Heal.Min_Health", "0.5", @@ -127,7 +131,7 @@ public class EnchantRegrowth extends ExcellentEnchant implements Chanced, Passiv entity.setHealth(amount); if (this.hasVisualEffects()) { - EffectUtil.playEffect(entity.getEyeLocation(), Particle.HEART, "", 0.3, 0.3, 0.3, 0.1, 5); + SimpleParticle.of(Particle.HEART).play(entity.getEyeLocation(), 0.25, 0.1, 5); } return true; } @@ -141,7 +145,7 @@ public class EnchantRegrowth extends ExcellentEnchant implements Chanced, Passiv @Override public void action() { for (LivingEntity entity : this.getEntities()) { - EnchantManager.getEquippedEnchants(entity, EnchantRegrowth.class).forEach((item, enchants) -> { + EnchantUtils.getEquipped(entity, EnchantRegrowth.class).forEach((item, enchants) -> { enchants.forEach((enchant, level) -> { if (enchant.isOutOfCharges(item)) return; if (enchant.onTrigger(entity, item, level)) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSaturation.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSaturation.java index 47a898b..d98bae4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSaturation.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSaturation.java @@ -10,12 +10,12 @@ import su.nexmedia.engine.api.manager.ICleanable; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import su.nightexpress.excellentenchants.enchantment.task.AbstractEnchantmentTask; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.function.UnaryOperator; @@ -35,6 +35,9 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan public EnchantSaturation(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Restores " + PLACEHOLDER_SATURATION_AMOUNT + " food points every " + PLACEHOLDER_SATURATION_INTERVAL + "s."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.5); } @Override @@ -112,7 +115,7 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan @Override public void action() { for (LivingEntity entity : this.getEntities()) { - EnchantManager.getEquippedEnchants(entity, EnchantSaturation.class).forEach((item, enchants) -> { + EnchantUtils.getEquipped(entity, EnchantSaturation.class).forEach((item, enchants) -> { enchants.forEach((enchant, level) -> { if (enchant.isOutOfCharges(item)) return; if (enchant.onTrigger(entity, item, level)) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSelfDestruction.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSelfDestruction.java index 1ec305a..2d836c9 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSelfDestruction.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSelfDestruction.java @@ -13,10 +13,10 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; @@ -34,13 +34,18 @@ public class EnchantSelfDestruction extends ExcellentEnchant implements Chanced, public EnchantSelfDestruction(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("%enchantment_trigger_chance%% chance to create an explosion on death."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.3); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); - this.explosionSize = EnchantScaler.read(this, "Settings.Explosion.Size", "1.0" + Placeholders.ENCHANTMENT_LEVEL, + this.chanceImplementation = ChanceImplementation.create(this, + "20.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 10"); + this.explosionSize = EnchantScaler.read(this, "Settings.Explosion.Size", + "1.0" + Placeholders.ENCHANTMENT_LEVEL, "A size of the explosion. The more size - the bigger the damage."); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSonic.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSonic.java index 24364db..4be2cda 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSonic.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSonic.java @@ -6,16 +6,36 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantSonic extends PotionEnchant implements PassiveEnchant { +public class EnchantSonic extends ExcellentEnchant implements Potioned, PassiveEnchant { public static final String ID = "sonic"; + private PotionImplementation potionImplementation; + public EnchantSonic(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.SPEED, true); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Grants permanent " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " effect."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.3); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.SPEED, true); + } + + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantBomber.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantBomber.java index 0d1aa2f..9cd1839 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantBomber.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantBomber.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; +import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; @@ -12,10 +13,10 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; @@ -31,13 +32,27 @@ public class EnchantBomber extends ExcellentEnchant implements Chanced, BowEncha public EnchantBomber(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGHEST); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch TNT that explodes in " + PLACEHOLDER_FUSE_TICKS + "s."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.7); + this.getDefaults().setConflicts( + EnchantEnderBow.ID, EnchantGhast.ID, + EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, + EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID, + EnchantHover.ID, + Enchantment.ARROW_FIRE.getKey().getKey(), + Enchantment.ARROW_KNOCKBACK.getKey().getKey(), + Enchantment.ARROW_DAMAGE.getKey().getKey() + ); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); - this.fuseTicks = EnchantScaler.read(this, "Settings.Fuse_Ticks", "100 - " + Placeholders.ENCHANTMENT_LEVEL + " * 10", + this.chanceImplementation = ChanceImplementation.create(this, + "5.0 * " + Placeholders.ENCHANTMENT_LEVEL); + this.fuseTicks = EnchantScaler.read(this, "Settings.Fuse_Ticks", + "100 - " + Placeholders.ENCHANTMENT_LEVEL + " * 10", "Sets fuse ticks (before it will explode) for the launched TNT."); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantConfusingArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantConfusingArrows.java index eeebde6..1061945 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantConfusingArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantConfusingArrows.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; +import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.Arrow; @@ -11,31 +12,48 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantConfusingArrows extends PotionEnchant implements Chanced, Arrowed, BowEnchant { +public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { public static final String ID = "confusing_arrows"; private ArrowImplementation arrowImplementation; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantConfusingArrows(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.CONFUSION, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)"); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.1); + this.getDefaults().setConflicts( + EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID, EnchantHover.ID, + EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, + EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID + ); } @Override public void loadConfig() { super.loadConfig(); - this.arrowImplementation = ArrowImplementation.create(this); - this.chanceImplementation = ChanceImplementation.create(this); + this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.SPELL_MOB)); + this.chanceImplementation = ChanceImplementation.create(this, + "20.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5.0"); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.CONFUSION, false, + "6.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 3.0", + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -50,6 +68,12 @@ public class EnchantConfusingArrows extends PotionEnchant implements Chanced, Ar return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantDragonfireArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantDragonfireArrows.java index ef630c5..a14aca5 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantDragonfireArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantDragonfireArrows.java @@ -16,14 +16,15 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.projectiles.ProjectileSource; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; @@ -45,16 +46,28 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced public EnchantDragonfireArrows(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an dragonfire arrow (R=" + PLACEHOLDER_FIRE_RADIUS + ", " + PLACEHOLDER_FIRE_DURATION + "s)."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.7); + + this.getDefaults().setConflicts( + EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, + EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, + EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID + ); } @Override public void loadConfig() { super.loadConfig(); - this.arrowImplementation = ArrowImplementation.create(this); - this.chanceImplementation = ChanceImplementation.create(this); - this.fireDuration = EnchantScaler.read(this, "Settings.Fire.Duration", "100 * " + Placeholders.ENCHANTMENT_LEVEL, + this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.DRAGON_BREATH)); + this.chanceImplementation = ChanceImplementation.create(this, + "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); + this.fireDuration = EnchantScaler.read(this, "Settings.Fire.Duration", + "100 * " + Placeholders.ENCHANTMENT_LEVEL, "Sets the dragonfire cloud effect duration (in ticks). 20 ticks = 1 second."); - this.fireRadius = EnchantScaler.read(this, "Settings.Fire.Radius", "2.0 + " + Placeholders.ENCHANTMENT_LEVEL, + this.fireRadius = EnchantScaler.read(this, "Settings.Fire.Radius", + "2.0 + " + Placeholders.ENCHANTMENT_LEVEL, "Sets the dragonfire cloud effect radius."); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantElectrifiedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantElectrifiedArrows.java index bd26d58..fed3c1c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantElectrifiedArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantElectrifiedArrows.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; +import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.enchantments.EnchantmentTarget; @@ -15,16 +16,17 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.LocationUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chanced, Arrowed, BowEnchant { @@ -37,13 +39,23 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance public EnchantElectrifiedArrows(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an electrified arrow."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.3); + + this.getDefaults().setConflicts( + EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, + EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, + EnchantWitheredArrows.ID, EnchantDragonfireArrows.ID + ); } @Override public void loadConfig() { super.loadConfig(); - this.arrowImplementation = ArrowImplementation.create(this); - this.chanceImplementation = ChanceImplementation.create(this); + this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.FIREWORKS_SPARK)); + this.chanceImplementation = ChanceImplementation.create(this, + "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); } @NotNull @@ -79,8 +91,9 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance Block block = e.getHitBlock(); block.getWorld().strikeLightning(block.getLocation()).setMetadata(META_NO_ITEM_DAMAGE, new FixedMetadataValue(plugin, true)); if (this.hasVisualEffects()) { - EffectUtil.playEffect(LocationUtil.getCenter(block.getLocation()), Particle.BLOCK_CRACK, block.getType().name(), 1D, 1D, 1D, 0.05, 150); - EffectUtil.playEffect(LocationUtil.getCenter(block.getLocation()), Particle.FIREWORKS_SPARK, "", 1D, 1D, 1D, 0.05, 150); + Location center = LocationUtil.getCenter(block.getLocation()); + SimpleParticle.of(Particle.BLOCK_CRACK, block.getType()).play(center, 1, 0.05, 120); + SimpleParticle.of(Particle.FIREWORKS_SPARK).play(center, 1, 0.05, 120); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantEnderBow.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantEnderBow.java index 32ac5a5..9b6f048 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantEnderBow.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantEnderBow.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; +import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.EnderPearl; import org.bukkit.entity.LivingEntity; @@ -10,10 +11,10 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Chanced { @@ -24,12 +25,25 @@ public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Cha public EnchantEnderBow(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGHEST); + this.getDefaults().setDescription("Shoots ender pearls instead of arrows."); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(1.0); + + this.getDefaults().setConflicts( + EnchantBomber.ID, EnchantGhast.ID, + EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, + EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID, + EnchantHover.ID, + Enchantment.ARROW_FIRE.getKey().getKey(), + Enchantment.ARROW_KNOCKBACK.getKey().getKey(), + Enchantment.ARROW_DAMAGE.getKey().getKey() + ); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, "100"); } @NotNull diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantExplosiveArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantExplosiveArrows.java index 9686a5d..2a86755 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantExplosiveArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantExplosiveArrows.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; +import org.bukkit.Particle; import org.bukkit.World; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.*; @@ -13,14 +14,15 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; @@ -44,20 +46,31 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, public EnchantExplosiveArrows(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an explosive arrow."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.7); + + this.getDefaults().setConflicts( + EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, + EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, + EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID + ); } @Override public void loadConfig() { super.loadConfig(); - this.arrowImplementation = ArrowImplementation.create(this); - this.chanceImplementation = ChanceImplementation.create(this); + this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.SMOKE_NORMAL)); + this.chanceImplementation = ChanceImplementation.create(this, + "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); this.explosionFireSpread = JOption.create("Settings.Explosion.Fire_Spread", true, "When 'true' creates fire on nearby blocks.").read(cfg); this.explosionDamageItems = JOption.create("Settings.Explosion.Damage_Items", false, "When 'true' inflicts damage to items on the ground.").read(cfg); this.explosionDamageBlocks = JOption.create("Settings.Explosion.Damage_Blocks", false, "When 'true' allows to break blocks by explosion.").read(cfg); - this.explosionSize = EnchantScaler.read(this, "Settings.Explosion.Size", "2.0 + " + Placeholders.ENCHANTMENT_LEVEL, + this.explosionSize = EnchantScaler.read(this, "Settings.Explosion.Size", + "2.0 + " + Placeholders.ENCHANTMENT_LEVEL, "Sets the explosion size. The more size - the bigger explosion."); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantGhast.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantGhast.java index f0f8367..96982b3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantGhast.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantGhast.java @@ -14,13 +14,13 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chanced { @@ -32,12 +32,25 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance public EnchantGhast(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGHEST); + this.getDefaults().setDescription("Shoots fireballs instead of arrows."); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(0.3); + + this.getDefaults().setConflicts( + EnchantEnderBow.ID, EnchantBomber.ID, + EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, + EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID, + EnchantHover.ID, + Enchantment.ARROW_FIRE.getKey().getKey(), + Enchantment.ARROW_KNOCKBACK.getKey().getKey(), + Enchantment.ARROW_DAMAGE.getKey().getKey() + ); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, "100"); this.fireSpread = JOption.create("Settings.Fire_Spread", true, "When 'true' creates fire on nearby blocks.").read(cfg); this.yield = EnchantScaler.read(this, "Settings.Yield", "1.0 + " + Placeholders.ENCHANTMENT_LEVEL, @@ -74,7 +87,7 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance // Shoot small fireballs for the Multishot enchantment, // as large ones has a slow speed and punches each other on shoot. - if (EnchantManager.hasEnchantment(bow, Enchantment.MULTISHOT)) { + if (EnchantUtils.contains(bow, Enchantment.MULTISHOT)) { fireball = shooter.launchProjectile(SmallFireball.class); fireball.setVelocity(projectile.getVelocity().normalize().multiply(0.5f)); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantHover.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantHover.java index 76e187d..f1ecdec 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantHover.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantHover.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; +import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.Arrow; @@ -11,31 +12,48 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantHover extends PotionEnchant implements Chanced, Arrowed, BowEnchant { +public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { public static final String ID = "hover"; private ArrowImplementation arrowImplementation; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantHover(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.LEVITATION, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)"); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.1); + this.getDefaults().setConflicts( + EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID, + EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, + EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID + ); } @Override public void loadConfig() { super.loadConfig(); - this.arrowImplementation = ArrowImplementation.create(this); - this.chanceImplementation = ChanceImplementation.create(this); + this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.BUBBLE_POP)); + this.chanceImplementation = ChanceImplementation.create(this, + "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.LEVITATION, false, + "2.5 + " + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -50,6 +68,12 @@ public class EnchantHover extends PotionEnchant implements Chanced, Arrowed, Bow return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantPoisonedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantPoisonedArrows.java index e05ca02..78e3a45 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantPoisonedArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantPoisonedArrows.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; +import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.Arrow; @@ -11,31 +12,49 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantPoisonedArrows extends PotionEnchant implements Chanced, Arrowed, BowEnchant { +public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { public static final String ID = "poisoned_arrows"; private ArrowImplementation arrowImplementation; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantPoisonedArrows(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.POISON, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)"); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.1); + + this.getDefaults().setConflicts( + EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, + EnchantExplosiveArrows.ID, EnchantConfusingArrows.ID, + EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID + ); } @Override public void loadConfig() { super.loadConfig(); - this.arrowImplementation = ArrowImplementation.create(this); - this.chanceImplementation = ChanceImplementation.create(this); + this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.SLIME)); + this.chanceImplementation = ChanceImplementation.create(this, + "25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.POISON, false, + "2.5 + " + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -50,6 +69,12 @@ public class EnchantPoisonedArrows extends PotionEnchant implements Chanced, Arr return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantWitheredArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantWitheredArrows.java index 9f8eca4..dd7def6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantWitheredArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantWitheredArrows.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; +import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.Arrow; @@ -11,31 +12,49 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantWitheredArrows extends PotionEnchant implements Chanced, Arrowed, BowEnchant { +public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { public static final String ID = "withered_arrows"; private ArrowImplementation arrowImplementation; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantWitheredArrows(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.WITHER, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)"); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.5); + + this.getDefaults().setConflicts( + EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, + EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, + EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID + ); } @Override public void loadConfig() { super.loadConfig(); - this.arrowImplementation = ArrowImplementation.create(this); - this.chanceImplementation = ChanceImplementation.create(this); + this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.SPELL_WITCH)); + this.chanceImplementation = ChanceImplementation.create(this, + "15.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5.0"); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.WITHER, false, + "2.5 + " + Placeholders.ENCHANTMENT_LEVEL + " * 0.75", + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -50,6 +69,12 @@ public class EnchantWitheredArrows extends PotionEnchant implements Chanced, Arr return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SpeedFishingEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SpeedFishingEnchant.java new file mode 100644 index 0000000..50c8b8b --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SpeedFishingEnchant.java @@ -0,0 +1,5 @@ +package su.nightexpress.excellentenchants.enchantment.impl.fishing; + +public class SpeedFishingEnchant { + +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/ArrowImplementation.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/ArrowImplementation.java index 944e9c9..7903f4f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/ArrowImplementation.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/ArrowImplementation.java @@ -7,9 +7,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.PDCUtil; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; import su.nightexpress.excellentenchants.enchantment.task.ArrowTrailsTask; @@ -20,29 +21,30 @@ public final class ArrowImplementation implements Arrowed { private final ExcellentEnchant enchant; private final NamespacedKey projectileKey; - private final Particle trailParticle; - private final String trailData; + private final SimpleParticle trailParticle; - private ArrowImplementation(@NotNull ExcellentEnchant enchant, - @Nullable Particle trailParticle, @Nullable String trailData) { + private ArrowImplementation(@NotNull ExcellentEnchant enchant, @Nullable SimpleParticle trailParticle) { this.enchant = enchant; this.projectileKey = new NamespacedKey(ExcellentEnchantsAPI.PLUGIN, "arrow.enchant_id"); - this.trailParticle = trailParticle; - this.trailData = trailData; } @NotNull public static ArrowImplementation create(@NotNull ExcellentEnchant enchant) { - JYML cfg = enchant.getConfig(); - Particle trailParticle = JOption.create("Settings.Arrow.Trail_Effect.Name", Particle.class, Particle.REDSTONE, - "Particle name for the arrow trail effect.", - "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html").read(cfg); - String trailData = JOption.create("Settings.Arrow.Trail_Effect.Data", "", - "Particle data for the particle effect.", - "This is required for certain particles only.").read(cfg); + return create(enchant, SimpleParticle.of(Particle.REDSTONE)); + } - return new ArrowImplementation(enchant, trailParticle, trailData); + @NotNull + public static ArrowImplementation create(@NotNull ExcellentEnchant enchant, @NotNull SimpleParticle particle) { + JYML cfg = enchant.getConfig(); + + SimpleParticle effect = new JOption<>("Settings.Arrow.Trail_Effect", + (cfg1, path, def) -> SimpleParticle.read(cfg1, path), + particle, + "Sets particle effect for the arrow trail of this enchantment." + ).setWriter((cfg1, path, particle1) -> SimpleParticle.write(particle1, cfg1, path)).read(cfg); + + return new ArrowImplementation(enchant, effect); } @Override @@ -56,24 +58,17 @@ public final class ArrowImplementation implements Arrowed { if (!this.enchant.hasVisualEffects()) return; if (this.getTrailParticle().isEmpty()) return; - Particle particle = this.getTrailParticle().get(); - String data = this.getTrailData().orElse(""); - - ArrowTrailsTask.add(projectile, particle, data); + this.getTrailParticle().ifPresent(particle -> { + ArrowTrailsTask.add(projectile, particle); + }); } @NotNull @Override - public Optional getTrailParticle() { + public Optional getTrailParticle() { return trailParticle == null ? Optional.empty() : Optional.of(trailParticle); } - @NotNull - @Override - public Optional getTrailData() { - return trailData == null ? Optional.empty() : Optional.of(trailData); - } - @NotNull public NamespacedKey getProjectileKey() { return projectileKey; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/ChanceImplementation.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/ChanceImplementation.java index 02ef093..165121b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/ChanceImplementation.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/ChanceImplementation.java @@ -2,14 +2,12 @@ package su.nightexpress.excellentenchants.enchantment.impl.meta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.random.Rnd; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; public final class ChanceImplementation implements Chanced { - public static final String PLACEHOLDER_CHANCE = "%enchantment_trigger_chance%"; - //private final ExcellentEnchant enchant; private final EnchantScaler triggerChance; @@ -20,7 +18,12 @@ public final class ChanceImplementation implements Chanced { @NotNull public static ChanceImplementation create(@NotNull ExcellentEnchant enchant) { - return new ChanceImplementation(enchant, EnchantScaler.read(enchant, "Settings.Trigger_Chance", "100", + return create(enchant, "100"); + } + + @NotNull + public static ChanceImplementation create(@NotNull ExcellentEnchant enchant, @NotNull String def) { + return new ChanceImplementation(enchant, EnchantScaler.read(enchant, "Settings.Trigger_Chance", def, "A chance that this enchantment will be triggered.")); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PotionImplementation.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PotionImplementation.java index 84a9c03..d089168 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PotionImplementation.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PotionImplementation.java @@ -6,30 +6,26 @@ import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; public final class PotionImplementation implements Potioned { - public static final String PLACEHOLDER_POTION_LEVEL = "%enchantment_potion_level%"; - public static final String PLACEHOLDER_POTION_DURATION = "%enchantment_potion_duration%"; - public static final String PLACEHOLDER_POTION_TYPE = "%enchantment_potion_type%"; - //private final ExcellentEnchant enchant; private final PotionEffectType effectType; private final Scaler duration; private final Scaler amplifier; private final boolean isPermanent; - private PotionImplementation(@NotNull ExcellentEnchant enchant, @NotNull PotionEffectType effectType, boolean isPermanent) { + private PotionImplementation(@NotNull ExcellentEnchant enchant, + @NotNull PotionEffectType effectType, boolean isPermanent, + @NotNull EnchantScaler duration, @NotNull EnchantScaler amplifier) { //this.enchant = enchant; this.effectType = effectType; - this.duration = EnchantScaler.read(enchant, "Settings.Potion_Effect.Duration", "5.0 * " + Placeholders.ENCHANTMENT_LEVEL, - "Potion effect duration (in seconds). This setting is useless for 'permanent' effects."); - this.amplifier = EnchantScaler.read(enchant, "Settings.Potion_Effect.Level", Placeholders.ENCHANTMENT_LEVEL, - "Potion effect level."); + this.duration = duration; + this.amplifier = amplifier; this.isPermanent = isPermanent; } @@ -40,7 +36,20 @@ public final class PotionImplementation implements Potioned { } public static PotionImplementation create(@NotNull ExcellentEnchant enchant, @NotNull PotionEffectType type, boolean isPermanent) { - return new PotionImplementation(enchant, type, isPermanent); + return create(enchant, type, isPermanent, "5 * " + Placeholders.ENCHANTMENT_LEVEL, Placeholders.ENCHANTMENT_LEVEL); + } + + public static PotionImplementation create(@NotNull ExcellentEnchant enchant, + @NotNull PotionEffectType type, boolean isPermanent, + @NotNull String duration, @NotNull String amplifier) { + + EnchantScaler durationScale = EnchantScaler.read(enchant, "Settings.Potion_Effect.Duration", duration, + "Potion effect duration (in seconds). This setting is useless for 'permanent' effects."); + + EnchantScaler amplifierScale = EnchantScaler.read(enchant, "Settings.Potion_Effect.Level", amplifier, + "Potion effect level."); + + return new PotionImplementation(enchant, type, isPermanent, durationScale, amplifierScale); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantBlastMining.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantBlastMining.java index 21ac6c2..c254b82 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantBlastMining.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantBlastMining.java @@ -16,14 +16,14 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; -import su.nightexpress.excellentenchants.enchantment.EnchantRegister; +import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; @@ -45,15 +45,22 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo public EnchantBlastMining(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to mine blocks by explosion."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(1.0); + this.getDefaults().setConflicts(EnchantVeinminer.ID, EnchantTunnel.ID); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); - this.explosionPower = EnchantScaler.read(this, "Settings.Explosion.Power", "3.0 + (" + Placeholders.ENCHANTMENT_LEVEL + " - 1.0 * 0.25)", + this.chanceImplementation = ChanceImplementation.create(this, + "20.0 * " + Placeholders.ENCHANTMENT_LEVEL); + this.explosionPower = EnchantScaler.read(this, "Settings.Explosion.Power", + "3.0 + (" + Placeholders.ENCHANTMENT_LEVEL + " - 1.0 * 0.25)", "Explosion power. The more power = the more blocks (area) to explode."); - this.minBlockStrength = EnchantScaler.read(this, "Settings.Min_Block_Strength", "1.5 - " + Placeholders.ENCHANTMENT_LEVEL + " / 10", + this.minBlockStrength = EnchantScaler.read(this, "Settings.Min_Block_Strength", + "1.5 - " + Placeholders.ENCHANTMENT_LEVEL + " / 10", "Minimal block strength value for the enchantment to have effect.", "Block strength value is how long it takes to break the block by a hand.", "For example, a Stone has 3.0 strength."); @@ -101,8 +108,8 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isAvailableToUse(player)) return false; - if (EnchantRegister.VEINMINER != null && EnchantManager.hasEnchantment(item, EnchantRegister.VEINMINER)) return false; - if (EnchantRegister.TUNNEL != null && EnchantManager.hasEnchantment(item, EnchantRegister.TUNNEL)) return false; + if (EnchantRegistry.VEINMINER != null && EnchantUtils.contains(item, EnchantRegistry.VEINMINER)) return false; + if (EnchantRegistry.TUNNEL != null && EnchantUtils.contains(item, EnchantRegistry.TUNNEL)) return false; Block block = e.getBlock(); if (block.hasMetadata(META_EXPLOSION_MINED)) return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfBreaking.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfBreaking.java index 95c2a32..0261b1f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfBreaking.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfBreaking.java @@ -10,12 +10,12 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.function.UnaryOperator; @@ -29,13 +29,18 @@ public class EnchantCurseOfBreaking extends ExcellentEnchant implements Chanced public EnchantCurseOfBreaking(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to consume extra " + PLACEHOLDER_DURABILITY_AMOUNT + " durability points."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0D); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); - this.durabilityAmount = EnchantScaler.read(this, "Settings.Durability_Amount", Placeholders.ENCHANTMENT_LEVEL, + this.chanceImplementation = ChanceImplementation.create(this, + "10.0 * " + Placeholders.ENCHANTMENT_LEVEL); + this.durabilityAmount = EnchantScaler.read(this, "Settings.Durability_Amount", + Placeholders.ENCHANTMENT_LEVEL, "Amount of durability points to be taken from the item."); } @@ -73,7 +78,7 @@ public class EnchantCurseOfBreaking extends ExcellentEnchant implements Chanced if (!this.isAvailableToUse(player)) return; ItemStack item = e.getItem(); - int level = EnchantManager.getEnchantmentLevel(item, this); + int level = EnchantUtils.getLevel(item, this); if (level < 1) return; if (!this.checkTriggerChance(level)) return; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfMisfortune.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfMisfortune.java index f029aad..9f6d407 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfMisfortune.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfMisfortune.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.tool; +import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -9,11 +10,12 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; @@ -26,12 +28,20 @@ public class EnchantCurseOfMisfortune extends ExcellentEnchant implements Chance public EnchantCurseOfMisfortune(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.LOWEST); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to have no drops from blocks or mobs."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0D); + this.getDefaults().setConflicts( + Enchantment.LOOT_BONUS_BLOCKS.getKey().getKey(), + Enchantment.LOOT_BONUS_MOBS.getKey().getKey() + ); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "20.0 * " + Placeholders.ENCHANTMENT_LEVEL); this.dropExp = JOption.create("Settings.Drop_Exp", false, "When 'true' allows to drop exp from mobs/blocks.").read(cfg); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantDivineTouch.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantDivineTouch.java index 68a184d..839e0b1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantDivineTouch.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantDivineTouch.java @@ -18,19 +18,19 @@ import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.Colorizer; -import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.LocationUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantDropContainer; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; +import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, BlockBreakEnchant, BlockDropEnchant { @@ -42,13 +42,19 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo public EnchantDivineTouch(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to mine spawner."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(1.0); + this.getDefaults().setConflicts(EnchantSmelter.ID); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); - this.spawnerName = JOption.create("Settings.Spawner_Item.Name", "&aMob Spawner &7(" + Placeholders.GENERIC_TYPE + ")", + this.chanceImplementation = ChanceImplementation.create(this, + "15.0 * " + Placeholders.ENCHANTMENT_LEVEL); + this.spawnerName = JOption.create("Settings.Spawner_Item.Name", + "&aMob Spawner &7(" + Placeholders.GENERIC_TYPE + ")", "Spawner item display name.", "Placeholder '" + Placeholders.GENERIC_TYPE + "' for the mob type.") .mapReader(Colorizer::apply).read(cfg); @@ -99,7 +105,7 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo Location location = LocationUtil.getCenter(block.getLocation()); if (this.hasVisualEffects()) { - EffectUtil.playEffect(location, Particle.VILLAGER_HAPPY, "", 0.3f, 0.3f, 0.3f, 0.15f, 30); + SimpleParticle.of(Particle.VILLAGER_HAPPY).play(location, 0.3, 0.15, 30); } block.removeMetadata(META_HANDLE, this.plugin); return true; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantHaste.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantHaste.java index ec9b412..1e1699e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantHaste.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantHaste.java @@ -6,16 +6,36 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantHaste extends PotionEnchant implements PassiveEnchant { +public class EnchantHaste extends ExcellentEnchant implements Potioned, PassiveEnchant { public static final String ID = "haste"; + private PotionImplementation potionImplementation; + public EnchantHaste(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.FAST_DIGGING, true); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Grants permanent " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " effect."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.3); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.FAST_DIGGING, true); + } + + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantLuckyMiner.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantLuckyMiner.java index d9b1b36..402c956 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantLuckyMiner.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantLuckyMiner.java @@ -8,10 +8,10 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; @@ -28,13 +28,18 @@ public class EnchantLuckyMiner extends ExcellentEnchant implements Chanced, Bloc public EnchantLuckyMiner(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to gain " + PLACEHOLDER_EXP_MODIFIER + "% more exp from ores."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.1); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); - this.expModifier = EnchantScaler.read(this, "Settings.Exp_Modifier", "1.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 0.5", + this.chanceImplementation = ChanceImplementation.create(this, + "30.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 7.0"); + this.expModifier = EnchantScaler.read(this, "Settings.Exp_Modifier", + "1.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 0.5", "Exp modifier value. The original exp amount will be multiplied on this value."); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantReplanter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantReplanter.java index c9dc4f9..826e2e8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantReplanter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantReplanter.java @@ -17,11 +17,11 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.utils.MessageUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.InteractEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; @@ -43,12 +43,15 @@ public class EnchantReplanter extends ExcellentEnchant implements Chanced, Inter public EnchantReplanter(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGH); + this.getDefaults().setDescription("Automatically replant crops on right click and when harvest."); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(0.3); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, "100"); this.replantOnRightClick = JOption.create("Settings.Replant.On_Right_Click", true, "When 'true', player will be able to replant crops when right-clicking farmland blocks.").read(cfg); this.replantOnPlantBreak = JOption.create("Settings.Replant.On_Plant_Break", true, diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java index de82e2f..894706a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java @@ -25,10 +25,10 @@ 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantDropContainer; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import java.util.ArrayList; @@ -48,6 +48,10 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha public EnchantSilkChest(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGH); + this.getDefaults().setDescription("Drop chests and saves all its content."); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(0.5); + this.keyChest = new NamespacedKey(plugin, ID + ".item"); this.keyItems = new TreeMap<>(); for (int pos = 0; pos < 27; pos++) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSmelter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSmelter.java index 02574e9..2cbe021 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSmelter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSmelter.java @@ -6,26 +6,28 @@ import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.Container; +import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.LocationUtil; import su.nexmedia.engine.utils.MessageUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantDropContainer; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; +import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -import java.util.HashMap; import java.util.Map; +import java.util.Objects; public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDropEnchant { @@ -37,37 +39,39 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr public EnchantSmelter(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to smelt a block/ore."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.3); + this.getDefaults().setConflicts( + EnchantDivineTouch.ID, + Enchantment.SILK_TOUCH.getKey().getKey() + ); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 10"); this.sound = JOption.create("Settings.Sound", Sound.class, Sound.BLOCK_LAVA_EXTINGUISH, "Sound to play on smelting.", "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html").read(cfg); - this.smeltingTable = new HashMap<>(); - for (String sFrom : cfg.getSection("Settings.Smelting_Table")) { - Material mFrom = Material.getMaterial(sFrom.toUpperCase()); - if (mFrom == null) { - plugin.error("[Smelter] Invalid source material '" + sFrom + "' !"); - continue; - } - String sTo = cfg.getString("Settings.Smelting_Table." + sFrom, ""); - Material mTo = Material.getMaterial(sTo.toUpperCase()); - if (mTo == null) { - plugin.error("[Smelter] Invalid result material '" + sTo + "' !"); - continue; - } - this.smeltingTable.put(mFrom, mTo); - } - this.cfg.setComments("Settings.Smelting_Table", + this.smeltingTable = JOption.forMap("Settings.Smelting_Table", + str -> Material.getMaterial(str.toLowerCase()), + (cfg, path, id) -> Material.getMaterial(cfg.getString(path + "." + id, "").toUpperCase()), + Map.of( + Material.RAW_IRON, Material.IRON_INGOT, + Material.RAW_GOLD, Material.GOLD_INGOT + ), "Table of Original -> Smelted items.", "Syntax: 'Material Source : Material Result'.", "Note: Material source is material name of the dropped item, not the broken block!", - "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html"); + "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html" + ).setWriter((cfg, path, map) -> map.forEach((src, to) -> cfg.set(path + "." + src.name(), to.name()))).read(cfg); + this.smeltingTable.keySet().removeIf(Objects::isNull); + this.smeltingTable.values().removeIf(Objects::isNull); } @NotNull @@ -104,7 +108,7 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr if (this.hasVisualEffects()) { Location location = LocationUtil.getCenter(block.getLocation(), true); MessageUtil.sound(location, this.sound); - EffectUtil.playEffect(location, Particle.FLAME, "", 0.2f, 0.2f, 0.2f, 0.05f, 30); + SimpleParticle.of(Particle.FLAME).play(location, 0.25, 0.05, 20); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTelekinesis.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTelekinesis.java index 67ee1fd..66c1371 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTelekinesis.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTelekinesis.java @@ -8,11 +8,11 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.PlayerUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantDropContainer; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; @@ -28,12 +28,15 @@ public class EnchantTelekinesis extends ExcellentEnchant implements Chanced, Blo public EnchantTelekinesis(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.LOWEST); + this.getDefaults().setDescription("Moves all blocks loot directly to your inventory."); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(0.75); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, "100"); } @NotNull diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTreasures.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTreasures.java index df9f323..70146cd 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTreasures.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTreasures.java @@ -1,30 +1,36 @@ package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.Material; +import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.manager.ICleanable; import su.nexmedia.engine.utils.random.Rnd; import su.nexmedia.playerblocktracker.PlayerBlockTracker; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantDropContainer; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import java.util.*; import java.util.function.Predicate; -public class EnchantTreasures extends ExcellentEnchant implements Chanced, BlockDropEnchant, ICleanable { +public class EnchantTreasures extends ExcellentEnchant implements Chanced, BlockBreakEnchant, BlockDropEnchant, ICleanable { public static final String ID = "treasures"; + private static final String META = "wasted"; private Map> treasures; private ChanceImplementation chanceImplementation; @@ -33,19 +39,42 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block public EnchantTreasures(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to attempt to find a treasure in mined block."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.1); PlayerBlockTracker.initialize(plugin); PlayerBlockTracker.BLOCK_FILTERS.add(this.blockTracker = (block) -> { - return !this.getTreasures(block.getType()).isEmpty(); + return this.treasures.containsKey(block.getType()); }); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 4.0"); this.treasures = new HashMap<>(); + + if (cfg.getSection("Settings.Treasures").isEmpty()) { + Tag.BASE_STONE_OVERWORLD.getValues().forEach(material -> { + cfg.addMissing("Settings.Treasures." + material.name() + ".BONE_MEAL", 2.0); + }); + Tag.DIRT.getValues().forEach(material -> { + cfg.addMissing("Settings.Treasures." + material.name() + ".CLAY_BALL", 0.5); + cfg.addMissing("Settings.Treasures." + material.name() + ".BOWL", 1.0); + cfg.addMissing("Settings.Treasures." + material.name() + ".STICK", 2.0); + }); + Tag.SAND.getValues().forEach(material -> { + cfg.addMissing("Settings.Treasures." + material.name() + ".GLOWSTONE_DUST", 1.0); + cfg.addMissing("Settings.Treasures." + material.name() + ".GOLD_NUGGET", 0.3); + }); + Tag.LEAVES.getValues().forEach(material -> { + cfg.addMissing("Settings.Treasures." + material.name() + ".APPLE", 12.0); + }); + } + for (String sFromArray : cfg.getSection("Settings.Treasures")) { for (String sFrom : sFromArray.split(",")) { Material mFrom = Material.getMaterial(sFrom.toUpperCase()); @@ -77,6 +106,7 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block @Override public void clear() { PlayerBlockTracker.BLOCK_FILTERS.remove(this.blockTracker); + PlayerBlockTracker.shutdown(); } @NotNull @@ -97,11 +127,22 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block return EnchantmentTarget.TOOL; } + @Override + public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (PlayerBlockTracker.isTracked(e.getBlock())) { + e.getBlock().setMetadata(META, new FixedMetadataValue(plugin, true)); + } + return false; + } + @Override public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { Block block = e.getBlockState().getBlock(); + if (block.hasMetadata(META)) { + block.removeMetadata(META, plugin); + return false; + } if (!this.isAvailableToUse(player)) return false; - if (PlayerBlockTracker.isTracked(block)) return false; if (!this.checkTriggerChance(level)) return false; dropContainer.getDrop().addAll(this.getTreasures(e.getBlockState().getType())); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTunnel.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTunnel.java index 6fb0a47..a36946d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTunnel.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTunnel.java @@ -1,7 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.Material; -import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.EnchantmentTarget; @@ -11,16 +10,15 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; -import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.LocationUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; -import su.nightexpress.excellentenchants.enchantment.EnchantRegister; +import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; +import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; import java.util.HashSet; import java.util.Set; @@ -42,6 +40,10 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant public EnchantTunnel(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGH); + this.getDefaults().setDescription("Mines multiple blocks at once in a certain shape."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(1.0); + this.getDefaults().setConflicts(EnchantVeinminer.ID, EnchantBlastMining.ID); } @Override @@ -68,8 +70,8 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant Block block = e.getBlock(); if (!this.isAvailableToUse(player)) return false; if (this.disableOnSneak && player.isSneaking()) return false; - if (EnchantRegister.VEINMINER != null && EnchantManager.hasEnchantment(item, EnchantRegister.VEINMINER)) return false; - if (EnchantRegister.BLAST_MINING != null && EnchantManager.hasEnchantment(item, EnchantRegister.BLAST_MINING)) return false; + if (EnchantRegistry.VEINMINER != null && EnchantUtils.contains(item, EnchantRegistry.VEINMINER)) return false; + if (EnchantRegistry.BLAST_MINING != null && EnchantUtils.contains(item, EnchantRegistry.BLAST_MINING)) return false; if (block.hasMetadata(META_BLOCK_TUNNEL)) return false; if (block.getType().isInteractable() && !INTERACTABLE_BLOCKS.contains(block.getType())) return false; if (block.getDrops(item).isEmpty()) return false; @@ -113,8 +115,12 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant if (addType == Material.OBSIDIAN && addType != block.getType()) continue; // Play block break particles before it's broken. + /*SimpleParticle.of(Particle.BLOCK_CRACK, blockAdd.getType()) + .play(damager.getEyeLocation(), 0.25, 0.1, 20); EffectUtil.playEffect(LocationUtil.getCenter(blockAdd.getLocation()), Particle.BLOCK_CRACK.name(), blockAdd.getType().name(), 0.2, 0.2, 0.2, 0.1, 20); + */ + // Add metadata to prevent enchantment triggering in a loop. blockAdd.setMetadata(META_BLOCK_TUNNEL, new FixedMetadataValue(plugin, true)); //plugin.getNMS().breakBlock(player, blockAdd); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantVeinminer.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantVeinminer.java index 8dbbf90..c90f5a3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantVeinminer.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantVeinminer.java @@ -1,7 +1,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.Material; -import org.bukkit.Particle; +import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.EnchantmentTarget; @@ -11,22 +11,19 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; -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.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; -import su.nightexpress.excellentenchants.enchantment.EnchantRegister; +import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; +import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; import java.util.HashSet; -import java.util.Objects; import java.util.Set; import java.util.function.UnaryOperator; import java.util.stream.Collectors; @@ -45,19 +42,39 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch public EnchantVeinminer(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGH); + this.getDefaults().setDescription("Mines up to " + PLACEHOLDER_BLOCK_LIMIT + " blocks of the ore vein at once."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.3); + this.getDefaults().setConflicts(EnchantBlastMining.ID, EnchantTunnel.ID); } @Override public void loadConfig() { super.loadConfig(); - this.blocksLimit = EnchantScaler.read(this, "Settings.Blocks.Max_At_Once", "6 + " + Placeholders.ENCHANTMENT_LEVEL, + this.blocksLimit = EnchantScaler.read(this, "Settings.Blocks.Max_At_Once", + "6 + " + Placeholders.ENCHANTMENT_LEVEL, "How much amount of blocks can be destroted at single use?"); - this.blocksAffected = JOption.create("Settings.Blocks.Affected", new HashSet<>(), + this.blocksAffected = JOption.forSet("Settings.Blocks.Affected", + str -> Material.getMaterial(str.toUpperCase()), + () -> { + Set set = new HashSet<>(); + set.addAll(Tag.COAL_ORES.getValues()); + set.addAll(Tag.COPPER_ORES.getValues()); + set.addAll(Tag.DIAMOND_ORES.getValues()); + set.addAll(Tag.EMERALD_ORES.getValues()); + set.addAll(Tag.GOLD_ORES.getValues()); + set.addAll(Tag.IRON_ORES.getValues()); + set.addAll(Tag.LAPIS_ORES.getValues()); + set.addAll(Tag.REDSTONE_ORES.getValues()); + set.add(Material.NETHER_GOLD_ORE); + set.add(Material.NETHER_QUARTZ_ORE); + return set; + }, "List of blocks, that will be affected by this enchantment.", - "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html").read(cfg).stream() - .map(type -> Material.getMaterial(type.toUpperCase())).filter(Objects::nonNull).collect(Collectors.toSet()); + "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html" + ).setWriter((cfg, path, set) -> cfg.set(path, set.stream().map(Enum::name).toList())).read(cfg); } @NotNull @@ -111,7 +128,7 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch ores.remove(source); ores.forEach(ore -> { // Play block break particles before the block broken. - EffectUtil.playEffect(LocationUtil.getCenter(ore.getLocation()), Particle.BLOCK_CRACK.name(), ore.getType().name(), 0.2, 0.2, 0.2, 0.1, 20); + //EffectUtil.playEffect(LocationUtil.getCenter(ore.getLocation()), Particle.BLOCK_CRACK.name(), ore.getType().name(), 0.2, 0.2, 0.2, 0.1, 20); ore.setMetadata(META_BLOCK_VEINED, new FixedMetadataValue(plugin, true)); //plugin.getNMS().breakBlock(player, ore); @@ -123,8 +140,8 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch @Override public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack tool, int level) { if (!this.isAvailableToUse(player)) return false; - if (EnchantRegister.TUNNEL != null && EnchantManager.hasEnchantment(tool, EnchantRegister.TUNNEL)) return false; - if (EnchantRegister.BLAST_MINING != null && EnchantManager.hasEnchantment(tool, EnchantRegister.BLAST_MINING)) return false; + if (EnchantRegistry.TUNNEL != null && EnchantUtils.contains(tool, EnchantRegistry.TUNNEL)) return false; + if (EnchantRegistry.BLAST_MINING != null && EnchantUtils.contains(tool, EnchantRegistry.BLAST_MINING)) return false; Block block = e.getBlock(); if (block.hasMetadata(META_BLOCK_VEINED)) return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/EnchantCurseOfFragility.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/EnchantCurseOfFragility.java index 1f87a7e..01a729c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/EnchantCurseOfFragility.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/EnchantCurseOfFragility.java @@ -12,9 +12,9 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; public class EnchantCurseOfFragility extends ExcellentEnchant { @@ -22,6 +22,9 @@ public class EnchantCurseOfFragility extends ExcellentEnchant { public EnchantCurseOfFragility(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Prevents an item from being grindstoned or anviled."); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(0D); } @NotNull @@ -36,8 +39,8 @@ public class EnchantCurseOfFragility extends ExcellentEnchant { ItemStack first = inventory.getItem(0); ItemStack second = inventory.getItem(1); - boolean cursedFirst = (first != null && EnchantManager.getEnchantmentLevel(first, this) >= 1); - boolean cursedSecond = (second != null && EnchantManager.getEnchantmentLevel(second, this) >= 1); + boolean cursedFirst = (first != null && EnchantUtils.getLevel(first, this) >= 1); + boolean cursedSecond = (second != null && EnchantUtils.getLevel(second, this) >= 1); if (cursedFirst || cursedSecond) { e.setResult(null); @@ -65,8 +68,8 @@ public class EnchantCurseOfFragility extends ExcellentEnchant { ItemStack first = inventory.getItem(0); ItemStack second = inventory.getItem(1); - boolean cursedFirst = (first != null && EnchantManager.getEnchantmentLevel(first, this) >= 1); - boolean cursedSecond = (second != null && EnchantManager.getEnchantmentLevel(second, this) >= 1); + boolean cursedFirst = (first != null && EnchantUtils.getLevel(first, this) >= 1); + boolean cursedSecond = (second != null && EnchantUtils.getLevel(second, this) >= 1); if (cursedFirst || cursedSecond) { inventory.setItem(2, null); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBaneOfNetherspawn.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBaneOfNetherspawn.java index 7b38ea4..d452aff 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBaneOfNetherspawn.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBaneOfNetherspawn.java @@ -8,14 +8,14 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import java.util.Set; import java.util.function.UnaryOperator; @@ -38,6 +38,9 @@ public class EnchantBaneOfNetherspawn extends ExcellentEnchant implements Combat public EnchantBaneOfNetherspawn(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Inflicts " + PLACEHOLDER_DAMAGE + " more damage to nether mobs."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.1); } @Override @@ -45,7 +48,8 @@ public class EnchantBaneOfNetherspawn extends ExcellentEnchant implements Combat super.loadConfig(); this.damageModifier = JOption.create("Settings.Damage.As_Modifier", false, "When 'true' multiplies the damage. When 'false' sums plain values.").read(cfg); - this.damageFormula = EnchantScaler.read(this, "Settings.Damage.Amount", "0.5 * " + Placeholders.ENCHANTMENT_LEVEL, + this.damageFormula = EnchantScaler.read(this, "Settings.Damage.Amount", + "0.5 * " + Placeholders.ENCHANTMENT_LEVEL, "Amount of additional damage."); } @@ -75,7 +79,7 @@ public class EnchantBaneOfNetherspawn extends ExcellentEnchant implements Combat double damageAdd = this.getDamageModifier(level); e.setDamage(this.damageModifier ? damageEvent * damageAdd : damageEvent + damageAdd); if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.SMOKE_NORMAL, "", 0.25, 0.25, 0.25, 0.1f, 30); + SimpleParticle.of(Particle.SMOKE_NORMAL).play(victim.getEyeLocation(), 0.25, 0.1, 30); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBlindness.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBlindness.java index ebf35a0..d11c372 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBlindness.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBlindness.java @@ -7,28 +7,39 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -public class EnchantBlindness extends PotionEnchant implements Chanced, CombatEnchant { +public class EnchantBlindness extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { public static final String ID = "blindness"; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantBlindness(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.BLINDNESS, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to apply " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) on hit."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.1); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "15.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 3"); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.BLINDNESS, false, + "3.5 + " + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -37,6 +48,12 @@ public class EnchantBlindness extends PotionEnchant implements Chanced, CombatEn return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { @@ -50,7 +67,7 @@ public class EnchantBlindness extends PotionEnchant implements Chanced, CombatEn if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.SMOKE_NORMAL, "", 0.25, 0.25, 0.25, 0.1f, 30); + SimpleParticle.of(Particle.SMOKE_NORMAL).play(victim.getEyeLocation(), 0.25, 0.1, 30); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantConfusion.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantConfusion.java index b31e5ef..b68b89d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantConfusion.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantConfusion.java @@ -8,28 +8,39 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -public class EnchantConfusion extends PotionEnchant implements Chanced, CombatEnchant { +public class EnchantConfusion extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { public static final String ID = "confusion"; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantConfusion(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.CONFUSION, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to apply " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) on hit."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.1); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "15.0 * " + Placeholders.ENCHANTMENT_LEVEL); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.CONFUSION, false, + "5.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 1.5", + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -38,6 +49,12 @@ public class EnchantConfusion extends PotionEnchant implements Chanced, CombatEn return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { @@ -51,7 +68,8 @@ public class EnchantConfusion extends PotionEnchant implements Chanced, CombatEn if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.ITEM_CRACK, Material.ROTTEN_FLESH.name(), 0.25, 0.25, 0.25, 0.1f, 30); + SimpleParticle.of(Particle.ITEM_CRACK, Material.ROTTEN_FLESH) + .play(victim.getEyeLocation(), 0.25, 0.1, 30); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCure.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCure.java index 90efddd..6a5813a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCure.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCure.java @@ -7,13 +7,14 @@ import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import java.util.Set; @@ -27,12 +28,16 @@ public class EnchantCure extends ExcellentEnchant implements Chanced, CombatEnch public EnchantCure(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to cure Zombified Piglins and Zombie Villagers on hit."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.5); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "20.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 8"); } @NotNull @@ -57,7 +62,7 @@ public class EnchantCure extends ExcellentEnchant implements Chanced, CombatEnch e.setCancelled(true); if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.CLOUD, "", 0.25, 0.25, 0.25, 0.1f, 30); + SimpleParticle.of(Particle.CLOUD).play(victim.getEyeLocation(), 0.25, 0.1, 30); } if (victim instanceof PigZombie pigZombie) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCutter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCutter.java index b901c0f..2cb403f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCutter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCutter.java @@ -11,18 +11,18 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.MessageUtil; import su.nexmedia.engine.utils.NumberUtil; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import java.util.function.UnaryOperator; @@ -36,13 +36,18 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn public EnchantCutter(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.LOWEST); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to throw away enemy''s armor and damage it for " + PLACEHOLDER_DURABILITY_DAMAGE + "%."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.75); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); - this.durabilityReduction = EnchantScaler.read(this, "Settings.Item.Durability_Reduction", Placeholders.ENCHANTMENT_LEVEL + " / 100", + this.chanceImplementation = ChanceImplementation.create(this, + "1.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 0.6"); + this.durabilityReduction = EnchantScaler.read(this, "Settings.Item.Durability_Reduction", + Placeholders.ENCHANTMENT_LEVEL + " / 100", "Amount (in percent) of how much item durability will be reduced."); } @@ -99,7 +104,7 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn drop.getVelocity().multiply(3D); if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.ITEM_CRACK.name(), itemCut.getType().name(), 0.2f, 0.15f, 0.2f, 0.15f, 40); + SimpleParticle.of(Particle.ITEM_CRACK, itemCut.getType()).play(victim.getEyeLocation(), 0.25, 0.15, 30); MessageUtil.sound(victim.getLocation(), Sound.ENTITY_ITEM_BREAK); } return true; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDecapitator.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDecapitator.java index 5a28bbd..66e8be4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDecapitator.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDecapitator.java @@ -18,6 +18,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.lang.LangManager; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.ItemUtil; @@ -25,47 +26,131 @@ import su.nexmedia.engine.utils.PDCUtil; import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; public class EnchantDecapitator extends ExcellentEnchant implements Chanced, DeathEnchant { public static final String ID = "decapitator"; - private Set ignoredEntityTypes; - private String headName; - private Map headTextures; + private Set ignoredEntityTypes; + private String headName; + private Map headTextures; + private ChanceImplementation chanceImplementation; private final NamespacedKey skullKey; public EnchantDecapitator(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to obtain player''s or mob''s head."); + this.getDefaults().setLevelMax(4); + this.getDefaults().setTier(0.75); + this.skullKey = new NamespacedKey(plugin, this.getId() + ".entity_type"); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "5.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 1.75"); - this.ignoredEntityTypes = JOption.create("Settings.Ignored_Entity_Types", new HashSet<>(), - "List of entities, that won't drop heads.").read(cfg).stream().map(String::toUpperCase).collect(Collectors.toSet()); + this.ignoredEntityTypes = JOption.forSet("Settings.Ignored_Entity_Types", + str -> StringUtil.getEnum(str, EntityType.class).orElse(null), + () -> Set.of( + EntityType.BAT, EntityType.BEE, EntityType.ENDER_DRAGON, EntityType.WITHER, EntityType.WITHER_SKELETON + ), + "List of entities, that won't drop heads." + ).setWriter((cfg, path, set) -> cfg.set(path, set.stream().map(Enum::name).toList())).read(cfg); this.headName = JOption.create("Settings.Head_Item.Name", "&c" + Placeholders.GENERIC_TYPE + "'s Head", "Head item display name. Use '" + Placeholders.GENERIC_TYPE + "' for entity name.").read(cfg); - this.headTextures = new HashMap<>(); - for (String sType : cfg.getSection("Settings.Head_Item.Textures")) { + this.headTextures = JOption.forMap("Settings.Head_Item.Textures", + id -> StringUtil.getEnum(id, EntityType.class).orElse(null), + (cfg, path, id) -> cfg.getString(path + "." + id), + () -> { + Map map = new HashMap<>(); + map.put(EntityType.AXOLOTL, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNThkYTFhMGEyYTEzZGQyMDliZmMyNTI5ZDljN2MyOWEyOWRkOWEyM2ZmNGI4MGIzOGI4OTk2MTc3MmU4MDM5ZSJ9fX0="); + map.put(EntityType.BAT, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWU5OWRlZWY5MTlkYjY2YWMyYmQyOGQ2MzAyNzU2Y2NkNTdjN2Y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jZjg5NzNhIn19fQ=="); + return map; + }, + "Head texture values for each entity type.", + "You can take some from http://minecraft-heads.com", + "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html" + ).setWriter((cfg, path, map) -> map.forEach((type, txt) -> cfg.set(path + "." + type.name(), txt))).read(cfg); + + /*for (String sType : cfg.getSection("Settings.Head_Item.Textures")) { this.headTextures.put(sType.toUpperCase(), cfg.getString("Settings.Head_Item.Textures." + sType, "")); } this.cfg.setComments("Settings.Head_Item.Textures", @@ -73,7 +158,7 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea "You can take some from http://minecraft-heads.com", "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html"); - /*this.headTextures = new JOption>("Settings.Head_Item.Textures", + this.headTextures = new JOption>("Settings.Head_Item.Textures", (cfg, path, def) -> cfg.getSection(path).stream().collect(Collectors.toMap(String::toUpperCase, v -> cfg.getString(path + "." + v, ""))), HashMap::new, "Head texture values for each entity type.", @@ -103,7 +188,7 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea if (!this.isAvailableToUse(entity)) return false; EntityType entityType = entity.getType(); - if (this.ignoredEntityTypes.contains(entityType.name())) return false; + if (this.ignoredEntityTypes.contains(entityType)) return false; if (!this.checkTriggerChance(level)) return false; ItemStack item; @@ -133,7 +218,7 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea meta.setOwningPlayer(player); } else { - String texture = this.headTextures.get(entity.getType().name()); + String texture = this.headTextures.get(entity.getType()); if (texture == null) return false; entityName = this.headName.replace(Placeholders.GENERIC_TYPE, plugin.getLangManager().getEnum(entity.getType())); @@ -149,7 +234,7 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea entity.getWorld().dropItemNaturally(entity.getLocation(), item); if (this.hasVisualEffects()) { - EffectUtil.playEffect(entity.getEyeLocation(), Particle.BLOCK_CRACK, Material.REDSTONE_BLOCK.name(), 0.2f, 0.15f, 0.2f, 0.15f, 40); + SimpleParticle.of(Particle.BLOCK_CRACK, Material.REDSTONE_BLOCK).play(entity.getEyeLocation(), 0.25, 0.15, 30); } return true; } @@ -170,12 +255,12 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea if (!(e.getBlockState() instanceof Skull skull)) return; PDCUtil.getString(skull, this.skullKey).ifPresent(type -> { - String texture = this.headTextures.get(type); - if (texture == null) return; - EntityType entityType = StringUtil.getEnum(type, EntityType.class).orElse(null); if (entityType == null) return; + String texture = this.headTextures.get(entityType); + if (texture == null) return; + e.getItems().forEach(item -> { ItemStack drop = item.getItemStack(); if (drop.getType() == Material.PLAYER_HEAD) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDoubleStrike.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDoubleStrike.java index 218838a..dc30d1b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDoubleStrike.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDoubleStrike.java @@ -7,14 +7,15 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.MessageUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantDoubleStrike extends ExcellentEnchant implements Chanced, CombatEnchant { @@ -24,12 +25,16 @@ public class EnchantDoubleStrike extends ExcellentEnchant implements Chanced, Co public EnchantDoubleStrike(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.LOW); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to inflict double damage."); + this.getDefaults().setLevelMax(4); + this.getDefaults().setTier(1.0); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "4.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 0.8"); } @NotNull @@ -52,7 +57,7 @@ public class EnchantDoubleStrike extends ExcellentEnchant implements Chanced, Co e.setDamage(e.getDamage() * 2D); if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.EXPLOSION_NORMAL, "", 0.2f, 0.15f, 0.2f, 0.15f, 20); + SimpleParticle.of(Particle.EXPLOSION_NORMAL).play(victim.getEyeLocation(), 0.25, 0.15, 15); MessageUtil.sound(victim.getLocation(), Sound.ENTITY_GENERIC_EXPLODE); } return true; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExhaust.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExhaust.java index 921e238..e611e9d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExhaust.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExhaust.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; +import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; @@ -7,28 +8,39 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -public class EnchantExhaust extends PotionEnchant implements Chanced, CombatEnchant { +public class EnchantExhaust extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { public static final String ID = "exhaust"; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantExhaust(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.HUNGER, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to apply " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) on hit."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.1); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "20.0 * " + Placeholders.ENCHANTMENT_LEVEL); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.HUNGER, false, + "3.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 1.5", + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -37,6 +49,12 @@ public class EnchantExhaust extends PotionEnchant implements Chanced, CombatEnch return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { @@ -50,7 +68,7 @@ public class EnchantExhaust extends PotionEnchant implements Chanced, CombatEnch if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.SPELL_MOB, "60,180,20", 0.2f, 0.15f, 0.2f, 0.15f, 20); + SimpleParticle.of(Particle.ITEM_CRACK, Material.ROTTEN_FLESH).play(victim.getEyeLocation(), 0.25, 0.1, 30); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExpHunter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExpHunter.java index 99a0b8d..ce88174 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExpHunter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExpHunter.java @@ -8,9 +8,9 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import java.util.function.UnaryOperator; @@ -24,12 +24,16 @@ public class EnchantExpHunter extends ExcellentEnchant implements DeathEnchant { public EnchantExpHunter(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Increases exp drop from mobs by " + PLACEHOLDER_EXP_MODIFIER + "%."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.3); } @Override public void loadConfig() { super.loadConfig(); - this.expModifier = EnchantScaler.read(this, "Settings.Exp_Modifier", "1.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 0.5", + this.expModifier = EnchantScaler.read(this, "Settings.Exp_Modifier", + "1.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 0.5", "Exp modifier value. The original exp amount will be multiplied on this value."); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantIceAspect.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantIceAspect.java index a4bf992..04b07a1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantIceAspect.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantIceAspect.java @@ -8,18 +8,50 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -public class EnchantIceAspect extends PotionEnchant implements CombatEnchant { +public class EnchantIceAspect extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { public static final String ID = "ice_aspect"; + private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; + public EnchantIceAspect(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.SLOW, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Freezes and applies " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) on hit."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.1); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this, "100"); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.SLOW, false, + "3.0 + " + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; } @NotNull @@ -31,12 +63,13 @@ public class EnchantIceAspect extends PotionEnchant implements CombatEnchant { @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; + if (!this.checkTriggerChance(level)) return false; if (!this.addEffect(victim, level)) return false; victim.setFreezeTicks(victim.getMaxFreezeTicks()); if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.BLOCK_CRACK, Material.ICE.name(), 0.25, 0.25, 0.25, 0.1f, 30); + SimpleParticle.of(Particle.BLOCK_CRACK, Material.ICE).play(victim.getEyeLocation(), 0.25, 0.15, 30); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantInfernus.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantInfernus.java index 51942b0..b4bf5dc 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantInfernus.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantInfernus.java @@ -13,10 +13,10 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.function.UnaryOperator; @@ -29,12 +29,16 @@ public class EnchantInfernus extends ExcellentEnchant { public EnchantInfernus(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Launched trident will ignite the enemy for " + PLACEHOLDER_FIRE_DURATION + "s. on hit."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.1); } @Override public void loadConfig() { super.loadConfig(); - this.fireTicks = EnchantScaler.read(this, "Settings.Fire_Ticks", "60 + " + Placeholders.ENCHANTMENT_LEVEL + " * 20", + this.fireTicks = EnchantScaler.read(this, "Settings.Fire_Ticks", + "60 + " + Placeholders.ENCHANTMENT_LEVEL + " * 20", "Sets for how long (in ticks) entity will be ignited on hit. 20 ticks = 1 second."); } @@ -65,7 +69,7 @@ public class EnchantInfernus extends ExcellentEnchant { ItemStack item = trident.getItem(); - int level = EnchantManager.getEnchantmentLevel(item, this); + int level = EnchantUtils.getLevel(item, this); if (level <= 0) return; trident.setFireTicks(Integer.MAX_VALUE); @@ -78,7 +82,7 @@ public class EnchantInfernus extends ExcellentEnchant { ItemStack item = trident.getItem(); - int level = EnchantManager.getEnchantmentLevel(item, this); + int level = EnchantUtils.getLevel(item, this); if (level <= 0 || trident.getFireTicks() <= 0) return; int ticks = this.getFireTicks(level); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantNimble.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantNimble.java index ffa26c6..07e5c95 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantNimble.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantNimble.java @@ -7,10 +7,10 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.PlayerUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; public class EnchantNimble extends ExcellentEnchant implements Chanced, DeathEnchant { @@ -21,6 +21,9 @@ public class EnchantNimble extends ExcellentEnchant implements Chanced, DeathEnc public EnchantNimble(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.LOWEST); + this.getDefaults().setDescription("Moves all mob's loot directly to your inventory."); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(0.4); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantParalyze.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantParalyze.java index 4073d2e..0f76234 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantParalyze.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantParalyze.java @@ -7,28 +7,39 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -public class EnchantParalyze extends PotionEnchant implements Chanced, CombatEnchant { +public class EnchantParalyze extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { public static final String ID = "paralyze"; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantParalyze(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.SLOW_DIGGING, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to apply " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) on hit."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.3); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "10.0 * " + Placeholders.ENCHANTMENT_LEVEL); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.SLOW_DIGGING, false, + "2.5 + " + Placeholders.ENCHANTMENT_LEVEL + " * 0.5", + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -37,6 +48,12 @@ public class EnchantParalyze extends PotionEnchant implements Chanced, CombatEnc return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { @@ -50,7 +67,7 @@ public class EnchantParalyze extends PotionEnchant implements Chanced, CombatEnc if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.CRIT_MAGIC, "", 0.25, 0.25, 0.25, 0.1f, 30); + SimpleParticle.of(Particle.CRIT_MAGIC).play(victim.getEyeLocation(), 0.25, 0.1, 30); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRage.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRage.java index 2370954..6403677 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRage.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRage.java @@ -7,28 +7,39 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -public class EnchantRage extends PotionEnchant implements Chanced, CombatEnchant { +public class EnchantRage extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { public static final String ID = "rage"; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantRage(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.INCREASE_DAMAGE, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to get " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) on hit."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.5); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "7.0 + " + Placeholders.ENCHANTMENT_LEVEL); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.INCREASE_DAMAGE, false, + "3.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 0.5", + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -37,6 +48,12 @@ public class EnchantRage extends PotionEnchant implements Chanced, CombatEnchant return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { @@ -50,7 +67,7 @@ public class EnchantRage extends PotionEnchant implements Chanced, CombatEnchant if (!this.addEffect(damager, level)) return false; if (this.hasVisualEffects()) { - EffectUtil.playEffect(damager.getEyeLocation(), Particle.LAVA, "", 0.25, 0.25, 0.25, 0.1f, 30); + SimpleParticle.of(Particle.LAVA).play(damager.getEyeLocation(), 0.25, 0.1, 30); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRocket.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRocket.java index 761aa2d..4f73460 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRocket.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRocket.java @@ -1,23 +1,24 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; -import org.bukkit.Sound; +import org.bukkit.*; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.FireworkMeta; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.MessageUtil; +import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantRocket extends ExcellentEnchant implements Chanced, CombatEnchant { @@ -28,13 +29,18 @@ public class EnchantRocket extends ExcellentEnchant implements Chanced, CombatEn public EnchantRocket(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch your enemy into the space."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.5); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); - this.fireworkPower = EnchantScaler.read(this, "Settings.Firework_Power", Placeholders.ENCHANTMENT_LEVEL + " * 0.25", + this.chanceImplementation = ChanceImplementation.create(this, + "4.0 + " + Placeholders.ENCHANTMENT_LEVEL); + this.fireworkPower = EnchantScaler.read(this, "Settings.Firework_Power", + Placeholders.ENCHANTMENT_LEVEL + " * 0.25", "Firework power. The more power = the higher fly distance."); } @@ -63,16 +69,32 @@ public class EnchantRocket extends ExcellentEnchant implements Chanced, CombatEn victim.leaveVehicle(); } - Firework firework = EntityUtil.spawnRandomFirework(victim.getLocation()); - FireworkMeta meta = firework.getFireworkMeta(); - meta.setPower((int) this.getFireworkPower(level)); - firework.setFireworkMeta(meta); + Firework firework = this.createRocket(victim.getLocation(), level); firework.addPassenger(victim); MessageUtil.sound(victim.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_LAUNCH); return true; } + @NotNull + private Firework createRocket(@NotNull Location location, int level) { + World world = location.getWorld(); + if (world == null) { + throw new IllegalStateException("World is null!"); + } + + Firework firework = (Firework) world.spawnEntity(location, EntityType.FIREWORK); + FireworkMeta meta = firework.getFireworkMeta(); + FireworkEffect.Type type = Rnd.get(FireworkEffect.Type.values()); + Color color = Color.fromBGR(Rnd.nextInt(255), Rnd.nextInt(255), Rnd.nextInt(255)); + Color fade = Color.fromBGR(Rnd.nextInt(255), Rnd.nextInt(255), Rnd.nextInt(255)); + FireworkEffect effect = FireworkEffect.builder().flicker(Rnd.nextBoolean()).withColor(color).withFade(fade).with(type).trail(Rnd.nextBoolean()).build(); + meta.addEffect(effect); + meta.setPower((int) this.getFireworkPower(level)); + firework.setFireworkMeta(meta); + return firework; + } + @Override public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantScavenger.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantScavenger.java index e4b06bb..c12d076 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantScavenger.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantScavenger.java @@ -8,16 +8,16 @@ import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.CollectionsUtil; import su.nexmedia.engine.utils.Pair; import su.nexmedia.engine.utils.StringUtil; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import java.util.HashMap; import java.util.Map; @@ -27,20 +27,36 @@ public class EnchantScavenger extends ExcellentEnchant implements Chanced, Death public static final String ID = "scavenger"; private Map>> loot; - private ChanceImplementation chanceImplementation; + + private ChanceImplementation chanceImplementation; public EnchantScavenger(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to obtain additional loot from mobs."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.3); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "15.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 10"); + this.loot = new HashMap<>(); + if (!this.cfg.contains("Settings.Treasures")) { + cfg.addMissing("Settings.Treasures.VILLAGER.EMERALD.Amount", "1:1"); + cfg.addMissing("Settings.Treasures.VILLAGER.EMERALD.Chance", "50"); + + cfg.addMissing("Settings.Treasures.SKELETON.BONE_MEAL.Amount", "1:2"); + cfg.addMissing("Settings.Treasures.SKELETON.BONE_MEAL.Chance", "50"); + + cfg.saveChanges(); + } + for (String eId : cfg.getSection("Settings.Treasures")) { - EntityType eType = CollectionsUtil.getEnum(eId, EntityType.class); + EntityType eType = StringUtil.getEnum(eId, EntityType.class).orElse(null); if (eType == null || !eType.isAlive()) { plugin.error("[Scavenger] Invalid entity type '" + eId + "' !"); continue; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantSurprise.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantSurprise.java index 9a4ef6c..519f1c4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantSurprise.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantSurprise.java @@ -12,26 +12,37 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantSurprise extends PotionEnchant implements Chanced, CombatEnchant { +public class EnchantSurprise extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { public static final String ID = "surprise"; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantSurprise(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.BLINDNESS, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to apply random potion effect to enemy on hit."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.75); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "2.25 * " + Placeholders.ENCHANTMENT_LEVEL); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.BLINDNESS, false, + "3.0 + " + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -40,6 +51,12 @@ public class EnchantSurprise extends PotionEnchant implements Chanced, CombatEnc return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantTemper.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantTemper.java index 89ace06..92b72a0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantTemper.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantTemper.java @@ -10,9 +10,9 @@ import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import java.util.function.UnaryOperator; @@ -30,12 +30,16 @@ public class EnchantTemper extends ExcellentEnchant implements CombatEnchant { public EnchantTemper(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Inflicts " + PLACEHOLDER_DAMAGE_AMOUNT + "% (max. " + PLACEHOLDER_DAMAGE_CAPACITY + "%) more damage for each " + PLACEHOLDER_HEALTH_POINT + " hearts missing."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.3); } @Override public void loadConfig() { super.loadConfig(); - this.damageAmount = EnchantScaler.read(this, "Settings.Damage.Amount", "0.01 * " + Placeholders.ENCHANTMENT_LEVEL, + this.damageAmount = EnchantScaler.read(this, "Settings.Damage.Amount", + "0.01 * " + Placeholders.ENCHANTMENT_LEVEL, "On how much (in percent) the damage will be increased per each Health Point?"); this.damageCapacity = EnchantScaler.read(this, "Settings.Damage.Capacity", "2.0", "Maximal possible value for the Damage.Amount."); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThrifty.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThrifty.java index 12b2afd..a3d6269 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThrifty.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThrifty.java @@ -13,14 +13,15 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; -import su.nexmedia.engine.utils.CollectionsUtil; import su.nexmedia.engine.utils.PDCUtil; +import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import java.util.Objects; import java.util.Set; @@ -38,19 +39,24 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn public EnchantThrifty(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to obtain mob spawn egg on kill."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.75); + this.keyEntityIgnored = new NamespacedKey(plugin, ID + "_ignored"); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "5.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 3"); this.ignoredEntityTypes = JOption.create("Settings.Ignored_Entity_Types", Set.of(EntityType.WITHER.name(), EntityType.ENDER_DRAGON.name()), "List of entity types, that will not drop spawn eggs.", "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html") - .read(cfg).stream().map(e -> CollectionsUtil.getEnum(e, EntityType.class)) + .read(cfg).stream().map(e -> StringUtil.getEnum(e, EntityType.class).orElse(null)) .filter(Objects::nonNull).collect(Collectors.toSet()); this.ignoredSpawnReasons = JOption.create("Settings.Ignored_Spawn_Reasons", @@ -59,7 +65,7 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn CreatureSpawnEvent.SpawnReason.DISPENSE_EGG.name()), "Entities will not drop spawn eggs if they were spawned by one of the reasons below.", "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/CreatureSpawnEvent.SpawnReason.html") - .read(cfg).stream().map(e -> CollectionsUtil.getEnum(e, CreatureSpawnEvent.SpawnReason.class)) + .read(cfg).stream().map(e -> StringUtil.getEnum(e, CreatureSpawnEvent.SpawnReason.class).orElse(null)) .filter(Objects::nonNull).collect(Collectors.toSet()); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThunder.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThunder.java index 98e4995..e5faaf6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThunder.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThunder.java @@ -11,10 +11,11 @@ import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatEnchant { @@ -28,12 +29,16 @@ public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatE public EnchantThunder(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to summon lightning to enemy on hit."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.3); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "10.0 * " + Placeholders.ENCHANTMENT_LEVEL); this.inThunderstormOnly = JOption.create("Settings.During_Thunderstorm_Only", false, "When 'true' the enchantment will be triggered only if there is an active thunderstorm in the world.").read(cfg); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVampire.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVampire.java index 774f38e..abecf76 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVampire.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVampire.java @@ -9,17 +9,17 @@ import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import java.util.function.UnaryOperator; @@ -34,14 +34,19 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE public EnchantVampire(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.LOWEST); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to heal for " + PLACEHOLDER_HEAL_AMOUNT + " heart(s) on hit."); + this.getDefaults().setLevelMax(4); + this.getDefaults().setTier(0.75); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5.0"); - this.healAmount = EnchantScaler.read(this, "Settings.Heal.Amount", "0.25 * " + Placeholders.ENCHANTMENT_LEVEL, + this.healAmount = EnchantScaler.read(this, "Settings.Heal.Amount", + "0.25 * " + Placeholders.ENCHANTMENT_LEVEL, "Amount of health to be restored for attacker."); this.healMultiplier = JOption.create("Settings.Heal.As_Multiplier", false, "When 'true', the option above will work as a multiplier of the inflicted damage.").read(cfg); @@ -97,7 +102,7 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE damager.setHealth(Math.min(healthMax, healthHas + healthEvent.getAmount())); if (this.hasVisualEffects()) { - EffectUtil.playEffect(damager.getEyeLocation(), Particle.HEART, "", 0.2f, 0.15f, 0.2f, 0.15f, 5); + SimpleParticle.of(Particle.HEART).play(damager.getEyeLocation(), 0.25, 0.15, 5); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVenom.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVenom.java index 556d2cf..b8b3e3d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVenom.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVenom.java @@ -7,28 +7,39 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -public class EnchantVenom extends PotionEnchant implements Chanced, CombatEnchant { +public class EnchantVenom extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { public static final String ID = "venom"; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantVenom(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.POISON, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to apply " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) on hit."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.3); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "30.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 10.0"); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.POISON, false, + "2.0 + " + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -37,6 +48,12 @@ public class EnchantVenom extends PotionEnchant implements Chanced, CombatEnchan return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { @@ -50,7 +67,7 @@ public class EnchantVenom extends PotionEnchant implements Chanced, CombatEnchan if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.SLIME, "", 0.25, 0.25, 0.25, 0.1f, 30); + SimpleParticle.of(Particle.SLIME).play(victim.getEyeLocation(), 0.25, 0.1, 30); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVillageDefender.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVillageDefender.java index 46dd024..2897fa2 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVillageDefender.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVillageDefender.java @@ -8,14 +8,15 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import java.util.function.UnaryOperator; @@ -29,13 +30,17 @@ public class EnchantVillageDefender extends ExcellentEnchant implements CombatEn public EnchantVillageDefender(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Inflicts " + PLACEHOLDER_DAMAGE_AMOUNT + " more damage to all pillagers."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.1); } @Override public void loadConfig() { super.loadConfig(); - this.damageAmount = EnchantScaler.read(this, "Settings.Damage.Formula", "0.5 * " + Placeholders.ENCHANTMENT_LEVEL, + this.damageAmount = EnchantScaler.read(this, "Settings.Damage.Formula", + "0.5 * " + Placeholders.ENCHANTMENT_LEVEL, "Amount of additional damage."); this.damageMultiplier = JOption.create("Settings.Damage.As_Modifier", false, @@ -76,7 +81,7 @@ public class EnchantVillageDefender extends ExcellentEnchant implements CombatEn e.setDamage(damageFinal); if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.VILLAGER_ANGRY, "", 0.25, 0.25, 0.25, 0.1f, 30); + SimpleParticle.of(Particle.VILLAGER_ANGRY).play(victim.getEyeLocation(), 0.25, 0.1, 30); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantWither.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantWither.java index 4a19eeb..0e739f7 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantWither.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantWither.java @@ -7,28 +7,40 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.EffectUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -public class EnchantWither extends PotionEnchant implements Chanced, CombatEnchant { +public class EnchantWither extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { public static final String ID = "wither"; private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; public EnchantWither(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.WITHER, false); + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to apply " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) on hit."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.5); } @Override public void loadConfig() { super.loadConfig(); - this.chanceImplementation = ChanceImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this, + "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.WITHER, false, + "3.0 + " + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); } @NotNull @@ -37,6 +49,12 @@ public class EnchantWither extends PotionEnchant implements Chanced, CombatEncha return chanceImplementation; } + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { @@ -50,7 +68,7 @@ public class EnchantWither extends PotionEnchant implements Chanced, CombatEncha if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.ASH, "", 0.25, 0.25, 0.25, 0.1f, 30); + SimpleParticle.of(Particle.ASH).play(victim.getEyeLocation(), 0.25, 0.1, 30); } return true; } 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 a28e943..1683df4 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 @@ -16,8 +16,8 @@ import su.nexmedia.engine.utils.MessageUtil; import su.nexmedia.engine.utils.PDCUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.HashMap; import java.util.Map; @@ -46,7 +46,7 @@ public class EnchantAnvilListener extends AbstractListener { if (result == null) result = new ItemStack(Material.AIR); // Check if source item is an enchantable single item. - if (first.getType().isAir() || first.getAmount() > 1 || !EnchantManager.isEnchantable(first)) return; + if (first.getType().isAir() || first.getAmount() > 1 || !EnchantUtils.isEnchantable(first)) return; if (this.handleRename(e, first, second, result)) return; if (this.handleRecharge(e, first, second, result)) return; @@ -61,10 +61,10 @@ public class EnchantAnvilListener extends AbstractListener { if (result.getType() != first.getType()) return false; ItemStack result2 = new ItemStack(result); - EnchantManager.getExcellentEnchantments(first).forEach((hasEnch, hasLevel) -> { - EnchantManager.addEnchantment(result2, hasEnch, hasLevel, true); + EnchantUtils.getExcellents(first).forEach((hasEnch, hasLevel) -> { + EnchantUtils.add(result2, hasEnch, hasLevel, true); }); - EnchantManager.updateEnchantmentsDisplay(result2); + EnchantUtils.updateDisplay(result2); e.setResult(result2); return true; } @@ -73,7 +73,7 @@ public class EnchantAnvilListener extends AbstractListener { @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) { if (second.getType().isAir()) return false; - Set chargeables = EnchantManager.getExcellentEnchantments(first).keySet().stream() + Set chargeables = EnchantUtils.getExcellents(first).keySet().stream() .filter(en -> en.isChargesEnabled() && en.isChargesFuel(second) && !en.isFullOfCharges(first)) .collect(Collectors.toSet()); if (chargeables.isEmpty()) return false; @@ -82,31 +82,31 @@ public class EnchantAnvilListener extends AbstractListener { int count = 0; while (count < second.getAmount() && !chargeables.stream().allMatch(en -> en.isFullOfCharges(result2))) { - chargeables.forEach(enchant -> EnchantManager.rechargeEnchantmentCharges(result2, enchant)); + chargeables.forEach(enchant -> EnchantUtils.rechargeCharges(result2, enchant)); count++; } PDCUtil.set(result2, RECHARGED, count); - EnchantManager.updateEnchantmentsDisplay(result2); + EnchantUtils.updateDisplay(result2); e.setResult(result2); - this.plugin.runTask(c -> e.getInventory().setRepairCost(chargeables.size()), false); + this.plugin.runTask(task -> e.getInventory().setRepairCost(chargeables.size())); return true; } private boolean handleEnchantMerging(@NotNull PrepareAnvilEvent e, @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) { // Validate items in the first two slots. - if (second.getType().isAir() || second.getAmount() > 1 || !EnchantManager.isEnchantable(second)) return false; + if (second.getType().isAir() || second.getAmount() > 1 || !EnchantUtils.isEnchantable(second)) return false; if (first.getType() == Material.ENCHANTED_BOOK && second.getType() != first.getType()) return false; ItemStack result2 = new ItemStack(result.getType().isAir() ? first : result); - Map enchantments = EnchantManager.getExcellentEnchantments(first); + Map enchantments = EnchantUtils.getExcellents(first); Map charges = new HashMap<>(enchantments.keySet().stream().collect(Collectors.toMap(k -> k, v -> v.getCharges(first)))); AtomicInteger repairCost = new AtomicInteger(e.getInventory().getRepairCost()); // Merge only if it's Item + Item, Item + Enchanted book or Enchanted Book + Enchanted Book if (second.getType() == Material.ENCHANTED_BOOK || second.getType() == first.getType()) { - EnchantManager.getExcellentEnchantments(second).forEach((enchant, level) -> { + 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))); charges.merge(enchant, enchant.getCharges(second), Integer::sum); }); @@ -114,19 +114,19 @@ public class EnchantAnvilListener extends AbstractListener { // Recalculate operation cost depends on enchantments merge cost. enchantments.forEach((enchant, level) -> { - if (EnchantManager.addEnchantment(result2, enchant, level, false)) { + if (EnchantUtils.add(result2, enchant, level, false)) { repairCost.addAndGet(enchant.getAnvilMergeCost(level)); - EnchantManager.setEnchantmentCharges(result2, enchant, charges.getOrDefault(enchant, 0)); + EnchantUtils.setCharges(result2, enchant, charges.getOrDefault(enchant, 0)); } }); if (first.equals(result2)) return false; - EnchantManager.updateEnchantmentsDisplay(result2); + EnchantUtils.updateDisplay(result2); e.setResult(result2); // NMS ContainerAnvil will set level cost to 0 right after calling the event, need 1 tick delay. - this.plugin.runTask((c) -> e.getInventory().setRepairCost(repairCost.get()), false); + this.plugin.runTask(task -> e.getInventory().setRepairCost(repairCost.get())); return true; } 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 47cc5a8..821d90a 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 @@ -21,10 +21,13 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.manager.AbstractListener; import su.nexmedia.engine.hooks.Hooks; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.EnchantManager; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; +import su.nightexpress.excellentenchants.hook.HookId; +import su.nightexpress.excellentenchants.hook.impl.MythicMobsHook; import java.util.HashMap; import java.util.Map; @@ -65,13 +68,13 @@ public class EnchantGenericListener extends AbstractListener ItemStack source = inventory.getItem(slot); if (source == null || source.getType().isAir()) continue; - curses.putAll(EnchantManager.getExcellentEnchantments(source)); + curses.putAll(EnchantUtils.getExcellents(source)); } curses.entrySet().removeIf(entry -> !entry.getKey().isCursed()); curses.forEach((excellentEnchant, level) -> { - EnchantManager.addEnchantment(result, excellentEnchant, level, true); + EnchantUtils.add(result, excellentEnchant, level, true); }); - EnchantManager.updateEnchantmentsDisplay(result); + EnchantUtils.updateDisplay(result); }); } @@ -81,7 +84,7 @@ public class EnchantGenericListener extends AbstractListener Item item = e.getItem(); ItemStack itemStack = item.getItemStack(); - if (EnchantManager.updateEnchantmentsDisplay(itemStack)) { + if (EnchantUtils.updateDisplay(itemStack)) { item.setItemStack(itemStack); } } @@ -93,7 +96,7 @@ public class EnchantGenericListener extends AbstractListener public void onEnchantPopulateEnchantingTable(final EnchantItemEvent e) { ItemStack target = e.getItem(); Map enchantsPrepared = e.getEnchantsToAdd(); - Map enchantsToPopulate = EnchantManager.getEnchantsToPopulate(target, ObtainType.ENCHANTING, enchantsPrepared, enchant -> enchant.getLevelByEnchantCost(e.getExpLevelCost())); + Map enchantsToPopulate = EnchantUtils.getPopulationCandidates(target, ObtainType.ENCHANTING, enchantsPrepared, enchant -> enchant.getLevelByEnchantCost(e.getExpLevelCost())); enchantsPrepared.putAll(enchantsToPopulate); @@ -116,10 +119,10 @@ public class EnchantGenericListener extends AbstractListener e.getEnchantsToAdd().forEach((enchantment, level) -> { if (enchantment instanceof ExcellentEnchant enchant && enchant.isChargesEnabled()) { - EnchantManager.restoreEnchantmentCharges(result, enchant); + EnchantUtils.restoreCharges(result, enchant); } }); - EnchantManager.updateEnchantmentsDisplay(result); + EnchantUtils.updateDisplay(result); e.getInventory().setItem(0, result); }); @@ -133,8 +136,8 @@ public class EnchantGenericListener extends AbstractListener MerchantRecipe recipe = e.getRecipe(); ItemStack result = recipe.getResult(); - if (!EnchantManager.isEnchantable(result)) return; - if (!EnchantManager.populateEnchantments(result, ObtainType.VILLAGER)) return; + if (!EnchantUtils.isEnchantable(result)) return; + if (!EnchantUtils.populate(result, ObtainType.VILLAGER)) return; int uses = recipe.getUses(); int maxUses = recipe.getMaxUses(); @@ -156,8 +159,8 @@ public class EnchantGenericListener extends AbstractListener if (entity instanceof Minecart || holder instanceof Chest) { e.getLoot().forEach(item -> { - if (item != null && EnchantManager.isEnchantable(item)) { - EnchantManager.populateEnchantments(item, ObtainType.LOOT_GENERATION); + if (item != null && EnchantUtils.isEnchantable(item)) { + EnchantUtils.populate(item, ObtainType.LOOT_GENERATION); } }); } @@ -170,8 +173,8 @@ public class EnchantGenericListener extends AbstractListener if (!(e.getCaught() instanceof Item item)) return; ItemStack itemStack = item.getItemStack(); - if (EnchantManager.isEnchantable(itemStack)) { - EnchantManager.populateEnchantments(itemStack, ObtainType.FISHING); + if (EnchantUtils.isEnchantable(itemStack)) { + EnchantUtils.populate(itemStack, ObtainType.FISHING); } } @@ -185,14 +188,14 @@ public class EnchantGenericListener extends AbstractListener EntityEquipment equipment = entity.getEquipment(); if (equipment == null) return; - boolean isMythic = Hooks.isMythicMob(entity); + boolean isMythic = Hooks.hasPlugin(HookId.MYTHIC_MOBS) && MythicMobsHook.isMythicMob(entity); boolean doPopulation = Config.getObtainSettings(ObtainType.MOB_SPAWNING).isPresent() && !isMythic; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack item = equipment.getItem(slot); - if (EnchantManager.isEnchantable(item)) { - if (doPopulation) EnchantManager.populateEnchantments(item, ObtainType.MOB_SPAWNING); - EnchantManager.getExcellentEnchantments(item).keySet().forEach(enchant -> EnchantManager.restoreEnchantmentCharges(item, enchant)); + if (EnchantUtils.isEnchantable(item)) { + if (doPopulation) EnchantUtils.populate(item, ObtainType.MOB_SPAWNING); + EnchantUtils.getExcellents(item).keySet().forEach(enchant -> EnchantUtils.restoreCharges(item, enchant)); equipment.setItem(slot, item); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java index aa91ae0..2f429cc 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java @@ -24,10 +24,11 @@ import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.manager.AbstractListener; import su.nexmedia.engine.utils.EntityUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.util.EnchantDropContainer; +import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; import su.nightexpress.excellentenchants.api.enchantment.type.*; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; public class EnchantHandlerListener extends AbstractListener { @@ -89,7 +90,7 @@ public class EnchantHandlerListener extends AbstractListener ItemStack weapon = equipment.getItemInMainHand(); if (weapon.getType().isAir() || weapon.getType() == Material.ENCHANTED_BOOK) return; - EnchantManager.getExcellentEnchantments(weapon, CombatEnchant.class).forEach((combatEnchant, level) -> { + EnchantUtils.getExcellents(weapon, CombatEnchant.class).forEach((combatEnchant, level) -> { if (combatEnchant.isOutOfCharges(weapon)) return; if (combatEnchant.onAttack(e, damager, victim, weapon, level)) { combatEnchant.consumeCharges(weapon); @@ -107,7 +108,7 @@ public class EnchantHandlerListener extends AbstractListener for (ItemStack armor : EntityUtil.getEquippedArmor(victim).values()) { if (armor == null || armor.getType().isAir()) continue; - EnchantManager.getExcellentEnchantments(armor, CombatEnchant.class).forEach((combatEnchant, level) -> { + EnchantUtils.getExcellents(armor, CombatEnchant.class).forEach((combatEnchant, level) -> { if (combatEnchant.isOutOfCharges(armor)) return; if (combatEnchant.onProtect(e, damager, victim, weaponDamager, level)) { combatEnchant.consumeCharges(armor); @@ -117,7 +118,7 @@ public class EnchantHandlerListener extends AbstractListener } private void handleArmorEnchants(@NotNull EntityDamageEvent e, @NotNull LivingEntity entity) { - EnchantManager.getEquippedEnchants(entity, DamageEnchant.class).forEach((item, enchants) -> { + EnchantUtils.getEquipped(entity, DamageEnchant.class).forEach((item, enchants) -> { enchants.forEach((enchant, level) -> { if (enchant.isOutOfCharges(item)) return; if (enchant.onDamage(e, entity, item, level)) { @@ -134,7 +135,7 @@ public class EnchantHandlerListener extends AbstractListener ItemStack bow = this.getSourceWeapon(projectile); if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; - EnchantManager.getExcellentEnchantments(bow, BowEnchant.class).forEach((bowEnchant, level) -> { + EnchantUtils.getExcellents(bow, BowEnchant.class).forEach((bowEnchant, level) -> { bowEnchant.onDamage(e, projectile, shooter, victim, bow, level); }); } @@ -150,7 +151,7 @@ public class EnchantHandlerListener extends AbstractListener ItemStack bow = e.getBow(); if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; - EnchantManager.getExcellentEnchantments(bow, BowEnchant.class).forEach((bowEnchant, level) -> { + EnchantUtils.getExcellents(bow, BowEnchant.class).forEach((bowEnchant, level) -> { if (bowEnchant.isOutOfCharges(bow)) return; if (bowEnchant.onShoot(e, shooter, bow, level)) { if (bowEnchant instanceof Arrowed arrowed && e.getProjectile() instanceof Projectile projectile) { @@ -176,7 +177,7 @@ public class EnchantHandlerListener extends AbstractListener ItemStack bow = this.getSourceWeapon(projectile); if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; - EnchantManager.getExcellentEnchantments(bow, BowEnchant.class).forEach((bowEnchant, level) -> { + EnchantUtils.getExcellents(bow, BowEnchant.class).forEach((bowEnchant, level) -> { bowEnchant.onHit(e, projectile, bow, level); }); @@ -196,7 +197,7 @@ public class EnchantHandlerListener extends AbstractListener if (item == null || item.getType().isAir() || item.getType() == Material.ENCHANTED_BOOK) return; Player player = e.getPlayer(); - EnchantManager.getExcellentEnchantments(item, InteractEnchant.class).forEach((interEnchant, level) -> { + EnchantUtils.getExcellents(item, InteractEnchant.class).forEach((interEnchant, level) -> { if (interEnchant.isOutOfCharges(item)) return; if (interEnchant.onInteract(e, player, item, level)) { interEnchant.consumeCharges(item); @@ -211,7 +212,7 @@ public class EnchantHandlerListener extends AbstractListener public void onEnchantDeath(EntityDeathEvent e) { LivingEntity entity = e.getEntity(); - EnchantManager.getEquippedEnchants(entity, DeathEnchant.class).forEach((item, enchants) -> { + EnchantUtils.getEquipped(entity, DeathEnchant.class).forEach((item, enchants) -> { enchants.forEach(((deathEnchant, level) -> { if (deathEnchant.isOutOfCharges(item)) return; if (deathEnchant.onDeath(e, entity, level)) { @@ -226,7 +227,7 @@ public class EnchantHandlerListener extends AbstractListener ItemStack weapon = killer.getInventory().getItemInMainHand(); if (weapon.getType().isAir() || weapon.getType() == Material.ENCHANTED_BOOK) return; - EnchantManager.getExcellentEnchantments(weapon, DeathEnchant.class).forEach((deathEnchant, level) -> { + EnchantUtils.getExcellents(weapon, DeathEnchant.class).forEach((deathEnchant, level) -> { if (deathEnchant.isOutOfCharges(weapon)) return; if (deathEnchant.onKill(e, entity, killer, level)) { deathEnchant.consumeCharges(weapon); @@ -243,7 +244,7 @@ public class EnchantHandlerListener extends AbstractListener ItemStack tool = player.getInventory().getItemInMainHand(); if (tool.getType().isAir() || tool.getType() == Material.ENCHANTED_BOOK) return; - EnchantManager.getExcellentEnchantments(tool, BlockBreakEnchant.class).forEach((blockEnchant, level) -> { + EnchantUtils.getExcellents(tool, BlockBreakEnchant.class).forEach((blockEnchant, level) -> { if (blockEnchant.isOutOfCharges(tool)) return; if (blockEnchant.onBreak(e, player, tool, level)) { blockEnchant.consumeCharges(tool); @@ -260,7 +261,7 @@ public class EnchantHandlerListener extends AbstractListener if (tool.getType().isAir() || tool.getType() == Material.ENCHANTED_BOOK) return; EnchantDropContainer dropContainer = new EnchantDropContainer(e); - EnchantManager.getExcellentEnchantments(tool, BlockDropEnchant.class).forEach((enchant, level) -> { + EnchantUtils.getExcellents(tool, BlockDropEnchant.class).forEach((enchant, level) -> { if (enchant.isOutOfCharges(tool)) return; if (enchant.onDrop(e, dropContainer, player, tool, level)) { enchant.consumeCharges(tool); 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 adb8773..c447a11 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 @@ -3,15 +3,17 @@ package su.nightexpress.excellentenchants.enchantment.menu; import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.api.menu.AbstractMenuAuto; -import su.nexmedia.engine.api.menu.MenuClick; -import su.nexmedia.engine.api.menu.MenuItem; +import su.nexmedia.engine.api.menu.AutoPaged; import su.nexmedia.engine.api.menu.MenuItemType; +import su.nexmedia.engine.api.menu.click.ClickHandler; +import su.nexmedia.engine.api.menu.click.ItemClick; +import su.nexmedia.engine.api.menu.impl.ConfigMenu; +import su.nexmedia.engine.api.menu.impl.MenuOptions; +import su.nexmedia.engine.api.menu.impl.MenuViewer; import su.nexmedia.engine.lang.LangManager; import su.nexmedia.engine.utils.Colorizer; import su.nexmedia.engine.utils.ItemUtil; @@ -19,30 +21,30 @@ import su.nexmedia.engine.utils.PDCUtil; import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.enchantment.EnchantRegister; +import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import java.util.*; -public class EnchantmentsListMenu extends AbstractMenuAuto { +public class EnchantmentsListMenu extends ConfigMenu implements AutoPaged { private static final String PATH = "/menu/enchants_list.yml"; private static final String PLACEHOLDER_CONFLICTS = "%conflicts%"; - private static final String PLACEHOLDER_CHARGES = "%charges%"; + private static final String PLACEHOLDER_CHARGES = "%charges%"; private static final String PLACEHOLDER_OBTAINING = "%obtaining%"; - private final ItemStack enchantIcon; + private final ItemStack enchantIcon; private final List enchantLoreConflicts; private final List enchantLoreCharges; private final List enchantLoreObtaining; - private final int[] enchantSlots; + private final int[] enchantSlots; private final NamespacedKey keyLevel; private final Map> iconCache; public EnchantmentsListMenu(@NotNull ExcellentEnchants plugin) { - super(plugin, JYML.loadOrExtract(plugin, PATH), ""); + super(plugin, JYML.loadOrExtract(plugin, PATH)); this.keyLevel = new NamespacedKey(plugin, "list_display_level"); this.iconCache = new HashMap<>(); @@ -52,20 +54,12 @@ public class EnchantmentsListMenu extends AbstractMenuAuto { - if (type instanceof MenuItemType type2) { - this.onItemClickDefault(player, type2); - } - }; + this.registerHandler(MenuItemType.class) + .addClick(MenuItemType.CLOSE, (viewer, event) -> plugin.runTask(task -> viewer.getPlayer().closeInventory())) + .addClick(MenuItemType.PAGE_NEXT, ClickHandler.forNextPage(this)) + .addClick(MenuItemType.PAGE_PREVIOUS, ClickHandler.forPreviousPage(this)); - for (String sId : cfg.getSection("Content")) { - MenuItem menuItem = cfg.getMenuItem("Content." + sId); - - if (menuItem.getType() != null) { - menuItem.setClickHandler(click); - } - this.addItem(menuItem); - } + this.load(); } @Override @@ -75,30 +69,42 @@ public class EnchantmentsListMenu extends AbstractMenuAuto getObjects(@NotNull Player player) { - return new ArrayList<>(EnchantRegister.ENCHANT_REGISTRY.values().stream() + public Comparator getObjectSorter() { + return (o1, o2) -> 0; + } + + @Override + @NotNull + public List getObjects(@NotNull Player player) { + return new ArrayList<>(EnchantRegistry.getRegistered().stream() .sorted(Comparator.comparing(ExcellentEnchant::getName)).toList()); } @Override @NotNull - protected ItemStack getObjectStack(@NotNull Player player, @NotNull ExcellentEnchant enchant) { + public ItemStack getObjectStack(@NotNull Player player, @NotNull ExcellentEnchant enchant) { return this.getEnchantIcon(enchant, 1); } @Override @NotNull - protected MenuClick getObjectClick(@NotNull Player player, @NotNull ExcellentEnchant enchant) { - return (player1, type, e) -> { - if (!e.isLeftClick()) return; + public ItemClick getObjectClick(@NotNull ExcellentEnchant enchant) { + return (viewer, event) -> { + if (!event.isLeftClick()) return; - ItemStack itemClick = e.getCurrentItem(); + ItemStack itemClick = event.getCurrentItem(); if (itemClick == null) return; int levelHas = PDCUtil.getInt(itemClick, this.keyLevel).orElse(0); @@ -108,7 +114,7 @@ public class EnchantmentsListMenu extends AbstractMenuAuto { - private static final Map>> TRAILS_MAP = new ConcurrentHashMap<>(); + private static final Map> TRAILS_MAP = new ConcurrentHashMap<>(); public ArrowTrailsTask(@NotNull ExcellentEnchants plugin) { super(plugin, Config.TASKS_ARROW_TRAIL_TICKS_INTERVAL.get(), true); @@ -29,17 +27,12 @@ public class ArrowTrailsTask extends AbstractTask { TRAILS_MAP.forEach((arrow, effects) -> { effects.forEach(entry -> { - EffectUtil.playEffect(arrow.getLocation(), entry.getFirst(), entry.getSecond(), 0f, 0f, 0f, 0f, 10); + entry.play(arrow.getLocation(), 0f, 0f, 10); }); }); } - @Deprecated - public static void add(@NotNull Projectile projectile, @NotNull String particleName, @NotNull String particleData) { - TRAILS_MAP.computeIfAbsent(projectile, list -> new HashSet<>()).add(Pair.of(Particle.valueOf(particleName), particleData)); - } - - public static void add(@NotNull Projectile projectile, @NotNull Particle particle, @NotNull String data) { - TRAILS_MAP.computeIfAbsent(projectile, list -> new HashSet<>()).add(Pair.of(particle, data)); + public static void add(@NotNull Projectile projectile, @NotNull SimpleParticle particle) { + TRAILS_MAP.computeIfAbsent(projectile, list -> new HashSet<>()).add(particle); } } \ No newline at end of file diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PotionEffectsTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PotionEffectsTask.java index 5f366cd..2d2a777 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PotionEffectsTask.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PotionEffectsTask.java @@ -4,7 +4,7 @@ import org.bukkit.entity.LivingEntity; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.config.Config; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; public class PotionEffectsTask extends AbstractEnchantmentTask { @@ -15,7 +15,7 @@ public class PotionEffectsTask extends AbstractEnchantmentTask { @Override public void action() { for (LivingEntity entity : this.getEntities()) { - EnchantManager.updateEquippedEnchantEffects(entity); + EnchantUtils.updateEquippedEffects(entity); } } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/util/EnchantDropContainer.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantDropContainer.java similarity index 90% rename from Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/util/EnchantDropContainer.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantDropContainer.java index 38ed11c..a570150 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/util/EnchantDropContainer.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantDropContainer.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.api.enchantment.util; +package su.nightexpress.excellentenchants.enchantment.util; import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.inventory.ItemStack; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/util/EnchantPriority.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantPriority.java similarity index 53% rename from Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/util/EnchantPriority.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantPriority.java index d51f714..533ddc8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/util/EnchantPriority.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantPriority.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.api.enchantment.util; +package su.nightexpress.excellentenchants.enchantment.util; public enum EnchantPriority { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java new file mode 100644 index 0000000..d3e8f65 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -0,0 +1,359 @@ +package su.nightexpress.excellentenchants.enchantment.util; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.utils.CollectionsUtil; +import su.nexmedia.engine.utils.EntityUtil; +import su.nexmedia.engine.utils.ItemUtil; +import su.nexmedia.engine.utils.PDCUtil; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; +import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; +import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.config.ObtainSettings; +import su.nightexpress.excellentenchants.enchantment.EnchantPopulator; +import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.type.ObtainType; +import su.nightexpress.excellentenchants.tier.Tier; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class EnchantUtils { + + public static final NamespacedKey KEY_LORE_SIZE = new NamespacedKey(ExcellentEnchantsAPI.PLUGIN, "lore_size"); + + public static boolean isEnchantable(@NotNull ItemStack item) { + if (item.getType().isAir()) return false; + + return item.getType() == Material.ENCHANTED_BOOK || Stream.of(EnchantmentTarget.values()).anyMatch(target -> target.includes(item)); + } + + public static boolean populate(@NotNull ItemStack item, @NotNull ObtainType obtainType) { + int enchantsHad = getAmount(item); + + getPopulationCandidates(item, obtainType).forEach((enchantment, level) -> { + add(item, enchantment, level, false); + }); + updateDisplay(item); + + return getAmount(item) != enchantsHad; + } + + @NotNull + public static Set populateFilter(@NotNull Set enchants, + @NotNull ObtainType obtainType, @Nullable ItemStack item) { + Set set = enchants.stream() + .filter(enchant -> enchant.getObtainChance(obtainType) > 0) + .filter(enchant -> item == null || enchant.canEnchantItem(item)) + .collect(Collectors.toCollection(HashSet::new)); + set.removeIf(enchant -> obtainType == ObtainType.ENCHANTING && (enchant.isTreasure() || enchant.isCursed())); + return set; + } + + @NotNull + public static Map getPopulationCandidates(@NotNull ItemStack item, @NotNull ObtainType obtainType) { + return getPopulationCandidates(item, obtainType, new HashMap<>(), (enchant) -> enchant.generateLevel(obtainType)); + } + + @NotNull + public static Map getPopulationCandidates(@NotNull ItemStack item, @NotNull ObtainType obtainType, + @NotNull Map enchantsPrepared, + @NotNull Function levelFunc) { + Map enchantsToAdd = new HashMap<>(enchantsPrepared); + + ObtainSettings settings = Config.getObtainSettings(obtainType).orElse(null); + if (settings == null || !Rnd.chance(settings.getEnchantsCustomGenerationChance())) return enchantsToAdd; + + int enchMax = settings.getEnchantsTotalMax(); + int enchRoll = Rnd.get(settings.getEnchantsCustomMin(), settings.getEnchantsCustomMax()); + + // Класс для исключения неудачных попыток. + EnchantPopulator populator = new EnchantPopulator(obtainType, item); + + // Добавляем сколько можем, пока нужное количество не будет добавлено или не закончатся чары и/или тиры. + while (!populator.isEmpty() && enchRoll > 0) { + // Достигнут максимум чар (любых) для итема, заканчиваем. + if (enchantsToAdd.size() >= enchMax) break; + + Tier tier = populator.getTierByChance(); + if (tier == null) break; // Нет тира? + + ExcellentEnchant enchant = populator.getEnchantByChance(tier); + // В тире нет подходящих чар (вообще) для итема, исключаем и идем дальше. + if (enchant == null) { + populator.getEnchants().remove(tier); + continue; + } + + // Среди уже добавленных чар есть конфликты с тем, что нашли. + // Исключаем, идем дальше. + if (enchantsToAdd.keySet().stream().anyMatch(has -> has.conflictsWith(enchant) || enchant.conflictsWith(has))) { + populator.getEnchants(tier).remove(enchant); + continue; + } + + // Не получилось сгенерировать подходящий уровень. + // Исключаем, идем дальше. + int level = levelFunc.apply(enchant); + if (level < enchant.getStartLevel()) { + populator.getEnchants(tier).remove(enchant); + continue; + } + + // Добавляем чар, засчитываем попытку. + populator.getEnchants(tier).remove(enchant); + enchantsToAdd.put(enchant, level); + enchRoll--; + } + return enchantsToAdd; + } + + public static boolean add(@NotNull ItemStack item, @NotNull Enchantment enchantment, int level, boolean force) { + if (!force && !enchantment.canEnchantItem(item)) return false; + + remove(item, enchantment); + + ItemMeta meta = item.getItemMeta(); + if (meta == null) return false; + + if (meta instanceof EnchantmentStorageMeta storageMeta) { + if (!storageMeta.addStoredEnchant(enchantment, level, true)) return false; + } + else { + if (!meta.addEnchant(enchantment, level, true)) return false; + } + item.setItemMeta(meta); + + return true; + } + + public static void remove(@NotNull ItemStack item, @NotNull Enchantment enchantment) { + ItemMeta meta = item.getItemMeta(); + if (meta instanceof EnchantmentStorageMeta storageMeta) { + storageMeta.removeStoredEnchant(enchantment); + } + else { + meta.removeEnchant(enchantment); + } + item.setItemMeta(meta); + } + + public static boolean updateDisplay(@NotNull ItemStack item) { + if (Config.ENCHANTMENTS_DISPLAY_MODE.get() != 1) return false; + + if (!isEnchantable(item)) { + PDCUtil.remove(item, KEY_LORE_SIZE); + return false; + } + + Map enchants = getExcellents(item); + + int sizeHas = PDCUtil.getInt(item, KEY_LORE_SIZE).orElse(0); + int sizeReal = enchants.size(); + + ItemMeta meta = item.getItemMeta(); + if (meta == null) return false; + + List lore = meta.getLore() == null ? new ArrayList<>() : meta.getLore(); + for (int index = 0; index < sizeHas && !lore.isEmpty(); index++) { + lore.remove(0); + } + //lore.removeIf(str -> enchants.keySet().stream().anyMatch(enchant -> str.contains(enchant.getDisplayName()))); + + if (!meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS)) { + if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED.get()) { + enchants.forEach((enchant, level) -> { + lore.addAll(0, enchant.formatDescription(level)); + }); + sizeReal += enchants.keySet().stream().map(ExcellentEnchant::getDescription).mapToInt(List::size).sum(); + } + enchants.forEach((enchant, level) -> { + lore.add(0, enchant.getNameFormatted(level, getCharges(meta, enchant))); + }); + } + else sizeReal = 0; + + meta.setLore(lore); + if (sizeReal > 0) { + PDCUtil.set(meta, KEY_LORE_SIZE, sizeReal); + } + item.setItemMeta(meta); + return true; + } + + @NotNull + public static Map getAll(@NotNull ItemStack item) { + ItemMeta meta = item.getItemMeta(); + return meta == null ? Collections.emptyMap() : getAll(meta); + } + + @NotNull + public static Map getAll(@NotNull ItemMeta meta) { + return (meta instanceof EnchantmentStorageMeta meta2) ? meta2.getStoredEnchants() : meta.getEnchants(); + } + + public static int getAmount(@NotNull ItemStack item) { + return getAll(item).size(); + } + + public static boolean contains(@NotNull ItemStack item, @NotNull Enchantment enchantment) { + return getLevel(item, enchantment) > 0; + } + + public static int getLevel(@NotNull ItemStack item, @NotNull Enchantment enchant) { + return getAll(item).getOrDefault(enchant, 0); + } + + public static int getCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { + return enchant.isChargesEnabled() ? PDCUtil.getInt(item, enchant.getChargesKey()).orElse(0) : -1; + } + + public static int getCharges(@NotNull ItemMeta meta, @NotNull ExcellentEnchant enchant) { + return enchant.isChargesEnabled() ? PDCUtil.getInt(meta, enchant.getChargesKey()).orElse(0) : -1; + } + + public static boolean isOutOfCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { + return enchant.isChargesEnabled() && getCharges(item, enchant) == 0; + } + + public static boolean isFullOfCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { + if (!enchant.isChargesEnabled()) return true; + + int level = getLevel(item, enchant); + int max = enchant.getChargesMax(level); + return getCharges(item, enchant) == max; + } + + public static void consumeCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { + if (!enchant.isChargesEnabled()) return; + + int level = getLevel(item, enchant); + int has = getCharges(item, enchant); + int use = enchant.getChargesConsumeAmount(level); + setCharges(item, enchant, has - use); + } + + public static void restoreCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { + if (!enchant.isChargesEnabled()) return; + + int level = getLevel(item, enchant); + int max = enchant.getChargesMax(level); + setCharges(item, enchant, max); + } + + public static void rechargeCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { + if (!enchant.isChargesEnabled()) return; + + int level = getLevel(item, enchant); + int recharge = enchant.getChargesRechargeAmount(level); + int has = getCharges(item, enchant); + setCharges(item, enchant, has + recharge); + } + + public static void setCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int charges) { + if (!enchant.isChargesEnabled()) return; + + int level = getLevel(item, enchant); + int max = enchant.getChargesMax(level); + PDCUtil.set(item, enchant.getChargesKey(), Math.max(0, Math.min(charges, max))); + } + + public static int getExcellentAmount(@NotNull ItemStack item) { + return getExcellents(item).size(); + } + + @NotNull + public static Map getExcellents(@NotNull ItemStack item) { + return getExcellents(getAll(item)); + } + + @NotNull + public static Map getExcellents(@NotNull ItemMeta meta) { + return getExcellents(getAll(meta)); + } + + @NotNull + private static Map getExcellents(@NotNull Map enchants) { + Map map = new HashMap<>(); + enchants.forEach((enchantment, level) -> { + ExcellentEnchant excellent = EnchantRegistry.get(enchantment.getKey()); + if (excellent != null) { + map.put(excellent, level); + } + }); + return map; + } + + @NotNull + public static Map getExcellents(@NotNull ItemStack item, @NotNull Class clazz) { + Map map = new HashMap<>(); + getAll(item).forEach((enchantment, level) -> { + ExcellentEnchant excellent = EnchantRegistry.get(enchantment.getKey()); + if (excellent == null || !clazz.isAssignableFrom(excellent.getClass())) return; + + map.put(clazz.cast(excellent), level); + }); + return CollectionsUtil.sort(map, Comparator.comparing(p -> p.getKey().getPriority(), Comparator.reverseOrder())); + } + + @NotNull + public static Map getEnchantedEquipment(@NotNull LivingEntity entity) { + Map equipment = EntityUtil.getEquippedItems(entity); + equipment.entrySet().removeIf(entry -> { + ItemStack item = entry.getValue(); + EquipmentSlot slot = entry.getKey(); + if (item == null || item.getType().isAir() || item.getType() == Material.ENCHANTED_BOOK) return true; + if ((slot == EquipmentSlot.HAND || slot == EquipmentSlot.OFF_HAND) && ItemUtil.isArmor(item)) return true; + return !item.hasItemMeta(); + }); + return equipment; + } + + @NotNull + public static Map> getEquipped(@NotNull LivingEntity entity) { + Map> map = new HashMap<>(); + getEnchantedEquipment(entity).values().forEach(item -> { + map.computeIfAbsent(item, k -> new LinkedHashMap<>()).putAll(getExcellents(item)); + }); + return map; + } + + @NotNull + public static Map> getEquipped(@NotNull LivingEntity entity, + @NotNull Class clazz) { + Map> map = new HashMap<>(); + getEnchantedEquipment(entity).values().forEach(item -> { + map.computeIfAbsent(item, k -> new LinkedHashMap<>()).putAll(getExcellents(item, clazz)); + }); + return map; + } + + public static void updateEquippedEffects(@NotNull LivingEntity entity) { + getEquipped(entity, PassiveEnchant.class).forEach((item, enchants) -> { + enchants.forEach((enchant, level) -> { + if (enchant instanceof Potioned potioned) { + if (enchant.isOutOfCharges(item)) return; + if (enchant.onTrigger(entity, item, level)) { + enchant.consumeCharges(item); + } + } + }); + }); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookId.java b/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookId.java index 5b643c9..574994a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookId.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookId.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.hook; public class HookId { + public static final String MYTHIC_MOBS = "MythicMobs"; public static final String NCP = "NoCheatPlus"; public static final String PROTOCOL_LIB = "ProtocolLib"; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/MythicMobsHook.java b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/MythicMobsHook.java new file mode 100644 index 0000000..0841f8e --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/MythicMobsHook.java @@ -0,0 +1,14 @@ +package su.nightexpress.excellentenchants.hook.impl; + +import io.lumine.mythic.bukkit.MythicBukkit; +import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class MythicMobsHook { + + private static final MythicBukkit MYTHIC_MOBS = MythicBukkit.inst(); + + public static boolean isMythicMob(@NotNull Entity entity) { + return MYTHIC_MOBS.getAPIHelper().isMythicMob(entity); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/PlaceholderHook.java b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/PlaceholderHook.java index 4421ea2..a8621b6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/PlaceholderHook.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/PlaceholderHook.java @@ -9,8 +9,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.enchantment.EnchantRegister; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; public class PlaceholderHook { @@ -63,7 +63,7 @@ public class PlaceholderHook { ItemStack item = player.getInventory().getItem(slot); if (item == null || item.getType().isAir()) return "-"; - ExcellentEnchant enchant = EnchantRegister.get(NamespacedKey.minecraft(chargesSplit[1].toLowerCase())); + ExcellentEnchant enchant = EnchantRegistry.get(NamespacedKey.minecraft(chargesSplit[1].toLowerCase())); if (enchant == null) return null; return String.valueOf(enchant.getCharges(item)); @@ -72,7 +72,7 @@ public class PlaceholderHook { String[] chargesSplit = params.substring("charges_maximum_".length()).split(":"); if (chargesSplit.length < 2) return null; - ExcellentEnchant enchant = EnchantRegister.get(NamespacedKey.minecraft(chargesSplit[0].toLowerCase())); + ExcellentEnchant enchant = EnchantRegistry.get(NamespacedKey.minecraft(chargesSplit[0].toLowerCase())); if (enchant == null) return null; int level = StringUtil.getInteger(chargesSplit[1], 1); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/ProtocolHook.java b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/ProtocolHook.java index d7cb47c..351fc82 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/ProtocolHook.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/ProtocolHook.java @@ -13,9 +13,9 @@ import org.bukkit.inventory.MerchantRecipe; import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.Nullable; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Config; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.*; import java.util.stream.Collectors; @@ -85,7 +85,7 @@ public class ProtocolHook { ItemMeta meta = copy.getItemMeta(); if (meta == null || meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS)) return item; - Map enchants = EnchantManager.getExcellentEnchantments(meta) + Map enchants = EnchantUtils.getExcellents(meta) .entrySet().stream() .sorted(Comparator.comparing(e -> e.getKey().getTier().getPriority())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (old,nev) -> nev, LinkedHashMap::new)); @@ -106,7 +106,7 @@ public class ProtocolHook { }); } enchants.forEach((enchant, level) -> { - int charges = EnchantManager.getEnchantmentCharges(meta, enchant); + int charges = EnchantUtils.getCharges(meta, enchant); lore.add(0, enchant.getNameFormatted(level, charges)); }); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.java b/Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.java index 8110b07..ca21aa4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.java @@ -1,38 +1,23 @@ package su.nightexpress.excellentenchants.tier; import net.md_5.bungee.api.ChatColor; -import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import su.nexmedia.engine.api.manager.IPlaceholder; +import su.nexmedia.engine.api.placeholder.Placeholder; +import su.nexmedia.engine.api.placeholder.PlaceholderMap; import su.nexmedia.engine.utils.Colorizer; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; -import java.util.HashMap; -import java.util.HashSet; import java.util.Map; -import java.util.Set; -import java.util.function.UnaryOperator; -import java.util.stream.Collectors; -import java.util.stream.Stream; -public class Tier implements IPlaceholder { - - public static final Tier DEFAULT = new Tier(Placeholders.DEFAULT, 100, "Default", ChatColor.WHITE, new HashMap<>()); - - static { - Stream.of(ObtainType.values()).forEach(type -> DEFAULT.getChance().put(type, 100D)); - } +public class Tier implements Placeholder { private final String id; private final int priority; private final String name; private final ChatColor color; private final Map chance; - - private final Set enchants; + private final PlaceholderMap placeholderMap; public Tier(@NotNull String id, int priority, @NotNull String name, @NotNull ChatColor color, @NotNull Map chance) { @@ -41,16 +26,16 @@ public class Tier implements IPlaceholder { this.name = Colorizer.apply(name); this.color = color; this.chance = chance; - this.enchants = new HashSet<>(); + this.placeholderMap = new PlaceholderMap() + .add(Placeholders.TIER_ID, this::getId) + .add(Placeholders.TIER_NAME, this::getName) + ; } @Override @NotNull - public UnaryOperator replacePlaceholders() { - return str -> str - .replace(Placeholders.TIER_ID, this.getId()) - .replace(Placeholders.TIER_NAME, this.getName()) - ; + public PlaceholderMap getPlaceholders() { + return this.placeholderMap; } @NotNull @@ -80,24 +65,4 @@ public class Tier implements IPlaceholder { public double getChance(@NotNull ObtainType obtainType) { return this.getChance().getOrDefault(obtainType, 0D); } - - @NotNull - public Set getEnchants() { - return this.enchants; - } - - @NotNull - public Set getEnchants(@NotNull ObtainType obtainType) { - return this.getEnchants(obtainType, null); - } - - @NotNull - public Set getEnchants(@NotNull ObtainType obtainType, @Nullable ItemStack item) { - Set set = this.getEnchants().stream() - .filter(enchant -> enchant.getObtainChance(obtainType) > 0) - .filter(enchant -> item == null || enchant.canEnchantItem(item)) - .collect(Collectors.toCollection(HashSet::new)); - set.removeIf(enchant -> obtainType == ObtainType.ENCHANTING && (enchant.isTreasure() || enchant.isCursed())); - return set; - } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java b/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java index 14b2d85..a0cbc46 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java @@ -14,6 +14,8 @@ import java.util.stream.Collectors; public class TierManager extends AbstractManager { + public static final String FILE_NAME = "tiers.yml"; + private JYML config; private final Map tiers; @@ -30,7 +32,7 @@ public class TierManager extends AbstractManager { return; }*/ - this.config = JYML.loadOrExtract(plugin, "tiers.yml"); + this.config = JYML.loadOrExtract(plugin, FILE_NAME); for (String sId : config.getSection("")) { String path = sId + "."; @@ -58,10 +60,6 @@ public class TierManager extends AbstractManager { this.tiers.put(tier.getId(), tier); } - if (this.tiers.isEmpty()) { - this.tiers.put(Tier.DEFAULT.getId(), Tier.DEFAULT); - } - this.plugin.info("Tiers Loaded: " + this.tiers.size()); } @@ -93,6 +91,22 @@ public class TierManager extends AbstractManager { @Nullable public Tier getTierByChance(@NotNull ObtainType obtainType) { Map map = this.getTiers().stream().collect(Collectors.toMap(k -> k, v -> v.getChance(obtainType))); - return Rnd.get(map); + return Rnd.getByWeight(map); + } + + @NotNull + public Tier getMostCommon() { + return this.getTiers().stream().min(Comparator.comparingInt(Tier::getPriority)).orElseThrow(); + } + + @NotNull + public Tier getByRarityModifier(double point) { + int minPriority = this.getTiers().stream().mapToInt(Tier::getPriority).min().orElse(0); + int maxPriority = this.getTiers().stream().mapToInt(Tier::getPriority).max().orElse(0); + + int threshold = (int) Math.ceil(minPriority + (maxPriority - minPriority) * point); + + return this.getTiers().stream().filter(tier -> tier.getPriority() <= threshold) + .max(Comparator.comparingInt(tier -> tier.getPriority() - threshold)).orElse(this.getMostCommon()); } } diff --git a/Core/src/main/resources/config.yml b/Core/src/main/resources/config.yml index 6bf4949..9fa4a0a 100644 --- a/Core/src/main/resources/config.yml +++ b/Core/src/main/resources/config.yml @@ -1,4 +1,2 @@ Plugin: - Command_Aliases: 'excellentenchants,eenchants' - Language: 'en' - Name: 'ExcellentEnchants' \ No newline at end of file + Command_Aliases: 'excellentenchants,eenchants' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/aquaman.yml b/Core/src/main/resources/enchants/aquaman.yml deleted file mode 100644 index d98f1bb..0000000 --- a/Core/src/main/resources/enchants/aquaman.yml +++ /dev/null @@ -1,8 +0,0 @@ -Name: Aquaman -Tier: exotic -Description: -- 'Grants permanent %enchantment_potion_type% %enchantment_potion_level% effect.' -Conflicts: [] -Level: - Min: 1 - Max: 1 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/bane_of_netherspawn.yml b/Core/src/main/resources/enchants/bane_of_netherspawn.yml deleted file mode 100644 index 9b73299..0000000 --- a/Core/src/main/resources/enchants/bane_of_netherspawn.yml +++ /dev/null @@ -1,12 +0,0 @@ -Name: Bane of Netherspawn -Tier: common -Description: -- 'Inflicts %enchantment_damage% more damage to nether mobs.' -Conflicts: -- village_defender -- sharpness -- smite -- bane_of_arthropods -Level: - Min: 1 - Max: 5 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/blast_mining.yml b/Core/src/main/resources/enchants/blast_mining.yml deleted file mode 100644 index 6006b23..0000000 --- a/Core/src/main/resources/enchants/blast_mining.yml +++ /dev/null @@ -1,12 +0,0 @@ -Name: Blast Mining -Tier: legendary -Description: -- '%enchantment_trigger_chance%% chance to mine blocks by explosion.' -Conflicts: -- tunnel -- veinminer -Level: - Min: 1 - Max: 5 -Settings: - Trigger_Chance: 20.0 * %enchantment_level% \ No newline at end of file diff --git a/Core/src/main/resources/enchants/blindness.yml b/Core/src/main/resources/enchants/blindness.yml deleted file mode 100644 index d7ceaee..0000000 --- a/Core/src/main/resources/enchants/blindness.yml +++ /dev/null @@ -1,13 +0,0 @@ -Name: Blindness -Tier: common -Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 15.0 + %enchantment_level% * 3 - Potion_Effect: - Duration: 3.5 + %enchantment_level% - Level: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/bomber.yml b/Core/src/main/resources/enchants/bomber.yml deleted file mode 100644 index 44137da..0000000 --- a/Core/src/main/resources/enchants/bomber.yml +++ /dev/null @@ -1,22 +0,0 @@ -Name: Bomber -Tier: exotic -Description: -- '%enchantment_trigger_chance%% chance to launch TNT that explodes in %enchantment_fuse_ticks%s.' -Conflicts: -- ender_bow -- ghast -- explosive_arrows -- withered_arrows -- poisoned_arrows -- dragonfire_arrows -- electrified_arrows -- confusing_arrows -- flame -- power -- punch -- hover -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 5.0 * %enchantment_level% \ No newline at end of file diff --git a/Core/src/main/resources/enchants/bunny_hop.yml b/Core/src/main/resources/enchants/bunny_hop.yml deleted file mode 100644 index c27acba..0000000 --- a/Core/src/main/resources/enchants/bunny_hop.yml +++ /dev/null @@ -1,8 +0,0 @@ -Name: 'Bunny Hop' -Tier: 'common' -Description: -- 'Grants permanent %enchantment_potion_type% %enchantment_potion_level% effect.' -Conflicts: [] -Level: - Min: 1 - Max: 3 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/cold_steel.yml b/Core/src/main/resources/enchants/cold_steel.yml deleted file mode 100644 index 7955bb5..0000000 --- a/Core/src/main/resources/enchants/cold_steel.yml +++ /dev/null @@ -1,13 +0,0 @@ -Name: Cold Steel -Tier: rare -Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on attacker.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: '60.0 + %enchantment_level% * 5' - Potion_Effect: - Duration: '4.0 + %enchantment_level%' - Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/confusing_arrows.yml b/Core/src/main/resources/enchants/confusing_arrows.yml deleted file mode 100644 index 1d6d724..0000000 --- a/Core/src/main/resources/enchants/confusing_arrows.yml +++ /dev/null @@ -1,22 +0,0 @@ -Name: Confusing Arrows -Tier: common -Description: -- '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' -Conflicts: - - dragonfire_arrows - - poisoned_arrows - - explosive_arrows - - withered_arrows - - electrified_arrows - - bomber - - ender_bow - - hover - - ghast -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 20.0 + %enchantment_level% * 5.0 - Potion_Effect: - Duration: 6.0 + %enchantment_level% * 3.0 - Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/confusion.yml b/Core/src/main/resources/enchants/confusion.yml deleted file mode 100644 index d3525b7..0000000 --- a/Core/src/main/resources/enchants/confusion.yml +++ /dev/null @@ -1,13 +0,0 @@ -Name: Confusion -Tier: common -Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 15.0 * %enchantment_level% - Potion_Effect: - Duration: 5.0 + %enchantment_level% * 1.5 - Level: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/cure.yml b/Core/src/main/resources/enchants/cure.yml deleted file mode 100644 index 3e24590..0000000 --- a/Core/src/main/resources/enchants/cure.yml +++ /dev/null @@ -1,10 +0,0 @@ -Name: Cure -Tier: exotic -Description: -- '%enchantment_trigger_chance%% chance to cure Zombified Piglins and Zombie Villagers on hit.' -Conflicts: [] -Level: - Min: 1 - Max: 5 -Settings: - Trigger_Chance: 20.0 + %enchantment_level% * 8 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/curse_of_breaking.yml b/Core/src/main/resources/enchants/curse_of_breaking.yml deleted file mode 100644 index f6fb9f8..0000000 --- a/Core/src/main/resources/enchants/curse_of_breaking.yml +++ /dev/null @@ -1,12 +0,0 @@ -Name: Curse of Breaking -Tier: cursed -Description: -- '%enchantment_trigger_chance%% chance to consume extra %enchantment_durability_amount% durability points.' -Conflicts: -- unbreaking -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 10.0 * %enchantment_level% - Durability_Amount: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/curse_of_fragility.yml b/Core/src/main/resources/enchants/curse_of_fragility.yml deleted file mode 100644 index 50e2c21..0000000 --- a/Core/src/main/resources/enchants/curse_of_fragility.yml +++ /dev/null @@ -1,7 +0,0 @@ -Name: 'Curse of Fragility' -Tier: cursed -Description: - - 'Prevents an item from being grindstoned or anviled.' -Level: - Min: 1 - Max: 1 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/curse_of_misfortune.yml b/Core/src/main/resources/enchants/curse_of_misfortune.yml deleted file mode 100644 index a9f00a6..0000000 --- a/Core/src/main/resources/enchants/curse_of_misfortune.yml +++ /dev/null @@ -1,12 +0,0 @@ -Name: Curse of Misfortune -Tier: cursed -Description: -- '%enchantment_trigger_chance%% chance to have no drops from blocks or mobs.' -Conflicts: -- fortune -- looting -Level: - Min: 1 - Max: 1 -Settings: - Trigger_Chance: 20.0 * %enchantment_level% \ No newline at end of file diff --git a/Core/src/main/resources/enchants/cutter.yml b/Core/src/main/resources/enchants/cutter.yml deleted file mode 100644 index 086afad..0000000 --- a/Core/src/main/resources/enchants/cutter.yml +++ /dev/null @@ -1,10 +0,0 @@ -Name: Cutter -Tier: exotic -Description: -- '%enchantment_trigger_chance%% chance to throw away enemy''s armor and damage it for %enchantment_durability_damage%%.' -Conflicts: [] -Level: - Min: 1 - Max: 5 -Settings: - Trigger_Chance: 1.0 + %enchantment_level% * 0.6 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/decapitator.yml b/Core/src/main/resources/enchants/decapitator.yml deleted file mode 100644 index 503bd0c..0000000 --- a/Core/src/main/resources/enchants/decapitator.yml +++ /dev/null @@ -1,82 +0,0 @@ -Name: Decapitator -Tier: exotic -Description: -- '%enchantment_trigger_chance%% chance to obtain player''s or mob''s head.' -Conflicts: [] -Level: - Min: 1 - Max: 4 -Settings: - Trigger_Chance: 5.0 + %enchantment_level% * 1.75 - Ignored_Entity_Types: - - BAT - - BEE - - ENDER_DRAGON - - WITHER_SKELETON - - WITHER - Head_Item: - Textures: - AXOLOTL: ey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Y2M1ZmFlNWE4YTQ5Yzg4NjNmZjQ4MzFhYWEyODQxOThmMWEyMzk4ODkwYzc2NWUwYThkZTE4ZGE4YyJ9fX0= - ZOMBIE_HORSE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDIyOTUwZjJkM2VmZGRiMThkZTg2ZjhmNTVhYzUxOGRjZTczZjEyYTZlMGY4NjM2ZDU1MWQ4ZWI0ODBjZWVjIn19fQ== - ZOMBIE_VILLAGER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTVlMDhhODc3NmMxNzY0YzNmZTZhNmRkZDQxMmRmY2I4N2Y0MTMzMWRhZDQ3OWFjOTZjMjFkZjRiZjNhYzg5YyJ9fX0= - SKELETON_HORSE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDdlZmZjZTM1MTMyYzg2ZmY3MmJjYWU3N2RmYmIxZDIyNTg3ZTk0ZGYzY2JjMjU3MGVkMTdjZjg5NzNhIn19fQ== diff --git a/Core/src/main/resources/enchants/divine_touch.yml b/Core/src/main/resources/enchants/divine_touch.yml deleted file mode 100644 index fdb7458..0000000 --- a/Core/src/main/resources/enchants/divine_touch.yml +++ /dev/null @@ -1,11 +0,0 @@ -Name: Divine Touch -Tier: legendary -Description: -- '%enchantment_trigger_chance%% chance to mine spawner.' -Conflicts: -- smelter -Level: - Min: 1 - Max: 5 -Settings: - Trigger_Chance: 15.0 * %enchantment_level% \ No newline at end of file diff --git a/Core/src/main/resources/enchants/double_strike.yml b/Core/src/main/resources/enchants/double_strike.yml deleted file mode 100644 index d47a0d6..0000000 --- a/Core/src/main/resources/enchants/double_strike.yml +++ /dev/null @@ -1,10 +0,0 @@ -Name: Double Strike -Tier: legendary -Description: -- '%enchantment_trigger_chance%% chance to inflict double damage.' -Conflicts: [] -Level: - Min: 1 - Max: 4 -Settings: - Trigger_Chance: 4.0 + %enchantment_level% * 0.8 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/dragonfire_arrows.yml b/Core/src/main/resources/enchants/dragonfire_arrows.yml deleted file mode 100644 index f7563c7..0000000 --- a/Core/src/main/resources/enchants/dragonfire_arrows.yml +++ /dev/null @@ -1,23 +0,0 @@ -Name: Dragonfire Arrows -Tier: exotic -Description: -- '%enchantment_trigger_chance%% chance to launch an dragonfire arrow (R=%enchantment_fire_radius%, %enchantment_fire_duration%s).' -Conflicts: -- confusing_arrows -- poisoned_arrows -- explosive_arrows -- withered_arrows -- electrified_arrows -- bomber -- ender_bow -- hover -- ghast -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 10.0 + %enchantment_level% * 5 - Arrow: - Trail_Effect: - Name: DRAGON_BREATH - Data: '' diff --git a/Core/src/main/resources/enchants/electrified_arrows.yml b/Core/src/main/resources/enchants/electrified_arrows.yml deleted file mode 100644 index 6ae4b30..0000000 --- a/Core/src/main/resources/enchants/electrified_arrows.yml +++ /dev/null @@ -1,23 +0,0 @@ -Name: Electrified Arrows -Tier: rare -Description: -- '%enchantment_trigger_chance%% chance to launch an electrified arrow.' -Conflicts: -- confusing_arrows -- poisoned_arrows -- explosive_arrows -- withered_arrows -- dragonfire_arrows -- bomber -- ender_bow -- ghast -- hover -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 10.0 + %enchantment_level% * 5 - Arrow: - Trail_Effect: - Name: FIREWORKS_SPARK - Data: '' diff --git a/Core/src/main/resources/enchants/elemental_protection.yml b/Core/src/main/resources/enchants/elemental_protection.yml deleted file mode 100644 index 81688a4..0000000 --- a/Core/src/main/resources/enchants/elemental_protection.yml +++ /dev/null @@ -1,8 +0,0 @@ -Name: Elemental Protection -Tier: common -Description: -- 'Reduces Poison, Magic, Wither, Lightning, Freeze damage by %enchantment_protection_amount%.' -Conflicts: [] -Level: - Min: 1 - Max: 5 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/ender_bow.yml b/Core/src/main/resources/enchants/ender_bow.yml deleted file mode 100644 index dbc4ec1..0000000 --- a/Core/src/main/resources/enchants/ender_bow.yml +++ /dev/null @@ -1,20 +0,0 @@ -Name: Ender Bow -Tier: legendary -Description: -- 'Shoots ender pearls instead of arrows.' -Conflicts: -- bomber -- ghast -- explosive_arrows -- withered_arrows -- poisoned_arrows -- dragonfire_arrows -- electrified_arrows -- confusing_arrows -- flame -- power -- punch -- hover -Level: - Min: 1 - Max: 1 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/exhaust.yml b/Core/src/main/resources/enchants/exhaust.yml deleted file mode 100644 index 9a6a3b4..0000000 --- a/Core/src/main/resources/enchants/exhaust.yml +++ /dev/null @@ -1,13 +0,0 @@ -Name: Exhaust -Tier: common -Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 20.0 * %enchantment_level% - Potion_Effect: - Duration: 3.0 + %enchantment_level% * 1.5 - Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/exp_hunter.yml b/Core/src/main/resources/enchants/exp_hunter.yml deleted file mode 100644 index 373ef01..0000000 --- a/Core/src/main/resources/enchants/exp_hunter.yml +++ /dev/null @@ -1,10 +0,0 @@ -Name: Exp Hunter -Tier: rare -Description: -- 'Increases exp drop from mobs by %enchantment_exp_modifier%%.' -Conflicts: [] -Level: - Min: 1 - Max: 5 -Settings: - Trigger_Chance: 50.0 + %enchantment_level% * 5 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/explosive_arrows.yml b/Core/src/main/resources/enchants/explosive_arrows.yml deleted file mode 100644 index bab2c79..0000000 --- a/Core/src/main/resources/enchants/explosive_arrows.yml +++ /dev/null @@ -1,23 +0,0 @@ -Name: Explosive Arrows -Tier: exotic -Description: -- '%enchantment_trigger_chance%% chance to launch an explosive arrow.' -Conflicts: -- confusing_arrows -- poisoned_arrows -- dragonfire_arrows -- withered_arrows -- electrified_arrows -- bomber -- ender_bow -- ghast -- hover -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 10.0 + %enchantment_level% * 5 - Arrow: - Trail_Effect: - Name: SMOKE_NORMAL - Data: '' diff --git a/Core/src/main/resources/enchants/fire_shield.yml b/Core/src/main/resources/enchants/fire_shield.yml deleted file mode 100644 index ecbea83..0000000 --- a/Core/src/main/resources/enchants/fire_shield.yml +++ /dev/null @@ -1,10 +0,0 @@ -Name: Fire Shield -Tier: rare -Description: -- '%enchantment_trigger_chance%% chance to ignite the attacker for %enchantment_fire_duration%s.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: '%enchantment_level% * 15.0' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/flame_walker.yml b/Core/src/main/resources/enchants/flame_walker.yml deleted file mode 100644 index e3bc6db..0000000 --- a/Core/src/main/resources/enchants/flame_walker.yml +++ /dev/null @@ -1,9 +0,0 @@ -Name: 'Flame Walker' -Tier: 'exotic' -Description: -- 'Ability to walk on lava and magma blocks without getting damage.' -Conflicts: -- 'frost_walker' -Level: - Min: 1 - Max: 3 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/ghast.yml b/Core/src/main/resources/enchants/ghast.yml deleted file mode 100644 index 2972307..0000000 --- a/Core/src/main/resources/enchants/ghast.yml +++ /dev/null @@ -1,20 +0,0 @@ -Name: Ghast -Tier: rare -Description: -- 'Shoots fireballs instead of arrows.' -Conflicts: -- ender_bow -- bomber -- explosive_arrows -- withered_arrows -- poisoned_arrows -- dragonfire_arrows -- electrified_arrows -- confusing_arrows -- flame -- punch -- hover -- power -Level: - Min: 1 - Max: 3 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/hardened.yml b/Core/src/main/resources/enchants/hardened.yml deleted file mode 100644 index 74062a0..0000000 --- a/Core/src/main/resources/enchants/hardened.yml +++ /dev/null @@ -1,12 +0,0 @@ -Name: 'Hardened' -Tier: 'rare' -Description: -- '%enchantment_trigger_chance%% chance to obtain %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) when damaged.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Potion_Effect: - Duration: '3.0 + %enchantment_level%' - Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/haste.yml b/Core/src/main/resources/enchants/haste.yml deleted file mode 100644 index 06bca78..0000000 --- a/Core/src/main/resources/enchants/haste.yml +++ /dev/null @@ -1,8 +0,0 @@ -Name: Haste -Tier: rare -Description: -- 'Grants permanent %enchantment_potion_type% %enchantment_potion_level% effect.' -Conflicts: [] -Level: - Min: 1 - Max: 3 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/hover.yml b/Core/src/main/resources/enchants/hover.yml deleted file mode 100644 index ed4f404..0000000 --- a/Core/src/main/resources/enchants/hover.yml +++ /dev/null @@ -1,22 +0,0 @@ -Name: Hover -Tier: common -Description: -- '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' -Conflicts: - - confusing_arrows - - poisoned_arrows - - dragonfire_arrows - - withered_arrows - - electrified_arrows - - explosive_arrows - - bomber - - ender_bow - - ghast -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 10.0 + %enchantment_level% * 5 - Potion_Effect: - Duration: 2.5 + %enchantment_level% - Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/ice_aspect.yml b/Core/src/main/resources/enchants/ice_aspect.yml deleted file mode 100644 index 2345e8d..0000000 --- a/Core/src/main/resources/enchants/ice_aspect.yml +++ /dev/null @@ -1,12 +0,0 @@ -Name: Ice Aspect -Tier: common -Description: -- 'Freezes and applies %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Potion_Effect: - Duration: 3.0 + %enchantment_level% - Level: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/ice_shield.yml b/Core/src/main/resources/enchants/ice_shield.yml deleted file mode 100644 index 6ca6f88..0000000 --- a/Core/src/main/resources/enchants/ice_shield.yml +++ /dev/null @@ -1,13 +0,0 @@ -Name: Ice Shield -Tier: common -Description: - - '%enchantment_trigger_chance%% chance to freeze and apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on attacker.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 25.0 * %enchantment_level% - Potion_Effect: - Duration: 3.0 + %enchantment_level% - Level: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/infernus.yml b/Core/src/main/resources/enchants/infernus.yml deleted file mode 100644 index d9a02e0..0000000 --- a/Core/src/main/resources/enchants/infernus.yml +++ /dev/null @@ -1,10 +0,0 @@ -Name: Infernus -Tier: common -Description: -- 'Launched trident will ignite the enemy for %enchantment_fire_duration%s. on hit.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Fire_Ticks: 60 + %enchantment_level% * 20 diff --git a/Core/src/main/resources/enchants/lucky_miner.yml b/Core/src/main/resources/enchants/lucky_miner.yml deleted file mode 100644 index 578f0f3..0000000 --- a/Core/src/main/resources/enchants/lucky_miner.yml +++ /dev/null @@ -1,10 +0,0 @@ -Name: Lucky Miner -Tier: common -Description: -- '%enchantment_trigger_chance%% chance to gain %enchantment_exp_modifier%% more exp from ores.' -Conflicts: [] -Level: - Min: 1 - Max: 5 -Settings: - Trigger_Chance: 30.0 + %enchantment_level% * 7.0 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/night_vision.yml b/Core/src/main/resources/enchants/night_vision.yml deleted file mode 100644 index dde8448..0000000 --- a/Core/src/main/resources/enchants/night_vision.yml +++ /dev/null @@ -1,7 +0,0 @@ -Name: Night Vision -Tier: rare -Description: -- 'Grants permanent %enchantment_potion_type% %enchantment_potion_level% effect.' -Level: - Min: 1 - Max: 1 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/nimble.yml b/Core/src/main/resources/enchants/nimble.yml deleted file mode 100644 index 47a8a82..0000000 --- a/Core/src/main/resources/enchants/nimble.yml +++ /dev/null @@ -1,7 +0,0 @@ -Name: Nimble -Tier: rare -Description: -- Moves all mob's loot directly to your inventory. -Level: - Min: 1 - Max: 1 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/paralyze.yml b/Core/src/main/resources/enchants/paralyze.yml deleted file mode 100644 index 6413305..0000000 --- a/Core/src/main/resources/enchants/paralyze.yml +++ /dev/null @@ -1,13 +0,0 @@ -Name: Paralyze -Tier: rare -Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 10.0 * %enchantment_level% - Potion_Effect: - Duration: 2.5 + %enchantment_level% * 0.5 - Level: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/poisoned_arrows.yml b/Core/src/main/resources/enchants/poisoned_arrows.yml deleted file mode 100644 index 37d2f6f..0000000 --- a/Core/src/main/resources/enchants/poisoned_arrows.yml +++ /dev/null @@ -1,22 +0,0 @@ -Name: Poisoned Arrows -Tier: common -Description: -- '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' -Conflicts: -- confusing_arrows -- dragonfire_arrows -- explosive_arrows -- withered_arrows -- electrified_arrows -- bomber -- ghast -- ender_bow -- hover -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 25.0 + %enchantment_level% * 5 - Potion_Effect: - Duration: 2.5 + %enchantment_level% - Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/rage.yml b/Core/src/main/resources/enchants/rage.yml deleted file mode 100644 index cfee35e..0000000 --- a/Core/src/main/resources/enchants/rage.yml +++ /dev/null @@ -1,13 +0,0 @@ -Name: Rage -Tier: rare -Description: -- '%enchantment_trigger_chance%% chance to get %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 7.0 + %enchantment_level% - Potion_Effect: - Duration: 3.0 + %enchantment_level% * 0.5 - Level: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/regrowth.yml b/Core/src/main/resources/enchants/regrowth.yml deleted file mode 100644 index 0c3308b..0000000 --- a/Core/src/main/resources/enchants/regrowth.yml +++ /dev/null @@ -1,10 +0,0 @@ -Name: Regrowth -Tier: exotic -Description: -- Restores %enchantment_heal_amount% hearts every %enchantment_heal_interval%s. -Conflicts: [] -Level: - Min: 1 - Max: 5 -Settings: - Trigger_Chance: 20.0 + %enchantment_level% * 5 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/replanter.yml b/Core/src/main/resources/enchants/replanter.yml deleted file mode 100644 index f2f6860..0000000 --- a/Core/src/main/resources/enchants/replanter.yml +++ /dev/null @@ -1,7 +0,0 @@ -Name: Replanter -Tier: common -Description: -- Automatically replant crops on right click and when harvest. -Level: - Min: 1 - Max: 1 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/rocket.yml b/Core/src/main/resources/enchants/rocket.yml deleted file mode 100644 index b6927d4..0000000 --- a/Core/src/main/resources/enchants/rocket.yml +++ /dev/null @@ -1,10 +0,0 @@ -Name: Rocket -Tier: exotic -Description: -- '%enchantment_trigger_chance%% chance to launch your enemy into the space.' -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 4.0 + %enchantment_level% - Firework_Power: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/saturation.yml b/Core/src/main/resources/enchants/saturation.yml deleted file mode 100644 index d509d1f..0000000 --- a/Core/src/main/resources/enchants/saturation.yml +++ /dev/null @@ -1,8 +0,0 @@ -Name: Saturation -Tier: rare -Description: -- Restores %enchantment_saturation_amount% food points every %enchantment_saturation_interval%s. -Conflicts: [] -Level: - Min: 1 - Max: 3 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/scavenger.yml b/Core/src/main/resources/enchants/scavenger.yml deleted file mode 100644 index 504c30b..0000000 --- a/Core/src/main/resources/enchants/scavenger.yml +++ /dev/null @@ -1,22 +0,0 @@ -Name: Scavenger -Tier: common -Description: -- '%enchantment_trigger_chance%% chance to obtain additional loot from mobs.' -Level: - Min: 1 - Max: 4 -Settings: - Trigger_Chance: 15.0 + %enchantment_level% * 10 - Treasures: - # Entity type to have an additional drop from. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html - VILLAGER: - # Material name for the item to drop. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - EMERALD: - Amount: '1:1' - Chance: 5.0 - SKELETON: - BONE_MEAL: - Amount: '1:2' - Chance: 50.0 diff --git a/Core/src/main/resources/enchants/self_destruction.yml b/Core/src/main/resources/enchants/self_destruction.yml deleted file mode 100644 index b7f4e7e..0000000 --- a/Core/src/main/resources/enchants/self_destruction.yml +++ /dev/null @@ -1,11 +0,0 @@ -Name: Self-Destruction -Tier: exotic -Description: -- '%enchantment_trigger_chance%% chance to create an explosion on death.' -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 20.0 + %enchantment_level% * 10 - Explosion: - Size: 1.0 + %enchantment_level% diff --git a/Core/src/main/resources/enchants/silk_chest.yml b/Core/src/main/resources/enchants/silk_chest.yml deleted file mode 100644 index 78b988a..0000000 --- a/Core/src/main/resources/enchants/silk_chest.yml +++ /dev/null @@ -1,8 +0,0 @@ -Name: Silk Chest -Tier: rare -Description: -- Drop chests and saves all its content. -Conflicts: [] -Level: - Min: 1 - Max: 1 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/smelter.yml b/Core/src/main/resources/enchants/smelter.yml deleted file mode 100644 index e5c8f55..0000000 --- a/Core/src/main/resources/enchants/smelter.yml +++ /dev/null @@ -1,17 +0,0 @@ -Name: Smelter -Tier: rare -Description: -- '%enchantment_trigger_chance%% chance to smelt a block/ore.' -Conflicts: - - silk_touch - - divine_touch -Level: - Min: 1 - Max: 5 -Settings: - Trigger_Chance: 25.0 + %enchantment_level% * 10 - Smelting_Table: - IRON_ORE: IRON_INGOT - GOLD_ORE: GOLD_INGOT - RAW_IRON: IRON_INGOT - RAW_GOLD: GOLD_INGOT \ No newline at end of file diff --git a/Core/src/main/resources/enchants/sonic.yml b/Core/src/main/resources/enchants/sonic.yml deleted file mode 100644 index 5804a3e..0000000 --- a/Core/src/main/resources/enchants/sonic.yml +++ /dev/null @@ -1,8 +0,0 @@ -Name: Sonic -Tier: rare -Description: -- Grants permanent %enchantment_potion_type% %enchantment_potion_level% effect. -Conflicts: [] -Level: - Min: 1 - Max: 3 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/surprise.yml b/Core/src/main/resources/enchants/surprise.yml deleted file mode 100644 index d0298fa..0000000 --- a/Core/src/main/resources/enchants/surprise.yml +++ /dev/null @@ -1,12 +0,0 @@ -Name: Surprise -Tier: exotic -Description: -- '%enchantment_trigger_chance%% chance to apply random potion effect to enemy on hit.' -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 2.25 * %enchantment_level% - Potion_Effect: - Duration: 3.0 + %enchantment_level% - Level: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/telekinesis.yml b/Core/src/main/resources/enchants/telekinesis.yml deleted file mode 100644 index 18687d3..0000000 --- a/Core/src/main/resources/enchants/telekinesis.yml +++ /dev/null @@ -1,8 +0,0 @@ -Name: Telekinesis -Tier: exotic -Description: -- Moves all blocks loot directly to your inventory. -Conflicts: [] -Level: - Min: 1 - Max: 1 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/temper.yml b/Core/src/main/resources/enchants/temper.yml deleted file mode 100644 index 72766a9..0000000 --- a/Core/src/main/resources/enchants/temper.yml +++ /dev/null @@ -1,8 +0,0 @@ -Name: Temper -Tier: rare -Description: -- 'Inflicts %enchantment_damage_amount%% (max. %enchantment_damage_capacity%%) more damage for each %enchantment_health_point% hearts missing.' -Conflicts: [] -Level: - Min: 1 - Max: 5 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/thrifty.yml b/Core/src/main/resources/enchants/thrifty.yml deleted file mode 100644 index 6f26018..0000000 --- a/Core/src/main/resources/enchants/thrifty.yml +++ /dev/null @@ -1,10 +0,0 @@ -Name: Thrifty -Tier: exotic -Description: -- '%enchantment_trigger_chance%% chance to obtain mob spawn egg on kill.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 5.0 + %enchantment_level% * 3 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/thunder.yml b/Core/src/main/resources/enchants/thunder.yml deleted file mode 100644 index fee3d31..0000000 --- a/Core/src/main/resources/enchants/thunder.yml +++ /dev/null @@ -1,9 +0,0 @@ -Name: Thunder -Tier: rare -Description: -- '%enchantment_trigger_chance%% chance to summon lightning to enemy on hit.' -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 10.0 * %enchantment_level% \ No newline at end of file diff --git a/Core/src/main/resources/enchants/treasures.yml b/Core/src/main/resources/enchants/treasures.yml deleted file mode 100644 index 2a9490c..0000000 --- a/Core/src/main/resources/enchants/treasures.yml +++ /dev/null @@ -1,33 +0,0 @@ -Name: Treasures -Tier: common -Description: -- '%enchantment_trigger_chance%% chance to attempt to find a treasure in mined block.' -Level: - Min: 1 - Max: 5 -Settings: - Trigger_Chance: 10.0 + %enchantment_level% * 4.0 - Treasures: - STONE,GRANITE,ANDESITE,DIORITE: - BONE_MEAL: 2.0 - CLAY: - SLIME_BALL: 7.0 - DIRT,PODZOL,COARSE_DIRT,ROOTED_DIRT: - CLAY_BALL: 0.5 - BOWL: 1.0 - STICK: 2.0 - SAND,RED_SAND: - GLOWSTONE_DUST: 1.0 - GOLD_NUGGET: 0.3 - SOUL_SAND: - FLINT: 1.5 - GUNPOWDER: 0.8 - COAL: 0.4 - NETHERRACK: - BRICK: 0.05 - END_STONE: - ENDER_PEARL: 0.1 - OAK_LEAVES,BIRCH_LEAVES,SPRUCE_LEAVES,ACACIA_LEAVES,JUNGLE_LEAVES,DARK_OAK_LEAVES: - APPLE: 15.0 - MOSSY_COBBLESTONE,MOSSY_STONE_BRICKS: - VINE: 50.0 diff --git a/Core/src/main/resources/enchants/tunnel.yml b/Core/src/main/resources/enchants/tunnel.yml deleted file mode 100644 index 5ef298c..0000000 --- a/Core/src/main/resources/enchants/tunnel.yml +++ /dev/null @@ -1,10 +0,0 @@ -Name: Tunnel -Tier: legendary -Description: -- Mines multiple blocks at once in a certain shape. -Conflicts: -- veinminer -- blast_mining -Level: - Min: 1 - Max: 3 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/vampire.yml b/Core/src/main/resources/enchants/vampire.yml deleted file mode 100644 index ca12389..0000000 --- a/Core/src/main/resources/enchants/vampire.yml +++ /dev/null @@ -1,10 +0,0 @@ -Name: Vampire -Tier: exotic -Description: -- '%enchantment_trigger_chance%% chance to heal for %enchantment_heal_amount% heart(s) on hit.' -Conflicts: [] -Level: - Min: 1 - Max: 4 -Settings: - Trigger_Chance: 25.0 + %enchantment_level% * 5.0 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/veinminer.yml b/Core/src/main/resources/enchants/veinminer.yml deleted file mode 100644 index 794eb65..0000000 --- a/Core/src/main/resources/enchants/veinminer.yml +++ /dev/null @@ -1,32 +0,0 @@ -Name: Veinminer -Tier: rare -Description: -- Mines up to %enchantment_block_limit% blocks of the ore vein at once. -Conflicts: -- blast_mining -- tunnel -Level: - Min: 1 - Max: 3 -Settings: - Blocks: - Max_At_Once: 6 + %enchantment_level% - Affected: - - COAL_ORE - - GOLD_ORE - - IRON_ORE - - DIAMOND_ORE - - EMERALD_ORE - - LAPIS_ORE - - REDSTONE_ORE - - COPPER_ORE - - DEEPSLATE_COAL_ORE - - DEEPSLATE_GOLD_ORE - - DEEPSLATE_IRON_ORE - - DEEPSLATE_DIAMOND_ORE - - DEEPSLATE_EMERALD_ORE - - DEEPSLATE_LAPIS_ORE - - DEEPSLATE_REDSTONE_ORE - - DEEPSLATE_COPPER_ORE - - NETHER_QUARTZ_ORE - - NETHER_GOLD_ORE diff --git a/Core/src/main/resources/enchants/venom.yml b/Core/src/main/resources/enchants/venom.yml deleted file mode 100644 index fb8d652..0000000 --- a/Core/src/main/resources/enchants/venom.yml +++ /dev/null @@ -1,13 +0,0 @@ -Name: Venom -Tier: rare -Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 30.0 + %enchantment_level% * 10.0 - Potion_Effect: - Duration: 2.0 + %enchantment_level% - Level: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/village_defender.yml b/Core/src/main/resources/enchants/village_defender.yml deleted file mode 100644 index ee7e62a..0000000 --- a/Core/src/main/resources/enchants/village_defender.yml +++ /dev/null @@ -1,12 +0,0 @@ -Name: Village Defender -Tier: common -Description: -- 'Inflicts %enchantment_damage_amount% more damage to all pillagers.' -Conflicts: -- bane_of_netherspawn -- sharpness -- smite -- bane_of_arthropods -Level: - Min: 1 - Max: 5 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/wither.yml b/Core/src/main/resources/enchants/wither.yml deleted file mode 100644 index 49a3b59..0000000 --- a/Core/src/main/resources/enchants/wither.yml +++ /dev/null @@ -1,13 +0,0 @@ -Name: Wither -Tier: rare -Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' -Conflicts: [] -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 10.0 + %enchantment_level% * 5 - Potion_Effect: - Duration: 3.0 + %enchantment_level% - Level: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/withered_arrows.yml b/Core/src/main/resources/enchants/withered_arrows.yml deleted file mode 100644 index 403db5e..0000000 --- a/Core/src/main/resources/enchants/withered_arrows.yml +++ /dev/null @@ -1,22 +0,0 @@ -Name: Withered Arrows -Tier: rare -Description: -- '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' -Conflicts: -- confusing_arrows -- poisoned_arrows -- explosive_arrows -- dragonfire_arrows -- electrified_arrows -- bomber -- ender_bow -- ghast -- hover -Level: - Min: 1 - Max: 3 -Settings: - Trigger_Chance: 15.0 + %enchantment_level% * 5.0 - Potion_Effect: - Duration: 2.5 + %enchantment_level% * 0.75 - Level: '%enchantment_level%' diff --git a/Core/src/main/resources/menu/enchants_list.yml b/Core/src/main/resources/menu/enchants_list.yml index 861e0ea..3a5f635 100644 --- a/Core/src/main/resources/menu/enchants_list.yml +++ b/Core/src/main/resources/menu/enchants_list.yml @@ -1,5 +1,6 @@ Title: ' #a267f3&lCustom Enchants' Size: 36 +Inventory_Type: CHEST Use_Mini_Message: false Enchantments: diff --git a/NMS/pom.xml b/NMS/pom.xml index f0cbe68..881f994 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.3 + 3.3.4 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index d2cac65..fec6efa 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.3 + 3.3.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.3 + 3.3.4 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 1edc824..113c38c 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.3 + 3.3.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.3 + 3.3.4 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index 5f13bdd..e2121b0 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.3 + 3.3.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.3 + 3.3.4 diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml index 381ca0d..10cd8f8 100644 --- a/V1_19_R2/pom.xml +++ b/V1_19_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.3 + 3.3.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.3 + 3.3.4 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index c268d67..00991b8 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.3 + 3.3.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.3 + 3.3.4 diff --git a/pom.xml b/pom.xml index 26401cb..9743b28 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.3.3 + 3.3.4 Core NMS @@ -21,6 +21,8 @@ 16 16 + UTF-8 + UTF-8