From ab5b19db4dff219a77f8a57a1c978090da79dd7d Mon Sep 17 00:00:00 2001 From: nulli0n Date: Fri, 21 Jan 2022 19:24:32 +0500 Subject: [PATCH 01/69] 3.1.0 --- .gitignore | 13 + Core/pom.xml | 92 ++++++ .../excellentenchants/ExcellentEnchants.java | 122 +++++++ .../nightexpress/excellentenchants/Perms.java | 15 + .../api/enchantment/EnchantPriority.java | 6 + .../api/enchantment/ExcellentEnchant.java | 308 ++++++++++++++++++ .../IEnchantBowPotionTemplate.java | 71 ++++ .../api/enchantment/IEnchantBowTemplate.java | 86 +++++ .../enchantment/IEnchantChanceTemplate.java | 51 +++ .../IEnchantCombatPotionTemplate.java | 53 +++ .../enchantment/IEnchantPotionTemplate.java | 73 +++++ .../enchantment/type/BlockBreakEnchant.java | 11 + .../api/enchantment/type/BowEnchant.java | 15 + .../api/enchantment/type/CombatEnchant.java | 11 + .../enchantment/type/CustomDropEnchant.java | 15 + .../api/enchantment/type/DeathEnchant.java | 10 + .../api/enchantment/type/InteractEnchant.java | 11 + .../api/enchantment/type/MoveEnchant.java | 10 + .../api/enchantment/type/PassiveEnchant.java | 9 + .../command/BookCommand.java | 98 ++++++ .../command/EnchantCommand.java | 105 ++++++ .../command/ListCommand.java | 37 +++ .../command/TierbookCommand.java | 97 ++++++ .../excellentenchants/config/Config.java | 169 ++++++++++ .../excellentenchants/config/Lang.java | 40 +++ .../config/ObtainSettings.java | 37 +++ .../excellentenchants/hook/HookId.java | 6 + .../excellentenchants/hook/HookNCP.java | 23 ++ .../manager/EnchantManager.java | 259 +++++++++++++++ .../manager/EnchantRegister.java | 221 +++++++++++++ .../enchants/armor/EnchantAquaman.java | 35 ++ .../enchants/armor/EnchantBunnyHop.java | 35 ++ .../enchants/armor/EnchantColdSteel.java | 37 +++ .../enchants/armor/EnchantFlameWalker.java | 179 ++++++++++ .../enchants/armor/EnchantHardened.java | 37 +++ .../enchants/armor/EnchantNightVision.java | 35 ++ .../enchants/armor/EnchantRegrowth.java | 119 +++++++ .../enchants/armor/EnchantSaturation.java | 108 ++++++ .../armor/EnchantSelfDestruction.java | 75 +++++ .../manager/enchants/armor/EnchantSonic.java | 35 ++ .../manager/enchants/bow/EnchantBomber.java | 100 ++++++ .../manager/enchants/bow/EnchantEnderBow.java | 69 ++++ .../enchants/bow/EnchantExplosiveArrows.java | 102 ++++++ .../manager/enchants/bow/EnchantGhast.java | 112 +++++++ .../enchants/bow/EnchantPoisonedArrows.java | 17 + .../enchants/bow/EnchantWitheredArrows.java | 17 + .../enchants/tool/EnchantBlastMining.java | 165 ++++++++++ .../enchants/tool/EnchantCurseOfBreaking.java | 75 +++++ .../tool/EnchantCurseOfMisfortune.java | 83 +++++ .../enchants/tool/EnchantDivineTouch.java | 150 +++++++++ .../manager/enchants/tool/EnchantHaste.java | 35 ++ .../enchants/tool/EnchantLuckyMiner.java | 73 +++++ .../enchants/tool/EnchantReplanter.java | 182 +++++++++++ .../enchants/tool/EnchantSilkChest.java | 183 +++++++++++ .../manager/enchants/tool/EnchantSmelter.java | 144 ++++++++ .../enchants/tool/EnchantTelekinesis.java | 151 +++++++++ .../enchants/tool/EnchantTreasures.java | 154 +++++++++ .../manager/enchants/tool/EnchantTunnel.java | 138 ++++++++ .../enchants/tool/EnchantVeinminer.java | 138 ++++++++ .../weapon/EnchantBaneOfNetherspawn.java | 106 ++++++ .../enchants/weapon/EnchantBlindness.java | 17 + .../enchants/weapon/EnchantConfusion.java | 17 + .../manager/enchants/weapon/EnchantCure.java | 79 +++++ .../enchants/weapon/EnchantCutter.java | 102 ++++++ .../enchants/weapon/EnchantDecapitator.java | 122 +++++++ .../enchants/weapon/EnchantDoubleStrike.java | 60 ++++ .../enchants/weapon/EnchantExhaust.java | 17 + .../enchants/weapon/EnchantExpHunter.java | 70 ++++ .../enchants/weapon/EnchantIceAspect.java | 31 ++ .../enchants/weapon/EnchantInfernus.java | 89 +++++ .../enchants/weapon/EnchantNimble.java | 43 +++ .../enchants/weapon/EnchantParalyze.java | 17 + .../manager/enchants/weapon/EnchantRage.java | 25 ++ .../enchants/weapon/EnchantRocket.java | 61 ++++ .../enchants/weapon/EnchantScavenger.java | 97 ++++++ .../enchants/weapon/EnchantSurprise.java | 28 ++ .../enchants/weapon/EnchantThrifty.java | 83 +++++ .../enchants/weapon/EnchantThunder.java | 51 +++ .../enchants/weapon/EnchantVampire.java | 102 ++++++ .../manager/enchants/weapon/EnchantVenom.java | 17 + .../weapon/EnchantVillageDefender.java | 98 ++++++ .../enchants/weapon/EnchantWither.java | 17 + .../listeners/EnchantGenericListener.java | 283 ++++++++++++++++ .../listeners/EnchantHandlerListener.java | 195 +++++++++++ .../manager/object/EnchantListGUI.java | 123 +++++++ .../manager/object/EnchantScaler.java | 12 + .../manager/object/EnchantTier.java | 94 ++++++ .../tasks/AbstractEnchantPassiveTask.java | 56 ++++ .../manager/tasks/ArrowTrailsTask.java | 37 +++ .../tasks/EnchantEffectPassiveTask.java | 28 ++ .../manager/type/FitItemType.java | 57 ++++ .../manager/type/ObtainType.java | 23 ++ Core/src/main/resources/config.yml | 165 ++++++++++ Core/src/main/resources/enchants/aquaman.yml | 31 ++ .../enchants/bane_of_netherspawn.yml | 34 ++ .../main/resources/enchants/blast_mining.yml | 31 ++ .../src/main/resources/enchants/blindness.yml | 34 ++ Core/src/main/resources/enchants/bomber.yml | 29 ++ .../src/main/resources/enchants/bunny_hop.yml | 30 ++ .../main/resources/enchants/cold_steel.yml | 31 ++ .../src/main/resources/enchants/confusion.yml | 34 ++ Core/src/main/resources/enchants/cure.yml | 32 ++ .../resources/enchants/curse_of_breaking.yml | 29 ++ .../enchants/curse_of_misfortune.yml | 29 ++ Core/src/main/resources/enchants/cutter.yml | 31 ++ .../main/resources/enchants/decapitator.yml | 104 ++++++ .../main/resources/enchants/divine_touch.yml | 33 ++ .../main/resources/enchants/double_strike.yml | 32 ++ .../src/main/resources/enchants/ender_bow.yml | 28 ++ Core/src/main/resources/enchants/exhaust.yml | 34 ++ .../main/resources/enchants/exp_hunter.yml | 29 ++ .../resources/enchants/explosive_arrows.yml | 37 +++ .../main/resources/enchants/flame_walker.yml | 29 ++ Core/src/main/resources/enchants/ghast.yml | 30 ++ Core/src/main/resources/enchants/hardened.yml | 31 ++ Core/src/main/resources/enchants/haste.yml | 31 ++ .../main/resources/enchants/ice_aspect.yml | 34 ++ Core/src/main/resources/enchants/infernus.yml | 29 ++ .../main/resources/enchants/lucky_miner.yml | 29 ++ .../main/resources/enchants/night_vision.yml | 31 ++ Core/src/main/resources/enchants/nimble.yml | 28 ++ Core/src/main/resources/enchants/paralyze.yml | 34 ++ .../resources/enchants/poisoned_arrows.yml | 31 ++ Core/src/main/resources/enchants/rage.yml | 34 ++ Core/src/main/resources/enchants/regrowth.yml | 34 ++ .../src/main/resources/enchants/replanter.yml | 31 ++ Core/src/main/resources/enchants/rocket.yml | 29 ++ .../main/resources/enchants/saturation.yml | 31 ++ .../src/main/resources/enchants/scavenger.yml | 37 +++ .../resources/enchants/self_destruction.yml | 30 ++ .../main/resources/enchants/silk_chest.yml | 30 ++ Core/src/main/resources/enchants/smelter.yml | 38 +++ Core/src/main/resources/enchants/sonic.yml | 30 ++ Core/src/main/resources/enchants/surprise.yml | 34 ++ .../main/resources/enchants/telekinesis.yml | 32 ++ Core/src/main/resources/enchants/thrifty.yml | 35 ++ Core/src/main/resources/enchants/thunder.yml | 29 ++ .../src/main/resources/enchants/treasures.yml | 65 ++++ Core/src/main/resources/enchants/tunnel.yml | 29 ++ Core/src/main/resources/enchants/vampire.yml | 34 ++ .../src/main/resources/enchants/veinminer.yml | 49 +++ Core/src/main/resources/enchants/venom.yml | 34 ++ .../resources/enchants/village_defender.yml | 34 ++ Core/src/main/resources/enchants/wither.yml | 34 ++ .../resources/enchants/withered_arrows.yml | 31 ++ Core/src/main/resources/gui.enchants.yml | 60 ++++ Core/src/main/resources/lang/messages_cn.yml | 18 + Core/src/main/resources/lang/messages_en.yml | 0 Core/src/main/resources/lang/messages_pl.yml | 18 + Core/src/main/resources/lang/messages_ru.yml | 35 ++ Core/src/main/resources/plugin.yml | 44 +++ NMS/pom.xml | 34 ++ .../excellentenchants/nms/EnchantNMS.java | 13 + V1_16_R1/pom.xml | 32 ++ .../excellentenchants/nms/V1_16_R3.java | 51 +++ V1_17_R1/pom.xml | 32 ++ .../excellentenchants/nms/V1_17_R1.java | 62 ++++ V1_18_R1/pom.xml | 32 ++ .../excellentenchants/nms/V1_18_R1.java | 61 ++++ pom.xml | 37 +++ 160 files changed, 9581 insertions(+) create mode 100644 .gitignore create mode 100644 Core/pom.xml create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/Perms.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantPriority.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowPotionTemplate.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantCombatPotionTemplate.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CustomDropEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/MoveEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/PassiveEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/command/ListCommand.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/config/ObtainSettings.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/hook/HookId.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/hook/HookNCP.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantAquaman.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantBunnyHop.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantColdSteel.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantHardened.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantNightVision.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSonic.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantHaste.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantReplanter.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBlindness.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantConfusion.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCure.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDoubleStrike.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExhaust.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantIceAspect.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantNimble.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantParalyze.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRage.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantScavenger.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantSurprise.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThrifty.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThunder.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVenom.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantWither.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantScaler.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/AbstractEnchantPassiveTask.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/ArrowTrailsTask.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/type/FitItemType.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/type/ObtainType.java create mode 100644 Core/src/main/resources/config.yml create mode 100644 Core/src/main/resources/enchants/aquaman.yml create mode 100644 Core/src/main/resources/enchants/bane_of_netherspawn.yml create mode 100644 Core/src/main/resources/enchants/blast_mining.yml create mode 100644 Core/src/main/resources/enchants/blindness.yml create mode 100644 Core/src/main/resources/enchants/bomber.yml create mode 100644 Core/src/main/resources/enchants/bunny_hop.yml create mode 100644 Core/src/main/resources/enchants/cold_steel.yml create mode 100644 Core/src/main/resources/enchants/confusion.yml create mode 100644 Core/src/main/resources/enchants/cure.yml create mode 100644 Core/src/main/resources/enchants/curse_of_breaking.yml create mode 100644 Core/src/main/resources/enchants/curse_of_misfortune.yml create mode 100644 Core/src/main/resources/enchants/cutter.yml create mode 100644 Core/src/main/resources/enchants/decapitator.yml create mode 100644 Core/src/main/resources/enchants/divine_touch.yml create mode 100644 Core/src/main/resources/enchants/double_strike.yml create mode 100644 Core/src/main/resources/enchants/ender_bow.yml create mode 100644 Core/src/main/resources/enchants/exhaust.yml create mode 100644 Core/src/main/resources/enchants/exp_hunter.yml create mode 100644 Core/src/main/resources/enchants/explosive_arrows.yml create mode 100644 Core/src/main/resources/enchants/flame_walker.yml create mode 100644 Core/src/main/resources/enchants/ghast.yml create mode 100644 Core/src/main/resources/enchants/hardened.yml create mode 100644 Core/src/main/resources/enchants/haste.yml create mode 100644 Core/src/main/resources/enchants/ice_aspect.yml create mode 100644 Core/src/main/resources/enchants/infernus.yml create mode 100644 Core/src/main/resources/enchants/lucky_miner.yml create mode 100644 Core/src/main/resources/enchants/night_vision.yml create mode 100644 Core/src/main/resources/enchants/nimble.yml create mode 100644 Core/src/main/resources/enchants/paralyze.yml create mode 100644 Core/src/main/resources/enchants/poisoned_arrows.yml create mode 100644 Core/src/main/resources/enchants/rage.yml create mode 100644 Core/src/main/resources/enchants/regrowth.yml create mode 100644 Core/src/main/resources/enchants/replanter.yml create mode 100644 Core/src/main/resources/enchants/rocket.yml create mode 100644 Core/src/main/resources/enchants/saturation.yml create mode 100644 Core/src/main/resources/enchants/scavenger.yml create mode 100644 Core/src/main/resources/enchants/self_destruction.yml create mode 100644 Core/src/main/resources/enchants/silk_chest.yml create mode 100644 Core/src/main/resources/enchants/smelter.yml create mode 100644 Core/src/main/resources/enchants/sonic.yml create mode 100644 Core/src/main/resources/enchants/surprise.yml create mode 100644 Core/src/main/resources/enchants/telekinesis.yml create mode 100644 Core/src/main/resources/enchants/thrifty.yml create mode 100644 Core/src/main/resources/enchants/thunder.yml create mode 100644 Core/src/main/resources/enchants/treasures.yml create mode 100644 Core/src/main/resources/enchants/tunnel.yml create mode 100644 Core/src/main/resources/enchants/vampire.yml create mode 100644 Core/src/main/resources/enchants/veinminer.yml create mode 100644 Core/src/main/resources/enchants/venom.yml create mode 100644 Core/src/main/resources/enchants/village_defender.yml create mode 100644 Core/src/main/resources/enchants/wither.yml create mode 100644 Core/src/main/resources/enchants/withered_arrows.yml create mode 100644 Core/src/main/resources/gui.enchants.yml create mode 100644 Core/src/main/resources/lang/messages_cn.yml create mode 100644 Core/src/main/resources/lang/messages_en.yml create mode 100644 Core/src/main/resources/lang/messages_pl.yml create mode 100644 Core/src/main/resources/lang/messages_ru.yml create mode 100644 Core/src/main/resources/plugin.yml create mode 100644 NMS/pom.xml create mode 100644 NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java create mode 100644 V1_16_R1/pom.xml create mode 100644 V1_16_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_16_R3.java create mode 100644 V1_17_R1/pom.xml create mode 100644 V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_17_R1.java create mode 100644 V1_18_R1/pom.xml create mode 100644 V1_18_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R1.java create mode 100644 pom.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62a5987 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +/Core/pom.xml.versionsBackup +/pom.xml.versionsBackup +/NMS/pom.xml.versionsBackup +/V1_16_R1/pom.xml.versionsBackup +/V1_17_R1/pom.xml.versionsBackup +/V1_18_R1/pom.xml.versionsBackup +/Core/target/ +/NMS/target/ +/V1_16_R1/target/ +/V1_17_R1/target/ +/V1_18_R1/target/ +/.idea/ +/target/ diff --git a/Core/pom.xml b/Core/pom.xml new file mode 100644 index 0000000..0416183 --- /dev/null +++ b/Core/pom.xml @@ -0,0 +1,92 @@ + + + + ExcellentEnchants + su.nightexpress.excellentenchants + 3.1.0 + + 4.0.0 + + Core + + + 16 + 16 + + + + + md_5-releases + https://repo.md-5.net/content/repositories/releases/ + + + + + + org.spigotmc + spigot-api + 1.18.1-R0.1-SNAPSHOT + + + su.nightexpress.excellentenchants + NMS + 3.1.0 + + + su.nightexpress.excellentenchants + V1_16_R1 + 3.1.0 + + + su.nightexpress.excellentenchants + V1_17_R1 + 3.1.0 + + + su.nightexpress.excellentenchants + V1_18_R1 + 3.1.0 + + + fr.neatmonster + nocheatplus + 3.16.1-SNAPSHOT + provided + + + + + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + ${project.parent.basedir}\target\${project.parent.name}-${project.version}.jar + + + su.nightexpress.excellentenchants* + + + + + + + + + + \ No newline at end of file diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java new file mode 100644 index 0000000..a62b0c8 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -0,0 +1,122 @@ +package su.nightexpress.excellentenchants; + +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.NexPlugin; +import su.nexmedia.engine.Version; +import su.nexmedia.engine.api.command.GeneralCommand; +import su.nexmedia.engine.utils.Reflex; +import su.nightexpress.excellentenchants.command.BookCommand; +import su.nightexpress.excellentenchants.command.EnchantCommand; +import su.nightexpress.excellentenchants.command.ListCommand; +import su.nightexpress.excellentenchants.command.TierbookCommand; +import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.config.Lang; +import su.nightexpress.excellentenchants.manager.EnchantManager; +import su.nightexpress.excellentenchants.nms.EnchantNMS; + +public class ExcellentEnchants extends NexPlugin { + + private static ExcellentEnchants instance; + + public static boolean isLoaded = false; + + private Config config; + private Lang lang; + + private EnchantNMS enchantNMS; + private EnchantManager enchantManager; + + public ExcellentEnchants() { + instance = this; + } + + public static ExcellentEnchants getInstance() { + return instance; + } + + @Override + public void enable() { + if (!this.setNMS()) { + this.error("Could not setup internal NMS handler!"); + this.getPluginManager().disablePlugin(this); + return; + } + + this.enchantManager = new EnchantManager(this); + this.enchantManager.setup(); + } + + @Override + public void disable() { + if (this.enchantManager != null) { + this.enchantManager.shutdown(); + this.enchantManager = null; + } + } + + @Override + public boolean useNewConfigFields() { + return true; + } + + private boolean setNMS() { + Version current = Version.CURRENT; + if (current == null) return false; + + String pack = EnchantNMS.class.getPackage().getName(); + Class clazz = Reflex.getClass(pack, current.name()); + if (clazz == null) return false; + + try { + this.enchantNMS = (EnchantNMS) clazz.getConstructor().newInstance(); + } + catch (Exception e) { + e.printStackTrace(); + } + return this.enchantNMS != null; + } + + @Override + public void setConfig() { + this.config = new Config(this); + this.config.setup(); + + this.lang = new Lang(this); + this.lang.setup(); + } + + @Override + public void registerCommands(@NotNull GeneralCommand mainCommand) { + mainCommand.addChildren(new BookCommand(this)); + mainCommand.addChildren(new EnchantCommand(this)); + mainCommand.addChildren(new ListCommand(this)); + mainCommand.addChildren(new TierbookCommand(this)); + } + + @Override + public void registerHooks() { + + } + + @Override + @NotNull + public Config cfg() { + return this.config; + } + + @Override + @NotNull + public Lang lang() { + return this.lang; + } + + @NotNull + public EnchantManager getEnchantManager() { + return this.enchantManager; + } + + @NotNull + public EnchantNMS getEnchantNMS() { + return enchantNMS; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java b/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java new file mode 100644 index 0000000..7d190b2 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java @@ -0,0 +1,15 @@ +package su.nightexpress.excellentenchants; + +public class Perms { + + public static final String PREFIX = "excellentenchants."; + + public static final String ADMIN = PREFIX + "admin"; + public static final String USER = PREFIX + "user"; + + public static final String COMMAND_BOOK = PREFIX + "command.book"; + public static final String COMMAND_ENCHANT = PREFIX + "command.enchant"; + public static final String COMMAND_LIST = PREFIX + "command.list"; + public static final String COMMAND_TIERBOOK = PREFIX + "command.tierbook"; + +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantPriority.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantPriority.java new file mode 100644 index 0000000..2ffa768 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantPriority.java @@ -0,0 +1,6 @@ +package su.nightexpress.excellentenchants.api.enchantment; + +public enum EnchantPriority { + + LOWEST, LOW, MEDIUM, HIGH, HIGHEST +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java new file mode 100644 index 0000000..31729ee --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -0,0 +1,308 @@ +package su.nightexpress.excellentenchants.api.enchantment; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.api.manager.IListener; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.*; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.manager.EnchantManager; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.manager.object.EnchantTier; +import su.nightexpress.excellentenchants.manager.type.FitItemType; +import su.nightexpress.excellentenchants.manager.type.ObtainType; + +import java.util.*; +import java.util.function.UnaryOperator; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public abstract class ExcellentEnchant extends Enchantment implements IListener { + + public static final String PLACEHOLDER_NAME = "%enchantment_name%"; + public static final String PLACEHLDER_NAME_FORMATTED = "%enchantment_name_formatted%"; + public static final String PLACEHOLDER_DESCRIPTION = "%enchantment_description%"; + public static final String PLACEHOLDER_LEVEL = "%enchantment_level%"; + public static final String PLACEHOLDER_LEVEL_MIN = "%enchantment_level_min%"; + public static final String PLACEHOLDER_LEVEL_MAX = "%enchantment_level_max%"; + public static final String PLACEHOLDER_CONFLICTS = "%enchantment_conflicts%"; + public static final String PLACEHOLDER_TARGET = "%enchantment_target%"; + public static final String PLACEHOLDER_TIER = "%enchantment_tier%"; + public static final String PLACEHOLDER_FIT_ITEM_TYPES = "%enchantment_fit_item_types%"; + public static final String PLACEHOLDER_OBTAIN_CHANCE_ENCHANTING = "%enchantment_obtain_chance_enchanting%"; + public static final String PLACEHOLDER_OBTAIN_CHANCE_VILLAGER = "%enchantment_obtain_chance_villager%"; + public static final String PLACEHOLDER_OBTAIN_CHANCE_LOOT_GENERATION = "%enchantment_obtain_chance_loot_generation%"; + public static final String PLACEHOLDER_OBTAIN_CHANCE_FISHING = "%enchantment_obtain_chance_fishing%"; + public static final String PLACEHOLDER_OBTAIN_CHANCE_MOB_SPAWNING = "%enchantment_obtain_chance_mob_spawning%"; + public static final String PLACEHOLDER_COST_ITEM = "%enchantment_cost_item%"; + + protected final ExcellentEnchants plugin; + protected final JYML cfg; + protected final String id; + protected final EnchantPriority priority; + + protected String displayName; + protected EnchantTier tier; + protected List description; + + private final Set conflicts; + protected boolean isTreasure; + protected int levelMin; + protected int levelMax; + protected Scaler levelByEnchantCost; + protected Scaler anvilMergeCost; + protected Map obtainChance; + protected ItemStack costItem; + protected boolean costEnabled; + + public ExcellentEnchant(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, @NotNull EnchantPriority priority) { + super(NamespacedKey.minecraft(cfg.getFile().getName().replace(".yml", "").toLowerCase())); + this.plugin = plugin; + this.id = this.getKey().getKey(); + this.cfg = cfg; + this.updateConfig(); + this.cfg.saveChanges(); + this.priority = priority; + + this.displayName = StringUtil.color(cfg.getString("Name", this.getId())); + this.tier = EnchantManager.getTierById(cfg.getString("Tier", Constants.DEFAULT)); + if (this.tier == null) { + throw new IllegalStateException("Invalid tier provided for the '" + id + "' enchantment!"); + } + this.tier.getEnchants().add(this); + this.description = StringUtil.color(cfg.getStringList("Description")); + + this.conflicts = new HashSet<>(); + this.isTreasure = cfg.getBoolean("Is_Treasure"); + this.levelMin = cfg.getInt("Level.Min"); + this.levelMax = cfg.getInt("Level.Max"); + this.levelByEnchantCost = new EnchantScaler(this, ObtainType.ENCHANTING.getPathName() + ".Level_By_Exp_Cost"); + this.anvilMergeCost = new EnchantScaler(this, "Anvil.Merge_Cost"); + + this.obtainChance = new HashMap<>(); + for (ObtainType obtainType : ObtainType.values()) { + double obtainChance = cfg.getDouble(obtainType.getPathName() + ".Chance"); + this.obtainChance.put(obtainType, obtainChance); + } + + this.costEnabled = cfg.getBoolean("Settings.Cost.Enabled"); + this.costItem = cfg.getItem("Settings.Cost.Item"); + } + + protected void updateConfig() { + cfg.addMissing("Is_Treasure", false); + cfg.addMissing("Settings.Cost.Enabled", false); + cfg.addMissing("Settings.Cost.Item.Material", Material.AIR.name()); + cfg.addMissing("Settings.Cost.Item.Amount", 1); + + if (cfg.contains("Enchantment_Table")) { + String path = ObtainType.ENCHANTING.getPathName() + "."; + cfg.addMissing(path + "Chance", cfg.getDouble("Enchantment_Table.Chance")); + cfg.addMissing(path + "Level_By_Exp_Cost", cfg.getString("Enchantment_Table.Level_By_Exp_Cost", "30")); + cfg.remove("Enchantment_Table"); + } + + for (ObtainType obtainType : ObtainType.values()) { + cfg.addMissing(obtainType.getPathName() + ".Chance", 25D); + } + } + + @NotNull + public UnaryOperator replacePlaceholders(int level) { + String conflicts = this.getConflicts().isEmpty() ? plugin.lang().Other_None.getMsg() : this.getConflicts().stream().filter(Objects::nonNull).map(en -> plugin.lang().getEnchantment(en)).collect(Collectors.joining("\n")); + + return str -> str + .replace(PLACEHOLDER_NAME, this.getDisplayName()) + .replace(PLACEHLDER_NAME_FORMATTED, this.getNameFormatted(level)) + .replace(PLACEHOLDER_LEVEL, NumberUtil.toRoman(level)) + .replace(PLACEHOLDER_LEVEL_MIN, String.valueOf(this.getStartLevel())) + .replace(PLACEHOLDER_LEVEL_MAX, String.valueOf(this.getMaxLevel())) + .replace(PLACEHOLDER_TARGET, plugin.lang().getEnum(this.getItemTarget())) + .replace(PLACEHOLDER_TIER, this.getTier().getName()) + .replace(PLACEHOLDER_CONFLICTS, conflicts) + .replace(PLACEHOLDER_FIT_ITEM_TYPES, String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.lang().getEnum(type)).toList())) + .replace(PLACEHOLDER_OBTAIN_CHANCE_ENCHANTING, NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING))) + .replace(PLACEHOLDER_OBTAIN_CHANCE_VILLAGER, NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER))) + .replace(PLACEHOLDER_OBTAIN_CHANCE_LOOT_GENERATION, NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION))) + .replace(PLACEHOLDER_OBTAIN_CHANCE_FISHING, NumberUtil.format(this.getObtainChance(ObtainType.FISHING))) + .replace(PLACEHOLDER_OBTAIN_CHANCE_MOB_SPAWNING, NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING))) + .replace(PLACEHOLDER_COST_ITEM, this.hasCostItem() ? ItemUtil.getItemName(this.costItem) : plugin.lang().Other_None.getMsg()) + ; + } + + @NotNull + public UnaryOperator formatString(int level) { + return str -> this.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_DESCRIPTION, String.join("\n", Config.formatDescription(this.getDescription()))) + ); + } + + @NotNull + public FitItemType[] getFitItemTypes() { + FitItemType itemType = FitItemType.getByEnchantmentTarget(this.getItemTarget()); + return itemType == null ? new FitItemType[0] : new FitItemType[]{itemType}; + } + + protected void addConflicts() { + + } + + protected void addConflict(@NotNull Enchantment enchantment) { + this.conflicts.add(enchantment); + } + + public boolean hasCostItem() { + return this.costEnabled && !this.costItem.getType().isAir(); + } + + public boolean takeCostItem(@NotNull LivingEntity livingEntity) { + if (!this.hasCostItem()) return true; + if (!(livingEntity instanceof Player player)) return true; + + if (PlayerUtil.countItem(player, this.costItem) < this.costItem.getAmount()) return false; + return PlayerUtil.takeItem(player, this.costItem, this.costItem.getAmount()); + } + + public boolean isEnchantmentAvailable(@NotNull LivingEntity entity) { + return !Config.isEnchantmentDisabled(this, entity.getWorld().getName()); + } + + @Override + public void registerListeners() { + this.addConflicts(); + this.plugin.getPluginManager().registerEvents(this, plugin); + } + + @NotNull + public JYML getConfig() { + return this.cfg; + } + + @NotNull + public String getId() { + return this.id; + } + + @NotNull + public EnchantPriority getPriority() { + return priority; + } + + @NotNull + @Override + public String getName() { + return getId().toUpperCase(); + } + + @NotNull + public String getDisplayName() { + return this.displayName; + } + + @NotNull + public String getNameFormatted(int level) { + return this.getTier().getColor() + this.getDisplayName() + " " + NumberUtil.toRoman(level); + } + + @NotNull + public List getDescription() { + return this.description; + } + + @NotNull + public List getDescription(int level) { + List description = new ArrayList<>(this.description); + description.replaceAll(this.replacePlaceholders(level)); + return description; + } + + @NotNull + public Set getConflicts() { + return conflicts; + } + + @NotNull + public EnchantTier getTier() { + return this.tier; + } + + @Override + public int getMaxLevel() { + return this.levelMax; + } + + @Override + public int getStartLevel() { + return this.levelMin; + } + + public int getLevelByEnchantCost(int expLevel) { + Optional> opt = this.levelByEnchantCost.getValues().entrySet().stream().filter(en -> expLevel >= en.getValue().intValue()).max(Comparator.comparingInt(Map.Entry::getKey)); + return opt.isPresent() ? opt.get().getKey() : Rnd.get(this.getStartLevel(), this.getMaxLevel()); + } + + public double getObtainChance(@NotNull ObtainType obtainType) { + return this.obtainChance.getOrDefault(obtainType, 0D); + } + + public int getAnvilMergeCost(int level) { + return (int) this.anvilMergeCost.getValue(level); + } + + @Override + public final boolean conflictsWith(@NotNull Enchantment enchantment) { + return this.conflicts.contains(enchantment); + } + + @Override + public final boolean canEnchantItem(@Nullable ItemStack item) { + if (item == null || item.getType().isAir()) return false; + if (EnchantManager.getItemEnchants(item).keySet().stream().anyMatch(e -> e.conflictsWith(this) || this.conflictsWith(e))) return false; + if (!item.containsEnchantment(this) && EnchantManager.getItemCustomEnchantsAmount(item) >= Config.ENCHANTMENTS_ITEM_CUSTOM_MAX) { + return false; + } + if (item.getType() == Material.BOOK || item.getType() == Material.ENCHANTED_BOOK) { + return true; + } + return Stream.of(this.getFitItemTypes()).anyMatch(fitItemType -> fitItemType.isIncluded(item)); + } + + /*protected boolean isFitItemType(@NotNull ItemStack item) { + EnchantmentTarget target = this.getItemTarget(); + return switch (target) { + case ARMOR -> ItemUtil.isArmor(item); + case ARMOR_FEET -> ItemUtil.isBoots(item); + case ARMOR_LEGS -> ItemUtil.isLeggings(item); + case ARMOR_TORSO -> ItemUtil.isChestplate(item) || (Config.ENCHANTMENTS_ITEM_ELYTRA_AS_CHESTPLATE && item.getType() == Material.ELYTRA); + case ARMOR_HEAD -> ItemUtil.isHelmet(item); + case WEAPON -> ItemUtil.isSword(item) || (Config.ENCHANTMENTS_ITEM_AXES_AS_SWORDS && ItemUtil.isAxe(item)); + case TOOL -> ItemUtil.isTool(item); + case BOW -> item.getType() == Material.BOW || (Config.ENCHANTMENTS_ITEM_CROSSBOWS_AS_BOWS && ItemUtil.isBow(item)); + case FISHING_ROD -> item.getType() == Material.FISHING_ROD; + case BREAKABLE -> true; + case WEARABLE -> EnchantManager.isEnchantable(item); + case TRIDENT -> ItemUtil.isTrident(item); + case CROSSBOW -> item.getType() == Material.CROSSBOW; + default -> false; + }; + }*/ + + @Override + public boolean isCursed() { + return false; + } + + @Override + public final boolean isTreasure() { + return this.isTreasure; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowPotionTemplate.java new file mode 100644 index 0000000..e321bba --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowPotionTemplate.java @@ -0,0 +1,71 @@ +package su.nightexpress.excellentenchants.api.enchantment; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; + +public abstract class IEnchantBowPotionTemplate extends IEnchantPotionTemplate implements BowEnchant { + + protected final String arrowMeta; + + public IEnchantBowPotionTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, + @NotNull EnchantPriority priority, + @NotNull PotionEffectType type) { + super(plugin, cfg, priority, type); + this.arrowMeta = this.getId() + "_potion_arrow"; + } + + public boolean isThisArrow(@NotNull Projectile projectile) { + return projectile.hasMetadata(this.arrowMeta); + } + + public void setThisArrow(@NotNull Projectile projectile) { + projectile.setMetadata(this.arrowMeta, new FixedMetadataValue(plugin, true)); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + if (!this.isThisArrow(projectile)) return false; + + return true; + } + + @Override + public boolean use(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isEnchantmentAvailable(shooter)) return false; + if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; + + this.setThisArrow(arrow); + arrow.addCustomEffect(this.getEffect(level), true); + return true; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(victim)) return false; + if (!(e.getDamager() instanceof Projectile projectile)) return false; + if (!this.isThisArrow(projectile)) return false; + + //this.addEffect(victim, level); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java new file mode 100644 index 0000000..a27cc07 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java @@ -0,0 +1,86 @@ +package su.nightexpress.excellentenchants.api.enchantment; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +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.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.manager.tasks.ArrowTrailsTask; + +public abstract class IEnchantBowTemplate extends IEnchantChanceTemplate implements BowEnchant { + + protected final String arrowTrailName; + protected final String arrowTrailData; + protected final String arrowMeta; + + public IEnchantBowTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, @NotNull EnchantPriority priority) { + super(plugin, cfg, priority); + this.arrowMeta = this.getId() + "_arrow"; + this.arrowTrailName = cfg.getString("Settings.Arrow.Trail.Name", ""); + this.arrowTrailData = cfg.getString("Settings.Arrow.Trail.Data", ""); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + if (cfg.contains("Settings.Arrow.Trail") && !cfg.isConfigurationSection("Settings.Arrow.Trail")) { + String trail = cfg.getString("Settings.Arrow.Trail", ""); + + cfg.set("Settings.Arrow.Trail", null); + cfg.addMissing("Settings.Arrow.Trail.Name", trail); + } + cfg.addMissing("Settings.Arrow.Trail.Data", ""); + } + + public boolean isThisArrow(@NotNull Projectile projectile) { + return projectile.hasMetadata(this.arrowMeta); + } + + public void setThisArrow(@NotNull Projectile projectile) { + projectile.setMetadata(this.arrowMeta, new FixedMetadataValue(plugin, true)); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + if (!this.isThisArrow(projectile)) return false; + + return true; + } + + @Override + public boolean use(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isEnchantmentAvailable(shooter)) return false; + if (!(e.getProjectile() instanceof Projectile arrow)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; + + this.setThisArrow(arrow); + if (!this.arrowTrailName.isEmpty()) { + ArrowTrailsTask.add(arrow, this.arrowTrailName, this.arrowTrailData); + } + return true; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(victim)) return false; + if (!(e.getDamager() instanceof Projectile projectile)) return false; + if (!this.isThisArrow(projectile)) return false; + + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java new file mode 100644 index 0000000..cff2561 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java @@ -0,0 +1,51 @@ +package su.nightexpress.excellentenchants.api.enchantment; + +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public abstract class IEnchantChanceTemplate extends ExcellentEnchant { + + public static final String PLACEHOLDER_CHANCE = "%enchantment_trigger_chance%"; + + protected Scaler triggerChance; + + public IEnchantChanceTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, @NotNull EnchantPriority priority) { + super(plugin, cfg, priority); + + this.triggerChance = new EnchantScaler(this, "Settings.Trigger_Chance"); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + if (cfg.contains("settings.enchant-trigger-chance")) { + String triggerChance = cfg.getString("settings.enchant-trigger-chance", "100").replace("%level%", PLACEHOLDER_LEVEL); + + cfg.set("Settings.Trigger_Chance", triggerChance); + cfg.set("settings.enchant-trigger-chance", null); + } + } + + @Override + public @NotNull UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_CHANCE, NumberUtil.format(this.getTriggerChance(level))) + ); + } + + public final double getTriggerChance(int level) { + return this.triggerChance.getValue(level); + } + + public final boolean checkTriggerChance(int level) { + return Rnd.get(true) <= this.getTriggerChance(level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantCombatPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantCombatPotionTemplate.java new file mode 100644 index 0000000..0320831 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantCombatPotionTemplate.java @@ -0,0 +1,53 @@ +package su.nightexpress.excellentenchants.api.enchantment; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.config.JYML; +import su.nexmedia.engine.utils.EffectUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; + +public abstract class IEnchantCombatPotionTemplate extends IEnchantPotionTemplate implements CombatEnchant { + + protected String particleName; + protected String particleData; + + public IEnchantCombatPotionTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, + @NotNull EnchantPriority priority, + @NotNull PotionEffectType effectType) { + super(plugin, cfg, priority, effectType); + + this.particleName = cfg.getString("Settings.Particle.Name", ""); + this.particleData = cfg.getString("Settings.Particle.Data", ""); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.remove("Settings.Particle_Effect"); + cfg.addMissing("Settings.Particle.Name", ""); + cfg.addMissing("Settings.Particle.Data", ""); + } + + @Override + @NotNull + public final EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(damager)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(damager)) return false; + if (!this.addEffect(victim, level)) return false; + + EffectUtil.playEffect(victim.getEyeLocation(), this.particleName, this.particleData, 0.25f, 0.25f, 0.25f, 0.1f, 50); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java new file mode 100644 index 0000000..b31bfab --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java @@ -0,0 +1,73 @@ +package su.nightexpress.excellentenchants.api.enchantment; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; +import su.nightexpress.excellentenchants.manager.EnchantManager; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public abstract class IEnchantPotionTemplate extends IEnchantChanceTemplate { + + 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%"; + + protected PotionEffectType potionEffectType; + protected Scaler potionDuration; + protected Scaler potionLevel; + protected final boolean potionParticles; + + public IEnchantPotionTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, + @NotNull EnchantPriority priority, + @NotNull PotionEffectType potionEffectType) { + super(plugin, cfg, priority); + this.potionEffectType = potionEffectType; + this.potionDuration = new EnchantScaler(this, "Settings.Potion_Effect.Duration"); + this.potionLevel = new EnchantScaler(this, "Settings.Potion_Effect.Level"); + this.potionParticles = !(this instanceof PassiveEnchant); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_POTION_LEVEL, NumberUtil.toRoman(this.getEffectLevel(level))) + .replace(PLACEHOLDER_POTION_DURATION, NumberUtil.format((double) this.getEffectDuration(level) / 20D)) + .replace(PLACEHOLDER_POTION_TYPE, plugin.lang().getPotionType(this.getEffectType())) + ); + } + + @NotNull + public final PotionEffectType getEffectType() { + return this.potionEffectType; + } + + public final int getEffectDuration(int level) { + return (int) (this.potionDuration.getValue(level) * 20); + } + + public final int getEffectLevel(int level) { + return (int) this.potionLevel.getValue(level); + } + + @NotNull + public PotionEffect getEffect(int level) { + int duration = this.getEffectDuration(level); + int amplifier = Math.max(0, this.getEffectLevel(level) - 1); + + return new PotionEffect(this.potionEffectType, duration, amplifier, false, this.potionParticles); + } + + public final boolean addEffect(@NotNull LivingEntity target, int level) { + EnchantManager.addPotionEffect(target, this.getEffect(level), true); + return true; + } +} \ No newline at end of file diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java new file mode 100644 index 0000000..51ecd54 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java @@ -0,0 +1,11 @@ +package su.nightexpress.excellentenchants.api.enchantment.type; + +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public interface BlockBreakEnchant { + + boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level); +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java new file mode 100644 index 0000000..3f41021 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java @@ -0,0 +1,15 @@ +package su.nightexpress.excellentenchants.api.enchantment.type; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public interface BowEnchant extends CombatEnchant { + + boolean use(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level); + + boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level); +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java new file mode 100644 index 0000000..0a78a0d --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java @@ -0,0 +1,11 @@ +package su.nightexpress.excellentenchants.api.enchantment.type; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public interface CombatEnchant { + + boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level); +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CustomDropEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CustomDropEnchant.java new file mode 100644 index 0000000..1d0607e --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CustomDropEnchant.java @@ -0,0 +1,15 @@ +package su.nightexpress.excellentenchants.api.enchantment.type; + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public interface CustomDropEnchant { + + @NotNull List getCustomDrops(@NotNull Player player, @NotNull ItemStack item, @NotNull Block block, int level); + + boolean isEventMustHaveDrops(); +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java new file mode 100644 index 0000000..4c823a7 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java @@ -0,0 +1,10 @@ +package su.nightexpress.excellentenchants.api.enchantment.type; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDeathEvent; +import org.jetbrains.annotations.NotNull; + +public interface DeathEnchant { + + boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level); +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java new file mode 100644 index 0000000..94b0235 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java @@ -0,0 +1,11 @@ +package su.nightexpress.excellentenchants.api.enchantment.type; + +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public interface InteractEnchant { + + boolean use(@NotNull PlayerInteractEvent e, @NotNull Player player, @NotNull ItemStack item, int level); +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/MoveEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/MoveEnchant.java new file mode 100644 index 0000000..a993c3e --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/MoveEnchant.java @@ -0,0 +1,10 @@ +package su.nightexpress.excellentenchants.api.enchantment.type; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.player.PlayerMoveEvent; +import org.jetbrains.annotations.NotNull; + +public interface MoveEnchant { + + boolean use(@NotNull PlayerMoveEvent e, @NotNull LivingEntity entity, int level); +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/PassiveEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/PassiveEnchant.java new file mode 100644 index 0000000..e460c06 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/PassiveEnchant.java @@ -0,0 +1,9 @@ +package su.nightexpress.excellentenchants.api.enchantment.type; + +import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +public interface PassiveEnchant { + + boolean use(@NotNull LivingEntity entity, int level); +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java new file mode 100644 index 0000000..160feb9 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java @@ -0,0 +1,98 @@ +package su.nightexpress.excellentenchants.command; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.command.CommandSender; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.command.AbstractCommand; +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.manager.EnchantManager; + +import java.util.Arrays; +import java.util.List; + +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.lang().Command_Book_Desc.getMsg(); + } + + @Override + @NotNull + public String getUsage() { + return plugin.lang().Command_Book_Usage.getMsg(); + } + + @Override + public boolean isPlayerOnly() { + return false; + } + + @Override + @NotNull + public List getTab(@NotNull Player player, int i, @NotNull String[] args) { + if (i == 1) { + return PlayerUtil.getPlayerNames(); + } + if (i == 2) { + return Arrays.stream(Enchantment.values()).map(e -> e.getKey().getKey()).toList(); + } + if (i == 3) { + return Arrays.asList("-1", "1", "5", "10"); + } + return super.getTab(player, i, args); + } + + @Override + public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) { + if (args.length != 4) { + this.printUsage(sender); + return; + } + + Player player = plugin.getServer().getPlayer(args[1]); + if (player == null) { + this.errorPlayer(sender); + return; + } + + Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(args[2].toLowerCase())); + if (enchantment == null) { + plugin.lang().Error_NoEnchant.send(sender); + return; + } + + int level = StringUtil.getInteger(args[3], -1, true); + if (level < 1) { + level = Rnd.get(enchantment.getStartLevel(), enchantment.getMaxLevel()); + } + + ItemStack item = new ItemStack(Material.ENCHANTED_BOOK); + EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta(); + if (meta == null) return; + + meta.addStoredEnchant(enchantment, level, true); + item.setItemMeta(meta); + + EnchantManager.updateItemLoreEnchants(item); + PlayerUtil.addItem(player, item); + + plugin.lang().Command_Book_Done + .replace("%enchant%", plugin.lang().getEnchantment(enchantment)) + .replace("%player%", player.getName()).send(sender); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java new file mode 100644 index 0000000..5f434f7 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java @@ -0,0 +1,105 @@ +package su.nightexpress.excellentenchants.command; + +import org.bukkit.NamespacedKey; +import org.bukkit.command.CommandSender; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +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.command.AbstractCommand; +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.manager.EnchantManager; + +import java.util.Arrays; +import java.util.List; + +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.lang().Command_Enchant_Desc.getMsg(); + } + + @Override + @NotNull + public String getUsage() { + return plugin.lang().Command_Enchant_Usage.getMsg(); + } + + @Override + public boolean isPlayerOnly() { + return true; + } + + @Override + @NotNull + public List getTab(@NotNull Player player, int i, @NotNull String[] args) { + if (i == 1) { + return Arrays.stream(Enchantment.values()).map(e -> e.getKey().getKey()).toList(); + } + if (i == 2) { + return Arrays.asList("-1", "1", "5", "10"); + } + return super.getTab(player, i, args); + } + + @Override + public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) { + if (args.length != 3) { + this.printUsage(sender); + return; + } + + Player player = (Player) sender; + ItemStack item = player.getInventory().getItemInMainHand(); + if (item.getType().isAir()) { + this.errorItem(sender); + return; + } + + Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(args[1].toLowerCase())); + if (enchantment == null) { + plugin.lang().Error_NoEnchant.send(sender); + return; + } + + int level = StringUtil.getInteger(args[2], -1, true); + if (level < 0) { + level = Rnd.get(enchantment.getStartLevel(), enchantment.getMaxLevel()); + } + + ItemMeta meta = item.getItemMeta(); + if (meta == null) return; + + if (meta instanceof EnchantmentStorageMeta) { + if (level == 0) { + ((EnchantmentStorageMeta) meta).removeStoredEnchant(enchantment); + } + else { + ((EnchantmentStorageMeta) meta).addStoredEnchant(enchantment, level, true); + } + } + else { + if (level == 0) { + meta.removeEnchant(enchantment); + } + else { + meta.addEnchant(enchantment, level, true); + } + } + item.setItemMeta(meta); + EnchantManager.updateItemLoreEnchants(item); + + plugin.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 new file mode 100644 index 0000000..b36c606 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/ListCommand.java @@ -0,0 +1,37 @@ +package su.nightexpress.excellentenchants.command; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.command.AbstractCommand; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Perms; + +public class ListCommand extends AbstractCommand { + + public ListCommand(@NotNull ExcellentEnchants plugin) { + super(plugin, new String[]{"list"}, Perms.COMMAND_LIST); + } + + @Override + @NotNull + public String getUsage() { + return ""; + } + + @Override + @NotNull + public String getDescription() { + return plugin.lang().Command_List_Desc.getMsg(); + } + + @Override + public boolean isPlayerOnly() { + return true; + } + + @Override + protected void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) { + 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 new file mode 100644 index 0000000..a6b835a --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java @@ -0,0 +1,97 @@ +package su.nightexpress.excellentenchants.command; + +import org.bukkit.Material; +import org.bukkit.command.CommandSender; +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.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.manager.EnchantManager; +import su.nightexpress.excellentenchants.manager.object.EnchantTier; + +import java.util.Arrays; +import java.util.List; + +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.lang().Command_TierBook_Desc.getMsg(); + } + + @Override + @NotNull + public String getUsage() { + return plugin.lang().Command_TierBook_Usage.getMsg(); + } + + @Override + public boolean isPlayerOnly() { + return false; + } + + @Override + @NotNull + public List getTab(@NotNull Player player, int i, @NotNull String[] args) { + if (i == 1) { + return PlayerUtil.getPlayerNames(); + } + if (i == 2) { + return EnchantManager.getTierIds(); + } + if (i == 3) { + return Arrays.asList("-1", "1", "5", "10"); + } + return super.getTab(player, i, args); + } + + @Override + public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) { + if (args.length != 4) { + this.printUsage(sender); + return; + } + + Player player = plugin.getServer().getPlayer(args[1]); + if (player == null) { + this.errorPlayer(sender); + return; + } + + EnchantTier tier = EnchantManager.getTierById(args[2].toLowerCase()); + if (tier == null) { + plugin.lang().Command_TierBook_Error.send(sender); + return; + } + + ExcellentEnchant enchant = Rnd.get(tier.getEnchants()); + if (enchant == null) { + plugin.lang().Error_NoEnchant.send(sender); + return; + } + + int level = StringUtil.getInteger(args[3], -1, true); + if (level < 1) { + level = Rnd.get(enchant.getStartLevel(), enchant.getMaxLevel()); + } + + ItemStack item = new ItemStack(Material.ENCHANTED_BOOK); + EnchantManager.addEnchant(item, enchant, level, true); + PlayerUtil.addItem(player, item); + + plugin.lang().Command_TierBook_Done + .replace("%tier%", tier.getName()) + .replace("%player%", player.getName()).send(sender); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java new file mode 100644 index 0000000..d8ac4b2 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -0,0 +1,169 @@ +package su.nightexpress.excellentenchants.config; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.api.config.ConfigTemplate; +import su.nexmedia.engine.utils.Constants; +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.manager.object.EnchantTier; +import su.nightexpress.excellentenchants.manager.type.ObtainType; + +import java.util.*; +import java.util.stream.Collectors; + +public class Config extends ConfigTemplate { + + public Config(@NotNull ExcellentEnchants plugin) { + super(plugin); + } + + public static long TASKS_ARROW_TRAIL_TICKS_INTERVAL; + public static long TASKS_PASSIVE_ENCHANTS_TICKS_INTERVAL; + + public static Set ENCHANTMENTS_DISABLED; + public static Map> ENCHANTMENTS_DISABLED_IN_WORLDS; + public static boolean ENCHANTMENTS_DESCRIPTION_ENABLED; + private static String ENCHANTMENTS_DESCRIPTION_FORMAT; + + public static int ENCHANTMENTS_ITEM_CUSTOM_MAX; + public static boolean ENCHANTMENTS_ITEM_AXES_AS_SWORDS; + public static boolean ENCHANTMENTS_ITEM_CROSSBOWS_AS_BOWS; + public static boolean ENCHANTMENTS_ITEM_ELYTRA_AS_CHESTPLATE; + public static boolean ENCHANTMENTS_ENTITY_PASSIVE_FOR_MOBS; + + private static Map OBTAIN_SETTINGS; + private static Map TIERS; + + @Override + public void load() { + String path = "General.Tasks."; + TASKS_ARROW_TRAIL_TICKS_INTERVAL = cfg.getLong(path + "Arrow_Trails.Ticks_Interval", 1); + TASKS_PASSIVE_ENCHANTS_TICKS_INTERVAL = cfg.getLong(path + "Passive_Enchants.Ticks_Interval", 100); + + path = "General.Enchantments."; + cfg.addMissing(path + "Disabled_In_Worlds.my_world", Collections.singletonList(Constants.MASK_ANY)); + cfg.addMissing(path + "Disabled_In_Worlds.other_world", Arrays.asList("enchant_name", "another_enchant")); + + ENCHANTMENTS_DISABLED = cfg.getStringSet(path + "Disabled").stream().map(String::toLowerCase).collect(Collectors.toSet()); + ENCHANTMENTS_DISABLED_IN_WORLDS = new HashMap<>(); + for (String worldName : cfg.getSection(path + "Disabled_In_Worlds")) { + ENCHANTMENTS_DISABLED_IN_WORLDS.put(worldName, cfg.getStringSet(path + "Disabled_In_Worlds." + worldName) + .stream().map(String::toLowerCase).collect(Collectors.toSet())); + } + + ENCHANTMENTS_DESCRIPTION_ENABLED = cfg.getBoolean(path + "Description.Enabled"); + ENCHANTMENTS_DESCRIPTION_FORMAT = StringUtil.color(cfg.getString(path + "Description.Format", "")); + + path = "General.Enchantments.Item."; + ENCHANTMENTS_ITEM_CUSTOM_MAX = cfg.getInt(path + "Max_Custom_Enchants", 3); + ENCHANTMENTS_ITEM_AXES_AS_SWORDS = cfg.getBoolean(path + "Axes_As_Swords"); + ENCHANTMENTS_ITEM_CROSSBOWS_AS_BOWS = cfg.getBoolean(path + "Crossbows_As_Bows"); + ENCHANTMENTS_ITEM_ELYTRA_AS_CHESTPLATE = cfg.getBoolean(path + "Elytra_As_Chestplate"); + + path = "General.Enchantments.Entity."; + ENCHANTMENTS_ENTITY_PASSIVE_FOR_MOBS = cfg.getBoolean(path + "Passive_Enchants_Applied_To_Mobs"); + + OBTAIN_SETTINGS = new HashMap<>(); + for (ObtainType obtainType : ObtainType.values()) { + String path2 = "General." + obtainType.getPathName() + "."; + + cfg.addMissing(path2 + "Enabled", true); + cfg.addMissing(path2 + "Enchantments.Total_Maximum", 4); + cfg.addMissing(path2 + "Enchantments.Custom_Generation_Chance", 50D); + cfg.addMissing(path2 + "Enchantments.Custom_Minimum", 0); + cfg.addMissing(path2 + "Enchantments.Custom_Maximum", 2); + + if (!cfg.getBoolean(path2 + "Enabled")) continue; + + int enchantsTotalMax = cfg.getInt(path2 + "Enchantments.Total_Maximum", 4); + double enchantsCustomGenerationChance = cfg.getDouble(path2 + "Enchantments.Custom_Generation_Chance", 50D); + int enchantsCustomMin = cfg.getInt(path2 + "Enchantments.Custom_Minimum", 0); + int enchantsCustomMax = cfg.getInt(path2 + "Enchantments.Custom_Maximum", 2); + + ObtainSettings settings = new ObtainSettings(enchantsTotalMax, enchantsCustomGenerationChance, enchantsCustomMin, enchantsCustomMax); + OBTAIN_SETTINGS.put(obtainType, settings); + } + + this.setupTiers(); + } + + private void setupTiers() { + // Reloading tiers will reset their lists with enchants = break the plugin mechanics + if (ExcellentEnchants.isLoaded) return; + + TIERS = new HashMap<>(); + + // No tiers defined, setup a default one. + // Every enchantment must have a tier. + if (cfg.getSection("Tiers").isEmpty()) { + this.plugin.info("No tiers defined! Creating a default one for you..."); + cfg.set("Tiers.default.Name", "&7Default"); + cfg.set("Tiers.default.Color", "&7"); + for (ObtainType obtainType : ObtainType.values()) { + cfg.set("Tiers.default.Obtain_Chance." + obtainType.name(), 100D); + } + } + + // Load existing tiers. + for (String sId : cfg.getSection("Tiers")) { + String path = "Tiers." + sId + "."; + cfg.addMissing(path + "Priority", 0); + + int priority = cfg.getInt(path + "Priority"); + String name = cfg.getString(path + "Name", sId); + String color = cfg.getString(path + "Color", "&f"); + Map chance = new HashMap<>(); + + for (ObtainType obtainType : ObtainType.values()) { + cfg.addMissing(path + "Obtain_Chance." + obtainType.name(), 50D); + + double chanceType = cfg.getDouble(path + "Obtain_Chance." + obtainType.name()); + chance.put(obtainType, chanceType); + } + + EnchantTier tier = new EnchantTier(sId, priority, name, color, chance); + TIERS.put(tier.getId(), tier); + } + + this.plugin.info("Tiers Loaded: " + TIERS.size()); + } + + public static boolean isEnchantmentDisabled(@NotNull ExcellentEnchant enchant, @NotNull String world) { + Set disabled = ENCHANTMENTS_DISABLED_IN_WORLDS.getOrDefault(world, Collections.emptySet()); + return disabled.contains(enchant.getKey().getKey()) || disabled.contains(Constants.MASK_ANY); + } + + @Nullable + public static EnchantTier getTierById(@NotNull String id) { + return TIERS.get(id.toLowerCase()); + } + + @NotNull + public static Collection getTiers() { + return TIERS.values(); + } + + @NotNull + public static List getTierIds() { + return new ArrayList<>(TIERS.keySet()); + } + + @Nullable + public static EnchantTier getTierByChance(@NotNull ObtainType obtainType) { + Map map = getTiers().stream().collect(Collectors.toMap(k -> k, v -> v.getChance(obtainType))); + return Rnd.get(map); + } + + @Nullable + public static ObtainSettings getObtainSettings(@NotNull ObtainType obtainType) { + return OBTAIN_SETTINGS.get(obtainType); + } + + @NotNull + public static List formatDescription(@NotNull List description) { + return new ArrayList<>(description.stream().map(line -> ENCHANTMENTS_DESCRIPTION_FORMAT.replace("%description%", line)).toList()); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java new file mode 100644 index 0000000..7c9029e --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java @@ -0,0 +1,40 @@ +package su.nightexpress.excellentenchants.config; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.LangMessage; +import su.nexmedia.engine.core.config.CoreLang; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.manager.type.FitItemType; + +public class Lang extends CoreLang { + + public Lang(@NotNull ExcellentEnchants plugin) { + super(plugin); + } + + @Override + public void setup() { + super.setup(); + this.setupEnum(EnchantmentTarget.class); + this.setupEnum(FitItemType.class); + } + + public LangMessage Command_List_Desc = new LangMessage(this, "List of all custom enchantments."); + + public LangMessage Command_Enchant_Usage = new LangMessage(this, " "); + public LangMessage Command_Enchant_Desc = new LangMessage(this, "Enchants the item in your hand."); + public LangMessage Command_Enchant_Done = new LangMessage(this, "&aSuccessfully enchanted!"); + + public LangMessage Command_Book_Usage = new LangMessage(this, " "); + public LangMessage Command_Book_Desc = new LangMessage(this, "Gives custom enchanted book."); + public LangMessage Command_Book_Done = new LangMessage(this, "Given &6%enchant%&7 enchanted book to &6%player%&7."); + + public LangMessage Command_TierBook_Usage = new LangMessage(this, " "); + public LangMessage Command_TierBook_Desc = new LangMessage(this, "Gives an enchanted book."); + public LangMessage Command_TierBook_Error = new LangMessage(this, "&cInvalid tier!"); + public LangMessage Command_TierBook_Done = new LangMessage(this, "Given &6%tier%&7 enchanted book to &6%player%&7."); + + public LangMessage Error_NoEnchant = new LangMessage(this, "&cNo such enchant."); + +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/config/ObtainSettings.java b/Core/src/main/java/su/nightexpress/excellentenchants/config/ObtainSettings.java new file mode 100644 index 0000000..468ccee --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/ObtainSettings.java @@ -0,0 +1,37 @@ +package su.nightexpress.excellentenchants.config; + +public class ObtainSettings { + + private final int enchantsTotalMax; + private final double enchantsCustomGenerationChance; + private final int enchantsCustomMin; + private final int enchantsCustomMax; + + public ObtainSettings(int enchantsTotalMax, double enchantsCustomGenerationChance, int enchantsCustomMin, int enchantsCustomMax) { + this.enchantsTotalMax = enchantsTotalMax; + this.enchantsCustomGenerationChance = enchantsCustomGenerationChance; + this.enchantsCustomMin = enchantsCustomMin; + this.enchantsCustomMax = enchantsCustomMax; + } + + public int getEnchantsTotalMax() { + return enchantsTotalMax; + } + + public double getEnchantsCustomGenerationChance() { + return enchantsCustomGenerationChance; + } + + public int getEnchantsCustomMin() { + return enchantsCustomMin; + } + + public int getEnchantsCustomMax() { + return enchantsCustomMax; + } + + @Override + public String toString() { + return "ObtainSettings{" + "enchantsTotalMax=" + enchantsTotalMax + ", enchantsCustomGenerationChance=" + enchantsCustomGenerationChance + ", enchantsCustomMin=" + enchantsCustomMin + ", enchantsCustomMax=" + enchantsCustomMax + '}'; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookId.java b/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookId.java new file mode 100644 index 0000000..ebc3a0a --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookId.java @@ -0,0 +1,6 @@ +package su.nightexpress.excellentenchants.hook; + +public class HookId { + + public static final String NCP = "NoCheatPlus"; +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookNCP.java b/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookNCP.java new file mode 100644 index 0000000..f830c75 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookNCP.java @@ -0,0 +1,23 @@ +package su.nightexpress.excellentenchants.hook; + +import fr.neatmonster.nocheatplus.NCPAPIProvider; +import fr.neatmonster.nocheatplus.checks.CheckType; +import fr.neatmonster.nocheatplus.hooks.ExemptionContext; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.hooks.Hooks; + +public class HookNCP { + + public static void exemptBlocks(@NotNull Player player) { + if (!Hooks.hasPlugin(HookId.NCP)) return; + + NCPAPIProvider.getNoCheatPlusAPI().getPlayerDataManager().getPlayerData(player).exempt(CheckType.BLOCKBREAK, ExemptionContext.ANONYMOUS_NESTED); + } + + public static void unexemptBlocks(@NotNull Player player) { + if (!Hooks.hasPlugin(HookId.NCP)) return; + + NCPAPIProvider.getNoCheatPlusAPI().getPlayerDataManager().getPlayerData(player).unexempt(CheckType.BLOCKBREAK, ExemptionContext.ANONYMOUS_NESTED); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java new file mode 100644 index 0000000..ee3f595 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java @@ -0,0 +1,259 @@ +package su.nightexpress.excellentenchants.manager; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.potion.PotionEffect; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.api.manager.AbstractManager; +import su.nexmedia.engine.utils.ItemUtil; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.config.ObtainSettings; +import su.nightexpress.excellentenchants.manager.listeners.EnchantGenericListener; +import su.nightexpress.excellentenchants.manager.listeners.EnchantHandlerListener; +import su.nightexpress.excellentenchants.manager.object.EnchantListGUI; +import su.nightexpress.excellentenchants.manager.object.EnchantTier; +import su.nightexpress.excellentenchants.manager.tasks.ArrowTrailsTask; +import su.nightexpress.excellentenchants.manager.tasks.EnchantEffectPassiveTask; +import su.nightexpress.excellentenchants.manager.type.ObtainType; + +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class EnchantManager extends AbstractManager { + + private EnchantListGUI enchantListGUI; + private ArrowTrailsTask arrowTrailsTask; + private EnchantEffectPassiveTask enchantEffectPassiveTask; + + private static final Map PROJECTILE_WEAPON = new HashMap<>(); + + public EnchantManager(@NotNull ExcellentEnchants plugin) { + super(plugin); + } + + @Override + protected void onLoad() { + EnchantRegister.setup(); + + this.enchantListGUI = new EnchantListGUI(this.plugin); + this.addListener(new EnchantHandlerListener(this)); + this.addListener(new EnchantGenericListener(this)); + + this.arrowTrailsTask = new ArrowTrailsTask(this.plugin); + this.arrowTrailsTask.start(); + + this.enchantEffectPassiveTask = new EnchantEffectPassiveTask(this.plugin); + this.enchantEffectPassiveTask.start(); + } + + @Override + protected void onShutdown() { + if (this.enchantListGUI != null) { + this.enchantListGUI.clear(); + this.enchantListGUI = null; + } + if (this.arrowTrailsTask != null) { + this.arrowTrailsTask.stop(); + this.arrowTrailsTask = null; + } + if (this.enchantEffectPassiveTask != null) { + this.enchantEffectPassiveTask.stop(); + this.enchantEffectPassiveTask = null; + } + EnchantRegister.shutdown(); + } + + @NotNull + public EnchantListGUI getEnchantsListGUI() { + return enchantListGUI; + } + + public static void addPotionEffect(@NotNull LivingEntity entity, @NotNull PotionEffect effect, boolean compat) { + if (compat) { + PotionEffect has = entity.getPotionEffect(effect.getType()); + if (has != null && has.getAmplifier() > effect.getAmplifier()) { + return; + } + } + else { + entity.removePotionEffect(effect.getType()); + } + entity.addPotionEffect(effect); + } + + 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)) + /*|| ItemUtil.isWeapon(item) || ItemUtil.isArmor(item) || ItemUtil.isTool(item) || ItemUtil.isBow(item)*/; + } + + public static boolean populateEnchantments(@NotNull ItemStack item, @NotNull ObtainType obtainType) { + ObtainSettings settings = Config.getObtainSettings(obtainType); + if (settings == null) return false; + + if (Rnd.get(true) > settings.getEnchantsCustomGenerationChance()) return false; + + int enchHas = EnchantManager.getItemEnchantsAmount(item); + int enchMax = settings.getEnchantsTotalMax(); + int enchRoll = Rnd.get(settings.getEnchantsCustomMin(), settings.getEnchantsCustomMax()); + + for (int count = 0; (count < enchRoll && count + enchHas < enchMax); count++) { + EnchantTier tier = EnchantManager.getTierByChance(obtainType); + if (tier == null) continue; + + ExcellentEnchant enchant = tier.getEnchant(obtainType, item); + if (enchant == null) continue; + + int level = Rnd.get(enchant.getStartLevel(), enchant.getMaxLevel()); + EnchantManager.addEnchant(item, enchant, level, false); + } + EnchantManager.updateItemLoreEnchants(item); + return true; + } + + @Deprecated + public static boolean hasEnchant(@NotNull ItemStack item, @NotNull Enchantment enchantment) { + return item.getEnchantmentLevel(enchantment) != 0; + } + + @Deprecated + public static int getEnchantLevel(@NotNull ItemStack item, @NotNull Enchantment enchantment) { + ItemMeta meta = item.getItemMeta(); + return meta != null ? meta.getEnchantLevel(enchantment) : item.getEnchantmentLevel(enchantment); + } + + public static void updateItemLoreEnchants(@NotNull ItemStack item) { + EnchantRegister.ENCHANT_LIST.forEach(ench -> { + ItemUtil.delLore(item, ench.getId()); + ItemUtil.delLore(item, ench.getId() + "_info"); + }); + + // Filter custom enchants and define map order. + Map excellents = getItemCustomEnchants(item).entrySet().stream() + .sorted((e1,e2) -> e2.getKey().getTier().getPriority() - e1.getKey().getTier().getPriority()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (has, add) -> add, LinkedHashMap::new)); + + excellents.forEach((excellent, level) -> { + ItemUtil.addLore(item, excellent.getId(), excellent.getNameFormatted(level), 0); + }); + + // Add enchantment description at the end of item lore. + if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED) { + List list = new ArrayList<>(excellents.keySet()); + Collections.reverse(list); + + list.forEach(excellent -> { + List desc = excellent.getDescription(excellents.get(excellent)); + if (desc.isEmpty()) return; + + ItemUtil.addLore(item, excellent.getId() + "_info", Config.formatDescription(desc), -1); + }); + } + } + + public static boolean addEnchant(@NotNull ItemStack item, @NotNull ExcellentEnchant ench, int level, boolean force) { + if (!force && !ench.canEnchantItem(item)) return false; + + EnchantManager.removeEnchant(item, ench); + ItemUtil.addLore(item, ench.getId(), ench.getNameFormatted(level), 0); + + ItemMeta meta = item.getItemMeta(); + if (meta == null) return false; + + if (meta instanceof EnchantmentStorageMeta meta2) { + if (!meta2.addStoredEnchant(ench, level, true)) return false; + } + else { + if (!meta.addEnchant(ench, level, true)) return false; + } + item.setItemMeta(meta); + + return true; + } + + public static void removeEnchant(@NotNull ItemStack item, @NotNull ExcellentEnchant en) { + ItemUtil.delLore(item, en.getId()); + + ItemMeta meta = item.getItemMeta(); + if (meta instanceof EnchantmentStorageMeta meta2) { + meta2.removeStoredEnchant(en); + } + else { + meta.removeEnchant(en); + } + item.setItemMeta(meta); + } + + @NotNull + public static Map getItemCustomEnchants(@NotNull ItemStack item) { + return EnchantManager.getItemEnchants(item).entrySet().stream() + .filter(entry -> entry.getKey() instanceof ExcellentEnchant) + .map(entry -> new AbstractMap.SimpleEntry<>((ExcellentEnchant) entry.getKey(), entry.getValue())) + .sorted((e1,e2) -> e2.getKey().getPriority().ordinal() - e1.getKey().getPriority().ordinal()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (old, nev) -> nev, LinkedHashMap::new)); + } + + @SuppressWarnings("unchecked") + @NotNull + public static Map getItemCustomEnchants(@NotNull ItemStack item, @NotNull Class clazz) { + return EnchantManager.getItemCustomEnchants(item).entrySet().stream() + .filter(entry -> clazz.isAssignableFrom(entry.getKey().getClass())) + .sorted((e1,e2) -> e2.getKey().getPriority().ordinal() - e1.getKey().getPriority().ordinal()) + .collect(Collectors.toMap(k -> (T) k.getKey(), Map.Entry::getValue, (old, nev) -> nev, LinkedHashMap::new)); + } + + public static int getItemCustomEnchantsAmount(@NotNull ItemStack item) { + return EnchantManager.getItemCustomEnchants(item).size(); + } + + @NotNull + public static Map getItemEnchants(@NotNull ItemStack item) { + ItemMeta meta = item.getItemMeta(); + return (meta instanceof EnchantmentStorageMeta meta2) ? meta2.getStoredEnchants() : meta.getEnchants(); + } + + public static int getItemEnchantsAmount(@NotNull ItemStack item) { + return EnchantManager.getItemEnchants(item).size(); + } + + @Nullable + public static EnchantTier getTierById(@NotNull String id) { + return Config.getTierById(id); + } + + @NotNull + public static Collection getTiers() { + return Config.getTiers(); + } + + @NotNull + public static List getTierIds() { + return Config.getTierIds(); + } + + @Nullable + public static EnchantTier getTierByChance(@NotNull ObtainType obtainType) { + return Config.getTierByChance(obtainType); + } + + public static void setArrowWeapon(@NotNull Projectile projectile, @NotNull ItemStack bow) { + PROJECTILE_WEAPON.put(projectile.getUniqueId(), bow); + } + + @Nullable + public static ItemStack getArrowWeapon(@NotNull Projectile projectile) { + return PROJECTILE_WEAPON.get(projectile.getUniqueId()); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java new file mode 100644 index 0000000..48f59d1 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java @@ -0,0 +1,221 @@ +package su.nightexpress.excellentenchants.manager; + +import org.bukkit.NamespacedKey; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.api.manager.ICleanable; +import su.nexmedia.engine.utils.Reflex; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.manager.enchants.armor.*; +import su.nightexpress.excellentenchants.manager.enchants.bow.*; +import su.nightexpress.excellentenchants.manager.enchants.tool.*; +import su.nightexpress.excellentenchants.manager.enchants.weapon.*; + +import java.lang.reflect.Field; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +public class EnchantRegister { + + private static final ExcellentEnchants PLUGIN; + public static final Set ENCHANT_LIST; + + public static final EnchantBlastMining BLAST_MINING; + public static final EnchantCurseOfBreaking CURSE_OF_BREAKING; + public static final EnchantCurseOfMisfortune CURSE_OF_MISFORTUNE; + public static final EnchantDivineTouch DIVINE_TOUCH; + public static final EnchantHaste HASTE; + public static final EnchantLuckyMiner LUCKY_MINER; + public static final EnchantReplanter REPLANTER; + public static final EnchantSilkChest SILK_CHEST; + public static final EnchantSmelter SMELTER; + public static final EnchantTelekinesis TELEKINESIS; + public static final EnchantTreasures TREASURES; + public static final EnchantTunnel TUNNEL; + public static final EnchantVeinminer VEINMINER; + + public static final EnchantBaneOfNetherspawn BANE_OF_NETHERSPAWN; + public static final EnchantIceAspect ICE_ASPECT; + public static final EnchantInfernus INFERNUS; + public static final EnchantVenom VENOM; + public static final EnchantExhaust EXHAUST; + public static final EnchantWither WITHER; + public static final EnchantParalyze PARALYZE; + public static final EnchantExpHunter EXP_HUNTER; + public static final EnchantDecapitator DECAPITATOR; + public static final EnchantCutter CUTTER; + public static final EnchantConfusion CONFUSION; + public static final EnchantDoubleStrike DOUBLE_STRIKE; + public static final EnchantNimble NIMBLE; + public static final EnchantBlindness BLINDNESS; + public static final EnchantVampire VAMPIRE; + public static final EnchantCure CURE; + public static final EnchantRage RAGE; + public static final EnchantScavenger SCAVENGER; + public static final EnchantSurprise SURPRISE; + public static final EnchantThrifty THRIFTY; + public static final EnchantThunder THUNDER; + public static final EnchantVillageDefender VILLAGE_DEFENDER; + public static final EnchantRocket ROCKET; + + public static final EnchantFlameWalker FLAME_WALKER; + public static final EnchantHardened HARDENED; + public static final EnchantColdSteel COLD_STEEL; + public static final EnchantSelfDestruction SELF_DESTRUCTION; + public static final EnchantSaturation SATURATION; + public static final EnchantAquaman AQUAMAN; + public static final EnchantNightVision NIGHT_VISION; + public static final EnchantBunnyHop BUNNY_HOP; + public static final EnchantSonic SONIC; + public static final EnchantRegrowth REGROWTH; + + public static final EnchantBomber BOMBER; + public static final EnchantEnderBow ENDER_BOW; + public static final EnchantGhast GHAST; + public static final EnchantPoisonedArrows POISONED_ARROWS; + public static final EnchantWitheredArrows WITHERED_ARROWS; + public static final EnchantExplosiveArrows EXPLOSIVE_ARROWS; + + static { + PLUGIN = ExcellentEnchants.getInstance(); + PLUGIN.getConfigManager().extract("enchants"); + ENCHANT_LIST = new HashSet<>(); + + // Tool enchants + BLAST_MINING = init(EnchantBlastMining.class, EnchantBlastMining.ID); + CURSE_OF_BREAKING = init(EnchantCurseOfBreaking.class, EnchantCurseOfBreaking.ID); + CURSE_OF_MISFORTUNE = init(EnchantCurseOfMisfortune.class, EnchantCurseOfMisfortune.ID); + DIVINE_TOUCH = init(EnchantDivineTouch.class, EnchantDivineTouch.ID); + HASTE = init(EnchantHaste.class, EnchantHaste.ID); + LUCKY_MINER = init(EnchantLuckyMiner.class, EnchantLuckyMiner.ID); + REPLANTER = init(EnchantReplanter.class, EnchantReplanter.ID); + SILK_CHEST = init(EnchantSilkChest.class, EnchantSilkChest.ID); + SMELTER = init(EnchantSmelter.class, EnchantSmelter.ID); + TELEKINESIS = init(EnchantTelekinesis.class, EnchantTelekinesis.ID); + TREASURES = init(EnchantTreasures.class, EnchantTreasures.ID); + TUNNEL = init(EnchantTunnel.class, EnchantTunnel.ID); + VEINMINER = init(EnchantVeinminer.class, EnchantVeinminer.ID); + + // Weapon enchants + BANE_OF_NETHERSPAWN = init(EnchantBaneOfNetherspawn.class, EnchantBaneOfNetherspawn.ID); + BLINDNESS = init(EnchantBlindness.class, EnchantBlindness.ID); + CONFUSION = init(EnchantConfusion.class, EnchantConfusion.ID); + CUTTER = init(EnchantCutter.class, EnchantCutter.ID); + DECAPITATOR = init(EnchantDecapitator.class, EnchantDecapitator.ID); + DOUBLE_STRIKE = init(EnchantDoubleStrike.class, EnchantDoubleStrike.ID); + EXHAUST = init(EnchantExhaust.class, EnchantExhaust.ID); + EXP_HUNTER = init(EnchantExpHunter.class, EnchantExpHunter.ID); + ICE_ASPECT = init(EnchantIceAspect.class, EnchantIceAspect.ID); + INFERNUS = init(EnchantInfernus.class, EnchantInfernus.ID); + NIMBLE = init(EnchantNimble.class, EnchantNimble.ID); + PARALYZE = init(EnchantParalyze.class, EnchantParalyze.ID); + CURE = init(EnchantCure.class, EnchantCure.ID); + RAGE = init(EnchantRage.class, EnchantRage.ID); + ROCKET = init(EnchantRocket.class, EnchantRocket.ID); + SCAVENGER = init(EnchantScavenger.class, EnchantScavenger.ID); + SURPRISE = init(EnchantSurprise.class, EnchantSurprise.ID); + THRIFTY = init(EnchantThrifty.class, EnchantThrifty.ID); + THUNDER = init(EnchantThunder.class, EnchantThunder.ID); + VAMPIRE = init(EnchantVampire.class, EnchantVampire.ID); + VENOM = init(EnchantVenom.class, EnchantVenom.ID); + VILLAGE_DEFENDER = init(EnchantVillageDefender.class, EnchantVillageDefender.ID); + WITHER = init(EnchantWither.class, EnchantWither.ID); + + // Armor enchants + AQUAMAN = init(EnchantAquaman.class, EnchantAquaman.ID); + BUNNY_HOP = init(EnchantBunnyHop.class, EnchantBunnyHop.ID); + COLD_STEEL = init(EnchantColdSteel.class, EnchantColdSteel.ID); + FLAME_WALKER = init(EnchantFlameWalker.class, EnchantFlameWalker.ID); + HARDENED = init(EnchantHardened.class, EnchantHardened.ID); + NIGHT_VISION = init(EnchantNightVision.class, EnchantNightVision.ID); + REGROWTH = init(EnchantRegrowth.class, EnchantRegrowth.ID); + SATURATION = init(EnchantSaturation.class, EnchantSaturation.ID); + SELF_DESTRUCTION = init(EnchantSelfDestruction.class, EnchantSelfDestruction.ID); + SONIC = init(EnchantSonic.class, EnchantSonic.ID); + + // Bow enchants + BOMBER = init(EnchantBomber.class, EnchantBomber.ID); + ENDER_BOW = init(EnchantEnderBow.class, EnchantEnderBow.ID); + EXPLOSIVE_ARROWS = init(EnchantExplosiveArrows.class, EnchantExplosiveArrows.ID); + GHAST = init(EnchantGhast.class, EnchantGhast.ID); + POISONED_ARROWS = init(EnchantPoisonedArrows.class, EnchantPoisonedArrows.ID); + WITHERED_ARROWS = init(EnchantWitheredArrows.class, EnchantWitheredArrows.ID); + + } + + public static void setup() { + if (ExcellentEnchants.isLoaded) return; // Prevent to register enchantments during the runtime. + + //ENCHANT_LIST.clear(); + Reflex.setFieldValue(Enchantment.class, "acceptingNew", true); + + for (Field field : EnchantRegister.class.getFields()) { + if (!ExcellentEnchant.class.isAssignableFrom(field.getType())) continue; + + ExcellentEnchant enchant; + try { + enchant = (ExcellentEnchant) field.get(null); + EnchantRegister.register(enchant); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + Enchantment.stopAcceptingRegistrations(); + PLUGIN.info("Enchants Registered: " + ENCHANT_LIST.size()); + ExcellentEnchants.isLoaded = true; + } + + @SuppressWarnings("unchecked") + public static void shutdown() { + if (PLUGIN.isEnabled()) return; // Prevent to unregister enchantments during the runtime. + + Map byKey = (Map) Reflex.getFieldValue(Enchantment.class, "byKey"); + Map byName = (Map) Reflex.getFieldValue(Enchantment.class, "byName"); + + if (byKey == null || byName == null) return; + + for (ExcellentEnchant enchant : ENCHANT_LIST) { + if (enchant instanceof ICleanable cleanable) { + cleanable.clear(); + } + + byKey.remove(enchant.getKey()); + byName.remove(enchant.getName()); + enchant.unregisterListeners(); + } + ENCHANT_LIST.clear(); + PLUGIN.info("All enchants are unregistered."); + } + + @Nullable + private static T init(@NotNull Class clazz, @NotNull String id) { + String enchantId = id.toLowerCase(); + if (Config.ENCHANTMENTS_DISABLED.contains(id)) return null; + + JYML enchantCfg = JYML.loadOrExtract(PLUGIN, "/enchants/" + enchantId + ".yml"); + try { + return clazz.getConstructor(ExcellentEnchants.class, JYML.class).newInstance(PLUGIN, enchantCfg); + } + catch (ReflectiveOperationException ex) { + ex.printStackTrace(); + return null; + } + } + + private static void register(@Nullable ExcellentEnchant enchant) { + if (enchant == null) return; + + Enchantment.registerEnchantment(enchant); + ENCHANT_LIST.add(enchant); + enchant.registerListeners(); + PLUGIN.info("Registered enchantment: " + enchant.getId()); + //IRegistry.a(IRegistry.ENCHANTMENT, enchant.getId(), CraftEnchantment.getRaw(enchant)); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantAquaman.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantAquaman.java new file mode 100644 index 0000000..5664bb8 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantAquaman.java @@ -0,0 +1,35 @@ +package su.nightexpress.excellentenchants.manager.enchants.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; + +public class EnchantAquaman extends IEnchantPotionTemplate implements PassiveEnchant { + + public static final String ID = "aquaman"; + + public EnchantAquaman(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.WATER_BREATHING); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_HEAD; + } + + @Override + public boolean use(@NotNull LivingEntity entity, int level) { + if (!this.isEnchantmentAvailable(entity)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(entity)) return false; + + return this.addEffect(entity, level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantBunnyHop.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantBunnyHop.java new file mode 100644 index 0000000..23f57f9 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantBunnyHop.java @@ -0,0 +1,35 @@ +package su.nightexpress.excellentenchants.manager.enchants.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; + +public class EnchantBunnyHop extends IEnchantPotionTemplate implements PassiveEnchant { + + public static final String ID = "bunny_hop"; + + public EnchantBunnyHop(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.JUMP); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_FEET; + } + + @Override + public boolean use(@NotNull LivingEntity entity, int level) { + if (!this.isEnchantmentAvailable(entity)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(entity)) return false; + + return this.addEffect(entity, level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantColdSteel.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantColdSteel.java new file mode 100644 index 0000000..02a79cc --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantColdSteel.java @@ -0,0 +1,37 @@ +package su.nightexpress.excellentenchants.manager.enchants.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; + +public class EnchantColdSteel extends IEnchantPotionTemplate implements CombatEnchant { + + public static final String ID = "cold_steel"; + + public EnchantColdSteel(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.SLOW_DIGGING); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_TORSO; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(damager)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(victim)) return false; + + return this.addEffect(damager, level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java new file mode 100644 index 0000000..63f097f --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java @@ -0,0 +1,179 @@ +package su.nightexpress.excellentenchants.manager.enchants.armor; + +import org.bukkit.Location; +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; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.api.manager.ICleanable; +import su.nexmedia.engine.api.task.AbstractTask; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.MoveEnchant; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Stream; + +public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEnchant, ICleanable { + + public static final String ID = "flame_walker"; + + private static final BlockFace[] FACES = {BlockFace.SOUTH, BlockFace.NORTH, BlockFace.EAST, BlockFace.WEST}; + private static final Map BLOCKS_TO_DESTROY = new HashMap<>(); + + private final Scaler blockDecayTime; + private BlockTickTask blockTickTask; + + public EnchantFlameWalker(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.blockDecayTime = new EnchantScaler(this, "Settings.Block_Decay"); + + this.blockTickTask = new BlockTickTask(plugin); + this.blockTickTask.start(); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.addMissing("Settings.Block_Decay", "5.0 + " + PLACEHOLDER_LEVEL + " * 2"); + } + + @Override + public void clear() { + if (this.blockTickTask != null) { + this.blockTickTask.stop(); + this.blockTickTask = null; + } + BLOCKS_TO_DESTROY.keySet().forEach(block -> block.setType(Material.LAVA)); + BLOCKS_TO_DESTROY.clear(); + } + + public static void addBlock(@NotNull Block block, double seconds) { + BLOCKS_TO_DESTROY.put(block, (long) (System.currentTimeMillis() + seconds * 1000L)); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(Enchantment.FROST_WALKER); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_FEET; + } + + public double getBlockDecayTime(int level) { + return this.blockDecayTime.getValue(level); + } + + @Override + public boolean use(@NotNull PlayerMoveEvent e, @NotNull LivingEntity entity, int level) { + if (!this.isEnchantmentAvailable(entity)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(entity)) return false; + + plugin.getEnchantNMS().handleFlameWalker(entity, entity.getLocation(), level).forEach(block -> { + addBlock(block, Rnd.getDouble(this.getBlockDecayTime(level)) + 1); + }); + return true; + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onEnchantFlameWalker(PlayerMoveEvent e) { + Player player = e.getPlayer(); + if (player.isFlying()) return; + if (!this.isEnchantmentAvailable(player)) return; + + Location from = e.getFrom(); + Location to = e.getTo(); + if (to == null) return; + if (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()) return; + + ItemStack boots = player.getInventory().getBoots(); + if (boots == null || boots.getType().isAir()) return; + + int level = boots.getEnchantmentLevel(this); + if (level < 1) return; + + Block bTo = to.getBlock().getRelative(BlockFace.DOWN); + boolean hasLava = Stream.of(FACES).anyMatch(face -> bTo.getRelative(face).getType() == Material.LAVA); + if (!hasLava) return; + + this.use(e, player, level); + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onFlameWalkerBlock(BlockBreakEvent e) { + if (BLOCKS_TO_DESTROY.containsKey(e.getBlock())) { + e.setDropItems(false); + e.setExpToDrop(0); + e.getBlock().setType(Material.LAVA); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onFlameWalkerMagmaDamage(EntityDamageEvent e) { + if (e.getCause() != EntityDamageEvent.DamageCause.HOT_FLOOR) return; + if (!(e.getEntity() instanceof LivingEntity livingEntity)) return; + if (!this.isEnchantmentAvailable(livingEntity)) return; + + EntityEquipment equipment = livingEntity.getEquipment(); + if (equipment == null) return; + + ItemStack boots = equipment.getBoots(); + if (boots == null || boots.getType().isAir()) return; + + int level = boots.getEnchantmentLevel(this); + if (level < 1) return; + if (!this.checkTriggerChance(level)) return; + + e.setCancelled(true); + } + + static class BlockTickTask extends AbstractTask { + + public BlockTickTask(@NotNull ExcellentEnchants plugin) { + super(plugin, 1, false); + } + + @Override + public void action() { + long now = System.currentTimeMillis(); + + BLOCKS_TO_DESTROY.keySet().removeIf(block -> { + if (block.isEmpty()) return true; + + long time = BLOCKS_TO_DESTROY.get(block); + if (now >= time) { + block.setType(Material.LAVA); + EffectUtil.playEffect(block.getLocation(), Particle.BLOCK_CRACK.name(), Material.MAGMA_BLOCK.name(), 0.5, 0.7, 0.5, 0.03, 50); + return true; + } + return false; + }); + } + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantHardened.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantHardened.java new file mode 100644 index 0000000..74fdbc8 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantHardened.java @@ -0,0 +1,37 @@ +package su.nightexpress.excellentenchants.manager.enchants.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; + +public class EnchantHardened extends IEnchantPotionTemplate implements CombatEnchant { + + public static final String ID = "hardened"; + + public EnchantHardened(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.DAMAGE_RESISTANCE); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_TORSO; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(damager)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(victim)) return false; + + return this.addEffect(victim, level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantNightVision.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantNightVision.java new file mode 100644 index 0000000..a6eda1d --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantNightVision.java @@ -0,0 +1,35 @@ +package su.nightexpress.excellentenchants.manager.enchants.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; + +public class EnchantNightVision extends IEnchantPotionTemplate implements PassiveEnchant { + + public static final String ID = "night_vision"; + + public EnchantNightVision(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.NIGHT_VISION); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_HEAD; + } + + @Override + public boolean use(@NotNull LivingEntity entity, int level) { + if (!this.isEnchantmentAvailable(entity)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(entity)) return false; + + return this.addEffect(entity, level); + } +} \ No newline at end of file diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java new file mode 100644 index 0000000..9b1bb02 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java @@ -0,0 +1,119 @@ +package su.nightexpress.excellentenchants.manager.enchants.armor; + +import org.bukkit.Particle; +import org.bukkit.attribute.Attribute; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.manager.ICleanable; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.EntityUtil; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.manager.tasks.AbstractEnchantPassiveTask; + +import java.util.function.UnaryOperator; + +public class EnchantRegrowth extends IEnchantChanceTemplate implements PassiveEnchant, ICleanable { + + public static final String ID = "regrowth"; + + private final String particleName; + private final String particleData; + private final long healthInterval; + private final Scaler healthAmount; + private Task healthTask; + + private static final String PLACEHOLDER_HEALTH_AMOUNT = "%enchantment_health_amount%"; + private static final String PLACEHOLDER_HEALTH_INTERVAL = "%enchantment_health_interval%"; + + public EnchantRegrowth(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + this.particleName = cfg.getString("Settings.Particle.Name", Particle.HEART.name()); + this.particleData = cfg.getString("Settings.Particle.Data", ""); + this.healthInterval = cfg.getLong("Settings.Health.Interval", 100); + this.healthAmount = new EnchantScaler(this, "Settings.Health.Amount"); + this.healthTask = new Task(plugin); + this.healthTask.start(); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.addMissing("Settings.Health.Interval", 100); + cfg.addMissing("Settings.Particle.Name", Particle.HEART.name()); + cfg.addMissing("Settings.Particle.Data", ""); + } + + @Override + public void clear() { + if (this.healthTask != null) { + this.healthTask.stop(); + this.healthTask = null; + } + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_HEALTH_AMOUNT, NumberUtil.format(this.getHealthAmount(level))) + .replace(PLACEHOLDER_HEALTH_INTERVAL, NumberUtil.format((double) this.healthInterval / 20D)) + ); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_TORSO; + } + + public double getHealthAmount(int level) { + return this.healthAmount.getValue(level); + } + + public long getHealthInterval() { + return this.healthInterval; + } + + @Override + public boolean use(@NotNull LivingEntity entity, int level) { + if (!this.isEnchantmentAvailable(entity)) return false; + if (!this.checkTriggerChance(level)) return false; + + double healthMax = EntityUtil.getAttribute(entity, Attribute.GENERIC_MAX_HEALTH); + double healthHas = entity.getHealth(); + if (healthHas >= healthMax) return false; + if (!this.takeCostItem(entity)) return false; + + double amount = Math.min(healthMax, healthHas + this.getHealthAmount(level)); + + entity.setHealth(amount); + EffectUtil.playEffect(entity.getEyeLocation(), this.particleName, this.particleData, 0.3, 0.3, 0.3, 0.1, 15); + return true; + } + + class Task extends AbstractEnchantPassiveTask { + + public Task(@NotNull ExcellentEnchants plugin) { + super(plugin, healthInterval, false); + } + + @Override + protected void apply(@NotNull LivingEntity entity, @NotNull ItemStack armor, @NotNull ItemMeta meta) { + int level = meta.getEnchantLevel(EnchantRegrowth.this); + if (level < 1) return; + + use(entity, level); + } + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java new file mode 100644 index 0000000..99b1e0e --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java @@ -0,0 +1,108 @@ +package su.nightexpress.excellentenchants.manager.enchants.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +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.manager.ICleanable; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.manager.tasks.AbstractEnchantPassiveTask; + +import java.util.function.UnaryOperator; + +public class EnchantSaturation extends IEnchantChanceTemplate implements PassiveEnchant, ICleanable { + + private final long saturationInterval; + private final Scaler saturationAmount; + private Task saturationTask; + + public static final String ID = "saturation"; + + private static final String PLACEHOLDER_SATURATION_AMOUNT = "%enchantment_saturation_amount%"; + private static final String PLACEHOLDER_SATURATION_INTERVAL = "%enchantment_saturation_interval%"; + + public EnchantSaturation(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.saturationInterval = cfg.getLong("Settings.Saturation.Interval", 100); + this.saturationAmount = new EnchantScaler(this, "Settings.Saturation.Amount"); + this.saturationTask = new Task(plugin); + this.saturationTask.start(); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.addMissing("Settings.Saturation.Interval", 100); + } + + @Override + public void clear() { + if (this.saturationTask != null) { + this.saturationTask.stop(); + this.saturationTask = null; + } + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_SATURATION_AMOUNT, NumberUtil.format(this.getSaturationAmount(level))) + .replace(PLACEHOLDER_SATURATION_INTERVAL, NumberUtil.format((double) this.saturationInterval / 20D)) + ); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_TORSO; + } + + public final double getSaturationAmount(int level) { + return this.saturationAmount.getValue(level); + } + + public long getSaturationInterval() { + return saturationInterval; + } + + @Override + public boolean use(@NotNull LivingEntity entity, int level) { + if (!this.isEnchantmentAvailable(entity)) return false; + if (!(entity instanceof Player player)) return false; + if (!this.checkTriggerChance(level)) return false; + if (player.getFoodLevel() >= 20) return false; + if (!this.takeCostItem(player)) return false; + + float amount = (float) this.getSaturationAmount(level); + player.setFoodLevel((int) Math.min(20, player.getFoodLevel() + amount)); + player.setSaturation(Math.min(20, player.getSaturation() + amount)); + return true; + } + + class Task extends AbstractEnchantPassiveTask { + + public Task(@NotNull ExcellentEnchants plugin) { + super(plugin, saturationInterval, true); + } + + @Override + protected void apply(@NotNull LivingEntity entity, @NotNull ItemStack armor, @NotNull ItemMeta meta) { + int level = meta.getEnchantLevel(EnchantSaturation.this); + if (level < 1) return; + + use(entity, level); + } + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java new file mode 100644 index 0000000..ecd3ff0 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java @@ -0,0 +1,75 @@ +package su.nightexpress.excellentenchants.manager.enchants.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.metadata.FixedMetadataValue; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantSelfDestruction extends IEnchantChanceTemplate implements DeathEnchant { + + private final Scaler explosionSize; + + public static final String ID = "self_destruction"; + private static final String META_EXPLOSION_SOURCE = ID + "_explosion_source"; + + private static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; + + public EnchantSelfDestruction(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + this.explosionSize = new EnchantScaler(this, "Settings.Explosion.Size"); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_EXPLOSION_POWER, NumberUtil.format(this.getExplosionSize(level))) + ); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_TORSO; + } + + public final double getExplosionSize(int level) { + return this.explosionSize.getValue(level); + } + + @Override + public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level) { + if (!this.isEnchantmentAvailable(dead)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(dead)) return false; + + float size = (float) this.getExplosionSize(level); + dead.setMetadata(META_EXPLOSION_SOURCE, new FixedMetadataValue(plugin, true)); + boolean exploded = dead.getWorld().createExplosion(dead.getLocation(), size, false, false, dead); + dead.removeMetadata(META_EXPLOSION_SOURCE, plugin); + return exploded; + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onItemDamage(EntityDamageByEntityEvent e) { + if (!e.getDamager().hasMetadata(META_EXPLOSION_SOURCE)) return; + if (!(e.getEntity() instanceof Item item)) return; + + e.setCancelled(true); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSonic.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSonic.java new file mode 100644 index 0000000..4e34205 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSonic.java @@ -0,0 +1,35 @@ +package su.nightexpress.excellentenchants.manager.enchants.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; + +public class EnchantSonic extends IEnchantPotionTemplate implements PassiveEnchant { + + public static final String ID = "sonic"; + + public EnchantSonic(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.SPEED); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_FEET; + } + + @Override + public boolean use(@NotNull LivingEntity entity, int level) { + if (!this.isEnchantmentAvailable(entity)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(entity)) return false; + + return this.addEffect(entity, level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java new file mode 100644 index 0000000..d16f31f --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java @@ -0,0 +1,100 @@ +package su.nightexpress.excellentenchants.manager.enchants.bow; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.manager.EnchantRegister; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantBomber extends IEnchantChanceTemplate implements BowEnchant { + + private final Scaler fuseTicks; + + public static final String ID = "bomber"; + + public static final String PLACEHOLDER_FUSE_TICKS = "%enchantment_fuse_ticks%"; + + public EnchantBomber(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.HIGHEST); + + this.fuseTicks = new EnchantScaler(this, "Settings.Fuse_Ticks"); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + this.cfg.addMissing("Settings.Fuse_Ticks", "100 - %enchantment_level% * 10"); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_FUSE_TICKS, NumberUtil.format((double) this.getFuseTicks(level) / 20D)) + ); + } + + public int getFuseTicks(int level) { + return (int) this.fuseTicks.getValue(level); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.ENDER_BOW); + this.addConflict(EnchantRegister.GHAST); + this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); + this.addConflict(EnchantRegister.WITHERED_ARROWS); + this.addConflict(EnchantRegister.POISONED_ARROWS); + this.addConflict(Enchantment.ARROW_FIRE); + this.addConflict(Enchantment.ARROW_DAMAGE); + this.addConflict(Enchantment.ARROW_KNOCKBACK); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean use(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isEnchantmentAvailable(shooter)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!(e.getProjectile() instanceof Projectile projectile)) return false; + if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; + + TNTPrimed primed = projectile.getWorld().spawn(projectile.getLocation(), TNTPrimed.class); + primed.setVelocity(projectile.getVelocity().multiply(e.getForce() * 1.25)); + primed.setFuseTicks(this.getFuseTicks(level)); + primed.setSource(shooter); + e.setProjectile(primed); + return true; + } + + @Override + public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return false; + } + + @Override + public boolean use(@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/manager/enchants/bow/EnchantEnderBow.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java new file mode 100644 index 0000000..8c6b9df --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java @@ -0,0 +1,69 @@ +package su.nightexpress.excellentenchants.manager.enchants.bow; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.manager.EnchantRegister; + +public class EnchantEnderBow extends IEnchantChanceTemplate implements BowEnchant { + + public static final String ID = "ender_bow"; + + public EnchantEnderBow(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.HIGHEST); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.BOMBER); + this.addConflict(EnchantRegister.GHAST); + this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); + this.addConflict(EnchantRegister.WITHERED_ARROWS); + this.addConflict(EnchantRegister.POISONED_ARROWS); + this.addConflict(Enchantment.ARROW_FIRE); + this.addConflict(Enchantment.ARROW_DAMAGE); + this.addConflict(Enchantment.ARROW_KNOCKBACK); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean use(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isEnchantmentAvailable(shooter)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!(e.getProjectile() instanceof Projectile projectile)) return false; + if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; + + EnderPearl pearl = shooter.launchProjectile(EnderPearl.class); + pearl.setVelocity(projectile.getVelocity()); + e.setProjectile(pearl); + return true; + } + + @Override + public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return false; + } + + @Override + public boolean use(@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/manager/enchants/bow/EnchantExplosiveArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java new file mode 100644 index 0000000..bbb5fb9 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java @@ -0,0 +1,102 @@ +package su.nightexpress.excellentenchants.manager.enchants.bow; + +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +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.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowTemplate; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantExplosiveArrows extends IEnchantBowTemplate { + + private final boolean explosionFireSpread; + private final boolean explosionDamageItems; + private final boolean explosionDamageBlocks; + private final Scaler explosionSize; + + public static final String ID = "explosive_arrows"; + public static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; + + private static final String META_EXPLOSION_SOURCE = ID + "_source"; + + public EnchantExplosiveArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + this.explosionFireSpread = cfg.getBoolean("Settings.Explosion.Fire_Spread"); + this.explosionDamageItems = cfg.getBoolean("Settings.Explosion.Damage_Items"); + this.explosionDamageBlocks = cfg.getBoolean("Settings.Explosion.Damage_Blocks"); + this.explosionSize = new EnchantScaler(this, "Settings.Explosion.Size"); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + this.cfg.addMissing("Settings.Explosion.Fire_Spread", true); + this.cfg.addMissing("Settings.Explosion.Damage_Items", true); + this.cfg.addMissing("Settings.Explosion.Damage_Blocks", false); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_EXPLOSION_POWER, NumberUtil.format(this.getExplosionSize(level))) + ); + } + + public final double getExplosionSize(int level) { + return this.explosionSize.getValue(level); + } + + public final boolean isExplosionFireSpread() { + return this.explosionFireSpread; + } + + public final boolean isExplosionDamageBlocks() { + return this.explosionDamageBlocks; + } + + @Override + public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + if (!super.use(e, projectile, bow, level)) return false; + + Entity shooter = null; + if (projectile.getShooter() instanceof Entity entity) { + shooter = entity; + shooter.setMetadata(META_EXPLOSION_SOURCE, new FixedMetadataValue(this.plugin, true)); + } + + World world = projectile.getWorld(); + float explSize = (float) this.getExplosionSize(level); + boolean explFire = this.isExplosionFireSpread(); + boolean explBlocks = this.isExplosionDamageBlocks(); + boolean exploded = world.createExplosion(projectile.getLocation(), explSize, explFire, explBlocks, shooter); + if (shooter != null) shooter.removeMetadata(META_EXPLOSION_SOURCE, this.plugin); + return exploded; + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onItemDamage(EntityDamageByEntityEvent e) { + if (e.getCause() != EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) return; + if (this.explosionDamageItems) return; + if (!e.getDamager().hasMetadata(META_EXPLOSION_SOURCE)) return; + if (!(e.getEntity() instanceof Item item)) return; + + e.setCancelled(true); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java new file mode 100644 index 0000000..5997474 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java @@ -0,0 +1,112 @@ +package su.nightexpress.excellentenchants.manager.enchants.bow; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Fireball; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.SmallFireball; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.manager.EnchantRegister; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { + + private final boolean fireSpread; + private final Scaler yield; + + public static final String ID = "ghast"; + + public EnchantGhast(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.HIGHEST); + + this.fireSpread = cfg.getBoolean("Settings.Fire_Spread"); + this.yield = new EnchantScaler(this, "Settings.Yield"); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.addMissing("Settings.Fire_Spread", true); + cfg.addMissing("Settings.Yield", "1.0 * " + PLACEHOLDER_LEVEL); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.BOMBER); + this.addConflict(EnchantRegister.ENDER_BOW); + this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); + this.addConflict(EnchantRegister.WITHERED_ARROWS); + this.addConflict(EnchantRegister.POISONED_ARROWS); + this.addConflict(Enchantment.ARROW_FIRE); + this.addConflict(Enchantment.ARROW_KNOCKBACK); + } + + public boolean isFireSpread() { + return fireSpread; + } + + public float getYield(int level) { + return (float) this.yield.getValue(level); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean use(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isEnchantmentAvailable(shooter)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!(e.getProjectile() instanceof Projectile projectile)) return false; + if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; + + Fireball fireball; + + // Shoot small fireballs for the Multishot enchantment, + // as large ones has a slow speed and punches each other on shoot. + if (bow.containsEnchantment(Enchantment.MULTISHOT)) { + fireball = shooter.launchProjectile(SmallFireball.class); + fireball.setVelocity(projectile.getVelocity().normalize().multiply(0.5f)); + } + else { + fireball = shooter.launchProjectile(Fireball.class); + fireball.setDirection(projectile.getVelocity()); + } + fireball.setIsIncendiary(this.isFireSpread()); + fireball.setYield(this.getYield(level)); + + e.setProjectile(fireball); + return true; + } + + @Override + public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return false; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + // Support for the 'Power' enchantment. + int power = weapon.getEnchantmentLevel(Enchantment.ARROW_DAMAGE); + if (power < 1) return false; + + double damagePower = 0.5 + power * 0.5; + e.setDamage(e.getDamage() + damagePower); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java new file mode 100644 index 0000000..bf4527c --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java @@ -0,0 +1,17 @@ +package su.nightexpress.excellentenchants.manager.enchants.bow; + +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowPotionTemplate; + +public class EnchantPoisonedArrows extends IEnchantBowPotionTemplate { + + public static final String ID = "poisoned_arrows"; + + public EnchantPoisonedArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.POISON); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java new file mode 100644 index 0000000..ab6cb4e --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java @@ -0,0 +1,17 @@ +package su.nightexpress.excellentenchants.manager.enchants.bow; + +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowPotionTemplate; + +public class EnchantWitheredArrows extends IEnchantBowPotionTemplate { + + public static final String ID = "withered_arrows"; + + public EnchantWitheredArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.WITHER); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java new file mode 100644 index 0000000..a3de7be --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java @@ -0,0 +1,165 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import org.bukkit.block.Block; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerItemDamageEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; +import su.nightexpress.excellentenchants.hook.HookNCP; +import su.nightexpress.excellentenchants.manager.EnchantRegister; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.manager.type.FitItemType; + +import java.util.List; +import java.util.function.UnaryOperator; + +public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockBreakEnchant { + + private final Scaler explosionPower; + private final Scaler minBlockStrength; + + public static final String ID = "blast_mining"; + public static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; + + private static final String META_EXPLOSION_SOURCE = ID + "_explosion_source"; + private static final String META_EXPLOSION_MINED = ID + "_explosion_mined"; + + public EnchantBlastMining(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.explosionPower = new EnchantScaler(this, "Settings.Explosion.Power"); + this.minBlockStrength = new EnchantScaler(this, "Settings.Min_Block_Strength"); + } + + public double getExplosionPower(int level) { + return this.explosionPower.getValue(level); + } + + public float getMinBlockStrength(int level) { + return (float) minBlockStrength.getValue(level); + } + + private boolean isBlockHardEnough(@NotNull Block block, int level) { + float strength = plugin.getNMS().getBlockStrength(block); + return (strength >= this.getMinBlockStrength(level)); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.addMissing("Settings.Min_Block_Strength", "1.5 - " + PLACEHOLDER_LEVEL + " / 10.0"); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.TUNNEL); + this.addConflict(EnchantRegister.VEINMINER); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_EXPLOSION_POWER, NumberUtil.format(this.getExplosionPower(level))) + ); + } + + /*@Override + public boolean isFitItemType(@NotNull ItemStack item) { + return ItemUtil.isPickaxe(item); + }*/ + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[]{FitItemType.PICKAXE}; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @Override + public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isEnchantmentAvailable(player)) return false; + + if (EnchantRegister.VEINMINER != null && item.containsEnchantment(EnchantRegister.VEINMINER)) return false; + if (EnchantRegister.TUNNEL != null && item.containsEnchantment(EnchantRegister.TUNNEL)) return false; + + Block block = e.getBlock(); + if (block.hasMetadata(META_EXPLOSION_MINED)) return false; + + if (!this.isBlockHardEnough(block, level)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(player)) return false; + + float power = (float) this.getExplosionPower(level); + + player.setMetadata(META_EXPLOSION_SOURCE, new FixedMetadataValue(plugin, level)); + HookNCP.exemptBlocks(player); + boolean exploded = block.getWorld().createExplosion(block.getLocation(), power, false, true, player); + HookNCP.unexemptBlocks(player); + player.removeMetadata(META_EXPLOSION_SOURCE, plugin); + return exploded; + } + + // Process explosion event to mine blocks. + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlastExplosionEvent(EntityExplodeEvent e) { + if (!(e.getEntity() instanceof Player player)) return; + if (!player.hasMetadata(META_EXPLOSION_SOURCE)) return; + + int level = player.getMetadata(META_EXPLOSION_SOURCE).get(0).asInt(); + List blockList = e.blockList(); + + // Remove the 'source' block which player mined and caused the explosion to prevent duplicated drops. + // Remove all the 'soft' blocks that should not be exploded. + blockList.removeIf(block -> block.getLocation().equals(e.getLocation()) || !this.isBlockHardEnough(block, level)); + + // Break all 'exploded' blocks by a player, adding metadata to them to prevent trigger enchantment in a loop. + blockList.forEach(block -> { + block.setMetadata(META_EXPLOSION_MINED, new FixedMetadataValue(plugin, true)); + plugin.getNMS().breakBlock(player, block); + block.removeMetadata(META_EXPLOSION_MINED, plugin); + }); + + // Clear list of 'exploded' blocks so the event won't affect them, as they are already mined by a player. + blockList.clear(); + } + + // Do not damage around entities by en enchantment explosion. + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlastExplosionDamage(EntityDamageByEntityEvent e) { + if (e.getCause() != DamageCause.ENTITY_EXPLOSION) return; + if (!(e.getDamager() instanceof Player player)) return; + + e.setCancelled(player.hasMetadata(META_EXPLOSION_SOURCE)); + } + + // Do not reduce item durability for 'exploded' blocks. + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlastExplosionItemDamage(PlayerItemDamageEvent e) { + if (!e.getPlayer().hasMetadata(META_EXPLOSION_SOURCE)) return; + + e.setCancelled(true); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java new file mode 100644 index 0000000..c2d219b --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java @@ -0,0 +1,75 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerItemDamageEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantCurseOfBreaking extends IEnchantChanceTemplate { + + private final Scaler durabilityAmount; + + public static final String ID = "curse_of_breaking"; + public static final String PLACEHOLDER_DURABILITY_AMOUNT = "%enchantment_durability_amount%"; + + public EnchantCurseOfBreaking(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.durabilityAmount = new EnchantScaler(this, "Settings.Durability_Amount"); + } + + public int getDurabilityAmount(int level) { + return (int) this.durabilityAmount.getValue(level); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(Enchantment.DURABILITY); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_DURABILITY_AMOUNT, NumberUtil.format(this.getDurabilityAmount(level))) + ); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BREAKABLE; + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onItemDurability(PlayerItemDamageEvent e) { + Player player = e.getPlayer(); + if (!this.isEnchantmentAvailable(player)) return; + + ItemStack item = e.getItem(); + int level = item.getEnchantmentLevel(this); + + if (level < 1) return; + if (!this.checkTriggerChance(level)) return; + if (!this.takeCostItem(player)) return; + + int durabilityAmount = this.getDurabilityAmount(level); + if (durabilityAmount <= 0) return; + + e.setDamage(e.getDamage() + durabilityAmount); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java new file mode 100644 index 0000000..b9066c4 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java @@ -0,0 +1,83 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; +import su.nightexpress.excellentenchants.manager.type.FitItemType; + +public class EnchantCurseOfMisfortune extends IEnchantChanceTemplate implements BlockBreakEnchant, DeathEnchant { + + private final boolean dropExp; + + public static final String ID = "curse_of_misfortune"; + + public EnchantCurseOfMisfortune(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.LOW); + + this.dropExp = cfg.getBoolean("Settings.Drop_Exp"); + } + + public boolean isDropExp() { + return dropExp; + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(LOOT_BONUS_BLOCKS); + this.addConflict(LOOT_BONUS_MOBS); + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[] {FitItemType.WEAPON, FitItemType.TOOL}; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BREAKABLE; + } + + @Override + public boolean isCursed() { + return true; + } + + @Override + public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isEnchantmentAvailable(player)) return false; + if (EnchantTelekinesis.isDropHandled(e.getBlock())) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(player)) return false; + + e.setDropItems(false); + if (!this.isDropExp()) e.setExpToDrop(0); + return true; + } + + @Override + public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level) { + Player player = dead.getKiller(); + if (player == null) return false; + if (!this.isEnchantmentAvailable(player)) return false; + + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(player)) return false; + + e.getDrops().clear(); + if (!this.isDropExp()) e.setDroppedExp(0); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java new file mode 100644 index 0000000..bb4ee1f --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java @@ -0,0 +1,150 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.CreatureSpawner; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BlockStateMeta; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.LocationUtil; +import su.nexmedia.engine.utils.StringUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; +import su.nightexpress.excellentenchants.manager.EnchantRegister; +import su.nightexpress.excellentenchants.manager.type.FitItemType; + +import java.util.Collections; +import java.util.List; + +public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockBreakEnchant, CustomDropEnchant { + + private final String particleName; + private final String particleData; + private final String spawnerName; + + public static final String ID = "divine_touch"; + + public EnchantDivineTouch(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.particleName = cfg.getString("Settings.Particle.Name", Particle.VILLAGER_HAPPY.name()); + this.particleData = cfg.getString("Settings.Particle.Data", ""); + this.spawnerName = StringUtil.color(cfg.getString("Settings.Spawner_Item.Name", "&aMob Spawner &7(%type%)")); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.SMELTER); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.remove("Settings.Particle_Effect"); + cfg.addMissing("Settings.Particle.Name", Particle.VILLAGER_HAPPY.name()); + cfg.addMissing("Settings.Particle.Data", ""); + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[]{FitItemType.PICKAXE}; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @NotNull + public ItemStack getSpawner(@NotNull CreatureSpawner spawnerBlock) { + ItemStack itemSpawner = new ItemStack(Material.SPAWNER); + BlockStateMeta stateItem = (BlockStateMeta) itemSpawner.getItemMeta(); + if (stateItem == null) return itemSpawner; + + CreatureSpawner spawnerItem = (CreatureSpawner) stateItem.getBlockState(); + spawnerItem.setSpawnedType(spawnerBlock.getSpawnedType()); + spawnerItem.update(true); + stateItem.setBlockState(spawnerItem); + stateItem.setDisplayName(this.spawnerName.replace("%type%", plugin.lang().getEnum(spawnerBlock.getSpawnedType()))); + itemSpawner.setItemMeta(stateItem); + + return itemSpawner; + } + + @Override + @NotNull + public List getCustomDrops(@NotNull Player player, @NotNull ItemStack item, @NotNull Block block, int level) { + if (!(block.getState() instanceof CreatureSpawner spawnerBlock)) return Collections.emptyList(); + + return Collections.singletonList(this.getSpawner(spawnerBlock)); + } + + @Override + public boolean isEventMustHaveDrops() { + return false; + } + + @Override + public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isEnchantmentAvailable(player)) return false; + Block block = e.getBlock(); + if (EnchantTelekinesis.isDropHandled(block)) return false; + if (!(block.getState() instanceof CreatureSpawner spawnerBlock)) return false; + if (this.isEventMustHaveDrops() && !e.isDropItems()) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(player)) return false; + + Location location = LocationUtil.getCenter(block.getLocation()); + World world = block.getWorld(); + + this.getCustomDrops(player, item, block, level).forEach(itemSpawner -> world.dropItemNaturally(location, itemSpawner)); + EffectUtil.playEffect(location, this.particleName, this.particleData, 0.3f, 0.3f, 0.3f, 0.15f, 30); + + e.setExpToDrop(0); + e.setDropItems(false); + return true; + } + + // Update spawner type of the placed spawner mined by Divine Touch. + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onSpawnerPlace(BlockPlaceEvent e) { + Block block = e.getBlock(); + if (block.getType() != Material.SPAWNER) return; + + Player player = e.getPlayer(); + ItemStack spawner = player.getInventory().getItemInMainHand(); + if (spawner.getType().isAir() || spawner.getType() != Material.SPAWNER) { + spawner = player.getInventory().getItemInOffHand(); + } + if (spawner.getType().isAir() || spawner.getType() != Material.SPAWNER) { + return; + } + + BlockStateMeta meta = (BlockStateMeta) spawner.getItemMeta(); + if (meta == null) return; + + CreatureSpawner spawnerItem = (CreatureSpawner) meta.getBlockState(); + CreatureSpawner spawnerBlock = (CreatureSpawner) block.getState(); + + spawnerBlock.setSpawnedType(spawnerItem.getSpawnedType()); + spawnerBlock.update(); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantHaste.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantHaste.java new file mode 100644 index 0000000..26eb8ba --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantHaste.java @@ -0,0 +1,35 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; + +public class EnchantHaste extends IEnchantPotionTemplate implements PassiveEnchant { + + public static final String ID = "haste"; + + public EnchantHaste(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.FAST_DIGGING); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @Override + public boolean use(@NotNull LivingEntity entity, int level) { + if (!this.isEnchantmentAvailable(entity)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(entity)) return false; + + return this.addEffect(entity, level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java new file mode 100644 index 0000000..a712b6e --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java @@ -0,0 +1,73 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.manager.type.FitItemType; + +import java.util.function.UnaryOperator; + +public class EnchantLuckyMiner extends IEnchantChanceTemplate implements BlockBreakEnchant { + + private final Scaler expModifier; + + public static final String ID = "lucky_miner"; + + private static final String PLACEHOLDER_EXP_MODIFIER = "%enchantment_exp_modifier%"; + + public EnchantLuckyMiner(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + this.expModifier = new EnchantScaler(this, "Settings.Exp_Modifier"); + } + + public double getExpModifier(int level) { + return this.expModifier.getValue(level); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_EXP_MODIFIER, NumberUtil.format(this.getExpModifier(level) * 100D - 100D)) + ); + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[]{FitItemType.PICKAXE}; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @Override + public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (e.isCancelled()) return false; + if (!this.isEnchantmentAvailable(player)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(player)) return false; + + double expMod = this.getExpModifier(level); + e.setExpToDrop((int) ((double) e.getExpToDrop() * expMod)); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantReplanter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantReplanter.java new file mode 100644 index 0000000..ed11133 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantReplanter.java @@ -0,0 +1,182 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import com.google.common.collect.Sets; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Ageable; +import org.bukkit.block.data.BlockData; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Player; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.MessageUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.InteractEnchant; +import su.nightexpress.excellentenchants.manager.type.FitItemType; + +import java.util.Set; + +public class EnchantReplanter extends IEnchantChanceTemplate implements InteractEnchant, BlockBreakEnchant { + + private final boolean replantOnRightClick; + private final boolean replantOnPlantBreak; + + public static final String ID = "replanter"; + + private static final Set CROPS = Sets.newHashSet( + Material.WHEAT_SEEDS, Material.BEETROOT_SEEDS, Material.MELON_SEEDS, Material.PUMPKIN_SEEDS, + Material.POTATO, Material.CARROT, Material.NETHER_WART); + + public EnchantReplanter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.HIGH); + + this.replantOnRightClick = cfg.getBoolean("Settings.Replant.On_Right_Click"); + this.replantOnPlantBreak = cfg.getBoolean("Settings.Replant.On_Plant_Break"); + } + + public boolean isReplantOnPlantBreak() { + return replantOnPlantBreak; + } + + public boolean isReplantOnRightClick() { + return replantOnRightClick; + } + + @NotNull + private Material fineSeedsToBlock(@NotNull Material material) { + if (material == Material.POTATO) return Material.POTATOES; + if (material == Material.CARROT) return Material.CARROTS; + if (material == Material.BEETROOT_SEEDS) return Material.BEETROOTS; + if (material == Material.WHEAT_SEEDS) return Material.WHEAT; + if (material == Material.PUMPKIN_SEEDS) return Material.PUMPKIN_STEM; + if (material == Material.MELON_SEEDS) return Material.MELON_STEM; + return material; + } + + @NotNull + private Material fineBlockToSeeds(@NotNull Material material) { + if (material == Material.POTATOES) return Material.POTATO; + if (material == Material.CARROTS) return Material.CARROT; + if (material == Material.BEETROOTS) return Material.BEETROOT_SEEDS; + if (material == Material.WHEAT) return Material.WHEAT_SEEDS; + if (material == Material.MELON_STEM) return Material.MELON_SEEDS; + if (material == Material.PUMPKIN_STEM) return Material.PUMPKIN_SEEDS; + return material; + } + + private boolean takeSeeds(@NotNull Player player, @NotNull Material material) { + material = this.fineBlockToSeeds(material); + + int slot = player.getInventory().first(material); + if (slot < 0) return false; + + ItemStack seed = player.getInventory().getItem(slot); + if (seed == null || seed.getType().isAir()) return false; + + seed.setAmount(seed.getAmount() - 1); + return true; + } + + @Override + protected void updateConfig() { + super.updateConfig(); + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[]{FitItemType.HOE}; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @Override + public boolean use(@NotNull PlayerInteractEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isEnchantmentAvailable(player)) return false; + if (!this.isReplantOnRightClick()) return false; + + // Check for a event hand. We dont want to trigger it twice. + if (e.getHand() != EquipmentSlot.HAND) return false; + if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return false; + + // Check if player holds seeds to plant them by offhand interaction. + ItemStack off = player.getInventory().getItemInOffHand(); + if (!off.getType().isAir() && CROPS.contains(off.getType())) return false; + + // Check if clicked block is a farmland. + Block blockGround = e.getClickedBlock(); + if (blockGround == null) return false; + if (blockGround.getType() != Material.FARMLAND && blockGround.getType() != Material.SOUL_SAND) return false; + + // Check enchantment trigger chance. + if (!this.checkTriggerChance(level)) return false; + + // Check if someting is already growing on the farmland. + Block blockPlant = blockGround.getRelative(BlockFace.UP); + if (!blockPlant.isEmpty()) return false; + + // Get the first crops from player's inventory and plant them. + for (Material seed : CROPS) { + if (seed == Material.NETHER_WART && blockGround.getType() == Material.SOUL_SAND + || seed != Material.NETHER_WART && blockGround.getType() == Material.FARMLAND) { + if (this.takeSeeds(player, seed)) { + MessageUtil.sound(player, seed == Material.NETHER_WART ? Sound.ITEM_NETHER_WART_PLANT : Sound.ITEM_CROP_PLANT); + plugin.getNMS().sendAttackPacket(player, 0); + blockPlant.setType(this.fineSeedsToBlock(seed)); + break; + } + } + } + return true; + } + + @Override + public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isEnchantmentAvailable(player)) return false; + if (!this.isReplantOnPlantBreak()) return false; + + Block blockPlant = e.getBlock(); + //if (EnchantTelekinesis.isDropHandled(blockPlant)) return false; + //if (EnchantRegister.TELEKINESIS != null && item.containsEnchantment(EnchantRegister.TELEKINESIS)) return false; + + // Check if broken block is supported crop(s). + if (!CROPS.contains(this.fineBlockToSeeds(blockPlant.getType()))) return false; + + // Check if broken block is actually can grow. + BlockData dataPlant = blockPlant.getBlockData(); + if (!(dataPlant instanceof Ageable plant)) return false; + + // Check enchantment trigger chance. + if (!this.checkTriggerChance(level)) return false; + + // Check if crop is not at its maximal age to prevent accidient replant. + /*if (plant.getAge() < plant.getMaximumAge()) { + e.setCancelled(true); + return false; + }*/ + + // Replant the gathered crops with a new one. + if (this.takeSeeds(player, plant.getMaterial())) { + plugin.getServer().getScheduler().runTask(plugin, () -> { + blockPlant.setType(plant.getMaterial()); + plant.setAge(0); + blockPlant.setBlockData(plant); + }); + } + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java new file mode 100644 index 0000000..bfa073a --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java @@ -0,0 +1,183 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.block.Chest; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryPickupItemEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.Inventory; +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.utils.ItemUtil; +import su.nexmedia.engine.utils.PDCUtil; +import su.nexmedia.engine.utils.StringUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; +import su.nightexpress.excellentenchants.manager.type.FitItemType; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +public class EnchantSilkChest extends IEnchantChanceTemplate implements BlockBreakEnchant, CustomDropEnchant { + + private final Map keyItems; + private final String chestName; + + public static final String ID = "silk_chest"; + + public EnchantSilkChest(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + this.keyItems = new TreeMap<>(); + this.chestName = StringUtil.color(cfg.getString("Settings.Chest_Item.Name", "%name% &7(%items% items)")); + + for (int pos = 0; pos < 27; pos++) { + this.getItemKey(pos); + } + } + + @Override + protected void updateConfig() { + super.updateConfig(); + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[]{FitItemType.AXE}; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + private NamespacedKey getItemKey(int pos) { + return this.keyItems.computeIfAbsent(pos, key -> new NamespacedKey(plugin, "silkchest_item_" + pos)); + } + + public boolean isSilkChest(@NotNull ItemStack item) { + return PDCUtil.getStringData(item, this.getItemKey(0)) != null; + } + + @NotNull + public ItemStack getSilkChest(@NotNull Chest chest) { + Block block = chest.getBlock(); + ItemStack chestItem = new ItemStack(block.getType()); + + // Store and count chest items. + int amount = 0; + int count = 0; + for (ItemStack itemInv : chest.getBlockInventory().getContents()) { + if (itemInv == null) itemInv = new ItemStack(Material.AIR); + else amount++; + + String base64 = ItemUtil.toBase64(itemInv); + if (base64 == null) continue; + if (base64.length() >= Short.MAX_VALUE) { + block.getWorld().dropItemNaturally(block.getLocation(), itemInv); + continue; + } + PDCUtil.setData(chestItem, this.getItemKey(count++), base64); + } + + // Apply item meta name and items data string. + ItemMeta meta = chestItem.getItemMeta(); + if (meta != null) { + String nameOrig = ItemUtil.getItemName(chestItem); + String nameChest = this.chestName.replace("%name%", nameOrig).replace("%items%", String.valueOf(amount)); + meta.setDisplayName(nameChest); + chestItem.setItemMeta(meta); + } + + return chestItem; + } + + @Override + @NotNull + public List getCustomDrops(@NotNull Player player, @NotNull ItemStack item, @NotNull Block block, int level) { + if (block.getType() == Material.ENDER_CHEST) return Collections.emptyList(); + if (!(block.getState() instanceof Chest chest)) return Collections.emptyList(); + + return Collections.singletonList(this.getSilkChest(chest)); + } + + @Override + public boolean isEventMustHaveDrops() { + return true; + } + + @Override + public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + Block block = e.getBlock(); + if (!this.isEnchantmentAvailable(player)) return false; + if (EnchantTelekinesis.isDropHandled(block)) return false; + if (block.getType() == Material.ENDER_CHEST) return false; + if (this.isEventMustHaveDrops() && !e.isDropItems()) return false; + if (!this.checkTriggerChance(level)) return false; + if (!(block.getState() instanceof Chest chest)) return false; + if (!this.takeCostItem(player)) return false; + + // Drop custom chest and do not drop the original one. + this.getCustomDrops(player, item, block, level).forEach(chestItem -> block.getWorld().dropItemNaturally(block.getLocation(), chestItem)); + + // Do not drop chest items. + chest.getBlockInventory().clear(); + e.setDropItems(false); + + return true; + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onSilkChestPlace(BlockPlaceEvent e) { + ItemStack item = e.getItemInHand(); + if (item.getType().isAir()) return; + + Block block = e.getBlockPlaced(); + BlockState state = block.getState(); + if (!(state instanceof Chest chest)) return; + + Inventory inventory = chest.getBlockInventory(); + for (int pos = 0; pos < inventory.getSize(); pos++) { + String data = PDCUtil.getStringData(item, this.getItemKey(pos)); + if (data == null) continue; + + ItemStack itemInv = ItemUtil.fromBase64(data); + inventory.setItem(pos, itemInv); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onSilkChestStore(InventoryClickEvent e) { + Inventory inv = e.getInventory(); + if (inv.getType() == InventoryType.CRAFTING || inv.getType() == InventoryType.CREATIVE) return; + + ItemStack item = e.getCurrentItem(); + if (item == null || item.getType().isAir()) return; + + if (this.isSilkChest(item)) { + e.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onSilkChestHopper(InventoryPickupItemEvent e) { + e.setCancelled(this.isSilkChest(e.getItem().getItemStack())); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java new file mode 100644 index 0000000..3ba3fa3 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java @@ -0,0 +1,144 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import org.bukkit.*; +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.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.LocationUtil; +import su.nexmedia.engine.utils.MessageUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; +import su.nightexpress.excellentenchants.manager.EnchantRegister; +import su.nightexpress.excellentenchants.manager.type.FitItemType; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class EnchantSmelter extends IEnchantChanceTemplate implements BlockBreakEnchant, CustomDropEnchant { + + private final String sound; + private final String particleName; + private final String particleData; + private final Map smeltingTable; + + public static final String ID = "smelter"; + + public EnchantSmelter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.sound = cfg.getString("Settings.Sound", ""); + this.particleName = cfg.getString("Settings.Particle.Name", Particle.FLAME.name()); + this.particleData = cfg.getString("Settings.Particle.Data", ""); + 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); + } + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(Enchantment.SILK_TOUCH); + this.addConflict(EnchantRegister.DIVINE_TOUCH); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.remove("Settings.Particle_Effect"); + cfg.addMissing("Settings.Sound", Sound.BLOCK_LAVA_EXTINGUISH.name()); + cfg.addMissing("Settings.Particle.Name", Particle.FLAME.name()); + cfg.addMissing("Settings.Particle.Data", ""); + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[]{FitItemType.PICKAXE, FitItemType.AXE, FitItemType.SHOVEL}; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @Override + @NotNull + public List getCustomDrops(@NotNull Player player, @NotNull ItemStack item, @NotNull Block block, int level) { + if (block.getState() instanceof Container) return Collections.emptyList(); + + List drops = plugin.getNMS().getBlockDrops(block, player, item); + return this.smelt(drops); + } + + public boolean isSmeltable(@NotNull Material material) { + return this.smeltingTable.containsKey(material); + } + + @NotNull + public List smelt(@NotNull List drops) { + return drops.stream().peek(drop -> { + Material material = this.smeltingTable.get(drop.getType()); + if (material != null) drop.setType(material); + }).toList(); + } + + public void playEffect(@NotNull Block block) { + Location location = LocationUtil.getCenter(block.getLocation(), true); + MessageUtil.sound(location, this.sound); + EffectUtil.playEffect(location, this.particleName, this.particleData, 0.2f, 0.2f, 0.2f, 0.05f, 30); + } + + @Override + public boolean isEventMustHaveDrops() { + return true; + } + + @Override + public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + Block block = e.getBlock(); + if (!this.isEnchantmentAvailable(player)) return false; + if (EnchantTelekinesis.isDropHandled(block)) return false; + if (this.isEventMustHaveDrops() && !e.isDropItems()) return false; + if (!this.checkTriggerChance(level)) return false; + + List defaults = plugin.getNMS().getBlockDrops(block, player, item); + List custom = this.getCustomDrops(player, item, block, level); + if (custom.isEmpty() || custom.containsAll(defaults)) return false; + if (!this.takeCostItem(player)) return false; + + e.setDropItems(false); + + World world = block.getWorld(); + Location location = LocationUtil.getCenter(block.getLocation(), true); + + custom.forEach(itemSmelt -> world.dropItem(location, itemSmelt)); + this.playEffect(block); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java new file mode 100644 index 0000000..cb13694 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java @@ -0,0 +1,151 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import org.bukkit.block.Block; +import org.bukkit.block.Chest; +import org.bukkit.block.Container; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.api.config.LangMessage; +import su.nexmedia.engine.utils.ItemUtil; +import su.nexmedia.engine.utils.PlayerUtil; +import su.nexmedia.engine.utils.StringUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; +import su.nightexpress.excellentenchants.manager.EnchantManager; +import su.nightexpress.excellentenchants.manager.EnchantRegister; +import su.nightexpress.excellentenchants.manager.type.FitItemType; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.UnaryOperator; + +public class EnchantTelekinesis extends IEnchantChanceTemplate implements BlockBreakEnchant { + + public static final String META_BLOCK_DROP_HANDLER = "telekinesis_drop_handler"; + + private final LangMessage messageDropReceived; + private final String messageItemName; + private final String messageItemSeparator; + + public static final String ID = "telekinesis"; + + public EnchantTelekinesis(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.HIGHEST); + + this.messageDropReceived = new LangMessage(plugin.lang(), cfg.getString("Settings.Message.Drop_Received", "")); + this.messageItemName = StringUtil.color(cfg.getString("Settings.Message.Item_Name", "&7x%item_amount% &f%item_name%")); + this.messageItemSeparator = StringUtil.color(cfg.getString("Settings.Message.Item_Separator", "&7, ")); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.remove("Settings.Radius"); + cfg.remove("Settings.Power"); + + cfg.addMissing("Settings.Message.Drop_Received", "{message: ~type: ACTION_BAR; ~prefix: false;}%items%"); + cfg.addMissing("Settings.Message.Item_Name", "&7x%item_amount% &f%item_name%"); + cfg.addMissing("Settings.Message.Item_Separator", "&7, "); + } + + public static boolean isDropHandled(@NotNull Block block) { + return block.hasMetadata(META_BLOCK_DROP_HANDLER); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return super.replacePlaceholders(level); + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[]{FitItemType.TOOL}; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @Override + public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isEnchantmentAvailable(player)) return false; + if (e.getBlock().getState() instanceof Container) return false; + if (!e.isDropItems()) return false; + if (!this.checkTriggerChance(level)) return false; + + EnchantCurseOfMisfortune curseOfMisfortune = EnchantRegister.CURSE_OF_MISFORTUNE; + if (curseOfMisfortune != null && item.containsEnchantment(curseOfMisfortune)) { + if (curseOfMisfortune.use(e, player, item, level)) { + return false; + } + } + + Block block = e.getBlock(); + List drops = new ArrayList<>(plugin.getNMS().getBlockDrops(block, player, item)); + + // Check inventory space. + if (drops.stream().anyMatch(itemDrop -> PlayerUtil.countItemSpace(player, itemDrop) == 0)) return false; + + // Tell other enchantments that block drops are handled by Telekinesis. + block.setMetadata(META_BLOCK_DROP_HANDLER, new FixedMetadataValue(plugin, true)); + + for (Map.Entry entry : EnchantManager.getItemCustomEnchants(item, CustomDropEnchant.class).entrySet()) { + CustomDropEnchant dropEnchant = entry.getKey(); + int dropLevel = entry.getValue(); + if (dropEnchant.isEventMustHaveDrops() && !e.isDropItems()) continue; + + if (dropEnchant instanceof IEnchantChanceTemplate chanceEnchant) { + if (!chanceEnchant.checkTriggerChance(dropLevel)) continue; + } + if (dropEnchant instanceof EnchantSilkChest && block.getState() instanceof Chest) { + drops.removeIf(drop -> drop.getType() == block.getType()); + } + if (dropEnchant instanceof EnchantSmelter smelter) { + boolean isSmelted = drops.stream().anyMatch(drop -> smelter.isSmeltable(drop.getType())); + smelter.smelt(drops); + if (isSmelted) smelter.playEffect(block); + continue; // Do not add smelted items twice, only replace current ones. + } + if (dropEnchant instanceof EnchantTreasures treasures) { + if (treasures.getTreasure(block) != null) { + treasures.playEffect(block); + } + } + + drops.addAll(dropEnchant.getCustomDrops(player, item, block, dropLevel)); + } + drops.removeIf(Objects::isNull); + + StringBuilder builder = new StringBuilder(); + drops.forEach(drop -> { + PlayerUtil.addItem(player, drop); + + if (!builder.isEmpty()) builder.append(this.messageItemSeparator); + builder.append(this.messageItemName + .replace("%item_name%", ItemUtil.getItemName(drop)) + .replace("%item_amount%", String.valueOf(drop.getAmount()))); + }); + this.messageDropReceived.replace("%items%", builder.toString()).send(player); + + e.setDropItems(false); + plugin.getServer().getScheduler().runTask(plugin, c -> { + block.removeMetadata(META_BLOCK_DROP_HANDLER, plugin); + }); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java new file mode 100644 index 0000000..841185d --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java @@ -0,0 +1,154 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.NexEngine; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.api.manager.ICleanable; +import su.nexmedia.engine.manager.player.listener.PlayerBlockPlacedListener; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.LocationUtil; +import su.nexmedia.engine.utils.MessageUtil; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; +import su.nightexpress.excellentenchants.manager.type.FitItemType; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + +public class EnchantTreasures extends IEnchantChanceTemplate implements BlockBreakEnchant, CustomDropEnchant, ICleanable { + + private final String particleName; + private final String particleData; + private final String sound; + private final Map> treasures; + private final Predicate userBlockFilter; + + public static final String ID = "treasures"; + + public EnchantTreasures(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.LOWEST); + + this.particleName = cfg.getString("Settings.Particle.Name", Particle.REDSTONE.name()); + this.particleData = cfg.getString("Settings.Particle.Data", "200,180,0"); + this.sound = cfg.getString("Settings.Sound", Sound.BLOCK_NOTE_BLOCK_BELL.name()); + this.treasures = new HashMap<>(); + for (String sFromArray : cfg.getSection("Settings.Treasures")) { + for (String sFrom : sFromArray.split(",")) { + Material mFrom = Material.getMaterial(sFrom.toUpperCase()); + if (mFrom == null) { + plugin.error("[Treasures] Invalid source material '" + sFrom + "' !"); + continue; + } + Map treasuresList = new HashMap<>(); + + for (String sTo : cfg.getSection("Settings.Treasures." + sFromArray)) { + Material mTo = Material.getMaterial(sTo.toUpperCase()); + if (mTo == null) { + plugin.error("[Treasures] Invalid result material '" + sTo + "' for '" + sFromArray + "' !"); + continue; + } + + double tChance = cfg.getDouble("Settings.Treasures." + sFromArray + "." + sTo); + treasuresList.put(mTo, tChance); + } + this.treasures.put(mFrom, treasuresList); + } + } + + NexEngine.get().getPlayerManager().enableUserBlockListening(); + PlayerBlockPlacedListener.BLOCK_FILTERS.add(this.userBlockFilter = (block) -> { + return this.getTreasure(block) != null; + }); + } + + @Override + public void clear() { + PlayerBlockPlacedListener.BLOCK_FILTERS.remove(this.userBlockFilter); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + cfg.remove("Settings.Particle_Effect"); + cfg.addMissing("Settings.Particle.Name", Particle.REDSTONE.name()); + cfg.addMissing("Settings.Particle.Data", "200,180,0"); + cfg.addMissing("Settings.Sound", Sound.BLOCK_NOTE_BLOCK_BELL.name()); + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[]{FitItemType.PICKAXE, FitItemType.AXE, FitItemType.SHOVEL}; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @Override + @NotNull + public List getCustomDrops(@NotNull Player player, @NotNull ItemStack item, @NotNull Block block, int level) { + ItemStack drop = this.getTreasure(block); + if (PlayerBlockPlacedListener.isUserPlaced(block) || drop == null) return Collections.emptyList(); + return Collections.singletonList(drop); + } + + @Override + public boolean isEventMustHaveDrops() { + return false; + } + + @Nullable + public final ItemStack getTreasure(@NotNull Block block) { + Map treasures = this.treasures.get(block.getType()); + if (treasures == null) return null; + + Material mat = Rnd.get(treasures); + return mat != null && !mat.isAir() ? new ItemStack(mat) : null; + } + + public void playEffect(@NotNull Block block) { + Location location = LocationUtil.getCenter(block.getLocation()); + MessageUtil.sound(location, this.sound); + EffectUtil.playEffect(location, this.particleName, this.particleData, 0.2f, 0.2f, 0.2f, 0.12f, 20); + } + + + @Override + public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + Block block = e.getBlock(); + if (!this.isEnchantmentAvailable(player)) return false; + if (EnchantTelekinesis.isDropHandled(block)) return false; + if (this.isEventMustHaveDrops() && !e.isDropItems()) return false; + if (PlayerBlockPlacedListener.isUserPlaced(block)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(player)) return false; + + Location location = LocationUtil.getCenter(block.getLocation()); + List drops = this.getCustomDrops(player, item, block, level); + if (drops.isEmpty()) return false; + + drops.forEach(itemDrop -> block.getWorld().dropItem(location, itemDrop)); + this.playEffect(block); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java new file mode 100644 index 0000000..fd3416a --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java @@ -0,0 +1,138 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.Version; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.LocationUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; +import su.nightexpress.excellentenchants.hook.HookNCP; +import su.nightexpress.excellentenchants.manager.EnchantRegister; +import su.nightexpress.excellentenchants.manager.type.FitItemType; + +import java.util.HashSet; +import java.util.Set; + +public class EnchantTunnel extends IEnchantChanceTemplate implements BlockBreakEnchant { + + private final boolean disableOnSneak; + + public static final String ID = "tunnel"; + private static final String META_BLOCK_TUNNEL = ID + "_block_tunneled"; + // X and Z offsets for each block AoE mined + private static final int[][] MINING_COORD_OFFSETS = new int[][]{{0, 0}, {0, -1}, {-1, 0}, {0, 1}, {1, 0}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1},}; + private static final Set INTERACTABLE_BLOCKS = new HashSet<>(); + + static { + INTERACTABLE_BLOCKS.add(Material.REDSTONE_ORE); + if (Version.CURRENT.isHigher(Version.V1_16_R3)) { + INTERACTABLE_BLOCKS.add(Material.DEEPSLATE_REDSTONE_ORE); + } + } + + public EnchantTunnel(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.HIGH); + this.disableOnSneak = cfg.getBoolean("Settings.Ignore_When_Sneaking"); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.VEINMINER); + this.addConflict(EnchantRegister.BLAST_MINING); + + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[]{FitItemType.PICKAXE, FitItemType.SHOVEL}; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @Override + public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + Block block = e.getBlock(); + if (!this.isEnchantmentAvailable(player)) return false; + if (this.disableOnSneak && player.isSneaking()) return false; + if (EnchantRegister.VEINMINER != null && item.containsEnchantment(EnchantRegister.VEINMINER)) return false; + if (EnchantRegister.BLAST_MINING != null && item.containsEnchantment(EnchantRegister.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; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(player)) return false; + + BlockFace dir = LocationUtil.getDirection(player); + boolean isY = dir != null && block.getRelative(dir.getOppositeFace()).isEmpty(); + boolean isZ = dir == BlockFace.EAST || dir == BlockFace.WEST; + + // Mine + shape if Tunnel I, 3x3 if Tunnel II + int blocksBroken = 1; + if (level == 1) blocksBroken = 2; + else if (level == 2) blocksBroken = 5; + else if (level == 3) blocksBroken = 9; + + HookNCP.exemptBlocks(player); + + for (int i = 0; i < blocksBroken; i++) { + if (item.getType().isAir()) break; + + int xAdd = MINING_COORD_OFFSETS[i][0]; + int zAdd = MINING_COORD_OFFSETS[i][1]; + + Block blockAdd; + if (isY) { + blockAdd = block.getLocation().clone().add(isZ ? 0 : xAdd, zAdd, isZ ? xAdd : 0).getBlock(); + } + else { + blockAdd = block.getLocation().clone().add(xAdd, 0, zAdd).getBlock(); + } + + // Skip blocks that should not be mined + if (blockAdd.equals(block)) continue; + if (blockAdd.getDrops(item).isEmpty()) continue; + if (blockAdd.isLiquid()) continue; + + Material addType = blockAdd.getType(); + + // Some extra block checks. + if (addType.isInteractable() && !INTERACTABLE_BLOCKS.contains(addType)) continue; + if (addType == Material.BEDROCK || addType == Material.END_PORTAL || addType == Material.END_PORTAL_FRAME) continue; + if (addType == Material.OBSIDIAN && addType != block.getType()) continue; + + // Play block break particles before it's broken. + 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); + blockAdd.removeMetadata(META_BLOCK_TUNNEL, plugin); + } + + HookNCP.unexemptBlocks(player); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java new file mode 100644 index 0000000..bff7eb7 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java @@ -0,0 +1,138 @@ +package su.nightexpress.excellentenchants.manager.enchants.tool; + +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.LocationUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; +import su.nightexpress.excellentenchants.hook.HookNCP; +import su.nightexpress.excellentenchants.manager.EnchantRegister; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.manager.type.FitItemType; + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; +import java.util.function.UnaryOperator; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class EnchantVeinminer extends IEnchantChanceTemplate implements BlockBreakEnchant { + + private final Scaler blocksLimit; + private final Set blocksAffected; + + public static final String ID = "veinminer"; + + private static final BlockFace[] AREA = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH}; + private static final String META_BLOCK_VEINED = ID + "_block_veined"; + private static final String PLACEHOLDER_BLOCK_LIMIT = "%enchantment_block_limit%"; + + public EnchantVeinminer(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.HIGH); + + this.blocksLimit = new EnchantScaler(this, "Settings.Blocks.Max_At_Once"); + this.blocksAffected = cfg.getStringSet("Settings.Blocks.Affected").stream() + .map(type -> Material.getMaterial(type.toUpperCase())).filter(Objects::nonNull).collect(Collectors.toSet()); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.TUNNEL); + this.addConflict(EnchantRegister.BLAST_MINING); + } + + @NotNull + public Set getBlocksAffected() { + return this.blocksAffected; + } + + public int getBlocksLimit(int level) { + return (int) this.blocksLimit.getValue(level); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_BLOCK_LIMIT, String.valueOf(this.getBlocksLimit(level))) + ); + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[]{FitItemType.PICKAXE}; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @NotNull + private Set getNearby(@NotNull Block block) { + return Stream.of(AREA).map(block::getRelative) + .filter(blockAdded -> blockAdded.getType() == block.getType()).collect(Collectors.toSet()); + } + + private void vein(@NotNull Player player, @NotNull Block source, int level) { + Set ores = new HashSet<>(); + Set prepare = new HashSet<>(this.getNearby(source)); + + int limit = Math.min(this.getBlocksLimit(level), 30); + if (limit < 0) return; + + while (ores.addAll(prepare) && ores.size() < limit) { + Set nearby = new HashSet<>(); + prepare.forEach(prepared -> nearby.addAll(this.getNearby(prepared))); + prepare.clear(); + prepare.addAll(nearby); + } + 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); + + ore.setMetadata(META_BLOCK_VEINED, new FixedMetadataValue(plugin, true)); + plugin.getNMS().breakBlock(player, ore); + ore.removeMetadata(META_BLOCK_VEINED, plugin); + }); + } + + @Override + public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack tool, int level) { + if (!this.isEnchantmentAvailable(player)) return false; + if (EnchantRegister.TUNNEL != null && tool.containsEnchantment(EnchantRegister.TUNNEL)) return false; + if (EnchantRegister.BLAST_MINING != null && tool.containsEnchantment(EnchantRegister.BLAST_MINING)) return false; + + Block block = e.getBlock(); + if (block.hasMetadata(META_BLOCK_VEINED)) return false; + if (block.getDrops(tool).isEmpty()) return false; + + if (!this.getBlocksAffected().contains(block.getType())) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(player)) return false; + + HookNCP.exemptBlocks(player); + this.vein(player, block, level); + HookNCP.unexemptBlocks(player); + + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java new file mode 100644 index 0000000..13a6136 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java @@ -0,0 +1,106 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import com.google.common.collect.Sets; +import org.bukkit.Particle; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.EntityType; +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.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.manager.EnchantRegister; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.Set; +import java.util.function.UnaryOperator; + +public class EnchantBaneOfNetherspawn extends IEnchantChanceTemplate implements CombatEnchant { + + private final String particleName; + private final String particleData; + private final boolean damageModifier; + private final Scaler damageFormula; + private final Set entityTypes; + + public static final String ID = "bane_of_netherspawn"; + + private static final String PLACEHOLDER_DAMAGE = "%enchantment_damage%"; + + public EnchantBaneOfNetherspawn(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.particleName = cfg.getString("Settings.Particle.Name", ""); + this.particleData = cfg.getString("Settings.Particle.Data", ""); + this.damageModifier = cfg.getBoolean("Settings.Damage.As_Modifier"); + this.damageFormula = new EnchantScaler(this, "Settings.Damage.Formula"); + + this.entityTypes = Sets.newHashSet(EntityType.BLAZE, EntityType.MAGMA_CUBE, + EntityType.WITHER_SKELETON, EntityType.GHAST, EntityType.WITHER); + + this.entityTypes.add(EntityType.PIGLIN); + this.entityTypes.add(EntityType.PIGLIN_BRUTE); + this.entityTypes.add(EntityType.ZOGLIN); + this.entityTypes.add(EntityType.HOGLIN); + this.entityTypes.add(EntityType.STRIDER); + this.entityTypes.add(EntityType.ZOMBIFIED_PIGLIN); + } + + public double getDamageModifier(int level) { + return this.damageFormula.getValue(level); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.remove("Settings.Particle_Effect"); + cfg.addMissing("Settings.Particle.Name", Particle.SMOKE_NORMAL.name()); + cfg.addMissing("Settings.Particle.Data", ""); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.VILLAGE_DEFENDER); + this.addConflict(Enchantment.DAMAGE_ARTHROPODS); + this.addConflict(Enchantment.DAMAGE_UNDEAD); + this.addConflict(Enchantment.DAMAGE_ALL); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_DAMAGE, NumberUtil.format(this.getDamageModifier(level))) + ); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(damager)) return false; + if (!this.entityTypes.contains(victim.getType())) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(damager)) return false; + + double damageEvent = e.getDamage(); + double damageAdd = this.getDamageModifier(level); + e.setDamage(this.damageModifier ? damageEvent * damageAdd : damageEvent + damageAdd); + EffectUtil.playEffect(victim.getEyeLocation(), this.particleName, this.particleData, 0.25, 0.25, 0.25, 0.1f, 30); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBlindness.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBlindness.java new file mode 100644 index 0000000..9b9bd7e --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBlindness.java @@ -0,0 +1,17 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; + +public class EnchantBlindness extends IEnchantCombatPotionTemplate { + + public static final String ID = "blindness"; + + public EnchantBlindness(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.BLINDNESS); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantConfusion.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantConfusion.java new file mode 100644 index 0000000..3eee512 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantConfusion.java @@ -0,0 +1,17 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; + +public class EnchantConfusion extends IEnchantCombatPotionTemplate { + + public static final String ID = "confusion"; + + public EnchantConfusion(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.CONFUSION); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCure.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCure.java new file mode 100644 index 0000000..a646ece --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCure.java @@ -0,0 +1,79 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import com.google.common.collect.Sets; +import org.bukkit.Particle; +import org.bukkit.Sound; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.*; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.MessageUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; + +import java.util.Set; + +public class EnchantCure extends IEnchantChanceTemplate implements CombatEnchant { + + private final Sound sound; + private final String particleName; + private final String particleData; + + public static final String ID = "cure"; + + private static final Set MOBS_TO_CURE = Sets.newHashSet(EntityType.ZOMBIFIED_PIGLIN, EntityType.ZOMBIE_VILLAGER); + + public EnchantCure(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.sound = cfg.getEnum("Settings.Sound", Sound.class); + this.particleName = cfg.getString("Settings.Particle.Name", Particle.CLOUD.name()); + this.particleData = cfg.getString("Settings.Particle.Data", ""); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.remove("Settings.Particle_Effect"); + cfg.addMissing("Settings.Particle.Name", Particle.CLOUD.name()); + cfg.addMissing("Settings.Particle.Data", ""); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(damager)) return false; + if (!MOBS_TO_CURE.contains(victim.getType())) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(damager)) return false; + + e.setCancelled(true); + + EffectUtil.playEffect(victim.getLocation(), this.particleName, this.particleData, 0.25, 0.25, 0.25, 0.1f, 20); + if (this.sound != null) MessageUtil.sound(victim.getLocation(), this.sound); + + if (victim instanceof PigZombie pigZombie) { + victim.getWorld().spawn(victim.getLocation(), Piglin.class); + } + else if (victim instanceof ZombieVillager zombieVillager) { + Villager.Profession profession = zombieVillager.getVillagerProfession(); + Villager villager = victim.getWorld().spawn(victim.getLocation(), Villager.class); + if (profession != null) { + villager.setProfession(profession); + } + } + victim.remove(); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java new file mode 100644 index 0000000..c7d6298 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java @@ -0,0 +1,102 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.Particle; +import org.bukkit.Sound; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.inventory.EntityEquipment; +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.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.MessageUtil; +import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantCutter extends IEnchantChanceTemplate implements CombatEnchant { + + protected Scaler durabilityReduction; + protected Sound sound; + + public static final String ID = "cutter"; + + private static final String PLACEHOLDER_DURABILITY_DAMAGE = "%enchantment_durability_damage%"; + + public EnchantCutter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.LOWEST); + this.durabilityReduction = new EnchantScaler(this, "Settings.Item.Durability_Reduction"); + this.sound = cfg.getEnum("Settings.Item.Sound", Sound.class); + } + + public final double getDurabilityReduction(int level) { + return this.durabilityReduction.getValue(level); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.addMissing("Settings.Item.Sound", Sound.ENTITY_ITEM_BREAK.name()); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_DURABILITY_DAMAGE, NumberUtil.format(this.getDurabilityReduction(level) * 100D)) + ); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(damager)) return false; + + EntityEquipment equipment = victim.getEquipment(); + if (equipment == null) return false; + + ItemStack[] armor = equipment.getArmorContents(); + if (armor.length == 0) return false; + + int get = Rnd.get(armor.length); + ItemStack itemCut = armor[get]; + + if (itemCut == null || itemCut.getType().isAir() || itemCut.getType().getMaxDurability() == 0) return false; + + ItemMeta meta = itemCut.getItemMeta(); + if (!(meta instanceof Damageable damageable)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(damager)) return false; + + damageable.setDamage((int) (itemCut.getType().getMaxDurability() * this.getDurabilityReduction(level))); + itemCut.setItemMeta(damageable); + + armor[get] = null; + equipment.setArmorContents(armor); + + Item drop = victim.getWorld().dropItemNaturally(victim.getLocation(), itemCut); + drop.setPickupDelay(50); + drop.getVelocity().multiply(3D); + + EffectUtil.playEffect(victim.getEyeLocation(), Particle.ITEM_CRACK.name(), itemCut.getType().name(), 0.2f, 0.15f, 0.2f, 0.15f, 40); + if (this.sound != null) MessageUtil.sound(victim.getLocation(), this.sound.name()); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java new file mode 100644 index 0000000..d12c449 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java @@ -0,0 +1,122 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + + +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.*; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.ItemUtil; +import su.nexmedia.engine.utils.StringUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +public class EnchantDecapitator extends IEnchantChanceTemplate implements DeathEnchant { + + private final String particleName; + private final String particleData; + private final Set ignoredEntityTypes; + private final String headName; + private final Map headTextures; + + public static final String ID = "decapitator"; + + public EnchantDecapitator(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.particleName = cfg.getString("Settings.Particle.Name", Particle.BLOCK_CRACK.name()); + this.particleData = cfg.getString("Settings.Particle.Data", Material.REDSTONE_BLOCK.name()); + this.ignoredEntityTypes = cfg.getStringSet("Settings.Ignored_Entity_Types").stream().map(String::toUpperCase).collect(Collectors.toSet()); + this.headName = StringUtil.color(cfg.getString("Settings.Head_Item.Name", "&c%entity%'s Head")); + this.headTextures = new HashMap<>(); + for (String sType : cfg.getSection("Settings.Head_Item.Textures")) { + String texture = cfg.getString("Settings.Head_Item.Textures." + sType); + this.headTextures.put(sType.toUpperCase(), texture); + } + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + this.cfg.remove("Settings.Particle_Effect"); + this.cfg.addMissing("Settings.Particle.Name", Particle.BLOCK_CRACK.name()); + this.cfg.addMissing("Settings.Particle.Data", Material.REDSTONE_BLOCK.name()); + this.cfg.addMissing("Settings.Ignored_Entity_Types", Arrays.asList("ENDER_DRAGON", "WITHER_SKELETON", "WITHER")); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity victim, int level) { + if (!this.isEnchantmentAvailable(victim)) return false; + + EntityType entityType = victim.getType(); + if (this.ignoredEntityTypes.contains(entityType.name())) return false; + if (!this.checkTriggerChance(level)) return false; + + Player killer = victim.getKiller(); + if (killer == null) return false; + if (!this.takeCostItem(killer)) return false; + + ItemStack item; + if (entityType == EntityType.WITHER_SKELETON || entityType == EntityType.WITHER) { + item = new ItemStack(Material.WITHER_SKELETON_SKULL); + } + else if (entityType == EntityType.ZOMBIE || entityType == EntityType.GIANT) { + item = new ItemStack(Material.ZOMBIE_HEAD); + } + else if (entityType == EntityType.SKELETON) { + item = new ItemStack(Material.SKELETON_SKULL); + } + else if (entityType == EntityType.CREEPER) { + item = new ItemStack(Material.CREEPER_HEAD); + } + else if (entityType == EntityType.ENDER_DRAGON) { + item = new ItemStack(Material.DRAGON_HEAD); + } + else { + item = new ItemStack(Material.PLAYER_HEAD); + SkullMeta meta = (SkullMeta) item.getItemMeta(); + if (meta == null) return false; + + String entityName; + if (victim instanceof Player player) { + entityName = this.headName.replace("%entity%", victim.getName()); + meta.setOwningPlayer(player); + } + else { + String texture = this.headTextures.get(victim.getType().name()); + if (texture == null) return false; + + entityName = this.headName.replace("%entity%", plugin.lang().getEnum(victim.getType())); + ItemUtil.addSkullTexture(item, texture, ID + victim.getType().name()); + meta = (SkullMeta) item.getItemMeta(); + } + + meta.setDisplayName(entityName); + item.setItemMeta(meta); + } + + victim.getWorld().dropItemNaturally(victim.getLocation(), item); + EffectUtil.playEffect(victim.getEyeLocation(), this.particleName, this.particleData, 0.2f, 0.15f, 0.2f, 0.15f, 40); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDoubleStrike.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDoubleStrike.java new file mode 100644 index 0000000..e967956 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDoubleStrike.java @@ -0,0 +1,60 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.Particle; +import org.bukkit.Sound; +import org.bukkit.enchantments.EnchantmentTarget; +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.api.config.JYML; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.MessageUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; + +public class EnchantDoubleStrike extends IEnchantChanceTemplate implements CombatEnchant { + + private final String particleName; + private final String particleData; + private final Sound sound; + + public static final String ID = "double_strike"; + + public EnchantDoubleStrike(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.LOW); + + this.particleName = cfg.getString("Settings.Particle.Name", Particle.EXPLOSION_NORMAL.name()); + this.particleData = cfg.getString("Settings.Particle.Data", ""); + this.sound = cfg.getEnum("Settings.Sound", Sound.class); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.remove("Settings.Particle_Effect"); + cfg.addMissing("Settings.Particle.Name", Particle.EXPLOSION_NORMAL.name()); + cfg.addMissing("Settings.Particle.Data", ""); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(damager)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(damager)) return false; + + e.setDamage(e.getDamage() * 2D); + EffectUtil.playEffect(victim.getEyeLocation(), this.particleName, this.particleData, 0.2f, 0.15f, 0.2f, 0.15f, 20); + if (this.sound != null) MessageUtil.sound(victim.getLocation(), this.sound); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExhaust.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExhaust.java new file mode 100644 index 0000000..41501f9 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExhaust.java @@ -0,0 +1,17 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; + +public class EnchantExhaust extends IEnchantCombatPotionTemplate { + + public static final String ID = "exhaust"; + + public EnchantExhaust(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.HUNGER); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java new file mode 100644 index 0000000..5c7eeba --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java @@ -0,0 +1,70 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDeathEvent; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantExpHunter extends IEnchantChanceTemplate implements DeathEnchant { + + private final Scaler expModifier; + + public static final String ID = "exp_hunter"; + public static final String PLACEHOLDER_EXP_MODIFIER = "%enchantment_exp_modifier%"; + + public EnchantExpHunter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + this.expModifier = new EnchantScaler(this, "Settings.Exp_Modifier"); + } + + public final double getExpModifier(int level) { + return this.expModifier.getValue(level); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_EXP_MODIFIER, NumberUtil.format(this.getExpModifier(level) * 100D - 100D)) + ); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level) { + if (!this.isEnchantmentAvailable(dead)) return false; + + Player killer = dead.getKiller(); + if (killer == null) return false; + + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(killer)) return false; + + double expModifier = this.getExpModifier(level); + double expFinal = Math.ceil((double) e.getDroppedExp() * expModifier); + + e.setDroppedExp((int) expFinal); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantIceAspect.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantIceAspect.java new file mode 100644 index 0000000..9a1eb76 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantIceAspect.java @@ -0,0 +1,31 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.entity.LivingEntity; +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.Version; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; + +public class EnchantIceAspect extends IEnchantCombatPotionTemplate { + + public static final String ID = "ice_aspect"; + + public EnchantIceAspect(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.SLOW); + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!super.use(e, damager, victim, weapon, level)) return false; + + if (Version.CURRENT.isHigher(Version.V1_16_R3)) { + victim.setFreezeTicks(victim.getMaxFreezeTicks()); + } + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java new file mode 100644 index 0000000..08b65ea --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java @@ -0,0 +1,89 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantInfernus extends IEnchantChanceTemplate { + + private final Scaler fireTicks; + + public static final String ID = "infernus"; + public static final String PLACEHOLDER_FIRE_DURATION = "%enchantment_fire_duration%"; + + public EnchantInfernus(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.fireTicks = new EnchantScaler(this, "Settings.Fire_Ticks"); + } + + public int getFireTicks(int level) { + return (int) this.fireTicks.getValue(level); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_FIRE_DURATION, NumberUtil.format((double) this.getFireTicks(level) / 20D)) + ); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TRIDENT; + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onInfernusTridentLaunch(ProjectileLaunchEvent e) { + Entity entity = e.getEntity(); + if (!(entity instanceof Trident trident)) return; + if (!(trident.getShooter() instanceof LivingEntity shooter)) return; + if (!this.isEnchantmentAvailable(shooter)) return; + + ItemStack item = trident.getItem(); + + int level = item.getEnchantmentLevel(this); + if (level <= 0) return; + + if (!this.checkTriggerChance(level)) return; + if (!this.takeCostItem(shooter)) return; + trident.setFireTicks(Integer.MAX_VALUE); + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onInfernusDamageApply(EntityDamageByEntityEvent e) { + Entity entity = e.getDamager(); + if (!(entity instanceof Trident trident)) return; + + ItemStack item = trident.getItem(); + + int level = item.getEnchantmentLevel(this); + if (level <= 0 || trident.getFireTicks() <= 0) return; + + int ticks = this.getFireTicks(level); + e.getEntity().setFireTicks(ticks); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantNimble.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantNimble.java new file mode 100644 index 0000000..85b13f9 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantNimble.java @@ -0,0 +1,43 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDeathEvent; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.PlayerUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; + +public class EnchantNimble extends IEnchantChanceTemplate implements DeathEnchant { + + public static final String ID = "nimble"; + + public EnchantNimble(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.LOWEST); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level) { + if (!this.isEnchantmentAvailable(dead)) return false; + + Player player = dead.getKiller(); + if (player == null) return false; + + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(player)) return false; + + e.getDrops().forEach(item -> PlayerUtil.addItem(player, item)); + e.getDrops().clear(); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantParalyze.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantParalyze.java new file mode 100644 index 0000000..e55d476 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantParalyze.java @@ -0,0 +1,17 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; + +public class EnchantParalyze extends IEnchantCombatPotionTemplate { + + public static final String ID = "paralyze"; + + public EnchantParalyze(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.SLOW_DIGGING); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRage.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRage.java new file mode 100644 index 0000000..9ce4156 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRage.java @@ -0,0 +1,25 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.entity.LivingEntity; +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.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; + +public class EnchantRage extends IEnchantCombatPotionTemplate { + + public static final String ID = "rage"; + + public EnchantRage(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.INCREASE_DAMAGE); + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return super.use(e, damager, damager, weapon, level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java new file mode 100644 index 0000000..780e7e5 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java @@ -0,0 +1,61 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.Sound; +import org.bukkit.enchantments.EnchantmentTarget; +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.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.EntityUtil; +import su.nexmedia.engine.utils.MessageUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +public class EnchantRocket extends IEnchantChanceTemplate implements CombatEnchant { + + private final Scaler fireworkPower; + + public static final String ID = "rocket"; + + public EnchantRocket(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + this.fireworkPower = new EnchantScaler(this, "Settings.Firework_Power"); + } + + public final double getFireworkPower(int level) { + return this.fireworkPower.getValue(level); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(damager)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(damager)) return false; + + if (victim.isInsideVehicle()) { + victim.leaveVehicle(); + } + + Firework firework = EntityUtil.spawnRandomFirework(victim.getLocation()); + FireworkMeta meta = firework.getFireworkMeta(); + meta.setPower((int) this.getFireworkPower(level)); + firework.setFireworkMeta(meta); + firework.addPassenger(victim); + + MessageUtil.sound(victim.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_LAUNCH); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantScavenger.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantScavenger.java new file mode 100644 index 0000000..e28c2e1 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantScavenger.java @@ -0,0 +1,97 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.Material; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +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.api.config.JYML; +import su.nexmedia.engine.utils.CollectionsUtil; +import su.nexmedia.engine.utils.StringUtil; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; + +import java.util.AbstractMap; +import java.util.HashMap; +import java.util.Map; + +public class EnchantScavenger extends IEnchantChanceTemplate implements DeathEnchant { + + private final Map>> loot; + + public static final String ID = "scavenger"; + + public EnchantScavenger(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + this.loot = new HashMap<>(); + + for (String eId : cfg.getSection("Settings.Treasures")) { + EntityType eType = CollectionsUtil.getEnum(eId, EntityType.class); + if (eType == null || !eType.isAlive()) { + plugin.error("[Scavenger] Invalid entity type '" + eId + "' !"); + continue; + } + + Map> items = new HashMap<>(); + for (String sFromArray : cfg.getSection("Settings.Treasures." + eId)) { + Material material = Material.getMaterial(sFromArray.toUpperCase()); + if (material == null) { + plugin.error("[Scavenger] Invalid item material '" + sFromArray + "' !"); + continue; + } + + String path = "Settings.Treasures." + eId + "." + sFromArray + "."; + String[] amountSplit = cfg.getString(path + "Amount", "1:1").split(":"); + int amountMin = StringUtil.getInteger(amountSplit[0], 1); + int amountMax = StringUtil.getInteger(amountSplit[1], 1); + int[] amount = new int[]{amountMin, amountMax}; + + double chance = cfg.getDouble(path + "Chance"); + if (chance <= 0) continue; + + Map.Entry item = new AbstractMap.SimpleEntry<>(amount, chance); + items.put(material, item); + } + this.loot.put(eType, items); + } + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level) { + if (!this.isEnchantmentAvailable(dead)) return false; + + Map> items = this.loot.get(dead.getType()); + if (items == null) return false; + + Player killer = dead.getKiller(); + if (killer == null) return false; + + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(killer)) return false; + + items.forEach((material, data) -> { + double chance = data.getValue(); + if (Rnd.get(true) > chance) return; + + int amount = Rnd.get(data.getKey()[0], data.getKey()[1]); + if (amount <= 0) return; + + ItemStack item = new ItemStack(material); + e.getDrops().add(item); + }); + + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantSurprise.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantSurprise.java new file mode 100644 index 0000000..d44ddfb --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantSurprise.java @@ -0,0 +1,28 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.entity.LivingEntity; +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.config.JYML; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; + +public class EnchantSurprise extends IEnchantCombatPotionTemplate { + + public static final String ID = "surprise"; + + public EnchantSurprise(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.BLINDNESS); + + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + this.potionEffectType = Rnd.get(PotionEffectType.values()); + return super.use(e, damager, victim, weapon, level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThrifty.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThrifty.java new file mode 100644 index 0000000..05df499 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThrifty.java @@ -0,0 +1,83 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.PDCUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; + +import java.util.Set; +import java.util.stream.Collectors; + +public class EnchantThrifty extends IEnchantChanceTemplate implements DeathEnchant { + + private final Set ignoredEntityTypes; + private final Set ignoredSpawnReasons; + private final NamespacedKey keyEntityIgnored; + + public static final String ID = "thrifty"; + + public EnchantThrifty(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + this.keyEntityIgnored = new NamespacedKey(plugin, ID + "_ignored"); + + this.ignoredEntityTypes = cfg.getStringSet("Settings.Ignored_Entity_Types").stream().map(String::toUpperCase).collect(Collectors.toSet()); + this.ignoredSpawnReasons = cfg.getStringSet("Settings.Ignored_Spawn_Reasons").stream().map(String::toUpperCase).collect(Collectors.toSet()); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level) { + if (!this.isEnchantmentAvailable(dead)) return false; + + Player killer = dead.getKiller(); + if (killer == null) return false; + + if (this.ignoredEntityTypes.contains(dead.getType().name())) return false; + if (PDCUtil.getBooleanData(dead, this.keyEntityIgnored)) return false; + if (!this.checkTriggerChance(level)) return false; + + Material material = Material.getMaterial(dead.getType().name() + "_SPAWN_EGG"); + if (material == null) { + if (dead.getType() == EntityType.MUSHROOM_COW) { + material = Material.MOOSHROOM_SPAWN_EGG; + } + else return false; + } + if (!this.takeCostItem(killer)) return false; + + ItemStack egg = new ItemStack(material); + e.getDrops().add(egg); + return true; + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onSettingCreatureSpawnReason(CreatureSpawnEvent e) { + if (!this.ignoredSpawnReasons.contains(e.getSpawnReason().name())) return; + + PDCUtil.setData(e.getEntity(), this.keyEntityIgnored, true); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThunder.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThunder.java new file mode 100644 index 0000000..54c0381 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThunder.java @@ -0,0 +1,51 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.enchantments.EnchantmentTarget; +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.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; + +public class EnchantThunder extends IEnchantChanceTemplate implements CombatEnchant { + + private final boolean inThunderstormOnly; + + public static final String ID = "thunder"; + + public EnchantThunder(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.inThunderstormOnly = cfg.getBoolean("Settings.During_Thunderstorm_Only"); + } + + public boolean isInThunderstormOnly() { + return inThunderstormOnly; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(damager)) return false; + if (this.isInThunderstormOnly() && !victim.getWorld().isThundering()) return false; + if (victim.getLocation().getBlock().getLightFromSky() != 15) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(damager)) return false; + + plugin.getServer().getScheduler().runTask(plugin, () -> { + victim.setNoDamageTicks(0); + victim.getWorld().strikeLightning(victim.getLocation()); + }); + + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java new file mode 100644 index 0000000..c767219 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java @@ -0,0 +1,102 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.Particle; +import org.bukkit.attribute.Attribute; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.EntityUtil; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantVampire extends IEnchantChanceTemplate implements CombatEnchant { + + private final String particleName; + private final String particleData; + private final Scaler healAmount; + private final boolean healMultiplier; + + public static final String ID = "vampire"; + public static final String PLACEHOLDER_HEAL_AMOUNT = "%enchantment_heal_amount%"; + + public EnchantVampire(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.LOWEST); + + this.particleName = cfg.getString("Settings.Particle.Name", Particle.HEART.name()); + this.particleData = cfg.getString("Settings.Particle.Data", ""); + this.healAmount = new EnchantScaler(this, "Settings.Heal.Amount"); + this.healMultiplier = cfg.getBoolean("Settings.Heal.As_Multiplier"); + } + + public double getHealAmount(int level) { + return this.healAmount.getValue(level); + } + + public boolean isHealMultiplier() { + return healMultiplier; + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.remove("Settings.Particle_Effect"); + cfg.remove("Settings.Heal_Of_Damage"); + cfg.addMissing("Settings.Particle.Name", Particle.HEART.name()); + cfg.addMissing("Settings.Particle.Data", ""); + cfg.addMissing("Settings.Heal.Amount", "0.25 * " + PLACEHOLDER_LEVEL); + cfg.addMissing("Settings.Heal.As_Multiplier", false); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + double healAmount = this.getHealAmount(level); + + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_HEAL_AMOUNT, NumberUtil.format(this.isHealMultiplier() ? healAmount * 100D : healAmount)) + ); + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(damager)) return false; + + double healthMax = EntityUtil.getAttribute(damager, Attribute.GENERIC_MAX_HEALTH); + double healthHas = damager.getHealth(); + if (healthHas == healthMax) return false; + + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(damager)) return false; + + double healAmount = this.getHealAmount(level); + double healFinal = this.isHealMultiplier() ? e.getDamage() * healAmount : healAmount; + + EntityRegainHealthEvent healthEvent = new EntityRegainHealthEvent(damager, healFinal, EntityRegainHealthEvent.RegainReason.CUSTOM); + plugin.getPluginManager().callEvent(healthEvent); + if (healthEvent.isCancelled()) return false; + + damager.setHealth(Math.min(healthMax, healthHas + healthEvent.getAmount())); + + EffectUtil.playEffect(damager.getEyeLocation(), this.particleName, this.particleData, 0.2f, 0.15f, 0.2f, 0.15f, 5); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVenom.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVenom.java new file mode 100644 index 0000000..c4b3bbe --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVenom.java @@ -0,0 +1,17 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; + +public class EnchantVenom extends IEnchantCombatPotionTemplate { + + public static final String ID = "venom"; + + public EnchantVenom(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.POISON); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java new file mode 100644 index 0000000..dda0224 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java @@ -0,0 +1,98 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.Particle; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Illager; +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.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.manager.EnchantRegister; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantVillageDefender extends IEnchantChanceTemplate implements CombatEnchant { + + private final boolean damageMultiplier; + private final Scaler damageAmount; + private final String particleName; + private final String particleData; + + public static final String ID = "village_defender"; + public static final String PLACEHOLDER_DAMAGE_AMOUNT = "%enchantment_damage_amount%"; + + public EnchantVillageDefender(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.damageAmount = new EnchantScaler(this, "Settings.Damage.Formula"); + this.damageMultiplier = cfg.getBoolean("Settings.Damage.As_Modifier"); + this.particleName = cfg.getString("Settings.Particle.Name", Particle.VILLAGER_ANGRY.name()); + this.particleData = cfg.getString("Settings.Particle.Data", ""); + } + + public double getDamageAddict(int level) { + return this.damageAmount.getValue(level); + } + + public boolean isDamageMultiplier() { + return damageMultiplier; + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_DAMAGE_AMOUNT, NumberUtil.format(this.getDamageAddict(level))) + ); + } + + @Override + protected void updateConfig() { + super.updateConfig(); + + cfg.remove("Settings.Particle_Effect"); + cfg.addMissing("Settings.Particle.Name", Particle.VILLAGER_ANGRY.name()); + cfg.addMissing("Settings.Particle.Data", ""); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.BANE_OF_NETHERSPAWN); + this.addConflict(Enchantment.DAMAGE_ARTHROPODS); + this.addConflict(Enchantment.DAMAGE_UNDEAD); + this.addConflict(Enchantment.DAMAGE_ALL); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(damager)) return false; + if (!(victim instanceof Illager)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(damager)) return false; + + double damageAdd = this.getDamageAddict(level); + double damageHas = e.getDamage(); + double damageFinal = this.isDamageMultiplier() ? (damageHas * damageAdd) : (damageHas + damageAdd); + + e.setDamage(damageFinal); + EffectUtil.playEffect(victim.getEyeLocation(), this.particleName, this.particleData, 0.15, 0.15, 0.15, 0.13f, 3); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantWither.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantWither.java new file mode 100644 index 0000000..0f032ca --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantWither.java @@ -0,0 +1,17 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; + +public class EnchantWither extends IEnchantCombatPotionTemplate { + + public static final String ID = "wither"; + + public EnchantWither(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.WITHER); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java new file mode 100644 index 0000000..17beea8 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java @@ -0,0 +1,283 @@ +package su.nightexpress.excellentenchants.manager.listeners; + +import org.bukkit.Material; +import org.bukkit.block.Chest; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Minecart; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.enchantment.EnchantItemEvent; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.VillagerAcquireTradeEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareAnvilEvent; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.event.world.LootGenerateEvent; +import org.bukkit.inventory.*; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.manager.AbstractListener; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.config.ObtainSettings; +import su.nightexpress.excellentenchants.manager.EnchantManager; +import su.nightexpress.excellentenchants.manager.object.EnchantTier; +import su.nightexpress.excellentenchants.manager.type.ObtainType; + +import java.util.HashMap; +import java.util.Map; + +public class EnchantGenericListener extends AbstractListener { + + public EnchantGenericListener(@NotNull EnchantManager enchantManager) { + super(enchantManager.plugin()); + } + + // --------------------------------------------------------------- + // Handle Anvil + // --------------------------------------------------------------- + @EventHandler(priority = EventPriority.HIGH) + public void onEnchantUpdateAnvil(PrepareAnvilEvent e) { + AnvilInventory inventory = e.getInventory(); + + ItemStack first = inventory.getItem(0); + ItemStack second = inventory.getItem(1); + ItemStack result = e.getResult(); + + // Check if source item is an enchantable single item. + if (first == null || !EnchantManager.isEnchantable(first) || first.getAmount() > 1) return; + + // For repair/rename, only re-add item enchants. + if ((second == null || second.getType().isAir() || !EnchantManager.isEnchantable(second)) && (result != null && result.getType() == first.getType())) { + ItemStack result2 = new ItemStack(result); + EnchantManager.getItemCustomEnchants(first).forEach((hasEnch, hasLevel) -> { + EnchantManager.addEnchant(result2, hasEnch, hasLevel, true); + }); + e.setResult(result2); + return; + } + + // Check if the second item is an enchantable single item. + if (second == null || second.getAmount() > 1 || !EnchantManager.isEnchantable(second)) return; + + // Prevent operation if first item is book while the second one is another item. + if (first.getType() == Material.ENCHANTED_BOOK && second.getType() != first.getType()) return; + + // Fine result item in case if it's nulled somehow. + if (result == null || result.getType() == Material.AIR) { + result = new ItemStack(first); + } + + Map enchAdd = EnchantManager.getItemCustomEnchants(first); + int repairCost = inventory.getRepairCost(); + + // If the second item is an enchanted book or the same item type, then + // we can merge our enchantments. + if (second.getType() == Material.ENCHANTED_BOOK || second.getType() == first.getType()) { + for (Map.Entry en : EnchantManager.getItemCustomEnchants(second).entrySet()) { + enchAdd.merge(en.getKey(), en.getValue(), (oldLvl, newLvl) -> (oldLvl.equals(newLvl)) ? (oldLvl + 1) : (Math.max(oldLvl, newLvl))); + } + } + + // Recalculate operation cost depends on enchantments merge cost. + for (Map.Entry ent : enchAdd.entrySet()) { + ExcellentEnchant enchant = ent.getKey(); + int level = Math.min(enchant.getMaxLevel(), ent.getValue()); + if (EnchantManager.addEnchant(result, enchant, level, false)) { + repairCost += enchant.getAnvilMergeCost(level); + } + } + + if (!first.equals(result)) { + EnchantManager.updateItemLoreEnchants(result); + e.setResult(result); + + // NMS ContainerAnvil will set level cost to 0 right after calling the event + // So we have to change it with a 1 tick delay. + final int repairCost2 = repairCost; + this.plugin.runTask((c) -> inventory.setRepairCost(repairCost2), false); + } + } + + // --------------------------------------------------------------- + // Update enchantment lore after grindstone + // --------------------------------------------------------------- + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantUpdateGrindstoneClick(InventoryClickEvent e) { + Inventory inventory = e.getInventory(); + if (inventory.getType() != InventoryType.GRINDSTONE) return; + if (e.getRawSlot() == 2) return; + + this.updateGrindstone(inventory); + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantUpdateGrindstoneDrag(InventoryDragEvent e) { + Inventory inventory = e.getInventory(); + if (inventory.getType() != InventoryType.GRINDSTONE) return; + + this.updateGrindstone(inventory); + } + + private void updateGrindstone(@NotNull Inventory inventory) { + this.plugin.getServer().getScheduler().runTask(plugin, () -> { + ItemStack result = inventory.getItem(2); + if (result == null || result.getType().isAir()) return; + + Map curses = new HashMap<>(); + for (int slot = 0; slot < 2; slot++) { + ItemStack source = inventory.getItem(slot); + if (source == null || source.getType().isAir()) continue; + + curses.putAll(EnchantManager.getItemCustomEnchants(source)); + } + curses.entrySet().removeIf(entry -> !entry.getKey().isCursed()); + curses.forEach((excellentEnchant, level) -> { + EnchantManager.addEnchant(result, excellentEnchant, level, true); + }); + EnchantManager.updateItemLoreEnchants(result); + }); + } + + + // --------------------------------------------------------------- + // Handle Enchanting Table + // --------------------------------------------------------------- + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onEnchantPopulateEnchantingTable(final EnchantItemEvent e) { + ObtainSettings settings = Config.getObtainSettings(ObtainType.ENCHANTING); + if (settings == null || Rnd.get(true) > settings.getEnchantsCustomGenerationChance()) return; + + ItemStack target = e.getItem(); + boolean enchantAdded = false; + + int enchMax = settings.getEnchantsTotalMax(); + int enchRoll = Rnd.get(settings.getEnchantsCustomMin(), settings.getEnchantsCustomMax()); + + for (int count = 0; (count < enchRoll && e.getEnchantsToAdd().size() < enchMax); count++) { + EnchantTier tier = EnchantManager.getTierByChance(ObtainType.ENCHANTING); + if (tier == null) continue; + + ExcellentEnchant enchant = tier.getEnchant(ObtainType.ENCHANTING, target); + if (enchant == null) continue; + if (e.getEnchantsToAdd().keySet().stream().anyMatch(add -> add.conflictsWith(enchant) || enchant.conflictsWith(add))) + continue; + + int level = enchant.getLevelByEnchantCost(e.getExpLevelCost()); + if (level < 1) continue; + + e.getEnchantsToAdd().put(enchant, level); + enchantAdded = true; + } + + if (enchantAdded) { + plugin.getServer().getScheduler().runTask(plugin, () -> { + ItemStack result = e.getInventory().getItem(0); + if (result == null) return; + + // Fix enchantments for Enchant Books. + // Enchants are not added on book because they do not exists in NMS. + // Server gets enchants from NMS to apply it on Book NBT tags. + ItemMeta meta = result.getItemMeta(); + if (meta instanceof EnchantmentStorageMeta meta2) { + e.getEnchantsToAdd().forEach((en, lvl) -> { + if (!meta2.hasStoredEnchant(en)) { + meta2.addStoredEnchant(en, lvl, true); + } + }); + result.setItemMeta(meta2); + } + + EnchantManager.updateItemLoreEnchants(result); + e.getInventory().setItem(0, result); + }); + } + } + + // --------------------------------------------------------------- + // Adding Enchants to Villagers + // --------------------------------------------------------------- + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantPopulateVillagerAcquire(VillagerAcquireTradeEvent e) { + MerchantRecipe recipe = e.getRecipe(); + ItemStack result = recipe.getResult(); + + if (!EnchantManager.isEnchantable(result)) return; + if (!EnchantManager.populateEnchantments(result, ObtainType.VILLAGER)) return; + + int uses = recipe.getUses(); + int maxUses = recipe.getMaxUses(); + boolean expReward = recipe.hasExperienceReward(); + int villagerExperience = recipe.getVillagerExperience(); + float priceMultiplier = recipe.getPriceMultiplier(); + + MerchantRecipe recipe2 = new MerchantRecipe(result, uses, maxUses, expReward, villagerExperience, priceMultiplier); + recipe2.setIngredients(recipe.getIngredients()); + e.setRecipe(recipe2); + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantPopulateLoot(LootGenerateEvent e) { + if (Config.getObtainSettings(ObtainType.LOOT_GENERATION) == null) return; + + Entity entity = e.getEntity(); + InventoryHolder holder = e.getInventoryHolder(); + + if (entity instanceof Minecart || holder instanceof Chest) { + e.getLoot().forEach(item -> { + if (item != null && EnchantManager.isEnchantable(item)) { + EnchantManager.populateEnchantments(item, ObtainType.LOOT_GENERATION); + } + }); + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantPopulateFishing(PlayerFishEvent e) { + if (Config.getObtainSettings(ObtainType.FISHING) == null) return; + if (e.getState() != PlayerFishEvent.State.CAUGHT_FISH) return; + if (!(e.getCaught() instanceof Item item)) return; + + ItemStack itemStack = item.getItemStack(); + if (EnchantManager.isEnchantable(itemStack)) { + EnchantManager.populateEnchantments(itemStack, ObtainType.FISHING); + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantPopulatePiglinBarter(CreatureSpawnEvent e) { + if (Config.getObtainSettings(ObtainType.MOB_SPAWNING) == null) return; + + LivingEntity entity = e.getEntity(); + EntityEquipment equipment = entity.getEquipment(); + if (equipment == null) return; + + ItemStack[] armor = equipment.getArmorContents(); + for (ItemStack item : armor) { + if (item != null && EnchantManager.isEnchantable(item)) { + EnchantManager.populateEnchantments(item, ObtainType.MOB_SPAWNING); + } + } + + ItemStack itemMain = equipment.getItemInMainHand(); + if (EnchantManager.isEnchantable(itemMain)) { + EnchantManager.populateEnchantments(itemMain, ObtainType.MOB_SPAWNING); + } + + ItemStack itemOff = equipment.getItemInOffHand(); + if (EnchantManager.isEnchantable(itemOff)) { + EnchantManager.populateEnchantments(itemOff, ObtainType.MOB_SPAWNING); + } + + equipment.setArmorContents(armor); + equipment.setItemInMainHand(itemMain); + equipment.setItemInOffHand(itemOff); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java new file mode 100644 index 0000000..ead48ab --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java @@ -0,0 +1,195 @@ +package su.nightexpress.excellentenchants.manager.listeners; + +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.Event.Result; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.manager.AbstractListener; +import su.nexmedia.engine.utils.EntityUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.type.*; +import su.nightexpress.excellentenchants.manager.EnchantManager; + +public class EnchantHandlerListener extends AbstractListener { + + public EnchantHandlerListener(@NotNull EnchantManager enchantManager) { + super(enchantManager.plugin()); + } + + // --------------------------------------------------------------- + // Combat Attacking Enchants + // --------------------------------------------------------------- + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantCombatMelee(EntityDamageByEntityEvent e) { + if (e.getCause() == DamageCause.THORNS) return; + if (!(e.getEntity() instanceof LivingEntity victim)) return; + if (!(e.getDamager() instanceof LivingEntity damager)) return; + + EntityEquipment equipment = damager.getEquipment(); + if (equipment == null) return; + + ItemStack weapon = equipment.getItemInMainHand(); + if (weapon.getType().isAir() || weapon.getType() == Material.ENCHANTED_BOOK) return; + + EnchantManager.getItemCustomEnchants(weapon, CombatEnchant.class).forEach((combatEnchant, level) -> { + if (combatEnchant instanceof BowEnchant) return; + combatEnchant.use(e, damager, victim, weapon, level); + }); + } + + // --------------------------------------------------------------- + // Armor Defensive Enchants + // --------------------------------------------------------------- + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantCombatArmor(EntityDamageByEntityEvent e) { + // Prevent armor enchants to have effect if damage is from Thorns. + if (e.getCause() == DamageCause.THORNS) return; + + Entity eVictim = e.getEntity(); + if (!(eVictim instanceof LivingEntity victim)) return; + + Entity eDamager = e.getDamager(); + if (eDamager instanceof Projectile projectile) { + if (projectile.getShooter() instanceof Entity) { + eDamager = (Entity) projectile.getShooter(); + } + } + if (!(eDamager instanceof LivingEntity damager) || eDamager.equals(eVictim)) return; + + EntityEquipment equipDamager = damager.getEquipment(); + if (equipDamager == null) return; + + ItemStack weaponDamager = equipDamager.getItemInMainHand(); + + for (ItemStack armor : EntityUtil.getArmor(victim)) { + if (armor == null || armor.getType().isAir()) continue; + + EnchantManager.getItemCustomEnchants(armor, CombatEnchant.class).forEach((combatEnchant, level) -> { + combatEnchant.use(e, damager, victim, weaponDamager, level); + }); + } + } + + // --------------------------------------------------------------- + // Bow Shooting Enchants + // --------------------------------------------------------------- + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantBowShoot(EntityShootBowEvent e) { + LivingEntity shooter = e.getEntity(); + if (shooter.getEquipment() == null) return; + + ItemStack bow = e.getBow(); + if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; + + EnchantManager.getItemCustomEnchants(bow, BowEnchant.class).forEach((bowEnchant, level) -> { + bowEnchant.use(e, shooter, bow, level); + }); + + if (e.getProjectile() instanceof Projectile projectile) { + EnchantManager.setArrowWeapon(projectile, bow); + } + } + + // --------------------------------------------------------------- + // Bow Damage Enchants + // --------------------------------------------------------------- + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantBowDamage(EntityDamageByEntityEvent e) { + if (!(e.getEntity() instanceof LivingEntity victim)) return; + if (!(e.getDamager() instanceof Projectile projectile)) return; + if (!(projectile.getShooter() instanceof LivingEntity damager)) return; + + ItemStack bow = EnchantManager.getArrowWeapon(projectile); + if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; + + EnchantManager.getItemCustomEnchants(bow, BowEnchant.class).forEach((bowEnchant, level) -> { + bowEnchant.use(e, damager, victim, bow, level); + }); + } + + // --------------------------------------------------------------- + // Bow Hit Land Enchants + // --------------------------------------------------------------- + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantBowHit(ProjectileHitEvent e) { + Projectile projectile = e.getEntity(); + + ItemStack bow = EnchantManager.getArrowWeapon(projectile); + if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; + + EnchantManager.getItemCustomEnchants(bow, BowEnchant.class).forEach((bowEnchant, level) -> { + bowEnchant.use(e, projectile, bow, level); + }); + } + + // --------------------------------------------------------------- + // Interaction Related Enchants + // --------------------------------------------------------------- + @EventHandler(priority = EventPriority.HIGHEST) + public void onEnchantInteract(PlayerInteractEvent e) { + if (e.useInteractedBlock() == Result.DENY) return; + if (e.useItemInHand() == Result.DENY) return; + + ItemStack item = e.getItem(); + if (item == null || item.getType().isAir() || item.getType() == Material.ENCHANTED_BOOK) return; + + Player player = e.getPlayer(); + EnchantManager.getItemCustomEnchants(item, InteractEnchant.class).forEach((interEnchant, level) -> { + interEnchant.use(e, player, item, level); + }); + } + + // --------------------------------------------------------------- + // Death Related Enchants + // --------------------------------------------------------------- + @EventHandler(priority = EventPriority.HIGHEST) + public void onEnchantDeath(EntityDeathEvent e) { + LivingEntity dead = e.getEntity(); + for (ItemStack armor : EntityUtil.getArmor(dead)) { + if (armor == null || armor.getType().isAir()) continue; + + EnchantManager.getItemCustomEnchants(armor, DeathEnchant.class).forEach((deathEnchant, level) -> { + deathEnchant.use(e, dead, level); + }); + } + + Player killer = dead.getKiller(); + if (killer == null) return; + + ItemStack weapon = killer.getInventory().getItemInMainHand(); + if (weapon.getType().isAir() || weapon.getType() == Material.ENCHANTED_BOOK) return; + + EnchantManager.getItemCustomEnchants(weapon, DeathEnchant.class).forEach((deathEnchant, level) -> { + deathEnchant.use(e, dead, level); + }); + } + + // Handle BlockBreak enchantments. + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantBlockBreak(BlockBreakEvent e) { + Player player = e.getPlayer(); + if (player.getGameMode() == GameMode.CREATIVE) return; + + ItemStack tool = player.getInventory().getItemInMainHand(); + if (tool.getType().isAir() || tool.getType() == Material.ENCHANTED_BOOK) return; + + EnchantManager.getItemCustomEnchants(tool, BlockBreakEnchant.class).forEach((blockEnchant, level) -> { + blockEnchant.use(e, player, tool, level); + }); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java new file mode 100644 index 0000000..79aae1f --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java @@ -0,0 +1,123 @@ +package su.nightexpress.excellentenchants.manager.object; + +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.api.menu.*; +import su.nexmedia.engine.utils.CollectionsUtil; +import su.nexmedia.engine.utils.ItemUtil; +import su.nexmedia.engine.utils.PDCUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.manager.EnchantRegister; + +import java.util.*; + +public class EnchantListGUI extends AbstractMenu { + + private final ItemStack enchantIcon; + private final int[] enchantSlots; + + private final NamespacedKey keyLevel; + private final Map> iconCache; + + public EnchantListGUI(@NotNull ExcellentEnchants plugin) { + super(plugin, JYML.loadOrExtract(plugin, "gui.enchants.yml"), ""); + this.keyLevel = new NamespacedKey(plugin, "list_display_level"); + this.iconCache = new HashMap<>(); + + this.enchantIcon = cfg.getItem("Enchantments.Icon"); + this.enchantSlots = cfg.getIntArray("Enchantments.Slots"); + + IMenuClick click = (p, type, e) -> { + if (type instanceof MenuItemType type2) { + switch (type2) { + case PAGE_NEXT -> this.open(p, this.getPage(p) + 1); + case PAGE_PREVIOUS -> this.open(p, this.getPage(p) - 1); + case CLOSE -> p.closeInventory(); + } + } + }; + + for (String sId : cfg.getSection("Content")) { + IMenuItem menuItem = cfg.getMenuItem("Content." + sId); + + if (menuItem.getType() != null) { + menuItem.setClick(click); + } + this.addItem(menuItem); + } + } + + private ItemStack getEnchantIcon(@NotNull ExcellentEnchant enchant, int level) { + return this.iconCache.computeIfAbsent(enchant.getId(), k -> new HashMap<>()).computeIfAbsent(level, k -> this.buildEnchantIcon(enchant, level)); + } + + @NotNull + private ItemStack buildEnchantIcon(@NotNull ExcellentEnchant enchant, int level) { + ItemStack icon = new ItemStack(this.enchantIcon); + + // Override the conflicts placeholder display to make it in a list. + List conflicts = enchant.getConflicts().isEmpty() + ? plugin.lang().Other_None.asList() + : enchant.getConflicts().stream().filter(Objects::nonNull) + .map(en -> plugin.lang().getEnchantment(en)).toList(); + + ItemUtil.replaceLore(icon, ExcellentEnchant.PLACEHOLDER_CONFLICTS, conflicts); + ItemUtil.replace(icon, enchant.formatString(level)); + return icon; + } + + @Override + public void onPrepare(@NotNull Player player, @NotNull Inventory inventory) { + int page = this.getPage(player); + int length = this.enchantSlots.length; + List list = new ArrayList<>(EnchantRegister.ENCHANT_LIST.stream(). + sorted(Comparator.comparing(ExcellentEnchant::getName)).toList()); + List> split = CollectionsUtil.split(list, length); + + int pages = split.size(); + if (pages < 1 || pages < page) list = Collections.emptyList(); + else list = split.get(page - 1); + + int count = 0; + for (ExcellentEnchant enchant : list) { + ItemStack icon = this.getEnchantIcon(enchant, 1); + PDCUtil.setData(icon, this.keyLevel, 1); + + IMenuClick click = (p, type, e) -> { + if (!e.isLeftClick()) return; + + ItemStack itemClick = e.getCurrentItem(); + if (itemClick == null) return; + + int levelHas = PDCUtil.getIntData(itemClick, this.keyLevel); + if (levelHas == 0) return; + + if (++levelHas > enchant.getMaxLevel()) levelHas = enchant.getStartLevel(); + itemClick = this.getEnchantIcon(enchant, levelHas); + PDCUtil.setData(itemClick, this.keyLevel, levelHas); + + e.setCurrentItem(itemClick); + }; + + IMenuItem menuItem = new MenuItem(icon, this.enchantSlots[count++]); + menuItem.setClick(click); + this.addItem(player, menuItem); + } + this.setPage(player, page, pages); + } + + @Override + public void onReady(@NotNull Player player, @NotNull Inventory inventory) { + + } + + @Override + public boolean cancelClick(@NotNull SlotType slotType, int slot) { + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantScaler.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantScaler.java new file mode 100644 index 0000000..a0dfb67 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantScaler.java @@ -0,0 +1,12 @@ +package su.nightexpress.excellentenchants.manager.object; + +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; + +public class EnchantScaler extends Scaler { + + public EnchantScaler(@NotNull ExcellentEnchant enchant, @NotNull String path) { + super(enchant.getConfig(), path, ExcellentEnchant.PLACEHOLDER_LEVEL, enchant.getStartLevel(), enchant.getMaxLevel()); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java new file mode 100644 index 0000000..ddaa01e --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java @@ -0,0 +1,94 @@ +package su.nightexpress.excellentenchants.manager.object; + +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.utils.StringUtil; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.manager.type.ObtainType; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +public class EnchantTier { + + private final String id; + private final int priority; + private final String name; + private final String color; + private final Map chance; + + private final Set enchants; + + public EnchantTier(@NotNull String id, int priority, @NotNull String name, @NotNull String color, @NotNull Map chance) { + this.id = id.toLowerCase(); + this.priority = priority; + this.name = StringUtil.color(name); + this.color = StringUtil.color(color); + this.chance = chance; + this.enchants = new HashSet<>(); + } + + @NotNull + public String getId() { + return this.id; + } + + public int getPriority() { + return priority; + } + + @NotNull + public String getName() { + return this.name; + } + + @NotNull + public String getColor() { + return this.color; + } + + @NotNull + public Map getChance() { + return this.chance; + } + + 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(en -> en.getObtainChance(obtainType) > 0) + .filter(en -> item == null || en.canEnchantItem(item)).collect(Collectors.toSet()); + set.removeIf(en -> obtainType == ObtainType.ENCHANTING && en.isTreasure()); + return set; + } + + @Nullable + public ExcellentEnchant getEnchant(@NotNull ObtainType obtainType) { + return getEnchant(obtainType, null); + } + + @Nullable + public ExcellentEnchant getEnchant(@NotNull ObtainType obtainType, @Nullable ItemStack item) { + Map map = this.getEnchants(obtainType).stream() + .filter(en -> item == null || en.canEnchantItem(item)) + .collect(Collectors.toMap(k -> k, v -> v.getObtainChance(obtainType))); + return map.isEmpty() ? null : Rnd.get(map); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/AbstractEnchantPassiveTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/AbstractEnchantPassiveTask.java new file mode 100644 index 0000000..9cf72ed --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/AbstractEnchantPassiveTask.java @@ -0,0 +1,56 @@ +package su.nightexpress.excellentenchants.manager.tasks; + +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.task.AbstractTask; +import su.nexmedia.engine.utils.EntityUtil; +import su.nexmedia.engine.utils.ItemUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.config.Config; + +import java.util.*; + +public abstract class AbstractEnchantPassiveTask extends AbstractTask { + + public AbstractEnchantPassiveTask(@NotNull ExcellentEnchants plugin, long interval, boolean async) { + super(plugin, interval, async); + } + + protected abstract void apply(@NotNull LivingEntity entity, @NotNull ItemStack armor, @NotNull ItemMeta meta); + + @Override + public void action() { + for (LivingEntity entity : this.getEntities()) { + + List list = new ArrayList<>(Arrays.asList(EntityUtil.getArmor(entity))); + EntityEquipment equipment = entity.getEquipment(); + if (equipment != null && !ItemUtil.isArmor(equipment.getItemInMainHand())) { + list.add(equipment.getItemInMainHand()); + } + list.removeIf(armor -> armor == null || armor.getType().isAir() || armor.getType() == Material.ENCHANTED_BOOK); + + for (ItemStack armor : list) { + ItemMeta meta = armor.getItemMeta(); + if (meta == null) continue; + + this.apply(entity, armor, meta); + } + } + } + + @NotNull + protected Collection<@NotNull ? extends LivingEntity> getEntities() { + Set list = new HashSet<>(plugin.getServer().getOnlinePlayers()); + + if (Config.ENCHANTMENTS_ENTITY_PASSIVE_FOR_MOBS) { + plugin.getServer().getWorlds().forEach(world -> { + list.addAll(world.getEntitiesByClass(LivingEntity.class)); + }); + } + return list; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/ArrowTrailsTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/ArrowTrailsTask.java new file mode 100644 index 0000000..90a60e4 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/ArrowTrailsTask.java @@ -0,0 +1,37 @@ +package su.nightexpress.excellentenchants.manager.tasks; + +import org.bukkit.entity.Projectile; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.task.AbstractTask; +import su.nexmedia.engine.utils.EffectUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.config.Config; + +import java.util.*; + +public class ArrowTrailsTask extends AbstractTask { + + private static final Map>> TRAILS_MAP = Collections.synchronizedMap(new HashMap<>()); + + public ArrowTrailsTask(@NotNull ExcellentEnchants plugin) { + super(plugin, Config.TASKS_ARROW_TRAIL_TICKS_INTERVAL, true); + TRAILS_MAP.clear(); + } + + @Override + public void action() { + TRAILS_MAP.keySet().removeIf(projectile -> !projectile.isValid() || projectile.isDead()); + + TRAILS_MAP.forEach((arrow, effects) -> { + effects.forEach(entry -> { + EffectUtil.playEffect(arrow.getLocation(), entry.getKey(), entry.getValue(), 0f, 0f, 0f, 0f, 10); + }); + }); + } + + public static void add(@NotNull Projectile projectile, @NotNull String particleName, @NotNull String particleData) { + synchronized (TRAILS_MAP) { + TRAILS_MAP.computeIfAbsent(projectile, list -> new HashSet<>()).add(new AbstractMap.SimpleEntry<>(particleName, particleData)); + } + } +} \ No newline at end of file diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java new file mode 100644 index 0000000..c9d35ce --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java @@ -0,0 +1,28 @@ +package su.nightexpress.excellentenchants.manager.tasks; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; +import su.nightexpress.excellentenchants.config.Config; + +public class EnchantEffectPassiveTask extends AbstractEnchantPassiveTask { + + public EnchantEffectPassiveTask(@NotNull ExcellentEnchants plugin) { + super(plugin, Config.TASKS_PASSIVE_ENCHANTS_TICKS_INTERVAL, true); + } + + @Override + protected void apply(@NotNull LivingEntity entity, @NotNull ItemStack armor, @NotNull ItemMeta meta) { + meta.getEnchants().forEach((enchantment, level) -> { + if (level < 1) return; + if (!(enchantment instanceof PassiveEnchant passiveEnchant)) return; + if (!(enchantment instanceof IEnchantPotionTemplate)) return; + + passiveEnchant.use(entity, level); + }); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/type/FitItemType.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/type/FitItemType.java new file mode 100644 index 0000000..7a47feb --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/type/FitItemType.java @@ -0,0 +1,57 @@ +package su.nightexpress.excellentenchants.manager.type; + +import org.bukkit.Material; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.utils.ItemUtil; +import su.nightexpress.excellentenchants.config.Config; + +public enum FitItemType { + + HELMET, CHESTPLATE, LEGGINGS, BOOTS, ELYTRA, + WEAPON, TOOL, ARMOR, + SWORD, TRIDENT, AXE, BOW, CROSSBOW, + HOE, PICKAXE, SHOVEL, FISHING_ROD; + + @Nullable + public static FitItemType getByEnchantmentTarget(@NotNull EnchantmentTarget target) { + return switch (target) { + case ARMOR -> ARMOR; + case ARMOR_FEET -> BOOTS; + case ARMOR_LEGS -> LEGGINGS; + case ARMOR_TORSO -> CHESTPLATE; + case ARMOR_HEAD -> HELMET; + case WEAPON -> WEAPON; + case TOOL -> TOOL; + case BOW -> BOW; + case FISHING_ROD -> FISHING_ROD; + case TRIDENT -> TRIDENT; + case CROSSBOW -> CROSSBOW; + default -> null; + }; + } + + public boolean isIncluded(@NotNull ItemStack item) { + return switch (this) { + case HELMET -> ItemUtil.isHelmet(item); + case CHESTPLATE -> ItemUtil.isChestplate(item) || (Config.ENCHANTMENTS_ITEM_ELYTRA_AS_CHESTPLATE && ELYTRA.isIncluded(item)); + case LEGGINGS -> ItemUtil.isLeggings(item); + case BOOTS -> ItemUtil.isBoots(item); + case ELYTRA -> item.getType() == Material.ELYTRA; + case WEAPON -> ItemUtil.isWeapon(item); + case TOOL -> ItemUtil.isTool(item); + case ARMOR -> ItemUtil.isArmor(item); + case SWORD -> ItemUtil.isSword(item) || (Config.ENCHANTMENTS_ITEM_AXES_AS_SWORDS && AXE.isIncluded(item)); + case TRIDENT -> ItemUtil.isTrident(item); + case AXE -> ItemUtil.isAxe(item); + case BOW -> item.getType() == Material.BOW || (Config.ENCHANTMENTS_ITEM_CROSSBOWS_AS_BOWS && CROSSBOW.isIncluded(item)); + case CROSSBOW -> item.getType() == Material.CROSSBOW; + case HOE -> ItemUtil.isHoe(item); + case PICKAXE -> ItemUtil.isPickaxe(item); + case SHOVEL -> ItemUtil.isShovel(item); + case FISHING_ROD -> item.getType() == Material.FISHING_ROD; + }; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/type/ObtainType.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/type/ObtainType.java new file mode 100644 index 0000000..7bd0f1c --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/type/ObtainType.java @@ -0,0 +1,23 @@ +package su.nightexpress.excellentenchants.manager.type; + +import org.jetbrains.annotations.NotNull; + +public enum ObtainType { + + ENCHANTING("Enchanting_Table"), + VILLAGER("Villagers"), + LOOT_GENERATION("Loot_Generation"), + FISHING("Fishing"), + MOB_SPAWNING("Mob_Spawning"); + + private final String pathName; + + ObtainType(@NotNull String pathName) { + this.pathName = pathName; + } + + @NotNull + public String getPathName() { + return pathName; + } +} diff --git a/Core/src/main/resources/config.yml b/Core/src/main/resources/config.yml new file mode 100644 index 0000000..d318b31 --- /dev/null +++ b/Core/src/main/resources/config.yml @@ -0,0 +1,165 @@ +# Plugin engine settings. +Plugin: + # Name(s) for the main plugin command. + Command_Aliases: excellentenchants,eenchants + # Plugin language config. + # + # In 'lang' folder there are configs for different languages with a format like 'messages_code.yml', + # where 'code' is the language code which you specify here. + # + # To create a new language config, simply copy the default one and rename it to your language code. + Language: en + # Plugin prefix name. + # To change a prefix format, edit language config in '/NexEngine/lang'. + Prefix: ExcellentEnchants + +# General plugin settings. +General: + # Settings for the plugin tasks. + Tasks: + Arrow_Trails: + # Defines the ticks interval (20 ticks = 1 second) for the arrow particle effect spawning. + Ticks_Interval: 1 + Passive_Enchants: + # Defines the ticks interval (20 ticks = 1 second) for the passive enchantment effects to trigger. + Ticks_Interval: 100 + # Enchantment global settings. + Enchantments: + # List of disabled custom enchantments. + # Use enchantment file names from the 'enchants' folder without the file extension. + # For example, to disable 'Explosive Arrows' enchantment you have to add 'explosive_arrows' to this list. + Disabled: + - enchant_name + - other_enchant + # Here you can disable certain enchantments in certain worlds. + Disabled_In_Worlds: + # This is your world name with a list of disabled enchantments. + # Enchantment names are the same as in the option above. + # To disable all enchantments, use '*'. + my_world: + - '*' + other_world: + - 'enchant_name' + - 'another_enchant' + # Item settings. + Item: + # How many of custom enchantments the item can contain at the same time? + Max_Custom_Enchants: 3 + # Set this to 'true' to make Sword enchantments apply on Axes. + Axes_As_Swords: true + # Set this to 'true' to make Bow enchantments apply on Crossbows. + Crossbows_As_Bows: true + # Set this to 'true' to make Chestplate enchantments apply on Elytras. + Elytra_As_Chestplate: true + # Non-player entity settings. + Entity: + # When enabled, enchantments with a passive effects (potion effects, regeneration, etc.) + # will be applied to mobs as well (if they are wearing items with such enchantments). + # Enabling this feature may cause performance issues. + Passive_Enchants_Applied_To_Mobs: false + # Enchantment description settings. + Description: + # When enabled, each custom enchantment will add a description in item lore. + Enabled: true + # Description format for the item lore. + # Placeholders: + # - %description% - Enchantment description. + Format: '&8▸ %description%' + # Settings to obtain enchants via Enchanting Table. + Enchanting_Table: + # Enable/Disable this way to obtain custom enchantments. + Enabled: true + Enchantments: + # Max. amount of all (including vanilla) enchantments on the item, when no more enchantments will be added. + Total_Maximum: 4 + # Chance that a custom enchantment will be added. + Custom_Generation_Chance: 90.0 + # Min. amount of custom enchantments to be added. + Custom_Minimum: 0 + # Max. amount of custom enchantments to be added. + Custom_Maximum: 2 + # Settings to obtain enchantments via Villager Trades. + Villagers: + Enabled: true + Enchantments: + Total_Maximum: 4 + Custom_Generation_Chance: 70.0 + Custom_Minimum: 0 + Custom_Maximum: 2 + # Settings to obtain enchantments via Loot Chests in dungeons and other world's structures. + Loot_Generation: + Enabled: true + Enchantments: + Total_Maximum: 4 + Custom_Generation_Chance: 80.0 + Custom_Minimum: 0 + Custom_Maximum: 2 + # Settings to obtain enchantments via Fishing. + Fishing: + Enabled: true + Enchantments: + Total_Maximum: 4 + Custom_Generation_Chance: 70.0 + Custom_Minimum: 0 + Custom_Maximum: 2 + # Settings to generate enchantments on mob equipment on spawn. + Mob_Spawning: + Enabled: true + Enchantments: + Total_Maximum: 4 + Custom_Generation_Chance: 70.0 + Custom_Minimum: 0 + Custom_Maximum: 2 + +# Enchantment tiers. +# You can create as many tiers as you want. +Tiers: + # Tier identifier. Must be unique. + common: + # Tier display name. + Name: '&fCommon' + # Tier color. + Color: '&f' + # Tier obtain chances. + Obtain_Chance: + ENCHANTING: 80.0 + VILLAGER: 80.0 + LOOT_GENERATION: 80.0 + FISHING: 80.0 + MOB_SPAWNING: 80.0 + rare: + Name: '&aRare' + Color: '&a' + Obtain_Chance: + ENCHANTING: 50.0 + VILLAGER: 50.0 + LOOT_GENERATION: 50.0 + FISHING: 50.0 + MOB_SPAWNING: 50.0 + exotic: + Name: '&eExotic' + Color: '&e' + Obtain_Chance: + ENCHANTING: 25.0 + VILLAGER: 25.0 + LOOT_GENERATION: 25.0 + FISHING: 25.0 + MOB_SPAWNING: 25.0 + legendary: + Name: '&6Legendary' + Color: '&6' + Obtain_Chance: + ENCHANTING: 10.0 + VILLAGER: 10.0 + LOOT_GENERATION: 10.0 + FISHING: 10.0 + MOB_SPAWNING: 10.0 + cursed: + Name: '&cCursed' + Color: '&c' + Obtain_Chance: + ENCHANTING: 7.0 + VILLAGER: 5.0 + LOOT_GENERATION: 7.0 + FISHING: 12.0 + MOB_SPAWNING: 0.0 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/aquaman.yml b/Core/src/main/resources/enchants/aquaman.yml new file mode 100644 index 0000000..40af9a7 --- /dev/null +++ b/Core/src/main/resources/enchants/aquaman.yml @@ -0,0 +1,31 @@ +Name: 'Aquaman' +Tier: 'exotic' +Description: + - 'Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 %enchantment_cost_item%.' +Is_Treasure: false +Level: + Min: 1 + Max: 1 +Anvil: + Merge_Cost: '%enchantment_level%' +Enchanting_Table: + Level_By_Exp_Cost: '%enchantment_level% * 15.0' + Chance: 20.0 +Villagers: + Chance: 20.0 +Loot_Generation: + Chance: 25.0 +Fishing: + Chance: 30.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: true + Item: + Material: PRISMARINE_SHARD + Amount: 1 + Potion_Effect: + Level: '1' + Duration: '25.0' \ 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 new file mode 100644 index 0000000..a8499d5 --- /dev/null +++ b/Core/src/main/resources/enchants/bane_of_netherspawn.yml @@ -0,0 +1,34 @@ +Name: Bane of Netherspawn +Tier: common +Description: + - '%enchantment_trigger_chance%% chance to inflict %enchantment_damage% more damage to Nether mobs.' +Is_Treasure: false +Level: + Min: 1 + Max: 5 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 25.0 +Enchanting_Table: + Level_By_Exp_Cost: '6 * %enchantment_level%' + Chance: 80.0 +Villagers: + Chance: 80.0 +Loot_Generation: + Chance: 80.0 +Mob_Spawning: + Chance: 50.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Particle: + Name: 'SMOKE_NORMAL' + Data: '' + Damage: + As_Modifier: false + Formula: '0.5 * %enchantment_level%' diff --git a/Core/src/main/resources/enchants/blast_mining.yml b/Core/src/main/resources/enchants/blast_mining.yml new file mode 100644 index 0000000..65fa1c1 --- /dev/null +++ b/Core/src/main/resources/enchants/blast_mining.yml @@ -0,0 +1,31 @@ +Is_Treasure: false +Name: Blast Mining +Tier: legendary +Description: + - '%enchantment_trigger_chance%% chance to mine blocks by x%enchantment_explosion_power% power explosion.' +Level: + Min: 1 + Max: 5 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 5.0 +Enchanting_Table: + Level_By_Exp_Cost: '6.0 * %enchantment_level%' + Chance: 10.0 +Villagers: + Chance: 10.0 +Loot_Generation: + Chance: 20.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '20.0 * %enchantment_level%' + Min_Block_Strength: '1.5 - %enchantment_level% / 10' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Explosion: + Power: '3.0 + (%enchantment_level% - 1.0 * 0.25)' diff --git a/Core/src/main/resources/enchants/blindness.yml b/Core/src/main/resources/enchants/blindness.yml new file mode 100644 index 0000000..ece0797 --- /dev/null +++ b/Core/src/main/resources/enchants/blindness.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Blindness +Tier: common +Description: + - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 60.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 60.0 +Villagers: + Chance: 60.0 +Loot_Generation: + Chance: 60.0 +Mob_Spawning: + Chance: 30.0 +Settings: + Trigger_Chance: '15.0 + %enchantment_level% * 3' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '3.5 + %enchantment_level%' + Level: '%enchantment_level%' + Particle: + Name: SMOKE_NORMAL + Data: '' diff --git a/Core/src/main/resources/enchants/bomber.yml b/Core/src/main/resources/enchants/bomber.yml new file mode 100644 index 0000000..16bc189 --- /dev/null +++ b/Core/src/main/resources/enchants/bomber.yml @@ -0,0 +1,29 @@ +Is_Treasure: false +Name: Bomber +Tier: exotic +Description: + - '%enchantment_trigger_chance%% chance to launch TNT that explodes in %enchantment_fuse_ticks%s.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 20.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 20.0 +Villagers: + Chance: 20.0 +Loot_Generation: + Chance: 20.0 +Mob_Spawning: + Chance: 5.0 +Settings: + Trigger_Chance: '4.0 * %enchantment_level%' + Cost: + Enabled: false + Item: + Material: TNT + Amount: 1 + Fuse_Ticks: '100 - %enchantment_level% * 10' \ 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 new file mode 100644 index 0000000..dc4491f --- /dev/null +++ b/Core/src/main/resources/enchants/bunny_hop.yml @@ -0,0 +1,30 @@ +Is_Treasure: false +Name: Bunny Hop +Tier: common +Description: + - 'Grants permanent %enchantment_potion_type% %enchantment_potion_level%.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 50.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 50.0 +Villagers: + Chance: 50.0 +Loot_Generation: + Chance: 50.0 +Mob_Spawning: + Chance: 25.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: RABBIT_FOOT + Potion_Effect: + Duration: '25.0' + Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/cold_steel.yml b/Core/src/main/resources/enchants/cold_steel.yml new file mode 100644 index 0000000..e6fff9d --- /dev/null +++ b/Core/src/main/resources/enchants/cold_steel.yml @@ -0,0 +1,31 @@ +Is_Treasure: false +Name: Cold Steel +Tier: rare +Description: + - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. to attacker.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 50.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 50.0 +Villagers: + Chance: 50.0 +Loot_Generation: + Chance: 50.0 +Mob_Spawning: + Chance: 30.0 +Settings: + Trigger_Chance: '60.0 + %enchantment_level% * 5' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '4.0 + %enchantment_level%' + Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/confusion.yml b/Core/src/main/resources/enchants/confusion.yml new file mode 100644 index 0000000..d3d0898 --- /dev/null +++ b/Core/src/main/resources/enchants/confusion.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Confusion +Tier: common +Description: + - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 50.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 50.0 +Villagers: + Chance: 50.0 +Loot_Generation: + Chance: 50.0 +Mob_Spawning: + Chance: 30.0 +Settings: + Trigger_Chance: '15.0 * %enchantment_level%' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '5.0 + %enchantment_level% * 1.5' + Level: '%enchantment_level%' + Particle: + Name: 'ITEM_CRACK' + Data: 'ROTTEN_FLESH' diff --git a/Core/src/main/resources/enchants/cure.yml b/Core/src/main/resources/enchants/cure.yml new file mode 100644 index 0000000..36287c7 --- /dev/null +++ b/Core/src/main/resources/enchants/cure.yml @@ -0,0 +1,32 @@ +Is_Treasure: false +Name: Cure +Tier: exotic +Description: + - '%enchantment_trigger_chance%% chance to cure Zombified Piglins and Zombie Villagers.' +Level: + Min: 1 + Max: 5 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 60.0 +Enchanting_Table: + Level_By_Exp_Cost: '5 * %enchantment_level%' + Chance: 60.0 +Villagers: + Chance: 75.0 +Loot_Generation: + Chance: 50.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '20.0 + %enchantment_level% * 8' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Particle: + Name: 'CLOUD' + Data: '' + Sound: '' diff --git a/Core/src/main/resources/enchants/curse_of_breaking.yml b/Core/src/main/resources/enchants/curse_of_breaking.yml new file mode 100644 index 0000000..c50b046 --- /dev/null +++ b/Core/src/main/resources/enchants/curse_of_breaking.yml @@ -0,0 +1,29 @@ +Is_Treasure: true +Name: Curse of Breaking +Tier: cursed +Description: + - '%enchantment_trigger_chance%% chance the item will consume extra %enchantment_durability_amount% durability points.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 20.0 +Enchanting_Table: + Level_By_Exp_Cost: '15.0 * %enchantment_level%' + Chance: 0.0 +Villagers: + Chance: 20.0 +Loot_Generation: + Chance: 20.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '10.0 * %enchantment_level%' + Durability_Amount: '%enchantment_level%' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 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 new file mode 100644 index 0000000..b258490 --- /dev/null +++ b/Core/src/main/resources/enchants/curse_of_misfortune.yml @@ -0,0 +1,29 @@ +Is_Treasure: true +Name: Curse of Misfortune +Tier: cursed +Description: + - '%enchantment_trigger_chance%% chance to have no drops from blocks or mobs.' +Level: + Min: 1 + Max: 1 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 20.0 +Enchanting_Table: + Level_By_Exp_Cost: '15.0 * %enchantment_level%' + Chance: 0.0 +Villagers: + Chance: 20.0 +Loot_Generation: + Chance: 20.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '20.0 * %enchantment_level%' + Drop_Exp: false + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/cutter.yml b/Core/src/main/resources/enchants/cutter.yml new file mode 100644 index 0000000..04c5430 --- /dev/null +++ b/Core/src/main/resources/enchants/cutter.yml @@ -0,0 +1,31 @@ +Is_Treasure: false +Name: Cutter +Tier: exotic +Description: + - '%enchantment_trigger_chance%% chance to throw away enemy''s armor and damage it for %enchantment_durability_damage%%.' +Level: + Min: 1 + Max: 5 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 0.0 +Enchanting_Table: + Level_By_Exp_Cost: '6 * %enchantment_level%' + Chance: 20.0 +Villagers: + Chance: 20.0 +Loot_Generation: + Chance: 20.0 +Mob_Spawning: + Chance: 5.0 +Settings: + Trigger_Chance: '1.0 + %enchantment_level% * 0.6' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Item: + Durability_Reduction: '%enchantment_level% / 100.0' + Sound: ENTITY_ITEM_BREAK diff --git a/Core/src/main/resources/enchants/decapitator.yml b/Core/src/main/resources/enchants/decapitator.yml new file mode 100644 index 0000000..814e8f2 --- /dev/null +++ b/Core/src/main/resources/enchants/decapitator.yml @@ -0,0 +1,104 @@ +Is_Treasure: false +Name: Decapitator +Tier: exotic +Description: + - '%enchantment_trigger_chance%% chance to obtain player''s or mob''s head.' +Level: + Min: 1 + Max: 4 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 30.0 +Enchanting_Table: + Level_By_Exp_Cost: '7 * %enchantment_level%' + Chance: 30.0 +Villagers: + Chance: 30.0 +Loot_Generation: + Chance: 30.0 +Mob_Spawning: + Chance: 15.0 +Settings: + Trigger_Chance: '5.0 + %enchantment_level% * 1.75' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Particle: + Name: 'BLOCK_CRACK' + Data: 'REDSTONE_BLOCK' + Ignored_Entity_Types: + - BAT + - BEE + - ENDER_DRAGON + - WITHER_SKELETON + - WITHER + Head_Item: + Name: '&cHead of &e%entity%' + Textures: + AXOLOTL: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNThkYTFhMGEyYTEzZGQyMDliZmMyNTI5ZDljN2MyOWEyOWRkOWEyM2ZmNGI4MGIzOGI4OTk2MTc3MmU4MDM5ZSJ9fX0= + BAT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWU5OWRlZWY5MTlkYjY2YWMyYmQyOGQ2MzAyNzU2Y2NkNTdjN2Y4YjEyYjlkY2E4ZjQxYzNlMGEwNGFjMWNjIn19fQ== + BEE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTI3MjRhOWE0Y2RkNjhiYTQ5NDE1NTYwZTViZTQwYjRhMWM0N2NiNWJlMWQ2NmFlZGI1MmEzMGU2MmVmMmQ0NyJ9fX0= + BLAZE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc4ZWYyZTRjZjJjNDFhMmQxNGJmZGU5Y2FmZjEwMjE5ZjViMWJmNWIzNWE0OWViNTFjNjQ2Nzg4MmNiNWYwIn19fQ== + CAT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTRiNDVjYmFhMTlmZTNkNjhjODU2Y2QzODQ2YzAzYjVmNTlkZTgxYTQ4MGVlYzkyMWFiNGZhM2NkODEzMTcifX19 + CAVE_SPIDER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTYxN2Y3ZGQ1ZWQxNmYzYmQxODY0NDA1MTdjZDQ0MGExNzAwMTViMWNjNmZjYjJlOTkzYzA1ZGUzM2YifX19 + CHICKEN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTYzODQ2OWE1OTljZWVmNzIwNzUzNzYwMzI0OGE5YWIxMWZmNTkxZmQzNzhiZWE0NzM1YjM0NmE3ZmFlODkzIn19fQ== + COD: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg5MmQ3ZGQ2YWFkZjM1Zjg2ZGEyN2ZiNjNkYTRlZGRhMjExZGY5NmQyODI5ZjY5MTQ2MmE0ZmIxY2FiMCJ9fX0= + COW: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2RmYTBhYzM3YmFiYTJhYTI5MGU0ZmFlZTQxOWE2MTNjZDYxMTdmYTU2OGU3MDlkOTAzNzQ3NTNjMDMyZGNiMCJ9fX0= + DOLPHIN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGU5Njg4Yjk1MGQ4ODBiNTViN2FhMmNmY2Q3NmU1YTBmYTk0YWFjNmQxNmY3OGU4MzNmNzQ0M2VhMjlmZWQzIn19fQ== + DONKEY: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjNhOTc2YzA0N2Y0MTJlYmM1Y2IxOTcxMzFlYmVmMzBjMDA0YzBmYWY0OWQ4ZGQ0MTA1ZmNhMTIwN2VkYWZmMyJ9fX0= + DROWNED: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzNmN2NjZjYxZGJjM2Y5ZmU5YTYzMzNjZGUwYzBlMTQzOTllYjJlZWE3MWQzNGNmMjIzYjNhY2UyMjA1MSJ9fX0= + ELDER_GUARDIAN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWM3OTc0ODJhMTRiZmNiODc3MjU3Y2IyY2ZmMWI2ZTZhOGI4NDEzMzM2ZmZiNGMyOWE2MTM5Mjc4YjQzNmIifX19 + ENDERMAN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjMGIzNmQ1M2ZmZjY5YTQ5YzdkNmYzOTMyZjJiMGZlOTQ4ZTAzMjIyNmQ1ZTgwNDVlYzU4NDA4YTM2ZTk1MSJ9fX0= + ENDERMITE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWExYTA4MzFhYTAzYWZiNDIxMmFkY2JiMjRlNWRmYWE3ZjQ3NmExMTczZmNlMjU5ZWY3NWE4NTg1NSJ9fX0= + EVOKER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDk1NDEzNWRjODIyMTM5NzhkYjQ3ODc3OGFlMTIxMzU5MWI5M2QyMjhkMzZkZDU0ZjFlYTFkYTQ4ZTdjYmE2In19fQ== + FOX: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDg5NTRhNDJlNjllMDg4MWFlNmQyNGQ0MjgxNDU5YzE0NGEwZDVhOTY4YWVkMzVkNmQzZDczYTNjNjVkMjZhIn19fQ== + GHAST: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGU4YTM4ZTlhZmJkM2RhMTBkMTliNTc3YzU1YzdiZmQ2YjRmMmU0MDdlNDRkNDAxN2IyM2JlOTE2N2FiZmYwMiJ9fX0= + GOAT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDU3YTBkNTM4ZmEwOGE3YWZmZTMxMjkwMzQ2ODg2MTcyMGY5ZmEzNGU4NmQ0NGI4OWRjZWM1NjM5MjY1ZjAzIn19fQ== + GUARDIAN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTBiZjM0YTcxZTc3MTViNmJhNTJkNWRkMWJhZTVjYjg1Zjc3M2RjOWIwZDQ1N2I0YmZjNWY5ZGQzY2M3Yzk0In19fQ== + HOGLIN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWJiOWJjMGYwMWRiZDc2MmEwOGQ5ZTc3YzA4MDY5ZWQ3Yzk1MzY0YWEzMGNhMTA3MjIwODU2MWI3MzBlOGQ3NSJ9fX0= + HORSE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjY2YjJiMzJkMzE1MzljNzM4M2Q5MjNiYWU0ZmFhZjY1ZGE2NzE1Y2Q1MjZjMzVkMmU0ZTY4MjVkYTExZmIifX19 + HUSK: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDY3NGM2M2M4ZGI1ZjRjYTYyOGQ2OWEzYjFmOGEzNmUyOWQ4ZmQ3NzVlMWE2YmRiNmNhYmI0YmU0ZGIxMjEifX19 + ILLUSIONER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmYyODgyZGQwOTcyM2U0N2MwYWI5NjYzZWFiMDgzZDZhNTk2OTI3MzcwNjExMGM4MjkxMGU2MWJmOGE4ZjA3ZSJ9fX0= + IRON_GOLEM: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODkwOTFkNzllYTBmNTllZjdlZjk0ZDdiYmE2ZTVmMTdmMmY3ZDQ1NzJjNDRmOTBmNzZjNDgxOWE3MTQifX19 + LLAMA: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODNkOWI1OTE1OTEyZmZjMmI4NTc2MWQ2YWRjYjQyOGE4MTJmOWI4M2ZmNjM0ZTMzMTE2MmNlNDZjOTllOSJ9fX0= + MAGMA_CUBE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTFjOTdhMDZlZmRlMDRkMDAyODdiZjIwNDE2NDA0YWIyMTAzZTEwZjA4NjIzMDg3ZTFiMGMxMjY0YTFjMGYwYyJ9fX0= + MULE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDZkY2RhMjY1ZTU3ZTRmNTFiMTQ1YWFjYmY1YjU5YmRjNjA5OWZmZDNjY2UwYTY2MWIyYzAwNjVkODA5MzBkOCJ9fX0= + MUSHROOM_COW: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmI1Mjg0MWYyZmQ1ODllMGJjODRjYmFiZjllMWMyN2NiNzBjYWM5OGY4ZDZiM2RkMDY1ZTU1YTRkY2I3MGQ3NyJ9fX0= + OCELOT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTY1N2NkNWMyOTg5ZmY5NzU3MGZlYzRkZGNkYzY5MjZhNjhhMzM5MzI1MGMxYmUxZjBiMTE0YTFkYjEifX19 + PANDA: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDE4OGM5ODBhYWNmYTk0Y2YzMzA4ODUxMmIxYjk1MTdiYTgyNmIxNTRkNGNhZmMyNjJhZmY2OTc3YmU4YSJ9fX0= + PARROT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjBiZmE4NTBmNWRlNGIyOTgxY2NlNzhmNTJmYzJjYzdjZDdiNWM2MmNhZWZlZGRlYjljZjMxMWU4M2Q5MDk3In19fQ== + PHANTOM: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDExZDI1YmNkYWJhZmFkNWZkNmUwMTBjNWIxY2Y3YTAwYzljY2E0MGM1YTQ2NzQ3ZjcwNmRjOWNiM2EifX19 + PIG: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWEzNzFhMDZlYTc4NThmODlkMjdjYzEwNTVjMzE3YjIzZjEwNWM5MTI1YmM1MTZkMzg5MWFhNGM4MzVjMjk5In19fQ== + PIGLIN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2NlZDlkODAxYWE2ZjgzZjhlNDlmOTBkOWE4Yjg1YjdmOGZkYTU4M2Q4NWY3MmNmZmI2OTg2NzI1Nzg5ZjYzNiJ9fX0= + PIGLIN_BRUTE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2NlZDlkODAxYWE2ZjgzZjhlNDlmOTBkOWE4Yjg1YjdmOGZkYTU4M2Q4NWY3MmNmZmI2OTg2NzI1Nzg5ZjYzNiJ9fX0= + PILLAGER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGFlZTZiYjM3Y2JmYzkyYjBkODZkYjVhZGE0NzkwYzY0ZmY0NDY4ZDY4Yjg0OTQyZmRlMDQ0MDVlOGVmNTMzMyJ9fX0= + POLAR_BEAR: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzRmZTkyNjkyMmZiYjQwNmYzNDNiMzRhMTBiYjk4OTkyY2VlNDQxMDEzN2QzZjg4MDk5NDI3YjIyZGUzYWI5MCJ9fX0= + PUFFERFISH: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjkyMzUwYzlmMDk5M2VkNTRkYjJjNzExMzkzNjMyNTY4M2ZmYzIwMTA0YTliNjIyYWE0NTdkMzdlNzA4ZDkzMSJ9fX0= + RABBIT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzk3N2EzMjY2YmYzYjllYWYxN2U1YTAyZWE1ZmJiNDY4MDExNTk4NjNkZDI4OGI5M2U2YzEyYzljYiJ9fX0= + RAVAGER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2QyMGJmNTJlYzM5MGEwNzk5Mjk5MTg0ZmM2NzhiZjg0Y2Y3MzJiYjFiZDc4ZmQxYzRiNDQxODU4ZjAyMzVhOCJ9fX0= + SALMON: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjBlYTlhMjIzNjIwY2RiNTRiMzU3NDEzZDQzYmQ4OWM0MDA4YmNhNmEyMjdmM2I3ZGI5N2Y3NzMzZWFkNWZjZiJ9fX0= + SHEEP: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjMxZjljY2M2YjNlMzJlY2YxM2I4YTExYWMyOWNkMzNkMThjOTVmYzczZGI4YTY2YzVkNjU3Y2NiOGJlNzAifX19 + SILVERFISH: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGE5MWRhYjgzOTFhZjVmZGE1NGFjZDJjMGIxOGZiZDgxOWI4NjVlMWE4ZjFkNjIzODEzZmE3NjFlOTI0NTQwIn19fQ== + SLIME: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODk1YWVlYzZiODQyYWRhODY2OWY4NDZkNjViYzQ5NzYyNTk3ODI0YWI5NDRmMjJmNDViZjNiYmI5NDFhYmU2YyJ9fX0= + SNOWMAN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGU4ZDIwNmY2MWU2ZGU4YTc5ZDBjYjBiY2Q5OGFjZWQ0NjRjYmZlZmM5MjFiNDE2MGEyNTI4MjE2MzExMmEifX19 + SPIDER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2Q1NDE1NDFkYWFmZjUwODk2Y2QyNThiZGJkZDRjZjgwYzNiYTgxNjczNTcyNjA3OGJmZTM5MzkyN2U1N2YxIn19fQ== + SQUID: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDljMmM5Y2U2N2ViNTk3MWNjNTk1ODQ2M2U2YzlhYmFiOGU1OTlhZGMyOTVmNGQ0MjQ5OTM2YjAwOTU3NjlkZCJ9fX0= + STRAY: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmM1MDk3OTE2YmMwNTY1ZDMwNjAxYzBlZWJmZWIyODcyNzdhMzRlODY3YjRlYTQzYzYzODE5ZDUzZTg5ZWRlNyJ9fX0= + STRIDER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2I3ZmZkZGE2NTZjNjhkODg4NTFhOGUwNWI0OGNkMjQ5Mzc3M2ZmYzRhYjdkNjRlOTMwMjIyOWZlMzU3MTA1OSJ9fX0= + TRADER_LLAMA: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODQyNDc4MGIzYzVjNTM1MWNmNDlmYjViZjQxZmNiMjg5NDkxZGY2YzQzMDY4M2M4NGQ3ODQ2MTg4ZGI0Zjg0ZCJ9fX0= + TROPICAL_FISH: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDZkZDVlNmFkZGI1NmFjYmM2OTRlYTRiYTU5MjNiMWIyNTY4ODE3OGZlZmZhNzIyOTAyOTllMjUwNWM5NzI4MSJ9fX0= + TURTLE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMGE0MDUwZTdhYWNjNDUzOTIwMjY1OGZkYzMzOWRkMTgyZDdlMzIyZjlmYmNjNGQ1Zjk5YjU3MThhIn19fQ== + VEX: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJlYzVhNTE2NjE3ZmYxNTczY2QyZjlkNWYzOTY5ZjU2ZDU1NzVjNGZmNGVmZWZhYmQyYTE4ZGM3YWI5OGNkIn19fQ== + VILLAGER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDFiODMwZWI0MDgyYWNlYzgzNmJjODM1ZTQwYTExMjgyYmI1MTE5MzMxNWY5MTE4NDMzN2U4ZDM1NTU1ODMifX19 + VINDICATOR: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmRlYWVjMzQ0YWIwOTViNDhjZWFkNzUyN2Y3ZGVlNjFiMDYzZmY3OTFmNzZhOGZhNzY2NDJjODY3NmUyMTczIn19fQ== + WANDERING_TRADER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWYxMzc5YTgyMjkwZDdhYmUxZWZhYWJiYzcwNzEwZmYyZWMwMmRkMzRhZGUzODZiYzAwYzkzMGM0NjFjZjkzMiJ9fX0= + WITCH: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjBlMTNkMTg0NzRmYzk0ZWQ1NWFlYjcwNjk1NjZlNDY4N2Q3NzNkYWMxNmY0YzNmODcyMmZjOTViZjlmMmRmYSJ9fX0= + WOLF: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA0OThkZTZmNWIwOWUwY2UzNWE3MjkyZmU1MGI3OWZjZTkwNjVkOWJlOGUyYTg3YzdhMTM1NjZlZmIyNmQ3MiJ9fX0= + ZOGLIN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTY3ZTE4NjAyZTAzMDM1YWQ2ODk2N2NlMDkwMjM1ZDg5OTY2NjNmYjllYTQ3NTc4ZDNhN2ViYmM0MmE1Y2NmOSJ9fX0= + ZOMBIFIED_PIGLIN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2VhYmFlY2M1ZmFlNWE4YTQ5Yzg4NjNmZjQ4MzFhYWEyODQxOThmMWEyMzk4ODkwYzc2NWUwYThkZTE4ZGE4YyJ9fX0= + 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 new file mode 100644 index 0000000..281457c --- /dev/null +++ b/Core/src/main/resources/enchants/divine_touch.yml @@ -0,0 +1,33 @@ +Is_Treasure: false +Name: Divine Touch +Tier: legendary +Description: + - '%enchantment_trigger_chance%% chance to obtain &fMob Spawner&8.' +Level: + Min: 1 + Max: 5 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 5.0 +Enchanting_Table: + Level_By_Exp_Cost: '6.0 * %enchantment_level%' + Chance: 5.0 +Villagers: + Chance: 5.0 +Loot_Generation: + Chance: 8.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '15.0 * %enchantment_level%' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Particle: + Name: 'VILLAGER_HAPPY' + Data: '' + Spawner_Item: + Name: '&aMob Spawner &7(%type%)' diff --git a/Core/src/main/resources/enchants/double_strike.yml b/Core/src/main/resources/enchants/double_strike.yml new file mode 100644 index 0000000..78ca809 --- /dev/null +++ b/Core/src/main/resources/enchants/double_strike.yml @@ -0,0 +1,32 @@ +Is_Treasure: false +Name: Double Strike +Tier: legendary +Description: + - '%enchantment_trigger_chance%% chance to inflict double damage.' +Level: + Min: 1 + Max: 4 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 10.0 +Enchanting_Table: + Level_By_Exp_Cost: '7 * %enchantment_level%' + Chance: 10.0 +Villagers: + Chance: 10.0 +Loot_Generation: + Chance: 15.0 +Mob_Spawning: + Chance: 10.0 +Settings: + Trigger_Chance: '4.0 + %enchantment_level% * 0.8' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Particle: + Name: 'EXPLOSION_NORMAL' + Data: '' + Sound: 'ENTITY_GENERIC_EXPLODE' diff --git a/Core/src/main/resources/enchants/ender_bow.yml b/Core/src/main/resources/enchants/ender_bow.yml new file mode 100644 index 0000000..a461d67 --- /dev/null +++ b/Core/src/main/resources/enchants/ender_bow.yml @@ -0,0 +1,28 @@ +Is_Treasure: false +Name: Ender Bow +Tier: legendary +Description: + - '%enchantment_trigger_chance%% chance to shoot Ender Pearl instead of arrows.' +Level: + Min: 1 + Max: 1 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 5.0 +Enchanting_Table: + Level_By_Exp_Cost: '30' + Chance: 5.0 +Villagers: + Chance: 3.0 +Loot_Generation: + Chance: 10.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: ENDER_PEARL + Amount: 1 diff --git a/Core/src/main/resources/enchants/exhaust.yml b/Core/src/main/resources/enchants/exhaust.yml new file mode 100644 index 0000000..48270e9 --- /dev/null +++ b/Core/src/main/resources/enchants/exhaust.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Exhaust +Tier: common +Description: + - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 70.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 70.0 +Villagers: + Chance: 70.0 +Loot_Generation: + Chance: 70.0 +Mob_Spawning: + Chance: 50.0 +Settings: + Trigger_Chance: '20.0 * %enchantment_level%' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '3.0 + %enchantment_level% * 1.5' + Level: '%enchantment_level%' + Particle: + Name: '' + Data: '' diff --git a/Core/src/main/resources/enchants/exp_hunter.yml b/Core/src/main/resources/enchants/exp_hunter.yml new file mode 100644 index 0000000..4db663e --- /dev/null +++ b/Core/src/main/resources/enchants/exp_hunter.yml @@ -0,0 +1,29 @@ +Is_Treasure: false +Name: Exp Hunter +Tier: rare +Description: + - '%enchantment_trigger_chance%% chance to obtain +%enchantment_exp_modifier%% more exp from mobs.' +Level: + Min: 1 + Max: 5 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 45.0 +Enchanting_Table: + Level_By_Exp_Cost: '6 * %enchantment_level%' + Chance: 45.0 +Villagers: + Chance: 45.0 +Loot_Generation: + Chance: 45.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '50.0 + %enchantment_level% * 5' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Exp_Modifier: '1.0 + %enchantment_level% * 0.5' diff --git a/Core/src/main/resources/enchants/explosive_arrows.yml b/Core/src/main/resources/enchants/explosive_arrows.yml new file mode 100644 index 0000000..fbd95e2 --- /dev/null +++ b/Core/src/main/resources/enchants/explosive_arrows.yml @@ -0,0 +1,37 @@ +Is_Treasure: false +Name: Explosive Arrows +Tier: exotic +Description: + - '%enchantment_trigger_chance%% chance to launch an explosive arrow with x%enchantment_explosion_power% power.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 40.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 40.0 +Villagers: + Chance: 40.0 +Loot_Generation: + Chance: 50.0 +Mob_Spawning: + Chance: 25.0 +Settings: + Trigger_Chance: '10.0 + %enchantment_level% * 5' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Explosion: + Fire_Spread: true + Damage_Items: true + Damage_Blocks: false + Size: '2.0 + %enchantment_level%' + Arrow: + Trail: + Name: 'SMOKE_NORMAL' + Data: '' diff --git a/Core/src/main/resources/enchants/flame_walker.yml b/Core/src/main/resources/enchants/flame_walker.yml new file mode 100644 index 0000000..5c7a9dd --- /dev/null +++ b/Core/src/main/resources/enchants/flame_walker.yml @@ -0,0 +1,29 @@ +Is_Treasure: false +Name: Flame Walker +Tier: exotic +Description: + - 'Ability to walk on lava and on magma blocks without getting damage.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 40.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 40.0 +Villagers: + Chance: 40.0 +Loot_Generation: + Chance: 50.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Block_Decay: '5.0 + %enchantment_level% * 2' diff --git a/Core/src/main/resources/enchants/ghast.yml b/Core/src/main/resources/enchants/ghast.yml new file mode 100644 index 0000000..f9f2766 --- /dev/null +++ b/Core/src/main/resources/enchants/ghast.yml @@ -0,0 +1,30 @@ +Is_Treasure: false +Name: Ghast +Tier: rare +Description: + - '%enchantment_trigger_chance%% chance to launch a fireball instead of arrow.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 40.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 40.0 +Villagers: + Chance: 40.0 +Loot_Generation: + Chance: 40.0 +Mob_Spawning: + Chance: 20.0 +Settings: + Trigger_Chance: '100.0' + Fire_Spread: true + Yield: '1.0 * %enchantment_level%' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/hardened.yml b/Core/src/main/resources/enchants/hardened.yml new file mode 100644 index 0000000..3f515e9 --- /dev/null +++ b/Core/src/main/resources/enchants/hardened.yml @@ -0,0 +1,31 @@ +Is_Treasure: false +Name: Hardened +Tier: rare +Description: + - '%enchantment_trigger_chance%% chance to obtain %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. when damaged.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 30.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 30.0 +Villagers: + Chance: 30.0 +Loot_Generation: + Chance: 30.0 +Mob_Spawning: + Chance: 20.0 +Settings: + Trigger_Chance: '10.0 + %enchantment_level% * 5' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '2.5 + %enchantment_level%' + Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/haste.yml b/Core/src/main/resources/enchants/haste.yml new file mode 100644 index 0000000..076ae8d --- /dev/null +++ b/Core/src/main/resources/enchants/haste.yml @@ -0,0 +1,31 @@ +Is_Treasure: false +Name: Haste +Tier: rare +Description: + - 'Grants %enchantment_potion_type% %enchantment_potion_level% effect.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 40.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 40.0 +Villagers: + Chance: 40.0 +Loot_Generation: + Chance: 40.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: SUGAR + Amount: 1 + Potion_Effect: + Duration: '25.0' + Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/ice_aspect.yml b/Core/src/main/resources/enchants/ice_aspect.yml new file mode 100644 index 0000000..5ebd743 --- /dev/null +++ b/Core/src/main/resources/enchants/ice_aspect.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Ice Aspect +Tier: common +Description: + - '%enchantment_trigger_chance%% chance to freeze and apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 70.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 70.0 +Villagers: + Chance: 70.0 +Loot_Generation: + Chance: 70.0 +Mob_Spawning: + Chance: 50.0 +Settings: + Trigger_Chance: '25.0 * %enchantment_level%' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '3.0 + %enchantment_level%' + Level: '%enchantment_level%' + Particle: + Name: 'BLOCK_CRACK' + Data: 'ICE' diff --git a/Core/src/main/resources/enchants/infernus.yml b/Core/src/main/resources/enchants/infernus.yml new file mode 100644 index 0000000..f4f2610 --- /dev/null +++ b/Core/src/main/resources/enchants/infernus.yml @@ -0,0 +1,29 @@ +Is_Treasure: false +Name: Infernus +Tier: common +Description: + - '%enchantment_trigger_chance%% chance to launch flaming Trident that ignites the enemy for %enchantment_fire_duration%s.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 45.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 35.0 +Villagers: + Chance: 45.0 +Loot_Generation: + Chance: 45.0 +Mob_Spawning: + Chance: 30.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + 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 new file mode 100644 index 0000000..1108e9b --- /dev/null +++ b/Core/src/main/resources/enchants/lucky_miner.yml @@ -0,0 +1,29 @@ +Is_Treasure: false +Name: Lucky Miner +Tier: common +Description: + - '%enchantment_trigger_chance%% chance to obtain +%enchantment_exp_modifier%% more exp from ores.' +Level: + Min: 1 + Max: 5 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 50.0 +Enchanting_Table: + Level_By_Exp_Cost: '6 * %enchantment_level%' + Chance: 50.0 +Villagers: + Chance: 50.0 +Loot_Generation: + Chance: 60.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '30.0 + %enchantment_level% * 7.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Exp_Modifier: '1.0 + %enchantment_level% * 0.5' diff --git a/Core/src/main/resources/enchants/night_vision.yml b/Core/src/main/resources/enchants/night_vision.yml new file mode 100644 index 0000000..983b628 --- /dev/null +++ b/Core/src/main/resources/enchants/night_vision.yml @@ -0,0 +1,31 @@ +Is_Treasure: false +Name: Night Vision +Tier: rare +Description: + - 'Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 %enchantment_cost_item%.' +Level: + Min: 1 + Max: 1 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 20.0 +Enchanting_Table: + Level_By_Exp_Cost: '15' + Chance: 20.0 +Villagers: + Chance: 20.0 +Loot_Generation: + Chance: 20.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: true + Item: + Material: GLOWSTONE_DUST + Amount: 1 + Potion_Effect: + Duration: '60.0' + Level: '1' diff --git a/Core/src/main/resources/enchants/nimble.yml b/Core/src/main/resources/enchants/nimble.yml new file mode 100644 index 0000000..247f80a --- /dev/null +++ b/Core/src/main/resources/enchants/nimble.yml @@ -0,0 +1,28 @@ +Is_Treasure: false +Name: Nimble +Tier: rare +Description: + - 'Moves all mob''s loot directly to your inventory.' +Level: + Min: 1 + Max: 1 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 40.0 +Enchanting_Table: + Level_By_Exp_Cost: '15 * %enchantment_level%' + Chance: 40.0 +Villagers: + Chance: 40.0 +Loot_Generation: + Chance: 40.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 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 new file mode 100644 index 0000000..bba51b5 --- /dev/null +++ b/Core/src/main/resources/enchants/paralyze.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Paralyze +Tier: rare +Description: + - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 50.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 50.0 +Villagers: + Chance: 50.0 +Loot_Generation: + Chance: 50.0 +Mob_Spawning: + Chance: 25.0 +Settings: + Trigger_Chance: '10.0 * %enchantment_level%' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '2.5 + %enchantment_level% * 0.5' + Level: '%enchantment_level%' + Particle: + Name: 'CRIT_MAGIC' + Data: '' diff --git a/Core/src/main/resources/enchants/poisoned_arrows.yml b/Core/src/main/resources/enchants/poisoned_arrows.yml new file mode 100644 index 0000000..950bf77 --- /dev/null +++ b/Core/src/main/resources/enchants/poisoned_arrows.yml @@ -0,0 +1,31 @@ +Is_Treasure: false +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.)' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 50.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 50.0 +Villagers: + Chance: 50.0 +Loot_Generation: + Chance: 50.0 +Mob_Spawning: + Chance: 30.0 +Settings: + Trigger_Chance: '25.0 + %enchantment_level% * 5' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '2.0 + %enchantment_level%' + Level: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/rage.yml b/Core/src/main/resources/enchants/rage.yml new file mode 100644 index 0000000..f5228ff --- /dev/null +++ b/Core/src/main/resources/enchants/rage.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Rage +Tier: rare +Description: + - '%enchantment_trigger_chance%% chance to get %enchantment_potion_type% %enchantment_potion_level% effect for %enchantment_potion_duration%s. on hit.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 30.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 30.0 +Villagers: + Chance: 30.0 +Loot_Generation: + Chance: 30.0 +Mob_Spawning: + Chance: 15.0 +Settings: + Trigger_Chance: '7.0 + %enchantment_level%' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '3.0 + %enchantment_level% * 0.5' + Level: '%enchantment_level%' + Particle: + Name: 'LAVA' + Data: '' diff --git a/Core/src/main/resources/enchants/regrowth.yml b/Core/src/main/resources/enchants/regrowth.yml new file mode 100644 index 0000000..4736309 --- /dev/null +++ b/Core/src/main/resources/enchants/regrowth.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Regrowth +Tier: exotic +Description: + - 'Restores %enchantment_health_amount% hearts every %enchantment_health_interval%s. with %enchantment_trigger_chance%% chance.' +Level: + Min: 1 + Max: 5 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 15.0 +Enchanting_Table: + Level_By_Exp_Cost: '6 * %enchantment_level%' + Chance: 10.0 +Villagers: + Chance: 15.0 +Loot_Generation: + Chance: 15.0 +Mob_Spawning: + Chance: 10.0 +Settings: + Trigger_Chance: '20.0 + %enchantment_level% * 5' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Particle: + Name: 'HEART' + Data: '' + Health: + Amount: '%enchantment_level% * 0.25' + Interval: 100 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/replanter.yml b/Core/src/main/resources/enchants/replanter.yml new file mode 100644 index 0000000..9f87016 --- /dev/null +++ b/Core/src/main/resources/enchants/replanter.yml @@ -0,0 +1,31 @@ +Is_Treasure: false +Name: Replanter +Tier: common +Description: + - 'Automatically replant crops on right click and harvest.' +Level: + Min: 1 + Max: 1 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 50.0 +Enchanting_Table: + Level_By_Exp_Cost: '15' + Chance: 50.0 +Villagers: + Chance: 50.0 +Loot_Generation: + Chance: 50.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Replant: + On_Right_Click: true + On_Plant_Break: true diff --git a/Core/src/main/resources/enchants/rocket.yml b/Core/src/main/resources/enchants/rocket.yml new file mode 100644 index 0000000..ef46c87 --- /dev/null +++ b/Core/src/main/resources/enchants/rocket.yml @@ -0,0 +1,29 @@ +Is_Treasure: false +Name: Rocket +Tier: exotic +Description: + - '%enchantment_trigger_chance%% chance to launch your enemy into the space.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 50.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 50.0 +Villagers: + Chance: 50.0 +Loot_Generation: + Chance: 50.0 +Mob_Spawning: + Chance: 20.0 +Settings: + Trigger_Chance: '4.0 + %enchantment_level%' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Firework_Power: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/saturation.yml b/Core/src/main/resources/enchants/saturation.yml new file mode 100644 index 0000000..d212924 --- /dev/null +++ b/Core/src/main/resources/enchants/saturation.yml @@ -0,0 +1,31 @@ +Is_Treasure: false +Name: Saturation +Tier: rare +Description: + - 'Restores %enchantment_saturation_amount% food points every %enchantment_saturation_interval%s. with %enchantment_trigger_chance%% chance.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 20.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 20.0 +Villagers: + Chance: 25.0 +Loot_Generation: + Chance: 25.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '25.0 + %enchantment_level% * 5' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Saturation: + Amount: '%enchantment_level%' + Interval: 150 diff --git a/Core/src/main/resources/enchants/scavenger.yml b/Core/src/main/resources/enchants/scavenger.yml new file mode 100644 index 0000000..a116f83 --- /dev/null +++ b/Core/src/main/resources/enchants/scavenger.yml @@ -0,0 +1,37 @@ +Is_Treasure: false +Name: Scavenger +Tier: common +Description: + - '%enchantment_trigger_chance%% chance to obtain additional loot from mobs.' +Level: + Min: 1 + Max: 4 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 60.0 +Enchanting_Table: + Level_By_Exp_Cost: '7 * %enchantment_level%' + Chance: 60.0 +Villagers: + Chance: 70.0 +Loot_Generation: + Chance: 70.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '15.0 + %enchantment_level% * 10' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Treasures: + VILLAGER: + EMERALD: + Amount: '1:1' + Chance: 5.0 + SKELETON: + BONE_MEAL: + Amount: '1:2' + Chance: 50.0 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/self_destruction.yml b/Core/src/main/resources/enchants/self_destruction.yml new file mode 100644 index 0000000..a5a6579 --- /dev/null +++ b/Core/src/main/resources/enchants/self_destruction.yml @@ -0,0 +1,30 @@ +Is_Treasure: false +Name: Self-Destruction +Tier: exotic +Description: + - '%enchantment_trigger_chance%% chance to create an x%enchantment_explosion_power% power explosion on death.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 20.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 20.0 +Villagers: + Chance: 20.0 +Loot_Generation: + Chance: 20.0 +Mob_Spawning: + Chance: 15.0 +Settings: + Trigger_Chance: '20.0 + %enchantment_level% * 10' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + 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 new file mode 100644 index 0000000..cab74c3 --- /dev/null +++ b/Core/src/main/resources/enchants/silk_chest.yml @@ -0,0 +1,30 @@ +Is_Treasure: false +Name: Silk Chest +Tier: rare +Description: + - 'Drop chests and saves all its content.' +Level: + Min: 1 + Max: 1 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 30.0 +Enchanting_Table: + Level_By_Exp_Cost: '30' + Chance: 30.0 +Villagers: + Chance: 30.0 +Loot_Generation: + Chance: 30.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Chest_Item: + Name: '&f%name% &7(%items% items)' diff --git a/Core/src/main/resources/enchants/smelter.yml b/Core/src/main/resources/enchants/smelter.yml new file mode 100644 index 0000000..0d646f6 --- /dev/null +++ b/Core/src/main/resources/enchants/smelter.yml @@ -0,0 +1,38 @@ +Is_Treasure: false +Name: Smelter +Tier: rare +Description: + - '%enchantment_trigger_chance%% chance to smelt ore or a block on mining.' +Level: + Min: 1 + Max: 5 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 60.0 +Enchanting_Table: + Level_By_Exp_Cost: '5 * %enchantment_level%' + Chance: 60.0 +Villagers: + Chance: 60.0 +Loot_Generation: + Chance: 60.0 +Mob_Spawning: + Chance: 60.0 +Settings: + Trigger_Chance: '25.0 + %enchantment_level% * 10' + Particle: + Name: 'FLAME' + Data: '' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Smelting_Table: + IRON_ORE: IRON_INGOT + RAW_IRON: IRON_INGOT + GOLD_ORE: GOLD_INGOT + RAW_GOLD: GOLD_INGOT + RAW_COPPER: COPPER_INGOT + SAND: GLASS \ No newline at end of file diff --git a/Core/src/main/resources/enchants/sonic.yml b/Core/src/main/resources/enchants/sonic.yml new file mode 100644 index 0000000..73ebc7f --- /dev/null +++ b/Core/src/main/resources/enchants/sonic.yml @@ -0,0 +1,30 @@ +Is_Treasure: false +Name: Sonic +Tier: rare +Description: + - 'Grants %enchantment_potion_type% %enchantment_potion_level% effect.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 30.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 30.0 +Villagers: + Chance: 30.0 +Loot_Generation: + Chance: 40.0 +Mob_Spawning: + Chance: 20.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: FEATHER + Potion_Effect: + Duration: '25.0' + Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/surprise.yml b/Core/src/main/resources/enchants/surprise.yml new file mode 100644 index 0000000..b606b24 --- /dev/null +++ b/Core/src/main/resources/enchants/surprise.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Surprise +Tier: exotic +Description: + - '%enchantment_trigger_chance%% chance to apply random potion effect to enemy on hit.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 50.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 50.0 +Villagers: + Chance: 50.0 +Loot_Generation: + Chance: 50.0 +Mob_Spawning: + Chance: 40.0 +Settings: + Trigger_Chance: '2.25 * %enchantment_level%' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '3.0 + %enchantment_level%' + Level: '%enchantment_level%' + Particle: + Name: 'SPELL_WITCH' + Data: '' diff --git a/Core/src/main/resources/enchants/telekinesis.yml b/Core/src/main/resources/enchants/telekinesis.yml new file mode 100644 index 0000000..902a65c --- /dev/null +++ b/Core/src/main/resources/enchants/telekinesis.yml @@ -0,0 +1,32 @@ +Is_Treasure: false +Name: Telekinesis +Tier: exotic +Description: + - 'Moves all blocks loot directly to your inventory.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 20.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 20.0 +Villagers: + Chance: 30.0 +Loot_Generation: + Chance: 30.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Message: + Drop_Received: '{message: ~type: ACTION_BAR; ~prefix: false;}%items%' + Item_Name: '&7x%item_amount% &f%item_name%' + Item_Separator: '&7, ' diff --git a/Core/src/main/resources/enchants/thrifty.yml b/Core/src/main/resources/enchants/thrifty.yml new file mode 100644 index 0000000..0e449bd --- /dev/null +++ b/Core/src/main/resources/enchants/thrifty.yml @@ -0,0 +1,35 @@ +Is_Treasure: false +Name: Thrifty +Tier: exotic +Description: + - '%enchantment_trigger_chance%% chance to obtain mob Spawn Egg on kill.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 15.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 15.0 +Villagers: + Chance: 10.0 +Loot_Generation: + Chance: 20.0 +Mob_Spawning: + Chance: 10.0 +Settings: + Trigger_Chance: '5.0 + %enchantment_level% * 3' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Ignored_Entity_Types: + - WITHER + - ENDER_DRAGON + Ignored_Spawn_Reasons: + - SPAWNER + - SPAWN_EGG + - DISPENSE_EGG \ No newline at end of file diff --git a/Core/src/main/resources/enchants/thunder.yml b/Core/src/main/resources/enchants/thunder.yml new file mode 100644 index 0000000..d42e8f3 --- /dev/null +++ b/Core/src/main/resources/enchants/thunder.yml @@ -0,0 +1,29 @@ +Is_Treasure: false +Name: Thunder +Tier: rare +Description: + - '%enchantment_trigger_chance%% chance to summon lightning to enemy on hit.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 70.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 70.0 +Villagers: + Chance: 70.0 +Loot_Generation: + Chance: 70.0 +Mob_Spawning: + Chance: 40.0 +Settings: + Trigger_Chance: '10.0 * %enchantment_level%' + During_Thunderstorm_Only: false + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/treasures.yml b/Core/src/main/resources/enchants/treasures.yml new file mode 100644 index 0000000..2ee454a --- /dev/null +++ b/Core/src/main/resources/enchants/treasures.yml @@ -0,0 +1,65 @@ +Is_Treasure: false +Name: Treasures +Tier: common +Description: + - '%enchantment_trigger_chance%% chance to attempt to find a treasure in mined block.' +Level: + Min: 1 + Max: 5 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 70.0 +Enchanting_Table: + Level_By_Exp_Cost: '6 * %enchantment_level%' + Chance: 70.0 +Villagers: + Chance: 75.0 +Loot_Generation: + Chance: 75.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '10.0 + %enchantment_level% * 4.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Particle: + Name: 'REDSTONE' + Data: '200,180,0' + Sound: 'BLOCK_NOTE_BLOCK_BELL' + Treasures: + STONE,GRANITE,ANDESITE,DIORITE: + AIR: 95.0 + BONE_MEAL: 2.0 + CLAY: + AIR: 95.0 + SLIME_BALL: 7.0 + DIRT,PODZOL,COARSE_DIRT,ROOTED_DIRT: + AIR: 95.0 + CLAY_BALL: 0.5 + BOWL: 1.0 + STICK: 2.0 + SAND,RED_SAND: + AIR: 95.0 + GLOWSTONE_DUST: 1.0 + GOLD_NUGGET: 0.3 + SOUL_SAND: + AIR: 95.0 + FLINT: 1.5 + GUNPOWDER: 0.8 + COAL: 0.4 + NETHERRACK: + AIR: 99.0 + BRICK: 0.05 + END_STONE: + AIR: 99.0 + ENDER_PEARL: 0.1 + OAK_LEAVES,BIRCH_LEAVES,SPRUCE_LEAVES,ACACIA_LEAVES,JUNGLE_LEAVES,DARK_OAK_LEAVES: + AIR: 80.0 + APPLE: 15.0 + MOSSY_COBBLESTONE,MOSSY_STONE_BRICKS: + AIR: 50.0 + VINE: 50.0 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/tunnel.yml b/Core/src/main/resources/enchants/tunnel.yml new file mode 100644 index 0000000..d1a0a53 --- /dev/null +++ b/Core/src/main/resources/enchants/tunnel.yml @@ -0,0 +1,29 @@ +Is_Treasure: false +Name: Tunnel +Tier: legendary +Description: + - 'Allows you to mine multiple blocks at once in a shape.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 20.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 20.0 +Villagers: + Chance: 20.0 +Loot_Generation: + Chance: 30.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Ignore_When_Sneaking: true diff --git a/Core/src/main/resources/enchants/vampire.yml b/Core/src/main/resources/enchants/vampire.yml new file mode 100644 index 0000000..1d44088 --- /dev/null +++ b/Core/src/main/resources/enchants/vampire.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Vampire +Tier: exotic +Description: + - '%enchantment_trigger_chance%% chance to heal yourself for %enchantment_heal_amount% heart(s) on hit.' +Level: + Min: 1 + Max: 4 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 30.0 +Enchanting_Table: + Level_By_Exp_Cost: '7 * %enchantment_level%' + Chance: 40.0 +Villagers: + Chance: 40.0 +Loot_Generation: + Chance: 40.0 +Mob_Spawning: + Chance: 20.0 +Settings: + Trigger_Chance: '10.0 + %enchantment_level% * 5.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Particle: + Name: 'HEART' + Data: '' + Heal: + Amount: '0.35 * %enchantment_level%' + As_Multiplier: false diff --git a/Core/src/main/resources/enchants/veinminer.yml b/Core/src/main/resources/enchants/veinminer.yml new file mode 100644 index 0000000..11f8161 --- /dev/null +++ b/Core/src/main/resources/enchants/veinminer.yml @@ -0,0 +1,49 @@ +Is_Treasure: false +Name: Veinminer +Tier: rare +Description: + - 'Mines up to %enchantment_block_limit% blocks of the ore vein at once.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 25.0 +Enchanting_Table: + Level_By_Exp_Cost: '10 * %enchantment_level%' + Chance: 25.0 +Villagers: + Chance: 25.0 +Loot_Generation: + Chance: 40.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + 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 \ No newline at end of file diff --git a/Core/src/main/resources/enchants/venom.yml b/Core/src/main/resources/enchants/venom.yml new file mode 100644 index 0000000..45bc8c6 --- /dev/null +++ b/Core/src/main/resources/enchants/venom.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Venom +Tier: rare +Description: + - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 50.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 50.0 +Villagers: + Chance: 60.0 +Loot_Generation: + Chance: 60.0 +Mob_Spawning: + Chance: 30.0 +Settings: + Trigger_Chance: '30.0 + %enchantment_level% * 10.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '2.0 + %enchantment_level%' + Level: '%enchantment_level%' + Particle: + Name: SLIME + Data: '' diff --git a/Core/src/main/resources/enchants/village_defender.yml b/Core/src/main/resources/enchants/village_defender.yml new file mode 100644 index 0000000..e735a43 --- /dev/null +++ b/Core/src/main/resources/enchants/village_defender.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Village Defender +Tier: common +Description: + - '%enchantment_trigger_chance%% chance to inflict %enchantment_damage_amount% more damage on Pillagers.' +Level: + Min: 1 + Max: 5 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 60.0 +Enchanting_Table: + Level_By_Exp_Cost: '6 * %enchantment_level%' + Chance: 80.0 +Villagers: + Chance: 80.0 +Loot_Generation: + Chance: 70.0 +Mob_Spawning: + Chance: 0.0 +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Particle: + Name: 'VILLAGER_ANGRY' + Data: '' + Damage: + As_Modifier: false + Formula: '0.5 * %enchantment_level%' diff --git a/Core/src/main/resources/enchants/wither.yml b/Core/src/main/resources/enchants/wither.yml new file mode 100644 index 0000000..c866f72 --- /dev/null +++ b/Core/src/main/resources/enchants/wither.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Wither +Tier: rare +Description: + - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 20.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 20.0 +Villagers: + Chance: 30.0 +Loot_Generation: + Chance: 30.0 +Mob_Spawning: + Chance: 15.0 +Settings: + Trigger_Chance: '10.0 + %enchantment_level% * 5' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '3.0 + %enchantment_level%' + Level: '%enchantment_level%' + Particle: + Name: '' + Data: '' diff --git a/Core/src/main/resources/enchants/withered_arrows.yml b/Core/src/main/resources/enchants/withered_arrows.yml new file mode 100644 index 0000000..8002bd9 --- /dev/null +++ b/Core/src/main/resources/enchants/withered_arrows.yml @@ -0,0 +1,31 @@ +Is_Treasure: false +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.)' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 25.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 25.0 +Villagers: + Chance: 25.0 +Loot_Generation: + Chance: 25.0 +Mob_Spawning: + Chance: 15.0 +Settings: + Trigger_Chance: '15.0 + %enchantment_level% * 5.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '2.5 + %enchantment_level% * 0.75' + Level: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/gui.enchants.yml b/Core/src/main/resources/gui.enchants.yml new file mode 100644 index 0000000..b47551e --- /dev/null +++ b/Core/src/main/resources/gui.enchants.yml @@ -0,0 +1,60 @@ +# Menu title. +Title: 'Excellent Enchants List' +# Menu size. Allowed values: 9, 18, 27, 36, 45, 54. +Size: 36 + +# Enchantment display settings. +Enchantments: + # Enchantment display item options. + Icon: + Material: 'ENCHANTED_BOOK' + Name: '%enchantment_name_formatted%' + Lore: + - '%enchantment_description%' + - '&7' + - '&a▸ &7Tier: &a%enchantment_tier%' + - '&a▸ &7Applies to: &a%enchantment_fit_item_types%' + - '&a▸ &7Levels: &a%enchantment_level_min% &7- &a%enchantment_level_max%' + - '&7' + - '&c&lConflicts with:' + - '&c▸ &4%enchantment_conflicts%' + - '&7' + - '&e&lItem Cost to Use:' + - '&e▸ &7%enchantment_cost_item%' + - '&7' + - '&b&lObtain Chance:' + - '&b▸ &7Enchanting Table: &b%enchantment_obtain_chance_enchanting%%' + - '&b▸ &7Villager Trade: &b%enchantment_obtain_chance_villager%%' + - '&b▸ &7Loot Generation: &b%enchantment_obtain_chance_loot_generation%%' + - '&b▸ &7Fishing: &b%enchantment_obtain_chance_fishing%%' + - '&b▸ &7Mob Spawning: &b%enchantment_obtain_chance_mob_spawning%%' + - '&7' + - '&d&lClick to switch enchantment levels!' + # Menu slots to display enchantments. + Slots: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 + +# List of custom menu items. +Content: + page_next: + Display: + default: + Priority: 0 + Item: + Material: ARROW + Name: '&aNext Page' + Lore: + - '&7Click to move &aForward&7!' + Slots: 35 + Type: PAGE_NEXT + + page_prev: + Display: + default: + Priority: 0 + Item: + Material: ARROW + Name: '&cPrevious Page' + Lore: + - '&7Click to move &cBack&7!' + Slots: 27 + Type: PAGE_PREVIOUS \ No newline at end of file diff --git a/Core/src/main/resources/lang/messages_cn.yml b/Core/src/main/resources/lang/messages_cn.yml new file mode 100644 index 0000000..ae013c2 --- /dev/null +++ b/Core/src/main/resources/lang/messages_cn.yml @@ -0,0 +1,18 @@ +# Tranlsated by @qsefthuopq +# Last updated:2021-03-15 +Command: + Enchant: + Usage: <附魔名> <等级> + Desc: 附魔你手中的物品。 + Done: '&a附魔成功!' + Book: + Usage: <玩家> <附魔名> <等级> + Desc: 给予自定义附魔书。 + Done: 已给予&6%player%&6%enchant%&7附魔书。 + TierBook: + Usage: <玩家> <品质> <等级> + Desc: 给予自定义品质的附魔书 + Error: '&c无效品质!' + Done: 已给予&6%player&6%enchant%&7附魔书。 +Error: + NoEnchant: '&c没有这种附魔' \ No newline at end of file diff --git a/Core/src/main/resources/lang/messages_en.yml b/Core/src/main/resources/lang/messages_en.yml new file mode 100644 index 0000000..e69de29 diff --git a/Core/src/main/resources/lang/messages_pl.yml b/Core/src/main/resources/lang/messages_pl.yml new file mode 100644 index 0000000..0470bfb --- /dev/null +++ b/Core/src/main/resources/lang/messages_pl.yml @@ -0,0 +1,18 @@ +# Przetłumaczone przez nitolar play +# Tłumaczenie utworzono: 06.11.2020 +Command: + Enchant: + Usage: + Desc: Zaklnij przedmiot w swojej ręce. + Done: '&aSukcesywnie Zaklnięto!' + Book: + Usage: + Desc: Dodaje niestandardowo zaklniętą książke. + Done: Dodano zaklniętą ksiązke z zaklęciem &6%enchant%&7 do gracza &6%player%&7. + TierBook: + Usage: <żadkość> + Desc: Dodaje zaklniętą książke. + Error: '&cZły poziom żadkości!' + Done: Dodano zaklniętą ksiązke z zaklęciem &6%enchant%&7 do gracza &6%player%&7. +Error: + NoEnchant: '&cNie ma takiego zaklęcia.' \ No newline at end of file diff --git a/Core/src/main/resources/lang/messages_ru.yml b/Core/src/main/resources/lang/messages_ru.yml new file mode 100644 index 0000000..9eff883 --- /dev/null +++ b/Core/src/main/resources/lang/messages_ru.yml @@ -0,0 +1,35 @@ +Command: + List: + Desc: Список всех пользовательских зачарований. + Enchant: + Usage: <зачарование> <уровень> + Desc: Зачаровывает предмет в вашей руке. + Done: '&aУспешно зачарован!' + Book: + Usage: <игрок> <зачарование> <уровень> + Desc: Даёт кастомную книгу зачарования. + Done: Выдана книга зачарованя &6%enchant%&7 &6%player%&7. + TierBook: + Usage: <игрок> <клас> <уровень> + Desc: Даёт зачарованную книгу. + Error: '&cНеверный уровень!' + Done: Выдан зачарованная книга класа &6%tier%&7 &6%player%&7. +Error: + NoEnchant: '&cНет такого зачарования.' +EnchantmentTarget: + ALL: All + ARMOR: Armor + ARMOR_FEET: Armor Feet + ARMOR_LEGS: Armor Legs + ARMOR_TORSO: Armor Torso + ARMOR_HEAD: Armor Head + WEAPON: Weapon + TOOL: Tool + BOW: Bow + FISHING_ROD: Fishing Rod + BREAKABLE: Breakable + WEARABLE: Wearable + TRIDENT: Trident + CROSSBOW: Crossbow + VANISHABLE: Vanishable + BOW_AND_CROSSBOW: Bow And Crossbow \ No newline at end of file diff --git a/Core/src/main/resources/plugin.yml b/Core/src/main/resources/plugin.yml new file mode 100644 index 0000000..386117e --- /dev/null +++ b/Core/src/main/resources/plugin.yml @@ -0,0 +1,44 @@ +main: su.nightexpress.excellentenchants.ExcellentEnchants +version: '${project.version}' +name: ExcellentEnchants +author: NightExpress +desciption: Vanilla-like enchants for your server. +depend: [ NexEngine ] +softdepend: [ Towny, Residence, WorldGuard, GriefPrevention, Lands ] +api-version: 1.16 +load: STARTUP + +permissions: + excellentenchants.admin: + description: Grants access to all plugin functions. + default: op + children: + excellentenchants.user: true + excellentenchants.command: true + + excellentenchants.user: + description: Grants access to basic player plugin functions. + default: true + + excellentenchants.command: + description: Grants access to all the plugin commands. + default: op + children: + excellentenchants.command.book: true + excellentenchants.command.enchant: true + excellentenchants.command.list: true + excellentenchants.command.tierbook: true + + excellentenchants.command.book: + description: Grants access to /eenchants book command. + default: op + excellentenchants.command.enchant: + description: Grants access to /eenchants enchant command. + default: op + excellentenchants.command.list: + description: Grants access to /eenchants list command. + default: true + excellentenchants.command.tierbook: + description: Grants access to /eenchants tierbook command. + default: op + diff --git a/NMS/pom.xml b/NMS/pom.xml new file mode 100644 index 0000000..4cd50d2 --- /dev/null +++ b/NMS/pom.xml @@ -0,0 +1,34 @@ + + + + ExcellentEnchants + su.nightexpress.excellentenchants + 3.1.0 + + 4.0.0 + + NMS + + + 16 + 16 + + + + + md_5-releases + https://repo.md-5.net/content/repositories/releases/ + + + + + + org.spigotmc + spigot-api + 1.18.1-R0.1-SNAPSHOT + + + + \ No newline at end of file diff --git a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java new file mode 100644 index 0000000..c675ddc --- /dev/null +++ b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java @@ -0,0 +1,13 @@ +package su.nightexpress.excellentenchants.nms; + +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +public interface EnchantNMS { + + @NotNull Set handleFlameWalker(@NotNull LivingEntity entity, @NotNull Location location, int level); +} diff --git a/V1_16_R1/pom.xml b/V1_16_R1/pom.xml new file mode 100644 index 0000000..fd5b5d5 --- /dev/null +++ b/V1_16_R1/pom.xml @@ -0,0 +1,32 @@ + + + + ExcellentEnchants + su.nightexpress.excellentenchants + 3.1.0 + + 4.0.0 + + V1_16_R1 + + + 16 + 16 + + + + + org.spigotmc + spigot + 1.16.5-R0.1-SNAPSHOT + + + su.nightexpress.excellentenchants + NMS + 3.1.0 + + + + \ No newline at end of file diff --git a/V1_16_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_16_R3.java b/V1_16_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_16_R3.java new file mode 100644 index 0000000..3eddc29 --- /dev/null +++ b/V1_16_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_16_R3.java @@ -0,0 +1,51 @@ +package su.nightexpress.excellentenchants.nms; + +import net.minecraft.server.v1_16_R3.*; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_16_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_16_R3.event.CraftEventFactory; +import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.Set; + +public class V1_16_R3 implements EnchantNMS { + + @Override + @NotNull + public Set handleFlameWalker(@NotNull LivingEntity entity1, @NotNull Location location, int level) { + EntityLiving entity = ((CraftLivingEntity) entity1).getHandle(); + BlockPosition pos = new BlockPosition(location.getX(), location.getY(), location.getZ()); + World world = ((CraftWorld) entity1.getWorld()).getHandle(); + + IBlockData bStone = Blocks.MAGMA_BLOCK.getBlockData(); + float rad = Math.min(16, 2 + level); + + BlockPosition.MutableBlockPosition posMut = new BlockPosition.MutableBlockPosition(); + Set blocks = new HashSet<>(); + for (BlockPosition bNear : BlockPosition.a(pos.a(-rad, -1.0, -rad), pos.a(rad, -1.0, rad))) { + + if (!bNear.a(entity.getPositionVector(), rad)) continue; + posMut.d(bNear.getX(), bNear.getY() + 1, bNear.getZ()); + + IBlockData bLavaUp = world.getType(posMut); + IBlockData bLava = world.getType(bNear); + + if (!bLavaUp.isAir()) continue; + if (bLava.getMaterial() != Material.LAVA) continue; + if (bLava.get(BlockFluids.LEVEL) != 0) continue; + if (!bStone.canPlace(world, bNear)) continue; + if (!world.a(bStone, bNear, VoxelShapeCollision.a())) continue; + if (!CraftEventFactory.handleBlockFormEvent(world, bNear, bStone, entity)) continue; + + world.getBlockTickList().a(bNear, Blocks.MAGMA_BLOCK, MathHelper.nextInt(entity.getRandom(), 60, 120)); + + Location loc2 = new Location(world.getWorld(), bNear.getX(), bNear.getY(), bNear.getZ()); + blocks.add(loc2.getBlock()); + } + return blocks; + } +} diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml new file mode 100644 index 0000000..66388b0 --- /dev/null +++ b/V1_17_R1/pom.xml @@ -0,0 +1,32 @@ + + + + ExcellentEnchants + su.nightexpress.excellentenchants + 3.1.0 + + 4.0.0 + + V1_17_R1 + + + 16 + 16 + + + + + org.spigotmc + spigot + 1.17.1-R0.1-SNAPSHOT + + + su.nightexpress.excellentenchants + NMS + 3.1.0 + + + + \ No newline at end of file diff --git a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_17_R1.java b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_17_R1.java new file mode 100644 index 0000000..0476c3b --- /dev/null +++ b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_17_R1.java @@ -0,0 +1,62 @@ +package su.nightexpress.excellentenchants.nms; + +import net.minecraft.core.BlockPosition; +import net.minecraft.util.MathHelper; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.World; +import net.minecraft.world.level.block.BlockFluids; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.IBlockData; +import net.minecraft.world.phys.shapes.VoxelShapeCollision; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory; +import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.utils.random.Rnd; + +import java.util.HashSet; +import java.util.Set; + +public class V1_17_R1 implements EnchantNMS { + + @Override + @NotNull + public Set handleFlameWalker(@NotNull LivingEntity entity1, @NotNull Location location, int level) { + Entity entity = ((CraftLivingEntity) entity1).getHandle(); + BlockPosition pos = new BlockPosition(location.getX(), location.getY(), location.getZ()); + World world = ((CraftWorld) entity1.getWorld()).getHandle(); + + IBlockData bStone = Blocks.iX.getBlockData(); + float rad = Math.min(16, 2 + level); + + org.bukkit.World w1 = entity1.getWorld(); + + BlockPosition.MutableBlockPosition posMut = new BlockPosition.MutableBlockPosition(); + Set blocks = new HashSet<>(); + for (BlockPosition bNear : BlockPosition.a(pos.b(-rad, -1.0, -rad), pos.b(rad, -1.0, rad))) { + if (!bNear.a(entity.getPositionVector(), rad)) continue; + posMut.d(bNear.getX(), bNear.getY() + 1, bNear.getZ()); + + IBlockData bLavaUp = world.getType(posMut); + IBlockData bLava = world.getType(bNear); + + if (!bLavaUp.isAir()) continue; + // меня заебало нахуй искать и подбирать ебучую лаву в NMS + Block normal = w1.getBlockAt(bNear.getX(), bNear.getY(), bNear.getZ()); + if (normal.getType() != org.bukkit.Material.LAVA) continue; + if (bLava.get(BlockFluids.a) != 0) continue; + if (!bStone.canPlace(world, bNear)) continue; + if (!world.a(bStone, bNear, VoxelShapeCollision.a())) continue; + if (!CraftEventFactory.handleBlockFormEvent(world, bNear, bStone, entity)) continue; + + world.getBlockTickList().a(bNear, Blocks.iX, MathHelper.nextInt(Rnd.rnd, 60, 120)); + + Location loc2 = new Location(world.getWorld(), bNear.getX(), bNear.getY(), bNear.getZ()); + blocks.add(loc2.getBlock()); + } + return blocks; + } +} diff --git a/V1_18_R1/pom.xml b/V1_18_R1/pom.xml new file mode 100644 index 0000000..d1e71a9 --- /dev/null +++ b/V1_18_R1/pom.xml @@ -0,0 +1,32 @@ + + + + ExcellentEnchants + su.nightexpress.excellentenchants + 3.1.0 + + 4.0.0 + + V1_18_R1 + + + 16 + 16 + + + + + org.spigotmc + spigot + 1.18.1-R0.1-SNAPSHOT + + + su.nightexpress.excellentenchants + NMS + 3.1.0 + + + + \ No newline at end of file diff --git a/V1_18_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R1.java b/V1_18_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R1.java new file mode 100644 index 0000000..fdfe456 --- /dev/null +++ b/V1_18_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R1.java @@ -0,0 +1,61 @@ +package su.nightexpress.excellentenchants.nms; + +import net.minecraft.core.BlockPosition; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.ItemBow; +import net.minecraft.world.level.IWorldReader; +import net.minecraft.world.level.World; +import net.minecraft.world.level.block.BlockFluids; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.IBlockData; +import net.minecraft.world.phys.shapes.VoxelShapeCollision; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_18_R1.event.CraftEventFactory; +import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.Set; + +public class V1_18_R1 implements EnchantNMS { + + @Override + @NotNull + public Set handleFlameWalker(@NotNull LivingEntity entity1, @NotNull Location location, int level) { + Entity entity = ((CraftLivingEntity) entity1).getHandle(); + BlockPosition pos = new BlockPosition(location.getX(), location.getY(), location.getZ()); + World world = ((CraftWorld) entity1.getWorld()).getHandle(); + + IBlockData bStone = Blocks.iX.n(); + float rad = Math.min(16, 2 + level); + + org.bukkit.World w1 = entity1.getWorld(); + BlockPosition.MutableBlockPosition posMut = new BlockPosition.MutableBlockPosition(); + + Set blocks = new HashSet<>(); + for (BlockPosition bNear : BlockPosition.a(pos.a(-rad, -1.0, -rad), pos.a(rad, -1.0, rad))) { + if (!bNear.a(entity.cV(), rad)) continue; + posMut.d(bNear.u(), bNear.v() + 1, bNear.w()); + + IBlockData bLavaUp = world.a_(posMut); + IBlockData bLava = world.a_(bNear); + + if (!bLavaUp.g()) continue; + // меня заебало нахуй искать и подбирать ебучую лаву в NMS + Block normal = w1.getBlockAt(bNear.u(), bNear.v(), bNear.w()); + if (normal.getType() != org.bukkit.Material.LAVA) continue; + if (bLava.c(BlockFluids.a) != 0) continue; + if (!bStone.a((IWorldReader) world, bNear)) continue; + if (!world.a(bStone, bNear, VoxelShapeCollision.a())) continue; + if (!CraftEventFactory.handleBlockFormEvent(world, bNear, bStone, entity)) continue; + world.N().a(bNear, Blocks.iX); + + Location loc2 = new Location(world.getWorld(), bNear.u(), bNear.v(), bNear.w()); + blocks.add(loc2.getBlock()); + } + return blocks; + } +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..776567d --- /dev/null +++ b/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + su.nightexpress.excellentenchants + ExcellentEnchants + pom + 3.1.0 + + Core + NMS + V1_17_R1 + V1_16_R1 + V1_18_R1 + + + + 16 + 16 + + + + + su.nexmedia + NexEngine + 2.1.0 + + + su.nexmedia + NexEngine_CustomEffects + 1.0.0 + + + + \ No newline at end of file From 458c42b0565c79eae77dd90873301b919c795284 Mon Sep 17 00:00:00 2001 From: nulli0n <73139339+nulli0n@users.noreply.github.com> Date: Fri, 21 Jan 2022 19:29:56 +0500 Subject: [PATCH 02/69] Create LICENSE --- LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 26ffce5dad82752ab13d9dd60d705c45464ba814 Mon Sep 17 00:00:00 2001 From: nulli0n <73139339+nulli0n@users.noreply.github.com> Date: Fri, 21 Jan 2022 19:30:03 +0500 Subject: [PATCH 03/69] Create README.md --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..6d411e7 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# ExcellentEnchants-spigot From d45c174a38738535d5794c877d22e4853cc6af9e Mon Sep 17 00:00:00 2001 From: nulli0n Date: Sun, 23 Jan 2022 18:34:54 +0500 Subject: [PATCH 04/69] 3.1.1 --- Core/pom.xml | 10 +++++----- .../manager/tasks/EnchantEffectPassiveTask.java | 2 +- NMS/pom.xml | 2 +- V1_16_R1/pom.xml | 4 ++-- V1_17_R1/pom.xml | 4 ++-- V1_18_R1/pom.xml | 4 ++-- pom.xml | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 0416183..f814a4d 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.0 + 3.1.1 4.0.0 @@ -32,22 +32,22 @@ su.nightexpress.excellentenchants NMS - 3.1.0 + 3.1.1 su.nightexpress.excellentenchants V1_16_R1 - 3.1.0 + 3.1.1 su.nightexpress.excellentenchants V1_17_R1 - 3.1.0 + 3.1.1 su.nightexpress.excellentenchants V1_18_R1 - 3.1.0 + 3.1.1 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java index c9d35ce..d861dcb 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java @@ -12,7 +12,7 @@ import su.nightexpress.excellentenchants.config.Config; public class EnchantEffectPassiveTask extends AbstractEnchantPassiveTask { public EnchantEffectPassiveTask(@NotNull ExcellentEnchants plugin) { - super(plugin, Config.TASKS_PASSIVE_ENCHANTS_TICKS_INTERVAL, true); + super(plugin, Config.TASKS_PASSIVE_ENCHANTS_TICKS_INTERVAL, false); } @Override diff --git a/NMS/pom.xml b/NMS/pom.xml index 4cd50d2..e8315cb 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.0 + 3.1.1 4.0.0 diff --git a/V1_16_R1/pom.xml b/V1_16_R1/pom.xml index fd5b5d5..37d3b7b 100644 --- a/V1_16_R1/pom.xml +++ b/V1_16_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.0 + 3.1.1 4.0.0 @@ -25,7 +25,7 @@ su.nightexpress.excellentenchants NMS - 3.1.0 + 3.1.1 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 66388b0..8e7dd4b 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.0 + 3.1.1 4.0.0 @@ -25,7 +25,7 @@ su.nightexpress.excellentenchants NMS - 3.1.0 + 3.1.1 diff --git a/V1_18_R1/pom.xml b/V1_18_R1/pom.xml index d1e71a9..8c500fc 100644 --- a/V1_18_R1/pom.xml +++ b/V1_18_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.0 + 3.1.1 4.0.0 @@ -25,7 +25,7 @@ su.nightexpress.excellentenchants NMS - 3.1.0 + 3.1.1 diff --git a/pom.xml b/pom.xml index 776567d..1bfd7e6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.1.0 + 3.1.1 Core NMS From e8a5e7702684a2ec06f14d554744d0f889b3d5aa Mon Sep 17 00:00:00 2001 From: nulli0n Date: Sat, 5 Feb 2022 14:05:34 +0500 Subject: [PATCH 05/69] 3.1.2 --- Core/pom.xml | 10 +++++----- .../manager/enchants/armor/EnchantSaturation.java | 4 ++-- NMS/pom.xml | 2 +- V1_16_R1/pom.xml | 4 ++-- V1_17_R1/pom.xml | 4 ++-- V1_18_R1/pom.xml | 4 ++-- pom.xml | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index f814a4d..d794f21 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.1 + 3.1.2 4.0.0 @@ -32,22 +32,22 @@ su.nightexpress.excellentenchants NMS - 3.1.1 + 3.1.2 su.nightexpress.excellentenchants V1_16_R1 - 3.1.1 + 3.1.2 su.nightexpress.excellentenchants V1_17_R1 - 3.1.1 + 3.1.2 su.nightexpress.excellentenchants V1_18_R1 - 3.1.1 + 3.1.2 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java index 99b1e0e..3a8ceb2 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java @@ -66,7 +66,7 @@ public class EnchantSaturation extends IEnchantChanceTemplate implements Passive @Override @NotNull public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.ARMOR_TORSO; + return EnchantmentTarget.ARMOR_HEAD; } public final double getSaturationAmount(int level) { @@ -94,7 +94,7 @@ public class EnchantSaturation extends IEnchantChanceTemplate implements Passive class Task extends AbstractEnchantPassiveTask { public Task(@NotNull ExcellentEnchants plugin) { - super(plugin, saturationInterval, true); + super(plugin, saturationInterval, false); } @Override diff --git a/NMS/pom.xml b/NMS/pom.xml index e8315cb..a26caa0 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.1 + 3.1.2 4.0.0 diff --git a/V1_16_R1/pom.xml b/V1_16_R1/pom.xml index 37d3b7b..a65e14c 100644 --- a/V1_16_R1/pom.xml +++ b/V1_16_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.1 + 3.1.2 4.0.0 @@ -25,7 +25,7 @@ su.nightexpress.excellentenchants NMS - 3.1.1 + 3.1.2 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 8e7dd4b..0a99072 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.1 + 3.1.2 4.0.0 @@ -25,7 +25,7 @@ su.nightexpress.excellentenchants NMS - 3.1.1 + 3.1.2 diff --git a/V1_18_R1/pom.xml b/V1_18_R1/pom.xml index 8c500fc..5756503 100644 --- a/V1_18_R1/pom.xml +++ b/V1_18_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.1 + 3.1.2 4.0.0 @@ -25,7 +25,7 @@ su.nightexpress.excellentenchants NMS - 3.1.1 + 3.1.2 diff --git a/pom.xml b/pom.xml index 1bfd7e6..7662efd 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.1.1 + 3.1.2 Core NMS From 490c1c7c96f0597f23a29d0b02b0f8b1a340c0ce Mon Sep 17 00:00:00 2001 From: nulli0n Date: Thu, 3 Mar 2022 06:33:14 +0500 Subject: [PATCH 06/69] 3.1.3 + Mojang Mappings for NMS --- Core/pom.xml | 10 ++-- .../enchants/tool/EnchantTelekinesis.java | 14 +++-- .../listeners/EnchantGenericListener.java | 26 ++------ NMS/pom.xml | 2 +- V1_16_R1/pom.xml | 4 +- V1_17_R1/pom.xml | 43 +++++++++++++- .../excellentenchants/nms/V1_17_R1.java | 58 ++++++++---------- V1_18_R1/pom.xml | 43 +++++++++++++- .../excellentenchants/nms/V1_18_R1.java | 59 +++++++++---------- pom.xml | 9 +-- 10 files changed, 160 insertions(+), 108 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index d794f21..2e108f1 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.2 + 3.1.3 4.0.0 @@ -32,22 +32,22 @@ su.nightexpress.excellentenchants NMS - 3.1.2 + 3.1.3 su.nightexpress.excellentenchants V1_16_R1 - 3.1.2 + 3.1.3 su.nightexpress.excellentenchants V1_17_R1 - 3.1.2 + 3.1.3 su.nightexpress.excellentenchants V1_18_R1 - 3.1.2 + 3.1.3 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java index cb13694..195ed4b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java @@ -1,5 +1,7 @@ package su.nightexpress.excellentenchants.manager.enchants.tool; +import com.google.common.collect.Sets; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Chest; import org.bukkit.block.Container; @@ -23,10 +25,7 @@ import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.type.FitItemType; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.function.UnaryOperator; public class EnchantTelekinesis extends IEnchantChanceTemplate implements BlockBreakEnchant { @@ -38,6 +37,12 @@ public class EnchantTelekinesis extends IEnchantChanceTemplate implements BlockB private final String messageItemSeparator; public static final String ID = "telekinesis"; + private static final Set INFESTED = Sets.newHashSet( + Material.INFESTED_CHISELED_STONE_BRICKS, Material.INFESTED_COBBLESTONE, + Material.INFESTED_CRACKED_STONE_BRICKS, Material.INFESTED_DEEPSLATE, + Material.INFESTED_MOSSY_STONE_BRICKS, Material.INFESTED_STONE, + Material.INFESTED_STONE_BRICKS + ); public EnchantTelekinesis(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.HIGHEST); @@ -85,6 +90,7 @@ public class EnchantTelekinesis extends IEnchantChanceTemplate implements BlockB public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isEnchantmentAvailable(player)) return false; if (e.getBlock().getState() instanceof Container) return false; + if (INFESTED.contains(e.getBlock().getType())) return false; if (!e.isDropItems()) return false; if (!this.checkTriggerChance(level)) return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java index 17beea8..3850130 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java @@ -2,10 +2,7 @@ package su.nightexpress.excellentenchants.manager.listeners; import org.bukkit.Material; import org.bukkit.block.Chest; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Minecart; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.enchantment.EnchantItemEvent; @@ -259,25 +256,12 @@ public class EnchantGenericListener extends AbstractListener EntityEquipment equipment = entity.getEquipment(); if (equipment == null) return; - ItemStack[] armor = equipment.getArmorContents(); - for (ItemStack item : armor) { - if (item != null && EnchantManager.isEnchantable(item)) { + for (EquipmentSlot slot : EquipmentSlot.values()) { + ItemStack item = equipment.getItem(slot); + if (EnchantManager.isEnchantable(item)) { EnchantManager.populateEnchantments(item, ObtainType.MOB_SPAWNING); + equipment.setItem(slot, item); } } - - ItemStack itemMain = equipment.getItemInMainHand(); - if (EnchantManager.isEnchantable(itemMain)) { - EnchantManager.populateEnchantments(itemMain, ObtainType.MOB_SPAWNING); - } - - ItemStack itemOff = equipment.getItemInOffHand(); - if (EnchantManager.isEnchantable(itemOff)) { - EnchantManager.populateEnchantments(itemOff, ObtainType.MOB_SPAWNING); - } - - equipment.setArmorContents(armor); - equipment.setItemInMainHand(itemMain); - equipment.setItemInOffHand(itemOff); } } diff --git a/NMS/pom.xml b/NMS/pom.xml index a26caa0..762bf93 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.2 + 3.1.3 4.0.0 diff --git a/V1_16_R1/pom.xml b/V1_16_R1/pom.xml index a65e14c..6d2fad1 100644 --- a/V1_16_R1/pom.xml +++ b/V1_16_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.2 + 3.1.3 4.0.0 @@ -25,7 +25,7 @@ su.nightexpress.excellentenchants NMS - 3.1.2 + 3.1.3 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 0a99072..87a9bd3 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.2 + 3.1.3 4.0.0 @@ -21,12 +21,51 @@ org.spigotmc spigot 1.17.1-R0.1-SNAPSHOT + remapped-mojang su.nightexpress.excellentenchants NMS - 3.1.2 + 3.1.3 + + + + net.md-5 + specialsource-maven-plugin + 1.2.3 + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:1.17.1-R0.1-SNAPSHOT:txt:maps-mojang + true + org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT:jar:remapped-mojang + true + remapped-obf + + + + package + + remap + + remap-spigot + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:1.17.1-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT:jar:remapped-obf + + + + + + + \ No newline at end of file diff --git a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_17_R1.java b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_17_R1.java index 0476c3b..afdee7a 100644 --- a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_17_R1.java +++ b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_17_R1.java @@ -1,13 +1,12 @@ package su.nightexpress.excellentenchants.nms; -import net.minecraft.core.BlockPosition; -import net.minecraft.util.MathHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.World; -import net.minecraft.world.level.block.BlockFluids; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.phys.shapes.VoxelShapeCollision; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; @@ -15,7 +14,6 @@ import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory; import org.bukkit.entity.LivingEntity; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.random.Rnd; import java.util.HashSet; import java.util.Set; @@ -24,38 +22,34 @@ public class V1_17_R1 implements EnchantNMS { @Override @NotNull - public Set handleFlameWalker(@NotNull LivingEntity entity1, @NotNull Location location, int level) { - Entity entity = ((CraftLivingEntity) entity1).getHandle(); - BlockPosition pos = new BlockPosition(location.getX(), location.getY(), location.getZ()); - World world = ((CraftWorld) entity1.getWorld()).getHandle(); + public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { + Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle(); + BlockPos pos = new BlockPos(location.getX(), location.getY(), location.getZ()); + ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle(); - IBlockData bStone = Blocks.iX.getBlockData(); - float rad = Math.min(16, 2 + level); + float radius = Math.min(16F, 2F + level); + BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState(); + BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos(); - org.bukkit.World w1 = entity1.getWorld(); - - BlockPosition.MutableBlockPosition posMut = new BlockPosition.MutableBlockPosition(); Set blocks = new HashSet<>(); - for (BlockPosition bNear : BlockPosition.a(pos.b(-rad, -1.0, -rad), pos.b(rad, -1.0, rad))) { - if (!bNear.a(entity.getPositionVector(), rad)) continue; - posMut.d(bNear.getX(), bNear.getY() + 1, bNear.getZ()); + for (BlockPos posNear : BlockPos.betweenClosed(pos.b(-radius, -1.0, -radius), pos.b(radius, -1.0, radius))) { + if (!posNear.closerThan(entity.position(), radius)) continue; - IBlockData bLavaUp = world.getType(posMut); - IBlockData bLava = world.getType(bNear); + posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ()); - if (!bLavaUp.isAir()) continue; - // меня заебало нахуй искать и подбирать ебучую лаву в NMS - Block normal = w1.getBlockAt(bNear.getX(), bNear.getY(), bNear.getZ()); - if (normal.getType() != org.bukkit.Material.LAVA) continue; - if (bLava.get(BlockFluids.a) != 0) continue; - if (!bStone.canPlace(world, bNear)) continue; - if (!world.a(bStone, bNear, VoxelShapeCollision.a())) continue; - if (!CraftEventFactory.handleBlockFormEvent(world, bNear, bStone, entity)) continue; + BlockState bLavaAbove = world.getBlockState(posAbove); + BlockState bLava = world.getBlockState(posNear); - world.getBlockTickList().a(bNear, Blocks.iX, MathHelper.nextInt(Rnd.rnd, 60, 120)); + if (!bLavaAbove.isAir()) continue; + if (!bLava.getBlock().equals(Blocks.LAVA)) continue; + if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue; + if (!bStone.canSurvive(world, posNear)) continue; + if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue; + if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue; + //world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120)); - Location loc2 = new Location(world.getWorld(), bNear.getX(), bNear.getY(), bNear.getZ()); - blocks.add(loc2.getBlock()); + Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ()); + blocks.add(bukkitLoc.getBlock()); } return blocks; } diff --git a/V1_18_R1/pom.xml b/V1_18_R1/pom.xml index 5756503..d09958f 100644 --- a/V1_18_R1/pom.xml +++ b/V1_18_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.2 + 3.1.3 4.0.0 @@ -21,12 +21,51 @@ org.spigotmc spigot 1.18.1-R0.1-SNAPSHOT + remapped-mojang su.nightexpress.excellentenchants NMS - 3.1.2 + 3.1.3 + + + + net.md-5 + specialsource-maven-plugin + 1.2.3 + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:1.18.1-R0.1-SNAPSHOT:txt:maps-mojang + true + org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT:jar:remapped-mojang + true + remapped-obf + + + + package + + remap + + remap-spigot + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:1.18.1-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT:jar:remapped-obf + + + + + + + \ No newline at end of file diff --git a/V1_18_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R1.java b/V1_18_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R1.java index fdfe456..e12c7ed 100644 --- a/V1_18_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R1.java +++ b/V1_18_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R1.java @@ -1,14 +1,12 @@ package su.nightexpress.excellentenchants.nms; -import net.minecraft.core.BlockPosition; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; -import net.minecraft.world.item.ItemBow; -import net.minecraft.world.level.IWorldReader; -import net.minecraft.world.level.World; -import net.minecraft.world.level.block.BlockFluids; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.phys.shapes.VoxelShapeCollision; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; @@ -24,37 +22,34 @@ public class V1_18_R1 implements EnchantNMS { @Override @NotNull - public Set handleFlameWalker(@NotNull LivingEntity entity1, @NotNull Location location, int level) { - Entity entity = ((CraftLivingEntity) entity1).getHandle(); - BlockPosition pos = new BlockPosition(location.getX(), location.getY(), location.getZ()); - World world = ((CraftWorld) entity1.getWorld()).getHandle(); + public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { + Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle(); + BlockPos pos = new BlockPos(location.getX(), location.getY(), location.getZ()); + ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle(); - IBlockData bStone = Blocks.iX.n(); - float rad = Math.min(16, 2 + level); - - org.bukkit.World w1 = entity1.getWorld(); - BlockPosition.MutableBlockPosition posMut = new BlockPosition.MutableBlockPosition(); + float radius = Math.min(16F, 2F + level); + BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState(); + BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos(); Set blocks = new HashSet<>(); - for (BlockPosition bNear : BlockPosition.a(pos.a(-rad, -1.0, -rad), pos.a(rad, -1.0, rad))) { - if (!bNear.a(entity.cV(), rad)) continue; - posMut.d(bNear.u(), bNear.v() + 1, bNear.w()); + for (BlockPos posNear : BlockPos.betweenClosed(pos.offset(-radius, -1.0, -radius), pos.offset(radius, -1.0, radius))) { + if (!posNear.closerThan(entity.position(), radius)) continue; - IBlockData bLavaUp = world.a_(posMut); - IBlockData bLava = world.a_(bNear); + posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ()); - if (!bLavaUp.g()) continue; - // меня заебало нахуй искать и подбирать ебучую лаву в NMS - Block normal = w1.getBlockAt(bNear.u(), bNear.v(), bNear.w()); - if (normal.getType() != org.bukkit.Material.LAVA) continue; - if (bLava.c(BlockFluids.a) != 0) continue; - if (!bStone.a((IWorldReader) world, bNear)) continue; - if (!world.a(bStone, bNear, VoxelShapeCollision.a())) continue; - if (!CraftEventFactory.handleBlockFormEvent(world, bNear, bStone, entity)) continue; - world.N().a(bNear, Blocks.iX); + BlockState bLavaAbove = world.getBlockState(posAbove); + BlockState bLava = world.getBlockState(posNear); - Location loc2 = new Location(world.getWorld(), bNear.u(), bNear.v(), bNear.w()); - blocks.add(loc2.getBlock()); + if (!bLavaAbove.isAir()) continue; + if (!bLava.getBlock().equals(Blocks.LAVA)) continue; + if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue; + if (!bStone.canSurvive(world, posNear)) continue; + if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue; + if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue; + //world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120)); + + Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ()); + blocks.add(bukkitLoc.getBlock()); } return blocks; } diff --git a/pom.xml b/pom.xml index 7662efd..0550c12 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.1.2 + 3.1.3 Core NMS @@ -25,12 +25,7 @@ su.nexmedia NexEngine - 2.1.0 - - - su.nexmedia - NexEngine_CustomEffects - 1.0.0 + 2.1.1 From 4660245bc8f17bd413b057969d78117afec1f38e Mon Sep 17 00:00:00 2001 From: nulli0n Date: Sun, 6 Mar 2022 13:06:16 +0500 Subject: [PATCH 07/69] 1.18.2 Support --- V1_18_R2/pom.xml | 71 +++++++++++++++++++ .../excellentenchants/nms/V1_18_R2.java | 56 +++++++++++++++ pom.xml | 3 +- 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 V1_18_R2/pom.xml create mode 100644 V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R2.java diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml new file mode 100644 index 0000000..f6e3eb8 --- /dev/null +++ b/V1_18_R2/pom.xml @@ -0,0 +1,71 @@ + + + + ExcellentEnchants + su.nightexpress.excellentenchants + 3.1.4 + + 4.0.0 + + V1_18_R2 + + + 16 + 16 + + + + + org.spigotmc + spigot + 1.18.2-R0.1-SNAPSHOT + remapped-mojang + + + su.nightexpress.excellentenchants + NMS + 3.1.4 + + + + + + + net.md-5 + specialsource-maven-plugin + 1.2.3 + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:txt:maps-mojang + true + org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-mojang + true + remapped-obf + + + + package + + remap + + remap-spigot + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-obf + + + + + + + + \ No newline at end of file diff --git a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R2.java b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R2.java new file mode 100644 index 0000000..abf9ab5 --- /dev/null +++ b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R2.java @@ -0,0 +1,56 @@ +package su.nightexpress.excellentenchants.nms; + +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory; +import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.Set; + +public class V1_18_R2 implements EnchantNMS { + + @Override + @NotNull + public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { + Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle(); + BlockPos pos = new BlockPos(location.getX(), location.getY(), location.getZ()); + ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle(); + + float radius = Math.min(16F, 2F + level); + BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState(); + BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos(); + + Set blocks = new HashSet<>(); + for (BlockPos posNear : BlockPos.betweenClosed(pos.offset(-radius, -1.0, -radius), pos.offset(radius, -1.0, radius))) { + if (!posNear.closerThan(entity.blockPosition(), radius)) continue; + + posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ()); + + BlockState bLavaAbove = world.getBlockState(posAbove); + BlockState bLava = world.getBlockState(posNear); + + if (!bLavaAbove.isAir()) continue; + if (!bLava.getBlock().equals(Blocks.LAVA)) continue; + if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue; + if (!bStone.canSurvive(world, posNear)) continue; + if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue; + if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue; + //world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120)); + + Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ()); + blocks.add(bukkitLoc.getBlock()); + } + return blocks; + } +} diff --git a/pom.xml b/pom.xml index 0550c12..8c4a448 100644 --- a/pom.xml +++ b/pom.xml @@ -7,13 +7,14 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.1.3 + 3.1.4 Core NMS V1_17_R1 V1_16_R1 V1_18_R1 + V1_18_R2 From 9a8a909378cc91f5ba5d93d7108b3262e379cfdd Mon Sep 17 00:00:00 2001 From: nulli0n Date: Sun, 6 Mar 2022 13:07:39 +0500 Subject: [PATCH 08/69] 1.18.2 Support --- Core/pom.xml | 15 ++++++++++----- NMS/pom.xml | 2 +- V1_16_R1/pom.xml | 4 ++-- V1_17_R1/pom.xml | 4 ++-- V1_18_R1/pom.xml | 4 ++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 2e108f1..0521238 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.3 + 3.1.4 4.0.0 @@ -32,22 +32,27 @@ su.nightexpress.excellentenchants NMS - 3.1.3 + 3.1.4 su.nightexpress.excellentenchants V1_16_R1 - 3.1.3 + 3.1.4 su.nightexpress.excellentenchants V1_17_R1 - 3.1.3 + 3.1.4 su.nightexpress.excellentenchants V1_18_R1 - 3.1.3 + 3.1.4 + + + su.nightexpress.excellentenchants + V1_18_R2 + 3.1.4 fr.neatmonster diff --git a/NMS/pom.xml b/NMS/pom.xml index 762bf93..c200153 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.3 + 3.1.4 4.0.0 diff --git a/V1_16_R1/pom.xml b/V1_16_R1/pom.xml index 6d2fad1..6427e28 100644 --- a/V1_16_R1/pom.xml +++ b/V1_16_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.3 + 3.1.4 4.0.0 @@ -25,7 +25,7 @@ su.nightexpress.excellentenchants NMS - 3.1.3 + 3.1.4 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 87a9bd3..6ea668b 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.3 + 3.1.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.1.3 + 3.1.4 diff --git a/V1_18_R1/pom.xml b/V1_18_R1/pom.xml index d09958f..6405e2f 100644 --- a/V1_18_R1/pom.xml +++ b/V1_18_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.3 + 3.1.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.1.3 + 3.1.4 From 66970daa246e99da64cd0ebbafafca41b9d4648e Mon Sep 17 00:00:00 2001 From: nulli0n Date: Sat, 16 Apr 2022 14:27:39 +0600 Subject: [PATCH 09/69] 3.2.0 --- Core/pom.xml | 12 +-- .../excellentenchants/ExcellentEnchants.java | 15 --- .../nightexpress/excellentenchants/Perms.java | 10 +- .../api/enchantment/EnchantDropContainer.java | 29 ++++++ .../api/enchantment/ExcellentEnchant.java | 4 +- .../enchantment/type/BlockDropEnchant.java | 11 +++ .../enchantment/type/CustomDropEnchant.java | 8 +- .../command/BookCommand.java | 14 +-- .../command/EnchantCommand.java | 18 ++-- .../command/ListCommand.java | 2 +- .../command/TierbookCommand.java | 14 +-- .../excellentenchants/config/Lang.java | 5 - .../manager/EnchantManager.java | 11 --- .../manager/EnchantRegister.java | 12 ++- .../manager/enchants/bow/EnchantBomber.java | 2 + .../enchants/bow/EnchantConfusingArrows.java | 17 ++++ .../enchants/bow/EnchantDragonfireArrows.java | 82 ++++++++++++++++ .../bow/EnchantElectrifiedArrows.java | 59 +++++++++++ .../manager/enchants/bow/EnchantEnderBow.java | 2 + .../enchants/bow/EnchantExplosiveArrows.java | 11 +++ .../manager/enchants/bow/EnchantGhast.java | 2 + .../manager/enchants/bow/EnchantHover.java | 17 ++++ .../enchants/bow/EnchantPoisonedArrows.java | 11 +++ .../enchants/bow/EnchantWitheredArrows.java | 11 +++ .../tool/EnchantCurseOfMisfortune.java | 3 +- .../enchants/tool/EnchantDivineTouch.java | 68 ++++++------- .../enchants/tool/EnchantSilkChest.java | 58 +++++------ .../manager/enchants/tool/EnchantSmelter.java | 87 ++++++---------- .../enchants/tool/EnchantTelekinesis.java | 98 ++++--------------- .../enchants/tool/EnchantTreasures.java | 69 +++++-------- .../enchants/weapon/EnchantTemper.java | 90 +++++++++++++++++ .../listeners/EnchantGenericListener.java | 2 +- .../listeners/EnchantHandlerListener.java | 24 +++++ .../manager/object/EnchantListGUI.java | 3 +- .../manager/object/EnchantTier.java | 6 +- .../resources/enchants/confusing_arrows.yml | 32 ++++++ .../resources/enchants/dragonfire_arrows.yml | 35 +++++++ .../resources/enchants/electrified_arrows.yml | 33 +++++++ Core/src/main/resources/enchants/hover.yml | 31 ++++++ Core/src/main/resources/enchants/temper.yml | 34 +++++++ Core/src/main/resources/lang/messages_es.yml | 18 ++++ NMS/pom.xml | 2 +- V1_16_R1/pom.xml | 4 +- V1_17_R1/pom.xml | 4 +- V1_18_R1/pom.xml | 4 +- V1_18_R2/pom.xml | 4 +- pom.xml | 4 +- 47 files changed, 743 insertions(+), 349 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantDropContainer.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockDropEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantConfusingArrows.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantHover.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantTemper.java create mode 100644 Core/src/main/resources/enchants/confusing_arrows.yml create mode 100644 Core/src/main/resources/enchants/dragonfire_arrows.yml create mode 100644 Core/src/main/resources/enchants/electrified_arrows.yml create mode 100644 Core/src/main/resources/enchants/hover.yml create mode 100644 Core/src/main/resources/enchants/temper.yml create mode 100644 Core/src/main/resources/lang/messages_es.yml diff --git a/Core/pom.xml b/Core/pom.xml index 0521238..5abfa79 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.4 + 3.2.0 4.0.0 @@ -32,27 +32,27 @@ su.nightexpress.excellentenchants NMS - 3.1.4 + 3.2.0 su.nightexpress.excellentenchants V1_16_R1 - 3.1.4 + 3.2.0 su.nightexpress.excellentenchants V1_17_R1 - 3.1.4 + 3.2.0 su.nightexpress.excellentenchants V1_18_R1 - 3.1.4 + 3.2.0 su.nightexpress.excellentenchants V1_18_R2 - 3.1.4 + 3.2.0 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index a62b0c8..e2408e1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -16,8 +16,6 @@ import su.nightexpress.excellentenchants.nms.EnchantNMS; public class ExcellentEnchants extends NexPlugin { - private static ExcellentEnchants instance; - public static boolean isLoaded = false; private Config config; @@ -26,14 +24,6 @@ public class ExcellentEnchants extends NexPlugin { private EnchantNMS enchantNMS; private EnchantManager enchantManager; - public ExcellentEnchants() { - instance = this; - } - - public static ExcellentEnchants getInstance() { - return instance; - } - @Override public void enable() { if (!this.setNMS()) { @@ -54,11 +44,6 @@ public class ExcellentEnchants extends NexPlugin { } } - @Override - public boolean useNewConfigFields() { - return true; - } - private boolean setNMS() { Version current = Version.CURRENT; if (current == null) return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java b/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java index 7d190b2..463cfd5 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java @@ -4,12 +4,12 @@ public class Perms { public static final String PREFIX = "excellentenchants."; - public static final String ADMIN = PREFIX + "admin"; - public static final String USER = PREFIX + "user"; + //public static final String ADMIN = PREFIX + "admin"; + //public static final String USER = PREFIX + "user"; - public static final String COMMAND_BOOK = PREFIX + "command.book"; - public static final String COMMAND_ENCHANT = PREFIX + "command.enchant"; - public static final String COMMAND_LIST = PREFIX + "command.list"; + public static final String COMMAND_BOOK = PREFIX + "command.book"; + public static final String COMMAND_ENCHANT = PREFIX + "command.enchant"; + public static final String COMMAND_LIST = PREFIX + "command.list"; public static final String COMMAND_TIERBOOK = PREFIX + "command.tierbook"; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantDropContainer.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantDropContainer.java new file mode 100644 index 0000000..028bfbd --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantDropContainer.java @@ -0,0 +1,29 @@ +package su.nightexpress.excellentenchants.api.enchantment; + +import org.bukkit.event.block.BlockDropItemEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +public class EnchantDropContainer { + + private final BlockDropItemEvent parent; + private final List drop; + + public EnchantDropContainer(@NotNull BlockDropItemEvent parent) { + this.parent = parent; + this.drop = new ArrayList<>(); + } + + @NotNull + public BlockDropItemEvent getParent() { + return parent; + } + + @NotNull + public List getDrop() { + return drop; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index 31729ee..af6adc5 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -118,7 +118,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener @NotNull public UnaryOperator replacePlaceholders(int level) { - String conflicts = this.getConflicts().isEmpty() ? plugin.lang().Other_None.getMsg() : this.getConflicts().stream().filter(Objects::nonNull).map(en -> plugin.lang().getEnchantment(en)).collect(Collectors.joining("\n")); + String conflicts = this.getConflicts().isEmpty() ? plugin.lang().Other_None.getLocalized() : this.getConflicts().stream().filter(Objects::nonNull).map(en -> plugin.lang().getEnchantment(en)).collect(Collectors.joining("\n")); return str -> str .replace(PLACEHOLDER_NAME, this.getDisplayName()) @@ -135,7 +135,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener .replace(PLACEHOLDER_OBTAIN_CHANCE_LOOT_GENERATION, NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION))) .replace(PLACEHOLDER_OBTAIN_CHANCE_FISHING, NumberUtil.format(this.getObtainChance(ObtainType.FISHING))) .replace(PLACEHOLDER_OBTAIN_CHANCE_MOB_SPAWNING, NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING))) - .replace(PLACEHOLDER_COST_ITEM, this.hasCostItem() ? ItemUtil.getItemName(this.costItem) : plugin.lang().Other_None.getMsg()) + .replace(PLACEHOLDER_COST_ITEM, this.hasCostItem() ? ItemUtil.getItemName(this.costItem) : plugin.lang().Other_None.getLocalized()) ; } 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 new file mode 100644 index 0000000..f732314 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockDropEnchant.java @@ -0,0 +1,11 @@ +package su.nightexpress.excellentenchants.api.enchantment.type; + +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockDropItemEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public interface BlockDropEnchant { + + boolean use(@NotNull BlockDropItemEvent e, @NotNull Player player, @NotNull ItemStack item, int level); +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CustomDropEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CustomDropEnchant.java index 1d0607e..14212ae 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CustomDropEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CustomDropEnchant.java @@ -1,15 +1,11 @@ package su.nightexpress.excellentenchants.api.enchantment.type; -import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; - -import java.util.List; +import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; public interface CustomDropEnchant { - @NotNull List getCustomDrops(@NotNull Player player, @NotNull ItemStack item, @NotNull Block block, int level); - - boolean isEventMustHaveDrops(); + void handleDrop(@NotNull EnchantDropContainer e, @NotNull Player player, @NotNull ItemStack item, int level); } 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 160feb9..d8858a0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java @@ -28,13 +28,13 @@ public class BookCommand extends AbstractCommand { @Override @NotNull public String getDescription() { - return plugin.lang().Command_Book_Desc.getMsg(); + return plugin.lang().Command_Book_Desc.getLocalized(); } @Override @NotNull public String getUsage() { - return plugin.lang().Command_Book_Usage.getMsg(); + return plugin.lang().Command_Book_Usage.getLocalized(); } @Override @@ -44,17 +44,17 @@ public class BookCommand extends AbstractCommand { @Override @NotNull - public List getTab(@NotNull Player player, int i, @NotNull String[] args) { - if (i == 1) { + public List getTab(@NotNull Player player, int arg, @NotNull String[] args) { + if (arg == 1) { return PlayerUtil.getPlayerNames(); } - if (i == 2) { + if (arg == 2) { return Arrays.stream(Enchantment.values()).map(e -> e.getKey().getKey()).toList(); } - if (i == 3) { + if (arg == 3) { return Arrays.asList("-1", "1", "5", "10"); } - return super.getTab(player, i, args); + return super.getTab(player, arg, args); } @Override 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 5f434f7..4994243 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java @@ -27,13 +27,13 @@ public class EnchantCommand extends AbstractCommand { @Override @NotNull public String getDescription() { - return plugin.lang().Command_Enchant_Desc.getMsg(); + return plugin.lang().Command_Enchant_Desc.getLocalized(); } @Override @NotNull public String getUsage() { - return plugin.lang().Command_Enchant_Usage.getMsg(); + return plugin.lang().Command_Enchant_Usage.getLocalized(); } @Override @@ -43,14 +43,14 @@ public class EnchantCommand extends AbstractCommand { @Override @NotNull - public List getTab(@NotNull Player player, int i, @NotNull String[] args) { - if (i == 1) { + public List getTab(@NotNull Player player, int arg, @NotNull String[] args) { + if (arg == 1) { return Arrays.stream(Enchantment.values()).map(e -> e.getKey().getKey()).toList(); } - if (i == 2) { + if (arg == 2) { return Arrays.asList("-1", "1", "5", "10"); } - return super.getTab(player, i, args); + return super.getTab(player, arg, args); } @Override @@ -81,12 +81,12 @@ public class EnchantCommand extends AbstractCommand { ItemMeta meta = item.getItemMeta(); if (meta == null) return; - if (meta instanceof EnchantmentStorageMeta) { + if (meta instanceof EnchantmentStorageMeta storageMeta) { if (level == 0) { - ((EnchantmentStorageMeta) meta).removeStoredEnchant(enchantment); + storageMeta.removeStoredEnchant(enchantment); } else { - ((EnchantmentStorageMeta) meta).addStoredEnchant(enchantment, level, true); + storageMeta.addStoredEnchant(enchantment, level, true); } } else { 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 b36c606..7bbb89f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/ListCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/ListCommand.java @@ -22,7 +22,7 @@ public class ListCommand extends AbstractCommand { @Override @NotNull public String getDescription() { - return plugin.lang().Command_List_Desc.getMsg(); + return plugin.lang().Command_List_Desc.getLocalized(); } @Override 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 a6b835a..9d2bf8b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java @@ -27,13 +27,13 @@ public class TierbookCommand extends AbstractCommand { @Override @NotNull public String getDescription() { - return plugin.lang().Command_TierBook_Desc.getMsg(); + return plugin.lang().Command_TierBook_Desc.getLocalized(); } @Override @NotNull public String getUsage() { - return plugin.lang().Command_TierBook_Usage.getMsg(); + return plugin.lang().Command_TierBook_Usage.getLocalized(); } @Override @@ -43,17 +43,17 @@ public class TierbookCommand extends AbstractCommand { @Override @NotNull - public List getTab(@NotNull Player player, int i, @NotNull String[] args) { - if (i == 1) { + public List getTab(@NotNull Player player, int arg, @NotNull String[] args) { + if (arg == 1) { return PlayerUtil.getPlayerNames(); } - if (i == 2) { + if (arg == 2) { return EnchantManager.getTierIds(); } - if (i == 3) { + if (arg == 3) { return Arrays.asList("-1", "1", "5", "10"); } - return super.getTab(player, i, args); + return super.getTab(player, arg, args); } @Override 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 7c9029e..577da79 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java @@ -11,11 +11,6 @@ public class Lang extends CoreLang { public Lang(@NotNull ExcellentEnchants plugin) { super(plugin); - } - - @Override - public void setup() { - super.setup(); this.setupEnum(EnchantmentTarget.class); this.setupEnum(FitItemType.class); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java index ee3f595..7dfec7a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java @@ -123,17 +123,6 @@ public class EnchantManager extends AbstractManager { return true; } - @Deprecated - public static boolean hasEnchant(@NotNull ItemStack item, @NotNull Enchantment enchantment) { - return item.getEnchantmentLevel(enchantment) != 0; - } - - @Deprecated - public static int getEnchantLevel(@NotNull ItemStack item, @NotNull Enchantment enchantment) { - ItemMeta meta = item.getItemMeta(); - return meta != null ? meta.getEnchantLevel(enchantment) : item.getEnchantmentLevel(enchantment); - } - public static void updateItemLoreEnchants(@NotNull ItemStack item) { EnchantRegister.ENCHANT_LIST.forEach(ench -> { ItemUtil.delLore(item, ench.getId()); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java index 48f59d1..a87df44 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java @@ -58,6 +58,7 @@ public class EnchantRegister { public static final EnchantRage RAGE; public static final EnchantScavenger SCAVENGER; public static final EnchantSurprise SURPRISE; + public static final EnchantTemper TEMPER; public static final EnchantThrifty THRIFTY; public static final EnchantThunder THUNDER; public static final EnchantVillageDefender VILLAGE_DEFENDER; @@ -75,14 +76,18 @@ public class EnchantRegister { public static final EnchantRegrowth REGROWTH; public static final EnchantBomber BOMBER; + public static final EnchantConfusingArrows CONFUSING_ARROWS; + public static final EnchantDragonfireArrows DRAGONFIRE_ARROWS; + public static final EnchantElectrifiedArrows ELECTRIFIED_ARROWS; public static final EnchantEnderBow ENDER_BOW; public static final EnchantGhast GHAST; + public static final EnchantHover HOVER; public static final EnchantPoisonedArrows POISONED_ARROWS; public static final EnchantWitheredArrows WITHERED_ARROWS; public static final EnchantExplosiveArrows EXPLOSIVE_ARROWS; static { - PLUGIN = ExcellentEnchants.getInstance(); + PLUGIN = ExcellentEnchants.getPlugin(ExcellentEnchants.class); PLUGIN.getConfigManager().extract("enchants"); ENCHANT_LIST = new HashSet<>(); @@ -119,6 +124,7 @@ public class EnchantRegister { ROCKET = init(EnchantRocket.class, EnchantRocket.ID); SCAVENGER = init(EnchantScavenger.class, EnchantScavenger.ID); SURPRISE = init(EnchantSurprise.class, EnchantSurprise.ID); + TEMPER = init(EnchantTemper.class, EnchantTemper.ID); THRIFTY = init(EnchantThrifty.class, EnchantThrifty.ID); THUNDER = init(EnchantThunder.class, EnchantThunder.ID); VAMPIRE = init(EnchantVampire.class, EnchantVampire.ID); @@ -140,9 +146,13 @@ public class EnchantRegister { // Bow enchants BOMBER = init(EnchantBomber.class, EnchantBomber.ID); + CONFUSING_ARROWS = init(EnchantConfusingArrows.class, EnchantConfusingArrows.ID); + DRAGONFIRE_ARROWS = init(EnchantDragonfireArrows.class, EnchantDragonfireArrows.ID); + ELECTRIFIED_ARROWS = init(EnchantElectrifiedArrows.class, EnchantElectrifiedArrows.ID); ENDER_BOW = init(EnchantEnderBow.class, EnchantEnderBow.ID); EXPLOSIVE_ARROWS = init(EnchantExplosiveArrows.class, EnchantExplosiveArrows.ID); GHAST = init(EnchantGhast.class, EnchantGhast.ID); + HOVER = init(EnchantHover.class, EnchantHover.ID); POISONED_ARROWS = init(EnchantPoisonedArrows.class, EnchantPoisonedArrows.ID); WITHERED_ARROWS = init(EnchantWitheredArrows.class, EnchantWitheredArrows.ID); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java index d16f31f..938c335 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java @@ -62,6 +62,8 @@ public class EnchantBomber extends IEnchantChanceTemplate implements BowEnchant this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); this.addConflict(EnchantRegister.WITHERED_ARROWS); this.addConflict(EnchantRegister.POISONED_ARROWS); + this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); + this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); this.addConflict(Enchantment.ARROW_FIRE); this.addConflict(Enchantment.ARROW_DAMAGE); this.addConflict(Enchantment.ARROW_KNOCKBACK); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantConfusingArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantConfusingArrows.java new file mode 100644 index 0000000..e7391b9 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantConfusingArrows.java @@ -0,0 +1,17 @@ +package su.nightexpress.excellentenchants.manager.enchants.bow; + +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowPotionTemplate; + +public class EnchantConfusingArrows extends IEnchantBowPotionTemplate { + + public static final String ID = "confusing_arrows"; + + public EnchantConfusingArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.CONFUSION); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java new file mode 100644 index 0000000..98ac9ad --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java @@ -0,0 +1,82 @@ +package su.nightexpress.excellentenchants.manager.enchants.bow; + +import org.bukkit.Particle; +import org.bukkit.World; +import org.bukkit.entity.AreaEffectCloud; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowTemplate; +import su.nightexpress.excellentenchants.manager.EnchantRegister; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantDragonfireArrows extends IEnchantBowTemplate { + + public static final String ID = "dragonfire_arrows"; + + public static final String PLACEHOLDER_FIRE_RADIUS = "%enchantment_fire_radius%"; + public static final String PLACEHOLDER_FIRE_DURATION = "%enchantment_fire_duration%"; + + private final EnchantScaler fireDuration; + private final EnchantScaler fireRadius; + + public EnchantDragonfireArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.fireDuration = new EnchantScaler(this, "Settings.Fire.Duration"); + this.fireRadius = new EnchantScaler(this, "Settings.Fire.Radius"); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.CONFUSING_ARROWS); + this.addConflict(EnchantRegister.POISONED_ARROWS); + this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); + this.addConflict(EnchantRegister.WITHERED_ARROWS); + this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_FIRE_DURATION, NumberUtil.format(this.getFireDuration(level) / 20D)) + .replace(PLACEHOLDER_FIRE_RADIUS, NumberUtil.format(this.getFireRadius(level))) + ); + } + + public int getFireDuration(int level) { + return (int) this.fireDuration.getValue(level); + } + + public double getFireRadius(int level) { + return this.fireRadius.getValue(level); + } + + @Override + public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + if (!super.use(e, projectile, bow, level)) return false; + + World world = projectile.getWorld(); + AreaEffectCloud cloud = world.spawn(projectile.getLocation(), AreaEffectCloud.class); + cloud.clearCustomEffects(); + cloud.setSource(projectile.getShooter()); + cloud.setParticle(Particle.DRAGON_BREATH); + cloud.setRadius((float) this.getFireRadius(level)); + cloud.setDuration(this.getFireDuration(level)); + cloud.setRadiusPerTick((7.0F - cloud.getRadius()) / (float) cloud.getDuration()); + cloud.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 1, 1), true); + + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java new file mode 100644 index 0000000..3404daa --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java @@ -0,0 +1,59 @@ +package su.nightexpress.excellentenchants.manager.enchants.bow; + +import org.bukkit.Particle; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.LocationUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowTemplate; +import su.nightexpress.excellentenchants.manager.EnchantRegister; + +public class EnchantElectrifiedArrows extends IEnchantBowTemplate { + + public static final String ID = "electrified_arrows"; + + public EnchantElectrifiedArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.CONFUSING_ARROWS); + this.addConflict(EnchantRegister.POISONED_ARROWS); + this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); + this.addConflict(EnchantRegister.WITHERED_ARROWS); + this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); + } + + @Override + public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + if (!super.use(e, projectile, bow, level)) return false; + + Entity entity = e.getHitEntity(); + Block block = e.getHitBlock(); + + if (entity instanceof LivingEntity victim) { + plugin.getServer().getScheduler().runTask(plugin, () -> { + victim.setNoDamageTicks(0); + victim.getWorld().strikeLightning(victim.getLocation()); + }); + } + else if (block != null) { + block.getWorld().strikeLightning(block.getLocation()); + 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); + } + else return false; + + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java index 8c6b9df..a346bb5 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java @@ -33,6 +33,8 @@ public class EnchantEnderBow extends IEnchantChanceTemplate implements BowEnchan this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); this.addConflict(EnchantRegister.WITHERED_ARROWS); this.addConflict(EnchantRegister.POISONED_ARROWS); + this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); + this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); this.addConflict(Enchantment.ARROW_FIRE); this.addConflict(Enchantment.ARROW_DAMAGE); this.addConflict(Enchantment.ARROW_KNOCKBACK); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java index bbb5fb9..610815b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java @@ -18,6 +18,7 @@ import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowTemplate; +import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import java.util.function.UnaryOperator; @@ -51,6 +52,16 @@ public class EnchantExplosiveArrows extends IEnchantBowTemplate { this.cfg.addMissing("Settings.Explosion.Damage_Blocks", false); } + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.CONFUSING_ARROWS); + this.addConflict(EnchantRegister.POISONED_ARROWS); + this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); + this.addConflict(EnchantRegister.WITHERED_ARROWS); + this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); + } + @Override @NotNull public UnaryOperator replacePlaceholders(int level) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java index 5997474..6fb1057 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java @@ -50,6 +50,8 @@ public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); this.addConflict(EnchantRegister.WITHERED_ARROWS); this.addConflict(EnchantRegister.POISONED_ARROWS); + this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); + this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); this.addConflict(Enchantment.ARROW_FIRE); this.addConflict(Enchantment.ARROW_KNOCKBACK); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantHover.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantHover.java new file mode 100644 index 0000000..b708611 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantHover.java @@ -0,0 +1,17 @@ +package su.nightexpress.excellentenchants.manager.enchants.bow; + +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowPotionTemplate; + +public class EnchantHover extends IEnchantBowPotionTemplate { + + public static final String ID = "hover"; + + public EnchantHover(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.LEVITATION); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java index bf4527c..e229d98 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java @@ -6,6 +6,7 @@ import su.nexmedia.engine.api.config.JYML; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowPotionTemplate; +import su.nightexpress.excellentenchants.manager.EnchantRegister; public class EnchantPoisonedArrows extends IEnchantBowPotionTemplate { @@ -14,4 +15,14 @@ public class EnchantPoisonedArrows extends IEnchantBowPotionTemplate { public EnchantPoisonedArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.POISON); } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.CONFUSING_ARROWS); + this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); + this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); + this.addConflict(EnchantRegister.WITHERED_ARROWS); + this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java index ab6cb4e..4af06d7 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java @@ -6,6 +6,7 @@ import su.nexmedia.engine.api.config.JYML; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowPotionTemplate; +import su.nightexpress.excellentenchants.manager.EnchantRegister; public class EnchantWitheredArrows extends IEnchantBowPotionTemplate { @@ -14,4 +15,14 @@ public class EnchantWitheredArrows extends IEnchantBowPotionTemplate { public EnchantWitheredArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.WITHER); } + + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.CONFUSING_ARROWS); + this.addConflict(EnchantRegister.POISONED_ARROWS); + this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); + this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); + this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java index b9066c4..88655aa 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java @@ -22,7 +22,7 @@ public class EnchantCurseOfMisfortune extends IEnchantChanceTemplate implements public static final String ID = "curse_of_misfortune"; public EnchantCurseOfMisfortune(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.LOW); + super(plugin, cfg, EnchantPriority.LOWEST); this.dropExp = cfg.getBoolean("Settings.Drop_Exp"); } @@ -58,7 +58,6 @@ public class EnchantCurseOfMisfortune extends IEnchantChanceTemplate implements @Override public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isEnchantmentAvailable(player)) return false; - if (EnchantTelekinesis.isDropHandled(e.getBlock())) return false; if (!this.checkTriggerChance(level)) return false; if (!this.takeCostItem(player)) return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java index bb4ee1f..2f71947 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java @@ -3,23 +3,26 @@ package su.nightexpress.excellentenchants.manager.enchants.tool; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Particle; -import org.bukkit.World; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.block.CreatureSpawner; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BlockStateMeta; +import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.LocationUtil; import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; @@ -27,17 +30,15 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.type.FitItemType; -import java.util.Collections; -import java.util.List; - public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockBreakEnchant, CustomDropEnchant { + public static final String ID = "divine_touch"; + private static final String META_HANDLE = ID + "_handle"; + private final String particleName; private final String particleData; private final String spawnerName; - public static final String ID = "divine_touch"; - public EnchantDivineTouch(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); @@ -46,12 +47,6 @@ public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockB this.spawnerName = StringUtil.color(cfg.getString("Settings.Spawner_Item.Name", "&aMob Spawner &7(%type%)")); } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.SMELTER); - } - @Override protected void updateConfig() { super.updateConfig(); @@ -67,6 +62,12 @@ public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockB return new FitItemType[]{FitItemType.PICKAXE}; } + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(EnchantRegister.SMELTER); + } + @Override @NotNull public EnchantmentTarget getItemTarget() { @@ -90,36 +91,31 @@ public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockB } @Override - @NotNull - public List getCustomDrops(@NotNull Player player, @NotNull ItemStack item, @NotNull Block block, int level) { - if (!(block.getState() instanceof CreatureSpawner spawnerBlock)) return Collections.emptyList(); + public void handleDrop(@NotNull EnchantDropContainer e, @NotNull Player player, @NotNull ItemStack item, int level) { + BlockDropItemEvent parent = e.getParent(); + BlockState state = parent.getBlockState(); + Block block = state.getBlock(); + if (!block.hasMetadata(META_HANDLE)) return; + if (!(state instanceof CreatureSpawner spawnerBlock)) return; - return Collections.singletonList(this.getSpawner(spawnerBlock)); - } + e.getDrop().add(this.getSpawner(spawnerBlock)); - @Override - public boolean isEventMustHaveDrops() { - return false; + Location location = LocationUtil.getCenter(block.getLocation()); + EffectUtil.playEffect(location, this.particleName, this.particleData, 0.3f, 0.3f, 0.3f, 0.15f, 30); + block.removeMetadata(META_HANDLE, this.plugin); } @Override public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isEnchantmentAvailable(player)) return false; Block block = e.getBlock(); - if (EnchantTelekinesis.isDropHandled(block)) return false; + if (!this.isEnchantmentAvailable(player)) return false; if (!(block.getState() instanceof CreatureSpawner spawnerBlock)) return false; - if (this.isEventMustHaveDrops() && !e.isDropItems()) return false; if (!this.checkTriggerChance(level)) return false; if (!this.takeCostItem(player)) return false; - Location location = LocationUtil.getCenter(block.getLocation()); - World world = block.getWorld(); - - this.getCustomDrops(player, item, block, level).forEach(itemSpawner -> world.dropItemNaturally(location, itemSpawner)); - EffectUtil.playEffect(location, this.particleName, this.particleData, 0.3f, 0.3f, 0.3f, 0.15f, 30); - e.setExpToDrop(0); - e.setDropItems(false); + e.setDropItems(true); + block.setMetadata(META_HANDLE, new FixedMetadataValue(this.plugin, true)); return true; } @@ -130,16 +126,8 @@ public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockB if (block.getType() != Material.SPAWNER) return; Player player = e.getPlayer(); - ItemStack spawner = player.getInventory().getItemInMainHand(); - if (spawner.getType().isAir() || spawner.getType() != Material.SPAWNER) { - spawner = player.getInventory().getItemInOffHand(); - } - if (spawner.getType().isAir() || spawner.getType() != Material.SPAWNER) { - return; - } - - BlockStateMeta meta = (BlockStateMeta) spawner.getItemMeta(); - if (meta == null) return; + ItemStack spawner = player.getInventory().getItem(e.getHand()); + if (spawner.getType() != Material.SPAWNER || !(spawner.getItemMeta() instanceof BlockStateMeta meta)) return; CreatureSpawner spawnerItem = (CreatureSpawner) meta.getBlockState(); CreatureSpawner spawnerBlock = (CreatureSpawner) block.getState(); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java index bfa073a..7113a34 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java @@ -6,10 +6,11 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryPickupItemEvent; @@ -23,18 +24,16 @@ import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PDCUtil; import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; import su.nightexpress.excellentenchants.manager.type.FitItemType; -import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.TreeMap; -public class EnchantSilkChest extends IEnchantChanceTemplate implements BlockBreakEnchant, CustomDropEnchant { +public class EnchantSilkChest extends IEnchantChanceTemplate implements CustomDropEnchant { private final Map keyItems; private final String chestName; @@ -42,7 +41,7 @@ public class EnchantSilkChest extends IEnchantChanceTemplate implements BlockBre public static final String ID = "silk_chest"; public EnchantSilkChest(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + super(plugin, cfg, EnchantPriority.HIGH); this.keyItems = new TreeMap<>(); this.chestName = StringUtil.color(cfg.getString("Settings.Chest_Item.Name", "%name% &7(%items% items)")); @@ -78,8 +77,7 @@ public class EnchantSilkChest extends IEnchantChanceTemplate implements BlockBre @NotNull public ItemStack getSilkChest(@NotNull Chest chest) { - Block block = chest.getBlock(); - ItemStack chestItem = new ItemStack(block.getType()); + ItemStack chestItem = new ItemStack(chest.getType()); // Store and count chest items. int amount = 0; @@ -91,7 +89,7 @@ public class EnchantSilkChest extends IEnchantChanceTemplate implements BlockBre String base64 = ItemUtil.toBase64(itemInv); if (base64 == null) continue; if (base64.length() >= Short.MAX_VALUE) { - block.getWorld().dropItemNaturally(block.getLocation(), itemInv); + chest.getWorld().dropItemNaturally(chest.getLocation(), itemInv); continue; } PDCUtil.setData(chestItem, this.getItemKey(count++), base64); @@ -110,38 +108,26 @@ public class EnchantSilkChest extends IEnchantChanceTemplate implements BlockBre } @Override - @NotNull - public List getCustomDrops(@NotNull Player player, @NotNull ItemStack item, @NotNull Block block, int level) { - if (block.getType() == Material.ENDER_CHEST) return Collections.emptyList(); - if (!(block.getState() instanceof Chest chest)) return Collections.emptyList(); + public void handleDrop(@NotNull EnchantDropContainer e, @NotNull Player player, @NotNull ItemStack item, int level) { + BlockDropItemEvent parent = e.getParent(); + BlockState state = parent.getBlockState(); + Block block = state.getBlock(); - return Collections.singletonList(this.getSilkChest(chest)); - } + if (!this.isEnchantmentAvailable(player)) return; + if (!(state instanceof Chest chest)) return; + if (!this.checkTriggerChance(level)) return; + if (!this.takeCostItem(player)) return; - @Override - public boolean isEventMustHaveDrops() { - return true; - } + // Добавляем в сундук обратно предметы из дроп листа, кроме самого сундука. + parent.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType()); + chest.getBlockInventory().addItem(parent.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0])); - @Override - public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - Block block = e.getBlock(); - if (!this.isEnchantmentAvailable(player)) return false; - if (EnchantTelekinesis.isDropHandled(block)) return false; - if (block.getType() == Material.ENDER_CHEST) return false; - if (this.isEventMustHaveDrops() && !e.isDropItems()) return false; - if (!this.checkTriggerChance(level)) return false; - if (!(block.getState() instanceof Chest chest)) return false; - if (!this.takeCostItem(player)) return false; + // Добавляем кастомный сундук в кастомный дроп лист. + e.getDrop().add(this.getSilkChest(chest)); - // Drop custom chest and do not drop the original one. - this.getCustomDrops(player, item, block, level).forEach(chestItem -> block.getWorld().dropItemNaturally(block.getLocation(), chestItem)); - - // Do not drop chest items. + // Очищаем инвентарь сундука и дефолтный дроп лист. chest.getBlockInventory().clear(); - e.setDropItems(false); - - return true; + parent.getItems().clear(); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java index 3ba3fa3..08f3f79 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java @@ -2,11 +2,10 @@ package su.nightexpress.excellentenchants.manager.enchants.tool; import org.bukkit.*; 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.BlockBreakEvent; +import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; @@ -16,29 +15,26 @@ import su.nexmedia.engine.utils.MessageUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.type.FitItemType; -import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; -public class EnchantSmelter extends IEnchantChanceTemplate implements BlockBreakEnchant, CustomDropEnchant { +public class EnchantSmelter extends IEnchantChanceTemplate implements BlockDropEnchant { - private final String sound; + public static final String ID = "smelter"; + + private final Sound sound; private final String particleName; private final String particleData; private final Map smeltingTable; - public static final String ID = "smelter"; - public EnchantSmelter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); - this.sound = cfg.getString("Settings.Sound", ""); + this.sound = cfg.getEnum("Settings.Sound", Sound.class); this.particleName = cfg.getString("Settings.Particle.Name", Particle.FLAME.name()); this.particleData = cfg.getString("Settings.Particle.Data", ""); this.smeltingTable = new HashMap<>(); @@ -58,13 +54,6 @@ public class EnchantSmelter extends IEnchantChanceTemplate implements BlockBreak } } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(Enchantment.SILK_TOUCH); - this.addConflict(EnchantRegister.DIVINE_TOUCH); - } - @Override protected void updateConfig() { super.updateConfig(); @@ -81,6 +70,13 @@ public class EnchantSmelter extends IEnchantChanceTemplate implements BlockBreak return new FitItemType[]{FitItemType.PICKAXE, FitItemType.AXE, FitItemType.SHOVEL}; } + @Override + protected void addConflicts() { + super.addConflicts(); + this.addConflict(Enchantment.SILK_TOUCH); + this.addConflict(EnchantRegister.DIVINE_TOUCH); + } + @Override @NotNull public EnchantmentTarget getItemTarget() { @@ -88,57 +84,30 @@ public class EnchantSmelter extends IEnchantChanceTemplate implements BlockBreak } @Override - @NotNull - public List getCustomDrops(@NotNull Player player, @NotNull ItemStack item, @NotNull Block block, int level) { - if (block.getState() instanceof Container) return Collections.emptyList(); + public boolean use(@NotNull BlockDropItemEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isEnchantmentAvailable(player)) return false; + if (!this.checkTriggerChance(level)) return false; + if (e.getItems().stream().noneMatch(drop -> this.isSmeltable(drop.getItemStack().getType()))) return false; + if (!this.takeCostItem(player)) return false; - List drops = plugin.getNMS().getBlockDrops(block, player, item); - return this.smelt(drops); + e.getItems().forEach(drop -> { + Material material = this.smeltingTable.get(drop.getItemStack().getType()); + if (material != null) drop.getItemStack().setType(material); + }); + + Block block = e.getBlockState().getBlock(); + this.playEffect(block); + return true; } public boolean isSmeltable(@NotNull Material material) { return this.smeltingTable.containsKey(material); } - @NotNull - public List smelt(@NotNull List drops) { - return drops.stream().peek(drop -> { - Material material = this.smeltingTable.get(drop.getType()); - if (material != null) drop.setType(material); - }).toList(); - } - + @Deprecated public void playEffect(@NotNull Block block) { Location location = LocationUtil.getCenter(block.getLocation(), true); MessageUtil.sound(location, this.sound); EffectUtil.playEffect(location, this.particleName, this.particleData, 0.2f, 0.2f, 0.2f, 0.05f, 30); } - - @Override - public boolean isEventMustHaveDrops() { - return true; - } - - @Override - public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - Block block = e.getBlock(); - if (!this.isEnchantmentAvailable(player)) return false; - if (EnchantTelekinesis.isDropHandled(block)) return false; - if (this.isEventMustHaveDrops() && !e.isDropItems()) return false; - if (!this.checkTriggerChance(level)) return false; - - List defaults = plugin.getNMS().getBlockDrops(block, player, item); - List custom = this.getCustomDrops(player, item, block, level); - if (custom.isEmpty() || custom.containsAll(defaults)) return false; - if (!this.takeCostItem(player)) return false; - - e.setDropItems(false); - - World world = block.getWorld(); - Location location = LocationUtil.getCenter(block.getLocation(), true); - - custom.forEach(itemSmelt -> world.dropItem(location, itemSmelt)); - this.playEffect(block); - return true; - } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java index 195ed4b..79fd1db 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java @@ -1,15 +1,11 @@ package su.nightexpress.excellentenchants.manager.enchants.tool; -import com.google.common.collect.Sets; -import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.Chest; -import org.bukkit.block.Container; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Item; 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.config.JYML; import su.nexmedia.engine.api.config.LangMessage; @@ -17,35 +13,27 @@ import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PlayerUtil; import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.type.FitItemType; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; import java.util.function.UnaryOperator; -public class EnchantTelekinesis extends IEnchantChanceTemplate implements BlockBreakEnchant { - - public static final String META_BLOCK_DROP_HANDLER = "telekinesis_drop_handler"; +public class EnchantTelekinesis extends IEnchantChanceTemplate implements CustomDropEnchant { private final LangMessage messageDropReceived; private final String messageItemName; private final String messageItemSeparator; public static final String ID = "telekinesis"; - private static final Set INFESTED = Sets.newHashSet( - Material.INFESTED_CHISELED_STONE_BRICKS, Material.INFESTED_COBBLESTONE, - Material.INFESTED_CRACKED_STONE_BRICKS, Material.INFESTED_DEEPSLATE, - Material.INFESTED_MOSSY_STONE_BRICKS, Material.INFESTED_STONE, - Material.INFESTED_STONE_BRICKS - ); public EnchantTelekinesis(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.HIGHEST); + super(plugin, cfg, EnchantPriority.LOWEST); this.messageDropReceived = new LangMessage(plugin.lang(), cfg.getString("Settings.Message.Drop_Received", "")); this.messageItemName = StringUtil.color(cfg.getString("Settings.Message.Item_Name", "&7x%item_amount% &f%item_name%")); @@ -64,10 +52,6 @@ public class EnchantTelekinesis extends IEnchantChanceTemplate implements BlockB cfg.addMissing("Settings.Message.Item_Separator", "&7, "); } - public static boolean isDropHandled(@NotNull Block block) { - return block.hasMetadata(META_BLOCK_DROP_HANDLER); - } - @Override @NotNull public UnaryOperator replacePlaceholders(int level) { @@ -87,54 +71,17 @@ public class EnchantTelekinesis extends IEnchantChanceTemplate implements BlockB } @Override - public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isEnchantmentAvailable(player)) return false; - if (e.getBlock().getState() instanceof Container) return false; - if (INFESTED.contains(e.getBlock().getType())) return false; - if (!e.isDropItems()) return false; - if (!this.checkTriggerChance(level)) return false; + public void handleDrop(@NotNull EnchantDropContainer e, @NotNull Player player, @NotNull ItemStack item, int level) { + BlockDropItemEvent parent = e.getParent(); + Block block = parent.getBlockState().getBlock(); - EnchantCurseOfMisfortune curseOfMisfortune = EnchantRegister.CURSE_OF_MISFORTUNE; - if (curseOfMisfortune != null && item.containsEnchantment(curseOfMisfortune)) { - if (curseOfMisfortune.use(e, player, item, level)) { - return false; - } - } + if (!this.isEnchantmentAvailable(player)) return; + //if (block.getState() instanceof Container) return; + if (!this.checkTriggerChance(level)) return; - Block block = e.getBlock(); - List drops = new ArrayList<>(plugin.getNMS().getBlockDrops(block, player, item)); - - // Check inventory space. - if (drops.stream().anyMatch(itemDrop -> PlayerUtil.countItemSpace(player, itemDrop) == 0)) return false; - - // Tell other enchantments that block drops are handled by Telekinesis. - block.setMetadata(META_BLOCK_DROP_HANDLER, new FixedMetadataValue(plugin, true)); - - for (Map.Entry entry : EnchantManager.getItemCustomEnchants(item, CustomDropEnchant.class).entrySet()) { - CustomDropEnchant dropEnchant = entry.getKey(); - int dropLevel = entry.getValue(); - if (dropEnchant.isEventMustHaveDrops() && !e.isDropItems()) continue; - - if (dropEnchant instanceof IEnchantChanceTemplate chanceEnchant) { - if (!chanceEnchant.checkTriggerChance(dropLevel)) continue; - } - if (dropEnchant instanceof EnchantSilkChest && block.getState() instanceof Chest) { - drops.removeIf(drop -> drop.getType() == block.getType()); - } - if (dropEnchant instanceof EnchantSmelter smelter) { - boolean isSmelted = drops.stream().anyMatch(drop -> smelter.isSmeltable(drop.getType())); - smelter.smelt(drops); - if (isSmelted) smelter.playEffect(block); - continue; // Do not add smelted items twice, only replace current ones. - } - if (dropEnchant instanceof EnchantTreasures treasures) { - if (treasures.getTreasure(block) != null) { - treasures.playEffect(block); - } - } - - drops.addAll(dropEnchant.getCustomDrops(player, item, block, dropLevel)); - } + List drops = new ArrayList<>(); + drops.addAll(parent.getItems().stream().map(Item::getItemStack).toList()); + drops.addAll(e.getDrop()); drops.removeIf(Objects::isNull); StringBuilder builder = new StringBuilder(); @@ -143,15 +90,12 @@ public class EnchantTelekinesis extends IEnchantChanceTemplate implements BlockB if (!builder.isEmpty()) builder.append(this.messageItemSeparator); builder.append(this.messageItemName - .replace("%item_name%", ItemUtil.getItemName(drop)) - .replace("%item_amount%", String.valueOf(drop.getAmount()))); + .replace("%item_name%", ItemUtil.getItemName(drop)) + .replace("%item_amount%", String.valueOf(drop.getAmount()))); }); this.messageDropReceived.replace("%items%", builder.toString()).send(player); - e.setDropItems(false); - plugin.getServer().getScheduler().runTask(plugin, c -> { - block.removeMetadata(META_BLOCK_DROP_HANDLER, plugin); - }); - return true; + e.getDrop().clear(); + parent.getItems().clear(); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java index 841185d..916d6d5 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java @@ -7,43 +7,40 @@ import org.bukkit.Sound; 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.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import su.nexmedia.engine.NexEngine; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.ICleanable; -import su.nexmedia.engine.manager.player.listener.PlayerBlockPlacedListener; +import su.nexmedia.engine.manager.player.PlayerBlockTracker; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.LocationUtil; import su.nexmedia.engine.utils.MessageUtil; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; import su.nightexpress.excellentenchants.manager.type.FitItemType; -import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.function.Predicate; -public class EnchantTreasures extends IEnchantChanceTemplate implements BlockBreakEnchant, CustomDropEnchant, ICleanable { +public class EnchantTreasures extends IEnchantChanceTemplate implements CustomDropEnchant, ICleanable { private final String particleName; private final String particleData; private final String sound; private final Map> treasures; - private final Predicate userBlockFilter; + private final Predicate blockTracker; public static final String ID = "treasures"; public EnchantTreasures(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.LOWEST); + super(plugin, cfg, EnchantPriority.MEDIUM); this.particleName = cfg.getString("Settings.Particle.Name", Particle.REDSTONE.name()); this.particleData = cfg.getString("Settings.Particle.Data", "200,180,0"); @@ -72,15 +69,15 @@ public class EnchantTreasures extends IEnchantChanceTemplate implements BlockBre } } - NexEngine.get().getPlayerManager().enableUserBlockListening(); - PlayerBlockPlacedListener.BLOCK_FILTERS.add(this.userBlockFilter = (block) -> { - return this.getTreasure(block) != null; + PlayerBlockTracker.initialize(); + PlayerBlockTracker.BLOCK_FILTERS.add(this.blockTracker = (block) -> { + return this.getTreasure(block.getType()) != null; }); } @Override public void clear() { - PlayerBlockPlacedListener.BLOCK_FILTERS.remove(this.userBlockFilter); + PlayerBlockTracker.BLOCK_FILTERS.remove(this.blockTracker); } @Override @@ -105,50 +102,34 @@ public class EnchantTreasures extends IEnchantChanceTemplate implements BlockBre } @Override - @NotNull - public List getCustomDrops(@NotNull Player player, @NotNull ItemStack item, @NotNull Block block, int level) { - ItemStack drop = this.getTreasure(block); - if (PlayerBlockPlacedListener.isUserPlaced(block) || drop == null) return Collections.emptyList(); - return Collections.singletonList(drop); - } + public void handleDrop(@NotNull EnchantDropContainer e, @NotNull Player player, @NotNull ItemStack item, int level) { + BlockDropItemEvent parent = e.getParent(); + Block block = parent.getBlockState().getBlock(); + if (!this.isEnchantmentAvailable(player)) return; + if (PlayerBlockTracker.isTracked(block)) return; + if (!this.checkTriggerChance(level)) return; + if (!this.takeCostItem(player)) return; - @Override - public boolean isEventMustHaveDrops() { - return false; + ItemStack treasure = this.getTreasure(parent.getBlockState().getType()); + if (treasure == null) return; + + e.getDrop().add(treasure); + this.playEffect(block); } @Nullable - public final ItemStack getTreasure(@NotNull Block block) { - Map treasures = this.treasures.get(block.getType()); + public final ItemStack getTreasure(@NotNull Material type) { + Map treasures = this.treasures.get(type); if (treasures == null) return null; Material mat = Rnd.get(treasures); return mat != null && !mat.isAir() ? new ItemStack(mat) : null; } + @Deprecated public void playEffect(@NotNull Block block) { Location location = LocationUtil.getCenter(block.getLocation()); MessageUtil.sound(location, this.sound); EffectUtil.playEffect(location, this.particleName, this.particleData, 0.2f, 0.2f, 0.2f, 0.12f, 20); } - - - @Override - public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - Block block = e.getBlock(); - if (!this.isEnchantmentAvailable(player)) return false; - if (EnchantTelekinesis.isDropHandled(block)) return false; - if (this.isEventMustHaveDrops() && !e.isDropItems()) return false; - if (PlayerBlockPlacedListener.isUserPlaced(block)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(player)) return false; - - Location location = LocationUtil.getCenter(block.getLocation()); - List drops = this.getCustomDrops(player, item, block, level); - if (drops.isEmpty()) return false; - - drops.forEach(itemDrop -> block.getWorld().dropItem(location, itemDrop)); - this.playEffect(block); - return true; - } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantTemper.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantTemper.java new file mode 100644 index 0000000..f407e90 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantTemper.java @@ -0,0 +1,90 @@ +package su.nightexpress.excellentenchants.manager.enchants.weapon; + +import org.bukkit.attribute.Attribute; +import org.bukkit.enchantments.EnchantmentTarget; +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.api.config.JYML; +import su.nexmedia.engine.utils.EntityUtil; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantTemper extends IEnchantChanceTemplate implements CombatEnchant { + + public static final String ID = "temper"; + public static final String PLACEHOLDER_DAMAGE_AMOUNT = "%enchantment_damage_amount%"; + public static final String PLACEHOLDER_DAMAGE_CAPACITY = "%enchantment_damage_capacity%"; + public static final String PLACEHOLDER_HEALTH_POINT = "%enchantment_health_point%"; + + private final EnchantScaler damageAmount; + private final EnchantScaler damageCapacity; + private final EnchantScaler healthPoint; + + public EnchantTemper(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + + this.damageAmount = new EnchantScaler(this, "Settings.Damage.Amount"); + this.damageCapacity = new EnchantScaler(this, "Settings.Damage.Capacity"); + this.healthPoint = new EnchantScaler(this, "Settings.Health.Point"); + } + + public double getDamageAmount(int level) { + return this.damageAmount.getValue(level); + } + + public double getDamageCapacity(int level) { + return this.damageCapacity.getValue(level); + } + + public double getHealthPoint(int level) { + return this.healthPoint.getValue(level); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_DAMAGE_AMOUNT, NumberUtil.format(this.getDamageAmount(level) * 100D)) + .replace(PLACEHOLDER_DAMAGE_CAPACITY, NumberUtil.format(this.getDamageCapacity(level) * 100D)) + .replace(PLACEHOLDER_HEALTH_POINT, NumberUtil.format(this.getHealthPoint(level))) + ); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(damager)) return false; + if (!this.checkTriggerChance(level)) return false; + + double healthPoint = this.getHealthPoint(level); + double healthHas = damager.getHealth(); + double healthMax = EntityUtil.getAttribute(damager, Attribute.GENERIC_MAX_HEALTH); + double healthDiff = healthMax - healthHas; + if (healthHas >= healthMax || healthDiff < healthPoint) return false; + + int pointAmount = (int) (healthDiff / healthPoint); + if (pointAmount == 0) return false; + + if (!this.takeCostItem(damager)) return false; + + double damageAmount = this.getDamageAmount(level); + double damageCap = this.getDamageCapacity(level); + double damageFinal = Math.min(damageCap, damageAmount * pointAmount); + + e.setDamage(e.getDamage() * damageFinal); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java index 3850130..1002087 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java @@ -249,7 +249,7 @@ public class EnchantGenericListener extends AbstractListener } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantPopulatePiglinBarter(CreatureSpawnEvent e) { + public void onEnchantPopulateSpawn(CreatureSpawnEvent e) { if (Config.getObtainSettings(ObtainType.MOB_SPAWNING) == null) return; LivingEntity entity = e.getEntity(); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java index ead48ab..07cfb07 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java @@ -10,6 +10,7 @@ import org.bukkit.event.Event.Result; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; @@ -23,6 +24,7 @@ import su.nexmedia.engine.api.manager.AbstractListener; import su.nexmedia.engine.utils.EntityUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.type.*; +import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; import su.nightexpress.excellentenchants.manager.EnchantManager; public class EnchantHandlerListener extends AbstractListener { @@ -192,4 +194,26 @@ public class EnchantHandlerListener extends AbstractListener blockEnchant.use(e, player, tool, level); }); } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantBlockDropItem(BlockDropItemEvent e) { + Player player = e.getPlayer(); + if (player.getGameMode() == GameMode.CREATIVE) return; + + ItemStack tool = player.getInventory().getItemInMainHand(); + if (tool.getType().isAir() || tool.getType() == Material.ENCHANTED_BOOK) return; + + EnchantManager.getItemCustomEnchants(tool, BlockDropEnchant.class).forEach((blockEnchant, level) -> { + blockEnchant.use(e, player, tool, level); + }); + + EnchantDropContainer dropContainer = new EnchantDropContainer(e); + EnchantManager.getItemCustomEnchants(tool, CustomDropEnchant.class).forEach((blockEnchant, level) -> { + blockEnchant.handleDrop(dropContainer, player, tool, level); + }); + + dropContainer.getDrop().forEach(item -> { + e.getBlockState().getBlock().getWorld().dropItem(e.getBlockState().getLocation(), item); + }); + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java index 79aae1f..7e854ab 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.manager.object; import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -117,7 +118,7 @@ public class EnchantListGUI extends AbstractMenu { } @Override - public boolean cancelClick(@NotNull SlotType slotType, int slot) { + public boolean cancelClick(@NotNull InventoryClickEvent e, @NotNull SlotType slotType) { return true; } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java index ddaa01e..5b7f144 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java @@ -16,7 +16,7 @@ import java.util.stream.Collectors; public class EnchantTier { private final String id; - private final int priority; + private final int priority; private final String name; private final String color; private final Map chance; @@ -73,8 +73,8 @@ public class EnchantTier { @NotNull public Set getEnchants(@NotNull ObtainType obtainType, @Nullable ItemStack item) { Set set = this.getEnchants().stream() - .filter(en -> en.getObtainChance(obtainType) > 0) - .filter(en -> item == null || en.canEnchantItem(item)).collect(Collectors.toSet()); + .filter(en -> en.getObtainChance(obtainType) > 0) + .filter(en -> item == null || en.canEnchantItem(item)).collect(Collectors.toSet()); set.removeIf(en -> obtainType == ObtainType.ENCHANTING && en.isTreasure()); return set; } diff --git a/Core/src/main/resources/enchants/confusing_arrows.yml b/Core/src/main/resources/enchants/confusing_arrows.yml new file mode 100644 index 0000000..f5f8202 --- /dev/null +++ b/Core/src/main/resources/enchants/confusing_arrows.yml @@ -0,0 +1,32 @@ +Is_Treasure: false +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.)' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 45.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 60.0 +Villagers: + Chance: 75.0 +Loot_Generation: + Chance: 60.0 +Mob_Spawning: + Chance: 35.0 + +Settings: + Trigger_Chance: '20.0 + %enchantment_level% * 5.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '6.0 + %enchantment_level% * 3.0' + Level: '%enchantment_level%' \ 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 new file mode 100644 index 0000000..2adb6c8 --- /dev/null +++ b/Core/src/main/resources/enchants/dragonfire_arrows.yml @@ -0,0 +1,35 @@ +Is_Treasure: false +Name: Dragonfire Arrows +Tier: exotic +Description: + - '%enchantment_trigger_chance%% chance to launch an dragonfire arrow (R=%enchantment_fire_radius%, %enchantment_fire_duration%s).' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 25.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 20.0 +Villagers: + Chance: 25.0 +Loot_Generation: + Chance: 30.0 +Mob_Spawning: + Chance: 5.0 +Settings: + Trigger_Chance: '10.0 + %enchantment_level% * 5' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Fire: + Duration: '%enchantment_level% * 100.0' + Radius: '2.0 + %enchantment_level%' + Arrow: + Trail: + Name: 'DRAGON_BREATH' + Data: '' diff --git a/Core/src/main/resources/enchants/electrified_arrows.yml b/Core/src/main/resources/enchants/electrified_arrows.yml new file mode 100644 index 0000000..55aa95e --- /dev/null +++ b/Core/src/main/resources/enchants/electrified_arrows.yml @@ -0,0 +1,33 @@ +Is_Treasure: false +Name: Electrified Arrows +Tier: rare +Description: + - '%enchantment_trigger_chance%% chance to launch an electrified arrow.' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 75.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 25.0 +Villagers: + Chance: 45.0 +Loot_Generation: + Chance: 40.0 +Mob_Spawning: + Chance: 10.0 + +Settings: + Trigger_Chance: '10.0 + %enchantment_level% * 5' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Arrow: + Trail: + Name: 'FIREWORKS_SPARK' + Data: '' diff --git a/Core/src/main/resources/enchants/hover.yml b/Core/src/main/resources/enchants/hover.yml new file mode 100644 index 0000000..daa294f --- /dev/null +++ b/Core/src/main/resources/enchants/hover.yml @@ -0,0 +1,31 @@ +Is_Treasure: false +Name: Hover +Tier: common +Description: + - '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' +Level: + Min: 1 + Max: 3 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 50.0 +Enchanting_Table: + Level_By_Exp_Cost: '9 * %enchantment_level%' + Chance: 30.0 +Villagers: + Chance: 40.0 +Loot_Generation: + Chance: 40.0 +Mob_Spawning: + Chance: 10.0 +Settings: + Trigger_Chance: '10.0 + %enchantment_level% * 5' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Potion_Effect: + Duration: '2.5 + %enchantment_level%' + Level: '%enchantment_level%' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/temper.yml b/Core/src/main/resources/enchants/temper.yml new file mode 100644 index 0000000..e55ce7c --- /dev/null +++ b/Core/src/main/resources/enchants/temper.yml @@ -0,0 +1,34 @@ +Is_Treasure: false +Name: Temper +Tier: rare +Description: + - '%enchantment_trigger_chance%% chance to inflict %enchantment_damage_amount%% (max. %enchantment_damage_capacity%%) more damage for each %enchantment_health_point% hearts missing.' +Level: + Min: 1 + Max: 5 +Anvil: + Merge_Cost: '%enchantment_level%' +Fishing: + Chance: 25.0 +Enchanting_Table: + Level_By_Exp_Cost: '6 * %enchantment_level%' + Chance: 15.0 +Villagers: + Chance: 20.0 +Loot_Generation: + Chance: 25.0 +Mob_Spawning: + Chance: 10.0 + +Settings: + Trigger_Chance: '100.0' + Cost: + Enabled: false + Item: + Material: AIR + Amount: 1 + Damage: + Amount: '0.01 * %enchantment_level%' + Capacity: '2.0' + Health: + Point: '0.5' diff --git a/Core/src/main/resources/lang/messages_es.yml b/Core/src/main/resources/lang/messages_es.yml new file mode 100644 index 0000000..9337d33 --- /dev/null +++ b/Core/src/main/resources/lang/messages_es.yml @@ -0,0 +1,18 @@ +Command: + List: + Desc: Lista de todos los encantamientos personalizados. + Enchant: + Usage: + Desc: Encanta el item de tu mano. + Done: '&a¡Encantado con éxito!' + Book: + Usage: + Desc: Da un libro encantado personalizado. + Done: Se ha dado un libro encantado de &6%enchant%&7 a &6%player%&7. + TierBook: + Usage: + Desc: Da un libro encantado. + Error: '&c¡Rareza inválida!' + Done: Se ha dado un libro encantado &6%tier%&7 a &6%player%&7. +Error: + NoEnchant: '&cNo hay tal encanto.' diff --git a/NMS/pom.xml b/NMS/pom.xml index c200153..f6b5aed 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.4 + 3.2.0 4.0.0 diff --git a/V1_16_R1/pom.xml b/V1_16_R1/pom.xml index 6427e28..6948894 100644 --- a/V1_16_R1/pom.xml +++ b/V1_16_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.4 + 3.2.0 4.0.0 @@ -25,7 +25,7 @@ su.nightexpress.excellentenchants NMS - 3.1.4 + 3.2.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 6ea668b..be02d99 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.4 + 3.2.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.1.4 + 3.2.0 diff --git a/V1_18_R1/pom.xml b/V1_18_R1/pom.xml index 6405e2f..cf11b4f 100644 --- a/V1_18_R1/pom.xml +++ b/V1_18_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.4 + 3.2.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.1.4 + 3.2.0 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index f6e3eb8..94812b7 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.1.4 + 3.2.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.1.4 + 3.2.0 diff --git a/pom.xml b/pom.xml index 8c4a448..d730a72 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.1.4 + 3.2.0 Core NMS @@ -26,7 +26,7 @@ su.nexmedia NexEngine - 2.1.1 + 2.1.2 From e2cb12ddd5f3bc1562aa0024dc165f023a2ed07b Mon Sep 17 00:00:00 2001 From: nulli0n Date: Thu, 21 Jul 2022 18:26:56 +0500 Subject: [PATCH 10/69] 3.2.3 --- .gitignore | 2 + Core/pom.xml | 25 +++--- .../excellentenchants/ExcellentEnchants.java | 37 ++++----- .../api/enchantment/ExcellentEnchant.java | 70 +++++++++++++--- .../enchantment/IEnchantPotionTemplate.java | 3 +- .../command/BookCommand.java | 12 +-- .../command/EnchantCommand.java | 9 ++- .../command/ListCommand.java | 3 +- .../command/TierbookCommand.java | 11 +-- .../excellentenchants/config/Config.java | 28 +++---- .../excellentenchants/config/Lang.java | 40 ++++----- .../manager/EnchantManager.java | 12 --- .../manager/enchants/bow/EnchantBomber.java | 1 + .../manager/enchants/bow/EnchantEnderBow.java | 1 + .../manager/enchants/bow/EnchantGhast.java | 1 + .../enchants/tool/EnchantCurseOfBreaking.java | 5 ++ .../enchants/tool/EnchantDivineTouch.java | 2 +- .../manager/enchants/tool/EnchantSmelter.java | 1 - .../enchants/tool/EnchantTelekinesis.java | 6 +- .../enchants/tool/EnchantTreasures.java | 7 +- .../manager/enchants/tool/EnchantTunnel.java | 5 +- .../enchants/weapon/EnchantCutter.java | 2 +- .../enchants/weapon/EnchantDecapitator.java | 4 +- .../enchants/weapon/EnchantIceAspect.java | 5 +- .../listeners/EnchantHandlerListener.java | 19 ++++- .../manager/object/EnchantListGUI.java | 6 +- Core/src/main/resources/config.yml | 4 +- Core/src/main/resources/enchants/aquaman.yml | 50 +++++++++++- .../enchants/bane_of_netherspawn.yml | 54 ++++++++++++- .../main/resources/enchants/blast_mining.yml | 51 ++++++++++-- .../src/main/resources/enchants/blindness.yml | 56 ++++++++++++- Core/src/main/resources/enchants/bomber.yml | 44 +++++++++- .../src/main/resources/enchants/bunny_hop.yml | 46 ++++++++++- .../main/resources/enchants/cold_steel.yml | 50 +++++++++++- .../resources/enchants/confusing_arrows.yml | 53 ++++++++++-- .../src/main/resources/enchants/confusion.yml | 60 ++++++++++++-- Core/src/main/resources/enchants/cure.yml | 49 ++++++++++- .../resources/enchants/curse_of_breaking.yml | 45 ++++++++++- .../enchants/curse_of_misfortune.yml | 42 +++++++++- Core/src/main/resources/enchants/cutter.yml | 45 ++++++++++- .../main/resources/enchants/decapitator.yml | 66 ++++++++++++--- .../main/resources/enchants/divine_touch.yml | 49 ++++++++++- .../main/resources/enchants/double_strike.yml | 51 ++++++++++-- .../resources/enchants/dragonfire_arrows.yml | 58 +++++++++++-- .../resources/enchants/electrified_arrows.yml | 49 +++++++++-- .../src/main/resources/enchants/ender_bow.yml | 35 +++++++- Core/src/main/resources/enchants/exhaust.yml | 56 ++++++++++++- .../main/resources/enchants/exp_hunter.yml | 45 ++++++++++- .../resources/enchants/explosive_arrows.yml | 58 +++++++++++-- .../main/resources/enchants/flame_walker.yml | 41 +++++++++- Core/src/main/resources/enchants/ghast.yml | 44 +++++++++- Core/src/main/resources/enchants/hardened.yml | 50 +++++++++++- Core/src/main/resources/enchants/haste.yml | 45 ++++++++++- Core/src/main/resources/enchants/hover.yml | 52 ++++++++++-- .../main/resources/enchants/ice_aspect.yml | 60 ++++++++++++-- Core/src/main/resources/enchants/infernus.yml | 43 +++++++++- .../main/resources/enchants/lucky_miner.yml | 45 ++++++++++- .../main/resources/enchants/night_vision.yml | 44 +++++++++- Core/src/main/resources/enchants/nimble.yml | 39 ++++++++- Core/src/main/resources/enchants/paralyze.yml | 58 +++++++++++-- .../resources/enchants/poisoned_arrows.yml | 52 ++++++++++-- Core/src/main/resources/enchants/rage.yml | 58 +++++++++++-- Core/src/main/resources/enchants/regrowth.yml | 56 +++++++++++-- .../src/main/resources/enchants/replanter.yml | 38 ++++++++- Core/src/main/resources/enchants/rocket.yml | 41 +++++++++- .../main/resources/enchants/saturation.yml | 46 ++++++++++- .../src/main/resources/enchants/scavenger.yml | 48 ++++++++++- .../resources/enchants/self_destruction.yml | 46 ++++++++++- .../main/resources/enchants/silk_chest.yml | 40 ++++++++- Core/src/main/resources/enchants/smelter.yml | 56 +++++++++++-- Core/src/main/resources/enchants/sonic.yml | 46 ++++++++++- Core/src/main/resources/enchants/surprise.yml | 58 +++++++++++-- .../main/resources/enchants/telekinesis.yml | 38 ++++++++- Core/src/main/resources/enchants/temper.yml | 53 +++++++++++- Core/src/main/resources/enchants/thrifty.yml | 53 ++++++++++-- Core/src/main/resources/enchants/thunder.yml | 42 +++++++++- .../src/main/resources/enchants/treasures.yml | 60 ++++++++++++-- Core/src/main/resources/enchants/tunnel.yml | 38 ++++++++- Core/src/main/resources/enchants/vampire.yml | 55 +++++++++++-- .../src/main/resources/enchants/veinminer.yml | 81 ++++++++++++++----- Core/src/main/resources/enchants/venom.yml | 56 ++++++++++++- .../resources/enchants/village_defender.yml | 53 +++++++++++- Core/src/main/resources/enchants/wither.yml | 56 ++++++++++++- .../resources/enchants/withered_arrows.yml | 52 ++++++++++-- Core/src/main/resources/gui.enchants.yml | 2 + NMS/pom.xml | 2 +- V1_16_R1/pom.xml | 32 -------- .../excellentenchants/nms/V1_16_R3.java | 51 ------------ V1_17_R1/pom.xml | 4 +- V1_18_R2/pom.xml | 4 +- {V1_18_R1 => V1_19_R1}/pom.xml | 18 ++--- .../excellentenchants/nms/V1_19_R1.java | 10 +-- pom.xml | 7 +- 93 files changed, 2810 insertions(+), 496 deletions(-) delete mode 100644 V1_16_R1/pom.xml delete mode 100644 V1_16_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_16_R3.java rename {V1_18_R1 => V1_19_R1}/pom.xml (85%) rename V1_18_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R1.java => V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_19_R1.java (88%) diff --git a/.gitignore b/.gitignore index 62a5987..4459b58 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ /V1_18_R1/target/ /.idea/ /target/ +/V1_18_R2/pom.xml.versionsBackup +/V1_18_R2/target/ diff --git a/Core/pom.xml b/Core/pom.xml index 5abfa79..f3f52ea 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.0 + 3.2.3 4.0.0 @@ -27,32 +27,27 @@ org.spigotmc spigot-api - 1.18.1-R0.1-SNAPSHOT + 1.19-R0.1-SNAPSHOT su.nightexpress.excellentenchants NMS - 3.2.0 - - - su.nightexpress.excellentenchants - V1_16_R1 - 3.2.0 + 3.2.3 su.nightexpress.excellentenchants V1_17_R1 - 3.2.0 - - - su.nightexpress.excellentenchants - V1_18_R1 - 3.2.0 + 3.2.3 su.nightexpress.excellentenchants V1_18_R2 - 3.2.0 + 3.2.3 + + + su.nightexpress.excellentenchants + V1_19_R1 + 3.2.3 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index e2408e1..532292b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants; +import org.bukkit.enchantments.EnchantmentTarget; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.NexPlugin; import su.nexmedia.engine.Version; @@ -12,18 +13,22 @@ import su.nightexpress.excellentenchants.command.TierbookCommand; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.config.Lang; import su.nightexpress.excellentenchants.manager.EnchantManager; +import su.nightexpress.excellentenchants.manager.type.FitItemType; import su.nightexpress.excellentenchants.nms.EnchantNMS; public class ExcellentEnchants extends NexPlugin { public static boolean isLoaded = false; - private Config config; - private Lang lang; - private EnchantNMS enchantNMS; private EnchantManager enchantManager; + @Override + @NotNull + protected ExcellentEnchants getSelf() { + return this; + } + @Override public void enable() { if (!this.setNMS()) { @@ -62,12 +67,16 @@ public class ExcellentEnchants extends NexPlugin { } @Override - public void setConfig() { - this.config = new Config(this); - this.config.setup(); + public void loadConfig() { + Config.load(this); + } - this.lang = new Lang(this); - this.lang.setup(); + @Override + public void loadLang() { + this.getLangManager().loadMissing(Lang.class); + this.getLangManager().setupEnum(EnchantmentTarget.class); + this.getLangManager().setupEnum(FitItemType.class); + this.getLang().saveChanges(); } @Override @@ -83,18 +92,6 @@ public class ExcellentEnchants extends NexPlugin { } - @Override - @NotNull - public Config cfg() { - return this.config; - } - - @Override - @NotNull - public Lang lang() { - return this.lang; - } - @NotNull public EnchantManager getEnchantManager() { return this.enchantManager; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index af6adc5..eb0e540 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -10,11 +10,13 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.IListener; +import su.nexmedia.engine.lang.LangManager; import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.*; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.config.Lang; import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import su.nightexpress.excellentenchants.manager.object.EnchantTier; @@ -28,9 +30,9 @@ import java.util.stream.Stream; public abstract class ExcellentEnchant extends Enchantment implements IListener { - public static final String PLACEHOLDER_NAME = "%enchantment_name%"; - public static final String PLACEHLDER_NAME_FORMATTED = "%enchantment_name_formatted%"; - public static final String PLACEHOLDER_DESCRIPTION = "%enchantment_description%"; + public static final String PLACEHOLDER_NAME = "%enchantment_name%"; + public static final String PLACEHOLDER_NAME_FORMATTED = "%enchantment_name_formatted%"; + public static final String PLACEHOLDER_DESCRIPTION = "%enchantment_description%"; public static final String PLACEHOLDER_LEVEL = "%enchantment_level%"; public static final String PLACEHOLDER_LEVEL_MIN = "%enchantment_level_min%"; public static final String PLACEHOLDER_LEVEL_MAX = "%enchantment_level_max%"; @@ -74,7 +76,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener this.priority = priority; this.displayName = StringUtil.color(cfg.getString("Name", this.getId())); - this.tier = EnchantManager.getTierById(cfg.getString("Tier", Constants.DEFAULT)); + this.tier = EnchantManager.getTierById(cfg.getString("Tier", Placeholders.DEFAULT)); if (this.tier == null) { throw new IllegalStateException("Invalid tier provided for the '" + id + "' enchantment!"); } @@ -114,28 +116,75 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener for (ObtainType obtainType : ObtainType.values()) { cfg.addMissing(obtainType.getPathName() + ".Chance", 25D); } + + /*String scalabe = "Scalable. Placeholder: " + PLACEHOLDER_LEVEL + ". See: http://77.222.60.131:8080/plugin/engine/config/formats"; + cfg.setComments("Is_Treasure", Arrays.asList("Defines if this enchantment is a treasure enchantment.", "Treasure enchantments can only be received via looting, trading, or fishing.")); + cfg.setComments("Name", Arrays.asList("Enchantment display name. This name will be displayed in item lore and in enchantments list GUI.")); + cfg.setComments("Tier", Arrays.asList("Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded.")); + cfg.setComments("Description", Arrays.asList("Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI.", "You can use multiple lines here.", "You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders")); + cfg.setComments("Level", Arrays.asList("Enchantment level settings.")); + cfg.setComments("Level.Min", Arrays.asList("Minimal (start) enchantment level. Can not be smaller then 1.")); + cfg.setComments("Level.Max", Arrays.asList("Maximal (final) enchantment level.", "Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level.")); + cfg.setComments("Anvil", Arrays.asList("Enchantment settings for Anvil.")); + cfg.setComments("Anvil.Merge_Cost", Arrays.asList("Defines the exp cost to merge this enchantment on other items on anvil.", scalabe)); + cfg.setComments("Enchanting_Table", Arrays.asList("Enchantment settings for Enchanting Table.")); + cfg.setComments("Enchanting_Table.Level_By_Exp_Cost", Arrays.asList("Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost.", "Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels.", scalabe)); + cfg.setComments("Enchanting_Table.Chance", Arrays.asList("A chance that this enchantment will be appeared in Enchanting Table.")); + cfg.setComments("Villagers.Chance", Arrays.asList("A chance that this enchantment will be populated on items in Villager trades.")); + cfg.setComments("Loot_Generation.Chance", Arrays.asList("A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers.")); + cfg.setComments("Fishing.Chance", Arrays.asList("A chance that this enchantment will be populated on items received from fishing.")); + cfg.setComments("Mob_Spawning.Chance", Arrays.asList("A chance that this enchantment will be populated on items equipped on mob on spawning.")); + cfg.setComments("Settings", Arrays.asList("Individual enchantment settings.")); + cfg.setComments("Settings.Trigger_Chance", Arrays.asList("A chance that this enchantment will be triggered.", scalabe)); + cfg.setComments("Settings.Cost", Arrays.asList("A cost a player will have to pay to have this enchantment triggered.")); + cfg.setComments("Settings.Cost.Enabled", Arrays.asList("Enables/Disables cost feature.")); + cfg.setComments("Settings.Cost.Item", Arrays.asList("A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect.", "See http://77.222.60.131:8080/plugin/engine/config/formats for item options.")); + cfg.setComments("Settings.Potion_Effect", Arrays.asList("Enchantment settings for the Potion Effect applied to a wearer or victim.")); + cfg.setComments("Settings.Potion_Effect.Level", Arrays.asList("Potion effect level (amplifier).", scalabe)); + cfg.setComments("Settings.Potion_Effect.Duration", Arrays.asList("Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay.", scalabe)); + cfg.setComments("Settings.Particle", Arrays.asList("Particle effect that will be played on enchantment trigger.")); + cfg.setComments("Settings.Particle.Name", Arrays.asList("Particle name. Set this to empty '' or 'NONE' to disable.", "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html")); + cfg.setComments("Settings.Particle.Data", Arrays.asList("Particle data (additional settings).", "- BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html", "- REDSTONE: Use RGB (like 255,255,255)")); + cfg.setComments("Settings.Sound", Arrays.asList("Sound that will be played on enchantment trigger.", "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html")); + cfg.setComments("Settings.Arrow", Arrays.asList("Enchantment arrow settings.")); + cfg.setComments("Settings.Arrow.Trail", Arrays.asList("A particle effect to play as an arrow trail.")); + cfg.setComments("Settings.Arrow.Trail.Name", Arrays.asList("Particle name. Set this to empty '' or 'NONE' to disable.", "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html")); + cfg.setComments("Settings.Arrow.Trail.Data", Arrays.asList("Particle data (additional settings).", "- BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html", "- REDSTONE: Use RGB (like 255,255,255)")); + + List placeholders = new ArrayList<>(); + placeholders.add("Additional placeholders:"); + for (Field field : Reflex.getFields(this.getClass())) { + if (field.getType() != String.class) continue; + if (!field.getName().startsWith("PLACEHOLDER")) continue; + if (field.getDeclaringClass().equals(ExcellentEnchant.class)) continue; + + String value = (String) Reflex.getFieldValue(this, field.getName()); + String name = StringUtil.capitalizeFully(value.replace("%", "").replace("_", " ")); + placeholders.add("- " + value + ": " + name.trim()); + } + cfg.options().setHeader(placeholders);*/ } @NotNull public UnaryOperator replacePlaceholders(int level) { - String conflicts = this.getConflicts().isEmpty() ? plugin.lang().Other_None.getLocalized() : this.getConflicts().stream().filter(Objects::nonNull).map(en -> plugin.lang().getEnchantment(en)).collect(Collectors.joining("\n")); + String conflicts = this.getConflicts().isEmpty() ? plugin.getMessage(Lang.OTHER_NONE).getLocalized() : this.getConflicts().stream().filter(Objects::nonNull).map(LangManager::getEnchantment).collect(Collectors.joining("\n")); return str -> str .replace(PLACEHOLDER_NAME, this.getDisplayName()) - .replace(PLACEHLDER_NAME_FORMATTED, this.getNameFormatted(level)) + .replace(PLACEHOLDER_NAME_FORMATTED, this.getNameFormatted(level)) .replace(PLACEHOLDER_LEVEL, NumberUtil.toRoman(level)) .replace(PLACEHOLDER_LEVEL_MIN, String.valueOf(this.getStartLevel())) .replace(PLACEHOLDER_LEVEL_MAX, String.valueOf(this.getMaxLevel())) - .replace(PLACEHOLDER_TARGET, plugin.lang().getEnum(this.getItemTarget())) + .replace(PLACEHOLDER_TARGET, plugin.getLangManager().getEnum(this.getItemTarget())) .replace(PLACEHOLDER_TIER, this.getTier().getName()) .replace(PLACEHOLDER_CONFLICTS, conflicts) - .replace(PLACEHOLDER_FIT_ITEM_TYPES, String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.lang().getEnum(type)).toList())) + .replace(PLACEHOLDER_FIT_ITEM_TYPES, String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList())) .replace(PLACEHOLDER_OBTAIN_CHANCE_ENCHANTING, NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING))) .replace(PLACEHOLDER_OBTAIN_CHANCE_VILLAGER, NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER))) .replace(PLACEHOLDER_OBTAIN_CHANCE_LOOT_GENERATION, NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION))) .replace(PLACEHOLDER_OBTAIN_CHANCE_FISHING, NumberUtil.format(this.getObtainChance(ObtainType.FISHING))) .replace(PLACEHOLDER_OBTAIN_CHANCE_MOB_SPAWNING, NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING))) - .replace(PLACEHOLDER_COST_ITEM, this.hasCostItem() ? ItemUtil.getItemName(this.costItem) : plugin.lang().Other_None.getLocalized()) + .replace(PLACEHOLDER_COST_ITEM, this.hasCostItem() ? ItemUtil.getItemName(this.costItem) : plugin.getMessage(Lang.OTHER_NONE).getLocalized()) ; } @@ -246,7 +295,8 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener } public int getLevelByEnchantCost(int expLevel) { - Optional> opt = this.levelByEnchantCost.getValues().entrySet().stream().filter(en -> expLevel >= en.getValue().intValue()).max(Comparator.comparingInt(Map.Entry::getKey)); + Optional> opt = this.levelByEnchantCost.getValues().entrySet().stream() + .filter(en -> expLevel >= en.getValue().intValue()).max(Comparator.comparingInt(Map.Entry::getKey)); return opt.isPresent() ? opt.get().getKey() : Rnd.get(this.getStartLevel(), this.getMaxLevel()); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java index b31bfab..17061e3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java @@ -5,6 +5,7 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.lang.LangManager; import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -41,7 +42,7 @@ public abstract class IEnchantPotionTemplate extends IEnchantChanceTemplate { return str -> super.replacePlaceholders(level).apply(str .replace(PLACEHOLDER_POTION_LEVEL, NumberUtil.toRoman(this.getEffectLevel(level))) .replace(PLACEHOLDER_POTION_DURATION, NumberUtil.format((double) this.getEffectDuration(level) / 20D)) - .replace(PLACEHOLDER_POTION_TYPE, plugin.lang().getPotionType(this.getEffectType())) + .replace(PLACEHOLDER_POTION_TYPE, LangManager.getPotionType(this.getEffectType())) ); } 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 d8858a0..7fa3fa3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java @@ -9,11 +9,13 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.command.AbstractCommand; +import su.nexmedia.engine.lang.LangManager; 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.config.Lang; import su.nightexpress.excellentenchants.manager.EnchantManager; import java.util.Arrays; @@ -28,13 +30,13 @@ public class BookCommand extends AbstractCommand { @Override @NotNull public String getDescription() { - return plugin.lang().Command_Book_Desc.getLocalized(); + return plugin.getMessage(Lang.COMMAND_BOOK_DESC).getLocalized(); } @Override @NotNull public String getUsage() { - return plugin.lang().Command_Book_Usage.getLocalized(); + return plugin.getMessage(Lang.COMMAND_BOOK_USAGE).getLocalized(); } @Override @@ -72,7 +74,7 @@ public class BookCommand extends AbstractCommand { Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(args[2].toLowerCase())); if (enchantment == null) { - plugin.lang().Error_NoEnchant.send(sender); + plugin.getMessage(Lang.ERROR_NO_ENCHANT).send(sender); return; } @@ -91,8 +93,8 @@ public class BookCommand extends AbstractCommand { EnchantManager.updateItemLoreEnchants(item); PlayerUtil.addItem(player, item); - plugin.lang().Command_Book_Done - .replace("%enchant%", plugin.lang().getEnchantment(enchantment)) + plugin.getMessage(Lang.COMMAND_BOOK_DONE) + .replace("%enchant%", LangManager.getEnchantment(enchantment)) .replace("%player%", player.getName()).send(sender); } } 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 4994243..6533cd4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java @@ -13,6 +13,7 @@ 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.config.Lang; import su.nightexpress.excellentenchants.manager.EnchantManager; import java.util.Arrays; @@ -27,13 +28,13 @@ public class EnchantCommand extends AbstractCommand { @Override @NotNull public String getDescription() { - return plugin.lang().Command_Enchant_Desc.getLocalized(); + return plugin.getMessage(Lang.COMMAND_ENCHANT_DESC).getLocalized(); } @Override @NotNull public String getUsage() { - return plugin.lang().Command_Enchant_Usage.getLocalized(); + return plugin.getMessage(Lang.COMMAND_ENCHANT_USAGE).getLocalized(); } @Override @@ -69,7 +70,7 @@ public class EnchantCommand extends AbstractCommand { Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(args[1].toLowerCase())); if (enchantment == null) { - plugin.lang().Error_NoEnchant.send(sender); + plugin.getMessage(Lang.ERROR_NO_ENCHANT).send(sender); return; } @@ -100,6 +101,6 @@ public class EnchantCommand extends AbstractCommand { item.setItemMeta(meta); EnchantManager.updateItemLoreEnchants(item); - plugin.lang().Command_Enchant_Done.send(sender); + 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 7bbb89f..54ca8ab 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/ListCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/ListCommand.java @@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.command.AbstractCommand; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Perms; +import su.nightexpress.excellentenchants.config.Lang; public class ListCommand extends AbstractCommand { @@ -22,7 +23,7 @@ public class ListCommand extends AbstractCommand { @Override @NotNull public String getDescription() { - return plugin.lang().Command_List_Desc.getLocalized(); + return plugin.getMessage(Lang.COMMAND_LIST_DESC).getLocalized(); } @Override 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 9d2bf8b..f1b2d91 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java @@ -12,6 +12,7 @@ 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.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.object.EnchantTier; @@ -27,13 +28,13 @@ public class TierbookCommand extends AbstractCommand { @Override @NotNull public String getDescription() { - return plugin.lang().Command_TierBook_Desc.getLocalized(); + return plugin.getMessage(Lang.COMMAND_TIER_BOOK_DESC).getLocalized(); } @Override @NotNull public String getUsage() { - return plugin.lang().Command_TierBook_Usage.getLocalized(); + return plugin.getMessage(Lang.COMMAND_TIER_BOOK_USAGE).getLocalized(); } @Override @@ -71,13 +72,13 @@ public class TierbookCommand extends AbstractCommand { EnchantTier tier = EnchantManager.getTierById(args[2].toLowerCase()); if (tier == null) { - plugin.lang().Command_TierBook_Error.send(sender); + plugin.getMessage(Lang.COMMAND_TIER_BOOK_ERROR).send(sender); return; } ExcellentEnchant enchant = Rnd.get(tier.getEnchants()); if (enchant == null) { - plugin.lang().Error_NoEnchant.send(sender); + plugin.getMessage(Lang.ERROR_NO_ENCHANT).send(sender); return; } @@ -90,7 +91,7 @@ public class TierbookCommand extends AbstractCommand { EnchantManager.addEnchant(item, enchant, level, true); PlayerUtil.addItem(player, item); - plugin.lang().Command_TierBook_Done + plugin.getMessage(Lang.COMMAND_TIER_BOOK_DONE) .replace("%tier%", tier.getName()) .replace("%player%", player.getName()).send(sender); } 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 d8ac4b2..c48b5ba 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -2,8 +2,8 @@ package su.nightexpress.excellentenchants.config; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import su.nexmedia.engine.api.config.ConfigTemplate; -import su.nexmedia.engine.utils.Constants; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.Placeholders; import su.nexmedia.engine.utils.StringUtil; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -14,11 +14,7 @@ import su.nightexpress.excellentenchants.manager.type.ObtainType; import java.util.*; import java.util.stream.Collectors; -public class Config extends ConfigTemplate { - - public Config(@NotNull ExcellentEnchants plugin) { - super(plugin); - } +public class Config { public static long TASKS_ARROW_TRAIL_TICKS_INTERVAL; public static long TASKS_PASSIVE_ENCHANTS_TICKS_INTERVAL; @@ -37,14 +33,15 @@ public class Config extends ConfigTemplate { private static Map OBTAIN_SETTINGS; private static Map TIERS; - @Override - public void load() { + public static void load(@NotNull ExcellentEnchants plugin) { + JYML cfg = plugin.getConfig(); + String path = "General.Tasks."; TASKS_ARROW_TRAIL_TICKS_INTERVAL = cfg.getLong(path + "Arrow_Trails.Ticks_Interval", 1); TASKS_PASSIVE_ENCHANTS_TICKS_INTERVAL = cfg.getLong(path + "Passive_Enchants.Ticks_Interval", 100); path = "General.Enchantments."; - cfg.addMissing(path + "Disabled_In_Worlds.my_world", Collections.singletonList(Constants.MASK_ANY)); + cfg.addMissing(path + "Disabled_In_Worlds.my_world", Collections.singletonList(Placeholders.MASK_ANY)); cfg.addMissing(path + "Disabled_In_Worlds.other_world", Arrays.asList("enchant_name", "another_enchant")); ENCHANTMENTS_DISABLED = cfg.getStringSet(path + "Disabled").stream().map(String::toLowerCase).collect(Collectors.toSet()); @@ -87,19 +84,20 @@ public class Config extends ConfigTemplate { OBTAIN_SETTINGS.put(obtainType, settings); } - this.setupTiers(); + setupTiers(plugin); } - private void setupTiers() { + private static void setupTiers(@NotNull ExcellentEnchants plugin) { // Reloading tiers will reset their lists with enchants = break the plugin mechanics if (ExcellentEnchants.isLoaded) return; + JYML cfg = plugin.getConfig(); TIERS = new HashMap<>(); // No tiers defined, setup a default one. // Every enchantment must have a tier. if (cfg.getSection("Tiers").isEmpty()) { - this.plugin.info("No tiers defined! Creating a default one for you..."); + plugin.info("No tiers defined! Creating a default one for you..."); cfg.set("Tiers.default.Name", "&7Default"); cfg.set("Tiers.default.Color", "&7"); for (ObtainType obtainType : ObtainType.values()) { @@ -128,12 +126,12 @@ public class Config extends ConfigTemplate { TIERS.put(tier.getId(), tier); } - this.plugin.info("Tiers Loaded: " + TIERS.size()); + plugin.info("Tiers Loaded: " + TIERS.size()); } public static boolean isEnchantmentDisabled(@NotNull ExcellentEnchant enchant, @NotNull String world) { Set disabled = ENCHANTMENTS_DISABLED_IN_WORLDS.getOrDefault(world, Collections.emptySet()); - return disabled.contains(enchant.getKey().getKey()) || disabled.contains(Constants.MASK_ANY); + return disabled.contains(enchant.getKey().getKey()) || disabled.contains(Placeholders.MASK_ANY); } @Nullable 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 577da79..fc73d19 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java @@ -1,35 +1,25 @@ package su.nightexpress.excellentenchants.config; -import org.bukkit.enchantments.EnchantmentTarget; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.LangMessage; -import su.nexmedia.engine.core.config.CoreLang; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.manager.type.FitItemType; +import su.nexmedia.engine.api.lang.LangKey; +import su.nexmedia.engine.lang.EngineLang; -public class Lang extends CoreLang { +public class Lang extends EngineLang { - public Lang(@NotNull ExcellentEnchants plugin) { - super(plugin); - this.setupEnum(EnchantmentTarget.class); - this.setupEnum(FitItemType.class); - } + public static final LangKey COMMAND_LIST_DESC = new LangKey("Command.List.Desc", "List of all custom enchantments."); - public LangMessage Command_List_Desc = new LangMessage(this, "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 LangMessage Command_Enchant_Usage = new LangMessage(this, " "); - public LangMessage Command_Enchant_Desc = new LangMessage(this, "Enchants the item in your hand."); - public LangMessage Command_Enchant_Done = new LangMessage(this, "&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%enchant%&7 enchanted book to &6%player%&7."); - public LangMessage Command_Book_Usage = new LangMessage(this, " "); - public LangMessage Command_Book_Desc = new LangMessage(this, "Gives custom enchanted book."); - public LangMessage Command_Book_Done = new LangMessage(this, "Given &6%enchant%&7 enchanted book to &6%player%&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%tier%&7 enchanted book to &6%player%&7."); - public LangMessage Command_TierBook_Usage = new LangMessage(this, " "); - public LangMessage Command_TierBook_Desc = new LangMessage(this, "Gives an enchanted book."); - public LangMessage Command_TierBook_Error = new LangMessage(this, "&cInvalid tier!"); - public LangMessage Command_TierBook_Done = new LangMessage(this, "Given &6%tier%&7 enchanted book to &6%player%&7."); - - public LangMessage Error_NoEnchant = new LangMessage(this, "&cNo such enchant."); + public static final LangKey ERROR_NO_ENCHANT = new LangKey("Error.NoEnchant", "&cNo such enchant."); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java index 7dfec7a..5d1a3b7 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java @@ -4,7 +4,6 @@ import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Projectile; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; @@ -36,8 +35,6 @@ public class EnchantManager extends AbstractManager { private ArrowTrailsTask arrowTrailsTask; private EnchantEffectPassiveTask enchantEffectPassiveTask; - private static final Map PROJECTILE_WEAPON = new HashMap<>(); - public EnchantManager(@NotNull ExcellentEnchants plugin) { super(plugin); } @@ -236,13 +233,4 @@ public class EnchantManager extends AbstractManager { public static EnchantTier getTierByChance(@NotNull ObtainType obtainType) { return Config.getTierByChance(obtainType); } - - public static void setArrowWeapon(@NotNull Projectile projectile, @NotNull ItemStack bow) { - PROJECTILE_WEAPON.put(projectile.getUniqueId(), bow); - } - - @Nullable - public static ItemStack getArrowWeapon(@NotNull Projectile projectile) { - return PROJECTILE_WEAPON.get(projectile.getUniqueId()); - } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java index 938c335..a2a9189 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java @@ -64,6 +64,7 @@ public class EnchantBomber extends IEnchantChanceTemplate implements BowEnchant this.addConflict(EnchantRegister.POISONED_ARROWS); this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); + this.addConflict(EnchantRegister.CONFUSING_ARROWS); this.addConflict(Enchantment.ARROW_FIRE); this.addConflict(Enchantment.ARROW_DAMAGE); this.addConflict(Enchantment.ARROW_KNOCKBACK); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java index a346bb5..0de6e28 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java @@ -35,6 +35,7 @@ public class EnchantEnderBow extends IEnchantChanceTemplate implements BowEnchan this.addConflict(EnchantRegister.POISONED_ARROWS); this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); + this.addConflict(EnchantRegister.CONFUSING_ARROWS); this.addConflict(Enchantment.ARROW_FIRE); this.addConflict(Enchantment.ARROW_DAMAGE); this.addConflict(Enchantment.ARROW_KNOCKBACK); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java index 6fb1057..9742f33 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java @@ -52,6 +52,7 @@ public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { this.addConflict(EnchantRegister.POISONED_ARROWS); this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); + this.addConflict(EnchantRegister.CONFUSING_ARROWS); this.addConflict(Enchantment.ARROW_FIRE); this.addConflict(Enchantment.ARROW_KNOCKBACK); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java index c2d219b..e57b2e3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java @@ -31,6 +31,11 @@ public class EnchantCurseOfBreaking extends IEnchantChanceTemplate { this.durabilityAmount = new EnchantScaler(this, "Settings.Durability_Amount"); } + @Override + public boolean isCursed() { + return true; + } + public int getDurabilityAmount(int level) { return (int) this.durabilityAmount.getValue(level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java index 2f71947..1b21d4e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java @@ -84,7 +84,7 @@ public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockB spawnerItem.setSpawnedType(spawnerBlock.getSpawnedType()); spawnerItem.update(true); stateItem.setBlockState(spawnerItem); - stateItem.setDisplayName(this.spawnerName.replace("%type%", plugin.lang().getEnum(spawnerBlock.getSpawnedType()))); + stateItem.setDisplayName(this.spawnerName.replace("%type%", plugin.getLangManager().getEnum(spawnerBlock.getSpawnedType()))); itemSpawner.setItemMeta(stateItem); return itemSpawner; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java index 08f3f79..6b44fc7 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java @@ -104,7 +104,6 @@ public class EnchantSmelter extends IEnchantChanceTemplate implements BlockDropE return this.smeltingTable.containsKey(material); } - @Deprecated public void playEffect(@NotNull Block block) { Location location = LocationUtil.getCenter(block.getLocation(), true); MessageUtil.sound(location, this.sound); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java index 79fd1db..3954272 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java @@ -8,7 +8,7 @@ import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.api.config.LangMessage; +import su.nexmedia.engine.api.lang.LangMessage; import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PlayerUtil; import su.nexmedia.engine.utils.StringUtil; @@ -28,14 +28,14 @@ public class EnchantTelekinesis extends IEnchantChanceTemplate implements Custom private final LangMessage messageDropReceived; private final String messageItemName; - private final String messageItemSeparator; + private final String messageItemSeparator; public static final String ID = "telekinesis"; public EnchantTelekinesis(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.LOWEST); - this.messageDropReceived = new LangMessage(plugin.lang(), cfg.getString("Settings.Message.Drop_Received", "")); + this.messageDropReceived = new LangMessage(plugin, cfg.getString("Settings.Message.Drop_Received", "")); this.messageItemName = StringUtil.color(cfg.getString("Settings.Message.Item_Name", "&7x%item_amount% &f%item_name%")); this.messageItemSeparator = StringUtil.color(cfg.getString("Settings.Message.Item_Separator", "&7, ")); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java index 916d6d5..133b069 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java @@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.ICleanable; -import su.nexmedia.engine.manager.player.PlayerBlockTracker; +import su.nexmedia.engine.manager.player.blocktracker.PlayerBlockTracker; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.LocationUtil; import su.nexmedia.engine.utils.MessageUtil; @@ -33,7 +33,7 @@ public class EnchantTreasures extends IEnchantChanceTemplate implements CustomDr private final String particleName; private final String particleData; - private final String sound; + private final Sound sound; private final Map> treasures; private final Predicate blockTracker; @@ -44,7 +44,7 @@ public class EnchantTreasures extends IEnchantChanceTemplate implements CustomDr this.particleName = cfg.getString("Settings.Particle.Name", Particle.REDSTONE.name()); this.particleData = cfg.getString("Settings.Particle.Data", "200,180,0"); - this.sound = cfg.getString("Settings.Sound", Sound.BLOCK_NOTE_BLOCK_BELL.name()); + this.sound = cfg.getEnum("Settings.Sound", Sound.class, Sound.BLOCK_NOTE_BLOCK_BELL); this.treasures = new HashMap<>(); for (String sFromArray : cfg.getSection("Settings.Treasures")) { for (String sFrom : sFromArray.split(",")) { @@ -126,7 +126,6 @@ public class EnchantTreasures extends IEnchantChanceTemplate implements CustomDr return mat != null && !mat.isAir() ? new ItemStack(mat) : null; } - @Deprecated public void playEffect(@NotNull Block block) { Location location = LocationUtil.getCenter(block.getLocation()); MessageUtil.sound(location, this.sound); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java index fd3416a..a01deac 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java @@ -10,7 +10,6 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.Version; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.LocationUtil; @@ -37,9 +36,7 @@ public class EnchantTunnel extends IEnchantChanceTemplate implements BlockBreakE static { INTERACTABLE_BLOCKS.add(Material.REDSTONE_ORE); - if (Version.CURRENT.isHigher(Version.V1_16_R3)) { - INTERACTABLE_BLOCKS.add(Material.DEEPSLATE_REDSTONE_ORE); - } + INTERACTABLE_BLOCKS.add(Material.DEEPSLATE_REDSTONE_ORE); } public EnchantTunnel(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java index c7d6298..d011263 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java @@ -96,7 +96,7 @@ public class EnchantCutter extends IEnchantChanceTemplate implements CombatEncha drop.getVelocity().multiply(3D); EffectUtil.playEffect(victim.getEyeLocation(), Particle.ITEM_CRACK.name(), itemCut.getType().name(), 0.2f, 0.15f, 0.2f, 0.15f, 40); - if (this.sound != null) MessageUtil.sound(victim.getLocation(), this.sound.name()); + MessageUtil.sound(victim.getLocation(), this.sound); return true; } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java index d12c449..fc0fce8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java @@ -106,8 +106,8 @@ public class EnchantDecapitator extends IEnchantChanceTemplate implements DeathE String texture = this.headTextures.get(victim.getType().name()); if (texture == null) return false; - entityName = this.headName.replace("%entity%", plugin.lang().getEnum(victim.getType())); - ItemUtil.addSkullTexture(item, texture, ID + victim.getType().name()); + entityName = this.headName.replace("%entity%", plugin.getLangManager().getEnum(victim.getType())); + ItemUtil.setSkullTexture(item, texture); meta = (SkullMeta) item.getItemMeta(); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantIceAspect.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantIceAspect.java index 9a1eb76..b6878d2 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantIceAspect.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantIceAspect.java @@ -5,7 +5,6 @@ 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.Version; import su.nexmedia.engine.api.config.JYML; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; @@ -23,9 +22,7 @@ public class EnchantIceAspect extends IEnchantCombatPotionTemplate { public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!super.use(e, damager, victim, weapon, level)) return false; - if (Version.CURRENT.isHigher(Version.V1_16_R3)) { - victim.setFreezeTicks(victim.getMaxFreezeTicks()); - } + victim.setFreezeTicks(victim.getMaxFreezeTicks()); return true; } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java index 07cfb07..c9f725c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java @@ -19,7 +19,9 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.manager.AbstractListener; import su.nexmedia.engine.utils.EntityUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -29,10 +31,21 @@ import su.nightexpress.excellentenchants.manager.EnchantManager; public class EnchantHandlerListener extends AbstractListener { + private static final String META_PROJECTILE_WEAPON = "sourceWeapon"; + public EnchantHandlerListener(@NotNull EnchantManager enchantManager) { super(enchantManager.plugin()); } + private void setSourceWeapon(@NotNull Projectile projectile, @NotNull ItemStack item) { + projectile.setMetadata(META_PROJECTILE_WEAPON, new FixedMetadataValue(plugin, item)); + } + + @Nullable + private ItemStack getSourceWeapon(@NotNull Projectile projectile) { + return projectile.hasMetadata(META_PROJECTILE_WEAPON) ? (ItemStack) projectile.getMetadata(META_PROJECTILE_WEAPON).get(0).value() : null; + } + // --------------------------------------------------------------- // Combat Attacking Enchants // --------------------------------------------------------------- @@ -103,7 +116,7 @@ public class EnchantHandlerListener extends AbstractListener }); if (e.getProjectile() instanceof Projectile projectile) { - EnchantManager.setArrowWeapon(projectile, bow); + this.setSourceWeapon(projectile, bow); } } @@ -116,7 +129,7 @@ public class EnchantHandlerListener extends AbstractListener if (!(e.getDamager() instanceof Projectile projectile)) return; if (!(projectile.getShooter() instanceof LivingEntity damager)) return; - ItemStack bow = EnchantManager.getArrowWeapon(projectile); + ItemStack bow = this.getSourceWeapon(projectile); if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; EnchantManager.getItemCustomEnchants(bow, BowEnchant.class).forEach((bowEnchant, level) -> { @@ -131,7 +144,7 @@ public class EnchantHandlerListener extends AbstractListener public void onEnchantBowHit(ProjectileHitEvent e) { Projectile projectile = e.getEntity(); - ItemStack bow = EnchantManager.getArrowWeapon(projectile); + ItemStack bow = this.getSourceWeapon(projectile); if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; EnchantManager.getItemCustomEnchants(bow, BowEnchant.class).forEach((bowEnchant, level) -> { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java index 7e854ab..66fdccf 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java @@ -8,11 +8,13 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.menu.*; +import su.nexmedia.engine.lang.LangManager; import su.nexmedia.engine.utils.CollectionsUtil; import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PDCUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.config.Lang; import su.nightexpress.excellentenchants.manager.EnchantRegister; import java.util.*; @@ -63,9 +65,9 @@ public class EnchantListGUI extends AbstractMenu { // Override the conflicts placeholder display to make it in a list. List conflicts = enchant.getConflicts().isEmpty() - ? plugin.lang().Other_None.asList() + ? plugin.getMessage(Lang.OTHER_NONE).asList() : enchant.getConflicts().stream().filter(Objects::nonNull) - .map(en -> plugin.lang().getEnchantment(en)).toList(); + .map(LangManager::getEnchantment).toList(); ItemUtil.replaceLore(icon, ExcellentEnchant.PLACEHOLDER_CONFLICTS, conflicts); ItemUtil.replace(icon, enchant.formatString(level)); diff --git a/Core/src/main/resources/config.yml b/Core/src/main/resources/config.yml index d318b31..dc7d9fd 100644 --- a/Core/src/main/resources/config.yml +++ b/Core/src/main/resources/config.yml @@ -10,8 +10,8 @@ Plugin: # To create a new language config, simply copy the default one and rename it to your language code. Language: en # Plugin prefix name. - # To change a prefix format, edit language config in '/NexEngine/lang'. - Prefix: ExcellentEnchants + Name: ExcellentEnchants + Prefix: '&e%plugin_name% &8» &7' # General plugin settings. General: diff --git a/Core/src/main/resources/enchants/aquaman.yml b/Core/src/main/resources/enchants/aquaman.yml index 40af9a7..72ecd4b 100644 --- a/Core/src/main/resources/enchants/aquaman.yml +++ b/Core/src/main/resources/enchants/aquaman.yml @@ -1,31 +1,73 @@ -Name: 'Aquaman' -Tier: 'exotic' +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. +Name: Aquaman +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. +Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 %enchantment_cost_item%.' +- Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 + %enchantment_cost_item%. +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 1 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' +# Enchantment settings for Enchanting Table. Enchanting_Table: + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level_By_Exp_Cost: '%enchantment_level% * 15.0' + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 25.0 Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: true + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: PRISMARINE_SHARD Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '1' - Duration: '25.0' \ No newline at end of file + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: '25.0' diff --git a/Core/src/main/resources/enchants/bane_of_netherspawn.yml b/Core/src/main/resources/enchants/bane_of_netherspawn.yml index a8499d5..8b677df 100644 --- a/Core/src/main/resources/enchants/bane_of_netherspawn.yml +++ b/Core/src/main/resources/enchants/bane_of_netherspawn.yml @@ -1,34 +1,80 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_damage%: Enchantment Damage + +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Bane of Netherspawn +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to inflict %enchantment_damage% more damage to Nether mobs.' +- '%enchantment_trigger_chance%% chance to inflict %enchantment_damage% more damage + to Nether mobs.' +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 25.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '6 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 6 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 80.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 80.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 80.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 50.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'SMOKE_NORMAL' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: SMOKE_NORMAL + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' + # Enchantment damage settings. Damage: + # When 'true' damage 'Formula' will work as a multiplier to the original damage. + # When 'false' damage 'Formula' will be added to the original damage. As_Modifier: false - Formula: '0.5 * %enchantment_level%' + # Damage formula. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Formula: 0.5 * %enchantment_level% diff --git a/Core/src/main/resources/enchants/blast_mining.yml b/Core/src/main/resources/enchants/blast_mining.yml index 65fa1c1..d61b8c3 100644 --- a/Core/src/main/resources/enchants/blast_mining.yml +++ b/Core/src/main/resources/enchants/blast_mining.yml @@ -1,31 +1,72 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_explosion_power%: Enchantment Explosion Power + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Blast Mining +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: legendary +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to mine blocks by x%enchantment_explosion_power% power explosion.' +- '%enchantment_trigger_chance%% chance to mine blocks by x%enchantment_explosion_power% + power explosion.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 5.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '6.0 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 6.0 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 10.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 10.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '20.0 * %enchantment_level%' - Min_Block_Strength: '1.5 - %enchantment_level% / 10' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 20.0 * %enchantment_level% + # Minimal block strength value for the enchantment to be triggered. + # Block strength value is how long it takes to break the block by a hand. + # For example, a Stone has 3.0 strength. + Min_Block_Strength: 1.5 - %enchantment_level% / 10 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment explosion settings. Explosion: - Power: '3.0 + (%enchantment_level% - 1.0 * 0.25)' + # Explosion power. The more power = the more blocks (area) to explode. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Power: 3.0 + (%enchantment_level% - 1.0 * 0.25) diff --git a/Core/src/main/resources/enchants/blindness.yml b/Core/src/main/resources/enchants/blindness.yml index ece0797..5791b78 100644 --- a/Core/src/main/resources/enchants/blindness.yml +++ b/Core/src/main/resources/enchants/blindness.yml @@ -1,34 +1,82 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Blindness +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% + for %enchantment_potion_duration%s. on hit.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 60.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 60.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 60.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 60.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 30.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '15.0 + %enchantment_level% * 3' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 15.0 + %enchantment_level% * 3 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '3.5 + %enchantment_level%' + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 3.5 + %enchantment_level% + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' + # Particle effect that will be played on enchantment trigger. Particle: + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html Name: SMOKE_NORMAL + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/bomber.yml b/Core/src/main/resources/enchants/bomber.yml index 16bc189..8650e99 100644 --- a/Core/src/main/resources/enchants/bomber.yml +++ b/Core/src/main/resources/enchants/bomber.yml @@ -1,29 +1,65 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_fuse_ticks%: Enchantment Fuse Ticks + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Bomber +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to launch TNT that explodes in %enchantment_fuse_ticks%s.' +- '%enchantment_trigger_chance%% chance to launch TNT that explodes in %enchantment_fuse_ticks%s.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 5.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '4.0 * %enchantment_level%' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 4.0 * %enchantment_level% + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: TNT Amount: 1 - Fuse_Ticks: '100 - %enchantment_level% * 10' \ No newline at end of file + # Fuse ticks value for the TNT launched. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Fuse_Ticks: 100 - %enchantment_level% * 10 diff --git a/Core/src/main/resources/enchants/bunny_hop.yml b/Core/src/main/resources/enchants/bunny_hop.yml index dc4491f..80637cf 100644 --- a/Core/src/main/resources/enchants/bunny_hop.yml +++ b/Core/src/main/resources/enchants/bunny_hop.yml @@ -1,30 +1,72 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Bunny Hop +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Grants permanent %enchantment_potion_type% %enchantment_potion_level%.' +- Grants permanent %enchantment_potion_type% %enchantment_potion_level%. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 25.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: RABBIT_FOOT + Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: '25.0' + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/cold_steel.yml b/Core/src/main/resources/enchants/cold_steel.yml index e6fff9d..6b680ec 100644 --- a/Core/src/main/resources/enchants/cold_steel.yml +++ b/Core/src/main/resources/enchants/cold_steel.yml @@ -1,31 +1,73 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Cold Steel +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. to attacker.' +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% + for %enchantment_potion_duration%s. to attacker.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 30.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '60.0 + %enchantment_level% * 5' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 60.0 + %enchantment_level% * 5 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '4.0 + %enchantment_level%' + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 4.0 + %enchantment_level% + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/confusing_arrows.yml b/Core/src/main/resources/enchants/confusing_arrows.yml index f5f8202..fa95d78 100644 --- a/Core/src/main/resources/enchants/confusing_arrows.yml +++ b/Core/src/main/resources/enchants/confusing_arrows.yml @@ -1,32 +1,73 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Confusing Arrows +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' +- '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% + %enchantment_potion_level% (%enchantment_potion_duration%s.)' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 45.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 60.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 75.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 60.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 35.0 - +# Individual enchantment settings. Settings: - Trigger_Chance: '20.0 + %enchantment_level% * 5.0' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 20.0 + %enchantment_level% * 5.0 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '6.0 + %enchantment_level% * 3.0' - Level: '%enchantment_level%' \ No newline at end of file + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 6.0 + %enchantment_level% * 3.0 + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/confusion.yml b/Core/src/main/resources/enchants/confusion.yml index d3d0898..4b61618 100644 --- a/Core/src/main/resources/enchants/confusion.yml +++ b/Core/src/main/resources/enchants/confusion.yml @@ -1,34 +1,82 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Confusion +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% + for %enchantment_potion_duration%s. on hit.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 30.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '15.0 * %enchantment_level%' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 15.0 * %enchantment_level% + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '5.0 + %enchantment_level% * 1.5' + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 5.0 + %enchantment_level% * 1.5 + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'ITEM_CRACK' - Data: 'ROTTEN_FLESH' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: ITEM_CRACK + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) + Data: ROTTEN_FLESH diff --git a/Core/src/main/resources/enchants/cure.yml b/Core/src/main/resources/enchants/cure.yml index 36287c7..9920323 100644 --- a/Core/src/main/resources/enchants/cure.yml +++ b/Core/src/main/resources/enchants/cure.yml @@ -1,32 +1,73 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Cure +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to cure Zombified Piglins and Zombie Villagers.' +- '%enchantment_trigger_chance%% chance to cure Zombified Piglins and Zombie Villagers.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 60.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '5 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 5 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 60.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 75.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '20.0 + %enchantment_level% * 8' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 20.0 + %enchantment_level% * 8 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'CLOUD' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: CLOUD + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' + # Sound that will be played on enchantment trigger. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html Sound: '' diff --git a/Core/src/main/resources/enchants/curse_of_breaking.yml b/Core/src/main/resources/enchants/curse_of_breaking.yml index c50b046..04d15d0 100644 --- a/Core/src/main/resources/enchants/curse_of_breaking.yml +++ b/Core/src/main/resources/enchants/curse_of_breaking.yml @@ -1,29 +1,66 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_durability_amount%: Enchantment Durability Amount + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: true +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Curse of Breaking +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: cursed +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance the item will consume extra %enchantment_durability_amount% durability points.' +- '%enchantment_trigger_chance%% chance the item will consume extra %enchantment_durability_amount% + durability points.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '15.0 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 15.0 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 0.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '10.0 * %enchantment_level%' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 10.0 * %enchantment_level% + # Amount of durability points to be taken from the item. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Durability_Amount: '%enchantment_level%' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR - Amount: 1 \ No newline at end of file + Amount: 1 diff --git a/Core/src/main/resources/enchants/curse_of_misfortune.yml b/Core/src/main/resources/enchants/curse_of_misfortune.yml index b258490..f81da4f 100644 --- a/Core/src/main/resources/enchants/curse_of_misfortune.yml +++ b/Core/src/main/resources/enchants/curse_of_misfortune.yml @@ -1,29 +1,63 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: true +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Curse of Misfortune +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: cursed +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to have no drops from blocks or mobs.' +- '%enchantment_trigger_chance%% chance to have no drops from blocks or mobs.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 1 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '15.0 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 15.0 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 0.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '20.0 * %enchantment_level%' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 20.0 * %enchantment_level% + # When 'false', it will also prevent exp drop from the blocks. Drop_Exp: false + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR - Amount: 1 \ No newline at end of file + Amount: 1 diff --git a/Core/src/main/resources/enchants/cutter.yml b/Core/src/main/resources/enchants/cutter.yml index 04c5430..5ff0bea 100644 --- a/Core/src/main/resources/enchants/cutter.yml +++ b/Core/src/main/resources/enchants/cutter.yml @@ -1,31 +1,70 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_durability_damage%: Enchantment Durability Damage + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Cutter +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to throw away enemy''s armor and damage it for %enchantment_durability_damage%%.' +- '%enchantment_trigger_chance%% chance to throw away enemy''s armor and damage it + for %enchantment_durability_damage%%.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 0.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '6 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 6 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 5.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '1.0 + %enchantment_level% * 0.6' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 1.0 + %enchantment_level% * 0.6 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 Item: + # Amount (in percent) of how much item durability will be reduced. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Durability_Reduction: '%enchantment_level% / 100.0' + # A sound to play when item durability is reduced. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html Sound: ENTITY_ITEM_BREAK diff --git a/Core/src/main/resources/enchants/decapitator.yml b/Core/src/main/resources/enchants/decapitator.yml index 814e8f2..fe98f39 100644 --- a/Core/src/main/resources/enchants/decapitator.yml +++ b/Core/src/main/resources/enchants/decapitator.yml @@ -1,42 +1,88 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Decapitator +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to obtain player''s or mob''s head.' +- '%enchantment_trigger_chance%% chance to obtain player''s or mob''s head.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 4 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '7 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 7 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 30.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 15.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '5.0 + %enchantment_level% * 1.75' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 5.0 + %enchantment_level% * 1.75 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'BLOCK_CRACK' - Data: 'REDSTONE_BLOCK' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: BLOCK_CRACK + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) + Data: REDSTONE_BLOCK + # List of entity types that will not drop the heads. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html Ignored_Entity_Types: - - BAT - - BEE - - ENDER_DRAGON - - WITHER_SKELETON - - WITHER + - BAT + - BEE + - ENDER_DRAGON + - WITHER_SKELETON + - WITHER + # Settings for the head item. Head_Item: + # Item display name. Use '%entity%' for entity name. Name: '&cHead of &e%entity%' + # 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 Textures: AXOLOTL: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNThkYTFhMGEyYTEzZGQyMDliZmMyNTI5ZDljN2MyOWEyOWRkOWEyM2ZmNGI4MGIzOGI4OTk2MTc3MmU4MDM5ZSJ9fX0= BAT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWU5OWRlZWY5MTlkYjY2YWMyYmQyOGQ2MzAyNzU2Y2NkNTdjN2Y4YjEyYjlkY2E4ZjQxYzNlMGEwNGFjMWNjIn19fQ== diff --git a/Core/src/main/resources/enchants/divine_touch.yml b/Core/src/main/resources/enchants/divine_touch.yml index 281457c..57bfd67 100644 --- a/Core/src/main/resources/enchants/divine_touch.yml +++ b/Core/src/main/resources/enchants/divine_touch.yml @@ -1,33 +1,74 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Divine Touch +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: legendary +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to obtain &fMob Spawner&8.' +- '%enchantment_trigger_chance%% chance to obtain &fMob Spawner&8.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 5.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '6.0 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 6.0 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 5.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 5.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 8.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '15.0 * %enchantment_level%' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 15.0 * %enchantment_level% + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'VILLAGER_HAPPY' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: VILLAGER_HAPPY + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' + # Spawner item settings. Spawner_Item: + # Spawner display name. Use '%type%' for entity type name. Name: '&aMob Spawner &7(%type%)' diff --git a/Core/src/main/resources/enchants/double_strike.yml b/Core/src/main/resources/enchants/double_strike.yml index 78ca809..dd30405 100644 --- a/Core/src/main/resources/enchants/double_strike.yml +++ b/Core/src/main/resources/enchants/double_strike.yml @@ -1,32 +1,73 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Double Strike +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: legendary +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to inflict double damage.' +- '%enchantment_trigger_chance%% chance to inflict double damage.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 4 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 10.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '7 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 7 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 10.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 10.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 15.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 10.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '4.0 + %enchantment_level% * 0.8' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 4.0 + %enchantment_level% * 0.8 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'EXPLOSION_NORMAL' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: EXPLOSION_NORMAL + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' - Sound: 'ENTITY_GENERIC_EXPLODE' + # Sound that will be played on enchantment trigger. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html + Sound: ENTITY_GENERIC_EXPLODE diff --git a/Core/src/main/resources/enchants/dragonfire_arrows.yml b/Core/src/main/resources/enchants/dragonfire_arrows.yml index 2adb6c8..a862d96 100644 --- a/Core/src/main/resources/enchants/dragonfire_arrows.yml +++ b/Core/src/main/resources/enchants/dragonfire_arrows.yml @@ -1,35 +1,83 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_fire_radius%: Enchantment Fire Radius +# - %enchantment_fire_duration%: Enchantment Fire Duration + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Dragonfire Arrows +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to launch an dragonfire arrow (R=%enchantment_fire_radius%, %enchantment_fire_duration%s).' +- '%enchantment_trigger_chance%% chance to launch an dragonfire arrow (R=%enchantment_fire_radius%, + %enchantment_fire_duration%s).' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 25.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 25.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 5.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '10.0 + %enchantment_level% * 5' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 10.0 + %enchantment_level% * 5 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment dragonfire settings. Fire: + # Dragonfire area cloud effect duration. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: '%enchantment_level% * 100.0' - Radius: '2.0 + %enchantment_level%' + # Dragonfire area cloud effect radius. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Radius: 2.0 + %enchantment_level% + # Enchantment arrow settings. Arrow: + # A particle effect to play as an arrow trail. Trail: - Name: 'DRAGON_BREATH' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: DRAGON_BREATH + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/electrified_arrows.yml b/Core/src/main/resources/enchants/electrified_arrows.yml index 55aa95e..ddb7ea2 100644 --- a/Core/src/main/resources/enchants/electrified_arrows.yml +++ b/Core/src/main/resources/enchants/electrified_arrows.yml @@ -1,33 +1,72 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Electrified Arrows +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to launch an electrified arrow.' +- '%enchantment_trigger_chance%% chance to launch an electrified arrow.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 75.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 25.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 45.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 10.0 - +# Individual enchantment settings. Settings: - Trigger_Chance: '10.0 + %enchantment_level% * 5' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 10.0 + %enchantment_level% * 5 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment arrow settings. Arrow: + # A particle effect to play as an arrow trail. Trail: - Name: 'FIREWORKS_SPARK' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: FIREWORKS_SPARK + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/ender_bow.yml b/Core/src/main/resources/enchants/ender_bow.yml index a461d67..3d74a98 100644 --- a/Core/src/main/resources/enchants/ender_bow.yml +++ b/Core/src/main/resources/enchants/ender_bow.yml @@ -1,28 +1,61 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Ender Bow +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: legendary +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to shoot Ender Pearl instead of arrows.' +- '%enchantment_trigger_chance%% chance to shoot Ender Pearl instead of arrows.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 1 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 5.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level_By_Exp_Cost: '30' + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 5.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 3.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 10.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: ENDER_PEARL Amount: 1 diff --git a/Core/src/main/resources/enchants/exhaust.yml b/Core/src/main/resources/enchants/exhaust.yml index 48270e9..1f05961 100644 --- a/Core/src/main/resources/enchants/exhaust.yml +++ b/Core/src/main/resources/enchants/exhaust.yml @@ -1,34 +1,82 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Exhaust +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% + for %enchantment_potion_duration%s. on hit.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 70.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 70.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 70.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 70.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 50.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '20.0 * %enchantment_level%' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 20.0 * %enchantment_level% + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '3.0 + %enchantment_level% * 1.5' + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 3.0 + %enchantment_level% * 1.5 + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' + # Particle effect that will be played on enchantment trigger. Particle: + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html Name: '' + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/exp_hunter.yml b/Core/src/main/resources/enchants/exp_hunter.yml index 4db663e..5d8b4fd 100644 --- a/Core/src/main/resources/enchants/exp_hunter.yml +++ b/Core/src/main/resources/enchants/exp_hunter.yml @@ -1,29 +1,66 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_exp_modifier%: Enchantment Exp Modifier + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Exp Hunter +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to obtain +%enchantment_exp_modifier%% more exp from mobs.' +- '%enchantment_trigger_chance%% chance to obtain +%enchantment_exp_modifier%% more + exp from mobs.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 45.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '6 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 6 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 45.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 45.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 45.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '50.0 + %enchantment_level% * 5' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 50.0 + %enchantment_level% * 5 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 - Exp_Modifier: '1.0 + %enchantment_level% * 0.5' + # Exp modifier value. The original exp amount will be multiplied on this value. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Exp_Modifier: 1.0 + %enchantment_level% * 0.5 diff --git a/Core/src/main/resources/enchants/explosive_arrows.yml b/Core/src/main/resources/enchants/explosive_arrows.yml index fbd95e2..c4092f6 100644 --- a/Core/src/main/resources/enchants/explosive_arrows.yml +++ b/Core/src/main/resources/enchants/explosive_arrows.yml @@ -1,37 +1,85 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_explosion_power%: Enchantment Explosion Power + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Explosive Arrows +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to launch an explosive arrow with x%enchantment_explosion_power% power.' +- '%enchantment_trigger_chance%% chance to launch an explosive arrow with x%enchantment_explosion_power% + power.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 40.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 40.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 25.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '10.0 + %enchantment_level% * 5' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 10.0 + %enchantment_level% * 5 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment explosion settings. Explosion: + # When 'true' an explosion will create fire on nearby blocks. Fire_Spread: true + # When 'true' an explosion will destroy all nearby items on the ground. Damage_Items: true + # When 'true' an explosion will destroy blocks. Damage_Blocks: false - Size: '2.0 + %enchantment_level%' + # Explosion size. The more size = the more damage and explosion area. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Size: 2.0 + %enchantment_level% + # Enchantment arrow settings. Arrow: + # A particle effect to play as an arrow trail. Trail: - Name: 'SMOKE_NORMAL' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: SMOKE_NORMAL + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/flame_walker.yml b/Core/src/main/resources/enchants/flame_walker.yml index 5c7a9dd..2e5f18f 100644 --- a/Core/src/main/resources/enchants/flame_walker.yml +++ b/Core/src/main/resources/enchants/flame_walker.yml @@ -1,29 +1,64 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Flame Walker +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Ability to walk on lava and on magma blocks without getting damage.' +- Ability to walk on lava and on magma blocks without getting damage. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 40.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 40.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 - Block_Decay: '5.0 + %enchantment_level% * 2' + # How soon (in seconds) blocks created by the enchantment will be destroyed back to lava? + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Block_Decay: 5.0 + %enchantment_level% * 2 diff --git a/Core/src/main/resources/enchants/ghast.yml b/Core/src/main/resources/enchants/ghast.yml index f9f2766..9ebe12c 100644 --- a/Core/src/main/resources/enchants/ghast.yml +++ b/Core/src/main/resources/enchants/ghast.yml @@ -1,30 +1,66 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Ghast +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to launch a fireball instead of arrow.' +- '%enchantment_trigger_chance%% chance to launch a fireball instead of arrow.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 40.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 40.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 20.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # When 'true' a fireball explosion will ignite nearby blocks. Fire_Spread: true - Yield: '1.0 * %enchantment_level%' + # Fireball explosion size/radius. The more value = the bigger the explosion. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Yield: 1.0 * %enchantment_level% + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR - Amount: 1 \ No newline at end of file + Amount: 1 diff --git a/Core/src/main/resources/enchants/hardened.yml b/Core/src/main/resources/enchants/hardened.yml index 3f515e9..7e6c9e2 100644 --- a/Core/src/main/resources/enchants/hardened.yml +++ b/Core/src/main/resources/enchants/hardened.yml @@ -1,31 +1,73 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Hardened +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to obtain %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. when damaged.' +- '%enchantment_trigger_chance%% chance to obtain %enchantment_potion_type% %enchantment_potion_level% + for %enchantment_potion_duration%s. when damaged.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 30.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 20.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '10.0 + %enchantment_level% * 5' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 10.0 + %enchantment_level% * 5 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '2.5 + %enchantment_level%' + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 2.5 + %enchantment_level% + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/haste.yml b/Core/src/main/resources/enchants/haste.yml index 076ae8d..cb90fd0 100644 --- a/Core/src/main/resources/enchants/haste.yml +++ b/Core/src/main/resources/enchants/haste.yml @@ -1,31 +1,72 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Haste +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Grants %enchantment_potion_type% %enchantment_potion_level% effect.' +- Grants %enchantment_potion_type% %enchantment_potion_level% effect. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 40.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 40.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: SUGAR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: '25.0' + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/hover.yml b/Core/src/main/resources/enchants/hover.yml index daa294f..5a89096 100644 --- a/Core/src/main/resources/enchants/hover.yml +++ b/Core/src/main/resources/enchants/hover.yml @@ -1,31 +1,73 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Hover +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' +- '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% + %enchantment_potion_level% (%enchantment_potion_duration%s.)' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 30.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 10.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '10.0 + %enchantment_level% * 5' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 10.0 + %enchantment_level% * 5 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '2.5 + %enchantment_level%' - Level: '%enchantment_level%' \ No newline at end of file + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 2.5 + %enchantment_level% + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/ice_aspect.yml b/Core/src/main/resources/enchants/ice_aspect.yml index 5ebd743..f66d4e7 100644 --- a/Core/src/main/resources/enchants/ice_aspect.yml +++ b/Core/src/main/resources/enchants/ice_aspect.yml @@ -1,34 +1,82 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Ice Aspect +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to freeze and apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +- '%enchantment_trigger_chance%% chance to freeze and apply %enchantment_potion_type% + %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 70.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 70.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 70.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 70.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 50.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '25.0 * %enchantment_level%' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 25.0 * %enchantment_level% + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '3.0 + %enchantment_level%' + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 3.0 + %enchantment_level% + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'BLOCK_CRACK' - Data: 'ICE' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: BLOCK_CRACK + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) + Data: ICE diff --git a/Core/src/main/resources/enchants/infernus.yml b/Core/src/main/resources/enchants/infernus.yml index f4f2610..b5dbb23 100644 --- a/Core/src/main/resources/enchants/infernus.yml +++ b/Core/src/main/resources/enchants/infernus.yml @@ -1,29 +1,66 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_fire_duration%: Enchantment Fire Duration + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Infernus +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to launch flaming Trident that ignites the enemy for %enchantment_fire_duration%s.' +- '%enchantment_trigger_chance%% chance to launch flaming Trident that ignites the + enemy for %enchantment_fire_duration%s.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 45.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 35.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 45.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 45.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 30.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 - Fire_Ticks: '60 + %enchantment_level% * 20' + # How long (in ticks, 20 ticks = 1 second) the damaged entity will be ignited for? + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + 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 index 1108e9b..c484974 100644 --- a/Core/src/main/resources/enchants/lucky_miner.yml +++ b/Core/src/main/resources/enchants/lucky_miner.yml @@ -1,29 +1,66 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_exp_modifier%: Enchantment Exp Modifier + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Lucky Miner +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to obtain +%enchantment_exp_modifier%% more exp from ores.' +- '%enchantment_trigger_chance%% chance to obtain +%enchantment_exp_modifier%% more + exp from ores.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '6 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 6 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 60.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '30.0 + %enchantment_level% * 7.0' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 30.0 + %enchantment_level% * 7.0 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 - Exp_Modifier: '1.0 + %enchantment_level% * 0.5' + # Exp modifier value. The original exp amount will be multiplied on this value. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Exp_Modifier: 1.0 + %enchantment_level% * 0.5 diff --git a/Core/src/main/resources/enchants/night_vision.yml b/Core/src/main/resources/enchants/night_vision.yml index 983b628..cae0def 100644 --- a/Core/src/main/resources/enchants/night_vision.yml +++ b/Core/src/main/resources/enchants/night_vision.yml @@ -1,31 +1,73 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Night Vision +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 %enchantment_cost_item%.' +- Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 + %enchantment_cost_item%. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 1 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level_By_Exp_Cost: '15' + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: true + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: GLOWSTONE_DUST Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: '60.0' + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '1' diff --git a/Core/src/main/resources/enchants/nimble.yml b/Core/src/main/resources/enchants/nimble.yml index 247f80a..b6796b2 100644 --- a/Core/src/main/resources/enchants/nimble.yml +++ b/Core/src/main/resources/enchants/nimble.yml @@ -1,28 +1,61 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Nimble +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Moves all mob''s loot directly to your inventory.' +- Moves all mob's loot directly to your inventory. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 1 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 40.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '15 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 15 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 40.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR - Amount: 1 \ No newline at end of file + Amount: 1 diff --git a/Core/src/main/resources/enchants/paralyze.yml b/Core/src/main/resources/enchants/paralyze.yml index bba51b5..1c1ea3e 100644 --- a/Core/src/main/resources/enchants/paralyze.yml +++ b/Core/src/main/resources/enchants/paralyze.yml @@ -1,34 +1,82 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Paralyze +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% + for %enchantment_potion_duration%s. on hit.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 25.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '10.0 * %enchantment_level%' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 10.0 * %enchantment_level% + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '2.5 + %enchantment_level% * 0.5' + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 2.5 + %enchantment_level% * 0.5 + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'CRIT_MAGIC' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: CRIT_MAGIC + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/poisoned_arrows.yml b/Core/src/main/resources/enchants/poisoned_arrows.yml index 950bf77..f849a0a 100644 --- a/Core/src/main/resources/enchants/poisoned_arrows.yml +++ b/Core/src/main/resources/enchants/poisoned_arrows.yml @@ -1,31 +1,73 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Poisoned Arrows +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' +- '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% + %enchantment_potion_level% (%enchantment_potion_duration%s.)' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 30.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '25.0 + %enchantment_level% * 5' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 25.0 + %enchantment_level% * 5 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '2.0 + %enchantment_level%' - Level: '%enchantment_level%' \ No newline at end of file + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 2.0 + %enchantment_level% + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/rage.yml b/Core/src/main/resources/enchants/rage.yml index f5228ff..8705c6b 100644 --- a/Core/src/main/resources/enchants/rage.yml +++ b/Core/src/main/resources/enchants/rage.yml @@ -1,34 +1,82 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Rage +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to get %enchantment_potion_type% %enchantment_potion_level% effect for %enchantment_potion_duration%s. on hit.' +- '%enchantment_trigger_chance%% chance to get %enchantment_potion_type% %enchantment_potion_level% + effect for %enchantment_potion_duration%s. on hit.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 30.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 15.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '7.0 + %enchantment_level%' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 7.0 + %enchantment_level% + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '3.0 + %enchantment_level% * 0.5' + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 3.0 + %enchantment_level% * 0.5 + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'LAVA' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: LAVA + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/regrowth.yml b/Core/src/main/resources/enchants/regrowth.yml index 4736309..c24c3e4 100644 --- a/Core/src/main/resources/enchants/regrowth.yml +++ b/Core/src/main/resources/enchants/regrowth.yml @@ -1,34 +1,80 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_health_amount%: Enchantment Health Amount +# - %enchantment_health_interval%: Enchantment Health Interval + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Regrowth +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Restores %enchantment_health_amount% hearts every %enchantment_health_interval%s. with %enchantment_trigger_chance%% chance.' +- Restores %enchantment_health_amount% hearts every %enchantment_health_interval%s. + with %enchantment_trigger_chance%% chance. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 15.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '6 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 6 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 10.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 15.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 15.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 10.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '20.0 + %enchantment_level% * 5' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 20.0 + %enchantment_level% * 5 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'HEART' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: HEART + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' + # Enchantment health restore settings. Health: + # How many hearts will be restored on enchantment trigger? + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Amount: '%enchantment_level% * 0.25' - Interval: 100 \ No newline at end of file + # How often (in ticks, 20 ticks = 1 second) enchantment will be triggered? + Interval: 100 diff --git a/Core/src/main/resources/enchants/replanter.yml b/Core/src/main/resources/enchants/replanter.yml index 9f87016..8f8ca8f 100644 --- a/Core/src/main/resources/enchants/replanter.yml +++ b/Core/src/main/resources/enchants/replanter.yml @@ -1,31 +1,67 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Replanter +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Automatically replant crops on right click and harvest.' +- Automatically replant crops on right click and harvest. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 1 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level_By_Exp_Cost: '15' + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment replant settings. Replant: + # When 'true', player will be able to replant crops when right-clicking the farmlang. On_Right_Click: true + # When 'true', crops will be automatically replanted when player breaks the plant with enchanted tool in hand. On_Plant_Break: true diff --git a/Core/src/main/resources/enchants/rocket.yml b/Core/src/main/resources/enchants/rocket.yml index ef46c87..63c7f62 100644 --- a/Core/src/main/resources/enchants/rocket.yml +++ b/Core/src/main/resources/enchants/rocket.yml @@ -1,29 +1,64 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Rocket +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to launch your enemy into the space.' +- '%enchantment_trigger_chance%% chance to launch your enemy into the space.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 20.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '4.0 + %enchantment_level%' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 4.0 + %enchantment_level% + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Firework power. The more power = the higher the fly distance. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Firework_Power: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/saturation.yml b/Core/src/main/resources/enchants/saturation.yml index d212924..b43ee5b 100644 --- a/Core/src/main/resources/enchants/saturation.yml +++ b/Core/src/main/resources/enchants/saturation.yml @@ -1,31 +1,71 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_saturation_amount%: Enchantment Saturation Amount +# - %enchantment_saturation_interval%: Enchantment Saturation Interval + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Saturation +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Restores %enchantment_saturation_amount% food points every %enchantment_saturation_interval%s. with %enchantment_trigger_chance%% chance.' +- Restores %enchantment_saturation_amount% food points every %enchantment_saturation_interval%s. + with %enchantment_trigger_chance%% chance. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 25.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 25.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '25.0 + %enchantment_level% * 5' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 25.0 + %enchantment_level% * 5 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment saturation settings. Saturation: + # How much of food points will be restored on enchantment trigger? + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Amount: '%enchantment_level%' + # How often (in ticks, 20 ticks = 1 second) this enchantment will be triggered? Interval: 150 diff --git a/Core/src/main/resources/enchants/scavenger.yml b/Core/src/main/resources/enchants/scavenger.yml index a116f83..71a0194 100644 --- a/Core/src/main/resources/enchants/scavenger.yml +++ b/Core/src/main/resources/enchants/scavenger.yml @@ -1,37 +1,77 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Scavenger +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to obtain additional loot from mobs.' +- '%enchantment_trigger_chance%% chance to obtain additional loot from mobs.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 4 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 60.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '7 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 7 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 60.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 70.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 70.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '15.0 + %enchantment_level% * 10' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 15.0 + %enchantment_level% * 10 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment treasures table. 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: + # Item amount. Syntax: 'Min:Max'. Amount: '1:1' + # Item drop chance. Chance: 5.0 SKELETON: BONE_MEAL: Amount: '1:2' - Chance: 50.0 \ No newline at end of file + Chance: 50.0 diff --git a/Core/src/main/resources/enchants/self_destruction.yml b/Core/src/main/resources/enchants/self_destruction.yml index a5a6579..4843874 100644 --- a/Core/src/main/resources/enchants/self_destruction.yml +++ b/Core/src/main/resources/enchants/self_destruction.yml @@ -1,30 +1,68 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_explosion_power%: Enchantment Explosion Power + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Self-Destruction +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to create an x%enchantment_explosion_power% power explosion on death.' +- '%enchantment_trigger_chance%% chance to create an x%enchantment_explosion_power% + power explosion on death.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 15.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '20.0 + %enchantment_level% * 10' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 20.0 + %enchantment_level% * 10 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment explosion settings. Explosion: - Size: '1.0 + %enchantment_level%' + # Explosion size. The more size = the bigger the explosion. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + 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 index cab74c3..5e5c795 100644 --- a/Core/src/main/resources/enchants/silk_chest.yml +++ b/Core/src/main/resources/enchants/silk_chest.yml @@ -1,30 +1,68 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Silk Chest +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Drop chests and saves all its content.' +- Drop chests and saves all its content. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 1 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level_By_Exp_Cost: '30' + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 30.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Chest item settings. Chest_Item: + # Item display name. + # Placeholders: + # - %name% - Item material name. + # - %items% - Amount of items in chest. Name: '&f%name% &7(%items% items)' diff --git a/Core/src/main/resources/enchants/smelter.yml b/Core/src/main/resources/enchants/smelter.yml index 0d646f6..d07262c 100644 --- a/Core/src/main/resources/enchants/smelter.yml +++ b/Core/src/main/resources/enchants/smelter.yml @@ -1,38 +1,84 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Smelter +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to smelt ore or a block on mining.' +- '%enchantment_trigger_chance%% chance to smelt ore or a block on mining.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 60.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '5 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 5 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 60.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 60.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 60.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 60.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '25.0 + %enchantment_level% * 10' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 25.0 + %enchantment_level% * 10 + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'FLAME' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: FLAME + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Smelting table. + # 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 Smelting_Table: IRON_ORE: IRON_INGOT RAW_IRON: IRON_INGOT GOLD_ORE: GOLD_INGOT RAW_GOLD: GOLD_INGOT RAW_COPPER: COPPER_INGOT - SAND: GLASS \ No newline at end of file + SAND: GLASS + # Sound that will be played on enchantment trigger. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html + Sound: BLOCK_LAVA_EXTINGUISH diff --git a/Core/src/main/resources/enchants/sonic.yml b/Core/src/main/resources/enchants/sonic.yml index 73ebc7f..a1b3885 100644 --- a/Core/src/main/resources/enchants/sonic.yml +++ b/Core/src/main/resources/enchants/sonic.yml @@ -1,30 +1,72 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Sonic +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Grants %enchantment_potion_type% %enchantment_potion_level% effect.' +- Grants %enchantment_potion_type% %enchantment_potion_level% effect. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 30.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 20.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: FEATHER + Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: '25.0' + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/surprise.yml b/Core/src/main/resources/enchants/surprise.yml index b606b24..6ce5ad9 100644 --- a/Core/src/main/resources/enchants/surprise.yml +++ b/Core/src/main/resources/enchants/surprise.yml @@ -1,34 +1,82 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Surprise +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to apply random potion effect to enemy on hit.' +- '%enchantment_trigger_chance%% chance to apply random potion effect to enemy on + hit.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 40.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '2.25 * %enchantment_level%' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 2.25 * %enchantment_level% + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '3.0 + %enchantment_level%' + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 3.0 + %enchantment_level% + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'SPELL_WITCH' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: SPELL_WITCH + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/telekinesis.yml b/Core/src/main/resources/enchants/telekinesis.yml index 902a65c..f4b8dcc 100644 --- a/Core/src/main/resources/enchants/telekinesis.yml +++ b/Core/src/main/resources/enchants/telekinesis.yml @@ -1,31 +1,65 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Telekinesis +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Moves all blocks loot directly to your inventory.' +- Moves all blocks loot directly to your inventory. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Message to display for a player with a list of received items. Message: Drop_Received: '{message: ~type: ACTION_BAR; ~prefix: false;}%items%' Item_Name: '&7x%item_amount% &f%item_name%' diff --git a/Core/src/main/resources/enchants/temper.yml b/Core/src/main/resources/enchants/temper.yml index e55ce7c..767c14c 100644 --- a/Core/src/main/resources/enchants/temper.yml +++ b/Core/src/main/resources/enchants/temper.yml @@ -1,34 +1,79 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_damage_amount%: Enchantment Damage Amount +# - %enchantment_damage_capacity%: Enchantment Damage Capacity +# - %enchantment_health_point%: Enchantment Health Point + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Temper +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to inflict %enchantment_damage_amount%% (max. %enchantment_damage_capacity%%) more damage for each %enchantment_health_point% hearts missing.' +- '%enchantment_trigger_chance%% chance to inflict %enchantment_damage_amount%% (max. + %enchantment_damage_capacity%%) more damage for each %enchantment_health_point% + hearts missing.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 25.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '6 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 6 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 15.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 25.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 10.0 - +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment damage settings. Damage: - Amount: '0.01 * %enchantment_level%' + # On how much (in percent) the damage will be increased per each Health Point? + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Amount: 0.01 * %enchantment_level% + # The maximal possible value for the Damage Amount. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Capacity: '2.0' + # Enchantment health settings. Health: + # For how much missing hearts the damage will be increased? + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Point: '0.5' diff --git a/Core/src/main/resources/enchants/thrifty.yml b/Core/src/main/resources/enchants/thrifty.yml index 0e449bd..8dcc233 100644 --- a/Core/src/main/resources/enchants/thrifty.yml +++ b/Core/src/main/resources/enchants/thrifty.yml @@ -1,35 +1,72 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Thrifty +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to obtain mob Spawn Egg on kill.' +- '%enchantment_trigger_chance%% chance to obtain mob Spawn Egg on kill.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 15.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 15.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 10.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 10.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '5.0 + %enchantment_level% * 3' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 5.0 + %enchantment_level% * 3 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # List of entity types, that will not drop spawn eggs. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html Ignored_Entity_Types: - - WITHER - - ENDER_DRAGON + - WITHER + - ENDER_DRAGON + # List of spawn reasons, from which entities will not drop spawn eggs. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/CreatureSpawnEvent.SpawnReason.html Ignored_Spawn_Reasons: - - SPAWNER - - SPAWN_EGG - - DISPENSE_EGG \ No newline at end of file + - SPAWNER + - SPAWN_EGG + - DISPENSE_EGG diff --git a/Core/src/main/resources/enchants/thunder.yml b/Core/src/main/resources/enchants/thunder.yml index d42e8f3..49bcadf 100644 --- a/Core/src/main/resources/enchants/thunder.yml +++ b/Core/src/main/resources/enchants/thunder.yml @@ -1,29 +1,63 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Thunder +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to summon lightning to enemy on hit.' +- '%enchantment_trigger_chance%% chance to summon lightning to enemy on hit.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 70.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 70.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 70.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 70.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 40.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '10.0 * %enchantment_level%' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 10.0 * %enchantment_level% + # When 'true' the enchantment will be triggered only if there is an active thunderstorm in the world. During_Thunderstorm_Only: false + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR - Amount: 1 \ No newline at end of file + Amount: 1 diff --git a/Core/src/main/resources/enchants/treasures.yml b/Core/src/main/resources/enchants/treasures.yml index 2ee454a..8202539 100644 --- a/Core/src/main/resources/enchants/treasures.yml +++ b/Core/src/main/resources/enchants/treasures.yml @@ -1,37 +1,83 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Treasures +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to attempt to find a treasure in mined block.' +- '%enchantment_trigger_chance%% chance to attempt to find a treasure in mined block.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 70.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '6 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 6 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 70.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 75.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 75.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '10.0 + %enchantment_level% * 4.0' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 10.0 + %enchantment_level% * 4.0 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'REDSTONE' - Data: '200,180,0' - Sound: 'BLOCK_NOTE_BLOCK_BELL' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: REDSTONE + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) + Data: 200,180,0 + # Sound that will be played on enchantment trigger. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html + Sound: BLOCK_NOTE_BLOCK_BELL + # Enchantment treasures table. Treasures: + # List of source materials (blocks that will drop additional loot). Separated by a comma. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html STONE,GRANITE,ANDESITE,DIORITE: + # List of Materials and chances for the additional loot. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html AIR: 95.0 BONE_MEAL: 2.0 CLAY: @@ -62,4 +108,4 @@ Settings: APPLE: 15.0 MOSSY_COBBLESTONE,MOSSY_STONE_BRICKS: AIR: 50.0 - VINE: 50.0 \ No newline at end of file + VINE: 50.0 diff --git a/Core/src/main/resources/enchants/tunnel.yml b/Core/src/main/resources/enchants/tunnel.yml index d1a0a53..b9af259 100644 --- a/Core/src/main/resources/enchants/tunnel.yml +++ b/Core/src/main/resources/enchants/tunnel.yml @@ -1,29 +1,63 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Tunnel +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: legendary +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Allows you to mine multiple blocks at once in a shape.' +- Allows you to mine multiple blocks at once in a shape. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # When 'true' the enchantment won't be triggered when sneaking. Ignore_When_Sneaking: true diff --git a/Core/src/main/resources/enchants/vampire.yml b/Core/src/main/resources/enchants/vampire.yml index 1d44088..d9a7a10 100644 --- a/Core/src/main/resources/enchants/vampire.yml +++ b/Core/src/main/resources/enchants/vampire.yml @@ -1,34 +1,79 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_heal_amount%: Enchantment Heal Amount + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Vampire +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to heal yourself for %enchantment_heal_amount% heart(s) on hit.' +- '%enchantment_trigger_chance%% chance to heal yourself for %enchantment_heal_amount% + heart(s) on hit.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 4 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '7 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 7 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 40.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 20.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '10.0 + %enchantment_level% * 5.0' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 10.0 + %enchantment_level% * 5.0 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'HEART' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: HEART + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' + # Enchantment heal settings. Heal: - Amount: '0.35 * %enchantment_level%' + # On how much hearts the damager will be healed? + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Amount: 0.35 * %enchantment_level% + # When 'true', the option above will work as a multiplier of the inflicted damage. As_Multiplier: false diff --git a/Core/src/main/resources/enchants/veinminer.yml b/Core/src/main/resources/enchants/veinminer.yml index 11f8161..e3ea7c8 100644 --- a/Core/src/main/resources/enchants/veinminer.yml +++ b/Core/src/main/resources/enchants/veinminer.yml @@ -1,49 +1,88 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_block_limit%: Enchantment Block Limit + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Veinminer +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - 'Mines up to %enchantment_block_limit% blocks of the ore vein at once.' +- Mines up to %enchantment_block_limit% blocks of the ore vein at once. +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 25.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '10 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 10 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 25.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 25.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment blocks settings. Blocks: - Max_At_Once: '6 + %enchantment_level%' + # How much amount of blocks can be destroted at single use? + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Max_At_Once: 6 + %enchantment_level% + # List of blocks, that will be affected by this enchantment. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html 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 \ No newline at end of file + - 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 index 45bc8c6..6f3a517 100644 --- a/Core/src/main/resources/enchants/venom.yml +++ b/Core/src/main/resources/enchants/venom.yml @@ -1,34 +1,82 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Venom +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% + for %enchantment_potion_duration%s. on hit.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 60.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 60.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 30.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '30.0 + %enchantment_level% * 10.0' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 30.0 + %enchantment_level% * 10.0 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '2.0 + %enchantment_level%' + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 2.0 + %enchantment_level% + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' + # Particle effect that will be played on enchantment trigger. Particle: + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html Name: SLIME + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/village_defender.yml b/Core/src/main/resources/enchants/village_defender.yml index e735a43..60a88cb 100644 --- a/Core/src/main/resources/enchants/village_defender.yml +++ b/Core/src/main/resources/enchants/village_defender.yml @@ -1,34 +1,79 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_damage_amount%: Enchantment Damage Amount + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Village Defender +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to inflict %enchantment_damage_amount% more damage on Pillagers.' +- '%enchantment_trigger_chance%% chance to inflict %enchantment_damage_amount% more + damage on Pillagers.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 60.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '6 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 6 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 80.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 80.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 70.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 +# Individual enchantment settings. Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Particle effect that will be played on enchantment trigger. Particle: - Name: 'VILLAGER_ANGRY' + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Name: VILLAGER_ANGRY + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' + # Enchantment damage settings. Damage: + # When 'true' the 'Damage.Formula' will work as a multiplier to the original damage. As_Modifier: false - Formula: '0.5 * %enchantment_level%' + # On how much the damage will be increased? + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Formula: 0.5 * %enchantment_level% diff --git a/Core/src/main/resources/enchants/wither.yml b/Core/src/main/resources/enchants/wither.yml index c866f72..9425b18 100644 --- a/Core/src/main/resources/enchants/wither.yml +++ b/Core/src/main/resources/enchants/wither.yml @@ -1,34 +1,82 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Wither +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% + for %enchantment_potion_duration%s. on hit.' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 15.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '10.0 + %enchantment_level% * 5' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 10.0 + %enchantment_level% * 5 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '3.0 + %enchantment_level%' + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 3.0 + %enchantment_level% + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' + # Particle effect that will be played on enchantment trigger. Particle: + # Particle name. Set this to empty '' or 'NONE' to disable. + # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html Name: '' + # Particle data (additional settings). + # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html + # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/withered_arrows.yml b/Core/src/main/resources/enchants/withered_arrows.yml index 8002bd9..81c81a2 100644 --- a/Core/src/main/resources/enchants/withered_arrows.yml +++ b/Core/src/main/resources/enchants/withered_arrows.yml @@ -1,31 +1,73 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_potion_level%: Enchantment Potion Level +# - %enchantment_potion_duration%: Enchantment Potion Duration +# - %enchantment_potion_type%: Enchantment Potion Type + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Withered Arrows +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - - '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' +- '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% + %enchantment_potion_level% (%enchantment_potion_duration%s.)' +# Enchantment level settings. Level: + # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# Enchantment settings for Anvil. Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Merge_Cost: '%enchantment_level%' Fishing: + # A chance that this enchantment will be populated on items received from fishing. Chance: 25.0 +# Enchantment settings for Enchanting Table. Enchanting_Table: - Level_By_Exp_Cost: '9 * %enchantment_level%' + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. Chance: 25.0 Villagers: + # A chance that this enchantment will be populated on items in Villager trades. Chance: 25.0 Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 25.0 Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 15.0 +# Individual enchantment settings. Settings: - Trigger_Chance: '15.0 + %enchantment_level% * 5.0' + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: 15.0 + %enchantment_level% * 5.0 + # A cost a player will have to pay to have this enchantment triggered. Cost: + # Enables/Disables cost feature. Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. Item: Material: AIR Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - Duration: '2.5 + %enchantment_level% * 0.75' - Level: '%enchantment_level%' \ No newline at end of file + # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 2.5 + %enchantment_level% * 0.75 + # Potion effect level (amplifier). + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level: '%enchantment_level%' diff --git a/Core/src/main/resources/gui.enchants.yml b/Core/src/main/resources/gui.enchants.yml index b47551e..ed9ee64 100644 --- a/Core/src/main/resources/gui.enchants.yml +++ b/Core/src/main/resources/gui.enchants.yml @@ -1,3 +1,4 @@ +# See http://77.222.60.131:8080/plugin/engine/config/menuConfig # Menu title. Title: 'Excellent Enchants List' # Menu size. Allowed values: 9, 18, 27, 36, 45, 54. @@ -6,6 +7,7 @@ Size: 36 # Enchantment display settings. Enchantments: # Enchantment display item options. + # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Icon: Material: 'ENCHANTED_BOOK' Name: '%enchantment_name_formatted%' diff --git a/NMS/pom.xml b/NMS/pom.xml index f6b5aed..b609f04 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.0 + 3.2.3 4.0.0 diff --git a/V1_16_R1/pom.xml b/V1_16_R1/pom.xml deleted file mode 100644 index 6948894..0000000 --- a/V1_16_R1/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - ExcellentEnchants - su.nightexpress.excellentenchants - 3.2.0 - - 4.0.0 - - V1_16_R1 - - - 16 - 16 - - - - - org.spigotmc - spigot - 1.16.5-R0.1-SNAPSHOT - - - su.nightexpress.excellentenchants - NMS - 3.2.0 - - - - \ No newline at end of file diff --git a/V1_16_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_16_R3.java b/V1_16_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_16_R3.java deleted file mode 100644 index 3eddc29..0000000 --- a/V1_16_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_16_R3.java +++ /dev/null @@ -1,51 +0,0 @@ -package su.nightexpress.excellentenchants.nms; - -import net.minecraft.server.v1_16_R3.*; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_16_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_16_R3.event.CraftEventFactory; -import org.bukkit.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -import java.util.HashSet; -import java.util.Set; - -public class V1_16_R3 implements EnchantNMS { - - @Override - @NotNull - public Set handleFlameWalker(@NotNull LivingEntity entity1, @NotNull Location location, int level) { - EntityLiving entity = ((CraftLivingEntity) entity1).getHandle(); - BlockPosition pos = new BlockPosition(location.getX(), location.getY(), location.getZ()); - World world = ((CraftWorld) entity1.getWorld()).getHandle(); - - IBlockData bStone = Blocks.MAGMA_BLOCK.getBlockData(); - float rad = Math.min(16, 2 + level); - - BlockPosition.MutableBlockPosition posMut = new BlockPosition.MutableBlockPosition(); - Set blocks = new HashSet<>(); - for (BlockPosition bNear : BlockPosition.a(pos.a(-rad, -1.0, -rad), pos.a(rad, -1.0, rad))) { - - if (!bNear.a(entity.getPositionVector(), rad)) continue; - posMut.d(bNear.getX(), bNear.getY() + 1, bNear.getZ()); - - IBlockData bLavaUp = world.getType(posMut); - IBlockData bLava = world.getType(bNear); - - if (!bLavaUp.isAir()) continue; - if (bLava.getMaterial() != Material.LAVA) continue; - if (bLava.get(BlockFluids.LEVEL) != 0) continue; - if (!bStone.canPlace(world, bNear)) continue; - if (!world.a(bStone, bNear, VoxelShapeCollision.a())) continue; - if (!CraftEventFactory.handleBlockFormEvent(world, bNear, bStone, entity)) continue; - - world.getBlockTickList().a(bNear, Blocks.MAGMA_BLOCK, MathHelper.nextInt(entity.getRandom(), 60, 120)); - - Location loc2 = new Location(world.getWorld(), bNear.getX(), bNear.getY(), bNear.getZ()); - blocks.add(loc2.getBlock()); - } - return blocks; - } -} diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index be02d99..e6e329c 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.0 + 3.2.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.0 + 3.2.3 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 94812b7..8499523 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.0 + 3.2.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.0 + 3.2.3 diff --git a/V1_18_R1/pom.xml b/V1_19_R1/pom.xml similarity index 85% rename from V1_18_R1/pom.xml rename to V1_19_R1/pom.xml index cf11b4f..26e50d6 100644 --- a/V1_18_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,11 +5,11 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.0 + 3.2.3 4.0.0 - V1_18_R1 + V1_19_R1 16 @@ -20,13 +20,13 @@ org.spigotmc spigot - 1.18.1-R0.1-SNAPSHOT + 1.19-R0.1-SNAPSHOT remapped-mojang su.nightexpress.excellentenchants NMS - 3.2.0 + 3.2.3 @@ -35,7 +35,7 @@ net.md-5 specialsource-maven-plugin - 1.2.3 + 1.2.4 package @@ -44,9 +44,9 @@ remap-obf - org.spigotmc:minecraft-server:1.18.1-R0.1-SNAPSHOT:txt:maps-mojang + org.spigotmc:minecraft-server:1.19-R0.1-SNAPSHOT:txt:maps-mojang true - org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT:jar:remapped-mojang + org.spigotmc:spigot:1.19-R0.1-SNAPSHOT:jar:remapped-mojang true remapped-obf @@ -59,8 +59,8 @@ remap-spigot ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.18.1-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT:jar:remapped-obf + org.spigotmc:minecraft-server:1.19-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.19-R0.1-SNAPSHOT:jar:remapped-obf diff --git a/V1_18_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R1.java b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_19_R1.java similarity index 88% rename from V1_18_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R1.java rename to V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_19_R1.java index e12c7ed..a76d34a 100644 --- a/V1_18_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R1.java +++ b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_19_R1.java @@ -9,16 +9,16 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.Location; import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_18_R1.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_19_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory; import org.bukkit.entity.LivingEntity; import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; -public class V1_18_R1 implements EnchantNMS { +public class V1_19_R1 implements EnchantNMS { @Override @NotNull @@ -33,7 +33,7 @@ public class V1_18_R1 implements EnchantNMS { Set blocks = new HashSet<>(); for (BlockPos posNear : BlockPos.betweenClosed(pos.offset(-radius, -1.0, -radius), pos.offset(radius, -1.0, radius))) { - if (!posNear.closerThan(entity.position(), radius)) continue; + if (!posNear.closerThan(entity.blockPosition(), radius)) continue; posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ()); diff --git a/pom.xml b/pom.xml index d730a72..8a348f5 100644 --- a/pom.xml +++ b/pom.xml @@ -7,14 +7,13 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.2.0 + 3.2.3 Core NMS V1_17_R1 - V1_16_R1 - V1_18_R1 V1_18_R2 + V1_19_R1 @@ -26,7 +25,7 @@ su.nexmedia NexEngine - 2.1.2 + 2.2.2 From 10249cb318043a2b24bcc941f9b26047769eb852 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Sun, 31 Jul 2022 16:26:23 +0500 Subject: [PATCH 11/69] 3.2.4 --- Core/pom.xml | 12 ++-- .../api/enchantment/ExcellentEnchant.java | 40 ++++------- .../api/enchantment/IEnchantBowTemplate.java | 9 ++- .../enchantment/IEnchantChanceTemplate.java | 4 ++ .../IEnchantCombatPotionTemplate.java | 4 ++ .../enchantment/IEnchantPotionTemplate.java | 13 ++-- .../manager/EnchantRegister.java | 6 +- .../enchants/armor/EnchantFlameWalker.java | 19 +++-- .../enchants/armor/EnchantRegrowth.java | 18 +++-- .../enchants/armor/EnchantSaturation.java | 13 ++-- .../armor/EnchantSelfDestruction.java | 8 ++- .../manager/enchants/bow/EnchantBomber.java | 24 ++----- .../enchants/bow/EnchantDragonfireArrows.java | 19 ++--- .../bow/EnchantElectrifiedArrows.java | 11 --- .../manager/enchants/bow/EnchantEnderBow.java | 18 ----- .../enchants/bow/EnchantExplosiveArrows.java | 24 +++---- .../manager/enchants/bow/EnchantGhast.java | 24 ++----- .../enchants/bow/EnchantPoisonedArrows.java | 11 --- .../enchants/bow/EnchantWitheredArrows.java | 11 --- .../enchants/tool/EnchantBlastMining.java | 20 ++---- .../enchants/tool/EnchantCurseOfBreaking.java | 13 ++-- .../tool/EnchantCurseOfMisfortune.java | 13 ++-- .../enchants/tool/EnchantDivineTouch.java | 17 ++--- .../enchants/tool/EnchantLuckyMiner.java | 7 +- .../enchants/tool/EnchantReplanter.java | 8 ++- .../enchants/tool/EnchantSilkChest.java | 13 +++- .../manager/enchants/tool/EnchantSmelter.java | 23 +++--- .../enchants/tool/EnchantTelekinesis.java | 10 ++- .../enchants/tool/EnchantTreasures.java | 22 +++--- .../manager/enchants/tool/EnchantTunnel.java | 15 ++-- .../enchants/tool/EnchantVeinminer.java | 17 ++--- .../weapon/EnchantBaneOfNetherspawn.java | 33 ++++----- .../manager/enchants/weapon/EnchantCure.java | 20 +++--- .../enchants/weapon/EnchantCutter.java | 5 ++ .../enchants/weapon/EnchantDecapitator.java | 14 ++-- .../enchants/weapon/EnchantDoubleStrike.java | 10 ++- .../enchants/weapon/EnchantExpHunter.java | 7 +- .../enchants/weapon/EnchantInfernus.java | 6 +- .../enchants/weapon/EnchantRocket.java | 7 +- .../enchants/weapon/EnchantScavenger.java | 7 +- .../enchants/weapon/EnchantTemper.java | 12 ++-- .../enchants/weapon/EnchantThrifty.java | 8 ++- .../enchants/weapon/EnchantThunder.java | 6 +- .../enchants/weapon/EnchantVampire.java | 12 ++-- .../weapon/EnchantVillageDefender.java | 23 +++--- Core/src/main/resources/enchants/aquaman.yml | 6 +- .../enchants/bane_of_netherspawn.yml | 7 ++ .../main/resources/enchants/blast_mining.yml | 5 ++ .../src/main/resources/enchants/blindness.yml | 3 + Core/src/main/resources/enchants/bomber.yml | 14 ++++ .../src/main/resources/enchants/bunny_hop.yml | 3 + .../main/resources/enchants/cold_steel.yml | 3 + .../resources/enchants/confusing_arrows.yml | 3 + .../src/main/resources/enchants/confusion.yml | 3 + Core/src/main/resources/enchants/cure.yml | 3 + .../resources/enchants/curse_of_breaking.yml | 4 ++ .../enchants/curse_of_misfortune.yml | 5 ++ Core/src/main/resources/enchants/cutter.yml | 3 + .../main/resources/enchants/decapitator.yml | 3 + .../main/resources/enchants/divine_touch.yml | 4 ++ .../main/resources/enchants/double_strike.yml | 3 + .../resources/enchants/dragonfire_arrows.yml | 8 +++ .../resources/enchants/electrified_arrows.yml | 8 +++ .../src/main/resources/enchants/ender_bow.yml | 14 ++++ Core/src/main/resources/enchants/exhaust.yml | 3 + .../main/resources/enchants/exp_hunter.yml | 3 + .../resources/enchants/explosive_arrows.yml | 8 +++ .../main/resources/enchants/flame_walker.yml | 4 ++ Core/src/main/resources/enchants/ghast.yml | 13 ++++ Core/src/main/resources/enchants/hardened.yml | 3 + Core/src/main/resources/enchants/haste.yml | 3 + Core/src/main/resources/enchants/hover.yml | 3 + .../main/resources/enchants/ice_aspect.yml | 3 + Core/src/main/resources/enchants/infernus.yml | 3 + .../main/resources/enchants/lucky_miner.yml | 3 + .../main/resources/enchants/night_vision.yml | 3 + Core/src/main/resources/enchants/nimble.yml | 3 + Core/src/main/resources/enchants/paralyze.yml | 3 + .../resources/enchants/poisoned_arrows.yml | 8 +++ Core/src/main/resources/enchants/rage.yml | 3 + Core/src/main/resources/enchants/regrowth.yml | 3 + .../src/main/resources/enchants/replanter.yml | 3 + Core/src/main/resources/enchants/rocket.yml | 3 + .../main/resources/enchants/saturation.yml | 3 + .../src/main/resources/enchants/scavenger.yml | 3 + .../resources/enchants/self_destruction.yml | 3 + .../main/resources/enchants/silk_chest.yml | 3 + Core/src/main/resources/enchants/smelter.yml | 3 + Core/src/main/resources/enchants/sonic.yml | 3 + Core/src/main/resources/enchants/surprise.yml | 3 + .../main/resources/enchants/telekinesis.yml | 3 + Core/src/main/resources/enchants/temper.yml | 3 + Core/src/main/resources/enchants/thrifty.yml | 3 + Core/src/main/resources/enchants/thunder.yml | 3 + .../src/main/resources/enchants/treasures.yml | 3 + Core/src/main/resources/enchants/tunnel.yml | 5 ++ Core/src/main/resources/enchants/vampire.yml | 3 + .../src/main/resources/enchants/veinminer.yml | 5 ++ Core/src/main/resources/enchants/venom.yml | 3 + .../resources/enchants/village_defender.yml | 7 ++ Core/src/main/resources/enchants/wither.yml | 3 + .../resources/enchants/withered_arrows.yml | 8 +++ Core/src/main/resources/lang/messages_ru.yml | 72 ++++++++++++------- Core/src/main/resources/plugin.yml | 2 +- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 +- V1_18_R2/pom.xml | 4 +- V1_19_R1/pom.xml | 6 +- pom.xml | 4 +- 109 files changed, 608 insertions(+), 372 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index f3f52ea..5925dda 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.3 + 3.2.4 4.0.0 @@ -27,27 +27,27 @@ org.spigotmc spigot-api - 1.19-R0.1-SNAPSHOT + 1.19.1-R0.1-SNAPSHOT su.nightexpress.excellentenchants NMS - 3.2.3 + 3.2.4 su.nightexpress.excellentenchants V1_17_R1 - 3.2.3 + 3.2.4 su.nightexpress.excellentenchants V1_18_R2 - 3.2.3 + 3.2.4 su.nightexpress.excellentenchants V1_19_R1 - 3.2.3 + 3.2.4 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index eb0e540..11cffd3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -74,6 +74,13 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener this.updateConfig(); this.cfg.saveChanges(); this.priority = priority; + this.conflicts = new HashSet<>(); + + this.loadConfig(); + } + + public void loadConfig() { + this.cfg.reload(); this.displayName = StringUtil.color(cfg.getString("Name", this.getId())); this.tier = EnchantManager.getTierById(cfg.getString("Tier", Placeholders.DEFAULT)); @@ -83,7 +90,6 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener this.tier.getEnchants().add(this); this.description = StringUtil.color(cfg.getStringList("Description")); - this.conflicts = new HashSet<>(); this.isTreasure = cfg.getBoolean("Is_Treasure"); this.levelMin = cfg.getInt("Level.Min"); this.levelMax = cfg.getInt("Level.Max"); @@ -102,6 +108,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener protected void updateConfig() { cfg.addMissing("Is_Treasure", false); + cfg.addMissing("Conflicts", new ArrayList()); cfg.addMissing("Settings.Cost.Enabled", false); cfg.addMissing("Settings.Cost.Item.Material", Material.AIR.name()); cfg.addMissing("Settings.Cost.Item.Amount", 1); @@ -201,12 +208,11 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener return itemType == null ? new FitItemType[0] : new FitItemType[]{itemType}; } - protected void addConflicts() { - - } - - protected void addConflict(@NotNull Enchantment enchantment) { - this.conflicts.add(enchantment); + private void addConflicts() { + this.conflicts.addAll(this.getConfig().getStringSet("Conflicts").stream() + .map(enchId -> Enchantment.getByKey(NamespacedKey.minecraft(enchId.toLowerCase()))) + .filter(Objects::nonNull) + .toList()); } public boolean hasCostItem() { @@ -326,26 +332,6 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener return Stream.of(this.getFitItemTypes()).anyMatch(fitItemType -> fitItemType.isIncluded(item)); } - /*protected boolean isFitItemType(@NotNull ItemStack item) { - EnchantmentTarget target = this.getItemTarget(); - return switch (target) { - case ARMOR -> ItemUtil.isArmor(item); - case ARMOR_FEET -> ItemUtil.isBoots(item); - case ARMOR_LEGS -> ItemUtil.isLeggings(item); - case ARMOR_TORSO -> ItemUtil.isChestplate(item) || (Config.ENCHANTMENTS_ITEM_ELYTRA_AS_CHESTPLATE && item.getType() == Material.ELYTRA); - case ARMOR_HEAD -> ItemUtil.isHelmet(item); - case WEAPON -> ItemUtil.isSword(item) || (Config.ENCHANTMENTS_ITEM_AXES_AS_SWORDS && ItemUtil.isAxe(item)); - case TOOL -> ItemUtil.isTool(item); - case BOW -> item.getType() == Material.BOW || (Config.ENCHANTMENTS_ITEM_CROSSBOWS_AS_BOWS && ItemUtil.isBow(item)); - case FISHING_ROD -> item.getType() == Material.FISHING_ROD; - case BREAKABLE -> true; - case WEARABLE -> EnchantManager.isEnchantable(item); - case TRIDENT -> ItemUtil.isTrident(item); - case CROSSBOW -> item.getType() == Material.CROSSBOW; - default -> false; - }; - }*/ - @Override public boolean isCursed() { return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java index a27cc07..005cecd 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java @@ -16,13 +16,18 @@ import su.nightexpress.excellentenchants.manager.tasks.ArrowTrailsTask; public abstract class IEnchantBowTemplate extends IEnchantChanceTemplate implements BowEnchant { - protected final String arrowTrailName; - protected final String arrowTrailData; + protected String arrowTrailName; + protected String arrowTrailData; protected final String arrowMeta; public IEnchantBowTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, @NotNull EnchantPriority priority) { super(plugin, cfg, priority); this.arrowMeta = this.getId() + "_arrow"; + } + + @Override + public void loadConfig() { + super.loadConfig(); this.arrowTrailName = cfg.getString("Settings.Arrow.Trail.Name", ""); this.arrowTrailData = cfg.getString("Settings.Arrow.Trail.Data", ""); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java index cff2561..c3368f3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java @@ -18,7 +18,11 @@ public abstract class IEnchantChanceTemplate extends ExcellentEnchant { public IEnchantChanceTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, @NotNull EnchantPriority priority) { super(plugin, cfg, priority); + } + @Override + public void loadConfig() { + super.loadConfig(); this.triggerChance = new EnchantScaler(this, "Settings.Trigger_Chance"); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantCombatPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantCombatPotionTemplate.java index 0320831..64b12eb 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantCombatPotionTemplate.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantCombatPotionTemplate.java @@ -20,7 +20,11 @@ public abstract class IEnchantCombatPotionTemplate extends IEnchantPotionTemplat @NotNull EnchantPriority priority, @NotNull PotionEffectType effectType) { super(plugin, cfg, priority, effectType); + } + @Override + public void loadConfig() { + super.loadConfig(); this.particleName = cfg.getString("Settings.Particle.Name", ""); this.particleData = cfg.getString("Settings.Particle.Data", ""); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java index 17061e3..256aa42 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java @@ -21,19 +21,24 @@ public abstract class IEnchantPotionTemplate extends IEnchantChanceTemplate { public static final String PLACEHOLDER_POTION_DURATION = "%enchantment_potion_duration%"; public static final String PLACEHOLDER_POTION_TYPE = "%enchantment_potion_type%"; - protected PotionEffectType potionEffectType; + protected PotionEffectType potionEffectType; + protected final boolean potionParticles; protected Scaler potionDuration; - protected Scaler potionLevel; - protected final boolean potionParticles; + protected Scaler potionLevel; public IEnchantPotionTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, @NotNull EnchantPriority priority, @NotNull PotionEffectType potionEffectType) { super(plugin, cfg, priority); this.potionEffectType = potionEffectType; + this.potionParticles = !(this instanceof PassiveEnchant); + } + + @Override + public void loadConfig() { + super.loadConfig(); this.potionDuration = new EnchantScaler(this, "Settings.Potion_Effect.Duration"); this.potionLevel = new EnchantScaler(this, "Settings.Potion_Effect.Level"); - this.potionParticles = !(this instanceof PassiveEnchant); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java index a87df44..9e482a8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java @@ -159,7 +159,11 @@ public class EnchantRegister { } public static void setup() { - if (ExcellentEnchants.isLoaded) return; // Prevent to register enchantments during the runtime. + // Prevent to register enchantments during the runtime. + if (ExcellentEnchants.isLoaded) { + ENCHANT_LIST.forEach(ExcellentEnchant::loadConfig); + return; + } //ENCHANT_LIST.clear(); Reflex.setFieldValue(Enchantment.class, "acceptingNew", true); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java index 63f097f..0d716d8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java @@ -5,7 +5,6 @@ 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; @@ -40,18 +39,22 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn private static final BlockFace[] FACES = {BlockFace.SOUTH, BlockFace.NORTH, BlockFace.EAST, BlockFace.WEST}; private static final Map BLOCKS_TO_DESTROY = new HashMap<>(); - private final Scaler blockDecayTime; - private BlockTickTask blockTickTask; + private Scaler blockDecayTime; + private BlockTickTask blockTickTask; public EnchantFlameWalker(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); - this.blockDecayTime = new EnchantScaler(this, "Settings.Block_Decay"); - this.blockTickTask = new BlockTickTask(plugin); this.blockTickTask.start(); } + @Override + public void loadConfig() { + super.loadConfig(); + this.blockDecayTime = new EnchantScaler(this, "Settings.Block_Decay"); + } + @Override protected void updateConfig() { super.updateConfig(); @@ -73,12 +76,6 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn BLOCKS_TO_DESTROY.put(block, (long) (System.currentTimeMillis() + seconds * 1000L)); } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(Enchantment.FROST_WALKER); - } - @Override @NotNull public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java index 9b1bb02..cc6f91b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java @@ -26,10 +26,10 @@ public class EnchantRegrowth extends IEnchantChanceTemplate implements PassiveEn public static final String ID = "regrowth"; - private final String particleName; - private final String particleData; - private final long healthInterval; - private final Scaler healthAmount; + private String particleName; + private String particleData; + private long healthInterval; + private Scaler healthAmount; private Task healthTask; private static final String PLACEHOLDER_HEALTH_AMOUNT = "%enchantment_health_amount%"; @@ -37,12 +37,18 @@ public class EnchantRegrowth extends IEnchantChanceTemplate implements PassiveEn public EnchantRegrowth(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + + this.healthTask = new Task(plugin); + this.healthTask.start(); + } + + @Override + public void loadConfig() { + super.loadConfig(); this.particleName = cfg.getString("Settings.Particle.Name", Particle.HEART.name()); this.particleData = cfg.getString("Settings.Particle.Data", ""); this.healthInterval = cfg.getLong("Settings.Health.Interval", 100); this.healthAmount = new EnchantScaler(this, "Settings.Health.Amount"); - this.healthTask = new Task(plugin); - this.healthTask.start(); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java index 3a8ceb2..8733caa 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java @@ -21,8 +21,8 @@ import java.util.function.UnaryOperator; public class EnchantSaturation extends IEnchantChanceTemplate implements PassiveEnchant, ICleanable { - private final long saturationInterval; - private final Scaler saturationAmount; + private long saturationInterval; + private Scaler saturationAmount; private Task saturationTask; public static final String ID = "saturation"; @@ -33,12 +33,17 @@ public class EnchantSaturation extends IEnchantChanceTemplate implements Passive public EnchantSaturation(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); - this.saturationInterval = cfg.getLong("Settings.Saturation.Interval", 100); - this.saturationAmount = new EnchantScaler(this, "Settings.Saturation.Amount"); this.saturationTask = new Task(plugin); this.saturationTask.start(); } + @Override + public void loadConfig() { + super.loadConfig(); + this.saturationInterval = cfg.getLong("Settings.Saturation.Interval", 100); + this.saturationAmount = new EnchantScaler(this, "Settings.Saturation.Amount"); + } + @Override protected void updateConfig() { super.updateConfig(); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java index ecd3ff0..42ff188 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java @@ -22,15 +22,19 @@ import java.util.function.UnaryOperator; public class EnchantSelfDestruction extends IEnchantChanceTemplate implements DeathEnchant { - private final Scaler explosionSize; + private Scaler explosionSize; public static final String ID = "self_destruction"; private static final String META_EXPLOSION_SOURCE = ID + "_explosion_source"; - private static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; public EnchantSelfDestruction(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + super.loadConfig(); this.explosionSize = new EnchantScaler(this, "Settings.Explosion.Size"); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java index a2a9189..01f7741 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java @@ -1,6 +1,5 @@ package su.nightexpress.excellentenchants.manager.enchants.bow; -import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; @@ -17,14 +16,13 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import java.util.function.UnaryOperator; public class EnchantBomber extends IEnchantChanceTemplate implements BowEnchant { - private final Scaler fuseTicks; + private Scaler fuseTicks; public static final String ID = "bomber"; @@ -32,7 +30,11 @@ public class EnchantBomber extends IEnchantChanceTemplate implements BowEnchant public EnchantBomber(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.HIGHEST); + } + @Override + public void loadConfig() { + super.loadConfig(); this.fuseTicks = new EnchantScaler(this, "Settings.Fuse_Ticks"); } @@ -54,22 +56,6 @@ public class EnchantBomber extends IEnchantChanceTemplate implements BowEnchant return (int) this.fuseTicks.getValue(level); } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.ENDER_BOW); - this.addConflict(EnchantRegister.GHAST); - this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); - this.addConflict(EnchantRegister.WITHERED_ARROWS); - this.addConflict(EnchantRegister.POISONED_ARROWS); - this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); - this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); - this.addConflict(EnchantRegister.CONFUSING_ARROWS); - this.addConflict(Enchantment.ARROW_FIRE); - this.addConflict(Enchantment.ARROW_DAMAGE); - this.addConflict(Enchantment.ARROW_KNOCKBACK); - } - @Override @NotNull public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java index 98ac9ad..cd08b84 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java @@ -14,7 +14,6 @@ import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowTemplate; -import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import java.util.function.UnaryOperator; @@ -26,24 +25,18 @@ public class EnchantDragonfireArrows extends IEnchantBowTemplate { public static final String PLACEHOLDER_FIRE_RADIUS = "%enchantment_fire_radius%"; public static final String PLACEHOLDER_FIRE_DURATION = "%enchantment_fire_duration%"; - private final EnchantScaler fireDuration; - private final EnchantScaler fireRadius; + private EnchantScaler fireDuration; + private EnchantScaler fireRadius; public EnchantDragonfireArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); - - this.fireDuration = new EnchantScaler(this, "Settings.Fire.Duration"); - this.fireRadius = new EnchantScaler(this, "Settings.Fire.Radius"); } @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.CONFUSING_ARROWS); - this.addConflict(EnchantRegister.POISONED_ARROWS); - this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); - this.addConflict(EnchantRegister.WITHERED_ARROWS); - this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); + public void loadConfig() { + super.loadConfig(); + this.fireDuration = new EnchantScaler(this, "Settings.Fire.Duration"); + this.fireRadius = new EnchantScaler(this, "Settings.Fire.Radius"); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java index 3404daa..a0e9954 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java @@ -14,7 +14,6 @@ import su.nexmedia.engine.utils.LocationUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowTemplate; -import su.nightexpress.excellentenchants.manager.EnchantRegister; public class EnchantElectrifiedArrows extends IEnchantBowTemplate { @@ -24,16 +23,6 @@ public class EnchantElectrifiedArrows extends IEnchantBowTemplate { super(plugin, cfg, EnchantPriority.MEDIUM); } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.CONFUSING_ARROWS); - this.addConflict(EnchantRegister.POISONED_ARROWS); - this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); - this.addConflict(EnchantRegister.WITHERED_ARROWS); - this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); - } - @Override public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { if (!super.use(e, projectile, bow, level)) return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java index 0de6e28..d1d3709 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java @@ -1,6 +1,5 @@ package su.nightexpress.excellentenchants.manager.enchants.bow; -import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.EnderPearl; import org.bukkit.entity.LivingEntity; @@ -15,7 +14,6 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.manager.EnchantRegister; public class EnchantEnderBow extends IEnchantChanceTemplate implements BowEnchant { @@ -25,22 +23,6 @@ public class EnchantEnderBow extends IEnchantChanceTemplate implements BowEnchan super(plugin, cfg, EnchantPriority.HIGHEST); } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.BOMBER); - this.addConflict(EnchantRegister.GHAST); - this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); - this.addConflict(EnchantRegister.WITHERED_ARROWS); - this.addConflict(EnchantRegister.POISONED_ARROWS); - this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); - this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); - this.addConflict(EnchantRegister.CONFUSING_ARROWS); - this.addConflict(Enchantment.ARROW_FIRE); - this.addConflict(Enchantment.ARROW_DAMAGE); - this.addConflict(Enchantment.ARROW_KNOCKBACK); - } - @Override @NotNull public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java index 610815b..ea01d3b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java @@ -18,17 +18,16 @@ import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowTemplate; -import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import java.util.function.UnaryOperator; public class EnchantExplosiveArrows extends IEnchantBowTemplate { - private final boolean explosionFireSpread; - private final boolean explosionDamageItems; - private final boolean explosionDamageBlocks; - private final Scaler explosionSize; + private boolean explosionFireSpread; + private boolean explosionDamageItems; + private boolean explosionDamageBlocks; + private Scaler explosionSize; public static final String ID = "explosive_arrows"; public static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; @@ -37,6 +36,11 @@ public class EnchantExplosiveArrows extends IEnchantBowTemplate { public EnchantExplosiveArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + super.loadConfig(); this.explosionFireSpread = cfg.getBoolean("Settings.Explosion.Fire_Spread"); this.explosionDamageItems = cfg.getBoolean("Settings.Explosion.Damage_Items"); this.explosionDamageBlocks = cfg.getBoolean("Settings.Explosion.Damage_Blocks"); @@ -52,16 +56,6 @@ public class EnchantExplosiveArrows extends IEnchantBowTemplate { this.cfg.addMissing("Settings.Explosion.Damage_Blocks", false); } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.CONFUSING_ARROWS); - this.addConflict(EnchantRegister.POISONED_ARROWS); - this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); - this.addConflict(EnchantRegister.WITHERED_ARROWS); - this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); - } - @Override @NotNull public UnaryOperator replacePlaceholders(int level) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java index 9742f33..eeed82d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java @@ -17,19 +17,22 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { - private final boolean fireSpread; - private final Scaler yield; + private boolean fireSpread; + private Scaler yield; public static final String ID = "ghast"; public EnchantGhast(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.HIGHEST); + } + @Override + public void loadConfig() { + super.loadConfig(); this.fireSpread = cfg.getBoolean("Settings.Fire_Spread"); this.yield = new EnchantScaler(this, "Settings.Yield"); } @@ -42,21 +45,6 @@ public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { cfg.addMissing("Settings.Yield", "1.0 * " + PLACEHOLDER_LEVEL); } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.BOMBER); - this.addConflict(EnchantRegister.ENDER_BOW); - this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); - this.addConflict(EnchantRegister.WITHERED_ARROWS); - this.addConflict(EnchantRegister.POISONED_ARROWS); - this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); - this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); - this.addConflict(EnchantRegister.CONFUSING_ARROWS); - this.addConflict(Enchantment.ARROW_FIRE); - this.addConflict(Enchantment.ARROW_KNOCKBACK); - } - public boolean isFireSpread() { return fireSpread; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java index e229d98..bf4527c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java @@ -6,7 +6,6 @@ import su.nexmedia.engine.api.config.JYML; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowPotionTemplate; -import su.nightexpress.excellentenchants.manager.EnchantRegister; public class EnchantPoisonedArrows extends IEnchantBowPotionTemplate { @@ -15,14 +14,4 @@ public class EnchantPoisonedArrows extends IEnchantBowPotionTemplate { public EnchantPoisonedArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.POISON); } - - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.CONFUSING_ARROWS); - this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); - this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); - this.addConflict(EnchantRegister.WITHERED_ARROWS); - this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); - } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java index 4af06d7..ab6cb4e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java @@ -6,7 +6,6 @@ import su.nexmedia.engine.api.config.JYML; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowPotionTemplate; -import su.nightexpress.excellentenchants.manager.EnchantRegister; public class EnchantWitheredArrows extends IEnchantBowPotionTemplate { @@ -15,14 +14,4 @@ public class EnchantWitheredArrows extends IEnchantBowPotionTemplate { public EnchantWitheredArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.WITHER); } - - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.CONFUSING_ARROWS); - this.addConflict(EnchantRegister.POISONED_ARROWS); - this.addConflict(EnchantRegister.EXPLOSIVE_ARROWS); - this.addConflict(EnchantRegister.ELECTRIFIED_ARROWS); - this.addConflict(EnchantRegister.DRAGONFIRE_ARROWS); - } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java index a3de7be..3def20d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java @@ -30,8 +30,8 @@ import java.util.function.UnaryOperator; public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockBreakEnchant { - private final Scaler explosionPower; - private final Scaler minBlockStrength; + private Scaler explosionPower; + private Scaler minBlockStrength; public static final String ID = "blast_mining"; public static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; @@ -41,7 +41,11 @@ public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockB public EnchantBlastMining(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + @Override + public void loadConfig() { + super.loadConfig(); this.explosionPower = new EnchantScaler(this, "Settings.Explosion.Power"); this.minBlockStrength = new EnchantScaler(this, "Settings.Min_Block_Strength"); } @@ -66,13 +70,6 @@ public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockB cfg.addMissing("Settings.Min_Block_Strength", "1.5 - " + PLACEHOLDER_LEVEL + " / 10.0"); } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.TUNNEL); - this.addConflict(EnchantRegister.VEINMINER); - } - @Override @NotNull public UnaryOperator replacePlaceholders(int level) { @@ -81,11 +78,6 @@ public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockB ); } - /*@Override - public boolean isFitItemType(@NotNull ItemStack item) { - return ItemUtil.isPickaxe(item); - }*/ - @Override @NotNull public FitItemType[] getFitItemTypes() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java index e57b2e3..21785fe 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java @@ -1,6 +1,5 @@ package su.nightexpress.excellentenchants.manager.enchants.tool; -import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -20,14 +19,18 @@ import java.util.function.UnaryOperator; public class EnchantCurseOfBreaking extends IEnchantChanceTemplate { - private final Scaler durabilityAmount; + private Scaler durabilityAmount; public static final String ID = "curse_of_breaking"; public static final String PLACEHOLDER_DURABILITY_AMOUNT = "%enchantment_durability_amount%"; public EnchantCurseOfBreaking(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + @Override + public void loadConfig() { + super.loadConfig(); this.durabilityAmount = new EnchantScaler(this, "Settings.Durability_Amount"); } @@ -40,12 +43,6 @@ public class EnchantCurseOfBreaking extends IEnchantChanceTemplate { return (int) this.durabilityAmount.getValue(level); } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(Enchantment.DURABILITY); - } - @Override @NotNull public UnaryOperator replacePlaceholders(int level) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java index 88655aa..ecb92f4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java @@ -17,13 +17,17 @@ import su.nightexpress.excellentenchants.manager.type.FitItemType; public class EnchantCurseOfMisfortune extends IEnchantChanceTemplate implements BlockBreakEnchant, DeathEnchant { - private final boolean dropExp; + private boolean dropExp; public static final String ID = "curse_of_misfortune"; public EnchantCurseOfMisfortune(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.LOWEST); + } + @Override + public void loadConfig() { + super.loadConfig(); this.dropExp = cfg.getBoolean("Settings.Drop_Exp"); } @@ -31,13 +35,6 @@ public class EnchantCurseOfMisfortune extends IEnchantChanceTemplate implements return dropExp; } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(LOOT_BONUS_BLOCKS); - this.addConflict(LOOT_BONUS_MOBS); - } - @Override @NotNull public FitItemType[] getFitItemTypes() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java index 1b21d4e..512791c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java @@ -27,7 +27,6 @@ import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; -import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.type.FitItemType; public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockBreakEnchant, CustomDropEnchant { @@ -35,13 +34,17 @@ public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockB public static final String ID = "divine_touch"; private static final String META_HANDLE = ID + "_handle"; - private final String particleName; - private final String particleData; - private final String spawnerName; + private String particleName; + private String particleData; + private String spawnerName; public EnchantDivineTouch(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + @Override + public void loadConfig() { + super.loadConfig(); this.particleName = cfg.getString("Settings.Particle.Name", Particle.VILLAGER_HAPPY.name()); this.particleData = cfg.getString("Settings.Particle.Data", ""); this.spawnerName = StringUtil.color(cfg.getString("Settings.Spawner_Item.Name", "&aMob Spawner &7(%type%)")); @@ -62,12 +65,6 @@ public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockB return new FitItemType[]{FitItemType.PICKAXE}; } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.SMELTER); - } - @Override @NotNull public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java index a712b6e..890b7f7 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java @@ -19,7 +19,7 @@ import java.util.function.UnaryOperator; public class EnchantLuckyMiner extends IEnchantChanceTemplate implements BlockBreakEnchant { - private final Scaler expModifier; + private Scaler expModifier; public static final String ID = "lucky_miner"; @@ -27,6 +27,11 @@ public class EnchantLuckyMiner extends IEnchantChanceTemplate implements BlockBr public EnchantLuckyMiner(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + super.loadConfig(); this.expModifier = new EnchantScaler(this, "Settings.Exp_Modifier"); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantReplanter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantReplanter.java index ed11133..3ab3f80 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantReplanter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantReplanter.java @@ -28,8 +28,8 @@ import java.util.Set; public class EnchantReplanter extends IEnchantChanceTemplate implements InteractEnchant, BlockBreakEnchant { - private final boolean replantOnRightClick; - private final boolean replantOnPlantBreak; + private boolean replantOnRightClick; + private boolean replantOnPlantBreak; public static final String ID = "replanter"; @@ -39,7 +39,11 @@ public class EnchantReplanter extends IEnchantChanceTemplate implements Interact public EnchantReplanter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.HIGH); + } + @Override + public void loadConfig() { + super.loadConfig(); this.replantOnRightClick = cfg.getBoolean("Settings.Replant.On_Right_Click"); this.replantOnPlantBreak = cfg.getBoolean("Settings.Replant.On_Plant_Break"); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java index 7113a34..fd54079 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java @@ -36,20 +36,26 @@ import java.util.TreeMap; public class EnchantSilkChest extends IEnchantChanceTemplate implements CustomDropEnchant { private final Map keyItems; - private final String chestName; + + private String chestName; public static final String ID = "silk_chest"; public EnchantSilkChest(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.HIGH); this.keyItems = new TreeMap<>(); - this.chestName = StringUtil.color(cfg.getString("Settings.Chest_Item.Name", "%name% &7(%items% items)")); for (int pos = 0; pos < 27; pos++) { this.getItemKey(pos); } } + @Override + public void loadConfig() { + super.loadConfig(); + this.chestName = StringUtil.color(cfg.getString("Settings.Chest_Item.Name", "%name% &7(%items% items)")); + } + @Override protected void updateConfig() { super.updateConfig(); @@ -139,6 +145,9 @@ public class EnchantSilkChest extends IEnchantChanceTemplate implements CustomDr BlockState state = block.getState(); if (!(state instanceof Chest chest)) return; + chest.setCustomName(null); + chest.update(true); + Inventory inventory = chest.getBlockInventory(); for (int pos = 0; pos < inventory.getSize(); pos++) { String data = PDCUtil.getStringData(item, this.getItemKey(pos)); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java index 6b44fc7..6b5981b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java @@ -1,8 +1,10 @@ package su.nightexpress.excellentenchants.manager.enchants.tool; -import org.bukkit.*; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.Sound; import org.bukkit.block.Block; -import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockDropItemEvent; @@ -16,7 +18,6 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; -import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.type.FitItemType; import java.util.HashMap; @@ -26,14 +27,18 @@ public class EnchantSmelter extends IEnchantChanceTemplate implements BlockDropE public static final String ID = "smelter"; - private final Sound sound; - private final String particleName; - private final String particleData; - private final Map smeltingTable; + private Sound sound; + private String particleName; + private String particleData; + private Map smeltingTable; public EnchantSmelter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + @Override + public void loadConfig() { + super.loadConfig(); this.sound = cfg.getEnum("Settings.Sound", Sound.class); this.particleName = cfg.getString("Settings.Particle.Name", Particle.FLAME.name()); this.particleData = cfg.getString("Settings.Particle.Data", ""); @@ -70,12 +75,12 @@ public class EnchantSmelter extends IEnchantChanceTemplate implements BlockDropE return new FitItemType[]{FitItemType.PICKAXE, FitItemType.AXE, FitItemType.SHOVEL}; } - @Override + /*@Override protected void addConflicts() { super.addConflicts(); this.addConflict(Enchantment.SILK_TOUCH); this.addConflict(EnchantRegister.DIVINE_TOUCH); - } + }*/ @Override @NotNull diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java index 3954272..cfa79f6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java @@ -26,15 +26,19 @@ import java.util.function.UnaryOperator; public class EnchantTelekinesis extends IEnchantChanceTemplate implements CustomDropEnchant { - private final LangMessage messageDropReceived; - private final String messageItemName; - private final String messageItemSeparator; + private LangMessage messageDropReceived; + private String messageItemName; + private String messageItemSeparator; public static final String ID = "telekinesis"; public EnchantTelekinesis(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.LOWEST); + } + @Override + public void loadConfig() { + super.loadConfig(); this.messageDropReceived = new LangMessage(plugin, cfg.getString("Settings.Message.Drop_Received", "")); this.messageItemName = StringUtil.color(cfg.getString("Settings.Message.Item_Name", "&7x%item_amount% &f%item_name%")); this.messageItemSeparator = StringUtil.color(cfg.getString("Settings.Message.Item_Separator", "&7, ")); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java index 133b069..e437b16 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java @@ -31,10 +31,10 @@ import java.util.function.Predicate; public class EnchantTreasures extends IEnchantChanceTemplate implements CustomDropEnchant, ICleanable { - private final String particleName; - private final String particleData; - private final Sound sound; - private final Map> treasures; + private String particleName; + private String particleData; + private Sound sound; + private Map> treasures; private final Predicate blockTracker; public static final String ID = "treasures"; @@ -42,6 +42,15 @@ public class EnchantTreasures extends IEnchantChanceTemplate implements CustomDr public EnchantTreasures(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + PlayerBlockTracker.initialize(); + PlayerBlockTracker.BLOCK_FILTERS.add(this.blockTracker = (block) -> { + return this.getTreasure(block.getType()) != null; + }); + } + + @Override + public void loadConfig() { + super.loadConfig(); this.particleName = cfg.getString("Settings.Particle.Name", Particle.REDSTONE.name()); this.particleData = cfg.getString("Settings.Particle.Data", "200,180,0"); this.sound = cfg.getEnum("Settings.Sound", Sound.class, Sound.BLOCK_NOTE_BLOCK_BELL); @@ -68,11 +77,6 @@ public class EnchantTreasures extends IEnchantChanceTemplate implements CustomDr this.treasures.put(mFrom, treasuresList); } } - - PlayerBlockTracker.initialize(); - PlayerBlockTracker.BLOCK_FILTERS.add(this.blockTracker = (block) -> { - return this.getTreasure(block.getType()) != null; - }); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java index a01deac..097d4cb 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java @@ -26,7 +26,7 @@ import java.util.Set; public class EnchantTunnel extends IEnchantChanceTemplate implements BlockBreakEnchant { - private final boolean disableOnSneak; + private boolean disableOnSneak; public static final String ID = "tunnel"; private static final String META_BLOCK_TUNNEL = ID + "_block_tunneled"; @@ -41,6 +41,11 @@ public class EnchantTunnel extends IEnchantChanceTemplate implements BlockBreakE public EnchantTunnel(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.HIGH); + } + + @Override + public void loadConfig() { + super.loadConfig(); this.disableOnSneak = cfg.getBoolean("Settings.Ignore_When_Sneaking"); } @@ -49,14 +54,6 @@ public class EnchantTunnel extends IEnchantChanceTemplate implements BlockBreakE super.updateConfig(); } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.VEINMINER); - this.addConflict(EnchantRegister.BLAST_MINING); - - } - @Override @NotNull public FitItemType[] getFitItemTypes() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java index bff7eb7..fc06e80 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java @@ -32,8 +32,8 @@ import java.util.stream.Stream; public class EnchantVeinminer extends IEnchantChanceTemplate implements BlockBreakEnchant { - private final Scaler blocksLimit; - private final Set blocksAffected; + private Scaler blocksLimit; + private Set blocksAffected; public static final String ID = "veinminer"; @@ -43,17 +43,14 @@ public class EnchantVeinminer extends IEnchantChanceTemplate implements BlockBre public EnchantVeinminer(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.HIGH); - - this.blocksLimit = new EnchantScaler(this, "Settings.Blocks.Max_At_Once"); - this.blocksAffected = cfg.getStringSet("Settings.Blocks.Affected").stream() - .map(type -> Material.getMaterial(type.toUpperCase())).filter(Objects::nonNull).collect(Collectors.toSet()); } @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.TUNNEL); - this.addConflict(EnchantRegister.BLAST_MINING); + public void loadConfig() { + super.loadConfig(); + this.blocksLimit = new EnchantScaler(this, "Settings.Blocks.Max_At_Once"); + this.blocksAffected = cfg.getStringSet("Settings.Blocks.Affected").stream() + .map(type -> Material.getMaterial(type.toUpperCase())).filter(Objects::nonNull).collect(Collectors.toSet()); } @NotNull diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java index 13a6136..ca40ac4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java @@ -2,7 +2,6 @@ package su.nightexpress.excellentenchants.manager.enchants.weapon; import com.google.common.collect.Sets; import org.bukkit.Particle; -import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; @@ -17,7 +16,6 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import java.util.Set; @@ -25,10 +23,10 @@ import java.util.function.UnaryOperator; public class EnchantBaneOfNetherspawn extends IEnchantChanceTemplate implements CombatEnchant { - private final String particleName; - private final String particleData; - private final boolean damageModifier; - private final Scaler damageFormula; + private String particleName; + private String particleData; + private boolean damageModifier; + private Scaler damageFormula; private final Set entityTypes; public static final String ID = "bane_of_netherspawn"; @@ -38,11 +36,6 @@ public class EnchantBaneOfNetherspawn extends IEnchantChanceTemplate implements public EnchantBaneOfNetherspawn(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); - this.particleName = cfg.getString("Settings.Particle.Name", ""); - this.particleData = cfg.getString("Settings.Particle.Data", ""); - this.damageModifier = cfg.getBoolean("Settings.Damage.As_Modifier"); - this.damageFormula = new EnchantScaler(this, "Settings.Damage.Formula"); - this.entityTypes = Sets.newHashSet(EntityType.BLAZE, EntityType.MAGMA_CUBE, EntityType.WITHER_SKELETON, EntityType.GHAST, EntityType.WITHER); @@ -54,6 +47,15 @@ public class EnchantBaneOfNetherspawn extends IEnchantChanceTemplate implements this.entityTypes.add(EntityType.ZOMBIFIED_PIGLIN); } + @Override + public void loadConfig() { + super.loadConfig(); + this.particleName = cfg.getString("Settings.Particle.Name", ""); + this.particleData = cfg.getString("Settings.Particle.Data", ""); + this.damageModifier = cfg.getBoolean("Settings.Damage.As_Modifier"); + this.damageFormula = new EnchantScaler(this, "Settings.Damage.Formula"); + } + public double getDamageModifier(int level) { return this.damageFormula.getValue(level); } @@ -67,15 +69,6 @@ public class EnchantBaneOfNetherspawn extends IEnchantChanceTemplate implements cfg.addMissing("Settings.Particle.Data", ""); } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.VILLAGE_DEFENDER); - this.addConflict(Enchantment.DAMAGE_ARTHROPODS); - this.addConflict(Enchantment.DAMAGE_UNDEAD); - this.addConflict(Enchantment.DAMAGE_ALL); - } - @Override @NotNull public UnaryOperator replacePlaceholders(int level) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCure.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCure.java index a646ece..eb65ca3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCure.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCure.java @@ -20,9 +20,9 @@ import java.util.Set; public class EnchantCure extends IEnchantChanceTemplate implements CombatEnchant { - private final Sound sound; - private final String particleName; - private final String particleData; + private Sound sound; + private String particleName; + private String particleData; public static final String ID = "cure"; @@ -30,7 +30,11 @@ public class EnchantCure extends IEnchantChanceTemplate implements CombatEnchant public EnchantCure(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + @Override + public void loadConfig() { + super.loadConfig(); this.sound = cfg.getEnum("Settings.Sound", Sound.class); this.particleName = cfg.getString("Settings.Particle.Name", Particle.CLOUD.name()); this.particleData = cfg.getString("Settings.Particle.Data", ""); @@ -61,19 +65,15 @@ public class EnchantCure extends IEnchantChanceTemplate implements CombatEnchant e.setCancelled(true); EffectUtil.playEffect(victim.getLocation(), this.particleName, this.particleData, 0.25, 0.25, 0.25, 0.1f, 20); - if (this.sound != null) MessageUtil.sound(victim.getLocation(), this.sound); + MessageUtil.sound(victim.getLocation(), this.sound); if (victim instanceof PigZombie pigZombie) { victim.getWorld().spawn(victim.getLocation(), Piglin.class); + victim.remove(); } else if (victim instanceof ZombieVillager zombieVillager) { - Villager.Profession profession = zombieVillager.getVillagerProfession(); - Villager villager = victim.getWorld().spawn(victim.getLocation(), Villager.class); - if (profession != null) { - villager.setProfession(profession); - } + zombieVillager.setConversionTime(1); } - victim.remove(); return true; } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java index d011263..2f25103 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java @@ -36,6 +36,11 @@ public class EnchantCutter extends IEnchantChanceTemplate implements CombatEncha public EnchantCutter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.LOWEST); + } + + @Override + public void loadConfig() { + super.loadConfig(); this.durabilityReduction = new EnchantScaler(this, "Settings.Item.Durability_Reduction"); this.sound = cfg.getEnum("Settings.Item.Sound", Sound.class); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java index fc0fce8..ef13794 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java @@ -26,17 +26,21 @@ import java.util.stream.Collectors; public class EnchantDecapitator extends IEnchantChanceTemplate implements DeathEnchant { - private final String particleName; - private final String particleData; - private final Set ignoredEntityTypes; - private final String headName; - private final Map headTextures; + private String particleName; + private String particleData; + private Set ignoredEntityTypes; + private String headName; + private Map headTextures; public static final String ID = "decapitator"; public EnchantDecapitator(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + @Override + public void loadConfig() { + super.loadConfig(); this.particleName = cfg.getString("Settings.Particle.Name", Particle.BLOCK_CRACK.name()); this.particleData = cfg.getString("Settings.Particle.Data", Material.REDSTONE_BLOCK.name()); this.ignoredEntityTypes = cfg.getStringSet("Settings.Ignored_Entity_Types").stream().map(String::toUpperCase).collect(Collectors.toSet()); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDoubleStrike.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDoubleStrike.java index e967956..0b69bde 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDoubleStrike.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDoubleStrike.java @@ -17,15 +17,19 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; public class EnchantDoubleStrike extends IEnchantChanceTemplate implements CombatEnchant { - private final String particleName; - private final String particleData; - private final Sound sound; + private String particleName; + private String particleData; + private Sound sound; public static final String ID = "double_strike"; public EnchantDoubleStrike(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.LOW); + } + @Override + public void loadConfig() { + super.loadConfig(); this.particleName = cfg.getString("Settings.Particle.Name", Particle.EXPLOSION_NORMAL.name()); this.particleData = cfg.getString("Settings.Particle.Data", ""); this.sound = cfg.getEnum("Settings.Sound", Sound.class); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java index 5c7eeba..79caf87 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java @@ -18,13 +18,18 @@ import java.util.function.UnaryOperator; public class EnchantExpHunter extends IEnchantChanceTemplate implements DeathEnchant { - private final Scaler expModifier; + private Scaler expModifier; public static final String ID = "exp_hunter"; public static final String PLACEHOLDER_EXP_MODIFIER = "%enchantment_exp_modifier%"; public EnchantExpHunter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + super.loadConfig(); this.expModifier = new EnchantScaler(this, "Settings.Exp_Modifier"); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java index 08b65ea..c4be70b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java @@ -22,14 +22,18 @@ import java.util.function.UnaryOperator; public class EnchantInfernus extends IEnchantChanceTemplate { - private final Scaler fireTicks; + private Scaler fireTicks; public static final String ID = "infernus"; public static final String PLACEHOLDER_FIRE_DURATION = "%enchantment_fire_duration%"; public EnchantInfernus(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + @Override + public void loadConfig() { + super.loadConfig(); this.fireTicks = new EnchantScaler(this, "Settings.Fire_Ticks"); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java index 780e7e5..3b8842f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java @@ -20,12 +20,17 @@ import su.nightexpress.excellentenchants.manager.object.EnchantScaler; public class EnchantRocket extends IEnchantChanceTemplate implements CombatEnchant { - private final Scaler fireworkPower; + private Scaler fireworkPower; public static final String ID = "rocket"; public EnchantRocket(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + super.loadConfig(); this.fireworkPower = new EnchantScaler(this, "Settings.Firework_Power"); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantScavenger.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantScavenger.java index e28c2e1..e59f9a9 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantScavenger.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantScavenger.java @@ -23,12 +23,17 @@ import java.util.Map; public class EnchantScavenger extends IEnchantChanceTemplate implements DeathEnchant { - private final Map>> loot; + private Map>> loot; public static final String ID = "scavenger"; public EnchantScavenger(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + super.loadConfig(); this.loot = new HashMap<>(); for (String eId : cfg.getSection("Settings.Treasures")) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantTemper.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantTemper.java index f407e90..79551a6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantTemper.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantTemper.java @@ -24,13 +24,17 @@ public class EnchantTemper extends IEnchantChanceTemplate implements CombatEncha public static final String PLACEHOLDER_DAMAGE_CAPACITY = "%enchantment_damage_capacity%"; public static final String PLACEHOLDER_HEALTH_POINT = "%enchantment_health_point%"; - private final EnchantScaler damageAmount; - private final EnchantScaler damageCapacity; - private final EnchantScaler healthPoint; + private EnchantScaler damageAmount; + private EnchantScaler damageCapacity; + private EnchantScaler healthPoint; public EnchantTemper(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + @Override + public void loadConfig() { + super.loadConfig(); this.damageAmount = new EnchantScaler(this, "Settings.Damage.Amount"); this.damageCapacity = new EnchantScaler(this, "Settings.Damage.Capacity"); this.healthPoint = new EnchantScaler(this, "Settings.Health.Point"); @@ -82,7 +86,7 @@ public class EnchantTemper extends IEnchantChanceTemplate implements CombatEncha double damageAmount = this.getDamageAmount(level); double damageCap = this.getDamageCapacity(level); - double damageFinal = Math.min(damageCap, damageAmount * pointAmount); + double damageFinal = Math.min(damageCap, 1D + damageAmount * pointAmount); e.setDamage(e.getDamage() * damageFinal); return true; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThrifty.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThrifty.java index 05df499..1f12fc0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThrifty.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThrifty.java @@ -24,8 +24,8 @@ import java.util.stream.Collectors; public class EnchantThrifty extends IEnchantChanceTemplate implements DeathEnchant { - private final Set ignoredEntityTypes; - private final Set ignoredSpawnReasons; + private Set ignoredEntityTypes; + private Set ignoredSpawnReasons; private final NamespacedKey keyEntityIgnored; public static final String ID = "thrifty"; @@ -33,7 +33,11 @@ public class EnchantThrifty extends IEnchantChanceTemplate implements DeathEncha public EnchantThrifty(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); this.keyEntityIgnored = new NamespacedKey(plugin, ID + "_ignored"); + } + @Override + public void loadConfig() { + super.loadConfig(); this.ignoredEntityTypes = cfg.getStringSet("Settings.Ignored_Entity_Types").stream().map(String::toUpperCase).collect(Collectors.toSet()); this.ignoredSpawnReasons = cfg.getStringSet("Settings.Ignored_Spawn_Reasons").stream().map(String::toUpperCase).collect(Collectors.toSet()); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThunder.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThunder.java index 54c0381..fe2965d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThunder.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThunder.java @@ -13,13 +13,17 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; public class EnchantThunder extends IEnchantChanceTemplate implements CombatEnchant { - private final boolean inThunderstormOnly; + private boolean inThunderstormOnly; public static final String ID = "thunder"; public EnchantThunder(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + @Override + public void loadConfig() { + super.loadConfig(); this.inThunderstormOnly = cfg.getBoolean("Settings.During_Thunderstorm_Only"); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java index c767219..ed492c3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java @@ -23,17 +23,21 @@ import java.util.function.UnaryOperator; public class EnchantVampire extends IEnchantChanceTemplate implements CombatEnchant { - private final String particleName; - private final String particleData; - private final Scaler healAmount; - private final boolean healMultiplier; + private String particleName; + private String particleData; + private Scaler healAmount; + private boolean healMultiplier; public static final String ID = "vampire"; public static final String PLACEHOLDER_HEAL_AMOUNT = "%enchantment_heal_amount%"; public EnchantVampire(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.LOWEST); + } + @Override + public void loadConfig() { + super.loadConfig(); this.particleName = cfg.getString("Settings.Particle.Name", Particle.HEART.name()); this.particleData = cfg.getString("Settings.Particle.Data", ""); this.healAmount = new EnchantScaler(this, "Settings.Heal.Amount"); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java index dda0224..89740d4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java @@ -1,7 +1,6 @@ package su.nightexpress.excellentenchants.manager.enchants.weapon; import org.bukkit.Particle; -import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Illager; import org.bukkit.entity.LivingEntity; @@ -16,24 +15,27 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import java.util.function.UnaryOperator; public class EnchantVillageDefender extends IEnchantChanceTemplate implements CombatEnchant { - private final boolean damageMultiplier; - private final Scaler damageAmount; - private final String particleName; - private final String particleData; + private boolean damageMultiplier; + private Scaler damageAmount; + private String particleName; + private String particleData; public static final String ID = "village_defender"; public static final String PLACEHOLDER_DAMAGE_AMOUNT = "%enchantment_damage_amount%"; public EnchantVillageDefender(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); + } + @Override + public void loadConfig() { + super.loadConfig(); this.damageAmount = new EnchantScaler(this, "Settings.Damage.Formula"); this.damageMultiplier = cfg.getBoolean("Settings.Damage.As_Modifier"); this.particleName = cfg.getString("Settings.Particle.Name", Particle.VILLAGER_ANGRY.name()); @@ -65,15 +67,6 @@ public class EnchantVillageDefender extends IEnchantChanceTemplate implements Co cfg.addMissing("Settings.Particle.Data", ""); } - @Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(EnchantRegister.BANE_OF_NETHERSPAWN); - this.addConflict(Enchantment.DAMAGE_ARTHROPODS); - this.addConflict(Enchantment.DAMAGE_UNDEAD); - this.addConflict(Enchantment.DAMAGE_ALL); - } - @Override @NotNull public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/resources/enchants/aquaman.yml b/Core/src/main/resources/enchants/aquaman.yml index 72ecd4b..9d8583f 100644 --- a/Core/src/main/resources/enchants/aquaman.yml +++ b/Core/src/main/resources/enchants/aquaman.yml @@ -12,11 +12,13 @@ Tier: exotic # You can use multiple lines here. # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 - %enchantment_cost_item%. +- 'Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 %enchantment_cost_item%.' # Defines if this enchantment is a treasure enchantment. # Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/bane_of_netherspawn.yml b/Core/src/main/resources/enchants/bane_of_netherspawn.yml index 8b677df..4085e2f 100644 --- a/Core/src/main/resources/enchants/bane_of_netherspawn.yml +++ b/Core/src/main/resources/enchants/bane_of_netherspawn.yml @@ -15,6 +15,13 @@ Description: # Defines if this enchantment is a treasure enchantment. # Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - village_defender + - sharpness + - smite + - bane_of_arthropods # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/blast_mining.yml b/Core/src/main/resources/enchants/blast_mining.yml index d61b8c3..f1324e4 100644 --- a/Core/src/main/resources/enchants/blast_mining.yml +++ b/Core/src/main/resources/enchants/blast_mining.yml @@ -15,6 +15,11 @@ Tier: legendary Description: - '%enchantment_trigger_chance%% chance to mine blocks by x%enchantment_explosion_power% power explosion.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - tunnel + - veinminer # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/blindness.yml b/Core/src/main/resources/enchants/blindness.yml index 5791b78..23ee75b 100644 --- a/Core/src/main/resources/enchants/blindness.yml +++ b/Core/src/main/resources/enchants/blindness.yml @@ -17,6 +17,9 @@ Tier: common Description: - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/bomber.yml b/Core/src/main/resources/enchants/bomber.yml index 8650e99..208f0fb 100644 --- a/Core/src/main/resources/enchants/bomber.yml +++ b/Core/src/main/resources/enchants/bomber.yml @@ -14,6 +14,20 @@ Tier: exotic # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to launch TNT that explodes in %enchantment_fuse_ticks%s.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - ender_bow + - ghast + - explosive_arrows + - withered_arrows + - poisoned_arrows + - dragonfire_arrows + - electrified_arrows + - confusing_arrows + - flame + - power + - punch # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/bunny_hop.yml b/Core/src/main/resources/enchants/bunny_hop.yml index 80637cf..3f8a21f 100644 --- a/Core/src/main/resources/enchants/bunny_hop.yml +++ b/Core/src/main/resources/enchants/bunny_hop.yml @@ -16,6 +16,9 @@ Tier: common # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Grants permanent %enchantment_potion_type% %enchantment_potion_level%. +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/cold_steel.yml b/Core/src/main/resources/enchants/cold_steel.yml index 6b680ec..80ed6f4 100644 --- a/Core/src/main/resources/enchants/cold_steel.yml +++ b/Core/src/main/resources/enchants/cold_steel.yml @@ -17,6 +17,9 @@ Tier: rare Description: - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. to attacker.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/confusing_arrows.yml b/Core/src/main/resources/enchants/confusing_arrows.yml index fa95d78..987cc97 100644 --- a/Core/src/main/resources/enchants/confusing_arrows.yml +++ b/Core/src/main/resources/enchants/confusing_arrows.yml @@ -17,6 +17,9 @@ Tier: common Description: - '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/confusion.yml b/Core/src/main/resources/enchants/confusion.yml index 4b61618..6823c10 100644 --- a/Core/src/main/resources/enchants/confusion.yml +++ b/Core/src/main/resources/enchants/confusion.yml @@ -17,6 +17,9 @@ Tier: common Description: - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/cure.yml b/Core/src/main/resources/enchants/cure.yml index 9920323..d0e91f5 100644 --- a/Core/src/main/resources/enchants/cure.yml +++ b/Core/src/main/resources/enchants/cure.yml @@ -13,6 +13,9 @@ Tier: exotic # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to cure Zombified Piglins and Zombie Villagers.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/curse_of_breaking.yml b/Core/src/main/resources/enchants/curse_of_breaking.yml index 04d15d0..1ac4680 100644 --- a/Core/src/main/resources/enchants/curse_of_breaking.yml +++ b/Core/src/main/resources/enchants/curse_of_breaking.yml @@ -15,6 +15,10 @@ Tier: cursed Description: - '%enchantment_trigger_chance%% chance the item will consume extra %enchantment_durability_amount% durability points.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - durability # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/curse_of_misfortune.yml b/Core/src/main/resources/enchants/curse_of_misfortune.yml index f81da4f..f7954de 100644 --- a/Core/src/main/resources/enchants/curse_of_misfortune.yml +++ b/Core/src/main/resources/enchants/curse_of_misfortune.yml @@ -13,6 +13,11 @@ Tier: cursed # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to have no drops from blocks or mobs.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - fortune + - looting # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/cutter.yml b/Core/src/main/resources/enchants/cutter.yml index 5ff0bea..0718a83 100644 --- a/Core/src/main/resources/enchants/cutter.yml +++ b/Core/src/main/resources/enchants/cutter.yml @@ -15,6 +15,9 @@ Tier: exotic Description: - '%enchantment_trigger_chance%% chance to throw away enemy''s armor and damage it for %enchantment_durability_damage%%.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/decapitator.yml b/Core/src/main/resources/enchants/decapitator.yml index fe98f39..aa98887 100644 --- a/Core/src/main/resources/enchants/decapitator.yml +++ b/Core/src/main/resources/enchants/decapitator.yml @@ -13,6 +13,9 @@ Tier: exotic # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to obtain player''s or mob''s head.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/divine_touch.yml b/Core/src/main/resources/enchants/divine_touch.yml index 57bfd67..d62f1e7 100644 --- a/Core/src/main/resources/enchants/divine_touch.yml +++ b/Core/src/main/resources/enchants/divine_touch.yml @@ -13,6 +13,10 @@ Tier: legendary # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to obtain &fMob Spawner&8.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - smelter # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/double_strike.yml b/Core/src/main/resources/enchants/double_strike.yml index dd30405..1417dd8 100644 --- a/Core/src/main/resources/enchants/double_strike.yml +++ b/Core/src/main/resources/enchants/double_strike.yml @@ -13,6 +13,9 @@ Tier: legendary # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to inflict double damage.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/dragonfire_arrows.yml b/Core/src/main/resources/enchants/dragonfire_arrows.yml index a862d96..15f51a7 100644 --- a/Core/src/main/resources/enchants/dragonfire_arrows.yml +++ b/Core/src/main/resources/enchants/dragonfire_arrows.yml @@ -16,6 +16,14 @@ Tier: exotic Description: - '%enchantment_trigger_chance%% chance to launch an dragonfire arrow (R=%enchantment_fire_radius%, %enchantment_fire_duration%s).' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - confusing_arrows + - poisoned_arrows + - explosive_arrows + - withered_arrows + - electrified_arrows # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/electrified_arrows.yml b/Core/src/main/resources/enchants/electrified_arrows.yml index ddb7ea2..1c62204 100644 --- a/Core/src/main/resources/enchants/electrified_arrows.yml +++ b/Core/src/main/resources/enchants/electrified_arrows.yml @@ -13,6 +13,14 @@ Tier: rare # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to launch an electrified arrow.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - confusing_arrows + - poisoned_arrows + - explosive_arrows + - withered_arrows + - dragonfire_arrows # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/ender_bow.yml b/Core/src/main/resources/enchants/ender_bow.yml index 3d74a98..ade8d32 100644 --- a/Core/src/main/resources/enchants/ender_bow.yml +++ b/Core/src/main/resources/enchants/ender_bow.yml @@ -13,6 +13,20 @@ Tier: legendary # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to shoot Ender Pearl instead of arrows.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - bomber + - ghast + - explosive_arrows + - withered_arrows + - poisoned_arrows + - dragonfire_arrows + - electrified_arrows + - confusing_arrows + - flame + - power + - punch # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/exhaust.yml b/Core/src/main/resources/enchants/exhaust.yml index 1f05961..a90119e 100644 --- a/Core/src/main/resources/enchants/exhaust.yml +++ b/Core/src/main/resources/enchants/exhaust.yml @@ -17,6 +17,9 @@ Tier: common Description: - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/exp_hunter.yml b/Core/src/main/resources/enchants/exp_hunter.yml index 5d8b4fd..69512cb 100644 --- a/Core/src/main/resources/enchants/exp_hunter.yml +++ b/Core/src/main/resources/enchants/exp_hunter.yml @@ -15,6 +15,9 @@ Tier: rare Description: - '%enchantment_trigger_chance%% chance to obtain +%enchantment_exp_modifier%% more exp from mobs.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/explosive_arrows.yml b/Core/src/main/resources/enchants/explosive_arrows.yml index c4092f6..1ddb540 100644 --- a/Core/src/main/resources/enchants/explosive_arrows.yml +++ b/Core/src/main/resources/enchants/explosive_arrows.yml @@ -15,6 +15,14 @@ Tier: exotic Description: - '%enchantment_trigger_chance%% chance to launch an explosive arrow with x%enchantment_explosion_power% power.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - confusing_arrows + - poisoned_arrows + - dragonfire_arrows + - withered_arrows + - electrified_arrows # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/flame_walker.yml b/Core/src/main/resources/enchants/flame_walker.yml index 2e5f18f..7021b43 100644 --- a/Core/src/main/resources/enchants/flame_walker.yml +++ b/Core/src/main/resources/enchants/flame_walker.yml @@ -13,6 +13,10 @@ Tier: exotic # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Ability to walk on lava and on magma blocks without getting damage. +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - frost_walker # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/ghast.yml b/Core/src/main/resources/enchants/ghast.yml index 9ebe12c..102d375 100644 --- a/Core/src/main/resources/enchants/ghast.yml +++ b/Core/src/main/resources/enchants/ghast.yml @@ -13,6 +13,19 @@ Tier: rare # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to launch a fireball instead of arrow.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - ender_bow + - bomber + - explosive_arrows + - withered_arrows + - poisoned_arrows + - dragonfire_arrows + - electrified_arrows + - confusing_arrows + - flame + - punch # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/hardened.yml b/Core/src/main/resources/enchants/hardened.yml index 7e6c9e2..0653997 100644 --- a/Core/src/main/resources/enchants/hardened.yml +++ b/Core/src/main/resources/enchants/hardened.yml @@ -17,6 +17,9 @@ Tier: rare Description: - '%enchantment_trigger_chance%% chance to obtain %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. when damaged.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/haste.yml b/Core/src/main/resources/enchants/haste.yml index cb90fd0..dc74e76 100644 --- a/Core/src/main/resources/enchants/haste.yml +++ b/Core/src/main/resources/enchants/haste.yml @@ -16,6 +16,9 @@ Tier: rare # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Grants %enchantment_potion_type% %enchantment_potion_level% effect. +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/hover.yml b/Core/src/main/resources/enchants/hover.yml index 5a89096..2c3591e 100644 --- a/Core/src/main/resources/enchants/hover.yml +++ b/Core/src/main/resources/enchants/hover.yml @@ -17,6 +17,9 @@ Tier: common Description: - '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/ice_aspect.yml b/Core/src/main/resources/enchants/ice_aspect.yml index f66d4e7..62bc8dd 100644 --- a/Core/src/main/resources/enchants/ice_aspect.yml +++ b/Core/src/main/resources/enchants/ice_aspect.yml @@ -17,6 +17,9 @@ Tier: common Description: - '%enchantment_trigger_chance%% chance to freeze and apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/infernus.yml b/Core/src/main/resources/enchants/infernus.yml index b5dbb23..924ea9d 100644 --- a/Core/src/main/resources/enchants/infernus.yml +++ b/Core/src/main/resources/enchants/infernus.yml @@ -15,6 +15,9 @@ Tier: common Description: - '%enchantment_trigger_chance%% chance to launch flaming Trident that ignites the enemy for %enchantment_fire_duration%s.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/lucky_miner.yml b/Core/src/main/resources/enchants/lucky_miner.yml index c484974..594a818 100644 --- a/Core/src/main/resources/enchants/lucky_miner.yml +++ b/Core/src/main/resources/enchants/lucky_miner.yml @@ -15,6 +15,9 @@ Tier: common Description: - '%enchantment_trigger_chance%% chance to obtain +%enchantment_exp_modifier%% more exp from ores.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/night_vision.yml b/Core/src/main/resources/enchants/night_vision.yml index cae0def..57f9481 100644 --- a/Core/src/main/resources/enchants/night_vision.yml +++ b/Core/src/main/resources/enchants/night_vision.yml @@ -17,6 +17,9 @@ Tier: rare Description: - Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 %enchantment_cost_item%. +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/nimble.yml b/Core/src/main/resources/enchants/nimble.yml index b6796b2..d32a88e 100644 --- a/Core/src/main/resources/enchants/nimble.yml +++ b/Core/src/main/resources/enchants/nimble.yml @@ -20,6 +20,9 @@ Level: # Maximal (final) enchantment level. # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 1 +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment settings for Anvil. Anvil: # Defines the exp cost to merge this enchantment on other items on anvil. diff --git a/Core/src/main/resources/enchants/paralyze.yml b/Core/src/main/resources/enchants/paralyze.yml index 1c1ea3e..528e323 100644 --- a/Core/src/main/resources/enchants/paralyze.yml +++ b/Core/src/main/resources/enchants/paralyze.yml @@ -17,6 +17,9 @@ Tier: rare Description: - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/poisoned_arrows.yml b/Core/src/main/resources/enchants/poisoned_arrows.yml index f849a0a..3cf2c17 100644 --- a/Core/src/main/resources/enchants/poisoned_arrows.yml +++ b/Core/src/main/resources/enchants/poisoned_arrows.yml @@ -17,6 +17,14 @@ Tier: common Description: - '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - confusing_arrows + - dragonfire_arrows + - explosive_arrows + - withered_arrows + - electrified_arrows # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/rage.yml b/Core/src/main/resources/enchants/rage.yml index 8705c6b..cf24a06 100644 --- a/Core/src/main/resources/enchants/rage.yml +++ b/Core/src/main/resources/enchants/rage.yml @@ -17,6 +17,9 @@ Tier: rare Description: - '%enchantment_trigger_chance%% chance to get %enchantment_potion_type% %enchantment_potion_level% effect for %enchantment_potion_duration%s. on hit.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/regrowth.yml b/Core/src/main/resources/enchants/regrowth.yml index c24c3e4..2ffba98 100644 --- a/Core/src/main/resources/enchants/regrowth.yml +++ b/Core/src/main/resources/enchants/regrowth.yml @@ -16,6 +16,9 @@ Tier: exotic Description: - Restores %enchantment_health_amount% hearts every %enchantment_health_interval%s. with %enchantment_trigger_chance%% chance. +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/replanter.yml b/Core/src/main/resources/enchants/replanter.yml index 8f8ca8f..b11a8c4 100644 --- a/Core/src/main/resources/enchants/replanter.yml +++ b/Core/src/main/resources/enchants/replanter.yml @@ -20,6 +20,9 @@ Level: # Maximal (final) enchantment level. # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 1 +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment settings for Anvil. Anvil: # Defines the exp cost to merge this enchantment on other items on anvil. diff --git a/Core/src/main/resources/enchants/rocket.yml b/Core/src/main/resources/enchants/rocket.yml index 63c7f62..7914d58 100644 --- a/Core/src/main/resources/enchants/rocket.yml +++ b/Core/src/main/resources/enchants/rocket.yml @@ -20,6 +20,9 @@ Level: # Maximal (final) enchantment level. # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment settings for Anvil. Anvil: # Defines the exp cost to merge this enchantment on other items on anvil. diff --git a/Core/src/main/resources/enchants/saturation.yml b/Core/src/main/resources/enchants/saturation.yml index b43ee5b..b5e00f0 100644 --- a/Core/src/main/resources/enchants/saturation.yml +++ b/Core/src/main/resources/enchants/saturation.yml @@ -16,6 +16,9 @@ Tier: rare Description: - Restores %enchantment_saturation_amount% food points every %enchantment_saturation_interval%s. with %enchantment_trigger_chance%% chance. +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/scavenger.yml b/Core/src/main/resources/enchants/scavenger.yml index 71a0194..17bd0df 100644 --- a/Core/src/main/resources/enchants/scavenger.yml +++ b/Core/src/main/resources/enchants/scavenger.yml @@ -13,6 +13,9 @@ Tier: common # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to obtain additional loot from mobs.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/self_destruction.yml b/Core/src/main/resources/enchants/self_destruction.yml index 4843874..de0a31b 100644 --- a/Core/src/main/resources/enchants/self_destruction.yml +++ b/Core/src/main/resources/enchants/self_destruction.yml @@ -15,6 +15,9 @@ Tier: exotic Description: - '%enchantment_trigger_chance%% chance to create an x%enchantment_explosion_power% power explosion on death.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/silk_chest.yml b/Core/src/main/resources/enchants/silk_chest.yml index 5e5c795..3f52c43 100644 --- a/Core/src/main/resources/enchants/silk_chest.yml +++ b/Core/src/main/resources/enchants/silk_chest.yml @@ -13,6 +13,9 @@ Tier: rare # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Drop chests and saves all its content. +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/smelter.yml b/Core/src/main/resources/enchants/smelter.yml index d07262c..a04021e 100644 --- a/Core/src/main/resources/enchants/smelter.yml +++ b/Core/src/main/resources/enchants/smelter.yml @@ -13,6 +13,9 @@ Tier: rare # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to smelt ore or a block on mining.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/sonic.yml b/Core/src/main/resources/enchants/sonic.yml index a1b3885..23f7e5a 100644 --- a/Core/src/main/resources/enchants/sonic.yml +++ b/Core/src/main/resources/enchants/sonic.yml @@ -16,6 +16,9 @@ Tier: rare # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Grants %enchantment_potion_type% %enchantment_potion_level% effect. +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/surprise.yml b/Core/src/main/resources/enchants/surprise.yml index 6ce5ad9..bbb8e52 100644 --- a/Core/src/main/resources/enchants/surprise.yml +++ b/Core/src/main/resources/enchants/surprise.yml @@ -17,6 +17,9 @@ Tier: exotic Description: - '%enchantment_trigger_chance%% chance to apply random potion effect to enemy on hit.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/telekinesis.yml b/Core/src/main/resources/enchants/telekinesis.yml index f4b8dcc..46f001f 100644 --- a/Core/src/main/resources/enchants/telekinesis.yml +++ b/Core/src/main/resources/enchants/telekinesis.yml @@ -13,6 +13,9 @@ Tier: exotic # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Moves all blocks loot directly to your inventory. +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/temper.yml b/Core/src/main/resources/enchants/temper.yml index 767c14c..2627c6c 100644 --- a/Core/src/main/resources/enchants/temper.yml +++ b/Core/src/main/resources/enchants/temper.yml @@ -18,6 +18,9 @@ Description: - '%enchantment_trigger_chance%% chance to inflict %enchantment_damage_amount%% (max. %enchantment_damage_capacity%%) more damage for each %enchantment_health_point% hearts missing.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/thrifty.yml b/Core/src/main/resources/enchants/thrifty.yml index 8dcc233..92ee8c4 100644 --- a/Core/src/main/resources/enchants/thrifty.yml +++ b/Core/src/main/resources/enchants/thrifty.yml @@ -13,6 +13,9 @@ Tier: exotic # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to obtain mob Spawn Egg on kill.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/thunder.yml b/Core/src/main/resources/enchants/thunder.yml index 49bcadf..e90a0d7 100644 --- a/Core/src/main/resources/enchants/thunder.yml +++ b/Core/src/main/resources/enchants/thunder.yml @@ -13,6 +13,9 @@ Tier: rare # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to summon lightning to enemy on hit.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/treasures.yml b/Core/src/main/resources/enchants/treasures.yml index 8202539..b1dca78 100644 --- a/Core/src/main/resources/enchants/treasures.yml +++ b/Core/src/main/resources/enchants/treasures.yml @@ -13,6 +13,9 @@ Tier: common # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to attempt to find a treasure in mined block.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/tunnel.yml b/Core/src/main/resources/enchants/tunnel.yml index b9af259..227b82a 100644 --- a/Core/src/main/resources/enchants/tunnel.yml +++ b/Core/src/main/resources/enchants/tunnel.yml @@ -13,6 +13,11 @@ Tier: legendary # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Allows you to mine multiple blocks at once in a shape. +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - veinminer + - blast_mining # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/vampire.yml b/Core/src/main/resources/enchants/vampire.yml index d9a7a10..2cde83f 100644 --- a/Core/src/main/resources/enchants/vampire.yml +++ b/Core/src/main/resources/enchants/vampire.yml @@ -15,6 +15,9 @@ Tier: exotic Description: - '%enchantment_trigger_chance%% chance to heal yourself for %enchantment_heal_amount% heart(s) on hit.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/veinminer.yml b/Core/src/main/resources/enchants/veinminer.yml index e3ea7c8..1e84d11 100644 --- a/Core/src/main/resources/enchants/veinminer.yml +++ b/Core/src/main/resources/enchants/veinminer.yml @@ -14,6 +14,11 @@ Tier: rare # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Mines up to %enchantment_block_limit% blocks of the ore vein at once. +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - blast_mining + - tunnel # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/venom.yml b/Core/src/main/resources/enchants/venom.yml index 6f3a517..19913d3 100644 --- a/Core/src/main/resources/enchants/venom.yml +++ b/Core/src/main/resources/enchants/venom.yml @@ -17,6 +17,9 @@ Tier: rare Description: - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/village_defender.yml b/Core/src/main/resources/enchants/village_defender.yml index 60a88cb..76d1127 100644 --- a/Core/src/main/resources/enchants/village_defender.yml +++ b/Core/src/main/resources/enchants/village_defender.yml @@ -15,6 +15,13 @@ Tier: common Description: - '%enchantment_trigger_chance%% chance to inflict %enchantment_damage_amount% more damage on Pillagers.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - bane_of_netherspawn + - sharpness + - smite + - bane_of_arthropods # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/wither.yml b/Core/src/main/resources/enchants/wither.yml index 9425b18..9200376 100644 --- a/Core/src/main/resources/enchants/wither.yml +++ b/Core/src/main/resources/enchants/wither.yml @@ -17,6 +17,9 @@ Tier: rare Description: - '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/enchants/withered_arrows.yml b/Core/src/main/resources/enchants/withered_arrows.yml index 81c81a2..05e5c5a 100644 --- a/Core/src/main/resources/enchants/withered_arrows.yml +++ b/Core/src/main/resources/enchants/withered_arrows.yml @@ -17,6 +17,14 @@ Tier: rare Description: - '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.)' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: + - confusing_arrows + - poisoned_arrows + - explosive_arrows + - dragonfire_arrows + - electrified_arrows # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. diff --git a/Core/src/main/resources/lang/messages_ru.yml b/Core/src/main/resources/lang/messages_ru.yml index 9eff883..e391d9e 100644 --- a/Core/src/main/resources/lang/messages_ru.yml +++ b/Core/src/main/resources/lang/messages_ru.yml @@ -1,35 +1,53 @@ Command: List: - Desc: Список всех пользовательских зачарований. + Desc: 'Список всех пользовательских зачарований.' Enchant: - Usage: <зачарование> <уровень> - Desc: Зачаровывает предмет в вашей руке. - Done: '&aУспешно зачарован!' + Usage: '<чары> <уровень>' + Desc: 'Зачаровывает предмет в вашей руке.' + Done: '&aУспешно зачаровано!' Book: - Usage: <игрок> <зачарование> <уровень> - Desc: Даёт кастомную книгу зачарования. - Done: Выдана книга зачарованя &6%enchant%&7 &6%player%&7. + Usage: '<игрок> <чары> <уровень>' + Desc: 'Даёт книгу с выбранным зачарованием.' + Done: 'Книга зачарования &6%enchant%&7 выдана &6%player%&7.' TierBook: - Usage: <игрок> <клас> <уровень> - Desc: Даёт зачарованную книгу. + Usage: '<игрок> <класс> <уровень>' + Desc: 'Даёт книгу со случайными чарами определенного класса.' Error: '&cНеверный уровень!' - Done: Выдан зачарованная книга класа &6%tier%&7 &6%player%&7. + Done: 'Зачарованная книга класса &6%tier%&7 выдана &6%player%&7.' Error: - NoEnchant: '&cНет такого зачарования.' + NoEnchant: '&cЗачарование не существует.' EnchantmentTarget: - ALL: All - ARMOR: Armor - ARMOR_FEET: Armor Feet - ARMOR_LEGS: Armor Legs - ARMOR_TORSO: Armor Torso - ARMOR_HEAD: Armor Head - WEAPON: Weapon - TOOL: Tool - BOW: Bow - FISHING_ROD: Fishing Rod - BREAKABLE: Breakable - WEARABLE: Wearable - TRIDENT: Trident - CROSSBOW: Crossbow - VANISHABLE: Vanishable - BOW_AND_CROSSBOW: Bow And Crossbow \ No newline at end of file + ALL: Всё + ARMOR: Броня + ARMOR_FEET: Ботинки + ARMOR_LEGS: Ноги + ARMOR_TORSO: Грудь + ARMOR_HEAD: Голова + WEAPON: Оружие + TOOL: Инструмент + BOW: Лук + FISHING_ROD: Удочка + BREAKABLE: Ломаемое + WEARABLE: Надеваемое + TRIDENT: Трезубец + CROSSBOW: Арбалет + VANISHABLE: Утрачиваемое + BOW_AND_CROSSBOW: Лук и Арбалет +FitItemType: + HELMET: Шлем + CHESTPLATE: Нагрудник + LEGGINGS: Поножи + BOOTS: Ботинки + ELYTRA: Элитры + WEAPON: Оружие + TOOL: Инструмент + ARMOR: Броня + SWORD: Меч + TRIDENT: Трезубец + AXE: Топор + BOW: Лук + CROSSBOW: Арбалет + HOE: Мотыга + PICKAXE: Кирка + SHOVEL: Лопата + FISHING_ROD: Удочка \ No newline at end of file diff --git a/Core/src/main/resources/plugin.yml b/Core/src/main/resources/plugin.yml index 386117e..abbaa5d 100644 --- a/Core/src/main/resources/plugin.yml +++ b/Core/src/main/resources/plugin.yml @@ -5,7 +5,7 @@ author: NightExpress desciption: Vanilla-like enchants for your server. depend: [ NexEngine ] softdepend: [ Towny, Residence, WorldGuard, GriefPrevention, Lands ] -api-version: 1.16 +api-version: 1.17 load: STARTUP permissions: diff --git a/NMS/pom.xml b/NMS/pom.xml index b609f04..6706f67 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.3 + 3.2.4 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index e6e329c..169720f 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.3 + 3.2.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.3 + 3.2.4 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 8499523..3f74daa 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.3 + 3.2.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.3 + 3.2.4 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index 26e50d6..35fb5e5 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.3 + 3.2.4 4.0.0 @@ -20,13 +20,13 @@ org.spigotmc spigot - 1.19-R0.1-SNAPSHOT + 1.19.1-R0.1-SNAPSHOT remapped-mojang su.nightexpress.excellentenchants NMS - 3.2.3 + 3.2.4 diff --git a/pom.xml b/pom.xml index 8a348f5..431867b 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.2.3 + 3.2.4 Core NMS @@ -25,7 +25,7 @@ su.nexmedia NexEngine - 2.2.2 + 2.2.3 From 1354ddf9bdffffa76b2c62d452c195a4b90f5c94 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Thu, 4 Aug 2022 19:50:21 +0500 Subject: [PATCH 12/69] 3.2.5 --- Core/pom.xml | 10 +- .../api/enchantment/ExcellentEnchant.java | 37 ++++++ .../manager/EnchantManager.java | 2 +- .../manager/EnchantRegister.java | 4 + .../armor/EnchantElementalProtection.java | 107 +++++++++++++++++ .../enchants/armor/EnchantFireShield.java | 67 +++++++++++ Core/src/main/resources/enchants/aquaman.yml | 33 +++++- .../enchants/bane_of_netherspawn.yml | 38 +++++- .../main/resources/enchants/blast_mining.yml | 34 +++++- .../src/main/resources/enchants/blindness.yml | 30 +++++ Core/src/main/resources/enchants/bomber.yml | 52 +++++++-- .../src/main/resources/enchants/bunny_hop.yml | 30 +++++ .../main/resources/enchants/cold_steel.yml | 30 +++++ .../resources/enchants/confusing_arrows.yml | 30 +++++ .../src/main/resources/enchants/confusion.yml | 30 +++++ Core/src/main/resources/enchants/cure.yml | 30 +++++ .../resources/enchants/curse_of_breaking.yml | 32 +++++- .../enchants/curse_of_misfortune.yml | 34 +++++- Core/src/main/resources/enchants/cutter.yml | 30 +++++ .../main/resources/enchants/decapitator.yml | 30 +++++ .../main/resources/enchants/divine_touch.yml | 32 +++++- .../main/resources/enchants/double_strike.yml | 30 +++++ .../resources/enchants/dragonfire_arrows.yml | 40 ++++++- .../resources/enchants/electrified_arrows.yml | 40 ++++++- .../enchants/elemental_protection.yml | 108 ++++++++++++++++++ .../src/main/resources/enchants/ender_bow.yml | 52 +++++++-- Core/src/main/resources/enchants/exhaust.yml | 30 +++++ .../main/resources/enchants/exp_hunter.yml | 30 +++++ .../resources/enchants/explosive_arrows.yml | 40 ++++++- .../main/resources/enchants/fire_shield.yml | 101 ++++++++++++++++ .../main/resources/enchants/flame_walker.yml | 32 +++++- Core/src/main/resources/enchants/ghast.yml | 50 ++++++-- Core/src/main/resources/enchants/hardened.yml | 30 +++++ Core/src/main/resources/enchants/haste.yml | 30 +++++ Core/src/main/resources/enchants/hover.yml | 30 +++++ .../main/resources/enchants/ice_aspect.yml | 30 +++++ Core/src/main/resources/enchants/infernus.yml | 30 +++++ .../main/resources/enchants/lucky_miner.yml | 30 +++++ .../main/resources/enchants/night_vision.yml | 30 +++++ Core/src/main/resources/enchants/nimble.yml | 30 +++++ Core/src/main/resources/enchants/paralyze.yml | 30 +++++ .../resources/enchants/poisoned_arrows.yml | 40 ++++++- Core/src/main/resources/enchants/rage.yml | 30 +++++ Core/src/main/resources/enchants/regrowth.yml | 30 +++++ .../src/main/resources/enchants/replanter.yml | 30 +++++ Core/src/main/resources/enchants/rocket.yml | 30 +++++ .../main/resources/enchants/saturation.yml | 30 +++++ .../src/main/resources/enchants/scavenger.yml | 30 +++++ .../resources/enchants/self_destruction.yml | 30 +++++ .../main/resources/enchants/silk_chest.yml | 30 +++++ Core/src/main/resources/enchants/smelter.yml | 30 +++++ Core/src/main/resources/enchants/sonic.yml | 30 +++++ Core/src/main/resources/enchants/surprise.yml | 30 +++++ .../main/resources/enchants/telekinesis.yml | 30 +++++ Core/src/main/resources/enchants/temper.yml | 30 +++++ Core/src/main/resources/enchants/thrifty.yml | 30 +++++ Core/src/main/resources/enchants/thunder.yml | 30 +++++ .../src/main/resources/enchants/treasures.yml | 30 +++++ Core/src/main/resources/enchants/tunnel.yml | 34 +++++- Core/src/main/resources/enchants/vampire.yml | 30 +++++ .../src/main/resources/enchants/veinminer.yml | 34 +++++- Core/src/main/resources/enchants/venom.yml | 30 +++++ .../resources/enchants/village_defender.yml | 38 +++++- Core/src/main/resources/enchants/wither.yml | 30 +++++ .../resources/enchants/withered_arrows.yml | 40 ++++++- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 +- V1_18_R2/pom.xml | 4 +- V1_19_R1/pom.xml | 12 +- pom.xml | 2 +- 70 files changed, 2230 insertions(+), 95 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFireShield.java create mode 100644 Core/src/main/resources/enchants/elemental_protection.yml create mode 100644 Core/src/main/resources/enchants/fire_shield.yml diff --git a/Core/pom.xml b/Core/pom.xml index 5925dda..9bfab09 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.4 + 3.2.5 4.0.0 @@ -32,22 +32,22 @@ su.nightexpress.excellentenchants NMS - 3.2.4 + 3.2.5 su.nightexpress.excellentenchants V1_17_R1 - 3.2.4 + 3.2.5 su.nightexpress.excellentenchants V1_18_R2 - 3.2.4 + 3.2.5 su.nightexpress.excellentenchants V1_19_R1 - 3.2.4 + 3.2.5 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index 11cffd3..5eaaff3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -13,6 +13,7 @@ import su.nexmedia.engine.api.manager.IListener; import su.nexmedia.engine.lang.LangManager; import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.*; +import su.nexmedia.engine.utils.data.Pair; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.config.Config; @@ -63,6 +64,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener protected Scaler levelByEnchantCost; protected Scaler anvilMergeCost; protected Map obtainChance; + protected Map> obtainLevelCap; protected ItemStack costItem; protected boolean costEnabled; @@ -97,9 +99,14 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener this.anvilMergeCost = new EnchantScaler(this, "Anvil.Merge_Cost"); this.obtainChance = new HashMap<>(); + this.obtainLevelCap = new HashMap<>(); for (ObtainType obtainType : ObtainType.values()) { double obtainChance = cfg.getDouble(obtainType.getPathName() + ".Chance"); this.obtainChance.put(obtainType, obtainChance); + + int levelMin = cfg.getInt(obtainType.getPathName() + ".Level.Min", -1); + int levelMax = cfg.getInt(obtainType.getPathName() + ".Level.Max", -1); + this.obtainLevelCap.put(obtainType, Pair.of(levelMin, levelMax)); } this.costEnabled = cfg.getBoolean("Settings.Cost.Enabled"); @@ -122,6 +129,14 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener for (ObtainType obtainType : ObtainType.values()) { cfg.addMissing(obtainType.getPathName() + ".Chance", 25D); + cfg.addMissing(obtainType.getPathName() + ".Level.Min", -1); + cfg.addMissing(obtainType.getPathName() + ".Level.Max", -1); + + /*cfg.setComments(obtainType.getPathName() + ".Level", Arrays.asList( + "Here you can set min. and max. level for enchantment generated via " + obtainType.getPathName().replace("_", " "), + "These levels can not be greater or smaller than the default enchantment min. and max levels.", + "Set min/max level to -1 to use the default enchantment min/max level value." + ));*/ } /*String scalabe = "Scalable. Placeholder: " + PLACEHOLDER_LEVEL + ". See: http://77.222.60.131:8080/plugin/engine/config/formats"; @@ -310,6 +325,28 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener return this.obtainChance.getOrDefault(obtainType, 0D); } + public int getObtainLevelMin(@NotNull ObtainType obtainType) { + return this.obtainLevelCap.getOrDefault(obtainType, Pair.of(-1, -1)).getFirst(); + } + + public int getObtainLevelMax(@NotNull ObtainType obtainType) { + return this.obtainLevelCap.getOrDefault(obtainType, Pair.of(-1, -1)).getSecond(); + } + + public int generateLevel() { + return Rnd.get(this.getStartLevel(), this.getMaxLevel()); + } + + public int generateLevel(@NotNull ObtainType obtainType) { + int levelCapMin = this.getObtainLevelMin(obtainType); + int levelCapMax = this.getObtainLevelMax(obtainType); + + if (levelCapMin <= 0 || levelCapMin < this.getStartLevel()) levelCapMin = this.getStartLevel(); + if (levelCapMax <= 0 || levelCapMax > this.getMaxLevel()) levelCapMax = this.getMaxLevel(); + + return Rnd.get(levelCapMin, levelCapMax); + } + public int getAnvilMergeCost(int level) { return (int) this.anvilMergeCost.getValue(level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java index 5d1a3b7..e65f2d7 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java @@ -113,7 +113,7 @@ public class EnchantManager extends AbstractManager { ExcellentEnchant enchant = tier.getEnchant(obtainType, item); if (enchant == null) continue; - int level = Rnd.get(enchant.getStartLevel(), enchant.getMaxLevel()); + int level = enchant.generateLevel(obtainType); EnchantManager.addEnchant(item, enchant, level, false); } EnchantManager.updateItemLoreEnchants(item); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java index 9e482a8..9187838 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java @@ -64,6 +64,8 @@ public class EnchantRegister { public static final EnchantVillageDefender VILLAGE_DEFENDER; public static final EnchantRocket ROCKET; + public static final EnchantElementalProtection ELEMENTAL_PROTECTION; + public static final EnchantFireShield FIRE_SHIELD; public static final EnchantFlameWalker FLAME_WALKER; public static final EnchantHardened HARDENED; public static final EnchantColdSteel COLD_STEEL; @@ -136,6 +138,8 @@ public class EnchantRegister { AQUAMAN = init(EnchantAquaman.class, EnchantAquaman.ID); BUNNY_HOP = init(EnchantBunnyHop.class, EnchantBunnyHop.ID); COLD_STEEL = init(EnchantColdSteel.class, EnchantColdSteel.ID); + ELEMENTAL_PROTECTION = init(EnchantElementalProtection.class, EnchantElementalProtection.ID); + FIRE_SHIELD = init(EnchantFireShield.class, EnchantFireShield.ID); FLAME_WALKER = init(EnchantFlameWalker.class, EnchantFlameWalker.ID); HARDENED = init(EnchantHardened.class, EnchantHardened.ID); NIGHT_VISION = init(EnchantNightVision.class, EnchantNightVision.ID); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java new file mode 100644 index 0000000..fdbe99b --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java @@ -0,0 +1,107 @@ +package su.nightexpress.excellentenchants.manager.enchants.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.ArrayUtil; +import su.nexmedia.engine.utils.EntityUtil; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantElementalProtection extends IEnchantChanceTemplate { + + public static final String ID = "elemental_protection"; + public static final String PLACEHOLDER_PROTECTION_AMOUNT = "%enchantment_protection_amount%"; + public static final String PLACEHOLDER_PROTECTION_CAPACITY = "%enchantment_protection_capacity%"; + + private static final EntityDamageEvent.DamageCause[] DAMAGE_CAUSES = new EntityDamageEvent.DamageCause[] { + EntityDamageEvent.DamageCause.POISON, EntityDamageEvent.DamageCause.WITHER, + EntityDamageEvent.DamageCause.MAGIC, EntityDamageEvent.DamageCause.FREEZE, + EntityDamageEvent.DamageCause.SONIC_BOOM, EntityDamageEvent.DamageCause.LIGHTNING, + }; + + private Scaler protectionAmount; + private double protectionCapacity; + private boolean protectionAsModifier; + + public EnchantElementalProtection(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_PROTECTION_AMOUNT, NumberUtil.format(this.getProtectionAmount(level))) + .replace(PLACEHOLDER_PROTECTION_CAPACITY, NumberUtil.format(this.getProtectionCapacity())) + ); + } + + @Override + public void loadConfig() { + super.loadConfig(); + + this.protectionAmount = new EnchantScaler(this, "Settings.Protection.Amount"); + this.protectionCapacity = cfg.getDouble("Settings.Protection.Capacity"); + this.protectionAsModifier = cfg.getBoolean("Settings.Protection.As_Modifier"); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR; + } + + public double getProtectionAmount(int level) { + return this.protectionAmount.getValue(level); + } + + public double getProtectionCapacity() { + return this.protectionCapacity; + } + + public boolean isProtectionAsModifier() { + return this.protectionAsModifier; + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onDamage(EntityDamageEvent e) { + if (!ArrayUtil.contains(DAMAGE_CAUSES, e.getCause())) return; + if (!(e.getEntity() instanceof LivingEntity victim)) return; + if (!this.isEnchantmentAvailable(victim)) return; + + double protectionAmount = 0D; + for (ItemStack armor : EntityUtil.getArmor(victim)) { + if (armor == null || armor.getType().isAir()) continue; + + int level = armor.getEnchantmentLevel(this); + if (this.checkTriggerChance(level)) { + protectionAmount += this.getProtectionAmount(level); + } + } + if (protectionAmount <= 0D) return; + if (!this.takeCostItem(victim)) return; + + if (protectionAmount > this.getProtectionCapacity()) { + protectionAmount = this.getProtectionCapacity(); + } + + if (this.isProtectionAsModifier()) { + e.setDamage(Math.max(0, 1D - e.getDamage() * protectionAmount)); + } + else { + e.setDamage(Math.max(0, e.getDamage() - protectionAmount)); + } + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFireShield.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFireShield.java new file mode 100644 index 0000000..229e278 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFireShield.java @@ -0,0 +1,67 @@ +package su.nightexpress.excellentenchants.manager.enchants.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +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.api.config.JYML; +import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.manager.object.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantFireShield extends IEnchantChanceTemplate implements CombatEnchant { + + public static final String ID = "fire_shield"; + public static final String PLACEHOLDER_FIRE_DURATION = "%enchantment_fire_duration%"; + + private Scaler fireDuration; + + public EnchantFireShield(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { + super(plugin, cfg, EnchantPriority.MEDIUM); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str + .replace(PLACEHOLDER_FIRE_DURATION, NumberUtil.format(this.getFireDuration(level))) + ); + } + + @Override + public void loadConfig() { + super.loadConfig(); + + this.fireDuration = new EnchantScaler(this, "Settings.Fire.Duration"); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR; + } + + public double getFireDuration(int level) { + return this.fireDuration.getValue(level); + } + + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, + @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isEnchantmentAvailable(victim)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.takeCostItem(victim)) return false; + + int fireTicks = (int) (this.getFireDuration(level) * 20); + damager.setFireTicks(fireTicks); + + return true; + } +} diff --git a/Core/src/main/resources/enchants/aquaman.yml b/Core/src/main/resources/enchants/aquaman.yml index 9d8583f..70a4603 100644 --- a/Core/src/main/resources/enchants/aquaman.yml +++ b/Core/src/main/resources/enchants/aquaman.yml @@ -12,7 +12,8 @@ Tier: exotic # You can use multiple lines here. # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- 'Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 %enchantment_cost_item%.' +- Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 + %enchantment_cost_item%. # Defines if this enchantment is a treasure enchantment. # Treasure enchantments can only be received via looting, trading, or fishing. Is_Treasure: false @@ -39,18 +40,48 @@ Enchanting_Table: Level_By_Exp_Cost: '%enchantment_level% * 15.0' # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/bane_of_netherspawn.yml b/Core/src/main/resources/enchants/bane_of_netherspawn.yml index 4085e2f..d474baa 100644 --- a/Core/src/main/resources/enchants/bane_of_netherspawn.yml +++ b/Core/src/main/resources/enchants/bane_of_netherspawn.yml @@ -18,10 +18,10 @@ Is_Treasure: false # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - village_defender - - sharpness - - smite - - bane_of_arthropods +- village_defender +- sharpness +- smite +- bane_of_arthropods # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -37,6 +37,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -45,15 +51,39 @@ Enchanting_Table: Level_By_Exp_Cost: 6 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 80.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 80.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 80.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/blast_mining.yml b/Core/src/main/resources/enchants/blast_mining.yml index f1324e4..0b19a97 100644 --- a/Core/src/main/resources/enchants/blast_mining.yml +++ b/Core/src/main/resources/enchants/blast_mining.yml @@ -18,8 +18,8 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - tunnel - - veinminer +- tunnel +- veinminer # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 5.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 6.0 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/blindness.yml b/Core/src/main/resources/enchants/blindness.yml index 23ee75b..6194520 100644 --- a/Core/src/main/resources/enchants/blindness.yml +++ b/Core/src/main/resources/enchants/blindness.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/bomber.yml b/Core/src/main/resources/enchants/bomber.yml index 208f0fb..d8c0383 100644 --- a/Core/src/main/resources/enchants/bomber.yml +++ b/Core/src/main/resources/enchants/bomber.yml @@ -17,17 +17,17 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - ender_bow - - ghast - - explosive_arrows - - withered_arrows - - poisoned_arrows - - dragonfire_arrows - - electrified_arrows - - confusing_arrows - - flame - - power - - punch +- ender_bow +- ghast +- explosive_arrows +- withered_arrows +- poisoned_arrows +- dragonfire_arrows +- electrified_arrows +- confusing_arrows +- flame +- power +- punch # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -43,6 +43,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -51,15 +57,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 5.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/bunny_hop.yml b/Core/src/main/resources/enchants/bunny_hop.yml index 3f8a21f..be7c056 100644 --- a/Core/src/main/resources/enchants/bunny_hop.yml +++ b/Core/src/main/resources/enchants/bunny_hop.yml @@ -34,6 +34,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -42,15 +48,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/cold_steel.yml b/Core/src/main/resources/enchants/cold_steel.yml index 80ed6f4..537b0ee 100644 --- a/Core/src/main/resources/enchants/cold_steel.yml +++ b/Core/src/main/resources/enchants/cold_steel.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/confusing_arrows.yml b/Core/src/main/resources/enchants/confusing_arrows.yml index 987cc97..59fd0c8 100644 --- a/Core/src/main/resources/enchants/confusing_arrows.yml +++ b/Core/src/main/resources/enchants/confusing_arrows.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 45.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 75.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 35.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/confusion.yml b/Core/src/main/resources/enchants/confusion.yml index 6823c10..61a5bbb 100644 --- a/Core/src/main/resources/enchants/confusion.yml +++ b/Core/src/main/resources/enchants/confusion.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/cure.yml b/Core/src/main/resources/enchants/cure.yml index d0e91f5..eaa23f3 100644 --- a/Core/src/main/resources/enchants/cure.yml +++ b/Core/src/main/resources/enchants/cure.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: 5 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 75.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/curse_of_breaking.yml b/Core/src/main/resources/enchants/curse_of_breaking.yml index 1ac4680..771089d 100644 --- a/Core/src/main/resources/enchants/curse_of_breaking.yml +++ b/Core/src/main/resources/enchants/curse_of_breaking.yml @@ -18,7 +18,7 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - durability +- durability # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -34,6 +34,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -42,15 +48,39 @@ Enchanting_Table: Level_By_Exp_Cost: 15.0 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/curse_of_misfortune.yml b/Core/src/main/resources/enchants/curse_of_misfortune.yml index f7954de..d49d769 100644 --- a/Core/src/main/resources/enchants/curse_of_misfortune.yml +++ b/Core/src/main/resources/enchants/curse_of_misfortune.yml @@ -16,8 +16,8 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - fortune - - looting +- fortune +- looting # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -33,6 +33,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -41,15 +47,39 @@ Enchanting_Table: Level_By_Exp_Cost: 15.0 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/cutter.yml b/Core/src/main/resources/enchants/cutter.yml index 0718a83..c9e780c 100644 --- a/Core/src/main/resources/enchants/cutter.yml +++ b/Core/src/main/resources/enchants/cutter.yml @@ -33,6 +33,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -41,15 +47,39 @@ Enchanting_Table: Level_By_Exp_Cost: 6 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 5.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/decapitator.yml b/Core/src/main/resources/enchants/decapitator.yml index aa98887..8b03d35 100644 --- a/Core/src/main/resources/enchants/decapitator.yml +++ b/Core/src/main/resources/enchants/decapitator.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: 7 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 15.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/divine_touch.yml b/Core/src/main/resources/enchants/divine_touch.yml index d62f1e7..d21ac5b 100644 --- a/Core/src/main/resources/enchants/divine_touch.yml +++ b/Core/src/main/resources/enchants/divine_touch.yml @@ -16,7 +16,7 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - smelter +- smelter # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -32,6 +32,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 5.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -40,15 +46,39 @@ Enchanting_Table: Level_By_Exp_Cost: 6.0 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 5.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 5.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 8.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/double_strike.yml b/Core/src/main/resources/enchants/double_strike.yml index 1417dd8..82ae202 100644 --- a/Core/src/main/resources/enchants/double_strike.yml +++ b/Core/src/main/resources/enchants/double_strike.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: 7 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 15.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/dragonfire_arrows.yml b/Core/src/main/resources/enchants/dragonfire_arrows.yml index 15f51a7..19aa968 100644 --- a/Core/src/main/resources/enchants/dragonfire_arrows.yml +++ b/Core/src/main/resources/enchants/dragonfire_arrows.yml @@ -19,11 +19,11 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - confusing_arrows - - poisoned_arrows - - explosive_arrows - - withered_arrows - - electrified_arrows +- confusing_arrows +- poisoned_arrows +- explosive_arrows +- withered_arrows +- electrified_arrows # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -39,6 +39,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -47,15 +53,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 5.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/electrified_arrows.yml b/Core/src/main/resources/enchants/electrified_arrows.yml index 1c62204..60f440b 100644 --- a/Core/src/main/resources/enchants/electrified_arrows.yml +++ b/Core/src/main/resources/enchants/electrified_arrows.yml @@ -16,11 +16,11 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - confusing_arrows - - poisoned_arrows - - explosive_arrows - - withered_arrows - - dragonfire_arrows +- confusing_arrows +- poisoned_arrows +- explosive_arrows +- withered_arrows +- dragonfire_arrows # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -36,6 +36,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 75.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -44,15 +50,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 45.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/elemental_protection.yml b/Core/src/main/resources/enchants/elemental_protection.yml new file mode 100644 index 0000000..df6078c --- /dev/null +++ b/Core/src/main/resources/enchants/elemental_protection.yml @@ -0,0 +1,108 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance value. +# - %enchantment_protection_amount%: Enchantment Protection Amount value. +# - %enchantment_protection_capacity%: Enchantment Protection Capacity value. + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. +Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. +Name: Elemental Protection +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. +Tier: common +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders +Description: +- '%enchantment_trigger_chance%% chance to reduce Poison, Magic, Wither, Lightning, + Freeze damage by %enchantment_protection_amount%.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] +# Enchantment level settings. +Level: + # Minimal (start) enchantment level. Can not be smaller then 1. + Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. + Max: 5 +# Enchantment settings for Anvil. +Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Merge_Cost: '%enchantment_level%' +Fishing: + # A chance that this enchantment will be populated on items received from fishing. + Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 +# Enchantment settings for Enchanting Table. +Enchanting_Table: + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 6 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. + Chance: 35.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 +Villagers: + # A chance that this enchantment will be populated on items in Villager trades. + Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 +Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. + Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 +Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. + Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 + +# Individual enchantment settings. +Settings: + # A chance that this enchantment will be triggered. + # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: '100.0' + # A cost a player will have to pay to have this enchantment triggered. + Cost: + # Enables/Disables cost feature. + Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. + Item: + Material: AIR + Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. + Protection: + # How much incoming damage should be reduced by this enchantment? + # [SCALABLE] + Amount: '%enchantment_level% * 0.1' + # When 'true', 'Protection.Amount' option will be a percent value on which damage will be multiplied. + # When 'false', 'Protection.Amount' option will be a plain number on which damage will be reduced. + As_Modifier: false + # Maximal possible value for the Protection Amount option that sums up from all entity armor items. + Capacity: 1.0 diff --git a/Core/src/main/resources/enchants/ender_bow.yml b/Core/src/main/resources/enchants/ender_bow.yml index ade8d32..7b77210 100644 --- a/Core/src/main/resources/enchants/ender_bow.yml +++ b/Core/src/main/resources/enchants/ender_bow.yml @@ -16,17 +16,17 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - bomber - - ghast - - explosive_arrows - - withered_arrows - - poisoned_arrows - - dragonfire_arrows - - electrified_arrows - - confusing_arrows - - flame - - power - - punch +- bomber +- ghast +- explosive_arrows +- withered_arrows +- poisoned_arrows +- dragonfire_arrows +- electrified_arrows +- confusing_arrows +- flame +- power +- punch # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -42,6 +42,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 5.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -50,15 +56,39 @@ Enchanting_Table: Level_By_Exp_Cost: '30' # A chance that this enchantment will be appeared in Enchanting Table. Chance: 5.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 3.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/exhaust.yml b/Core/src/main/resources/enchants/exhaust.yml index a90119e..4d46493 100644 --- a/Core/src/main/resources/enchants/exhaust.yml +++ b/Core/src/main/resources/enchants/exhaust.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/exp_hunter.yml b/Core/src/main/resources/enchants/exp_hunter.yml index 69512cb..25dc7a4 100644 --- a/Core/src/main/resources/enchants/exp_hunter.yml +++ b/Core/src/main/resources/enchants/exp_hunter.yml @@ -33,6 +33,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 45.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -41,15 +47,39 @@ Enchanting_Table: Level_By_Exp_Cost: 6 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 45.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 45.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 45.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/explosive_arrows.yml b/Core/src/main/resources/enchants/explosive_arrows.yml index 1ddb540..5302dab 100644 --- a/Core/src/main/resources/enchants/explosive_arrows.yml +++ b/Core/src/main/resources/enchants/explosive_arrows.yml @@ -18,11 +18,11 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - confusing_arrows - - poisoned_arrows - - dragonfire_arrows - - withered_arrows - - electrified_arrows +- confusing_arrows +- poisoned_arrows +- dragonfire_arrows +- withered_arrows +- electrified_arrows # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -38,6 +38,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -46,15 +52,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/fire_shield.yml b/Core/src/main/resources/enchants/fire_shield.yml new file mode 100644 index 0000000..f3e43bf --- /dev/null +++ b/Core/src/main/resources/enchants/fire_shield.yml @@ -0,0 +1,101 @@ +# Additional placeholders: +# - %enchantment_trigger_chance%: Enchantment Trigger Chance +# - %enchantment_fire_duration%: Enchantment Fire Duration + +# Defines if this enchantment is a treasure enchantment. +# Treasure enchantments can only be received via looting, trading, or fishing. +Is_Treasure: false +# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. +Name: Fire Shield +# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. +Tier: rare +# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. +# You can use multiple lines here. +# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders +Description: +- '%enchantment_trigger_chance%% chance to ignite the attacker for %enchantment_fire_duration%s.' +# List of the conflicting enchantments. +# Conflicted enchantments can not be applied together on the same item. +Conflicts: [] +# Enchantment level settings. +Level: + # Minimal (start) enchantment level. Can not be smaller then 1. + Min: 1 + # Maximal (final) enchantment level. + # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. + Max: 3 +# Enchantment settings for Anvil. +Anvil: + # Defines the exp cost to merge this enchantment on other items on anvil. + # [SCALABLE] Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Merge_Cost: '%enchantment_level%' +Fishing: + # A chance that this enchantment will be populated on items received from fishing. + Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 +# Enchantment settings for Enchanting Table. +Enchanting_Table: + # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. + # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. + # [SCALABLE] Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Level_By_Exp_Cost: 9 * %enchantment_level% + # A chance that this enchantment will be appeared in Enchanting Table. + Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 +Villagers: + # A chance that this enchantment will be populated on items in Villager trades. + Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 +Loot_Generation: + # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. + Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 +Mob_Spawning: + # A chance that this enchantment will be populated on items equipped on mob on spawning. + Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 + +# Individual enchantment settings. +Settings: + # A chance that this enchantment will be triggered. + # [SCALABLE] Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Trigger_Chance: '%enchantment_level% * 10.0' + # A cost a player will have to pay to have this enchantment triggered. + Cost: + # Enables/Disables cost feature. + Enabled: false + # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. + # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. + Item: + Material: AIR + Amount: 1 + # Enchantment settings for the Potion Effect applied to a wearer or victim. + Fire: + # Fire effect duration (in seconds). + # [SCALABLE] Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + Duration: 2.5 + %enchantment_level% diff --git a/Core/src/main/resources/enchants/flame_walker.yml b/Core/src/main/resources/enchants/flame_walker.yml index 7021b43..ce0564c 100644 --- a/Core/src/main/resources/enchants/flame_walker.yml +++ b/Core/src/main/resources/enchants/flame_walker.yml @@ -16,7 +16,7 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - frost_walker +- frost_walker # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -32,6 +32,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -40,15 +46,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/ghast.yml b/Core/src/main/resources/enchants/ghast.yml index 102d375..61fca9b 100644 --- a/Core/src/main/resources/enchants/ghast.yml +++ b/Core/src/main/resources/enchants/ghast.yml @@ -16,16 +16,16 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - ender_bow - - bomber - - explosive_arrows - - withered_arrows - - poisoned_arrows - - dragonfire_arrows - - electrified_arrows - - confusing_arrows - - flame - - punch +- ender_bow +- bomber +- explosive_arrows +- withered_arrows +- poisoned_arrows +- dragonfire_arrows +- electrified_arrows +- confusing_arrows +- flame +- punch # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -41,6 +41,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -49,15 +55,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/hardened.yml b/Core/src/main/resources/enchants/hardened.yml index 0653997..2243310 100644 --- a/Core/src/main/resources/enchants/hardened.yml +++ b/Core/src/main/resources/enchants/hardened.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/haste.yml b/Core/src/main/resources/enchants/haste.yml index dc74e76..06c4243 100644 --- a/Core/src/main/resources/enchants/haste.yml +++ b/Core/src/main/resources/enchants/haste.yml @@ -34,6 +34,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -42,15 +48,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/hover.yml b/Core/src/main/resources/enchants/hover.yml index 2c3591e..67373bf 100644 --- a/Core/src/main/resources/enchants/hover.yml +++ b/Core/src/main/resources/enchants/hover.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/ice_aspect.yml b/Core/src/main/resources/enchants/ice_aspect.yml index 62bc8dd..33e6797 100644 --- a/Core/src/main/resources/enchants/ice_aspect.yml +++ b/Core/src/main/resources/enchants/ice_aspect.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/infernus.yml b/Core/src/main/resources/enchants/infernus.yml index 924ea9d..577c395 100644 --- a/Core/src/main/resources/enchants/infernus.yml +++ b/Core/src/main/resources/enchants/infernus.yml @@ -33,6 +33,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 45.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -41,15 +47,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 35.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 45.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 45.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/lucky_miner.yml b/Core/src/main/resources/enchants/lucky_miner.yml index 594a818..b925cba 100644 --- a/Core/src/main/resources/enchants/lucky_miner.yml +++ b/Core/src/main/resources/enchants/lucky_miner.yml @@ -33,6 +33,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -41,15 +47,39 @@ Enchanting_Table: Level_By_Exp_Cost: 6 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/night_vision.yml b/Core/src/main/resources/enchants/night_vision.yml index 57f9481..2e6aaf8 100644 --- a/Core/src/main/resources/enchants/night_vision.yml +++ b/Core/src/main/resources/enchants/night_vision.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: '15' # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/nimble.yml b/Core/src/main/resources/enchants/nimble.yml index d32a88e..61a7426 100644 --- a/Core/src/main/resources/enchants/nimble.yml +++ b/Core/src/main/resources/enchants/nimble.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: 15 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/paralyze.yml b/Core/src/main/resources/enchants/paralyze.yml index 528e323..3e57935 100644 --- a/Core/src/main/resources/enchants/paralyze.yml +++ b/Core/src/main/resources/enchants/paralyze.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/poisoned_arrows.yml b/Core/src/main/resources/enchants/poisoned_arrows.yml index 3cf2c17..bd8174c 100644 --- a/Core/src/main/resources/enchants/poisoned_arrows.yml +++ b/Core/src/main/resources/enchants/poisoned_arrows.yml @@ -20,11 +20,11 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - confusing_arrows - - dragonfire_arrows - - explosive_arrows - - withered_arrows - - electrified_arrows +- confusing_arrows +- dragonfire_arrows +- explosive_arrows +- withered_arrows +- electrified_arrows # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -40,6 +40,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -48,15 +54,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/rage.yml b/Core/src/main/resources/enchants/rage.yml index cf24a06..a458954 100644 --- a/Core/src/main/resources/enchants/rage.yml +++ b/Core/src/main/resources/enchants/rage.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 15.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/regrowth.yml b/Core/src/main/resources/enchants/regrowth.yml index 2ffba98..59ec656 100644 --- a/Core/src/main/resources/enchants/regrowth.yml +++ b/Core/src/main/resources/enchants/regrowth.yml @@ -34,6 +34,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 15.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -42,15 +48,39 @@ Enchanting_Table: Level_By_Exp_Cost: 6 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 15.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 15.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/replanter.yml b/Core/src/main/resources/enchants/replanter.yml index b11a8c4..3dbce43 100644 --- a/Core/src/main/resources/enchants/replanter.yml +++ b/Core/src/main/resources/enchants/replanter.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: '15' # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/rocket.yml b/Core/src/main/resources/enchants/rocket.yml index 7914d58..d198c7e 100644 --- a/Core/src/main/resources/enchants/rocket.yml +++ b/Core/src/main/resources/enchants/rocket.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/saturation.yml b/Core/src/main/resources/enchants/saturation.yml index b5e00f0..47ba5f7 100644 --- a/Core/src/main/resources/enchants/saturation.yml +++ b/Core/src/main/resources/enchants/saturation.yml @@ -34,6 +34,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -42,15 +48,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/scavenger.yml b/Core/src/main/resources/enchants/scavenger.yml index 17bd0df..67420fa 100644 --- a/Core/src/main/resources/enchants/scavenger.yml +++ b/Core/src/main/resources/enchants/scavenger.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: 7 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/self_destruction.yml b/Core/src/main/resources/enchants/self_destruction.yml index de0a31b..693a5d5 100644 --- a/Core/src/main/resources/enchants/self_destruction.yml +++ b/Core/src/main/resources/enchants/self_destruction.yml @@ -33,6 +33,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -41,15 +47,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 15.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/silk_chest.yml b/Core/src/main/resources/enchants/silk_chest.yml index 3f52c43..ed9737d 100644 --- a/Core/src/main/resources/enchants/silk_chest.yml +++ b/Core/src/main/resources/enchants/silk_chest.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: '30' # A chance that this enchantment will be appeared in Enchanting Table. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/smelter.yml b/Core/src/main/resources/enchants/smelter.yml index a04021e..8a0c59a 100644 --- a/Core/src/main/resources/enchants/smelter.yml +++ b/Core/src/main/resources/enchants/smelter.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: 5 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/sonic.yml b/Core/src/main/resources/enchants/sonic.yml index 23f7e5a..72d0516 100644 --- a/Core/src/main/resources/enchants/sonic.yml +++ b/Core/src/main/resources/enchants/sonic.yml @@ -34,6 +34,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -42,15 +48,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/surprise.yml b/Core/src/main/resources/enchants/surprise.yml index bbb8e52..b4a7975 100644 --- a/Core/src/main/resources/enchants/surprise.yml +++ b/Core/src/main/resources/enchants/surprise.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/telekinesis.yml b/Core/src/main/resources/enchants/telekinesis.yml index 46f001f..c4e344a 100644 --- a/Core/src/main/resources/enchants/telekinesis.yml +++ b/Core/src/main/resources/enchants/telekinesis.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/temper.yml b/Core/src/main/resources/enchants/temper.yml index 2627c6c..99dad3d 100644 --- a/Core/src/main/resources/enchants/temper.yml +++ b/Core/src/main/resources/enchants/temper.yml @@ -36,6 +36,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -44,15 +50,39 @@ Enchanting_Table: Level_By_Exp_Cost: 6 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 15.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/thrifty.yml b/Core/src/main/resources/enchants/thrifty.yml index 92ee8c4..c3087e9 100644 --- a/Core/src/main/resources/enchants/thrifty.yml +++ b/Core/src/main/resources/enchants/thrifty.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 15.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 15.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 10.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/thunder.yml b/Core/src/main/resources/enchants/thunder.yml index e90a0d7..10bdad0 100644 --- a/Core/src/main/resources/enchants/thunder.yml +++ b/Core/src/main/resources/enchants/thunder.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/treasures.yml b/Core/src/main/resources/enchants/treasures.yml index b1dca78..76cf0a2 100644 --- a/Core/src/main/resources/enchants/treasures.yml +++ b/Core/src/main/resources/enchants/treasures.yml @@ -31,6 +31,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -39,15 +45,39 @@ Enchanting_Table: Level_By_Exp_Cost: 6 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 75.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 75.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/tunnel.yml b/Core/src/main/resources/enchants/tunnel.yml index 227b82a..2ca0e53 100644 --- a/Core/src/main/resources/enchants/tunnel.yml +++ b/Core/src/main/resources/enchants/tunnel.yml @@ -16,8 +16,8 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - veinminer - - blast_mining +- veinminer +- blast_mining # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -33,6 +33,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -41,15 +47,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/vampire.yml b/Core/src/main/resources/enchants/vampire.yml index 2cde83f..a8e2ead 100644 --- a/Core/src/main/resources/enchants/vampire.yml +++ b/Core/src/main/resources/enchants/vampire.yml @@ -33,6 +33,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -41,15 +47,39 @@ Enchanting_Table: Level_By_Exp_Cost: 7 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/veinminer.yml b/Core/src/main/resources/enchants/veinminer.yml index 1e84d11..409f17d 100644 --- a/Core/src/main/resources/enchants/veinminer.yml +++ b/Core/src/main/resources/enchants/veinminer.yml @@ -17,8 +17,8 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - blast_mining - - tunnel +- blast_mining +- tunnel # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -34,6 +34,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -42,15 +48,39 @@ Enchanting_Table: Level_By_Exp_Cost: 10 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 40.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/venom.yml b/Core/src/main/resources/enchants/venom.yml index 19913d3..5346855 100644 --- a/Core/src/main/resources/enchants/venom.yml +++ b/Core/src/main/resources/enchants/venom.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 50.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/village_defender.yml b/Core/src/main/resources/enchants/village_defender.yml index 76d1127..e9b242a 100644 --- a/Core/src/main/resources/enchants/village_defender.yml +++ b/Core/src/main/resources/enchants/village_defender.yml @@ -18,10 +18,10 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - bane_of_netherspawn - - sharpness - - smite - - bane_of_arthropods +- bane_of_netherspawn +- sharpness +- smite +- bane_of_arthropods # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -37,6 +37,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 60.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -45,15 +51,39 @@ Enchanting_Table: Level_By_Exp_Cost: 6 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 80.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 80.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 70.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 0.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/wither.yml b/Core/src/main/resources/enchants/wither.yml index 9200376..3576edf 100644 --- a/Core/src/main/resources/enchants/wither.yml +++ b/Core/src/main/resources/enchants/wither.yml @@ -35,6 +35,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -43,15 +49,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 20.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 30.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 15.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/Core/src/main/resources/enchants/withered_arrows.yml b/Core/src/main/resources/enchants/withered_arrows.yml index 05e5c5a..157959d 100644 --- a/Core/src/main/resources/enchants/withered_arrows.yml +++ b/Core/src/main/resources/enchants/withered_arrows.yml @@ -20,11 +20,11 @@ Description: # List of the conflicting enchantments. # Conflicted enchantments can not be applied together on the same item. Conflicts: - - confusing_arrows - - poisoned_arrows - - explosive_arrows - - dragonfire_arrows - - electrified_arrows +- confusing_arrows +- poisoned_arrows +- explosive_arrows +- dragonfire_arrows +- electrified_arrows # Enchantment level settings. Level: # Minimal (start) enchantment level. Can not be smaller then 1. @@ -40,6 +40,12 @@ Anvil: Fishing: # A chance that this enchantment will be populated on items received from fishing. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Fishing + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Enchantment settings for Enchanting Table. Enchanting_Table: # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. @@ -48,15 +54,39 @@ Enchanting_Table: Level_By_Exp_Cost: 9 * %enchantment_level% # A chance that this enchantment will be appeared in Enchanting Table. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Enchanting Table + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Villagers: # A chance that this enchantment will be populated on items in Villager trades. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Villagers + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Loot_Generation: # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. Chance: 25.0 + # Here you can set min. and max. level for enchantment generated via Loot Generation + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 Mob_Spawning: # A chance that this enchantment will be populated on items equipped on mob on spawning. Chance: 15.0 + # Here you can set min. and max. level for enchantment generated via Mob Spawning + # These levels can not be greater or smaller than the default enchantment min. and max levels. + # Set min/max level to -1 to use the default enchantment min/max level value. + Level: + Min: -1 + Max: -1 # Individual enchantment settings. Settings: # A chance that this enchantment will be triggered. diff --git a/NMS/pom.xml b/NMS/pom.xml index 6706f67..e7e4f26 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.4 + 3.2.5 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 169720f..654d97e 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.4 + 3.2.5 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.4 + 3.2.5 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 3f74daa..a4ec5a4 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.4 + 3.2.5 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.4 + 3.2.5 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index 35fb5e5..1f40499 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.4 + 3.2.5 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.4 + 3.2.5 @@ -44,9 +44,9 @@ remap-obf - org.spigotmc:minecraft-server:1.19-R0.1-SNAPSHOT:txt:maps-mojang + org.spigotmc:minecraft-server:1.19.1-R0.1-SNAPSHOT:txt:maps-mojang true - org.spigotmc:spigot:1.19-R0.1-SNAPSHOT:jar:remapped-mojang + org.spigotmc:spigot:1.19.1-R0.1-SNAPSHOT:jar:remapped-mojang true remapped-obf @@ -59,8 +59,8 @@ remap-spigot ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.19-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.19-R0.1-SNAPSHOT:jar:remapped-obf + org.spigotmc:minecraft-server:1.19.1-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.19.1-R0.1-SNAPSHOT:jar:remapped-obf diff --git a/pom.xml b/pom.xml index 431867b..dab4a9f 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.2.4 + 3.2.5 Core NMS From 559e70da9af44bb9a8367ba79c9f9d03689c0ebc Mon Sep 17 00:00:00 2001 From: nulli0n Date: Fri, 5 Aug 2022 19:50:30 +0500 Subject: [PATCH 13/69] 3.2.5 Fix --- .../manager/enchants/armor/EnchantElementalProtection.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java index fdbe99b..b58911c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java @@ -28,7 +28,7 @@ public class EnchantElementalProtection extends IEnchantChanceTemplate { private static final EntityDamageEvent.DamageCause[] DAMAGE_CAUSES = new EntityDamageEvent.DamageCause[] { EntityDamageEvent.DamageCause.POISON, EntityDamageEvent.DamageCause.WITHER, EntityDamageEvent.DamageCause.MAGIC, EntityDamageEvent.DamageCause.FREEZE, - EntityDamageEvent.DamageCause.SONIC_BOOM, EntityDamageEvent.DamageCause.LIGHTNING, + /*EntityDamageEvent.DamageCause.SONIC_BOOM, */EntityDamageEvent.DamageCause.LIGHTNING, }; private Scaler protectionAmount; @@ -98,7 +98,7 @@ public class EnchantElementalProtection extends IEnchantChanceTemplate { } if (this.isProtectionAsModifier()) { - e.setDamage(Math.max(0, 1D - e.getDamage() * protectionAmount)); + e.setDamage(Math.max(0, e.getDamage() * (1D - protectionAmount))); } else { e.setDamage(Math.max(0, e.getDamage() - protectionAmount)); From 2b864e97a2a00db0f5702d9952d9b13848a45489 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Tue, 9 Aug 2022 19:36:32 +0500 Subject: [PATCH 14/69] 3.2.6 --- Core/pom.xml | 20 +++++++++--- .../enchants/bow/EnchantDragonfireArrows.java | 28 +++++++++++++--- .../bow/EnchantElectrifiedArrows.java | 32 ++++++++++--------- .../listeners/EnchantHandlerListener.java | 7 ++++ 4 files changed, 62 insertions(+), 25 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 9bfab09..3310d9c 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.5 + 3.2.6 4.0.0 @@ -21,6 +21,10 @@ md_5-releases https://repo.md-5.net/content/repositories/releases/ + + sk89q-repo + https://maven.enginehub.org/repo/ + @@ -32,22 +36,22 @@ su.nightexpress.excellentenchants NMS - 3.2.5 + 3.2.6 su.nightexpress.excellentenchants V1_17_R1 - 3.2.5 + 3.2.6 su.nightexpress.excellentenchants V1_18_R2 - 3.2.5 + 3.2.6 su.nightexpress.excellentenchants V1_19_R1 - 3.2.5 + 3.2.6 fr.neatmonster @@ -55,6 +59,12 @@ 3.16.1-SNAPSHOT provided + + com.sk89q.worldguard + worldguard-bukkit + 7.0.6 + provided + diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java index cd08b84..22c8608 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java @@ -1,14 +1,19 @@ package su.nightexpress.excellentenchants.manager.enchants.bow; +import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.World; import org.bukkit.entity.AreaEffectCloud; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; 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.config.JYML; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -56,20 +61,33 @@ public class EnchantDragonfireArrows extends IEnchantBowTemplate { return this.fireRadius.getValue(level); } + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!super.use(e, damager, victim, weapon, level)) return false; + + this.createCloud(damager, victim.getLocation(), level); + return true; + } + @Override public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { if (!super.use(e, projectile, bow, level)) return false; - World world = projectile.getWorld(); - AreaEffectCloud cloud = world.spawn(projectile.getLocation(), AreaEffectCloud.class); + this.createCloud(projectile.getShooter(), projectile.getLocation() , level); + return true; + } + + private void createCloud(@Nullable ProjectileSource shooter, @NotNull Location location, int level) { + World world = location.getWorld(); + if (world == null) return; + + AreaEffectCloud cloud = world.spawn(location, AreaEffectCloud.class); cloud.clearCustomEffects(); - cloud.setSource(projectile.getShooter()); + cloud.setSource(shooter); cloud.setParticle(Particle.DRAGON_BREATH); cloud.setRadius((float) this.getFireRadius(level)); cloud.setDuration(this.getFireDuration(level)); cloud.setRadiusPerTick((7.0F - cloud.getRadius()) / (float) cloud.getDuration()); cloud.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 1, 1), true); - - return true; } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java index a0e9954..b97f186 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java @@ -2,9 +2,9 @@ package su.nightexpress.excellentenchants.manager.enchants.bow; import org.bukkit.Particle; import org.bukkit.block.Block; -import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -23,25 +23,27 @@ public class EnchantElectrifiedArrows extends IEnchantBowTemplate { super(plugin, cfg, EnchantPriority.MEDIUM); } + @Override + public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!super.use(e, damager, victim, weapon, level)) return false; + + plugin.getServer().getScheduler().runTask(plugin, () -> { + victim.setNoDamageTicks(0); + victim.getWorld().strikeLightning(victim.getLocation()); + }); + + return true; + } + @Override public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { if (!super.use(e, projectile, bow, level)) return false; + if (e.getHitEntity() != null || e.getHitBlock() == null) return false; - Entity entity = e.getHitEntity(); Block block = e.getHitBlock(); - - if (entity instanceof LivingEntity victim) { - plugin.getServer().getScheduler().runTask(plugin, () -> { - victim.setNoDamageTicks(0); - victim.getWorld().strikeLightning(victim.getLocation()); - }); - } - else if (block != null) { - block.getWorld().strikeLightning(block.getLocation()); - 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); - } - else return false; + block.getWorld().strikeLightning(block.getLocation()); + 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); return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java index c9f725c..de8bcaf 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java @@ -46,6 +46,10 @@ public class EnchantHandlerListener extends AbstractListener return projectile.hasMetadata(META_PROJECTILE_WEAPON) ? (ItemStack) projectile.getMetadata(META_PROJECTILE_WEAPON).get(0).value() : null; } + private void removeSourceWeapon(@NotNull Projectile projectile) { + projectile.removeMetadata(META_PROJECTILE_WEAPON, plugin); + } + // --------------------------------------------------------------- // Combat Attacking Enchants // --------------------------------------------------------------- @@ -150,6 +154,9 @@ public class EnchantHandlerListener extends AbstractListener EnchantManager.getItemCustomEnchants(bow, BowEnchant.class).forEach((bowEnchant, level) -> { bowEnchant.use(e, projectile, bow, level); }); + + // Prevent to apply enchants multiple times on hits. + this.removeSourceWeapon(projectile); } // --------------------------------------------------------------- From 9118b7cc3c1a84abb0fb7889bb50304e6f8b085a Mon Sep 17 00:00:00 2001 From: nulli0n Date: Tue, 9 Aug 2022 19:36:53 +0500 Subject: [PATCH 15/69] 3.2.6 --- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 ++-- V1_18_R2/pom.xml | 4 ++-- V1_19_R1/pom.xml | 4 ++-- pom.xml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/NMS/pom.xml b/NMS/pom.xml index e7e4f26..30e30f9 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.5 + 3.2.6 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 654d97e..2621e5f 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.5 + 3.2.6 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.5 + 3.2.6 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index a4ec5a4..8a5f149 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.5 + 3.2.6 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.5 + 3.2.6 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index 1f40499..c673e00 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.5 + 3.2.6 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.5 + 3.2.6 diff --git a/pom.xml b/pom.xml index dab4a9f..9778dbf 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.2.5 + 3.2.6 Core NMS From 770b2d0ce178721198a2e5367784833ea3c61768 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Tue, 9 Aug 2022 20:24:03 +0500 Subject: [PATCH 16/69] Support for 1.19.2 --- Core/pom.xml | 2 +- V1_19_R1/pom.xml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 3310d9c..9971e97 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -31,7 +31,7 @@ org.spigotmc spigot-api - 1.19.1-R0.1-SNAPSHOT + 1.19.2-R0.1-SNAPSHOT su.nightexpress.excellentenchants diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index c673e00..a65ba3c 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -20,7 +20,7 @@ org.spigotmc spigot - 1.19.1-R0.1-SNAPSHOT + 1.19.2-R0.1-SNAPSHOT remapped-mojang @@ -44,9 +44,9 @@ remap-obf - org.spigotmc:minecraft-server:1.19.1-R0.1-SNAPSHOT:txt:maps-mojang + org.spigotmc:minecraft-server:1.19.2-R0.1-SNAPSHOT:txt:maps-mojang true - org.spigotmc:spigot:1.19.1-R0.1-SNAPSHOT:jar:remapped-mojang + org.spigotmc:spigot:1.19.2-R0.1-SNAPSHOT:jar:remapped-mojang true remapped-obf @@ -59,8 +59,8 @@ remap-spigot ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.19.1-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.19.1-R0.1-SNAPSHOT:jar:remapped-obf + org.spigotmc:minecraft-server:1.19.2-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.19.2-R0.1-SNAPSHOT:jar:remapped-obf From e2835aee73183c277dc171e9fe0d88b508791989 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Tue, 4 Oct 2022 13:55:53 +0600 Subject: [PATCH 17/69] v3.2.7 --- .gitignore | 2 ++ Core/pom.xml | 10 +++++----- .../excellentenchants/ExcellentEnchants.java | 7 +++++++ .../manager/enchants/tool/EnchantSilkChest.java | 2 +- .../manager/enchants/tool/EnchantSmelter.java | 2 ++ .../manager/listeners/EnchantHandlerListener.java | 2 +- Core/src/main/resources/enchants/thrifty.yml | 2 +- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 ++-- V1_18_R2/pom.xml | 4 ++-- V1_19_R1/pom.xml | 4 ++-- pom.xml | 4 ++-- 12 files changed, 28 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 4459b58..c48c708 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ /target/ /V1_18_R2/pom.xml.versionsBackup /V1_18_R2/target/ +/V1_19_R1/target/ +/V1_19_R1/pom.xml.versionsBackup diff --git a/Core/pom.xml b/Core/pom.xml index 9971e97..ccffb67 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.6 + 3.2.7 4.0.0 @@ -36,22 +36,22 @@ su.nightexpress.excellentenchants NMS - 3.2.6 + 3.2.7 su.nightexpress.excellentenchants V1_17_R1 - 3.2.6 + 3.2.7 su.nightexpress.excellentenchants V1_18_R2 - 3.2.6 + 3.2.7 su.nightexpress.excellentenchants V1_19_R1 - 3.2.6 + 3.2.7 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 532292b..526ac4d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -5,6 +5,7 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.NexPlugin; import su.nexmedia.engine.Version; import su.nexmedia.engine.api.command.GeneralCommand; +import su.nexmedia.engine.command.list.ReloadSubCommand; import su.nexmedia.engine.utils.Reflex; import su.nightexpress.excellentenchants.command.BookCommand; import su.nightexpress.excellentenchants.command.EnchantCommand; @@ -85,6 +86,7 @@ public class ExcellentEnchants extends NexPlugin { mainCommand.addChildren(new EnchantCommand(this)); mainCommand.addChildren(new ListCommand(this)); mainCommand.addChildren(new TierbookCommand(this)); + mainCommand.addChildren(new ReloadSubCommand<>(this, Perms.PREFIX + "admin")); } @Override @@ -92,6 +94,11 @@ public class ExcellentEnchants extends NexPlugin { } + @Override + public void registerPermissions() { + // TODO + } + @NotNull public EnchantManager getEnchantManager() { return this.enchantManager; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java index fd54079..3b7c9a6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java @@ -125,7 +125,7 @@ public class EnchantSilkChest extends IEnchantChanceTemplate implements CustomDr if (!this.takeCostItem(player)) return; // Добавляем в сундук обратно предметы из дроп листа, кроме самого сундука. - parent.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType()); + parent.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType() && drop.getItemStack().getAmount() == 1); chest.getBlockInventory().addItem(parent.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0])); // Добавляем кастомный сундук в кастомный дроп лист. diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java index 6b5981b..a6aa542 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java @@ -5,6 +5,7 @@ import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.block.Block; +import org.bukkit.block.Container; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockDropItemEvent; @@ -90,6 +91,7 @@ public class EnchantSmelter extends IEnchantChanceTemplate implements BlockDropE @Override public boolean use(@NotNull BlockDropItemEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (e.getBlockState() instanceof Container) return false; if (!this.isEnchantmentAvailable(player)) return false; if (!this.checkTriggerChance(level)) return false; if (e.getItems().stream().noneMatch(drop -> this.isSmeltable(drop.getItemStack().getType()))) return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java index de8bcaf..b52cf56 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java @@ -156,7 +156,7 @@ public class EnchantHandlerListener extends AbstractListener }); // Prevent to apply enchants multiple times on hits. - this.removeSourceWeapon(projectile); + this.plugin.getScheduler().runTask(this.plugin, c -> this.removeSourceWeapon(projectile)); } // --------------------------------------------------------------- diff --git a/Core/src/main/resources/enchants/thrifty.yml b/Core/src/main/resources/enchants/thrifty.yml index c3087e9..e9c9070 100644 --- a/Core/src/main/resources/enchants/thrifty.yml +++ b/Core/src/main/resources/enchants/thrifty.yml @@ -101,5 +101,5 @@ Settings: # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/CreatureSpawnEvent.SpawnReason.html Ignored_Spawn_Reasons: - SPAWNER - - SPAWN_EGG + - SPAWNER_EGG - DISPENSE_EGG diff --git a/NMS/pom.xml b/NMS/pom.xml index 30e30f9..7d1f2eb 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.6 + 3.2.7 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 2621e5f..9df79f3 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.6 + 3.2.7 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.6 + 3.2.7 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 8a5f149..74cd5c7 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.6 + 3.2.7 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.6 + 3.2.7 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index a65ba3c..fd308ef 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.6 + 3.2.7 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.6 + 3.2.7 diff --git a/pom.xml b/pom.xml index 9778dbf..45364b1 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.2.6 + 3.2.7 Core NMS @@ -25,7 +25,7 @@ su.nexmedia NexEngine - 2.2.3 + 2.2.6 From a4cc0bfd88628339eba8207871e527d88ac186c0 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Wed, 30 Nov 2022 19:18:05 +0600 Subject: [PATCH 18/69] v3.2.8 --- Core/pom.xml | 10 +- .../excellentenchants/ExcellentEnchants.java | 24 +-- .../ExcellentEnchantsAPI.java | 6 + .../api/enchantment/ExcellentEnchant.java | 18 +- .../enchantment/IEnchantPotionTemplate.java | 11 +- .../excellentenchants/config/Config.java | 5 +- .../manager/EnchantManager.java | 193 ++++++++++++++---- .../armor/EnchantElementalProtection.java | 3 +- .../enchants/armor/EnchantFlameWalker.java | 6 +- .../enchants/armor/EnchantRegrowth.java | 11 +- .../enchants/armor/EnchantSaturation.java | 14 +- .../manager/enchants/bow/EnchantGhast.java | 3 +- .../enchants/tool/EnchantCurseOfBreaking.java | 3 +- .../enchants/tool/EnchantSilkChest.java | 24 ++- .../enchants/tool/EnchantTelekinesis.java | 14 +- .../enchants/weapon/EnchantInfernus.java | 5 +- .../listeners/EnchantGenericListener.java | 78 +++---- .../manager/object/EnchantPopulator.java | 77 +++++++ .../manager/object/EnchantTier.java | 21 +- .../tasks/AbstractEnchantPassiveTask.java | 31 +-- .../tasks/EnchantEffectPassiveTask.java | 20 +- Core/src/main/resources/config.yml | 3 - NMS/pom.xml | 2 +- .../excellentenchants/nms/EnchantNMS.java | 27 +++ V1_17_R1/pom.xml | 4 +- .../nms/v1_17_R1/CustomEffectInstance.java | 39 ++++ .../nms/{ => v1_17_R1}/V1_17_R1.java | 26 ++- V1_18_R2/pom.xml | 4 +- .../nms/v1_18_R2/CustomEffectInstance.java | 39 ++++ .../nms/{ => v1_18_R2}/V1_18_R2.java | 26 ++- V1_19_R1/pom.xml | 4 +- .../nms/v1_19_R1/CustomEffectInstance.java | 39 ++++ .../nms/{ => v1_19_R1}/V1_19_R1.java | 26 ++- pom.xml | 4 +- 34 files changed, 607 insertions(+), 213 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchantsAPI.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantPopulator.java create mode 100644 V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java rename V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/{ => v1_17_R1}/V1_17_R1.java (66%) create mode 100644 V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java rename V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/{ => v1_18_R2}/V1_18_R2.java (66%) create mode 100644 V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java rename V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/{ => v1_19_R1}/V1_19_R1.java (66%) diff --git a/Core/pom.xml b/Core/pom.xml index ccffb67..20aaa2e 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.7 + 3.2.8 4.0.0 @@ -36,22 +36,22 @@ su.nightexpress.excellentenchants NMS - 3.2.7 + 3.2.8 su.nightexpress.excellentenchants V1_17_R1 - 3.2.7 + 3.2.8 su.nightexpress.excellentenchants V1_18_R2 - 3.2.7 + 3.2.8 su.nightexpress.excellentenchants V1_19_R1 - 3.2.7 + 3.2.8 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 526ac4d..9ec1a86 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -6,7 +6,6 @@ import su.nexmedia.engine.NexPlugin; import su.nexmedia.engine.Version; import su.nexmedia.engine.api.command.GeneralCommand; import su.nexmedia.engine.command.list.ReloadSubCommand; -import su.nexmedia.engine.utils.Reflex; import su.nightexpress.excellentenchants.command.BookCommand; import su.nightexpress.excellentenchants.command.EnchantCommand; import su.nightexpress.excellentenchants.command.ListCommand; @@ -16,6 +15,9 @@ import su.nightexpress.excellentenchants.config.Lang; import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.type.FitItemType; import su.nightexpress.excellentenchants.nms.EnchantNMS; +import su.nightexpress.excellentenchants.nms.v1_17_R1.V1_17_R1; +import su.nightexpress.excellentenchants.nms.v1_18_R2.V1_18_R2; +import su.nightexpress.excellentenchants.nms.v1_19_R1.V1_19_R1; public class ExcellentEnchants extends NexPlugin { @@ -51,20 +53,12 @@ public class ExcellentEnchants extends NexPlugin { } private boolean setNMS() { - Version current = Version.CURRENT; - if (current == null) return false; - - String pack = EnchantNMS.class.getPackage().getName(); - Class clazz = Reflex.getClass(pack, current.name()); - if (clazz == null) return false; - - try { - this.enchantNMS = (EnchantNMS) clazz.getConstructor().newInstance(); - } - catch (Exception e) { - e.printStackTrace(); - } - return this.enchantNMS != null; + this.enchantNMS = switch (Version.CURRENT) { + case V1_17_R1 -> new V1_17_R1(); + case V1_18_R2 -> new V1_18_R2(); + case V1_19_R1 -> new V1_19_R1(); + }; + return true; } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchantsAPI.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchantsAPI.java new file mode 100644 index 0000000..f690fb8 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchantsAPI.java @@ -0,0 +1,6 @@ +package su.nightexpress.excellentenchants; + +public class ExcellentEnchantsAPI { + + public static final ExcellentEnchants PLUGIN = ExcellentEnchants.getPlugin(ExcellentEnchants.class); +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index 5eaaff3..68f7443 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -316,9 +316,11 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener } public int getLevelByEnchantCost(int expLevel) { - Optional> opt = this.levelByEnchantCost.getValues().entrySet().stream() - .filter(en -> expLevel >= en.getValue().intValue()).max(Comparator.comparingInt(Map.Entry::getKey)); - return opt.isPresent() ? opt.get().getKey() : Rnd.get(this.getStartLevel(), this.getMaxLevel()); + int get = this.levelByEnchantCost.getValues().entrySet().stream() + .filter(en -> expLevel >= en.getValue().intValue()).max(Comparator.comparingInt(Map.Entry::getKey)) + .map(Map.Entry::getKey).orElse(0); + + return get != 0 ? this.fineLevel(get, ObtainType.ENCHANTING) : 0; } public double getObtainChance(@NotNull ObtainType obtainType) { @@ -333,6 +335,16 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener return this.obtainLevelCap.getOrDefault(obtainType, Pair.of(-1, -1)).getSecond(); } + public int fineLevel(int level, @NotNull ObtainType obtainType) { + int levelCapMin = this.getObtainLevelMin(obtainType); + int levelCapMax = this.getObtainLevelMax(obtainType); + + if (levelCapMin > 0 && level < levelCapMin) level = levelCapMin; + if (levelCapMax > 0 && level > levelCapMax) level = levelCapMax; + + return level; + } + public int generateLevel() { return Rnd.get(this.getStartLevel(), this.getMaxLevel()); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java index 256aa42..bf6b103 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java @@ -72,8 +72,17 @@ public abstract class IEnchantPotionTemplate extends IEnchantChanceTemplate { return new PotionEffect(this.potionEffectType, duration, amplifier, false, this.potionParticles); } + public final boolean hasEffect(@NotNull LivingEntity entity) { + return EnchantManager.hasEnchantmentEffect(entity, this); + } + public final boolean addEffect(@NotNull LivingEntity target, int level) { - EnchantManager.addPotionEffect(target, this.getEffect(level), true); + if (this instanceof PassiveEnchant) { + this.plugin.getEnchantNMS().addEnchantmentEffect(target, this, this.getEffect(level)); + } + else { + target.addPotionEffect(this.getEffect(level)); + } return true; } } \ No newline at end of file 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 c48b5ba..6b7d84c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.config; 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.Placeholders; import su.nexmedia.engine.utils.StringUtil; @@ -17,7 +18,7 @@ import java.util.stream.Collectors; public class Config { public static long TASKS_ARROW_TRAIL_TICKS_INTERVAL; - public static long TASKS_PASSIVE_ENCHANTS_TICKS_INTERVAL; + public static final JOption TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL = JOption.create("General.Tasks.Passive_Potion_Effects.Apply_Interval", "Sets how often (in ticks) the plugin will apply permanent potion effects from enchanted items to an entity who wear them.\nThis setting does NOT refreshes currently active effects, but only attempts to add them if absent.", 150); public static Set ENCHANTMENTS_DISABLED; public static Map> ENCHANTMENTS_DISABLED_IN_WORLDS; @@ -35,10 +36,10 @@ public class Config { public static void load(@NotNull ExcellentEnchants plugin) { JYML cfg = plugin.getConfig(); + cfg.initializeOptions(Config.class); String path = "General.Tasks."; TASKS_ARROW_TRAIL_TICKS_INTERVAL = cfg.getLong(path + "Arrow_Trails.Ticks_Interval", 1); - TASKS_PASSIVE_ENCHANTS_TICKS_INTERVAL = cfg.getLong(path + "Passive_Enchants.Ticks_Interval", 100); path = "General.Enchantments."; cfg.addMissing(path + "Disabled_In_Worlds.my_world", Collections.singletonList(Placeholders.MASK_ANY)); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java index e65f2d7..e412912 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java @@ -4,6 +4,7 @@ import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; @@ -11,21 +12,28 @@ import org.bukkit.potion.PotionEffect; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.manager.AbstractManager; +import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.ItemUtil; 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.IEnchantPotionTemplate; +import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.config.ObtainSettings; import su.nightexpress.excellentenchants.manager.listeners.EnchantGenericListener; import su.nightexpress.excellentenchants.manager.listeners.EnchantHandlerListener; import su.nightexpress.excellentenchants.manager.object.EnchantListGUI; +import su.nightexpress.excellentenchants.manager.object.EnchantPopulator; import su.nightexpress.excellentenchants.manager.object.EnchantTier; import su.nightexpress.excellentenchants.manager.tasks.ArrowTrailsTask; import su.nightexpress.excellentenchants.manager.tasks.EnchantEffectPassiveTask; import su.nightexpress.excellentenchants.manager.type.ObtainType; import java.util.*; +import java.util.function.BiFunction; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -76,19 +84,6 @@ public class EnchantManager extends AbstractManager { return enchantListGUI; } - public static void addPotionEffect(@NotNull LivingEntity entity, @NotNull PotionEffect effect, boolean compat) { - if (compat) { - PotionEffect has = entity.getPotionEffect(effect.getType()); - if (has != null && has.getAmplifier() > effect.getAmplifier()) { - return; - } - } - else { - entity.removePotionEffect(effect.getType()); - } - entity.addPotionEffect(effect); - } - public static boolean isEnchantable(@NotNull ItemStack item) { if (item.getType().isAir()) return false; @@ -96,28 +91,73 @@ public class EnchantManager extends AbstractManager { /*|| ItemUtil.isWeapon(item) || ItemUtil.isArmor(item) || ItemUtil.isTool(item) || ItemUtil.isBow(item)*/; } - public static boolean populateEnchantments(@NotNull ItemStack item, @NotNull ObtainType obtainType) { + @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); - if (settings == null) return false; + if (settings == null || !Rnd.chance(settings.getEnchantsCustomGenerationChance())) return enchantsToAdd; - if (Rnd.get(true) > settings.getEnchantsCustomGenerationChance()) return false; - - int enchHas = EnchantManager.getItemEnchantsAmount(item); int enchMax = settings.getEnchantsTotalMax(); int enchRoll = Rnd.get(settings.getEnchantsCustomMin(), settings.getEnchantsCustomMax()); - for (int count = 0; (count < enchRoll && count + enchHas < enchMax); count++) { - EnchantTier tier = EnchantManager.getTierByChance(obtainType); - if (tier == null) continue; + // Класс для исключения неудачных попыток. + EnchantPopulator populator = new EnchantPopulator(obtainType, item); - ExcellentEnchant enchant = tier.getEnchant(obtainType, item); - if (enchant == null) continue; + // Херачим до талого, пока нужное количество не будет добавлено + // или не закончатся чары и/или тиры. + while (!populator.isEmpty() && enchRoll > 0) { + // Достигнут максимум чар (любых) для итема, заканчиваем. + if (enchantsToAdd.size() >= enchMax) break; - int level = enchant.generateLevel(obtainType); - EnchantManager.addEnchant(item, enchant, level, false); + EnchantTier 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--; } - EnchantManager.updateItemLoreEnchants(item); - return true; + return enchantsToAdd; + } + + public static boolean populateEnchantments(@NotNull ItemStack item, @NotNull ObtainType obtainType) { + int enchantsHad = EnchantManager.getItemCustomEnchantsAmount(item); + + EnchantManager.getEnchantsToPopulate(item, obtainType).forEach((enchantment, level) -> { + EnchantManager.addEnchant(item, enchantment, level, false); + }); + + return EnchantManager.getItemCustomEnchantsAmount(item) != enchantsHad; } public static void updateItemLoreEnchants(@NotNull ItemStack item) { @@ -149,35 +189,40 @@ public class EnchantManager extends AbstractManager { } } - public static boolean addEnchant(@NotNull ItemStack item, @NotNull ExcellentEnchant ench, int level, boolean force) { - if (!force && !ench.canEnchantItem(item)) return false; + public static boolean addEnchant(@NotNull ItemStack item, @NotNull Enchantment enchantment, int level, boolean force) { + if (!force && !enchantment.canEnchantItem(item)) return false; - EnchantManager.removeEnchant(item, ench); - ItemUtil.addLore(item, ench.getId(), ench.getNameFormatted(level), 0); + EnchantManager.removeEnchant(item, enchantment); + + if (enchantment instanceof ExcellentEnchant excellentEnchant) { + ItemUtil.addLore(item, excellentEnchant.getId(), excellentEnchant.getNameFormatted(level), 0); + } ItemMeta meta = item.getItemMeta(); if (meta == null) return false; - if (meta instanceof EnchantmentStorageMeta meta2) { - if (!meta2.addStoredEnchant(ench, level, true)) return false; + if (meta instanceof EnchantmentStorageMeta storageMeta) { + if (!storageMeta.addStoredEnchant(enchantment, level, true)) return false; } else { - if (!meta.addEnchant(ench, level, true)) return false; + if (!meta.addEnchant(enchantment, level, true)) return false; } item.setItemMeta(meta); return true; } - public static void removeEnchant(@NotNull ItemStack item, @NotNull ExcellentEnchant en) { - ItemUtil.delLore(item, en.getId()); + public static void removeEnchant(@NotNull ItemStack item, @NotNull Enchantment enchantment) { + if (enchantment instanceof ExcellentEnchant excellentEnchant) { + ItemUtil.delLore(item, excellentEnchant.getId()); + } ItemMeta meta = item.getItemMeta(); - if (meta instanceof EnchantmentStorageMeta meta2) { - meta2.removeStoredEnchant(en); + if (meta instanceof EnchantmentStorageMeta storageMeta) { + storageMeta.removeStoredEnchant(enchantment); } else { - meta.removeEnchant(en); + meta.removeEnchant(enchantment); } item.setItemMeta(meta); } @@ -204,9 +249,15 @@ public class EnchantManager extends AbstractManager { return EnchantManager.getItemCustomEnchants(item).size(); } + public static int getItemEnchantLevel(@NotNull ItemStack item, @NotNull Enchantment enchantment) { + return getItemEnchants(item).getOrDefault(enchantment, 0); + } + @NotNull public static Map getItemEnchants(@NotNull ItemStack item) { ItemMeta meta = item.getItemMeta(); + if (meta == null) return Collections.emptyMap(); + return (meta instanceof EnchantmentStorageMeta meta2) ? meta2.getStoredEnchants() : meta.getEnchants(); } @@ -214,6 +265,70 @@ public class EnchantManager extends AbstractManager { return EnchantManager.getItemEnchants(item).size(); } + public static int getEnchantmentLevel(@NotNull ItemStack item, @NotNull Enchantment enchant) { + ItemMeta meta = item.getItemMeta(); + if (meta == null) return 0; + + return meta.getEnchantLevel(enchant); + } + + @Nullable + public static ExcellentEnchant getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect effect) { + Enchantment enchantment = ExcellentEnchantsAPI.PLUGIN.getEnchantNMS().getEnchantmentByEffect(entity, effect); + if (enchantment instanceof ExcellentEnchant enchant) return enchant; + + return null; + } + + public static boolean isEnchantmentEffect(@NotNull LivingEntity entity, @NotNull PotionEffect effect) { + return getEnchantmentByEffect(entity, effect) != null; + } + + public static boolean hasEnchantmentEffect(@NotNull LivingEntity entity, @NotNull ExcellentEnchant enchant) { + return entity.getActivePotionEffects().stream().anyMatch(effect -> enchant.equals(getEnchantmentByEffect(entity, effect))); + } + + @NotNull + public static Map getEquippedEnchantsMax(@NotNull LivingEntity entity) { + return getEquippedEnchants(entity, Math::max); + } + + @NotNull + public static Map getEquippedEnchantsTotal(@NotNull LivingEntity entity) { + return getEquippedEnchants(entity, Integer::sum); + } + + @NotNull + private static Map getEquippedEnchants(@NotNull LivingEntity entity, @NotNull BiFunction remap) { + Map map = new HashMap<>(); + + Map equipment = EntityUtil.getEquippedItems(entity); + equipment.entrySet().stream().filter(entry -> { + if (entry.getValue().getType() == Material.ENCHANTED_BOOK) return false; + if ((entry.getKey() == EquipmentSlot.HAND || entry.getKey() == EquipmentSlot.OFF_HAND) && ItemUtil.isArmor(entry.getValue())) return false; + return true; + }).map(Map.Entry::getValue).map(EnchantManager::getItemCustomEnchants).forEach(itemEnchants -> { + itemEnchants.forEach((enchant, level) -> map.merge(enchant, level, remap)); + }); + return map; + } + + public static int getEquippedEnchantLevelMax(@NotNull LivingEntity entity, @NotNull ExcellentEnchant enchant) { + return getEquippedEnchantsMax(entity).getOrDefault(enchant, 0); + } + + public static int getEquippedEnchantLevelTotal(@NotNull LivingEntity entity, @NotNull ExcellentEnchant enchant) { + return getEquippedEnchantsTotal(entity).getOrDefault(enchant, 0); + } + + public static void updateEquippedEnchantEffects(@NotNull LivingEntity entity) { + getEquippedEnchantsMax(entity).forEach((enchant, level) -> { + if (enchant instanceof PassiveEnchant passiveEnchant && enchant instanceof IEnchantPotionTemplate) { + passiveEnchant.use(entity, level); + } + }); + } + @Nullable public static EnchantTier getTierById(@NotNull String id) { return Config.getTierById(id); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java index b58911c..a6be031 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java @@ -15,6 +15,7 @@ import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import java.util.function.UnaryOperator; @@ -85,7 +86,7 @@ public class EnchantElementalProtection extends IEnchantChanceTemplate { for (ItemStack armor : EntityUtil.getArmor(victim)) { if (armor == null || armor.getType().isAir()) continue; - int level = armor.getEnchantmentLevel(this); + int level = EnchantManager.getItemEnchantLevel(armor, this); if (this.checkTriggerChance(level)) { protectionAmount += this.getProtectionAmount(level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java index 0d716d8..1008afa 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java @@ -26,6 +26,7 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.MoveEnchant; +import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import java.util.HashMap; @@ -112,7 +113,8 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn ItemStack boots = player.getInventory().getBoots(); if (boots == null || boots.getType().isAir()) return; - int level = boots.getEnchantmentLevel(this); + //int level = boots.getEnchantmentLevel(this); + int level = EnchantManager.getItemEnchants(boots).getOrDefault(this, 0); if (level < 1) return; Block bTo = to.getBlock().getRelative(BlockFace.DOWN); @@ -143,7 +145,7 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn ItemStack boots = equipment.getBoots(); if (boots == null || boots.getType().isAir()) return; - int level = boots.getEnchantmentLevel(this); + int level = EnchantManager.getItemEnchantLevel(boots, this); if (level < 1) return; if (!this.checkTriggerChance(level)) return; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java index cc6f91b..decce70 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java @@ -4,8 +4,6 @@ import org.bukkit.Particle; import org.bukkit.attribute.Attribute; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; -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.manager.ICleanable; @@ -15,11 +13,13 @@ import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import su.nightexpress.excellentenchants.manager.tasks.AbstractEnchantPassiveTask; +import java.util.Map; import java.util.function.UnaryOperator; public class EnchantRegrowth extends IEnchantChanceTemplate implements PassiveEnchant, ICleanable { @@ -115,11 +115,8 @@ public class EnchantRegrowth extends IEnchantChanceTemplate implements PassiveEn } @Override - protected void apply(@NotNull LivingEntity entity, @NotNull ItemStack armor, @NotNull ItemMeta meta) { - int level = meta.getEnchantLevel(EnchantRegrowth.this); - if (level < 1) return; - - use(entity, level); + protected void apply(@NotNull LivingEntity entity, @NotNull Map enchants) { + use(entity, enchants.getOrDefault(EnchantRegrowth.this, 0)); } } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java index 8733caa..1a2dd17 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java @@ -3,8 +3,6 @@ package su.nightexpress.excellentenchants.manager.enchants.armor; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -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.manager.ICleanable; @@ -12,11 +10,13 @@ import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import su.nightexpress.excellentenchants.manager.tasks.AbstractEnchantPassiveTask; +import java.util.Map; import java.util.function.UnaryOperator; public class EnchantSaturation extends IEnchantChanceTemplate implements PassiveEnchant, ICleanable { @@ -86,8 +86,8 @@ public class EnchantSaturation extends IEnchantChanceTemplate implements Passive public boolean use(@NotNull LivingEntity entity, int level) { if (!this.isEnchantmentAvailable(entity)) return false; if (!(entity instanceof Player player)) return false; - if (!this.checkTriggerChance(level)) return false; if (player.getFoodLevel() >= 20) return false; + if (!this.checkTriggerChance(level)) return false; if (!this.takeCostItem(player)) return false; float amount = (float) this.getSaturationAmount(level); @@ -103,11 +103,9 @@ public class EnchantSaturation extends IEnchantChanceTemplate implements Passive } @Override - protected void apply(@NotNull LivingEntity entity, @NotNull ItemStack armor, @NotNull ItemMeta meta) { - int level = meta.getEnchantLevel(EnchantSaturation.this); - if (level < 1) return; - - use(entity, level); + protected void apply(@NotNull LivingEntity entity, @NotNull Map enchants) { + // TODO Need to use SUM level and bypass the Scaler cap + use(entity, enchants.getOrDefault(EnchantSaturation.this, 0)); } } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java index eeed82d..bd3471d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java @@ -17,6 +17,7 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { @@ -93,7 +94,7 @@ public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { @Override public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { // Support for the 'Power' enchantment. - int power = weapon.getEnchantmentLevel(Enchantment.ARROW_DAMAGE); + int power = EnchantManager.getEnchantmentLevel(weapon, Enchantment.ARROW_DAMAGE); if (power < 1) return false; double damagePower = 0.5 + power * 0.5; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java index 21785fe..8ca176b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java @@ -13,6 +13,7 @@ import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import java.util.function.UnaryOperator; @@ -63,7 +64,7 @@ public class EnchantCurseOfBreaking extends IEnchantChanceTemplate { if (!this.isEnchantmentAvailable(player)) return; ItemStack item = e.getItem(); - int level = item.getEnchantmentLevel(this); + int level = EnchantManager.getItemEnchantLevel(item, this); if (level < 1) return; if (!this.checkTriggerChance(level)) return; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java index 3b7c9a6..a5aea8e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java @@ -12,6 +12,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.inventory.InventoryType; @@ -160,15 +161,24 @@ public class EnchantSilkChest extends IEnchantChanceTemplate implements CustomDr @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onSilkChestStore(InventoryClickEvent e) { - Inventory inv = e.getInventory(); - if (inv.getType() == InventoryType.CRAFTING || inv.getType() == InventoryType.CREATIVE) return; + Inventory inventory = e.getInventory(); + if (inventory.getType() == InventoryType.CRAFTING || inventory.getType() == InventoryType.CREATIVE) return; - ItemStack item = e.getCurrentItem(); - if (item == null || item.getType().isAir()) return; - - if (this.isSilkChest(item)) { - e.setCancelled(true); + Player player = (Player) e.getWhoClicked(); + ItemStack item; + if (e.getHotbarButton() >= 0) { + item = player.getInventory().getItem(e.getHotbarButton()); } + else item = e.getCurrentItem(); + + if (item == null || item.getType().isAir() || !this.isSilkChest(item)) return; + + Inventory clicked = e.getClickedInventory(); + if (e.getClick() != ClickType.NUMBER_KEY) { + if (clicked != null && clicked.equals(e.getView().getTopInventory())) return; + } + + e.setCancelled(true); } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java index cfa79f6..2fdae73 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java @@ -75,17 +75,17 @@ public class EnchantTelekinesis extends IEnchantChanceTemplate implements Custom } @Override - public void handleDrop(@NotNull EnchantDropContainer e, @NotNull Player player, @NotNull ItemStack item, int level) { - BlockDropItemEvent parent = e.getParent(); - Block block = parent.getBlockState().getBlock(); + public void handleDrop(@NotNull EnchantDropContainer container, @NotNull Player player, @NotNull ItemStack item, int level) { + BlockDropItemEvent dropItemEvent = container.getParent(); + Block block = dropItemEvent.getBlockState().getBlock(); if (!this.isEnchantmentAvailable(player)) return; //if (block.getState() instanceof Container) return; if (!this.checkTriggerChance(level)) return; List drops = new ArrayList<>(); - drops.addAll(parent.getItems().stream().map(Item::getItemStack).toList()); - drops.addAll(e.getDrop()); + drops.addAll(dropItemEvent.getItems().stream().map(Item::getItemStack).toList()); + drops.addAll(container.getDrop()); drops.removeIf(Objects::isNull); StringBuilder builder = new StringBuilder(); @@ -99,7 +99,7 @@ public class EnchantTelekinesis extends IEnchantChanceTemplate implements Custom }); this.messageDropReceived.replace("%items%", builder.toString()).send(player); - e.getDrop().clear(); - parent.getItems().clear(); + container.getDrop().clear(); + dropItemEvent.getItems().clear(); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java index c4be70b..720188c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java @@ -16,6 +16,7 @@ import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import java.util.function.UnaryOperator; @@ -69,7 +70,7 @@ public class EnchantInfernus extends IEnchantChanceTemplate { ItemStack item = trident.getItem(); - int level = item.getEnchantmentLevel(this); + int level = EnchantManager.getItemEnchantLevel(item, this); if (level <= 0) return; if (!this.checkTriggerChance(level)) return; @@ -84,7 +85,7 @@ public class EnchantInfernus extends IEnchantChanceTemplate { ItemStack item = trident.getItem(); - int level = item.getEnchantmentLevel(this); + int level = EnchantManager.getItemEnchantLevel(item, this); if (level <= 0 || trident.getFireTicks() <= 0) return; int ticks = this.getFireTicks(level); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java index 1002087..c5552a6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.manager.listeners; import org.bukkit.Material; import org.bukkit.block.Chest; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -13,19 +14,17 @@ import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.PrepareAnvilEvent; import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.LootGenerateEvent; import org.bukkit.inventory.*; import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.manager.AbstractListener; -import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Config; -import su.nightexpress.excellentenchants.config.ObtainSettings; import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.object.EnchantTier; import su.nightexpress.excellentenchants.manager.type.ObtainType; import java.util.HashMap; @@ -37,6 +36,16 @@ public class EnchantGenericListener extends AbstractListener super(enchantManager.plugin()); } + @EventHandler(priority = EventPriority.MONITOR) + public void onEnchantPotionEffectQuit(PlayerQuitEvent e) { + Player player = e.getPlayer(); + + player.getActivePotionEffects().stream() + .filter(effect -> EnchantManager.isEnchantmentEffect(player, effect)).forEach(effect -> { + player.removePotionEffect(effect.getType()); + }); + } + // --------------------------------------------------------------- // Handle Anvil // --------------------------------------------------------------- @@ -149,53 +158,32 @@ public class EnchantGenericListener extends AbstractListener // --------------------------------------------------------------- @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEnchantPopulateEnchantingTable(final EnchantItemEvent e) { - ObtainSettings settings = Config.getObtainSettings(ObtainType.ENCHANTING); - if (settings == null || Rnd.get(true) > settings.getEnchantsCustomGenerationChance()) return; - ItemStack target = e.getItem(); - boolean enchantAdded = false; + Map enchantsPrepared = e.getEnchantsToAdd(); + Map enchantsToPopulate = EnchantManager.getEnchantsToPopulate(target, ObtainType.ENCHANTING, enchantsPrepared, enchant -> enchant.getLevelByEnchantCost(e.getExpLevelCost())); - int enchMax = settings.getEnchantsTotalMax(); - int enchRoll = Rnd.get(settings.getEnchantsCustomMin(), settings.getEnchantsCustomMax()); + enchantsPrepared.putAll(enchantsToPopulate); - for (int count = 0; (count < enchRoll && e.getEnchantsToAdd().size() < enchMax); count++) { - EnchantTier tier = EnchantManager.getTierByChance(ObtainType.ENCHANTING); - if (tier == null) continue; + plugin.getServer().getScheduler().runTask(plugin, () -> { + ItemStack result = e.getInventory().getItem(0); + if (result == null) return; - ExcellentEnchant enchant = tier.getEnchant(ObtainType.ENCHANTING, target); - if (enchant == null) continue; - if (e.getEnchantsToAdd().keySet().stream().anyMatch(add -> add.conflictsWith(enchant) || enchant.conflictsWith(add))) - continue; + // Fix enchantments for Enchant Books. + // Enchants are not added on book because they do not exists in NMS. + // Server gets enchants from NMS to apply it on Book NBT tags. + ItemMeta meta = result.getItemMeta(); + if (meta instanceof EnchantmentStorageMeta storageMeta) { + e.getEnchantsToAdd().forEach((enchantment, level) -> { + if (!storageMeta.hasStoredEnchant(enchantment)) { + storageMeta.addStoredEnchant(enchantment, level, true); + } + }); + result.setItemMeta(storageMeta); + } - int level = enchant.getLevelByEnchantCost(e.getExpLevelCost()); - if (level < 1) continue; - - e.getEnchantsToAdd().put(enchant, level); - enchantAdded = true; - } - - if (enchantAdded) { - plugin.getServer().getScheduler().runTask(plugin, () -> { - ItemStack result = e.getInventory().getItem(0); - if (result == null) return; - - // Fix enchantments for Enchant Books. - // Enchants are not added on book because they do not exists in NMS. - // Server gets enchants from NMS to apply it on Book NBT tags. - ItemMeta meta = result.getItemMeta(); - if (meta instanceof EnchantmentStorageMeta meta2) { - e.getEnchantsToAdd().forEach((en, lvl) -> { - if (!meta2.hasStoredEnchant(en)) { - meta2.addStoredEnchant(en, lvl, true); - } - }); - result.setItemMeta(meta2); - } - - EnchantManager.updateItemLoreEnchants(result); - e.getInventory().setItem(0, result); - }); - } + EnchantManager.updateItemLoreEnchants(result); + e.getInventory().setItem(0, result); + }); } // --------------------------------------------------------------- diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantPopulator.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantPopulator.java new file mode 100644 index 0000000..5b831c6 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantPopulator.java @@ -0,0 +1,77 @@ +package su.nightexpress.excellentenchants.manager.object; + +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.manager.type.ObtainType; + +import java.util.*; +import java.util.stream.Collectors; + +public class EnchantPopulator { + + private final ObtainType obtainType; + private final ItemStack item; + private final Map> enchants; + + public EnchantPopulator(@NotNull ObtainType obtainType, @NotNull ItemStack item) { + this.obtainType = obtainType; + this.item = item; + this.enchants = Config.getTiers().stream() + .collect(Collectors.toMap(k -> k, v -> v.getEnchants(obtainType, item), (prev, add) -> add, HashMap::new)); + } + + public boolean isEmpty() { + return this.getEnchants().isEmpty() || this.getEnchants().values().stream().allMatch(Set::isEmpty); + } + + public boolean isEmpty(@NotNull EnchantTier tier) { + return this.getEnchants(tier).isEmpty(); + } + + public void purge(@NotNull EnchantTier tier) { + this.getEnchants().remove(tier); + } + + public void purge(@NotNull EnchantTier tier, @NotNull ExcellentEnchant enchant) { + this.getEnchants(tier).remove(enchant); + this.getEnchants().keySet().removeIf(this::isEmpty); + } + + @NotNull + public ObtainType getObtainType() { + return obtainType; + } + + @NotNull + public ItemStack getItem() { + return item; + } + + @NotNull + public Map> getEnchants() { + return this.enchants; + } + + @NotNull + public Set getEnchants(@NotNull EnchantTier tier) { + return this.getEnchants().getOrDefault(tier, new HashSet<>()); + } + + @Nullable + public EnchantTier getTierByChance() { + Map map = this.getEnchants().keySet().stream() + .collect(Collectors.toMap(k -> k, v -> v.getChance(this.getObtainType()))); + return Rnd.get(map); + } + + @Nullable + public ExcellentEnchant getEnchantByChance(@NotNull EnchantTier tier) { + Map map = this.getEnchants(tier).stream() + .collect(Collectors.toMap(k -> k, v -> v.getObtainChance(this.getObtainType()))); + return map.isEmpty() ? null : Rnd.get(map); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java index 5b7f144..3fb1ea0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java @@ -4,7 +4,6 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.utils.StringUtil; -import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.manager.type.ObtainType; @@ -73,22 +72,10 @@ public class EnchantTier { @NotNull public Set getEnchants(@NotNull ObtainType obtainType, @Nullable ItemStack item) { Set set = this.getEnchants().stream() - .filter(en -> en.getObtainChance(obtainType) > 0) - .filter(en -> item == null || en.canEnchantItem(item)).collect(Collectors.toSet()); - set.removeIf(en -> obtainType == ObtainType.ENCHANTING && en.isTreasure()); + .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()); return set; } - - @Nullable - public ExcellentEnchant getEnchant(@NotNull ObtainType obtainType) { - return getEnchant(obtainType, null); - } - - @Nullable - public ExcellentEnchant getEnchant(@NotNull ObtainType obtainType, @Nullable ItemStack item) { - Map map = this.getEnchants(obtainType).stream() - .filter(en -> item == null || en.canEnchantItem(item)) - .collect(Collectors.toMap(k -> k, v -> v.getObtainChance(obtainType))); - return map.isEmpty() ? null : Rnd.get(map); - } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/AbstractEnchantPassiveTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/AbstractEnchantPassiveTask.java index 9cf72ed..93647b4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/AbstractEnchantPassiveTask.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/AbstractEnchantPassiveTask.java @@ -1,44 +1,31 @@ package su.nightexpress.excellentenchants.manager.tasks; -import org.bukkit.Material; import org.bukkit.entity.LivingEntity; -import org.bukkit.inventory.EntityEquipment; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.task.AbstractTask; -import su.nexmedia.engine.utils.EntityUtil; -import su.nexmedia.engine.utils.ItemUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.manager.EnchantManager; -import java.util.*; +import java.util.Collection; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +@Deprecated public abstract class AbstractEnchantPassiveTask extends AbstractTask { public AbstractEnchantPassiveTask(@NotNull ExcellentEnchants plugin, long interval, boolean async) { super(plugin, interval, async); } - protected abstract void apply(@NotNull LivingEntity entity, @NotNull ItemStack armor, @NotNull ItemMeta meta); + protected abstract void apply(@NotNull LivingEntity entity, @NotNull Map enchants); @Override public void action() { for (LivingEntity entity : this.getEntities()) { - - List list = new ArrayList<>(Arrays.asList(EntityUtil.getArmor(entity))); - EntityEquipment equipment = entity.getEquipment(); - if (equipment != null && !ItemUtil.isArmor(equipment.getItemInMainHand())) { - list.add(equipment.getItemInMainHand()); - } - list.removeIf(armor -> armor == null || armor.getType().isAir() || armor.getType() == Material.ENCHANTED_BOOK); - - for (ItemStack armor : list) { - ItemMeta meta = armor.getItemMeta(); - if (meta == null) continue; - - this.apply(entity, armor, meta); - } + this.apply(entity, EnchantManager.getEquippedEnchantsMax(entity)); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java index d861dcb..bd5f123 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java @@ -1,28 +1,22 @@ package su.nightexpress.excellentenchants.manager.tasks; import org.bukkit.entity.LivingEntity; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.manager.EnchantManager; + +import java.util.Map; public class EnchantEffectPassiveTask extends AbstractEnchantPassiveTask { public EnchantEffectPassiveTask(@NotNull ExcellentEnchants plugin) { - super(plugin, Config.TASKS_PASSIVE_ENCHANTS_TICKS_INTERVAL, false); + super(plugin, Config.TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL.get(), false); } @Override - protected void apply(@NotNull LivingEntity entity, @NotNull ItemStack armor, @NotNull ItemMeta meta) { - meta.getEnchants().forEach((enchantment, level) -> { - if (level < 1) return; - if (!(enchantment instanceof PassiveEnchant passiveEnchant)) return; - if (!(enchantment instanceof IEnchantPotionTemplate)) return; - - passiveEnchant.use(entity, level); - }); + protected void apply(@NotNull LivingEntity entity, @NotNull Map enchants) { + EnchantManager.updateEquippedEnchantEffects(entity); } } diff --git a/Core/src/main/resources/config.yml b/Core/src/main/resources/config.yml index dc7d9fd..df80ae3 100644 --- a/Core/src/main/resources/config.yml +++ b/Core/src/main/resources/config.yml @@ -20,9 +20,6 @@ General: Arrow_Trails: # Defines the ticks interval (20 ticks = 1 second) for the arrow particle effect spawning. Ticks_Interval: 1 - Passive_Enchants: - # Defines the ticks interval (20 ticks = 1 second) for the passive enchantment effects to trigger. - Ticks_Interval: 100 # Enchantment global settings. Enchantments: # List of disabled custom enchantments. diff --git a/NMS/pom.xml b/NMS/pom.xml index 7d1f2eb..82cd19c 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.7 + 3.2.8 4.0.0 diff --git a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java index c675ddc..8a40271 100644 --- a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java +++ b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java @@ -2,12 +2,39 @@ package su.nightexpress.excellentenchants.nms; import org.bukkit.Location; import org.bukkit.block.Block; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.potion.PotionEffect; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.utils.EntityUtil; +import java.util.Arrays; import java.util.Set; public interface EnchantNMS { + // TODO Move in 'API' module? + @Deprecated + static int getEnchantmentLevel(@NotNull ItemStack item, @NotNull Enchantment enchant) { + ItemMeta meta = item.getItemMeta(); + if (meta == null) return 0; + + return meta.getEnchantLevel(enchant); + } + + // TODO Move in 'API' module? + @Deprecated + static int getEquippedEnchantLevel(@NotNull LivingEntity entity, @NotNull Enchantment enchant) { + return Arrays.stream(EntityUtil.getEquipment(entity)).filter(enchant::canEnchantItem) + .map(item -> getEnchantmentLevel(item, enchant)).max(Integer::compareTo).orElse(0); + } + + void addEnchantmentEffect(@NotNull LivingEntity entity, @NotNull Enchantment enchant, @NotNull PotionEffect effect); + + @Nullable Enchantment getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect type); + @NotNull Set handleFlameWalker(@NotNull LivingEntity entity, @NotNull Location location, int level); } diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 9df79f3..a7f8cc0 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.7 + 3.2.8 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.7 + 3.2.8 diff --git a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java new file mode 100644 index 0000000..c0d7909 --- /dev/null +++ b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java @@ -0,0 +1,39 @@ +package su.nightexpress.excellentenchants.nms.v1_17_R1; + +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.LivingEntity; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.utils.Reflex; +import su.nightexpress.excellentenchants.nms.EnchantNMS; + +public class CustomEffectInstance extends MobEffectInstance { + + private static final int MIN = 60 * 60 * 20; + + private final Enchantment enchantment; + + public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { + super(effect, Integer.MAX_VALUE, amplifier); + this.enchantment = enchantment; + } + + @NotNull + public Enchantment getEnchantment() { + return enchantment; + } + + public boolean tick(LivingEntity entity, Runnable runnable) { + if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) { + return false; + } + if (super.tick(entity, runnable)) { + if (this.getDuration() <= MIN) { + Reflex.setFieldValue(this, "c", Integer.MAX_VALUE); + } + return true; + } + return false; + } +} diff --git a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_17_R1.java b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java similarity index 66% rename from V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_17_R1.java rename to V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java index afdee7a..bc6ced2 100644 --- a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_17_R1.java +++ b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java @@ -1,7 +1,9 @@ -package su.nightexpress.excellentenchants.nms; +package su.nightexpress.excellentenchants.nms.v1_17_R1; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; @@ -12,14 +14,36 @@ import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityPotionEffectEvent; +import org.bukkit.potion.PotionEffect; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nightexpress.excellentenchants.nms.EnchantNMS; import java.util.HashSet; import java.util.Set; public class V1_17_R1 implements EnchantNMS { + @Override + public void addEnchantmentEffect(@NotNull LivingEntity entity, @NotNull Enchantment enchant, @NotNull PotionEffect effect) { + net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); + entity1.addEffect(new CustomEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getAmplifier(), enchant), EntityPotionEffectEvent.Cause.PLUGIN); + } + + @Override + @Nullable + public Enchantment getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect type) { + net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); + MobEffectInstance handle = entity1.getEffect(MobEffect.byId(type.getType().getId())); + if (handle instanceof CustomEffectInstance instance) { + return instance.getEnchantment(); + } + return null; + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 74cd5c7..1eb72be 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.7 + 3.2.8 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.7 + 3.2.8 diff --git a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java new file mode 100644 index 0000000..a644d72 --- /dev/null +++ b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java @@ -0,0 +1,39 @@ +package su.nightexpress.excellentenchants.nms.v1_18_R2; + +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.LivingEntity; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.utils.Reflex; +import su.nightexpress.excellentenchants.nms.EnchantNMS; + +public class CustomEffectInstance extends MobEffectInstance { + + private static final int MIN = 60 * 60 * 20; + + private final Enchantment enchantment; + + public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { + super(effect, Integer.MAX_VALUE, amplifier); + this.enchantment = enchantment; + } + + @NotNull + public Enchantment getEnchantment() { + return enchantment; + } + + public boolean tick(LivingEntity entity, Runnable runnable) { + if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) { + return false; + } + if (super.tick(entity, runnable)) { + if (this.getDuration() <= MIN) { + Reflex.setFieldValue(this, "c", Integer.MAX_VALUE); + } + return true; + } + return false; + } +} diff --git a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R2.java b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java similarity index 66% rename from V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R2.java rename to V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java index abf9ab5..15dc5af 100644 --- a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/V1_18_R2.java +++ b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java @@ -1,7 +1,9 @@ -package su.nightexpress.excellentenchants.nms; +package su.nightexpress.excellentenchants.nms.v1_18_R2; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; @@ -12,14 +14,36 @@ import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityPotionEffectEvent; +import org.bukkit.potion.PotionEffect; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nightexpress.excellentenchants.nms.EnchantNMS; import java.util.HashSet; import java.util.Set; public class V1_18_R2 implements EnchantNMS { + @Override + public void addEnchantmentEffect(@NotNull LivingEntity entity, @NotNull Enchantment enchant, @NotNull PotionEffect effect) { + net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); + entity1.addEffect(new CustomEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getAmplifier(), enchant), EntityPotionEffectEvent.Cause.PLUGIN); + } + + @Override + @Nullable + public Enchantment getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect type) { + net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); + MobEffectInstance handle = entity1.getEffect(MobEffect.byId(type.getType().getId())); + if (handle instanceof CustomEffectInstance instance) { + return instance.getEnchantment(); + } + return null; + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index fd308ef..e4f3bf3 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.7 + 3.2.8 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.7 + 3.2.8 diff --git a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java new file mode 100644 index 0000000..facfcdf --- /dev/null +++ b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java @@ -0,0 +1,39 @@ +package su.nightexpress.excellentenchants.nms.v1_19_R1; + +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.LivingEntity; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.utils.Reflex; +import su.nightexpress.excellentenchants.nms.EnchantNMS; + +public class CustomEffectInstance extends MobEffectInstance { + + private static final int MIN = 60 * 60 * 20; + + private final Enchantment enchantment; + + public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { + super(effect, Integer.MAX_VALUE, amplifier); + this.enchantment = enchantment; + } + + @NotNull + public Enchantment getEnchantment() { + return enchantment; + } + + public boolean tick(LivingEntity entity, Runnable runnable) { + if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) { + return false; + } + if (super.tick(entity, runnable)) { + if (this.getDuration() <= MIN) { + Reflex.setFieldValue(this, "c", Integer.MAX_VALUE); + } + return true; + } + return false; + } +} diff --git a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_19_R1.java b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java similarity index 66% rename from V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_19_R1.java rename to V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java index a76d34a..88e9977 100644 --- a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/V1_19_R1.java +++ b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java @@ -1,7 +1,9 @@ -package su.nightexpress.excellentenchants.nms; +package su.nightexpress.excellentenchants.nms.v1_19_R1; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; @@ -12,14 +14,36 @@ import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityPotionEffectEvent; +import org.bukkit.potion.PotionEffect; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nightexpress.excellentenchants.nms.EnchantNMS; import java.util.HashSet; import java.util.Set; public class V1_19_R1 implements EnchantNMS { + @Override + public void addEnchantmentEffect(@NotNull LivingEntity entity, @NotNull Enchantment enchant, @NotNull PotionEffect effect) { + net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); + entity1.addEffect(new CustomEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getAmplifier(), enchant), EntityPotionEffectEvent.Cause.PLUGIN); + } + + @Override + @Nullable + public Enchantment getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect type) { + net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); + MobEffectInstance handle = entity1.getEffect(MobEffect.byId(type.getType().getId())); + if (handle instanceof CustomEffectInstance instance) { + return instance.getEnchantment(); + } + return null; + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { diff --git a/pom.xml b/pom.xml index 45364b1..4e37986 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.2.7 + 3.2.8 Core NMS @@ -25,7 +25,7 @@ su.nexmedia NexEngine - 2.2.6 + 2.2.7 From befeda87fb23e66a97ce6e9bf9f5514efa8823a0 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Thu, 22 Dec 2022 01:34:09 +0600 Subject: [PATCH 19/69] v3.2.11 --- .gitignore | 22 +++-- Core/pom.xml | 17 ++-- .../excellentenchants/ExcellentEnchants.java | 2 + .../api/enchantment/ExcellentEnchant.java | 2 +- .../IEnchantBowPotionTemplate.java | 3 +- .../api/enchantment/IEnchantBowTemplate.java | 3 +- .../enchantment/IEnchantPotionTemplate.java | 4 +- .../excellentenchants/config/Config.java | 9 ++- .../manager/EnchantManager.java | 6 ++ .../enchants/armor/EnchantFlameWalker.java | 4 +- .../manager/enchants/bow/EnchantBomber.java | 3 +- .../manager/enchants/bow/EnchantEnderBow.java | 3 +- .../manager/enchants/bow/EnchantGhast.java | 4 +- .../enchants/tool/EnchantBlastMining.java | 5 +- .../enchants/tool/EnchantDivineTouch.java | 2 +- .../manager/enchants/tool/EnchantTunnel.java | 5 +- .../enchants/tool/EnchantVeinminer.java | 5 +- NMS/pom.xml | 2 +- .../excellentenchants/nms/EnchantNMS.java | 4 +- V1_17_R1/pom.xml | 4 +- .../nms/v1_17_R1/CustomEffectInstance.java | 11 +++ V1_18_R2/pom.xml | 4 +- .../nms/v1_18_R2/CustomEffectInstance.java | 11 +++ V1_19_R1/pom.xml | 4 +- .../nms/v1_19_R1/CustomEffectInstance.java | 11 +++ V1_19_R2/pom.xml | 70 ++++++++++++++++ .../nms/v1_19_R2/CustomEffectInstance.java | 50 ++++++++++++ .../nms/v1_19_R2/V1_19_R2.java | 80 +++++++++++++++++++ pom.xml | 3 +- 29 files changed, 305 insertions(+), 48 deletions(-) create mode 100644 V1_19_R2/pom.xml create mode 100644 V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java create mode 100644 V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java diff --git a/.gitignore b/.gitignore index c48c708..3438c0f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,15 @@ -/Core/pom.xml.versionsBackup -/pom.xml.versionsBackup -/NMS/pom.xml.versionsBackup -/V1_16_R1/pom.xml.versionsBackup -/V1_17_R1/pom.xml.versionsBackup -/V1_18_R1/pom.xml.versionsBackup -/Core/target/ -/NMS/target/ -/V1_16_R1/target/ -/V1_17_R1/target/ -/V1_18_R1/target/ /.idea/ /target/ -/V1_18_R2/pom.xml.versionsBackup +/pom.xml.versionsBackup +/Core/target/ +/Core/pom.xml.versionsBackup +/NMS/target/ +/NMS/pom.xml.versionsBackup +/V1_17_R1/target/ +/V1_17_R1/pom.xml.versionsBackup /V1_18_R2/target/ +/V1_18_R2/pom.xml.versionsBackup /V1_19_R1/target/ /V1_19_R1/pom.xml.versionsBackup +/V1_19_R2/target/ +/V1_19_R2/pom.xml.versionsBackup \ No newline at end of file diff --git a/Core/pom.xml b/Core/pom.xml index 20aaa2e..92ec565 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.8 + 3.2.11 4.0.0 @@ -31,27 +31,32 @@ org.spigotmc spigot-api - 1.19.2-R0.1-SNAPSHOT + 1.19.3-R0.1-SNAPSHOT su.nightexpress.excellentenchants NMS - 3.2.8 + 3.2.11 su.nightexpress.excellentenchants V1_17_R1 - 3.2.8 + 3.2.11 su.nightexpress.excellentenchants V1_18_R2 - 3.2.8 + 3.2.11 su.nightexpress.excellentenchants V1_19_R1 - 3.2.8 + 3.2.11 + + + su.nightexpress.excellentenchants + V1_19_R2 + 3.2.11 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 9ec1a86..625c630 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.nms.EnchantNMS; import su.nightexpress.excellentenchants.nms.v1_17_R1.V1_17_R1; import su.nightexpress.excellentenchants.nms.v1_18_R2.V1_18_R2; import su.nightexpress.excellentenchants.nms.v1_19_R1.V1_19_R1; +import su.nightexpress.excellentenchants.nms.v1_19_R2.V1_19_R2; public class ExcellentEnchants extends NexPlugin { @@ -57,6 +58,7 @@ public class ExcellentEnchants extends NexPlugin { case V1_17_R1 -> new V1_17_R1(); case V1_18_R2 -> new V1_18_R2(); case V1_19_R1 -> new V1_19_R1(); + case V1_19_R2 -> new V1_19_R2(); }; return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index 68f7443..a07789a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -372,7 +372,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener public final boolean canEnchantItem(@Nullable ItemStack item) { if (item == null || item.getType().isAir()) return false; if (EnchantManager.getItemEnchants(item).keySet().stream().anyMatch(e -> e.conflictsWith(this) || this.conflictsWith(e))) return false; - if (!item.containsEnchantment(this) && EnchantManager.getItemCustomEnchantsAmount(item) >= Config.ENCHANTMENTS_ITEM_CUSTOM_MAX) { + if (EnchantManager.getEnchantmentLevel(item, this) <= 0 && EnchantManager.getItemCustomEnchantsAmount(item) >= Config.ENCHANTMENTS_ITEM_CUSTOM_MAX) { return false; } if (item.getType() == Material.BOOK || item.getType() == Material.ENCHANTED_BOOK) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowPotionTemplate.java index e321bba..ad103ab 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowPotionTemplate.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowPotionTemplate.java @@ -14,6 +14,7 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.manager.EnchantManager; public abstract class IEnchantBowPotionTemplate extends IEnchantPotionTemplate implements BowEnchant { @@ -52,7 +53,7 @@ public abstract class IEnchantBowPotionTemplate extends IEnchantPotionTemplate i if (!this.isEnchantmentAvailable(shooter)) return false; if (!(e.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; - if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; + if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; this.setThisArrow(arrow); arrow.addCustomEffect(this.getEffect(level), true); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java index 005cecd..83dec43 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java @@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.tasks.ArrowTrailsTask; public abstract class IEnchantBowTemplate extends IEnchantChanceTemplate implements BowEnchant { @@ -71,7 +72,7 @@ public abstract class IEnchantBowTemplate extends IEnchantChanceTemplate impleme if (!this.isEnchantmentAvailable(shooter)) return false; if (!(e.getProjectile() instanceof Projectile arrow)) return false; if (!this.checkTriggerChance(level)) return false; - if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; + if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; this.setThisArrow(arrow); if (!this.arrowTrailName.isEmpty()) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java index bf6b103..7cd66c7 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java @@ -78,7 +78,9 @@ public abstract class IEnchantPotionTemplate extends IEnchantChanceTemplate { public final boolean addEffect(@NotNull LivingEntity target, int level) { if (this instanceof PassiveEnchant) { - this.plugin.getEnchantNMS().addEnchantmentEffect(target, this, this.getEffect(level)); + if (!this.hasEffect(target)) { + this.plugin.getEnchantNMS().addEnchantmentEffect(target, this, this.getEffect(level)); + } } else { target.addPotionEffect(this.getEffect(level)); 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 6b7d84c..27ba4ff 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -18,7 +18,10 @@ import java.util.stream.Collectors; public class Config { public static long TASKS_ARROW_TRAIL_TICKS_INTERVAL; - public static final JOption TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL = JOption.create("General.Tasks.Passive_Potion_Effects.Apply_Interval", "Sets how often (in ticks) the plugin will apply permanent potion effects from enchanted items to an entity who wear them.\nThis setting does NOT refreshes currently active effects, but only attempts to add them if absent.", 150); + public static final JOption TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL = JOption.create("General.Tasks.Passive_Potion_Effects.Apply_Interval", 150, + "Sets how often (in ticks) the plugin will apply permanent potion effects from enchanted items to an entity who wear them.", + "This setting does NOT refreshes currently active effects, but only attempts to add them if absent." + ); public static Set ENCHANTMENTS_DISABLED; public static Map> ENCHANTMENTS_DISABLED_IN_WORLDS; @@ -42,7 +45,7 @@ public class Config { TASKS_ARROW_TRAIL_TICKS_INTERVAL = cfg.getLong(path + "Arrow_Trails.Ticks_Interval", 1); path = "General.Enchantments."; - cfg.addMissing(path + "Disabled_In_Worlds.my_world", Collections.singletonList(Placeholders.MASK_ANY)); + cfg.addMissing(path + "Disabled_In_Worlds.my_world", Collections.singletonList(Placeholders.WILDCARD)); cfg.addMissing(path + "Disabled_In_Worlds.other_world", Arrays.asList("enchant_name", "another_enchant")); ENCHANTMENTS_DISABLED = cfg.getStringSet(path + "Disabled").stream().map(String::toLowerCase).collect(Collectors.toSet()); @@ -132,7 +135,7 @@ public class Config { public static boolean isEnchantmentDisabled(@NotNull ExcellentEnchant enchant, @NotNull String world) { Set disabled = ENCHANTMENTS_DISABLED_IN_WORLDS.getOrDefault(world, Collections.emptySet()); - return disabled.contains(enchant.getKey().getKey()) || disabled.contains(Placeholders.MASK_ANY); + return disabled.contains(enchant.getKey().getKey()) || disabled.contains(Placeholders.WILDCARD); } @Nullable diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java index e412912..65d448e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java @@ -249,6 +249,7 @@ public class EnchantManager extends AbstractManager { return EnchantManager.getItemCustomEnchants(item).size(); } + @Deprecated public static int getItemEnchantLevel(@NotNull ItemStack item, @NotNull Enchantment enchantment) { return getItemEnchants(item).getOrDefault(enchantment, 0); } @@ -265,6 +266,10 @@ public class EnchantManager extends AbstractManager { return EnchantManager.getItemEnchants(item).size(); } + public static boolean hasEnchantment(@NotNull ItemStack item, @NotNull Enchantment enchantment) { + return getEnchantmentLevel(item, enchantment) > 0; + } + public static int getEnchantmentLevel(@NotNull ItemStack item, @NotNull Enchantment enchant) { ItemMeta meta = item.getItemMeta(); if (meta == null) return 0; @@ -304,6 +309,7 @@ public class EnchantManager extends AbstractManager { Map equipment = EntityUtil.getEquippedItems(entity); equipment.entrySet().stream().filter(entry -> { + if (entry.getValue() == null) return false; if (entry.getValue().getType() == Material.ENCHANTED_BOOK) return false; if ((entry.getKey() == EquipmentSlot.HAND || entry.getKey() == EquipmentSlot.OFF_HAND) && ItemUtil.isArmor(entry.getValue())) return false; return true; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java index 1008afa..0bca191 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java @@ -114,7 +114,7 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn if (boots == null || boots.getType().isAir()) return; //int level = boots.getEnchantmentLevel(this); - int level = EnchantManager.getItemEnchants(boots).getOrDefault(this, 0); + int level = EnchantManager.getEnchantmentLevel(boots, this); if (level < 1) return; Block bTo = to.getBlock().getRelative(BlockFace.DOWN); @@ -145,7 +145,7 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn ItemStack boots = equipment.getBoots(); if (boots == null || boots.getType().isAir()) return; - int level = EnchantManager.getItemEnchantLevel(boots, this); + int level = EnchantManager.getEnchantmentLevel(boots, this); if (level < 1) return; if (!this.checkTriggerChance(level)) return; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java index 01f7741..380d136 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java @@ -16,6 +16,7 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import java.util.function.UnaryOperator; @@ -67,7 +68,7 @@ public class EnchantBomber extends IEnchantChanceTemplate implements BowEnchant if (!this.isEnchantmentAvailable(shooter)) return false; if (!this.checkTriggerChance(level)) return false; if (!(e.getProjectile() instanceof Projectile projectile)) return false; - if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; + if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; TNTPrimed primed = projectile.getWorld().spawn(projectile.getLocation(), TNTPrimed.class); primed.setVelocity(projectile.getVelocity().multiply(e.getForce() * 1.25)); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java index d1d3709..f2cbc70 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java @@ -14,6 +14,7 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.manager.EnchantManager; public class EnchantEnderBow extends IEnchantChanceTemplate implements BowEnchant { @@ -34,7 +35,7 @@ public class EnchantEnderBow extends IEnchantChanceTemplate implements BowEnchan if (!this.isEnchantmentAvailable(shooter)) return false; if (!this.checkTriggerChance(level)) return false; if (!(e.getProjectile() instanceof Projectile projectile)) return false; - if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; + if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; EnderPearl pearl = shooter.launchProjectile(EnderPearl.class); pearl.setVelocity(projectile.getVelocity()); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java index bd3471d..9f8d4f7 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java @@ -65,13 +65,13 @@ public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { if (!this.isEnchantmentAvailable(shooter)) return false; if (!this.checkTriggerChance(level)) return false; if (!(e.getProjectile() instanceof Projectile projectile)) return false; - if (!bow.containsEnchantment(ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; + if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; Fireball fireball; // Shoot small fireballs for the Multishot enchantment, // as large ones has a slow speed and punches each other on shoot. - if (bow.containsEnchantment(Enchantment.MULTISHOT)) { + if (EnchantManager.hasEnchantment(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/manager/enchants/tool/EnchantBlastMining.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java index 3def20d..e6061ae 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java @@ -21,6 +21,7 @@ import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.hook.HookNCP; +import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import su.nightexpress.excellentenchants.manager.type.FitItemType; @@ -94,8 +95,8 @@ public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockB public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isEnchantmentAvailable(player)) return false; - if (EnchantRegister.VEINMINER != null && item.containsEnchantment(EnchantRegister.VEINMINER)) return false; - if (EnchantRegister.TUNNEL != null && item.containsEnchantment(EnchantRegister.TUNNEL)) return false; + if (EnchantRegister.VEINMINER != null && EnchantManager.hasEnchantment(item, EnchantRegister.VEINMINER)) return false; + if (EnchantRegister.TUNNEL != null && EnchantManager.hasEnchantment(item, EnchantRegister.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/manager/enchants/tool/EnchantDivineTouch.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java index 512791c..e591e67 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java @@ -124,7 +124,7 @@ public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockB Player player = e.getPlayer(); ItemStack spawner = player.getInventory().getItem(e.getHand()); - if (spawner.getType() != Material.SPAWNER || !(spawner.getItemMeta() instanceof BlockStateMeta meta)) return; + if (spawner == null || spawner.getType() != Material.SPAWNER || !(spawner.getItemMeta() instanceof BlockStateMeta meta)) return; CreatureSpawner spawnerItem = (CreatureSpawner) meta.getBlockState(); CreatureSpawner spawnerBlock = (CreatureSpawner) block.getState(); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java index 097d4cb..9424d21 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java @@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.hook.HookNCP; +import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.type.FitItemType; @@ -71,8 +72,8 @@ public class EnchantTunnel extends IEnchantChanceTemplate implements BlockBreakE Block block = e.getBlock(); if (!this.isEnchantmentAvailable(player)) return false; if (this.disableOnSneak && player.isSneaking()) return false; - if (EnchantRegister.VEINMINER != null && item.containsEnchantment(EnchantRegister.VEINMINER)) return false; - if (EnchantRegister.BLAST_MINING != null && item.containsEnchantment(EnchantRegister.BLAST_MINING)) 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 (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; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java index fc06e80..82034cf 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java @@ -19,6 +19,7 @@ import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.hook.HookNCP; +import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.EnchantRegister; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import su.nightexpress.excellentenchants.manager.type.FitItemType; @@ -115,8 +116,8 @@ public class EnchantVeinminer extends IEnchantChanceTemplate implements BlockBre @Override public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack tool, int level) { if (!this.isEnchantmentAvailable(player)) return false; - if (EnchantRegister.TUNNEL != null && tool.containsEnchantment(EnchantRegister.TUNNEL)) return false; - if (EnchantRegister.BLAST_MINING != null && tool.containsEnchantment(EnchantRegister.BLAST_MINING)) 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; Block block = e.getBlock(); if (block.hasMetadata(META_BLOCK_VEINED)) return false; diff --git a/NMS/pom.xml b/NMS/pom.xml index 82cd19c..6a0d505 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.8 + 3.2.11 4.0.0 diff --git a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java index 8a40271..a57a9ef 100644 --- a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java +++ b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.utils.EntityUtil; -import java.util.Arrays; +import java.util.Objects; import java.util.Set; public interface EnchantNMS { @@ -28,7 +28,7 @@ public interface EnchantNMS { // TODO Move in 'API' module? @Deprecated static int getEquippedEnchantLevel(@NotNull LivingEntity entity, @NotNull Enchantment enchant) { - return Arrays.stream(EntityUtil.getEquipment(entity)).filter(enchant::canEnchantItem) + return EntityUtil.getEquippedItems(entity).values().stream().filter(Objects::nonNull).filter(enchant::canEnchantItem) .map(item -> getEnchantmentLevel(item, enchant)).max(Integer::compareTo).orElse(0); } diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index a7f8cc0..989600f 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.8 + 3.2.11 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.8 + 3.2.11 diff --git a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java index c0d7909..3e98c59 100644 --- a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java +++ b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java @@ -24,6 +24,17 @@ public class CustomEffectInstance extends MobEffectInstance { return enchantment; } + @Override + public boolean update(MobEffectInstance effect) { + /*if (effect instanceof CustomEffectInstance custom) { + return false; + } + if (effect.getAmplifier() > this.getAmplifier()) { + + }*/ + return false; + } + public boolean tick(LivingEntity entity, Runnable runnable) { if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) { return false; diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 1eb72be..589949f 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.8 + 3.2.11 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.8 + 3.2.11 diff --git a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java index a644d72..6f76733 100644 --- a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java +++ b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java @@ -24,6 +24,17 @@ public class CustomEffectInstance extends MobEffectInstance { return enchantment; } + @Override + public boolean update(MobEffectInstance effect) { + /*if (effect instanceof CustomEffectInstance custom) { + return false; + } + if (effect.getAmplifier() > this.getAmplifier()) { + + }*/ + return false; + } + public boolean tick(LivingEntity entity, Runnable runnable) { if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) { return false; diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index e4f3bf3..6d6516e 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.8 + 3.2.11 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.8 + 3.2.11 diff --git a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java index facfcdf..f62e277 100644 --- a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java +++ b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java @@ -24,6 +24,17 @@ public class CustomEffectInstance extends MobEffectInstance { return enchantment; } + @Override + public boolean update(MobEffectInstance effect) { + /*if (effect instanceof CustomEffectInstance custom) { + return false; + } + if (effect.getAmplifier() > this.getAmplifier()) { + + }*/ + return false; + } + public boolean tick(LivingEntity entity, Runnable runnable) { if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) { return false; diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml new file mode 100644 index 0000000..61cad56 --- /dev/null +++ b/V1_19_R2/pom.xml @@ -0,0 +1,70 @@ + + + + ExcellentEnchants + su.nightexpress.excellentenchants + 3.2.11 + + 4.0.0 + + V1_19_R2 + + + 16 + 16 + + + + + org.spigotmc + spigot + 1.19.3-R0.1-SNAPSHOT + remapped-mojang + + + su.nightexpress.excellentenchants + NMS + 3.2.11 + + + + + + + net.md-5 + specialsource-maven-plugin + 1.2.4 + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:txt:maps-mojang + true + org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-mojang + true + remapped-obf + + + + package + + remap + + remap-spigot + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-obf + + + + + + + \ No newline at end of file diff --git a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java new file mode 100644 index 0000000..7a7d20f --- /dev/null +++ b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java @@ -0,0 +1,50 @@ +package su.nightexpress.excellentenchants.nms.v1_19_R2; + +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.LivingEntity; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.utils.Reflex; +import su.nightexpress.excellentenchants.nms.EnchantNMS; + +public class CustomEffectInstance extends MobEffectInstance { + + private static final int MIN = 60 * 60 * 20; + + private final Enchantment enchantment; + + public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { + super(effect, Integer.MAX_VALUE, amplifier); + this.enchantment = enchantment; + } + + @NotNull + public Enchantment getEnchantment() { + return enchantment; + } + + @Override + public boolean update(MobEffectInstance effect) { + /*if (effect instanceof CustomEffectInstance custom) { + return false; + } + if (effect.getAmplifier() > this.getAmplifier()) { + + }*/ + return false; + } + + public boolean tick(LivingEntity entity, Runnable runnable) { + if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) { + return false; + } + if (super.tick(entity, runnable)) { + if (this.getDuration() <= MIN) { + Reflex.setFieldValue(this, "c", Integer.MAX_VALUE); + } + return true; + } + return false; + } +} diff --git a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java new file mode 100644 index 0000000..e5fdfdb --- /dev/null +++ b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java @@ -0,0 +1,80 @@ +package su.nightexpress.excellentenchants.nms.v1_19_R2; + +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_19_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_19_R2.event.CraftEventFactory; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityPotionEffectEvent; +import org.bukkit.potion.PotionEffect; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nightexpress.excellentenchants.nms.EnchantNMS; + +import java.util.HashSet; +import java.util.Set; + +public class V1_19_R2 implements EnchantNMS { + + @Override + public void addEnchantmentEffect(@NotNull LivingEntity entity, @NotNull Enchantment enchant, @NotNull PotionEffect effect) { + net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); + entity1.addEffect(new CustomEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getAmplifier(), enchant), EntityPotionEffectEvent.Cause.PLUGIN); + } + + @Override + @Nullable + public Enchantment getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect type) { + net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); + MobEffectInstance handle = entity1.getEffect(MobEffect.byId(type.getType().getId())); + if (handle instanceof CustomEffectInstance instance) { + return instance.getEnchantment(); + } + return null; + } + + @Override + @NotNull + public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { + Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle(); + BlockPos pos = new BlockPos(location.getX(), location.getY(), location.getZ()); + ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle(); + + float radius = Math.min(16F, 2F + level); + BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState(); + BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos(); + + Set blocks = new HashSet<>(); + for (BlockPos posNear : BlockPos.betweenClosed(pos.offset(-radius, -1.0, -radius), pos.offset(radius, -1.0, radius))) { + if (!posNear.closerThan(entity.blockPosition(), radius)) continue; + + posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ()); + + BlockState bLavaAbove = world.getBlockState(posAbove); + BlockState bLava = world.getBlockState(posNear); + + if (!bLavaAbove.isAir()) continue; + if (!bLava.getBlock().equals(Blocks.LAVA)) continue; + if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue; + if (!bStone.canSurvive(world, posNear)) continue; + if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue; + if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue; + //world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120)); + + Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ()); + blocks.add(bukkitLoc.getBlock()); + } + return blocks; + } +} diff --git a/pom.xml b/pom.xml index 4e37986..164146d 100644 --- a/pom.xml +++ b/pom.xml @@ -7,13 +7,14 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.2.8 + 3.2.11 Core NMS V1_17_R1 V1_18_R2 V1_19_R1 + V1_19_R2 From 39ec13296ec53f4c227b570f0e50ea4255d741a0 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Mon, 26 Dec 2022 22:10:54 +0600 Subject: [PATCH 20/69] v3.2.13 + engine update --- Core/pom.xml | 46 ++++++- .../excellentenchants/ExcellentEnchants.java | 9 +- .../excellentenchants/Placeholders.java | 25 ++++ .../api/enchantment/ExcellentEnchant.java | 65 ++++------ .../enchantment/IEnchantChanceTemplate.java | 5 +- .../enchantment/IEnchantPotionTemplate.java | 4 +- .../command/BookCommand.java | 6 +- .../command/EnchantCommand.java | 6 +- .../command/ListCommand.java | 4 +- .../command/TierbookCommand.java | 3 +- .../excellentenchants/hook/ProtocolHook.java | 115 ++++++++++++++++++ .../manager/EnchantManager.java | 21 ++-- .../manager/EnchantRegister.java | 2 +- .../armor/EnchantElementalProtection.java | 4 +- .../enchants/armor/EnchantFireShield.java | 2 +- .../enchants/armor/EnchantFlameWalker.java | 5 +- .../enchants/armor/EnchantRegrowth.java | 4 +- .../enchants/armor/EnchantSaturation.java | 6 +- .../armor/EnchantSelfDestruction.java | 2 +- .../manager/enchants/bow/EnchantBomber.java | 2 +- .../enchants/bow/EnchantExplosiveArrows.java | 2 +- .../manager/enchants/bow/EnchantGhast.java | 7 +- .../enchants/tool/EnchantBlastMining.java | 5 +- .../enchants/tool/EnchantCurseOfBreaking.java | 2 +- .../enchants/tool/EnchantLuckyMiner.java | 2 +- .../enchants/tool/EnchantTreasures.java | 4 +- .../enchants/tool/EnchantVeinminer.java | 2 +- .../weapon/EnchantBaneOfNetherspawn.java | 10 +- .../enchants/weapon/EnchantCutter.java | 2 +- .../enchants/weapon/EnchantExpHunter.java | 2 +- .../enchants/weapon/EnchantInfernus.java | 2 +- .../enchants/weapon/EnchantRocket.java | 2 +- .../enchants/weapon/EnchantVampire.java | 11 +- .../weapon/EnchantVillageDefender.java | 8 +- .../listeners/EnchantGenericListener.java | 6 +- .../listeners/EnchantHandlerListener.java | 4 +- .../manager/object/EnchantListGUI.java | 23 ++-- .../manager/object/EnchantScaler.java | 5 +- Core/src/main/resources/plugin.yml | 2 +- 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 +- .../nms/v1_19_R2/CustomEffectInstance.java | 2 +- pom.xml | 4 +- 46 files changed, 316 insertions(+), 145 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/hook/ProtocolHook.java diff --git a/Core/pom.xml b/Core/pom.xml index 92ec565..f469c75 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.11 + 3.2.13 4.0.0 @@ -25,6 +25,10 @@ sk89q-repo https://maven.enginehub.org/repo/ + + dmulloy2-repo + https://repo.dmulloy2.net/repository/public/ + @@ -33,30 +37,35 @@ spigot-api 1.19.3-R0.1-SNAPSHOT + + su.nexmedia.playerblocktracker + PlayerBlockTracker + 1.0.1 + su.nightexpress.excellentenchants NMS - 3.2.11 + 3.2.13 su.nightexpress.excellentenchants V1_17_R1 - 3.2.11 + 3.2.13 su.nightexpress.excellentenchants V1_18_R2 - 3.2.11 + 3.2.13 su.nightexpress.excellentenchants V1_19_R1 - 3.2.11 + 3.2.13 su.nightexpress.excellentenchants V1_19_R2 - 3.2.11 + 3.2.13 fr.neatmonster @@ -70,6 +79,11 @@ 7.0.6 provided + + com.comphenix.protocol + ProtocolLib + 5.0.0-SNAPSHOT + @@ -84,6 +98,19 @@ org.apache.maven.plugins maven-shade-plugin 3.2.4 + + + + org.ow2.asm + asm + 9.2 + + + org.ow2.asm + asm-commons + 9.2 + + package @@ -95,8 +122,15 @@ su.nightexpress.excellentenchants* + su.nexmedia.playerblocktracker:* + + + su.nexmedia.playerblocktracker. + su.nightexpress.excellentenchants.playerblocktracker. + + diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 625c630..b4e5156 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -6,12 +6,14 @@ import su.nexmedia.engine.NexPlugin; import su.nexmedia.engine.Version; import su.nexmedia.engine.api.command.GeneralCommand; import su.nexmedia.engine.command.list.ReloadSubCommand; +import su.nexmedia.engine.hooks.Hooks; import su.nightexpress.excellentenchants.command.BookCommand; import su.nightexpress.excellentenchants.command.EnchantCommand; import su.nightexpress.excellentenchants.command.ListCommand; import su.nightexpress.excellentenchants.command.TierbookCommand; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.config.Lang; +import su.nightexpress.excellentenchants.hook.ProtocolHook; import su.nightexpress.excellentenchants.manager.EnchantManager; import su.nightexpress.excellentenchants.manager.type.FitItemType; import su.nightexpress.excellentenchants.nms.EnchantNMS; @@ -87,7 +89,12 @@ public class ExcellentEnchants extends NexPlugin { @Override public void registerHooks() { - + if (Hooks.hasPlugin("ProtocolLib")) { + ProtocolHook.setup(); + } + else { + this.warn("ProtocolLib is not installed. Enchantments won't be displayed on items."); + } } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java new file mode 100644 index 0000000..5656606 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java @@ -0,0 +1,25 @@ +package su.nightexpress.excellentenchants; + +public class Placeholders extends su.nexmedia.engine.utils.Placeholders { + + public static final String URL_WIKI = "https://github.com/nulli0n/ExcellentEnchants-spigot/wiki/"; + public static final String URL_PLACEHOLDERS = URL_WIKI + "Internal-Placeholders"; + public static final String URL_ENGINE_SCALE = "https://github.com/nulli0n/NexEngine-spigot/wiki/Configuration-Tips#scalable-sections"; + + public static final String ENCHANTMENT_NAME = "%enchantment_name%"; + public static final String ENCHANTMENT_NAME_FORMATTED = "%enchantment_name_formatted%"; + public static final String ENCHANTMENT_DESCRIPTION = "%enchantment_description%"; + public static final String ENCHANTMENT_LEVEL = "%enchantment_level%"; + public static final String ENCHANTMENT_LEVEL_MIN = "%enchantment_level_min%"; + public static final String ENCHANTMENT_LEVEL_MAX = "%enchantment_level_max%"; + public static final String ENCHANTMENT_CONFLICTS = "%enchantment_conflicts%"; + public static final String ENCHANTMENT_TARGET = "%enchantment_target%"; + public static final String ENCHANTMENT_TIER = "%enchantment_tier%"; + public static final String ENCHANTMENT_FIT_ITEM_TYPES = "%enchantment_fit_item_types%"; + public static final String ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING = "%enchantment_obtain_chance_enchanting%"; + public static final String ENCHANTMENT_OBTAIN_CHANCE_VILLAGER = "%enchantment_obtain_chance_villager%"; + public static final String ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION = "%enchantment_obtain_chance_loot_generation%"; + public static final String ENCHANTMENT_OBTAIN_CHANCE_FISHING = "%enchantment_obtain_chance_fishing%"; + public static final String ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING = "%enchantment_obtain_chance_mob_spawning%"; + public static final String ENCHANTMENT_COST_ITEM = "%enchantment_cost_item%"; +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index a07789a..04b006e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -11,9 +11,7 @@ import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.IListener; import su.nexmedia.engine.lang.LangManager; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.*; -import su.nexmedia.engine.utils.data.Pair; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.config.Config; @@ -23,6 +21,7 @@ import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import su.nightexpress.excellentenchants.manager.object.EnchantTier; import su.nightexpress.excellentenchants.manager.type.FitItemType; import su.nightexpress.excellentenchants.manager.type.ObtainType; +import su.nightexpress.excellentenchants.Placeholders; import java.util.*; import java.util.function.UnaryOperator; @@ -31,23 +30,6 @@ import java.util.stream.Stream; public abstract class ExcellentEnchant extends Enchantment implements IListener { - public static final String PLACEHOLDER_NAME = "%enchantment_name%"; - public static final String PLACEHOLDER_NAME_FORMATTED = "%enchantment_name_formatted%"; - public static final String PLACEHOLDER_DESCRIPTION = "%enchantment_description%"; - public static final String PLACEHOLDER_LEVEL = "%enchantment_level%"; - public static final String PLACEHOLDER_LEVEL_MIN = "%enchantment_level_min%"; - public static final String PLACEHOLDER_LEVEL_MAX = "%enchantment_level_max%"; - public static final String PLACEHOLDER_CONFLICTS = "%enchantment_conflicts%"; - public static final String PLACEHOLDER_TARGET = "%enchantment_target%"; - public static final String PLACEHOLDER_TIER = "%enchantment_tier%"; - public static final String PLACEHOLDER_FIT_ITEM_TYPES = "%enchantment_fit_item_types%"; - public static final String PLACEHOLDER_OBTAIN_CHANCE_ENCHANTING = "%enchantment_obtain_chance_enchanting%"; - public static final String PLACEHOLDER_OBTAIN_CHANCE_VILLAGER = "%enchantment_obtain_chance_villager%"; - public static final String PLACEHOLDER_OBTAIN_CHANCE_LOOT_GENERATION = "%enchantment_obtain_chance_loot_generation%"; - public static final String PLACEHOLDER_OBTAIN_CHANCE_FISHING = "%enchantment_obtain_chance_fishing%"; - public static final String PLACEHOLDER_OBTAIN_CHANCE_MOB_SPAWNING = "%enchantment_obtain_chance_mob_spawning%"; - public static final String PLACEHOLDER_COST_ITEM = "%enchantment_cost_item%"; - protected final ExcellentEnchants plugin; protected final JYML cfg; protected final String id; @@ -113,6 +95,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener this.costItem = cfg.getItem("Settings.Cost.Item"); } + @Deprecated protected void updateConfig() { cfg.addMissing("Is_Treasure", false); cfg.addMissing("Conflicts", new ArrayList()); @@ -192,28 +175,34 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener String conflicts = this.getConflicts().isEmpty() ? plugin.getMessage(Lang.OTHER_NONE).getLocalized() : this.getConflicts().stream().filter(Objects::nonNull).map(LangManager::getEnchantment).collect(Collectors.joining("\n")); return str -> str - .replace(PLACEHOLDER_NAME, this.getDisplayName()) - .replace(PLACEHOLDER_NAME_FORMATTED, this.getNameFormatted(level)) - .replace(PLACEHOLDER_LEVEL, NumberUtil.toRoman(level)) - .replace(PLACEHOLDER_LEVEL_MIN, String.valueOf(this.getStartLevel())) - .replace(PLACEHOLDER_LEVEL_MAX, String.valueOf(this.getMaxLevel())) - .replace(PLACEHOLDER_TARGET, plugin.getLangManager().getEnum(this.getItemTarget())) - .replace(PLACEHOLDER_TIER, this.getTier().getName()) - .replace(PLACEHOLDER_CONFLICTS, conflicts) - .replace(PLACEHOLDER_FIT_ITEM_TYPES, String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList())) - .replace(PLACEHOLDER_OBTAIN_CHANCE_ENCHANTING, NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING))) - .replace(PLACEHOLDER_OBTAIN_CHANCE_VILLAGER, NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER))) - .replace(PLACEHOLDER_OBTAIN_CHANCE_LOOT_GENERATION, NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION))) - .replace(PLACEHOLDER_OBTAIN_CHANCE_FISHING, NumberUtil.format(this.getObtainChance(ObtainType.FISHING))) - .replace(PLACEHOLDER_OBTAIN_CHANCE_MOB_SPAWNING, NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING))) - .replace(PLACEHOLDER_COST_ITEM, this.hasCostItem() ? ItemUtil.getItemName(this.costItem) : plugin.getMessage(Lang.OTHER_NONE).getLocalized()) + .replace(Placeholders.ENCHANTMENT_NAME, this.getDisplayName()) + .replace(Placeholders.ENCHANTMENT_NAME_FORMATTED, this.getNameFormatted(level)) + .replace(Placeholders.ENCHANTMENT_LEVEL, NumberUtil.toRoman(level)) + .replace(Placeholders.ENCHANTMENT_LEVEL_MIN, String.valueOf(this.getStartLevel())) + .replace(Placeholders.ENCHANTMENT_LEVEL_MAX, String.valueOf(this.getMaxLevel())) + .replace(Placeholders.ENCHANTMENT_TARGET, plugin.getLangManager().getEnum(this.getItemTarget())) + .replace(Placeholders.ENCHANTMENT_TIER, this.getTier().getName()) + .replace(Placeholders.ENCHANTMENT_CONFLICTS, conflicts) + .replace(Placeholders.ENCHANTMENT_FIT_ITEM_TYPES, String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList())) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING, NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING))) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_VILLAGER, NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER))) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION, NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION))) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_FISHING, NumberUtil.format(this.getObtainChance(ObtainType.FISHING))) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING, NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING))) + .replace(Placeholders.ENCHANTMENT_COST_ITEM, this.hasCostItem() ? ItemUtil.getItemName(this.costItem) : plugin.getMessage(Lang.OTHER_NONE).getLocalized()) ; } + @Override + public void registerListeners() { + this.addConflicts(); + this.plugin.getPluginManager().registerEvents(this, plugin); + } + @NotNull public UnaryOperator formatString(int level) { return str -> this.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_DESCRIPTION, String.join("\n", Config.formatDescription(this.getDescription()))) + .replace(Placeholders.ENCHANTMENT_DESCRIPTION, String.join("\n", Config.formatDescription(this.getDescription()))) ); } @@ -246,12 +235,6 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener return !Config.isEnchantmentDisabled(this, entity.getWorld().getName()); } - @Override - public void registerListeners() { - this.addConflicts(); - this.plugin.getPluginManager().registerEvents(this, plugin); - } - @NotNull public JYML getConfig() { return this.cfg; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java index c3368f3..a05254e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java @@ -2,10 +2,11 @@ package su.nightexpress.excellentenchants.api.enchantment; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.manager.object.EnchantScaler; import java.util.function.UnaryOperator; @@ -31,7 +32,7 @@ public abstract class IEnchantChanceTemplate extends ExcellentEnchant { super.updateConfig(); if (cfg.contains("settings.enchant-trigger-chance")) { - String triggerChance = cfg.getString("settings.enchant-trigger-chance", "100").replace("%level%", PLACEHOLDER_LEVEL); + String triggerChance = cfg.getString("settings.enchant-trigger-chance", "100").replace("%level%", Placeholders.ENCHANTMENT_LEVEL); cfg.set("Settings.Trigger_Chance", triggerChance); cfg.set("settings.enchant-trigger-chance", null); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java index 7cd66c7..bc9bb1c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java @@ -6,8 +6,8 @@ import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.lang.LangManager; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.manager.EnchantManager; @@ -21,7 +21,7 @@ public abstract class IEnchantPotionTemplate extends IEnchantChanceTemplate { public static final String PLACEHOLDER_POTION_DURATION = "%enchantment_potion_duration%"; public static final String PLACEHOLDER_POTION_TYPE = "%enchantment_potion_type%"; - protected PotionEffectType potionEffectType; + protected PotionEffectType potionEffectType; protected final boolean potionParticles; protected Scaler potionDuration; protected Scaler potionLevel; 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 7fa3fa3..669c5e9 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java @@ -16,10 +16,10 @@ import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Perms; import su.nightexpress.excellentenchants.config.Lang; -import su.nightexpress.excellentenchants.manager.EnchantManager; import java.util.Arrays; import java.util.List; +import java.util.Map; public class BookCommand extends AbstractCommand { @@ -60,7 +60,7 @@ public class BookCommand extends AbstractCommand { } @Override - public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) { + public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args, @NotNull Map flags) { if (args.length != 4) { this.printUsage(sender); return; @@ -90,7 +90,7 @@ public class BookCommand extends AbstractCommand { meta.addStoredEnchant(enchantment, level, true); item.setItemMeta(meta); - EnchantManager.updateItemLoreEnchants(item); + //EnchantManager.updateItemLoreEnchants(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 6533cd4..c714df1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java @@ -14,10 +14,10 @@ import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Perms; import su.nightexpress.excellentenchants.config.Lang; -import su.nightexpress.excellentenchants.manager.EnchantManager; import java.util.Arrays; import java.util.List; +import java.util.Map; public class EnchantCommand extends AbstractCommand { @@ -55,7 +55,7 @@ public class EnchantCommand extends AbstractCommand { } @Override - public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) { + public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args, @NotNull Map flags) { if (args.length != 3) { this.printUsage(sender); return; @@ -99,7 +99,7 @@ public class EnchantCommand extends AbstractCommand { } } item.setItemMeta(meta); - EnchantManager.updateItemLoreEnchants(item); + //EnchantManager.updateItemLoreEnchants(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 54ca8ab..259dce4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/ListCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/ListCommand.java @@ -8,6 +8,8 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Perms; import su.nightexpress.excellentenchants.config.Lang; +import java.util.Map; + public class ListCommand extends AbstractCommand { public ListCommand(@NotNull ExcellentEnchants plugin) { @@ -32,7 +34,7 @@ public class ListCommand extends AbstractCommand { } @Override - protected void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) { + protected void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args, @NotNull Map flags) { 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 f1b2d91..a38a5a7 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java @@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.manager.object.EnchantTier; import java.util.Arrays; import java.util.List; +import java.util.Map; public class TierbookCommand extends AbstractCommand { @@ -58,7 +59,7 @@ public class TierbookCommand extends AbstractCommand { } @Override - public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) { + public void onExecute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args, @NotNull Map flags) { if (args.length != 4) { this.printUsage(sender); return; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/hook/ProtocolHook.java b/Core/src/main/java/su/nightexpress/excellentenchants/hook/ProtocolHook.java new file mode 100644 index 0000000..54fbf43 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/ProtocolHook.java @@ -0,0 +1,115 @@ +package su.nightexpress.excellentenchants.hook; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.ProtocolManager; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import org.bukkit.GameMode; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.utils.ItemUtil; +import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.manager.EnchantManager; + +import java.util.List; +import java.util.Map; + +public class ProtocolHook { + + private static boolean isRegistered = false; + + public static void setup() { + if (isRegistered) return; + + ProtocolManager manager = ProtocolLibrary.getProtocolManager(); + manager.addPacketListener(new PacketAdapter(ExcellentEnchantsAPI.PLUGIN, PacketType.Play.Server.SET_SLOT) { + @Override + public void onPacketSending(PacketEvent event) { + PacketContainer packet = event.getPacket(); + + ItemStack item = packet.getItemModifier().read(0); + boolean removeOld = event.getPlayer().getGameMode() == GameMode.CREATIVE; + if (removeOld) { + packet.getItemModifier().write(0, remove(item)); + } + else { + packet.getItemModifier().write(0, update(item)); + } + } + }); + + manager.addPacketListener(new PacketAdapter(ExcellentEnchantsAPI.PLUGIN, PacketType.Play.Server.WINDOW_ITEMS) { + @Override + public void onPacketSending(PacketEvent event) { + PacketContainer packet = event.getPacket(); + + List items = packet.getItemListModifier().readSafely(0); + boolean removeOld = event.getPlayer().getGameMode() == GameMode.CREATIVE; + + for (int index = 0; index < items.size(); index++) { + if (removeOld) { + items.set(index, remove(items.get(index))); + } + else { + items.set(index, update(items.get(index))); + } + } + packet.getItemListModifier().write(0, items); + } + }); + + isRegistered = true; + } + + @Nullable + private static ItemStack update(@Nullable ItemStack item) { + if (item == null || item.getType().isAir()) return item; + + ItemStack copy = new ItemStack(item); + ItemMeta meta = copy.getItemMeta(); + if (meta == null) return item; + + List lore = ItemUtil.getLore(copy); + Map enchants = EnchantManager.getItemCustomEnchants(item); + //if (enchants.keySet().stream().anyMatch(enchant -> ItemUtil.getLoreTag(item, enchant.getId()) != null)) { + // return item; + //} + + if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED) { + enchants.forEach((enchant, integer) -> { + lore.addAll(0, Config.formatDescription(enchant.getDescription(integer))); + }); + } + enchants.forEach((enchant, integer) -> { + lore.add(0, enchant.getNameFormatted(integer)); + }); + + meta.setLore(lore); + copy.setItemMeta(meta); + return copy; + } + + @Nullable + private static ItemStack remove(@Nullable ItemStack item) { + if (item == null || item.getType().isAir()) return item; + + List from = ItemUtil.getLore(item); + Map enchants = EnchantManager.getItemCustomEnchants(item); + enchants.forEach((enchant, integer) -> { + from.removeIf(line -> line.equalsIgnoreCase(enchant.getNameFormatted(integer))); + from.removeAll(Config.formatDescription(enchant.getDescription(integer))); + }); + + ItemMeta meta = item.getItemMeta(); + if (meta == null) return item; + + meta.setLore(from); + item.setItemMeta(meta); + return item; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java index 65d448e..fc9b9e7 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java @@ -160,10 +160,11 @@ public class EnchantManager extends AbstractManager { return EnchantManager.getItemCustomEnchantsAmount(item) != enchantsHad; } + @Deprecated public static void updateItemLoreEnchants(@NotNull ItemStack item) { EnchantRegister.ENCHANT_LIST.forEach(ench -> { - ItemUtil.delLore(item, ench.getId()); - ItemUtil.delLore(item, ench.getId() + "_info"); + //ItemUtil.delLore(item, ench.getId()); + //ItemUtil.delLore(item, ench.getId() + "_info"); }); // Filter custom enchants and define map order. @@ -172,7 +173,7 @@ public class EnchantManager extends AbstractManager { .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (has, add) -> add, LinkedHashMap::new)); excellents.forEach((excellent, level) -> { - ItemUtil.addLore(item, excellent.getId(), excellent.getNameFormatted(level), 0); + //ItemUtil.addLore(item, excellent.getId(), excellent.getNameFormatted(level), 0); }); // Add enchantment description at the end of item lore. @@ -184,7 +185,7 @@ public class EnchantManager extends AbstractManager { List desc = excellent.getDescription(excellents.get(excellent)); if (desc.isEmpty()) return; - ItemUtil.addLore(item, excellent.getId() + "_info", Config.formatDescription(desc), -1); + //ItemUtil.addLore(item, excellent.getId() + "_info", Config.formatDescription(desc), -1); }); } } @@ -194,9 +195,9 @@ public class EnchantManager extends AbstractManager { EnchantManager.removeEnchant(item, enchantment); - if (enchantment instanceof ExcellentEnchant excellentEnchant) { - ItemUtil.addLore(item, excellentEnchant.getId(), excellentEnchant.getNameFormatted(level), 0); - } + //if (enchantment instanceof ExcellentEnchant excellentEnchant) { + //ItemUtil.addLore(item, excellentEnchant.getId(), excellentEnchant.getNameFormatted(level), 0); + //} ItemMeta meta = item.getItemMeta(); if (meta == null) return false; @@ -213,9 +214,9 @@ public class EnchantManager extends AbstractManager { } public static void removeEnchant(@NotNull ItemStack item, @NotNull Enchantment enchantment) { - if (enchantment instanceof ExcellentEnchant excellentEnchant) { - ItemUtil.delLore(item, excellentEnchant.getId()); - } + //if (enchantment instanceof ExcellentEnchant excellentEnchant) { + //ItemUtil.delLore(item, excellentEnchant.getId()); + //} ItemMeta meta = item.getItemMeta(); if (meta instanceof EnchantmentStorageMeta storageMeta) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java index 9187838..c95735e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java @@ -90,7 +90,7 @@ public class EnchantRegister { static { PLUGIN = ExcellentEnchants.getPlugin(ExcellentEnchants.class); - PLUGIN.getConfigManager().extract("enchants"); + PLUGIN.getConfigManager().extractResources("/enchants/"); ENCHANT_LIST = new HashSet<>(); // Tool enchants diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java index a6be031..801bc1a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java @@ -8,10 +8,10 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.ArrayUtil; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; @@ -83,7 +83,7 @@ public class EnchantElementalProtection extends IEnchantChanceTemplate { if (!this.isEnchantmentAvailable(victim)) return; double protectionAmount = 0D; - for (ItemStack armor : EntityUtil.getArmor(victim)) { + for (ItemStack armor : EntityUtil.getEquippedArmor(victim).values()) { if (armor == null || armor.getType().isAir()) continue; int level = EnchantManager.getItemEnchantLevel(armor, this); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFireShield.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFireShield.java index 229e278..d177944 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFireShield.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFireShield.java @@ -6,8 +6,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java index 0bca191..d4bfe21 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java @@ -19,10 +19,11 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.ICleanable; import su.nexmedia.engine.api.task.AbstractTask; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.Scaler; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.MoveEnchant; @@ -60,7 +61,7 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn protected void updateConfig() { super.updateConfig(); - cfg.addMissing("Settings.Block_Decay", "5.0 + " + PLACEHOLDER_LEVEL + " * 2"); + cfg.addMissing("Settings.Block_Decay", "5.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 2"); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java index decce70..eeda95e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java @@ -7,10 +7,10 @@ import org.bukkit.entity.LivingEntity; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.ICleanable; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; @@ -30,7 +30,7 @@ public class EnchantRegrowth extends IEnchantChanceTemplate implements PassiveEn private String particleData; private long healthInterval; private Scaler healthAmount; - private Task healthTask; + private Task healthTask; private static final String PLACEHOLDER_HEALTH_AMOUNT = "%enchantment_health_amount%"; private static final String PLACEHOLDER_HEALTH_INTERVAL = "%enchantment_health_interval%"; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java index 1a2dd17..7af96ca 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java @@ -6,8 +6,8 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.ICleanable; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; @@ -21,9 +21,9 @@ import java.util.function.UnaryOperator; public class EnchantSaturation extends IEnchantChanceTemplate implements PassiveEnchant, ICleanable { - private long saturationInterval; + private long saturationInterval; private Scaler saturationAmount; - private Task saturationTask; + private Task saturationTask; public static final String ID = "saturation"; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java index 42ff188..01def0c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java @@ -10,8 +10,8 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java index 380d136..3b3208a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java @@ -10,8 +10,8 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java index ea01d3b..11adde2 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java @@ -13,8 +13,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowTemplate; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java index 9f8d4f7..4e18d5f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java @@ -12,8 +12,9 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; @@ -23,7 +24,7 @@ import su.nightexpress.excellentenchants.manager.object.EnchantScaler; public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { private boolean fireSpread; - private Scaler yield; + private Scaler yield; public static final String ID = "ghast"; @@ -43,7 +44,7 @@ public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { super.updateConfig(); cfg.addMissing("Settings.Fire_Spread", true); - cfg.addMissing("Settings.Yield", "1.0 * " + PLACEHOLDER_LEVEL); + cfg.addMissing("Settings.Yield", "1.0 * " + Placeholders.ENCHANTMENT_LEVEL); } public boolean isFireSpread() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java index e6061ae..f28dab5 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java @@ -14,9 +14,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; @@ -68,7 +69,7 @@ public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockB protected void updateConfig() { super.updateConfig(); - cfg.addMissing("Settings.Min_Block_Strength", "1.5 - " + PLACEHOLDER_LEVEL + " / 10.0"); + cfg.addMissing("Settings.Min_Block_Strength", "1.5 - " + Placeholders.ENCHANTMENT_LEVEL + " / 10.0"); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java index 8ca176b..0c00d63 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java @@ -8,8 +8,8 @@ import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java index 890b7f7..1c31f34 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java @@ -6,8 +6,8 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java index e437b16..fbef4b8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java @@ -13,11 +13,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.ICleanable; -import su.nexmedia.engine.manager.player.blocktracker.PlayerBlockTracker; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.LocationUtil; import su.nexmedia.engine.utils.MessageUtil; import su.nexmedia.engine.utils.random.Rnd; +import su.nexmedia.playerblocktracker.PlayerBlockTracker; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; @@ -42,7 +42,7 @@ public class EnchantTreasures extends IEnchantChanceTemplate implements CustomDr public EnchantTreasures(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { super(plugin, cfg, EnchantPriority.MEDIUM); - PlayerBlockTracker.initialize(); + PlayerBlockTracker.initialize(plugin); PlayerBlockTracker.BLOCK_FILTERS.add(this.blockTracker = (block) -> { return this.getTreasure(block.getType()) != null; }); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java index 82034cf..62894bf 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java @@ -11,9 +11,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.LocationUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java index ca40ac4..d6cc057 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java @@ -9,9 +9,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; @@ -23,10 +23,10 @@ import java.util.function.UnaryOperator; public class EnchantBaneOfNetherspawn extends IEnchantChanceTemplate implements CombatEnchant { - private String particleName; - private String particleData; - private boolean damageModifier; - private Scaler damageFormula; + private String particleName; + private String particleData; + private boolean damageModifier; + private Scaler damageFormula; private final Set entityTypes; public static final String ID = "bane_of_netherspawn"; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java index 2f25103..ec49c0f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java @@ -12,10 +12,10 @@ import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.MessageUtil; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java index 79caf87..aff8142 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java @@ -6,8 +6,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDeathEvent; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java index 720188c..ba30988 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java @@ -11,8 +11,8 @@ import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java index 3b8842f..f7c397a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java @@ -9,9 +9,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.FireworkMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.MessageUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java index ed492c3..5bb11e0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java @@ -9,11 +9,12 @@ import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; @@ -23,9 +24,9 @@ import java.util.function.UnaryOperator; public class EnchantVampire extends IEnchantChanceTemplate implements CombatEnchant { - private String particleName; - private String particleData; - private Scaler healAmount; + private String particleName; + private String particleData; + private Scaler healAmount; private boolean healMultiplier; public static final String ID = "vampire"; @@ -60,7 +61,7 @@ public class EnchantVampire extends IEnchantChanceTemplate implements CombatEnch cfg.remove("Settings.Heal_Of_Damage"); cfg.addMissing("Settings.Particle.Name", Particle.HEART.name()); cfg.addMissing("Settings.Particle.Data", ""); - cfg.addMissing("Settings.Heal.Amount", "0.25 * " + PLACEHOLDER_LEVEL); + cfg.addMissing("Settings.Heal.Amount", "0.25 * " + Placeholders.ENCHANTMENT_LEVEL); cfg.addMissing("Settings.Heal.As_Multiplier", false); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java index 89740d4..e2ab391 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java @@ -8,9 +8,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.manager.leveling.Scaler; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; @@ -22,9 +22,9 @@ import java.util.function.UnaryOperator; public class EnchantVillageDefender extends IEnchantChanceTemplate implements CombatEnchant { private boolean damageMultiplier; - private Scaler damageAmount; - private String particleName; - private String particleData; + private Scaler damageAmount; + private String particleName; + private String particleData; public static final String ID = "village_defender"; public static final String PLACEHOLDER_DAMAGE_AMOUNT = "%enchantment_damage_amount%"; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java index c5552a6..e6660a9 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java @@ -102,7 +102,7 @@ public class EnchantGenericListener extends AbstractListener } if (!first.equals(result)) { - EnchantManager.updateItemLoreEnchants(result); + //EnchantManager.updateItemLoreEnchants(result); e.setResult(result); // NMS ContainerAnvil will set level cost to 0 right after calling the event @@ -148,7 +148,7 @@ public class EnchantGenericListener extends AbstractListener curses.forEach((excellentEnchant, level) -> { EnchantManager.addEnchant(result, excellentEnchant, level, true); }); - EnchantManager.updateItemLoreEnchants(result); + //EnchantManager.updateItemLoreEnchants(result); }); } @@ -181,7 +181,7 @@ public class EnchantGenericListener extends AbstractListener result.setItemMeta(storageMeta); } - EnchantManager.updateItemLoreEnchants(result); + //EnchantManager.updateItemLoreEnchants(result); e.getInventory().setItem(0, result); }); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java index b52cf56..51d6375 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java @@ -95,7 +95,7 @@ public class EnchantHandlerListener extends AbstractListener ItemStack weaponDamager = equipDamager.getItemInMainHand(); - for (ItemStack armor : EntityUtil.getArmor(victim)) { + for (ItemStack armor : EntityUtil.getEquippedArmor(victim).values()) { if (armor == null || armor.getType().isAir()) continue; EnchantManager.getItemCustomEnchants(armor, CombatEnchant.class).forEach((combatEnchant, level) -> { @@ -182,7 +182,7 @@ public class EnchantHandlerListener extends AbstractListener @EventHandler(priority = EventPriority.HIGHEST) public void onEnchantDeath(EntityDeathEvent e) { LivingEntity dead = e.getEntity(); - for (ItemStack armor : EntityUtil.getArmor(dead)) { + for (ItemStack armor : EntityUtil.getEquippedArmor(dead).values()) { if (armor == null || armor.getType().isAir()) continue; EnchantManager.getItemCustomEnchants(armor, DeathEnchant.class).forEach((deathEnchant, level) -> { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java index 66fdccf..22a93b8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java @@ -13,6 +13,7 @@ import su.nexmedia.engine.utils.CollectionsUtil; import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PDCUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Lang; import su.nightexpress.excellentenchants.manager.EnchantRegister; @@ -35,7 +36,7 @@ public class EnchantListGUI extends AbstractMenu { this.enchantIcon = cfg.getItem("Enchantments.Icon"); this.enchantSlots = cfg.getIntArray("Enchantments.Slots"); - IMenuClick click = (p, type, e) -> { + MenuClick click = (p, type, e) -> { if (type instanceof MenuItemType type2) { switch (type2) { case PAGE_NEXT -> this.open(p, this.getPage(p) + 1); @@ -46,10 +47,10 @@ public class EnchantListGUI extends AbstractMenu { }; for (String sId : cfg.getSection("Content")) { - IMenuItem menuItem = cfg.getMenuItem("Content." + sId); + MenuItem menuItem = cfg.getMenuItem("Content." + sId); if (menuItem.getType() != null) { - menuItem.setClick(click); + menuItem.setClickHandler(click); } this.addItem(menuItem); } @@ -69,13 +70,13 @@ public class EnchantListGUI extends AbstractMenu { : enchant.getConflicts().stream().filter(Objects::nonNull) .map(LangManager::getEnchantment).toList(); - ItemUtil.replaceLore(icon, ExcellentEnchant.PLACEHOLDER_CONFLICTS, conflicts); + ItemUtil.replaceLore(icon, Placeholders.ENCHANTMENT_CONFLICTS, conflicts); ItemUtil.replace(icon, enchant.formatString(level)); return icon; } @Override - public void onPrepare(@NotNull Player player, @NotNull Inventory inventory) { + public boolean onPrepare(@NotNull Player player, @NotNull Inventory inventory) { int page = this.getPage(player); int length = this.enchantSlots.length; List list = new ArrayList<>(EnchantRegister.ENCHANT_LIST.stream(). @@ -91,7 +92,7 @@ public class EnchantListGUI extends AbstractMenu { ItemStack icon = this.getEnchantIcon(enchant, 1); PDCUtil.setData(icon, this.keyLevel, 1); - IMenuClick click = (p, type, e) -> { + MenuClick click = (p, type, e) -> { if (!e.isLeftClick()) return; ItemStack itemClick = e.getCurrentItem(); @@ -107,16 +108,12 @@ public class EnchantListGUI extends AbstractMenu { e.setCurrentItem(itemClick); }; - IMenuItem menuItem = new MenuItem(icon, this.enchantSlots[count++]); - menuItem.setClick(click); + MenuItem menuItem = new MenuItem(icon, this.enchantSlots[count++]); + menuItem.setClickHandler(click); this.addItem(player, menuItem); } this.setPage(player, page, pages); - } - - @Override - public void onReady(@NotNull Player player, @NotNull Inventory inventory) { - + return true; } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantScaler.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantScaler.java index a0dfb67..200df18 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantScaler.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantScaler.java @@ -1,12 +1,13 @@ package su.nightexpress.excellentenchants.manager.object; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.manager.leveling.Scaler; +import su.nexmedia.engine.utils.Scaler; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; public class EnchantScaler extends Scaler { public EnchantScaler(@NotNull ExcellentEnchant enchant, @NotNull String path) { - super(enchant.getConfig(), path, ExcellentEnchant.PLACEHOLDER_LEVEL, enchant.getStartLevel(), enchant.getMaxLevel()); + super(enchant.getConfig(), path, Placeholders.ENCHANTMENT_LEVEL, enchant.getStartLevel(), enchant.getMaxLevel()); } } diff --git a/Core/src/main/resources/plugin.yml b/Core/src/main/resources/plugin.yml index abbaa5d..66e9b82 100644 --- a/Core/src/main/resources/plugin.yml +++ b/Core/src/main/resources/plugin.yml @@ -4,7 +4,7 @@ name: ExcellentEnchants author: NightExpress desciption: Vanilla-like enchants for your server. depend: [ NexEngine ] -softdepend: [ Towny, Residence, WorldGuard, GriefPrevention, Lands ] +softdepend: [ ProtocolLib, Towny, Residence, WorldGuard, GriefPrevention, Lands ] api-version: 1.17 load: STARTUP diff --git a/NMS/pom.xml b/NMS/pom.xml index 6a0d505..5c8fd3d 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.11 + 3.2.13 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 989600f..39c989f 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.11 + 3.2.13 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.11 + 3.2.13 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 589949f..a5222ff 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.11 + 3.2.13 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.11 + 3.2.13 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index 6d6516e..53686f3 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.11 + 3.2.13 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.11 + 3.2.13 diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml index 61cad56..051da34 100644 --- a/V1_19_R2/pom.xml +++ b/V1_19_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.11 + 3.2.13 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.11 + 3.2.13 diff --git a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java index 7a7d20f..c4aca5b 100644 --- a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java +++ b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java @@ -15,7 +15,7 @@ public class CustomEffectInstance extends MobEffectInstance { private final Enchantment enchantment; public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { - super(effect, Integer.MAX_VALUE, amplifier); + super(effect, MIN * 2, amplifier); this.enchantment = enchantment; } diff --git a/pom.xml b/pom.xml index 164146d..51ff3c4 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.2.11 + 3.2.13 Core NMS @@ -26,7 +26,7 @@ su.nexmedia NexEngine - 2.2.7 + 2.2.8 From 6435834698c9a1ea6c344ec37e76dcbada29266c Mon Sep 17 00:00:00 2001 From: nulli0n Date: Tue, 27 Dec 2022 15:05:08 +0600 Subject: [PATCH 21/69] v3.2.14, packets improvements --- .../excellentenchants/hook/ProtocolHook.java | 59 ++++++------------- .../manager/EnchantManager.java | 18 +++++- .../manager/EnchantRegister.java | 24 ++++---- .../manager/object/EnchantListGUI.java | 2 +- 4 files changed, 50 insertions(+), 53 deletions(-) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/hook/ProtocolHook.java b/Core/src/main/java/su/nightexpress/excellentenchants/hook/ProtocolHook.java index 54fbf43..80ab216 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/hook/ProtocolHook.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/ProtocolHook.java @@ -10,12 +10,12 @@ import org.bukkit.GameMode; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.Nullable; -import su.nexmedia.engine.utils.ItemUtil; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.manager.EnchantManager; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -33,13 +33,10 @@ public class ProtocolHook { PacketContainer packet = event.getPacket(); ItemStack item = packet.getItemModifier().read(0); - boolean removeOld = event.getPlayer().getGameMode() == GameMode.CREATIVE; - if (removeOld) { - packet.getItemModifier().write(0, remove(item)); - } - else { - packet.getItemModifier().write(0, update(item)); - } + boolean isCreative = event.getPlayer().getGameMode() == GameMode.CREATIVE; + //else { + packet.getItemModifier().write(0, update(item, isCreative)); + //} } }); @@ -49,15 +46,11 @@ public class ProtocolHook { PacketContainer packet = event.getPacket(); List items = packet.getItemListModifier().readSafely(0); - boolean removeOld = event.getPlayer().getGameMode() == GameMode.CREATIVE; + boolean isCreative = event.getPlayer().getGameMode() == GameMode.CREATIVE; for (int index = 0; index < items.size(); index++) { - if (removeOld) { - items.set(index, remove(items.get(index))); - } - else { - items.set(index, update(items.get(index))); - } + ItemStack item = items.get(index); + items.set(index, update(item, isCreative)); } packet.getItemListModifier().write(0, items); } @@ -67,20 +60,23 @@ public class ProtocolHook { } @Nullable - private static ItemStack update(@Nullable ItemStack item) { + private static ItemStack update(@Nullable ItemStack item, boolean isCreative) { if (item == null || item.getType().isAir()) return item; ItemStack copy = new ItemStack(item); ItemMeta meta = copy.getItemMeta(); if (meta == null) return item; - List lore = ItemUtil.getLore(copy); - Map enchants = EnchantManager.getItemCustomEnchants(item); - //if (enchants.keySet().stream().anyMatch(enchant -> ItemUtil.getLoreTag(item, enchant.getId()) != null)) { - // return item; - //} + List lore = meta.getLore() == null ? new ArrayList<>() : meta.getLore(); + Map enchants = EnchantManager.getExcellentEnchantments(item); - if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED) { + enchants.keySet().forEach(enchant -> lore.removeIf(line -> line.contains(enchant.getDisplayName()))); + if (isCreative) { + enchants.forEach((enchant, integer) -> { + lore.removeAll(Config.formatDescription(enchant.getDescription(integer))); + }); + } + if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED && !isCreative) { enchants.forEach((enchant, integer) -> { lore.addAll(0, Config.formatDescription(enchant.getDescription(integer))); }); @@ -93,23 +89,4 @@ public class ProtocolHook { copy.setItemMeta(meta); return copy; } - - @Nullable - private static ItemStack remove(@Nullable ItemStack item) { - if (item == null || item.getType().isAir()) return item; - - List from = ItemUtil.getLore(item); - Map enchants = EnchantManager.getItemCustomEnchants(item); - enchants.forEach((enchant, integer) -> { - from.removeIf(line -> line.equalsIgnoreCase(enchant.getNameFormatted(integer))); - from.removeAll(Config.formatDescription(enchant.getDescription(integer))); - }); - - ItemMeta meta = item.getItemMeta(); - if (meta == null) return item; - - meta.setLore(from); - item.setItemMeta(meta); - return item; - } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java index fc9b9e7..7513811 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java @@ -14,6 +14,7 @@ import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.manager.AbstractManager; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.ItemUtil; +import su.nexmedia.engine.utils.Pair; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; @@ -162,7 +163,7 @@ public class EnchantManager extends AbstractManager { @Deprecated public static void updateItemLoreEnchants(@NotNull ItemStack item) { - EnchantRegister.ENCHANT_LIST.forEach(ench -> { + EnchantRegister.ENCHANT_REGISTRY.values().forEach(ench -> { //ItemUtil.delLore(item, ench.getId()); //ItemUtil.delLore(item, ench.getId() + "_info"); }); @@ -228,7 +229,9 @@ public class EnchantManager extends AbstractManager { item.setItemMeta(meta); } + // Too expensive @NotNull + @Deprecated public static Map getItemCustomEnchants(@NotNull ItemStack item) { return EnchantManager.getItemEnchants(item).entrySet().stream() .filter(entry -> entry.getKey() instanceof ExcellentEnchant) @@ -246,6 +249,7 @@ public class EnchantManager extends AbstractManager { .collect(Collectors.toMap(k -> (T) k.getKey(), Map.Entry::getValue, (old, nev) -> nev, LinkedHashMap::new)); } + @Deprecated public static int getItemCustomEnchantsAmount(@NotNull ItemStack item) { return EnchantManager.getItemCustomEnchants(item).size(); } @@ -256,6 +260,7 @@ public class EnchantManager extends AbstractManager { } @NotNull + @Deprecated public static Map getItemEnchants(@NotNull ItemStack item) { ItemMeta meta = item.getItemMeta(); if (meta == null) return Collections.emptyMap(); @@ -263,6 +268,7 @@ public class EnchantManager extends AbstractManager { return (meta instanceof EnchantmentStorageMeta meta2) ? meta2.getStoredEnchants() : meta.getEnchants(); } + @Deprecated public static int getItemEnchantsAmount(@NotNull ItemStack item) { return EnchantManager.getItemEnchants(item).size(); } @@ -278,6 +284,16 @@ public class EnchantManager extends AbstractManager { return meta.getEnchantLevel(enchant); } + @NotNull + public static Map getExcellentEnchantments(@NotNull ItemStack item) { + return EnchantManager.getItemEnchants(item).entrySet().stream() + .map(entry -> { + ExcellentEnchant ex = EnchantRegister.get(entry.getKey().getKey()); + return ex == null ? null : Pair.of(ex, entry.getValue()); + }).filter(Objects::nonNull) + .collect(Collectors.toMap(Pair::getFirst, Pair::getSecond, (old, nev) -> nev, LinkedHashMap::new)); + } + @Nullable public static ExcellentEnchant getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect effect) { Enchantment enchantment = ExcellentEnchantsAPI.PLUGIN.getEnchantNMS().getEnchantmentByEffect(entity, effect); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java index c95735e..2f18bbc 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java @@ -16,14 +16,13 @@ import su.nightexpress.excellentenchants.manager.enchants.tool.*; import su.nightexpress.excellentenchants.manager.enchants.weapon.*; import java.lang.reflect.Field; -import java.util.HashSet; +import java.util.HashMap; import java.util.Map; -import java.util.Set; public class EnchantRegister { - private static final ExcellentEnchants PLUGIN; - public static final Set ENCHANT_LIST; + private static final ExcellentEnchants PLUGIN; + public static final Map ENCHANT_REGISTRY; public static final EnchantBlastMining BLAST_MINING; public static final EnchantCurseOfBreaking CURSE_OF_BREAKING; @@ -91,7 +90,7 @@ public class EnchantRegister { static { PLUGIN = ExcellentEnchants.getPlugin(ExcellentEnchants.class); PLUGIN.getConfigManager().extractResources("/enchants/"); - ENCHANT_LIST = new HashSet<>(); + ENCHANT_REGISTRY = new HashMap<>(); // Tool enchants BLAST_MINING = init(EnchantBlastMining.class, EnchantBlastMining.ID); @@ -165,7 +164,7 @@ public class EnchantRegister { public static void setup() { // Prevent to register enchantments during the runtime. if (ExcellentEnchants.isLoaded) { - ENCHANT_LIST.forEach(ExcellentEnchant::loadConfig); + ENCHANT_REGISTRY.values().forEach(ExcellentEnchant::loadConfig); return; } @@ -186,7 +185,7 @@ public class EnchantRegister { } Enchantment.stopAcceptingRegistrations(); - PLUGIN.info("Enchants Registered: " + ENCHANT_LIST.size()); + PLUGIN.info("Enchants Registered: " + ENCHANT_REGISTRY.size()); ExcellentEnchants.isLoaded = true; } @@ -199,7 +198,7 @@ public class EnchantRegister { if (byKey == null || byName == null) return; - for (ExcellentEnchant enchant : ENCHANT_LIST) { + for (ExcellentEnchant enchant : ENCHANT_REGISTRY.values()) { if (enchant instanceof ICleanable cleanable) { cleanable.clear(); } @@ -208,10 +207,15 @@ public class EnchantRegister { byName.remove(enchant.getName()); enchant.unregisterListeners(); } - ENCHANT_LIST.clear(); + ENCHANT_REGISTRY.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) { String enchantId = id.toLowerCase(); @@ -231,7 +235,7 @@ public class EnchantRegister { if (enchant == null) return; Enchantment.registerEnchantment(enchant); - ENCHANT_LIST.add(enchant); + ENCHANT_REGISTRY.put(enchant.getKey(), enchant); enchant.registerListeners(); PLUGIN.info("Registered enchantment: " + enchant.getId()); //IRegistry.a(IRegistry.ENCHANTMENT, enchant.getId(), CraftEnchantment.getRaw(enchant)); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java index 22a93b8..aa6c268 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java @@ -79,7 +79,7 @@ public class EnchantListGUI extends AbstractMenu { public boolean onPrepare(@NotNull Player player, @NotNull Inventory inventory) { int page = this.getPage(player); int length = this.enchantSlots.length; - List list = new ArrayList<>(EnchantRegister.ENCHANT_LIST.stream(). + List list = new ArrayList<>(EnchantRegister.ENCHANT_REGISTRY.values().stream(). sorted(Comparator.comparing(ExcellentEnchant::getName)).toList()); List> split = CollectionsUtil.split(list, length); From 046c11924f6366a6162b6b25a3526d3d06d8bdce Mon Sep 17 00:00:00 2001 From: nulli0n Date: Sat, 21 Jan 2023 04:19:57 +0600 Subject: [PATCH 22/69] v3.3.0 --- Core/pom.xml | 12 +- .../excellentenchants/ExcellentEnchants.java | 33 +- .../ExcellentEnchantsAPI.java | 14 + .../nightexpress/excellentenchants/Perms.java | 24 +- .../excellentenchants/Placeholders.java | 22 +- .../api/enchantment/ExcellentEnchant.java | 387 ++++++++++-------- .../IEnchantBowPotionTemplate.java | 72 ---- .../api/enchantment/IEnchantBowTemplate.java | 92 ----- .../enchantment/IEnchantChanceTemplate.java | 56 --- .../IEnchantCombatPotionTemplate.java | 57 --- .../enchantment/IEnchantPotionTemplate.java | 90 ---- .../api/enchantment/IEnchantment.java | 78 ++++ .../api/enchantment/meta/Arrowed.java | 34 ++ .../api/enchantment/meta/Chanced.java | 21 + .../api/enchantment/meta/Potioned.java | 44 ++ .../enchantment/template/PotionEnchant.java | 36 ++ .../enchantment/type/BlockBreakEnchant.java | 5 +- .../enchantment/type/BlockDropEnchant.java | 7 +- .../api/enchantment/type/BowEnchant.java | 12 +- .../api/enchantment/type/CombatEnchant.java | 11 +- .../enchantment/type/CustomDropEnchant.java | 11 - .../api/enchantment/type/DamageEnchant.java | 12 + .../api/enchantment/type/DeathEnchant.java | 8 +- .../api/enchantment/type/InteractEnchant.java | 5 +- .../api/enchantment/type/MoveEnchant.java | 10 - .../api/enchantment/type/PassiveEnchant.java | 6 +- .../{ => util}/EnchantDropContainer.java | 2 +- .../{ => util}/EnchantPriority.java | 2 +- .../command/BookCommand.java | 16 +- .../command/EnchantCommand.java | 26 +- .../command/TierbookCommand.java | 16 +- .../excellentenchants/config/Config.java | 212 ++++------ .../excellentenchants/config/Lang.java | 7 +- .../config/ObtainSettings.java | 34 +- .../EnchantManager.java | 312 +++++++------- .../EnchantPopulator.java | 36 +- .../EnchantRegister.java | 118 +++--- .../enchantment/config/EnchantScaler.java | 30 ++ .../impl/armor/EnchantAquaman.java | 33 ++ .../impl/armor/EnchantBunnyHop.java | 33 ++ .../impl/armor/EnchantColdSteel.java | 56 +++ .../armor/EnchantElementalProtection.java | 72 ++-- .../impl/armor/EnchantFireShield.java | 86 ++++ .../impl}/armor/EnchantFlameWalker.java | 71 ++-- .../impl/armor/EnchantHardened.java | 56 +++ .../impl/armor/EnchantIceShield.java | 65 +++ .../impl/armor/EnchantNightVision.java | 33 ++ .../impl/armor/EnchantRegrowth.java | 134 ++++++ .../impl/armor/EnchantSaturation.java | 117 ++++++ .../impl}/armor/EnchantSelfDestruction.java | 58 ++- .../enchantment/impl/armor/EnchantSonic.java | 33 ++ .../impl}/bow/EnchantBomber.java | 56 +-- .../impl/bow/EnchantConfusingArrows.java | 76 ++++ .../impl/bow/EnchantDragonfireArrows.java | 133 ++++++ .../impl/bow/EnchantElectrifiedArrows.java | 92 +++++ .../enchantment/impl/bow/EnchantEnderBow.java | 51 +++ .../impl/bow/EnchantExplosiveArrows.java | 145 +++++++ .../impl}/bow/EnchantGhast.java | 59 ++- .../enchantment/impl/bow/EnchantHover.java | 76 ++++ .../impl/bow/EnchantPoisonedArrows.java | 76 ++++ .../impl/bow/EnchantWitheredArrows.java | 76 ++++ .../impl/meta/ArrowImplementation.java | 92 +++++ .../impl/meta/ChanceImplementation.java | 42 ++ .../impl/meta/PotionImplementation.java | 86 ++++ .../impl}/tool/EnchantBlastMining.java | 72 ++-- .../impl}/tool/EnchantCurseOfBreaking.java | 46 ++- .../impl/tool/EnchantCurseOfMisfortune.java | 90 ++++ .../impl}/tool/EnchantDivineTouch.java | 66 +-- .../enchantment/impl/tool/EnchantHaste.java | 33 ++ .../impl}/tool/EnchantLuckyMiner.java | 52 +-- .../impl}/tool/EnchantReplanter.java | 51 +-- .../impl}/tool/EnchantSilkChest.java | 111 ++--- .../impl}/tool/EnchantSmelter.java | 70 ++-- .../impl/tool/EnchantTelekinesis.java | 56 +++ .../impl/tool/EnchantTreasures.java | 121 ++++++ .../impl}/tool/EnchantTunnel.java | 44 +- .../impl}/tool/EnchantVeinminer.java | 61 +-- .../universal/EnchantCurseOfFragility.java | 77 ++++ .../impl/weapon/EnchantBaneOfNetherspawn.java | 87 ++++ .../impl/weapon/EnchantBlindness.java | 62 +++ .../impl/weapon/EnchantConfusion.java | 63 +++ .../enchantment/impl/weapon/EnchantCure.java | 78 ++++ .../impl}/weapon/EnchantCutter.java | 65 +-- .../impl/weapon/EnchantDecapitator.java | 143 +++++++ .../impl/weapon/EnchantDoubleStrike.java | 65 +++ .../impl/weapon/EnchantExhaust.java | 62 +++ .../impl}/weapon/EnchantExpHunter.java | 48 +-- .../impl/weapon/EnchantIceAspect.java | 48 +++ .../impl}/weapon/EnchantInfernus.java | 43 +- .../impl/weapon/EnchantNimble.java | 41 ++ .../impl/weapon/EnchantParalyze.java | 62 +++ .../enchantment/impl/weapon/EnchantRage.java | 62 +++ .../impl/weapon/EnchantRocket.java | 80 ++++ .../impl}/weapon/EnchantScavenger.java | 52 ++- .../impl/weapon/EnchantSurprise.java | 68 +++ .../impl}/weapon/EnchantTemper.java | 41 +- .../impl/weapon/EnchantThrifty.java | 110 +++++ .../impl/weapon/EnchantThunder.java | 70 ++++ .../impl}/weapon/EnchantVampire.java | 74 ++-- .../enchantment/impl/weapon/EnchantVenom.java | 62 +++ .../impl}/weapon/EnchantVillageDefender.java | 65 ++- .../impl/weapon/EnchantWither.java | 62 +++ .../listener/EnchantAnvilListener.java | 146 +++++++ .../listener}/EnchantGenericListener.java | 92 +---- .../listener}/EnchantHandlerListener.java | 193 +++++---- .../menu/EnchantmentsListMenu.java | 150 +++++++ .../task/AbstractEnchantmentTask.java | 31 ++ .../task}/ArrowTrailsTask.java | 24 +- .../enchantment/task/PotionEffectsTask.java | 21 + .../type/FitItemType.java | 12 +- .../type/ObtainType.java | 2 +- .../excellentenchants/hook/HookId.java | 1 + .../NoCheatPlusHook.java} | 5 +- .../hook/{ => impl}/ProtocolHook.java | 43 +- .../enchants/armor/EnchantAquaman.java | 35 -- .../enchants/armor/EnchantBunnyHop.java | 35 -- .../enchants/armor/EnchantColdSteel.java | 37 -- .../enchants/armor/EnchantFireShield.java | 67 --- .../enchants/armor/EnchantHardened.java | 37 -- .../enchants/armor/EnchantNightVision.java | 35 -- .../enchants/armor/EnchantRegrowth.java | 122 ------ .../enchants/armor/EnchantSaturation.java | 111 ----- .../manager/enchants/armor/EnchantSonic.java | 35 -- .../enchants/bow/EnchantConfusingArrows.java | 17 - .../enchants/bow/EnchantDragonfireArrows.java | 93 ----- .../bow/EnchantElectrifiedArrows.java | 50 --- .../manager/enchants/bow/EnchantEnderBow.java | 55 --- .../enchants/bow/EnchantExplosiveArrows.java | 107 ----- .../manager/enchants/bow/EnchantHover.java | 17 - .../enchants/bow/EnchantPoisonedArrows.java | 17 - .../enchants/bow/EnchantWitheredArrows.java | 17 - .../tool/EnchantCurseOfMisfortune.java | 79 ---- .../manager/enchants/tool/EnchantHaste.java | 35 -- .../enchants/tool/EnchantTelekinesis.java | 105 ----- .../enchants/tool/EnchantTreasures.java | 138 ------- .../weapon/EnchantBaneOfNetherspawn.java | 99 ----- .../enchants/weapon/EnchantBlindness.java | 17 - .../enchants/weapon/EnchantConfusion.java | 17 - .../manager/enchants/weapon/EnchantCure.java | 79 ---- .../enchants/weapon/EnchantDecapitator.java | 126 ------ .../enchants/weapon/EnchantDoubleStrike.java | 64 --- .../enchants/weapon/EnchantExhaust.java | 17 - .../enchants/weapon/EnchantIceAspect.java | 28 -- .../enchants/weapon/EnchantNimble.java | 43 -- .../enchants/weapon/EnchantParalyze.java | 17 - .../manager/enchants/weapon/EnchantRage.java | 25 -- .../enchants/weapon/EnchantRocket.java | 66 --- .../enchants/weapon/EnchantSurprise.java | 28 -- .../enchants/weapon/EnchantThrifty.java | 87 ---- .../enchants/weapon/EnchantThunder.java | 55 --- .../manager/enchants/weapon/EnchantVenom.java | 17 - .../enchants/weapon/EnchantWither.java | 17 - .../manager/object/EnchantListGUI.java | 123 ------ .../manager/object/EnchantScaler.java | 13 - .../tasks/AbstractEnchantPassiveTask.java | 43 -- .../tasks/EnchantEffectPassiveTask.java | 22 - .../EnchantTier.java => tier/Tier.java} | 40 +- .../excellentenchants/tier/TierManager.java | 98 +++++ Core/src/main/resources/config.yml | 164 +------- Core/src/main/resources/enchants/aquaman.yml | 102 +---- .../enchants/bane_of_netherspawn.yml | 109 +---- .../main/resources/enchants/blast_mining.yml | 99 +---- .../src/main/resources/enchants/blindness.yml | 106 +---- Core/src/main/resources/enchants/bomber.yml | 91 +--- .../src/main/resources/enchants/bunny_hop.yml | 105 +---- .../main/resources/enchants/cold_steel.yml | 99 +---- .../resources/enchants/confusing_arrows.yml | 106 +---- .../src/main/resources/enchants/confusion.yml | 106 +---- Core/src/main/resources/enchants/cure.yml | 100 +---- .../resources/enchants/curse_of_breaking.yml | 94 +---- .../resources/enchants/curse_of_fragility.yml | 7 + .../enchants/curse_of_misfortune.yml | 88 +--- Core/src/main/resources/enchants/cutter.yml | 97 +---- .../main/resources/enchants/decapitator.yml | 101 ----- .../main/resources/enchants/divine_touch.yml | 101 +---- .../main/resources/enchants/double_strike.yml | 98 +---- .../resources/enchants/dragonfire_arrows.yml | 110 +---- .../resources/enchants/electrified_arrows.yml | 97 +---- .../enchants/elemental_protection.yml | 104 +---- .../src/main/resources/enchants/ender_bow.yml | 91 +--- Core/src/main/resources/enchants/exhaust.yml | 104 +---- .../main/resources/enchants/exp_hunter.yml | 93 +---- .../resources/enchants/explosive_arrows.yml | 112 +---- .../main/resources/enchants/fire_shield.yml | 93 +---- .../main/resources/enchants/flame_walker.yml | 99 +---- Core/src/main/resources/enchants/ghast.yml | 97 +---- Core/src/main/resources/enchants/hardened.yml | 102 +---- Core/src/main/resources/enchants/haste.yml | 101 +---- Core/src/main/resources/enchants/hover.yml | 106 +---- .../main/resources/enchants/ice_aspect.yml | 107 +---- .../main/resources/enchants/ice_shield.yml | 13 + Core/src/main/resources/enchants/infernus.yml | 91 +--- .../main/resources/enchants/lucky_miner.yml | 93 +---- .../main/resources/enchants/night_vision.yml | 103 +---- Core/src/main/resources/enchants/nimble.yml | 89 +--- Core/src/main/resources/enchants/paralyze.yml | 106 +---- .../resources/enchants/poisoned_arrows.yml | 101 +---- Core/src/main/resources/enchants/rage.yml | 106 +---- Core/src/main/resources/enchants/regrowth.yml | 107 +---- .../src/main/resources/enchants/replanter.yml | 97 +---- Core/src/main/resources/enchants/rocket.yml | 87 ---- .../main/resources/enchants/saturation.yml | 98 +---- .../src/main/resources/enchants/scavenger.yml | 88 ---- .../resources/enchants/self_destruction.yml | 92 +---- .../main/resources/enchants/silk_chest.yml | 95 +---- Core/src/main/resources/enchants/smelter.yml | 112 +---- Core/src/main/resources/enchants/sonic.yml | 101 +---- Core/src/main/resources/enchants/surprise.yml | 107 +---- .../main/resources/enchants/telekinesis.yml | 93 +---- Core/src/main/resources/enchants/temper.yml | 108 +---- Core/src/main/resources/enchants/thrifty.yml | 99 +---- Core/src/main/resources/enchants/thunder.yml | 89 +--- .../src/main/resources/enchants/treasures.yml | 111 ----- Core/src/main/resources/enchants/tunnel.yml | 92 +---- Core/src/main/resources/enchants/vampire.yml | 106 +---- .../src/main/resources/enchants/veinminer.yml | 91 ---- Core/src/main/resources/enchants/venom.yml | 106 +---- .../resources/enchants/village_defender.yml | 108 +---- Core/src/main/resources/enchants/wither.yml | 106 +---- .../resources/enchants/withered_arrows.yml | 99 +---- Core/src/main/resources/gui.enchants.yml | 62 --- Core/src/main/resources/lang/messages_ru.yml | 78 ++-- .../src/main/resources/menu/enchants_list.yml | 71 ++++ Core/src/main/resources/plugin.yml | 2 +- Core/src/main/resources/tiers.yml | 50 +++ NMS/pom.xml | 2 +- .../excellentenchants/nms/EnchantNMS.java | 24 +- V1_17_R1/pom.xml | 4 +- .../nms/v1_17_R1/CustomEffectInstance.java | 8 +- V1_18_R2/pom.xml | 4 +- .../nms/v1_18_R2/CustomEffectInstance.java | 8 +- V1_19_R1/pom.xml | 4 +- .../nms/v1_19_R1/CustomEffectInstance.java | 8 +- V1_19_R2/pom.xml | 4 +- .../nms/v1_19_R2/CustomEffectInstance.java | 6 +- pom.xml | 2 +- 236 files changed, 5808 insertions(+), 10157 deletions(-) delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowPotionTemplate.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantCombatPotionTemplate.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantment.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Arrowed.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Chanced.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Potioned.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/template/PotionEnchant.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CustomDropEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DamageEnchant.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/MoveEnchant.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%) rename Core/src/main/java/su/nightexpress/excellentenchants/{manager => enchantment}/EnchantManager.java (50%) rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/object => enchantment}/EnchantPopulator.java (60%) rename Core/src/main/java/su/nightexpress/excellentenchants/{manager => enchantment}/EnchantRegister.java (70%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantScaler.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantAquaman.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantBunnyHop.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantColdSteel.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/armor/EnchantElementalProtection.java (50%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFireShield.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/armor/EnchantFlameWalker.java (66%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantHardened.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantIceShield.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantNightVision.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantRegrowth.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSaturation.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/armor/EnchantSelfDestruction.java (50%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSonic.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/bow/EnchantBomber.java (52%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantConfusingArrows.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantDragonfireArrows.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantElectrifiedArrows.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantEnderBow.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantExplosiveArrows.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/bow/EnchantGhast.java (50%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantHover.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantPoisonedArrows.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantWitheredArrows.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/ArrowImplementation.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/ChanceImplementation.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PotionImplementation.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/tool/EnchantBlastMining.java (69%) rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/tool/EnchantCurseOfBreaking.java (54%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfMisfortune.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/tool/EnchantDivineTouch.java (60%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantHaste.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/tool/EnchantLuckyMiner.java (51%) rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/tool/EnchantReplanter.java (79%) rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/tool/EnchantSilkChest.java (57%) rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/tool/EnchantSmelter.java (55%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTelekinesis.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTreasures.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/tool/EnchantTunnel.java (77%) rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/tool/EnchantVeinminer.java (69%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/EnchantCurseOfFragility.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBaneOfNetherspawn.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBlindness.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantConfusion.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCure.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/weapon/EnchantCutter.java (56%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDecapitator.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDoubleStrike.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExhaust.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/weapon/EnchantExpHunter.java (55%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantIceAspect.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/weapon/EnchantInfernus.java (66%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantNimble.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantParalyze.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRage.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRocket.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/weapon/EnchantScavenger.java (61%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantSurprise.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/weapon/EnchantTemper.java (64%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThrifty.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThunder.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/weapon/EnchantVampire.java (55%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVenom.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/enchants => enchantment/impl}/weapon/EnchantVillageDefender.java (50%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantWither.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantAnvilListener.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/listeners => enchantment/listener}/EnchantGenericListener.java (66%) rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/listeners => enchantment/listener}/EnchantHandlerListener.java (53%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/menu/EnchantmentsListMenu.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/AbstractEnchantmentTask.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/tasks => enchantment/task}/ArrowTrailsTask.java (52%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PotionEffectsTask.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager => enchantment}/type/FitItemType.java (81%) rename Core/src/main/java/su/nightexpress/excellentenchants/{manager => enchantment}/type/ObtainType.java (87%) rename Core/src/main/java/su/nightexpress/excellentenchants/hook/{HookNCP.java => impl/NoCheatPlusHook.java} (85%) rename Core/src/main/java/su/nightexpress/excellentenchants/hook/{ => impl}/ProtocolHook.java (61%) delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantAquaman.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantBunnyHop.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantColdSteel.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFireShield.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantHardened.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantNightVision.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSonic.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantConfusingArrows.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantHover.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantHaste.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBlindness.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantConfusion.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCure.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDoubleStrike.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExhaust.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantIceAspect.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantNimble.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantParalyze.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRage.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantSurprise.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThrifty.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThunder.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVenom.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantWither.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantScaler.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/AbstractEnchantPassiveTask.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java rename Core/src/main/java/su/nightexpress/excellentenchants/{manager/object/EnchantTier.java => tier/Tier.java} (61%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java create mode 100644 Core/src/main/resources/enchants/curse_of_fragility.yml create mode 100644 Core/src/main/resources/enchants/ice_shield.yml delete mode 100644 Core/src/main/resources/gui.enchants.yml create mode 100644 Core/src/main/resources/menu/enchants_list.yml create mode 100644 Core/src/main/resources/tiers.yml diff --git a/Core/pom.xml b/Core/pom.xml index f469c75..5146a28 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.13 + 3.3.0 4.0.0 @@ -45,27 +45,27 @@ su.nightexpress.excellentenchants NMS - 3.2.13 + 3.3.0 su.nightexpress.excellentenchants V1_17_R1 - 3.2.13 + 3.3.0 su.nightexpress.excellentenchants V1_18_R2 - 3.2.13 + 3.3.0 su.nightexpress.excellentenchants V1_19_R1 - 3.2.13 + 3.3.0 su.nightexpress.excellentenchants V1_19_R2 - 3.2.13 + 3.3.0 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index b4e5156..92b344b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -1,6 +1,5 @@ package su.nightexpress.excellentenchants; -import org.bukkit.enchantments.EnchantmentTarget; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.NexPlugin; import su.nexmedia.engine.Version; @@ -13,14 +12,16 @@ import su.nightexpress.excellentenchants.command.ListCommand; import su.nightexpress.excellentenchants.command.TierbookCommand; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.config.Lang; -import su.nightexpress.excellentenchants.hook.ProtocolHook; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.type.FitItemType; +import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.type.FitItemType; +import su.nightexpress.excellentenchants.hook.HookId; +import su.nightexpress.excellentenchants.hook.impl.ProtocolHook; import su.nightexpress.excellentenchants.nms.EnchantNMS; import su.nightexpress.excellentenchants.nms.v1_17_R1.V1_17_R1; import su.nightexpress.excellentenchants.nms.v1_18_R2.V1_18_R2; import su.nightexpress.excellentenchants.nms.v1_19_R1.V1_19_R1; import su.nightexpress.excellentenchants.nms.v1_19_R2.V1_19_R2; +import su.nightexpress.excellentenchants.tier.TierManager; public class ExcellentEnchants extends NexPlugin { @@ -28,6 +29,7 @@ public class ExcellentEnchants extends NexPlugin { private EnchantNMS enchantNMS; private EnchantManager enchantManager; + private TierManager tierManager; @Override @NotNull @@ -43,6 +45,9 @@ public class ExcellentEnchants extends NexPlugin { return; } + this.tierManager = new TierManager(this); + this.tierManager.setup(); + this.enchantManager = new EnchantManager(this); this.enchantManager.setup(); } @@ -53,6 +58,10 @@ public class ExcellentEnchants extends NexPlugin { this.enchantManager.shutdown(); this.enchantManager = null; } + if (this.tierManager != null) { + this.tierManager.shutdown(); + this.tierManager = null; + } } private boolean setNMS() { @@ -67,13 +76,12 @@ public class ExcellentEnchants extends NexPlugin { @Override public void loadConfig() { - Config.load(this); + this.getConfig().initializeOptions(Config.class); } @Override public void loadLang() { this.getLangManager().loadMissing(Lang.class); - this.getLangManager().setupEnum(EnchantmentTarget.class); this.getLangManager().setupEnum(FitItemType.class); this.getLang().saveChanges(); } @@ -84,22 +92,27 @@ public class ExcellentEnchants extends NexPlugin { mainCommand.addChildren(new EnchantCommand(this)); mainCommand.addChildren(new ListCommand(this)); mainCommand.addChildren(new TierbookCommand(this)); - mainCommand.addChildren(new ReloadSubCommand<>(this, Perms.PREFIX + "admin")); + mainCommand.addChildren(new ReloadSubCommand<>(this, Perms.COMMAND_RELOAD)); } @Override public void registerHooks() { - if (Hooks.hasPlugin("ProtocolLib")) { + if (Hooks.hasPlugin(HookId.PROTOCOL_LIB)) { ProtocolHook.setup(); } else { - this.warn("ProtocolLib is not installed. Enchantments won't be displayed on items."); + this.warn(HookId.PROTOCOL_LIB + " is not installed. Enchantments won't be displayed on items."); } } @Override public void registerPermissions() { - // TODO + this.registerPermissions(Perms.class); + } + + @NotNull + public TierManager getTierManager() { + return tierManager; } @NotNull diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchantsAPI.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchantsAPI.java index f690fb8..a7ccda1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchantsAPI.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchantsAPI.java @@ -1,6 +1,20 @@ package su.nightexpress.excellentenchants; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.tier.TierManager; + public class ExcellentEnchantsAPI { public static final ExcellentEnchants PLUGIN = ExcellentEnchants.getPlugin(ExcellentEnchants.class); + + @NotNull + public static EnchantManager getEnchantManager() { + return PLUGIN.getEnchantManager(); + } + + @NotNull + public static TierManager getTierManager() { + return PLUGIN.getTierManager(); + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java b/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java index 463cfd5..0eea32d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java @@ -1,15 +1,25 @@ package su.nightexpress.excellentenchants; +import org.bukkit.permissions.PermissionDefault; +import su.nexmedia.engine.api.server.JPermission; + public class Perms { - public static final String PREFIX = "excellentenchants."; + private static final String PREFIX = "excellentenchants."; + private static final String PREFIX_COMMAND = PREFIX + "command."; - //public static final String ADMIN = PREFIX + "admin"; - //public static final String USER = PREFIX + "user"; + public static final JPermission PLUGIN = new JPermission(PREFIX + Placeholders.WILDCARD, "Access to all the plugin functions."); + public static final JPermission COMMAND = new JPermission(PREFIX_COMMAND + Placeholders.WILDCARD, "Access to all the plugin commands."); - public static final String COMMAND_BOOK = PREFIX + "command.book"; - public static final String COMMAND_ENCHANT = PREFIX + "command.enchant"; - public static final String COMMAND_LIST = PREFIX + "command.list"; - public static final String COMMAND_TIERBOOK = PREFIX + "command.tierbook"; + public static final JPermission COMMAND_BOOK = new JPermission(PREFIX_COMMAND + "book", "Allows to use '/eenchants book' command."); + public static final JPermission COMMAND_ENCHANT = new JPermission(PREFIX_COMMAND + "enchant", "Allows to use '/eenchants enchant' command."); + public static final JPermission COMMAND_LIST = new JPermission(PREFIX_COMMAND + "list", "Allows to use '/eenchants list' command.", PermissionDefault.TRUE); + public static final JPermission COMMAND_TIERBOOK = new JPermission(PREFIX_COMMAND + "tierbook", "Allows to use '/eenchants tierbook' command."); + public static final JPermission COMMAND_RELOAD = new JPermission(PREFIX_COMMAND + "reload", "Allows to use '/eenchants reload' command."); + static { + PLUGIN.addChildren(COMMAND); + + COMMAND.addChildren(COMMAND_BOOK, COMMAND_ENCHANT, COMMAND_LIST, COMMAND_RELOAD, COMMAND_TIERBOOK); + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java index 5656606..101247d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java @@ -2,9 +2,15 @@ package su.nightexpress.excellentenchants; public class Placeholders extends su.nexmedia.engine.utils.Placeholders { - public static final String URL_WIKI = "https://github.com/nulli0n/ExcellentEnchants-spigot/wiki/"; - public static final String URL_PLACEHOLDERS = URL_WIKI + "Internal-Placeholders"; - public static final String URL_ENGINE_SCALE = "https://github.com/nulli0n/NexEngine-spigot/wiki/Configuration-Tips#scalable-sections"; + public static final String URL_WIKI = "https://github.com/nulli0n/ExcellentEnchants-spigot/wiki/"; + public static final String URL_PLACEHOLDERS = URL_WIKI + "Internal-Placeholders"; + public static final String URL_ENGINE_SCALER = "https://github.com/nulli0n/NexEngine-spigot/wiki/Configuration-Tips#scalable-sections"; + public static final String URL_ENGINE_ITEMS = "https://github.com/nulli0n/NexEngine-spigot/wiki/Configuration-Tips#item-sections"; + + public static final String GENERIC_TYPE = "%type%"; + public static final String GENERIC_AMOUNT = "%amount%"; + public static final String GENERIC_DESCRIPTION = "%description%"; + public static final String GENERIC_ENCHANT = "%enchant%"; public static final String ENCHANTMENT_NAME = "%enchantment_name%"; public static final String ENCHANTMENT_NAME_FORMATTED = "%enchantment_name_formatted%"; @@ -12,8 +18,6 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders { public static final String ENCHANTMENT_LEVEL = "%enchantment_level%"; public static final String ENCHANTMENT_LEVEL_MIN = "%enchantment_level_min%"; public static final String ENCHANTMENT_LEVEL_MAX = "%enchantment_level_max%"; - public static final String ENCHANTMENT_CONFLICTS = "%enchantment_conflicts%"; - public static final String ENCHANTMENT_TARGET = "%enchantment_target%"; public static final String ENCHANTMENT_TIER = "%enchantment_tier%"; public static final String ENCHANTMENT_FIT_ITEM_TYPES = "%enchantment_fit_item_types%"; public static final String ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING = "%enchantment_obtain_chance_enchanting%"; @@ -21,5 +25,11 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders { public static final String ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION = "%enchantment_obtain_chance_loot_generation%"; public static final String ENCHANTMENT_OBTAIN_CHANCE_FISHING = "%enchantment_obtain_chance_fishing%"; public static final String ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING = "%enchantment_obtain_chance_mob_spawning%"; - public static final String ENCHANTMENT_COST_ITEM = "%enchantment_cost_item%"; + public static final String ENCHANTMENT_CHARGES_MAX_AMOUNT = "%enchantment_charges_max_amount%"; + public static final String ENCHANTMENT_CHARGES_CONSUME_AMOUNT = "%enchantment_charges_consume_amount%"; + public static final String ENCHANTMENT_CHARGES_RECHARGE_AMOUNT = "%enchantment_charges_recharge_amount%"; + 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%"; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index 04b006e..7d1b016 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -2,237 +2,211 @@ package su.nightexpress.excellentenchants.api.enchantment; import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.World; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; 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.Scaler; +import su.nexmedia.engine.utils.StringUtil; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.config.Config; -import su.nightexpress.excellentenchants.config.Lang; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; -import su.nightexpress.excellentenchants.manager.object.EnchantTier; -import su.nightexpress.excellentenchants.manager.type.FitItemType; -import su.nightexpress.excellentenchants.manager.type.ObtainType; import su.nightexpress.excellentenchants.Placeholders; +import 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.config.Config; +import su.nightexpress.excellentenchants.enchantment.EnchantManager; +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.config.EnchantScaler; +import su.nightexpress.excellentenchants.tier.Tier; import java.util.*; import java.util.function.UnaryOperator; -import java.util.stream.Collectors; import java.util.stream.Stream; -public abstract class ExcellentEnchant extends Enchantment implements IListener { +public abstract class ExcellentEnchant extends Enchantment implements IEnchantment, IListener { protected final ExcellentEnchants plugin; protected final JYML cfg; protected final String id; - protected final EnchantPriority priority; + protected final EnchantPriority priority; protected String displayName; - protected EnchantTier tier; + 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; - private final Set conflicts; - protected boolean isTreasure; - protected int levelMin; - protected int levelMax; - protected Scaler levelByEnchantCost; - protected Scaler anvilMergeCost; - protected Map obtainChance; - protected Map> obtainLevelCap; - protected ItemStack costItem; - protected boolean costEnabled; + protected boolean chargesEnabled; + protected boolean chargesCustomFuel; + protected EnchantScaler chargesMax; + protected EnchantScaler chargesConsumeAmount; + protected EnchantScaler chargesRechargeAmount; + protected ItemStack chargesFuel; + protected final NamespacedKey chargesKey; - public ExcellentEnchant(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, @NotNull EnchantPriority priority) { - super(NamespacedKey.minecraft(cfg.getFile().getName().replace(".yml", "").toLowerCase())); + 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 = cfg; - this.updateConfig(); - this.cfg.saveChanges(); + this.cfg = JYML.loadOrExtract(plugin, "/enchants/" + id + ".yml"); this.priority = priority; this.conflicts = new HashSet<>(); - - this.loadConfig(); + this.chargesKey = new NamespacedKey(plugin, this.getId() + ".charges"); } public void loadConfig() { this.cfg.reload(); - this.displayName = StringUtil.color(cfg.getString("Name", this.getId())); - this.tier = EnchantManager.getTierById(cfg.getString("Tier", Placeholders.DEFAULT)); + this.displayName = JOption.create("Name", StringUtil.capitalizeFully(this.getId().replace("_", " ")), + "Enchantment display name. It will be shown in item lore.").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) { - throw new IllegalStateException("Invalid tier provided for the '" + id + "' enchantment!"); + this.tier = Tier.DEFAULT; } this.tier.getEnchants().add(this); - this.description = StringUtil.color(cfg.getStringList("Description")); - this.isTreasure = cfg.getBoolean("Is_Treasure"); - this.levelMin = cfg.getInt("Level.Min"); - this.levelMax = cfg.getInt("Level.Max"); - this.levelByEnchantCost = new EnchantScaler(this, ObtainType.ENCHANTING.getPathName() + ".Level_By_Exp_Cost"); - this.anvilMergeCost = new EnchantScaler(this, "Anvil.Merge_Cost"); + 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).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 = cfg.getDouble(obtainType.getPathName() + ".Chance"); + 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 = cfg.getInt(obtainType.getPathName() + ".Level.Min", -1); - int levelMax = cfg.getInt(obtainType.getPathName() + ".Level.Max", -1); - this.obtainLevelCap.put(obtainType, Pair.of(levelMin, levelMax)); + 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.costEnabled = cfg.getBoolean("Settings.Cost.Enabled"); - this.costItem = cfg.getItem("Settings.Cost.Item"); - } - @Deprecated - protected void updateConfig() { - cfg.addMissing("Is_Treasure", false); - cfg.addMissing("Conflicts", new ArrayList()); - cfg.addMissing("Settings.Cost.Enabled", false); - cfg.addMissing("Settings.Cost.Item.Material", Material.AIR.name()); - cfg.addMissing("Settings.Cost.Item.Amount", 1); + 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); - if (cfg.contains("Enchantment_Table")) { - String path = ObtainType.ENCHANTING.getPathName() + "."; - cfg.addMissing(path + "Chance", cfg.getDouble("Enchantment_Table.Chance")); - cfg.addMissing(path + "Level_By_Exp_Cost", cfg.getString("Enchantment_Table.Level_By_Exp_Cost", "30")); - cfg.remove("Enchantment_Table"); + 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); } - - for (ObtainType obtainType : ObtainType.values()) { - cfg.addMissing(obtainType.getPathName() + ".Chance", 25D); - cfg.addMissing(obtainType.getPathName() + ".Level.Min", -1); - cfg.addMissing(obtainType.getPathName() + ".Level.Max", -1); - - /*cfg.setComments(obtainType.getPathName() + ".Level", Arrays.asList( - "Here you can set min. and max. level for enchantment generated via " + obtainType.getPathName().replace("_", " "), - "These levels can not be greater or smaller than the default enchantment min. and max levels.", - "Set min/max level to -1 to use the default enchantment min/max level value." - ));*/ - } - - /*String scalabe = "Scalable. Placeholder: " + PLACEHOLDER_LEVEL + ". See: http://77.222.60.131:8080/plugin/engine/config/formats"; - cfg.setComments("Is_Treasure", Arrays.asList("Defines if this enchantment is a treasure enchantment.", "Treasure enchantments can only be received via looting, trading, or fishing.")); - cfg.setComments("Name", Arrays.asList("Enchantment display name. This name will be displayed in item lore and in enchantments list GUI.")); - cfg.setComments("Tier", Arrays.asList("Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded.")); - cfg.setComments("Description", Arrays.asList("Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI.", "You can use multiple lines here.", "You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders")); - cfg.setComments("Level", Arrays.asList("Enchantment level settings.")); - cfg.setComments("Level.Min", Arrays.asList("Minimal (start) enchantment level. Can not be smaller then 1.")); - cfg.setComments("Level.Max", Arrays.asList("Maximal (final) enchantment level.", "Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level.")); - cfg.setComments("Anvil", Arrays.asList("Enchantment settings for Anvil.")); - cfg.setComments("Anvil.Merge_Cost", Arrays.asList("Defines the exp cost to merge this enchantment on other items on anvil.", scalabe)); - cfg.setComments("Enchanting_Table", Arrays.asList("Enchantment settings for Enchanting Table.")); - cfg.setComments("Enchanting_Table.Level_By_Exp_Cost", Arrays.asList("Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost.", "Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels.", scalabe)); - cfg.setComments("Enchanting_Table.Chance", Arrays.asList("A chance that this enchantment will be appeared in Enchanting Table.")); - cfg.setComments("Villagers.Chance", Arrays.asList("A chance that this enchantment will be populated on items in Villager trades.")); - cfg.setComments("Loot_Generation.Chance", Arrays.asList("A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers.")); - cfg.setComments("Fishing.Chance", Arrays.asList("A chance that this enchantment will be populated on items received from fishing.")); - cfg.setComments("Mob_Spawning.Chance", Arrays.asList("A chance that this enchantment will be populated on items equipped on mob on spawning.")); - cfg.setComments("Settings", Arrays.asList("Individual enchantment settings.")); - cfg.setComments("Settings.Trigger_Chance", Arrays.asList("A chance that this enchantment will be triggered.", scalabe)); - cfg.setComments("Settings.Cost", Arrays.asList("A cost a player will have to pay to have this enchantment triggered.")); - cfg.setComments("Settings.Cost.Enabled", Arrays.asList("Enables/Disables cost feature.")); - cfg.setComments("Settings.Cost.Item", Arrays.asList("A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect.", "See http://77.222.60.131:8080/plugin/engine/config/formats for item options.")); - cfg.setComments("Settings.Potion_Effect", Arrays.asList("Enchantment settings for the Potion Effect applied to a wearer or victim.")); - cfg.setComments("Settings.Potion_Effect.Level", Arrays.asList("Potion effect level (amplifier).", scalabe)); - cfg.setComments("Settings.Potion_Effect.Duration", Arrays.asList("Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay.", scalabe)); - cfg.setComments("Settings.Particle", Arrays.asList("Particle effect that will be played on enchantment trigger.")); - cfg.setComments("Settings.Particle.Name", Arrays.asList("Particle name. Set this to empty '' or 'NONE' to disable.", "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html")); - cfg.setComments("Settings.Particle.Data", Arrays.asList("Particle data (additional settings).", "- BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html", "- REDSTONE: Use RGB (like 255,255,255)")); - cfg.setComments("Settings.Sound", Arrays.asList("Sound that will be played on enchantment trigger.", "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html")); - cfg.setComments("Settings.Arrow", Arrays.asList("Enchantment arrow settings.")); - cfg.setComments("Settings.Arrow.Trail", Arrays.asList("A particle effect to play as an arrow trail.")); - cfg.setComments("Settings.Arrow.Trail.Name", Arrays.asList("Particle name. Set this to empty '' or 'NONE' to disable.", "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html")); - cfg.setComments("Settings.Arrow.Trail.Data", Arrays.asList("Particle data (additional settings).", "- BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html", "- REDSTONE: Use RGB (like 255,255,255)")); - - List placeholders = new ArrayList<>(); - placeholders.add("Additional placeholders:"); - for (Field field : Reflex.getFields(this.getClass())) { - if (field.getType() != String.class) continue; - if (!field.getName().startsWith("PLACEHOLDER")) continue; - if (field.getDeclaringClass().equals(ExcellentEnchant.class)) continue; - - String value = (String) Reflex.getFieldValue(this, field.getName()); - String name = StringUtil.capitalizeFully(value.replace("%", "").replace("_", " ")); - placeholders.add("- " + value + ": " + name.trim()); - } - cfg.options().setHeader(placeholders);*/ } @NotNull public UnaryOperator replacePlaceholders(int level) { - String conflicts = this.getConflicts().isEmpty() ? plugin.getMessage(Lang.OTHER_NONE).getLocalized() : this.getConflicts().stream().filter(Objects::nonNull).map(LangManager::getEnchantment).collect(Collectors.joining("\n")); + return str -> { + str = str.replace(Placeholders.ENCHANTMENT_DESCRIPTION, String.join("\n", this.getDescription())); - return str -> str - .replace(Placeholders.ENCHANTMENT_NAME, this.getDisplayName()) - .replace(Placeholders.ENCHANTMENT_NAME_FORMATTED, this.getNameFormatted(level)) - .replace(Placeholders.ENCHANTMENT_LEVEL, NumberUtil.toRoman(level)) - .replace(Placeholders.ENCHANTMENT_LEVEL_MIN, String.valueOf(this.getStartLevel())) - .replace(Placeholders.ENCHANTMENT_LEVEL_MAX, String.valueOf(this.getMaxLevel())) - .replace(Placeholders.ENCHANTMENT_TARGET, plugin.getLangManager().getEnum(this.getItemTarget())) - .replace(Placeholders.ENCHANTMENT_TIER, this.getTier().getName()) - .replace(Placeholders.ENCHANTMENT_CONFLICTS, conflicts) - .replace(Placeholders.ENCHANTMENT_FIT_ITEM_TYPES, String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList())) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING, NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING))) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_VILLAGER, NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER))) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION, NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION))) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_FISHING, NumberUtil.format(this.getObtainChance(ObtainType.FISHING))) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING, NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING))) - .replace(Placeholders.ENCHANTMENT_COST_ITEM, this.hasCostItem() ? ItemUtil.getItemName(this.costItem) : plugin.getMessage(Lang.OTHER_NONE).getLocalized()) + if (this instanceof Chanced chanced) { + str = str.replace(ChanceImplementation.PLACEHOLDER_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())); + } + return str + .replace(Placeholders.ENCHANTMENT_NAME, this.getDisplayName()) + .replace(Placeholders.ENCHANTMENT_NAME_FORMATTED, this.getNameFormatted(level)) + .replace(Placeholders.ENCHANTMENT_LEVEL, NumberUtil.toRoman(level)) + .replace(Placeholders.ENCHANTMENT_LEVEL_MIN, String.valueOf(this.getStartLevel())) + .replace(Placeholders.ENCHANTMENT_LEVEL_MAX, String.valueOf(this.getMaxLevel())) + .replace(Placeholders.ENCHANTMENT_TIER, this.getTier().getName()) + .replace(Placeholders.ENCHANTMENT_FIT_ITEM_TYPES, String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList())) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING, NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING))) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_VILLAGER, NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER))) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION, NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION))) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_FISHING, NumberUtil.format(this.getObtainChance(ObtainType.FISHING))) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING, NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING))) + .replace(Placeholders.ENCHANTMENT_CHARGES_MAX_AMOUNT, String.valueOf(this.getChargesMax(level))) + .replace(Placeholders.ENCHANTMENT_CHARGES_CONSUME_AMOUNT, String.valueOf(this.getChargesConsumeAmount(level))) + .replace(Placeholders.ENCHANTMENT_CHARGES_RECHARGE_AMOUNT, String.valueOf(this.getChargesRechargeAmount(level))) + .replace(Placeholders.ENCHANTMENT_CHARGES_FUEL_ITEM, ItemUtil.getItemName(this.getChargesFuel())) ; + }; } @Override public void registerListeners() { - this.addConflicts(); this.plugin.getPluginManager().registerEvents(this, plugin); } - @NotNull - public UnaryOperator formatString(int level) { - return str -> this.replacePlaceholders(level).apply(str - .replace(Placeholders.ENCHANTMENT_DESCRIPTION, String.join("\n", Config.formatDescription(this.getDescription()))) - ); - } - @NotNull public FitItemType[] getFitItemTypes() { FitItemType itemType = FitItemType.getByEnchantmentTarget(this.getItemTarget()); return itemType == null ? new FitItemType[0] : new FitItemType[]{itemType}; } - private void addConflicts() { - this.conflicts.addAll(this.getConfig().getStringSet("Conflicts").stream() - .map(enchId -> Enchantment.getByKey(NamespacedKey.minecraft(enchId.toLowerCase()))) - .filter(Objects::nonNull) - .toList()); + public boolean isDisabledInWorld(@NotNull World world) { + Set disabled = Config.ENCHANTMENTS_DISABLED_IN_WORLDS.get().getOrDefault(world.getName(), Collections.emptySet()); + return disabled.contains(this.getKey().getKey()) || disabled.contains(Placeholders.WILDCARD); } - public boolean hasCostItem() { - return this.costEnabled && !this.costItem.getType().isAir(); - } - - public boolean takeCostItem(@NotNull LivingEntity livingEntity) { - if (!this.hasCostItem()) return true; - if (!(livingEntity instanceof Player player)) return true; - - if (PlayerUtil.countItem(player, this.costItem) < this.costItem.getAmount()) return false; - return PlayerUtil.takeItem(player, this.costItem, this.costItem.getAmount()); - } - - public boolean isEnchantmentAvailable(@NotNull LivingEntity entity) { - return !Config.isEnchantmentDisabled(this, entity.getWorld().getName()); + public boolean isAvailableToUse(@NotNull LivingEntity entity) { + return !this.isDisabledInWorld(entity.getWorld()); } @NotNull @@ -266,6 +240,19 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener return this.getTier().getColor() + this.getDisplayName() + " " + NumberUtil.toRoman(level); } + @NotNull + public String getNameFormatted(int level, int charges) { + if (!this.isChargesEnabled()) return this.getNameFormatted(level); + + int chargesMax = this.getChargesMax(level); + double percent = (double) charges / (double) chargesMax * 100D; + Map.Entry entry = Config.ENCHANTMENTS_CHARGES_FORMAT.get().floorEntry(percent); + if (entry == null) return this.getNameFormatted(level); + + String format = entry.getValue().replace(Placeholders.GENERIC_AMOUNT, String.valueOf(charges)); + return this.getNameFormatted(level) + " " + format; + } + @NotNull public List getDescription() { return this.description; @@ -279,12 +266,19 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener } @NotNull - public Set getConflicts() { + public List formatDescription(int level) { + return new ArrayList<>(this.getDescription(level).stream() + .map(line -> Config.ENCHANTMENTS_DESCRIPTION_FORMAT.get().replace(Placeholders.GENERIC_DESCRIPTION, line)) + .toList()); + } + + @NotNull + public Set getConflicts() { return conflicts; } @NotNull - public EnchantTier getTier() { + public Tier getTier() { return this.tier; } @@ -311,11 +305,11 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener } public int getObtainLevelMin(@NotNull ObtainType obtainType) { - return this.obtainLevelCap.getOrDefault(obtainType, Pair.of(-1, -1)).getFirst(); + return this.obtainLevelCap.getOrDefault(obtainType, new int[]{-1, -1})[0]; } public int getObtainLevelMax(@NotNull ObtainType obtainType) { - return this.obtainLevelCap.getOrDefault(obtainType, Pair.of(-1, -1)).getSecond(); + return this.obtainLevelCap.getOrDefault(obtainType, new int[]{-1, -1})[1]; } public int fineLevel(int level, @NotNull ObtainType obtainType) { @@ -348,14 +342,14 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener @Override public final boolean conflictsWith(@NotNull Enchantment enchantment) { - return this.conflicts.contains(enchantment); + return this.conflicts.contains(enchantment.getKey().getKey()); } @Override public final boolean canEnchantItem(@Nullable ItemStack item) { if (item == null || item.getType().isAir()) return false; - if (EnchantManager.getItemEnchants(item).keySet().stream().anyMatch(e -> e.conflictsWith(this) || this.conflictsWith(e))) return false; - if (EnchantManager.getEnchantmentLevel(item, this) <= 0 && EnchantManager.getItemCustomEnchantsAmount(item) >= Config.ENCHANTMENTS_ITEM_CUSTOM_MAX) { + 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()) { return false; } if (item.getType() == Material.BOOK || item.getType() == Material.ENCHANTED_BOOK) { @@ -373,4 +367,61 @@ public abstract class ExcellentEnchant extends Enchantment implements IListener public final boolean isTreasure() { return this.isTreasure; } + + public boolean hasVisualEffects() { + return this.hasVisualEffects; + } + + public boolean isChargesEnabled() { + return Config.ENCHANTMENTS_CHARGES_ENABLED.get() && this.chargesEnabled; + } + + public boolean isChargesCustomFuel() { + return chargesCustomFuel; + } + + public int getChargesMax(int level) { + return this.isChargesEnabled() ? (int) this.chargesMax.getValue(level) : 0; + } + + public int getChargesConsumeAmount(int level) { + return this.isChargesEnabled() ? (int) this.chargesConsumeAmount.getValue(level) : 0; + } + + public int getChargesRechargeAmount(int level) { + return this.isChargesEnabled() ? (int) this.chargesRechargeAmount.getValue(level) : 0; + } + + @NotNull + public ItemStack getChargesFuel() { + ItemStack fuelHas = this.chargesFuel; + if (!this.isChargesCustomFuel() || fuelHas == null || fuelHas.getType().isAir()) { + return Config.ENCHANTMENTS_CHARGES_FUEL_ITEM.get(); + } + return new ItemStack(fuelHas); + } + + public boolean isChargesFuel(@NotNull ItemStack item) { + return item.isSimilar(this.getChargesFuel()); + } + + @NotNull + public NamespacedKey getChargesKey() { + return chargesKey; + } + + @Override + public boolean isOutOfCharges(@NotNull ItemStack item) { + return EnchantManager.isEnchantmentOutOfCharges(item, this); + } + + @Override + public boolean isFullOfCharges(@NotNull ItemStack item) { + return EnchantManager.isEnchantmentFullOfCharges(item, this); + } + + @Override + public void consumeCharges(@NotNull ItemStack item) { + EnchantManager.consumeEnchantmentCharges(item, this); + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowPotionTemplate.java deleted file mode 100644 index ad103ab..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowPotionTemplate.java +++ /dev/null @@ -1,72 +0,0 @@ -package su.nightexpress.excellentenchants.api.enchantment; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Projectile; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.manager.EnchantManager; - -public abstract class IEnchantBowPotionTemplate extends IEnchantPotionTemplate implements BowEnchant { - - protected final String arrowMeta; - - public IEnchantBowPotionTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, - @NotNull EnchantPriority priority, - @NotNull PotionEffectType type) { - super(plugin, cfg, priority, type); - this.arrowMeta = this.getId() + "_potion_arrow"; - } - - public boolean isThisArrow(@NotNull Projectile projectile) { - return projectile.hasMetadata(this.arrowMeta); - } - - public void setThisArrow(@NotNull Projectile projectile) { - projectile.setMetadata(this.arrowMeta, new FixedMetadataValue(plugin, true)); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.BOW; - } - - @Override - public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { - if (!this.isThisArrow(projectile)) return false; - - return true; - } - - @Override - public boolean use(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isEnchantmentAvailable(shooter)) return false; - if (!(e.getProjectile() instanceof Arrow arrow)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; - - this.setThisArrow(arrow); - arrow.addCustomEffect(this.getEffect(level), true); - return true; - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(victim)) return false; - if (!(e.getDamager() instanceof Projectile projectile)) return false; - if (!this.isThisArrow(projectile)) return false; - - //this.addEffect(victim, level); - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java deleted file mode 100644 index 83dec43..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantBowTemplate.java +++ /dev/null @@ -1,92 +0,0 @@ -package su.nightexpress.excellentenchants.api.enchantment; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Projectile; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -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.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.tasks.ArrowTrailsTask; - -public abstract class IEnchantBowTemplate extends IEnchantChanceTemplate implements BowEnchant { - - protected String arrowTrailName; - protected String arrowTrailData; - protected final String arrowMeta; - - public IEnchantBowTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, @NotNull EnchantPriority priority) { - super(plugin, cfg, priority); - this.arrowMeta = this.getId() + "_arrow"; - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.arrowTrailName = cfg.getString("Settings.Arrow.Trail.Name", ""); - this.arrowTrailData = cfg.getString("Settings.Arrow.Trail.Data", ""); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - if (cfg.contains("Settings.Arrow.Trail") && !cfg.isConfigurationSection("Settings.Arrow.Trail")) { - String trail = cfg.getString("Settings.Arrow.Trail", ""); - - cfg.set("Settings.Arrow.Trail", null); - cfg.addMissing("Settings.Arrow.Trail.Name", trail); - } - cfg.addMissing("Settings.Arrow.Trail.Data", ""); - } - - public boolean isThisArrow(@NotNull Projectile projectile) { - return projectile.hasMetadata(this.arrowMeta); - } - - public void setThisArrow(@NotNull Projectile projectile) { - projectile.setMetadata(this.arrowMeta, new FixedMetadataValue(plugin, true)); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.BOW; - } - - @Override - public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { - if (!this.isThisArrow(projectile)) return false; - - return true; - } - - @Override - public boolean use(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isEnchantmentAvailable(shooter)) return false; - if (!(e.getProjectile() instanceof Projectile arrow)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; - - this.setThisArrow(arrow); - if (!this.arrowTrailName.isEmpty()) { - ArrowTrailsTask.add(arrow, this.arrowTrailName, this.arrowTrailData); - } - return true; - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(victim)) return false; - if (!(e.getDamager() instanceof Projectile projectile)) return false; - if (!this.isThisArrow(projectile)) return false; - - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java deleted file mode 100644 index a05254e..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantChanceTemplate.java +++ /dev/null @@ -1,56 +0,0 @@ -package su.nightexpress.excellentenchants.api.enchantment; - -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; -import su.nexmedia.engine.utils.random.Rnd; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; - -import java.util.function.UnaryOperator; - -public abstract class IEnchantChanceTemplate extends ExcellentEnchant { - - public static final String PLACEHOLDER_CHANCE = "%enchantment_trigger_chance%"; - - protected Scaler triggerChance; - - public IEnchantChanceTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, @NotNull EnchantPriority priority) { - super(plugin, cfg, priority); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.triggerChance = new EnchantScaler(this, "Settings.Trigger_Chance"); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - if (cfg.contains("settings.enchant-trigger-chance")) { - String triggerChance = cfg.getString("settings.enchant-trigger-chance", "100").replace("%level%", Placeholders.ENCHANTMENT_LEVEL); - - cfg.set("Settings.Trigger_Chance", triggerChance); - cfg.set("settings.enchant-trigger-chance", null); - } - } - - @Override - public @NotNull UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_CHANCE, NumberUtil.format(this.getTriggerChance(level))) - ); - } - - public final double getTriggerChance(int level) { - return this.triggerChance.getValue(level); - } - - public final boolean checkTriggerChance(int level) { - return Rnd.get(true) <= this.getTriggerChance(level); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantCombatPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantCombatPotionTemplate.java deleted file mode 100644 index 64b12eb..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantCombatPotionTemplate.java +++ /dev/null @@ -1,57 +0,0 @@ -package su.nightexpress.excellentenchants.api.enchantment; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -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.config.JYML; -import su.nexmedia.engine.utils.EffectUtil; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; - -public abstract class IEnchantCombatPotionTemplate extends IEnchantPotionTemplate implements CombatEnchant { - - protected String particleName; - protected String particleData; - - public IEnchantCombatPotionTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, - @NotNull EnchantPriority priority, - @NotNull PotionEffectType effectType) { - super(plugin, cfg, priority, effectType); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.particleName = cfg.getString("Settings.Particle.Name", ""); - this.particleData = cfg.getString("Settings.Particle.Data", ""); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.remove("Settings.Particle_Effect"); - cfg.addMissing("Settings.Particle.Name", ""); - cfg.addMissing("Settings.Particle.Data", ""); - } - - @Override - @NotNull - public final EnchantmentTarget getItemTarget() { - return EnchantmentTarget.WEAPON; - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(damager)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(damager)) return false; - if (!this.addEffect(victim, level)) return false; - - EffectUtil.playEffect(victim.getEyeLocation(), this.particleName, this.particleData, 0.25f, 0.25f, 0.25f, 0.1f, 50); - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java deleted file mode 100644 index bc9bb1c..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantPotionTemplate.java +++ /dev/null @@ -1,90 +0,0 @@ -package su.nightexpress.excellentenchants.api.enchantment; - -import org.bukkit.entity.LivingEntity; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.lang.LangManager; -import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; - -import java.util.function.UnaryOperator; - -public abstract class IEnchantPotionTemplate extends IEnchantChanceTemplate { - - 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%"; - - protected PotionEffectType potionEffectType; - protected final boolean potionParticles; - protected Scaler potionDuration; - protected Scaler potionLevel; - - public IEnchantPotionTemplate(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg, - @NotNull EnchantPriority priority, - @NotNull PotionEffectType potionEffectType) { - super(plugin, cfg, priority); - this.potionEffectType = potionEffectType; - this.potionParticles = !(this instanceof PassiveEnchant); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.potionDuration = new EnchantScaler(this, "Settings.Potion_Effect.Duration"); - this.potionLevel = new EnchantScaler(this, "Settings.Potion_Effect.Level"); - } - - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_POTION_LEVEL, NumberUtil.toRoman(this.getEffectLevel(level))) - .replace(PLACEHOLDER_POTION_DURATION, NumberUtil.format((double) this.getEffectDuration(level) / 20D)) - .replace(PLACEHOLDER_POTION_TYPE, LangManager.getPotionType(this.getEffectType())) - ); - } - - @NotNull - public final PotionEffectType getEffectType() { - return this.potionEffectType; - } - - public final int getEffectDuration(int level) { - return (int) (this.potionDuration.getValue(level) * 20); - } - - public final int getEffectLevel(int level) { - return (int) this.potionLevel.getValue(level); - } - - @NotNull - public PotionEffect getEffect(int level) { - int duration = this.getEffectDuration(level); - int amplifier = Math.max(0, this.getEffectLevel(level) - 1); - - return new PotionEffect(this.potionEffectType, duration, amplifier, false, this.potionParticles); - } - - public final boolean hasEffect(@NotNull LivingEntity entity) { - return EnchantManager.hasEnchantmentEffect(entity, this); - } - - public final boolean addEffect(@NotNull LivingEntity target, int level) { - if (this instanceof PassiveEnchant) { - if (!this.hasEffect(target)) { - this.plugin.getEnchantNMS().addEnchantmentEffect(target, this, this.getEffect(level)); - } - } - else { - target.addPotionEffect(this.getEffect(level)); - } - return true; - } -} \ No newline at end of file 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 new file mode 100644 index 0000000..5fec1c7 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/IEnchantment.java @@ -0,0 +1,78 @@ +package su.nightexpress.excellentenchants.api.enchantment; + +import org.bukkit.enchantments.Enchantment; +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.tier.Tier; +import su.nightexpress.excellentenchants.enchantment.type.ObtainType; + +import java.util.List; +import java.util.Set; + +public interface IEnchantment { + + @NotNull JYML getConfig(); + + @NotNull String getId(); + + @NotNull EnchantPriority getPriority(); + + @NotNull String getDisplayName(); + + @NotNull String getNameFormatted(int level); + + @NotNull String getNameFormatted(int level, int charges); + + @NotNull List getDescription(); + + @NotNull List getDescription(int level); + + @NotNull Set getConflicts(); + + @NotNull Tier getTier(); + + int getMaxLevel(); + + int getStartLevel(); + + int getLevelByEnchantCost(int expLevel); + + double getObtainChance(@NotNull ObtainType obtainType); + + int getObtainLevelMin(@NotNull ObtainType obtainType); + + int getObtainLevelMax(@NotNull ObtainType obtainType); + + int generateLevel(@NotNull ObtainType obtainType); + + int getAnvilMergeCost(int level); + + boolean conflictsWith(@NotNull Enchantment enchantment); + + boolean canEnchantItem(@Nullable ItemStack item); + + boolean isCursed(); + + boolean isTreasure(); + + boolean isChargesEnabled(); + + int getChargesMax(int level); + + int getChargesConsumeAmount(int level); + + int getChargesRechargeAmount(int level); + + @NotNull ItemStack getChargesFuel(); + + boolean isChargesFuel(@NotNull ItemStack item); + + boolean isFullOfCharges(@NotNull ItemStack item); + + boolean isOutOfCharges(@NotNull ItemStack item); + + void consumeCharges(@NotNull ItemStack item); +} 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 new file mode 100644 index 0000000..7255e77 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Arrowed.java @@ -0,0 +1,34 @@ +package su.nightexpress.excellentenchants.api.enchantment.meta; + +import org.bukkit.Particle; +import org.bukkit.entity.Projectile; +import org.jetbrains.annotations.NotNull; + +import java.util.Optional; + +public interface Arrowed { + + @NotNull Arrowed getArrowImplementation(); + + @NotNull + 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); + } + + default void addData(@NotNull Projectile projectile) { + this.getArrowImplementation().addData(projectile); + } + + default boolean isOurProjectile(@NotNull Projectile projectile) { + return this.getArrowImplementation().isOurProjectile(projectile); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Chanced.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Chanced.java new file mode 100644 index 0000000..21f2b32 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Chanced.java @@ -0,0 +1,21 @@ +package su.nightexpress.excellentenchants.api.enchantment.meta; + +import org.jetbrains.annotations.NotNull; + +public interface Chanced { + + @NotNull Chanced getChanceImplementation(); + + /*@NotNull + default UnaryOperator replacePlaceholders(int level) { + return this.getChanceImplementation().replacePlaceholders(level); + }*/ + + default double getTriggerChance(int level) { + return this.getChanceImplementation().getTriggerChance(level); + } + + default boolean checkTriggerChance(int level) { + return getChanceImplementation().checkTriggerChance(level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Potioned.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Potioned.java new file mode 100644 index 0000000..ddc2c34 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Potioned.java @@ -0,0 +1,44 @@ +package su.nightexpress.excellentenchants.api.enchantment.meta; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public interface Potioned { + + @NotNull Potioned getPotionImplementation(); + + /*@NotNull + default UnaryOperator replacePlaceholders(int level) { + return this.getPotionImplementation().replacePlaceholders(level); + }*/ + + default boolean isPermanent() { + return this.getPotionImplementation().isPermanent(); + } + + default PotionEffectType getEffectType() { + return this.getPotionImplementation().getEffectType(); + } + + default int getEffectAmplifier(int level) { + return this.getPotionImplementation().getEffectAmplifier(level); + } + + default int getEffectDuration(int level) { + return this.getPotionImplementation().getEffectDuration(level); + } + + default PotionEffect createEffect(int level) { + return this.getPotionImplementation().createEffect(level); + } + + default boolean hasEffect(@NotNull LivingEntity target) { + return this.getPotionImplementation().hasEffect(target); + } + + default boolean addEffect(@NotNull LivingEntity target, int level) { + return this.getPotionImplementation().addEffect(target, level); + } +} 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 new file mode 100644 index 0000000..a0737a9 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/template/PotionEnchant.java @@ -0,0 +1,36 @@ +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/BlockBreakEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java index 51ecd54..f1300eb 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java @@ -4,8 +4,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; -public interface BlockBreakEnchant { +public interface BlockBreakEnchant extends IEnchantment { - boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level); + boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level); } 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 f732314..b45b3b8 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,8 +4,11 @@ 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.api.enchantment.IEnchantment; -public interface BlockDropEnchant { +public interface BlockDropEnchant extends IEnchantment { - boolean use(@NotNull BlockDropItemEvent e, @NotNull Player player, @NotNull ItemStack item, int level); + boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, + @NotNull Player player, @NotNull ItemStack item, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java index 3f41021..6845c15 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java @@ -2,14 +2,20 @@ package su.nightexpress.excellentenchants.api.enchantment.type; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; -public interface BowEnchant extends CombatEnchant { +public interface BowEnchant extends IEnchantment { - boolean use(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level); + boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level); - boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level); + boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level); + + boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, + @NotNull LivingEntity shooter, @NotNull LivingEntity victim, + @NotNull ItemStack weapon, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java index 0a78a0d..6386f6f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java @@ -4,8 +4,15 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; -public interface CombatEnchant { +public interface CombatEnchant extends IEnchantment { - boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level); + boolean onAttack(@NotNull EntityDamageByEntityEvent e, + @NotNull LivingEntity damager, @NotNull LivingEntity victim, + @NotNull ItemStack weapon, int level); + + boolean onProtect(@NotNull EntityDamageByEntityEvent e, + @NotNull LivingEntity damager, @NotNull LivingEntity victim, + @NotNull ItemStack weapon, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CustomDropEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CustomDropEnchant.java deleted file mode 100644 index 14212ae..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CustomDropEnchant.java +++ /dev/null @@ -1,11 +0,0 @@ -package su.nightexpress.excellentenchants.api.enchantment.type; - -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; - -public interface CustomDropEnchant { - - void handleDrop(@NotNull EnchantDropContainer e, @NotNull Player player, @NotNull ItemStack item, int level); -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DamageEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DamageEnchant.java new file mode 100644 index 0000000..1e295c6 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DamageEnchant.java @@ -0,0 +1,12 @@ +package su.nightexpress.excellentenchants.api.enchantment.type; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; + +public interface DamageEnchant extends IEnchantment { + + boolean onDamage(@NotNull EntityDamageEvent e, @NotNull LivingEntity entity, @NotNull ItemStack item, int level); +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java index 4c823a7..0d5af0f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java @@ -1,10 +1,14 @@ package su.nightexpress.excellentenchants.api.enchantment.type; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDeathEvent; import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; -public interface DeathEnchant { +public interface DeathEnchant extends IEnchantment { - boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level); + boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level); + + boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java index 94b0235..1d9b54e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java @@ -4,8 +4,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; -public interface InteractEnchant { +public interface InteractEnchant extends IEnchantment { - boolean use(@NotNull PlayerInteractEvent e, @NotNull Player player, @NotNull ItemStack item, int level); + boolean onInteract(@NotNull PlayerInteractEvent e, @NotNull Player player, @NotNull ItemStack item, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/MoveEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/MoveEnchant.java deleted file mode 100644 index a993c3e..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/MoveEnchant.java +++ /dev/null @@ -1,10 +0,0 @@ -package su.nightexpress.excellentenchants.api.enchantment.type; - -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.player.PlayerMoveEvent; -import org.jetbrains.annotations.NotNull; - -public interface MoveEnchant { - - boolean use(@NotNull PlayerMoveEvent e, @NotNull LivingEntity entity, int level); -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/PassiveEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/PassiveEnchant.java index e460c06..2426733 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/PassiveEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/PassiveEnchant.java @@ -1,9 +1,11 @@ package su.nightexpress.excellentenchants.api.enchantment.type; import org.bukkit.entity.LivingEntity; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; -public interface PassiveEnchant { +public interface PassiveEnchant extends IEnchantment { - boolean use(@NotNull LivingEntity entity, int level); + boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantDropContainer.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/util/EnchantDropContainer.java similarity index 90% rename from Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantDropContainer.java rename to Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/util/EnchantDropContainer.java index 028bfbd..38ed11c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantDropContainer.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/util/EnchantDropContainer.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.api.enchantment; +package su.nightexpress.excellentenchants.api.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/EnchantPriority.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/util/EnchantPriority.java similarity index 53% rename from Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantPriority.java rename to Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/util/EnchantPriority.java index 2ffa768..d51f714 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/EnchantPriority.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/util/EnchantPriority.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.api.enchantment; +package su.nightexpress.excellentenchants.api.enchantment.util; public enum EnchantPriority { 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 669c5e9..9d475a4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.command.AbstractCommand; import su.nexmedia.engine.lang.LangManager; @@ -15,7 +14,9 @@ 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 java.util.Arrays; import java.util.List; @@ -84,17 +85,12 @@ public class BookCommand extends AbstractCommand { } ItemStack item = new ItemStack(Material.ENCHANTED_BOOK); - EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta(); - if (meta == null) return; - - meta.addStoredEnchant(enchantment, level, true); - item.setItemMeta(meta); - - //EnchantManager.updateItemLoreEnchants(item); + EnchantManager.addEnchantment(item, enchantment, level, true); PlayerUtil.addItem(player, item); plugin.getMessage(Lang.COMMAND_BOOK_DONE) - .replace("%enchant%", LangManager.getEnchantment(enchantment)) - .replace("%player%", player.getName()).send(sender); + .replace(Placeholders.GENERIC_ENCHANT, LangManager.getEnchantment(enchantment)) + .replace(Placeholders.Player.replacer(player)) + .send(sender); } } 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 c714df1..ef064b1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java @@ -5,8 +5,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; 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.command.AbstractCommand; import su.nexmedia.engine.utils.StringUtil; @@ -14,6 +12,7 @@ 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 java.util.Arrays; import java.util.List; @@ -79,27 +78,10 @@ public class EnchantCommand extends AbstractCommand { level = Rnd.get(enchantment.getStartLevel(), enchantment.getMaxLevel()); } - ItemMeta meta = item.getItemMeta(); - if (meta == null) return; - - if (meta instanceof EnchantmentStorageMeta storageMeta) { - if (level == 0) { - storageMeta.removeStoredEnchant(enchantment); - } - else { - storageMeta.addStoredEnchant(enchantment, level, true); - } + if (level > 0) { + EnchantManager.addEnchantment(item, enchantment, level, true); } - else { - if (level == 0) { - meta.removeEnchant(enchantment); - } - else { - meta.addEnchant(enchantment, level, true); - } - } - item.setItemMeta(meta); - //EnchantManager.updateItemLoreEnchants(item); + else EnchantManager.removeEnchantment(item, enchantment); plugin.getMessage(Lang.COMMAND_ENCHANT_DONE).send(sender); } 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 a38a5a7..9849ce8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java @@ -6,6 +6,7 @@ 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.Placeholders; import su.nexmedia.engine.utils.PlayerUtil; import su.nexmedia.engine.utils.StringUtil; import su.nexmedia.engine.utils.random.Rnd; @@ -13,8 +14,8 @@ 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.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.object.EnchantTier; +import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.tier.Tier; import java.util.Arrays; import java.util.List; @@ -50,7 +51,7 @@ public class TierbookCommand extends AbstractCommand { return PlayerUtil.getPlayerNames(); } if (arg == 2) { - return EnchantManager.getTierIds(); + return plugin.getTierManager().getTierIds(); } if (arg == 3) { return Arrays.asList("-1", "1", "5", "10"); @@ -71,7 +72,7 @@ public class TierbookCommand extends AbstractCommand { return; } - EnchantTier tier = EnchantManager.getTierById(args[2].toLowerCase()); + Tier tier = plugin.getTierManager().getTierById(args[2].toLowerCase()); if (tier == null) { plugin.getMessage(Lang.COMMAND_TIER_BOOK_ERROR).send(sender); return; @@ -89,11 +90,12 @@ public class TierbookCommand extends AbstractCommand { } ItemStack item = new ItemStack(Material.ENCHANTED_BOOK); - EnchantManager.addEnchant(item, enchant, level, true); + EnchantManager.addEnchantment(item, enchant, level, true); PlayerUtil.addItem(player, item); plugin.getMessage(Lang.COMMAND_TIER_BOOK_DONE) - .replace("%tier%", tier.getName()) - .replace("%player%", player.getName()).send(sender); + .replace(tier.replacePlaceholders()) + .replace(Placeholders.Player.replacer(player)) + .send(sender); } } 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 27ba4ff..bb333ea 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -1,171 +1,103 @@ package su.nightexpress.excellentenchants.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.Placeholders; 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.manager.object.EnchantTier; -import su.nightexpress.excellentenchants.manager.type.ObtainType; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.enchantment.type.ObtainType; -import java.util.*; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.TreeMap; import java.util.stream.Collectors; +import java.util.stream.Stream; public class Config { - public static long TASKS_ARROW_TRAIL_TICKS_INTERVAL; - public static final JOption TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL = JOption.create("General.Tasks.Passive_Potion_Effects.Apply_Interval", 150, + 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", 150L, "Sets how often (in ticks) the plugin will apply permanent potion effects from enchanted items to an entity who wear them.", "This setting does NOT refreshes currently active effects, but only attempts to add them if absent." ); - public static Set ENCHANTMENTS_DISABLED; - public static Map> ENCHANTMENTS_DISABLED_IN_WORLDS; - public static boolean ENCHANTMENTS_DESCRIPTION_ENABLED; - private static String ENCHANTMENTS_DESCRIPTION_FORMAT; + public static final JOption ENCHANTMENTS_CHARGES_ENABLED = JOption.create("Enchantments.Charges.Enabled", false, + "Enables the enchantment Charges feature."); // TODO Wiki link - public static int ENCHANTMENTS_ITEM_CUSTOM_MAX; - public static boolean ENCHANTMENTS_ITEM_AXES_AS_SWORDS; - public static boolean ENCHANTMENTS_ITEM_CROSSBOWS_AS_BOWS; - public static boolean ENCHANTMENTS_ITEM_ELYTRA_AS_CHESTPLATE; - public static boolean ENCHANTMENTS_ENTITY_PASSIVE_FOR_MOBS; + public static final JOption> ENCHANTMENTS_CHARGES_FORMAT = new JOption>("Enchantments.Charges.Format", + (cfg, path, def) -> cfg.getSection(path).stream().collect(Collectors.toMap(k -> StringUtil.getDouble(k, 0), v -> StringUtil.color(cfg.getString(path + "." + v, "")), (o,n) -> n, TreeMap::new)), + () -> { + TreeMap map = new TreeMap<>(); + map.put(0D, "#ff9a9a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); + map.put(25D, "#ffc39a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); + map.put(50D, "#f6ff9a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); + map.put(75D, "#bcff9a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); + return map; + }, + "Enchantment charges format depends on amount of charges left (in percent).", + "If you don't want to display charges, leave only keys with negative values.", + "Use '" + Placeholders.GENERIC_AMOUNT + "' placeholder for amount of charges.") + .setWriter((cfg, path, map) -> map.forEach((perc, str) -> cfg.set(path + "." + perc, str))); - private static Map OBTAIN_SETTINGS; - private static Map TIERS; + public static final JOption ENCHANTMENTS_CHARGES_FUEL_ITEM = JOption.create("Enchantments.Charges.Fuel_Item", + new ItemStack(Material.LAPIS_LAZULI), + "Default item used to recharge item's enchantments on anvils.", + "If you want different item for certain enchantments, you can do it in that enchantment configs.", + "Item Options: " + Placeholders.URL_ENGINE_SCALER) + .setWriter(JYML::setItem); - public static void load(@NotNull ExcellentEnchants plugin) { - JYML cfg = plugin.getConfig(); - cfg.initializeOptions(Config.class); + public static final JOption> ENCHANTMENTS_DISABLED = JOption.create("Enchantments.Disabled", + Set.of("enchant_name", "other_enchant"), + "A list of enchantments, that will be disabled and removed from the game (server).", + "Enchantment names are the same as enchantment file name in /enchants/ folder. ! Must be in lower_case !", + "Example: To disable 'Explosive Arrows' you need to add 'explosive_arrows' here."); - String path = "General.Tasks."; - TASKS_ARROW_TRAIL_TICKS_INTERVAL = cfg.getLong(path + "Arrow_Trails.Ticks_Interval", 1); + public static final JOption>> ENCHANTMENTS_DISABLED_IN_WORLDS = new JOption>>("Enchantments.Disabled_In_Worlds", + (cfg, path, def) -> cfg.getSection(path).stream().collect(Collectors.toMap(k -> k, worldName -> cfg.getStringSet(path + "." + worldName))), + () -> Map.of("your_world_name", Set.of("enchantment_name", "ice_aspect")), + "Here you can disable certain enchantments in certain worlds.", + "Enchantment names are the same as enchantment file name in /enchants/ folder. ! Must be in lower_case !", + "To disable all enchantments for a world, use '" + Placeholders.WILDCARD + "' instead of enchantment names.") + .setWriter((cfg, path, map) -> map.forEach((world, enchants) -> cfg.set(path + "." + world, enchants))); - path = "General.Enchantments."; - cfg.addMissing(path + "Disabled_In_Worlds.my_world", Collections.singletonList(Placeholders.WILDCARD)); - cfg.addMissing(path + "Disabled_In_Worlds.other_world", Arrays.asList("enchant_name", "another_enchant")); + public static final JOption ENCHANTMENTS_DESCRIPTION_ENABLED = JOption.create("Enchantments.Description.Enabled", true, + "When 'true', adds the enchantment description to item lore under enchantment names.", + "Note #1: You must have ProtocolLib installed for this feature to work (as well as for enchantments name display).", + "Note #2: Description is not shown while you're in Creative gamemode."); - ENCHANTMENTS_DISABLED = cfg.getStringSet(path + "Disabled").stream().map(String::toLowerCase).collect(Collectors.toSet()); - ENCHANTMENTS_DISABLED_IN_WORLDS = new HashMap<>(); - for (String worldName : cfg.getSection(path + "Disabled_In_Worlds")) { - ENCHANTMENTS_DISABLED_IN_WORLDS.put(worldName, cfg.getStringSet(path + "Disabled_In_Worlds." + worldName) - .stream().map(String::toLowerCase).collect(Collectors.toSet())); - } + public static final JOption ENCHANTMENTS_DESCRIPTION_FORMAT = JOption.create("Enchantments.Description.Format", + "&8▸ " + Placeholders.GENERIC_DESCRIPTION, + "Sets the global enchantment description format."); - ENCHANTMENTS_DESCRIPTION_ENABLED = cfg.getBoolean(path + "Description.Enabled"); - ENCHANTMENTS_DESCRIPTION_FORMAT = StringUtil.color(cfg.getString(path + "Description.Format", "")); + public static final JOption ENCHANTMENTS_ITEM_CUSTOM_MAX = JOption.create("Enchantments.Item.Max_Custom_Enchants", 3, + "How many of custom enchantments the item can contain at the same time?"); - path = "General.Enchantments.Item."; - ENCHANTMENTS_ITEM_CUSTOM_MAX = cfg.getInt(path + "Max_Custom_Enchants", 3); - ENCHANTMENTS_ITEM_AXES_AS_SWORDS = cfg.getBoolean(path + "Axes_As_Swords"); - ENCHANTMENTS_ITEM_CROSSBOWS_AS_BOWS = cfg.getBoolean(path + "Crossbows_As_Bows"); - ENCHANTMENTS_ITEM_ELYTRA_AS_CHESTPLATE = cfg.getBoolean(path + "Elytra_As_Chestplate"); + public static final JOption ENCHANTMENTS_ITEM_SWORD_ENCHANTS_TO_AXES = JOption.create("Enchantments.Item.Sword_Enchants_To_Axes", true, + "Set this to 'true' to allow Sword enchantments for Axes."); - path = "General.Enchantments.Entity."; - ENCHANTMENTS_ENTITY_PASSIVE_FOR_MOBS = cfg.getBoolean(path + "Passive_Enchants_Applied_To_Mobs"); + public static final JOption ENCHANTMENTS_ITEM_BOW_ENCHANTS_TO_CROSSBOW = JOption.create("Enchantments.Item.Bow_Enchants_To_Crossbows", true, + "Set this to 'true' to allow Bow enchantments for Crossbows."); - OBTAIN_SETTINGS = new HashMap<>(); - for (ObtainType obtainType : ObtainType.values()) { - String path2 = "General." + obtainType.getPathName() + "."; + public static final JOption ENCHANTMENTS_ITEM_CHESTPLATE_ENCHANTS_TO_ELYTRA = JOption.create("Enchantments.Item.Chestplate_Enchants_To_Elytra", false, + "Set this to 'true' to allow Chestplate enchantments for Elytras."); - cfg.addMissing(path2 + "Enabled", true); - cfg.addMissing(path2 + "Enchantments.Total_Maximum", 4); - cfg.addMissing(path2 + "Enchantments.Custom_Generation_Chance", 50D); - cfg.addMissing(path2 + "Enchantments.Custom_Minimum", 0); - cfg.addMissing(path2 + "Enchantments.Custom_Maximum", 2); + public static final JOption ENCHANTMENTS_ENTITY_PASSIVE_FOR_MOBS = JOption.create("Enchantments.Entity.Apply_Passive_Enchants_To_Mobs", true, + "When enabled, passive enchantments (permanent potion effects, regeneration, etc.) will be applied to mobs as well.", + "Disable this if you're experiencing performance issues."); - if (!cfg.getBoolean(path2 + "Enabled")) continue; - - int enchantsTotalMax = cfg.getInt(path2 + "Enchantments.Total_Maximum", 4); - double enchantsCustomGenerationChance = cfg.getDouble(path2 + "Enchantments.Custom_Generation_Chance", 50D); - int enchantsCustomMin = cfg.getInt(path2 + "Enchantments.Custom_Minimum", 0); - int enchantsCustomMax = cfg.getInt(path2 + "Enchantments.Custom_Maximum", 2); - - ObtainSettings settings = new ObtainSettings(enchantsTotalMax, enchantsCustomGenerationChance, enchantsCustomMin, enchantsCustomMax); - OBTAIN_SETTINGS.put(obtainType, settings); - } - - setupTiers(plugin); - } - - private static void setupTiers(@NotNull ExcellentEnchants plugin) { - // Reloading tiers will reset their lists with enchants = break the plugin mechanics - if (ExcellentEnchants.isLoaded) return; - - JYML cfg = plugin.getConfig(); - TIERS = new HashMap<>(); - - // No tiers defined, setup a default one. - // Every enchantment must have a tier. - if (cfg.getSection("Tiers").isEmpty()) { - plugin.info("No tiers defined! Creating a default one for you..."); - cfg.set("Tiers.default.Name", "&7Default"); - cfg.set("Tiers.default.Color", "&7"); - for (ObtainType obtainType : ObtainType.values()) { - cfg.set("Tiers.default.Obtain_Chance." + obtainType.name(), 100D); - } - } - - // Load existing tiers. - for (String sId : cfg.getSection("Tiers")) { - String path = "Tiers." + sId + "."; - cfg.addMissing(path + "Priority", 0); - - int priority = cfg.getInt(path + "Priority"); - String name = cfg.getString(path + "Name", sId); - String color = cfg.getString(path + "Color", "&f"); - Map chance = new HashMap<>(); - - for (ObtainType obtainType : ObtainType.values()) { - cfg.addMissing(path + "Obtain_Chance." + obtainType.name(), 50D); - - double chanceType = cfg.getDouble(path + "Obtain_Chance." + obtainType.name()); - chance.put(obtainType, chanceType); - } - - EnchantTier tier = new EnchantTier(sId, priority, name, color, chance); - TIERS.put(tier.getId(), tier); - } - - plugin.info("Tiers Loaded: " + TIERS.size()); - } - - public static boolean isEnchantmentDisabled(@NotNull ExcellentEnchant enchant, @NotNull String world) { - Set disabled = ENCHANTMENTS_DISABLED_IN_WORLDS.getOrDefault(world, Collections.emptySet()); - return disabled.contains(enchant.getKey().getKey()) || disabled.contains(Placeholders.WILDCARD); - } - - @Nullable - public static EnchantTier getTierById(@NotNull String id) { - return TIERS.get(id.toLowerCase()); - } + private static final JOption> OBTAIN_SETTINGS = new JOption>("Enchantments.Obtaining", + (cfg, path, def) -> Stream.of(ObtainType.values()).collect(Collectors.toMap(k -> k, v -> ObtainSettings.read(cfg, path + "." + v.getPathName()))), + () -> Stream.of(ObtainType.values()).collect(Collectors.toMap(k -> k, v -> new ObtainSettings(true, 4, 80D, 0, 2))), + "Settings for the different ways of obtaining enchantments.") + .setWriter((cfg, path, map) -> map.forEach((type, settings) -> ObtainSettings.write(cfg, path + "." + type.getPathName(), settings))); @NotNull - public static Collection getTiers() { - return TIERS.values(); - } - - @NotNull - public static List getTierIds() { - return new ArrayList<>(TIERS.keySet()); - } - - @Nullable - public static EnchantTier getTierByChance(@NotNull ObtainType obtainType) { - Map map = getTiers().stream().collect(Collectors.toMap(k -> k, v -> v.getChance(obtainType))); - return Rnd.get(map); - } - - @Nullable - public static ObtainSettings getObtainSettings(@NotNull ObtainType obtainType) { - return OBTAIN_SETTINGS.get(obtainType); - } - - @NotNull - public static List formatDescription(@NotNull List description) { - return new ArrayList<>(description.stream().map(line -> ENCHANTMENTS_DESCRIPTION_FORMAT.replace("%description%", line)).toList()); + public static Optional getObtainSettings(@NotNull ObtainType obtainType) { + ObtainSettings settings = OBTAIN_SETTINGS.get().get(obtainType); + return settings == null || !settings.isEnabled() ? Optional.empty() : Optional.of(settings); } } 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 fc73d19..344586b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.config; import su.nexmedia.engine.api.lang.LangKey; import su.nexmedia.engine.lang.EngineLang; +import su.nightexpress.excellentenchants.Placeholders; public class Lang extends EngineLang { @@ -13,13 +14,13 @@ public class Lang extends EngineLang { 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%enchant%&7 enchanted book to &6%player%&7."); + 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_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%tier%&7 enchanted book to &6%player%&7."); + 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 ERROR_NO_ENCHANT = new LangKey("Error.NoEnchant", "&cNo such enchant."); + public static final LangKey ERROR_NO_ENCHANT = new LangKey("Error.NoEnchant", "&cInvalid enchantment."); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/config/ObtainSettings.java b/Core/src/main/java/su/nightexpress/excellentenchants/config/ObtainSettings.java index 468ccee..d4d737f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/ObtainSettings.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/ObtainSettings.java @@ -1,19 +1,49 @@ package su.nightexpress.excellentenchants.config; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; + public class ObtainSettings { - private final int enchantsTotalMax; + private final boolean isEnabled; + private final int enchantsTotalMax; private final double enchantsCustomGenerationChance; private final int enchantsCustomMin; private final int enchantsCustomMax; - public ObtainSettings(int enchantsTotalMax, double enchantsCustomGenerationChance, int enchantsCustomMin, int enchantsCustomMax) { + public ObtainSettings(boolean isEnabled, + int enchantsTotalMax, double enchantsCustomGenerationChance, + int enchantsCustomMin, int enchantsCustomMax) { + this.isEnabled = isEnabled; this.enchantsTotalMax = enchantsTotalMax; this.enchantsCustomGenerationChance = enchantsCustomGenerationChance; this.enchantsCustomMin = enchantsCustomMin; this.enchantsCustomMax = enchantsCustomMax; } + @NotNull + public static ObtainSettings read(@NotNull JYML cfg, @NotNull String path) { + boolean isEnabled = cfg.getBoolean(path + ".Enabled"); + int enchantsTotalMax = cfg.getInt(path + ".Enchantments.Total_Maximum", 4); + double enchantsCustomGenerationChance = cfg.getDouble(path + ".Enchantments.Custom_Generation_Chance", 50D); + int enchantsCustomMin = cfg.getInt(path + ".Enchantments.Custom_Minimum", 0); + int enchantsCustomMax = cfg.getInt(path + ".Enchantments.Custom_Maximum", 2); + + return new ObtainSettings(isEnabled, enchantsTotalMax, enchantsCustomGenerationChance, enchantsCustomMin, enchantsCustomMax); + } + + public static void write(@NotNull JYML cfg, @NotNull String path, @NotNull ObtainSettings settings) { + cfg.set(path + ".Enabled", settings.isEnabled()); + cfg.set(path + ".Enchantments.Total_Maximum", settings.getEnchantsTotalMax()); + cfg.set(path + ".Enchantments.Custom_Generation_Chance", settings.getEnchantsCustomGenerationChance()); + cfg.set(path + ".Enchantments.Custom_Minimum", settings.getEnchantsCustomMin()); + cfg.set(path + ".Enchantments.Custom_Maximum", settings.getEnchantsCustomMax()); + } + + public boolean isEnabled() { + return isEnabled; + } + public int getEnchantsTotalMax() { return enchantsTotalMax; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java similarity index 50% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java index 7513811..691fe95 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager; +package su.nightexpress.excellentenchants.enchantment; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -14,35 +14,37 @@ import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.manager.AbstractManager; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.ItemUtil; +import su.nexmedia.engine.utils.PDCUtil; import su.nexmedia.engine.utils.Pair; 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.IEnchantPotionTemplate; +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.manager.listeners.EnchantGenericListener; -import su.nightexpress.excellentenchants.manager.listeners.EnchantHandlerListener; -import su.nightexpress.excellentenchants.manager.object.EnchantListGUI; -import su.nightexpress.excellentenchants.manager.object.EnchantPopulator; -import su.nightexpress.excellentenchants.manager.object.EnchantTier; -import su.nightexpress.excellentenchants.manager.tasks.ArrowTrailsTask; -import su.nightexpress.excellentenchants.manager.tasks.EnchantEffectPassiveTask; -import su.nightexpress.excellentenchants.manager.type.ObtainType; +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.BiFunction; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; public class EnchantManager extends AbstractManager { - private EnchantListGUI enchantListGUI; - private ArrowTrailsTask arrowTrailsTask; - private EnchantEffectPassiveTask enchantEffectPassiveTask; + private EnchantmentsListMenu enchantmentsListMenu; + + private ArrowTrailsTask arrowTrailsTask; + private PotionEffectsTask potionEffectsTask; public EnchantManager(@NotNull ExcellentEnchants plugin) { super(plugin); @@ -52,44 +54,44 @@ public class EnchantManager extends AbstractManager { protected void onLoad() { EnchantRegister.setup(); - this.enchantListGUI = new EnchantListGUI(this.plugin); + this.enchantmentsListMenu = new EnchantmentsListMenu(this.plugin); this.addListener(new EnchantHandlerListener(this)); this.addListener(new EnchantGenericListener(this)); + this.addListener(new EnchantAnvilListener(this.plugin)); this.arrowTrailsTask = new ArrowTrailsTask(this.plugin); this.arrowTrailsTask.start(); - this.enchantEffectPassiveTask = new EnchantEffectPassiveTask(this.plugin); - this.enchantEffectPassiveTask.start(); + this.potionEffectsTask = new PotionEffectsTask(this.plugin); + this.potionEffectsTask.start(); } @Override protected void onShutdown() { - if (this.enchantListGUI != null) { - this.enchantListGUI.clear(); - this.enchantListGUI = null; + if (this.enchantmentsListMenu != null) { + this.enchantmentsListMenu.clear(); + this.enchantmentsListMenu = null; } if (this.arrowTrailsTask != null) { this.arrowTrailsTask.stop(); this.arrowTrailsTask = null; } - if (this.enchantEffectPassiveTask != null) { - this.enchantEffectPassiveTask.stop(); - this.enchantEffectPassiveTask = null; + if (this.potionEffectsTask != null) { + this.potionEffectsTask.stop(); + this.potionEffectsTask = null; } EnchantRegister.shutdown(); } @NotNull - public EnchantListGUI getEnchantsListGUI() { - return enchantListGUI; + 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)) - /*|| ItemUtil.isWeapon(item) || ItemUtil.isArmor(item) || ItemUtil.isTool(item) || ItemUtil.isBow(item)*/; + return item.getType() == Material.ENCHANTED_BOOK || Stream.of(EnchantmentTarget.values()).anyMatch(target -> target.includes(item)); } @NotNull @@ -103,7 +105,7 @@ public class EnchantManager extends AbstractManager { @NotNull Function levelFunc) { Map enchantsToAdd = new HashMap<>(enchantsPrepared); - ObtainSettings settings = Config.getObtainSettings(obtainType); + ObtainSettings settings = Config.getObtainSettings(obtainType).orElse(null); if (settings == null || !Rnd.chance(settings.getEnchantsCustomGenerationChance())) return enchantsToAdd; int enchMax = settings.getEnchantsTotalMax(); @@ -118,7 +120,7 @@ public class EnchantManager extends AbstractManager { // Достигнут максимум чар (любых) для итема, заканчиваем. if (enchantsToAdd.size() >= enchMax) break; - EnchantTier tier = populator.getTierByChance(); + Tier tier = populator.getTierByChance(); if (tier == null) break; // Нет тира? ExcellentEnchant enchant = populator.getEnchantByChance(tier); @@ -152,53 +154,19 @@ public class EnchantManager extends AbstractManager { } public static boolean populateEnchantments(@NotNull ItemStack item, @NotNull ObtainType obtainType) { - int enchantsHad = EnchantManager.getItemCustomEnchantsAmount(item); + int enchantsHad = EnchantManager.getEnchantmentsAmount(item); EnchantManager.getEnchantsToPopulate(item, obtainType).forEach((enchantment, level) -> { - EnchantManager.addEnchant(item, enchantment, level, false); + EnchantManager.addEnchantment(item, enchantment, level, false); }); - return EnchantManager.getItemCustomEnchantsAmount(item) != enchantsHad; + return EnchantManager.getEnchantmentsAmount(item) != enchantsHad; } - @Deprecated - public static void updateItemLoreEnchants(@NotNull ItemStack item) { - EnchantRegister.ENCHANT_REGISTRY.values().forEach(ench -> { - //ItemUtil.delLore(item, ench.getId()); - //ItemUtil.delLore(item, ench.getId() + "_info"); - }); - - // Filter custom enchants and define map order. - Map excellents = getItemCustomEnchants(item).entrySet().stream() - .sorted((e1,e2) -> e2.getKey().getTier().getPriority() - e1.getKey().getTier().getPriority()) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (has, add) -> add, LinkedHashMap::new)); - - excellents.forEach((excellent, level) -> { - //ItemUtil.addLore(item, excellent.getId(), excellent.getNameFormatted(level), 0); - }); - - // Add enchantment description at the end of item lore. - if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED) { - List list = new ArrayList<>(excellents.keySet()); - Collections.reverse(list); - - list.forEach(excellent -> { - List desc = excellent.getDescription(excellents.get(excellent)); - if (desc.isEmpty()) return; - - //ItemUtil.addLore(item, excellent.getId() + "_info", Config.formatDescription(desc), -1); - }); - } - } - - public static boolean addEnchant(@NotNull ItemStack item, @NotNull Enchantment enchantment, int level, boolean force) { + public static boolean addEnchantment(@NotNull ItemStack item, @NotNull Enchantment enchantment, int level, boolean force) { if (!force && !enchantment.canEnchantItem(item)) return false; - EnchantManager.removeEnchant(item, enchantment); - - //if (enchantment instanceof ExcellentEnchant excellentEnchant) { - //ItemUtil.addLore(item, excellentEnchant.getId(), excellentEnchant.getNameFormatted(level), 0); - //} + EnchantManager.removeEnchantment(item, enchantment); ItemMeta meta = item.getItemMeta(); if (meta == null) return false; @@ -214,11 +182,7 @@ public class EnchantManager extends AbstractManager { return true; } - public static void removeEnchant(@NotNull ItemStack item, @NotNull Enchantment enchantment) { - //if (enchantment instanceof ExcellentEnchant excellentEnchant) { - //ItemUtil.delLore(item, excellentEnchant.getId()); - //} - + public static void removeEnchantment(@NotNull ItemStack item, @NotNull Enchantment enchantment) { ItemMeta meta = item.getItemMeta(); if (meta instanceof EnchantmentStorageMeta storageMeta) { storageMeta.removeStoredEnchant(enchantment); @@ -229,68 +193,103 @@ public class EnchantManager extends AbstractManager { item.setItemMeta(meta); } - // Too expensive @NotNull - @Deprecated - public static Map getItemCustomEnchants(@NotNull ItemStack item) { - return EnchantManager.getItemEnchants(item).entrySet().stream() - .filter(entry -> entry.getKey() instanceof ExcellentEnchant) - .map(entry -> new AbstractMap.SimpleEntry<>((ExcellentEnchant) entry.getKey(), entry.getValue())) - .sorted((e1,e2) -> e2.getKey().getPriority().ordinal() - e1.getKey().getPriority().ordinal()) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (old, nev) -> nev, LinkedHashMap::new)); - } - - @SuppressWarnings("unchecked") - @NotNull - public static Map getItemCustomEnchants(@NotNull ItemStack item, @NotNull Class clazz) { - return EnchantManager.getItemCustomEnchants(item).entrySet().stream() - .filter(entry -> clazz.isAssignableFrom(entry.getKey().getClass())) - .sorted((e1,e2) -> e2.getKey().getPriority().ordinal() - e1.getKey().getPriority().ordinal()) - .collect(Collectors.toMap(k -> (T) k.getKey(), Map.Entry::getValue, (old, nev) -> nev, LinkedHashMap::new)); - } - - @Deprecated - public static int getItemCustomEnchantsAmount(@NotNull ItemStack item) { - return EnchantManager.getItemCustomEnchants(item).size(); - } - - @Deprecated - public static int getItemEnchantLevel(@NotNull ItemStack item, @NotNull Enchantment enchantment) { - return getItemEnchants(item).getOrDefault(enchantment, 0); - } - - @NotNull - @Deprecated - public static Map getItemEnchants(@NotNull ItemStack item) { + public static Map getEnchantments(@NotNull ItemStack item) { ItemMeta meta = item.getItemMeta(); if (meta == null) return Collections.emptyMap(); return (meta instanceof EnchantmentStorageMeta meta2) ? meta2.getStoredEnchants() : meta.getEnchants(); } - @Deprecated - public static int getItemEnchantsAmount(@NotNull ItemStack item) { - return EnchantManager.getItemEnchants(item).size(); + public static int getEnchantmentsAmount(@NotNull ItemStack item) { + return EnchantManager.getEnchantments(item).size(); } public static boolean hasEnchantment(@NotNull ItemStack item, @NotNull Enchantment enchantment) { - return getEnchantmentLevel(item, enchantment) > 0; + return EnchantManager.getEnchantmentLevel(item, enchantment) > 0; } public static int getEnchantmentLevel(@NotNull ItemStack item, @NotNull Enchantment enchant) { - ItemMeta meta = item.getItemMeta(); - if (meta == null) return 0; + return EnchantManager.getEnchantments(item).getOrDefault(enchant, 0); + } - return meta.getEnchantLevel(enchant); + public static int getEnchantmentCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { + return PDCUtil.getIntData(item, enchant.getChargesKey()); + } + + 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.setData(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 EnchantManager.getItemEnchants(item).entrySet().stream() + return EnchantManager.getEnchantments(item).entrySet().stream() .map(entry -> { - ExcellentEnchant ex = EnchantRegister.get(entry.getKey().getKey()); - return ex == null ? null : Pair.of(ex, entry.getValue()); - }).filter(Objects::nonNull) + ExcellentEnchant enchant = EnchantRegister.get(entry.getKey().getKey()); + return enchant == null ? null : Pair.of(enchant, entry.getValue()); + }) + .filter(Objects::nonNull) + .sorted(Comparator.comparing(p -> p.getFirst().getPriority(), Comparator.reverseOrder())) + .collect(Collectors.toMap(Pair::getFirst, Pair::getSecond, (old, nev) -> nev, LinkedHashMap::new)); + } + + @SuppressWarnings("unchecked") + @NotNull + public static Map getExcellentEnchantments(@NotNull ItemStack item, @NotNull Class clazz) { + return EnchantManager.getEnchantments(item).entrySet().stream() + .map(entry -> { + ExcellentEnchant enchant = EnchantRegister.get(entry.getKey().getKey()); + if (enchant == null || !clazz.isAssignableFrom(enchant.getClass())) return null; + return Pair.of((T) enchant, entry.getValue()); + }) + .filter(Objects::nonNull) + .sorted(Comparator.comparing(p -> p.getFirst().getPriority(), Comparator.reverseOrder())) .collect(Collectors.toMap(Pair::getFirst, Pair::getSecond, (old, nev) -> nev, LinkedHashMap::new)); } @@ -311,64 +310,45 @@ public class EnchantManager extends AbstractManager { } @NotNull - public static Map getEquippedEnchantsMax(@NotNull LivingEntity entity) { - return getEquippedEnchants(entity, Math::max); - } - - @NotNull - public static Map getEquippedEnchantsTotal(@NotNull LivingEntity entity) { - return getEquippedEnchants(entity, Integer::sum); - } - - @NotNull - private static Map getEquippedEnchants(@NotNull LivingEntity entity, @NotNull BiFunction remap) { - Map map = new HashMap<>(); - + public static Map getEquipmentEnchanted(@NotNull LivingEntity entity) { Map equipment = EntityUtil.getEquippedItems(entity); - equipment.entrySet().stream().filter(entry -> { - if (entry.getValue() == null) return false; - if (entry.getValue().getType() == Material.ENCHANTED_BOOK) return false; - if ((entry.getKey() == EquipmentSlot.HAND || entry.getKey() == EquipmentSlot.OFF_HAND) && ItemUtil.isArmor(entry.getValue())) return false; - return true; - }).map(Map.Entry::getValue).map(EnchantManager::getItemCustomEnchants).forEach(itemEnchants -> { - itemEnchants.forEach((enchant, level) -> map.merge(enchant, level, remap)); + 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; } - public static int getEquippedEnchantLevelMax(@NotNull LivingEntity entity, @NotNull ExcellentEnchant enchant) { - return getEquippedEnchantsMax(entity).getOrDefault(enchant, 0); - } - - public static int getEquippedEnchantLevelTotal(@NotNull LivingEntity entity, @NotNull ExcellentEnchant enchant) { - return getEquippedEnchantsTotal(entity).getOrDefault(enchant, 0); + @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) { - getEquippedEnchantsMax(entity).forEach((enchant, level) -> { - if (enchant instanceof PassiveEnchant passiveEnchant && enchant instanceof IEnchantPotionTemplate) { - passiveEnchant.use(entity, level); - } + EnchantManager.getEquippedEnchants(entity, PassiveEnchant.class).forEach((item, enchants) -> { + enchants.forEach((enchant, level) -> { + if (enchant instanceof Potioned potioned) { + if (enchant.onTrigger(entity, item, level)) { + enchant.consumeCharges(item); + } + } + }); }); } - - @Nullable - public static EnchantTier getTierById(@NotNull String id) { - return Config.getTierById(id); - } - - @NotNull - public static Collection getTiers() { - return Config.getTiers(); - } - - @NotNull - public static List getTierIds() { - return Config.getTierIds(); - } - - @Nullable - public static EnchantTier getTierByChance(@NotNull ObtainType obtainType) { - return Config.getTierByChance(obtainType); - } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantPopulator.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java similarity index 60% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantPopulator.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java index 5b831c6..dd423ab 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantPopulator.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java @@ -1,26 +1,30 @@ -package su.nightexpress.excellentenchants.manager.object; +package su.nightexpress.excellentenchants.enchantment; import org.bukkit.inventory.ItemStack; 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.config.Config; -import su.nightexpress.excellentenchants.manager.type.ObtainType; +import su.nightexpress.excellentenchants.enchantment.type.ObtainType; +import su.nightexpress.excellentenchants.tier.Tier; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; public class EnchantPopulator { - private final ObtainType obtainType; - private final ItemStack item; - private final Map> enchants; + private final ObtainType obtainType; + private final ItemStack item; + private final Map> enchants; public EnchantPopulator(@NotNull ObtainType obtainType, @NotNull ItemStack item) { this.obtainType = obtainType; this.item = item; - this.enchants = Config.getTiers().stream() + this.enchants = ExcellentEnchantsAPI.getTierManager().getTiers().stream() .collect(Collectors.toMap(k -> k, v -> v.getEnchants(obtainType, item), (prev, add) -> add, HashMap::new)); } @@ -28,15 +32,15 @@ public class EnchantPopulator { return this.getEnchants().isEmpty() || this.getEnchants().values().stream().allMatch(Set::isEmpty); } - public boolean isEmpty(@NotNull EnchantTier tier) { + public boolean isEmpty(@NotNull Tier tier) { return this.getEnchants(tier).isEmpty(); } - public void purge(@NotNull EnchantTier tier) { + public void purge(@NotNull Tier tier) { this.getEnchants().remove(tier); } - public void purge(@NotNull EnchantTier tier, @NotNull ExcellentEnchant enchant) { + public void purge(@NotNull Tier tier, @NotNull ExcellentEnchant enchant) { this.getEnchants(tier).remove(enchant); this.getEnchants().keySet().removeIf(this::isEmpty); } @@ -52,24 +56,24 @@ public class EnchantPopulator { } @NotNull - public Map> getEnchants() { + public Map> getEnchants() { return this.enchants; } @NotNull - public Set getEnchants(@NotNull EnchantTier tier) { + public Set getEnchants(@NotNull Tier tier) { return this.getEnchants().getOrDefault(tier, new HashSet<>()); } @Nullable - public EnchantTier getTierByChance() { - Map map = this.getEnchants().keySet().stream() + public Tier getTierByChance() { + Map map = this.getEnchants().keySet().stream() .collect(Collectors.toMap(k -> k, v -> v.getChance(this.getObtainType()))); return Rnd.get(map); } @Nullable - public ExcellentEnchant getEnchantByChance(@NotNull EnchantTier tier) { + 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); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegister.java similarity index 70% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegister.java index 2f18bbc..4daf1f5 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/EnchantRegister.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegister.java @@ -1,19 +1,19 @@ -package su.nightexpress.excellentenchants.manager; +package su.nightexpress.excellentenchants.enchantment; import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.ICleanable; import su.nexmedia.engine.utils.Reflex; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Config; -import su.nightexpress.excellentenchants.manager.enchants.armor.*; -import su.nightexpress.excellentenchants.manager.enchants.bow.*; -import su.nightexpress.excellentenchants.manager.enchants.tool.*; -import su.nightexpress.excellentenchants.manager.enchants.weapon.*; +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 java.lang.reflect.Field; import java.util.HashMap; @@ -24,19 +24,19 @@ public class EnchantRegister { private static final ExcellentEnchants PLUGIN; public static final Map ENCHANT_REGISTRY; - public static final EnchantBlastMining BLAST_MINING; - public static final EnchantCurseOfBreaking CURSE_OF_BREAKING; + public static final EnchantBlastMining BLAST_MINING; + public static final EnchantCurseOfBreaking CURSE_OF_BREAKING; public static final EnchantCurseOfMisfortune CURSE_OF_MISFORTUNE; - public static final EnchantDivineTouch DIVINE_TOUCH; - public static final EnchantHaste HASTE; - public static final EnchantLuckyMiner LUCKY_MINER; - public static final EnchantReplanter REPLANTER; - public static final EnchantSilkChest SILK_CHEST; - public static final EnchantSmelter SMELTER; - public static final EnchantTelekinesis TELEKINESIS; - public static final EnchantTreasures TREASURES; - public static final EnchantTunnel TUNNEL; - public static final EnchantVeinminer VEINMINER; + public static final EnchantDivineTouch DIVINE_TOUCH; + public static final EnchantHaste HASTE; + public static final EnchantLuckyMiner LUCKY_MINER; + public static final EnchantReplanter REPLANTER; + public static final EnchantSilkChest SILK_CHEST; + public static final EnchantSmelter SMELTER; + public static final EnchantTelekinesis TELEKINESIS; + public static final EnchantTreasures TREASURES; + public static final EnchantTunnel TUNNEL; + public static final EnchantVeinminer VEINMINER; public static final EnchantBaneOfNetherspawn BANE_OF_NETHERSPAWN; public static final EnchantIceAspect ICE_ASPECT; @@ -45,18 +45,18 @@ public class EnchantRegister { public static final EnchantExhaust EXHAUST; public static final EnchantWither WITHER; public static final EnchantParalyze PARALYZE; - public static final EnchantExpHunter EXP_HUNTER; - public static final EnchantDecapitator DECAPITATOR; - public static final EnchantCutter CUTTER; + public static final EnchantExpHunter EXP_HUNTER; + public static final EnchantDecapitator DECAPITATOR; + public static final EnchantCutter CUTTER; public static final EnchantConfusion CONFUSION; public static final EnchantDoubleStrike DOUBLE_STRIKE; - public static final EnchantNimble NIMBLE; + public static final EnchantNimble NIMBLE; public static final EnchantBlindness BLINDNESS; - public static final EnchantVampire VAMPIRE; - public static final EnchantCure CURE; - public static final EnchantRage RAGE; - public static final EnchantScavenger SCAVENGER; - public static final EnchantSurprise SURPRISE; + public static final EnchantVampire VAMPIRE; + public static final EnchantCure CURE; + public static final EnchantRage RAGE; + public static final EnchantScavenger SCAVENGER; + public static final EnchantSurprise SURPRISE; public static final EnchantTemper TEMPER; public static final EnchantThrifty THRIFTY; public static final EnchantThunder THUNDER; @@ -64,28 +64,31 @@ public class EnchantRegister { public static final EnchantRocket ROCKET; public static final EnchantElementalProtection ELEMENTAL_PROTECTION; - public static final EnchantFireShield FIRE_SHIELD; - public static final EnchantFlameWalker FLAME_WALKER; - public static final EnchantHardened HARDENED; - public static final EnchantColdSteel COLD_STEEL; - public static final EnchantSelfDestruction SELF_DESTRUCTION; - public static final EnchantSaturation SATURATION; - public static final EnchantAquaman AQUAMAN; - public static final EnchantNightVision NIGHT_VISION; - public static final EnchantBunnyHop BUNNY_HOP; - public static final EnchantSonic SONIC; - public static final EnchantRegrowth REGROWTH; + public static final EnchantFireShield FIRE_SHIELD; + public static final EnchantFlameWalker FLAME_WALKER; + public static final EnchantHardened HARDENED; + public static final EnchantIceShield ICE_SHIELD; + public static final EnchantColdSteel COLD_STEEL; + public static final EnchantSelfDestruction SELF_DESTRUCTION; + public static final EnchantSaturation SATURATION; + public static final EnchantAquaman AQUAMAN; + public static final EnchantNightVision NIGHT_VISION; + public static final EnchantBunnyHop BUNNY_HOP; + public static final EnchantSonic SONIC; + public static final EnchantRegrowth REGROWTH; - public static final EnchantBomber BOMBER; - public static final EnchantConfusingArrows CONFUSING_ARROWS; - public static final EnchantDragonfireArrows DRAGONFIRE_ARROWS; + public static final EnchantBomber BOMBER; + public static final EnchantConfusingArrows CONFUSING_ARROWS; + public static final EnchantDragonfireArrows DRAGONFIRE_ARROWS; public static final EnchantElectrifiedArrows ELECTRIFIED_ARROWS; - public static final EnchantEnderBow ENDER_BOW; - public static final EnchantGhast GHAST; - public static final EnchantHover HOVER; - public static final EnchantPoisonedArrows POISONED_ARROWS; - public static final EnchantWitheredArrows WITHERED_ARROWS; - public static final EnchantExplosiveArrows EXPLOSIVE_ARROWS; + public static final EnchantEnderBow ENDER_BOW; + public static final EnchantGhast GHAST; + public static final EnchantHover HOVER; + public static final EnchantPoisonedArrows POISONED_ARROWS; + public static final EnchantWitheredArrows WITHERED_ARROWS; + public static final EnchantExplosiveArrows EXPLOSIVE_ARROWS; + + public static final EnchantCurseOfFragility CURSE_OF_FRAGILITY; static { PLUGIN = ExcellentEnchants.getPlugin(ExcellentEnchants.class); @@ -137,6 +140,7 @@ public class EnchantRegister { AQUAMAN = init(EnchantAquaman.class, EnchantAquaman.ID); BUNNY_HOP = init(EnchantBunnyHop.class, EnchantBunnyHop.ID); COLD_STEEL = init(EnchantColdSteel.class, EnchantColdSteel.ID); + ICE_SHIELD = init(EnchantIceShield.class, EnchantIceShield.ID); ELEMENTAL_PROTECTION = init(EnchantElementalProtection.class, EnchantElementalProtection.ID); FIRE_SHIELD = init(EnchantFireShield.class, EnchantFireShield.ID); FLAME_WALKER = init(EnchantFlameWalker.class, EnchantFlameWalker.ID); @@ -159,6 +163,8 @@ public class EnchantRegister { POISONED_ARROWS = init(EnchantPoisonedArrows.class, EnchantPoisonedArrows.ID); WITHERED_ARROWS = init(EnchantWitheredArrows.class, EnchantWitheredArrows.ID); + // Universal + CURSE_OF_FRAGILITY = init(EnchantCurseOfFragility.class, EnchantCurseOfFragility.ID); } public static void setup() { @@ -168,15 +174,12 @@ public class EnchantRegister { return; } - //ENCHANT_LIST.clear(); Reflex.setFieldValue(Enchantment.class, "acceptingNew", true); - for (Field field : EnchantRegister.class.getFields()) { if (!ExcellentEnchant.class.isAssignableFrom(field.getType())) continue; - ExcellentEnchant enchant; try { - enchant = (ExcellentEnchant) field.get(null); + ExcellentEnchant enchant = (ExcellentEnchant) field.get(null); EnchantRegister.register(enchant); } catch (Exception e) { @@ -185,7 +188,7 @@ public class EnchantRegister { } Enchantment.stopAcceptingRegistrations(); - PLUGIN.info("Enchants Registered: " + ENCHANT_REGISTRY.size()); + PLUGIN.info("Enchantments Registered: " + ENCHANT_REGISTRY.size()); ExcellentEnchants.isLoaded = true; } @@ -218,14 +221,12 @@ public class EnchantRegister { @Nullable private static T init(@NotNull Class clazz, @NotNull String id) { - String enchantId = id.toLowerCase(); - if (Config.ENCHANTMENTS_DISABLED.contains(id)) return null; + if (Config.ENCHANTMENTS_DISABLED.get().contains(id)) return null; - JYML enchantCfg = JYML.loadOrExtract(PLUGIN, "/enchants/" + enchantId + ".yml"); try { - return clazz.getConstructor(ExcellentEnchants.class, JYML.class).newInstance(PLUGIN, enchantCfg); + return clazz.getConstructor(ExcellentEnchants.class).newInstance(PLUGIN); } - catch (ReflectiveOperationException ex) { + catch (Exception ex) { ex.printStackTrace(); return null; } @@ -236,8 +237,9 @@ public class EnchantRegister { Enchantment.registerEnchantment(enchant); ENCHANT_REGISTRY.put(enchant.getKey(), enchant); + enchant.loadConfig(); + enchant.getConfig().saveChanges(); enchant.registerListeners(); PLUGIN.info("Registered enchantment: " + enchant.getId()); - //IRegistry.a(IRegistry.ENCHANTMENT, enchant.getId(), CraftEnchantment.getRaw(enchant)); } } 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 new file mode 100644 index 0000000..d61e032 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantScaler.java @@ -0,0 +1,30 @@ +package su.nightexpress.excellentenchants.enchantment.config; + +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 java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class EnchantScaler extends Scaler { + + public EnchantScaler(@NotNull ExcellentEnchant enchant, @NotNull String path) { + super(enchant.getConfig(), path, Placeholders.ENCHANTMENT_LEVEL, enchant.getStartLevel(), enchant.getMaxLevel()); + } + + @NotNull + public static EnchantScaler read(@NotNull ExcellentEnchant enchant, @NotNull String path, @NotNull String def, @Nullable String... comments) { + enchant.getConfig().addMissing(path, def); + if (comments != null) { + List list = new ArrayList<>(Arrays.asList(comments)); + list.add("You can use formulas/expressions here: " + Placeholders.URL_ENGINE_SCALER); + list.add("Level placeholder: " + Placeholders.ENCHANTMENT_LEVEL); + enchant.getConfig().setComments(path, list); + } + return new EnchantScaler(enchant, path); + } +} 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 new file mode 100644 index 0000000..7739947 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantAquaman.java @@ -0,0 +1,33 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.api.enchantment.type.PassiveEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; + +public class EnchantAquaman extends PotionEnchant implements PassiveEnchant { + + public static final String ID = "aquaman"; + + public EnchantAquaman(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.WATER_BREATHING, true); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_HEAD; + } + + @Override + public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(entity) || this.hasEffect(entity)) return false; + + return this.addEffect(entity, level); + } +} 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 new file mode 100644 index 0000000..3733489 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantBunnyHop.java @@ -0,0 +1,33 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.api.enchantment.type.PassiveEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; + +public class EnchantBunnyHop extends PotionEnchant implements PassiveEnchant { + + public static final String ID = "bunny_hop"; + + public EnchantBunnyHop(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.JUMP, true); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_FEET; + } + + @Override + public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(entity) || this.hasEffect(entity)) return false; + + return this.addEffect(entity, level); + } +} 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 new file mode 100644 index 0000000..721c386 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantColdSteel.java @@ -0,0 +1,56 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +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.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantColdSteel extends PotionEnchant implements Chanced, CombatEnchant { + + public static final String ID = "cold_steel"; + + private ChanceImplementation chanceImplementation; + + public EnchantColdSteel(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.SLOW_DIGGING, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_TORSO; + } + + @Override + public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return false; + } + + @Override + public boolean onProtect(@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; + + return this.addEffect(damager, level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantElementalProtection.java similarity index 50% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantElementalProtection.java index 801bc1a..e96f8fd 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantElementalProtection.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantElementalProtection.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.armor; +package su.nightexpress.excellentenchants.enchantment.impl.armor; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; @@ -7,55 +7,57 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.utils.ArrayUtil; -import su.nexmedia.engine.utils.EntityUtil; +import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +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.config.EnchantScaler; +import java.util.Set; import java.util.function.UnaryOperator; -public class EnchantElementalProtection extends IEnchantChanceTemplate { +public class EnchantElementalProtection extends ExcellentEnchant { - public static final String ID = "elemental_protection"; - public static final String PLACEHOLDER_PROTECTION_AMOUNT = "%enchantment_protection_amount%"; + public static final String ID = "elemental_protection"; + public static final String PLACEHOLDER_PROTECTION_AMOUNT = "%enchantment_protection_amount%"; public static final String PLACEHOLDER_PROTECTION_CAPACITY = "%enchantment_protection_capacity%"; - private static final EntityDamageEvent.DamageCause[] DAMAGE_CAUSES = new EntityDamageEvent.DamageCause[] { + private static final Set DAMAGE_CAUSES = Set.of( EntityDamageEvent.DamageCause.POISON, EntityDamageEvent.DamageCause.WITHER, EntityDamageEvent.DamageCause.MAGIC, EntityDamageEvent.DamageCause.FREEZE, - /*EntityDamageEvent.DamageCause.SONIC_BOOM, */EntityDamageEvent.DamageCause.LIGHTNING, - }; + EntityDamageEvent.DamageCause.LIGHTNING); - private Scaler protectionAmount; - private double protectionCapacity; - private boolean protectionAsModifier; + private EnchantScaler protectionAmount; + private double protectionCapacity; + private boolean protectionAsModifier; - public EnchantElementalProtection(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + public EnchantElementalProtection(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); } @Override @NotNull public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str + return str -> super.replacePlaceholders(level).apply(str) .replace(PLACEHOLDER_PROTECTION_AMOUNT, NumberUtil.format(this.getProtectionAmount(level))) .replace(PLACEHOLDER_PROTECTION_CAPACITY, NumberUtil.format(this.getProtectionCapacity())) - ); + ; } @Override public void loadConfig() { super.loadConfig(); - this.protectionAmount = new EnchantScaler(this, "Settings.Protection.Amount"); - this.protectionCapacity = cfg.getDouble("Settings.Protection.Capacity"); - this.protectionAsModifier = cfg.getBoolean("Settings.Protection.As_Modifier"); + 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); + this.protectionAsModifier = JOption.create("Settings.Protection.As_Modifier", false, + "When 'true' damage will be reduced by a percent of protection value.", + "When 'false' damage will be reduced by a plain protection value.").read(cfg); } @NotNull @@ -78,22 +80,20 @@ public class EnchantElementalProtection extends IEnchantChanceTemplate { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onDamage(EntityDamageEvent e) { - if (!ArrayUtil.contains(DAMAGE_CAUSES, e.getCause())) return; - if (!(e.getEntity() instanceof LivingEntity victim)) return; - if (!this.isEnchantmentAvailable(victim)) return; + if (!DAMAGE_CAUSES.contains(e.getCause())) return; + if (!(e.getEntity() instanceof LivingEntity entity)) return; + if (!this.isAvailableToUse(entity)) return; double protectionAmount = 0D; - for (ItemStack armor : EntityUtil.getEquippedArmor(victim).values()) { - if (armor == null || armor.getType().isAir()) continue; + for (ItemStack armor : EnchantManager.getEquipmentEnchanted(entity).values()) { + int level = EnchantManager.getEnchantmentLevel(armor, this); + if (level <= 0) continue; - int level = EnchantManager.getItemEnchantLevel(armor, this); - if (this.checkTriggerChance(level)) { - protectionAmount += this.getProtectionAmount(level); - } + protectionAmount += this.getProtectionAmount(level); + this.consumeCharges(armor); } - if (protectionAmount <= 0D) return; - if (!this.takeCostItem(victim)) return; + if (protectionAmount <= 0D) return; if (protectionAmount > this.getProtectionCapacity()) { protectionAmount = this.getProtectionCapacity(); } 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 new file mode 100644 index 0000000..58de781 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFireShield.java @@ -0,0 +1,86 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +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.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 java.util.function.UnaryOperator; + +public class EnchantFireShield extends ExcellentEnchant implements Chanced, CombatEnchant { + + public static final String ID = "fire_shield"; + public static final String PLACEHOLDER_FIRE_DURATION = "%enchantment_fire_duration%"; + + private EnchantScaler fireDuration; + private ChanceImplementation chanceImplementation; + + public EnchantFireShield(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str) + .replace(PLACEHOLDER_FIRE_DURATION, NumberUtil.format(this.getFireDuration(level))) + ; + } + + @Override + public void loadConfig() { + super.loadConfig(); + + this.chanceImplementation = ChanceImplementation.create(this); + 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."); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR; + } + + public double getFireDuration(int level) { + return this.fireDuration.getValue(level); + } + + @Override + public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return false; + } + + @Override + public boolean onProtect(@NotNull EntityDamageByEntityEvent e, + @NotNull LivingEntity damager, @NotNull LivingEntity victim, + @NotNull ItemStack weapon, int level) { + if (!this.isAvailableToUse(victim)) return false; + if (!this.checkTriggerChance(level)) return false; + + int ticksToSet = (int) (this.getFireDuration(level) * 20); + int ticksHas = damager.getFireTicks(); + if (ticksHas >= ticksToSet) return false; + + damager.setFireTicks(ticksToSet); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFlameWalker.java similarity index 66% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFlameWalker.java index d4bfe21..f2ec964 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFlameWalker.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFlameWalker.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.armor; +package su.nightexpress.excellentenchants.enchantment.impl.armor; import org.bukkit.Location; import org.bukkit.Material; @@ -16,36 +16,32 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.ICleanable; import su.nexmedia.engine.api.task.AbstractTask; import su.nexmedia.engine.utils.EffectUtil; -import su.nexmedia.engine.utils.Scaler; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.MoveEnchant; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +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 java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; -public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEnchant, ICleanable { +public class EnchantFlameWalker extends ExcellentEnchant implements ICleanable { public static final String ID = "flame_walker"; - private static final BlockFace[] FACES = {BlockFace.SOUTH, BlockFace.NORTH, BlockFace.EAST, BlockFace.WEST}; - private static final Map BLOCKS_TO_DESTROY = new HashMap<>(); + private static final BlockFace[] FACES = {BlockFace.SOUTH, BlockFace.NORTH, BlockFace.EAST, BlockFace.WEST}; + private static final Map BLOCKS_TO_DESTROY = new ConcurrentHashMap<>(); - private Scaler blockDecayTime; + private EnchantScaler blockDecayTime; private BlockTickTask blockTickTask; - public EnchantFlameWalker(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + public EnchantFlameWalker(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); this.blockTickTask = new BlockTickTask(plugin); this.blockTickTask.start(); @@ -54,14 +50,8 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn @Override public void loadConfig() { super.loadConfig(); - this.blockDecayTime = new EnchantScaler(this, "Settings.Block_Decay"); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.addMissing("Settings.Block_Decay", "5.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 2"); + this.blockDecayTime = EnchantScaler.read(this, "Settings.Block_Decay", "12.0", + "Sets up to how long (in seconds) blocks will stay before turn back to lava."); } @Override @@ -88,23 +78,10 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn return this.blockDecayTime.getValue(level); } - @Override - public boolean use(@NotNull PlayerMoveEvent e, @NotNull LivingEntity entity, int level) { - if (!this.isEnchantmentAvailable(entity)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(entity)) return false; - - plugin.getEnchantNMS().handleFlameWalker(entity, entity.getLocation(), level).forEach(block -> { - addBlock(block, Rnd.getDouble(this.getBlockDecayTime(level)) + 1); - }); - return true; - } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void onEnchantFlameWalker(PlayerMoveEvent e) { + public void onPlayerMove(PlayerMoveEvent e) { Player player = e.getPlayer(); - if (player.isFlying()) return; - if (!this.isEnchantmentAvailable(player)) return; + if (player.isFlying() || !this.isAvailableToUse(player)) return; Location from = e.getFrom(); Location to = e.getTo(); @@ -114,15 +91,16 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn ItemStack boots = player.getInventory().getBoots(); if (boots == null || boots.getType().isAir()) return; - //int level = boots.getEnchantmentLevel(this); int level = EnchantManager.getEnchantmentLevel(boots, this); - if (level < 1) return; + if (level <= 0) return; Block bTo = to.getBlock().getRelative(BlockFace.DOWN); boolean hasLava = Stream.of(FACES).anyMatch(face -> bTo.getRelative(face).getType() == Material.LAVA); if (!hasLava) return; - this.use(e, player, level); + plugin.getEnchantNMS().handleFlameWalker(player, player.getLocation(), level).forEach(block -> { + addBlock(block, Rnd.getDouble(this.getBlockDecayTime(level)) + 1); + }); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -135,10 +113,10 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onFlameWalkerMagmaDamage(EntityDamageEvent e) { + public void onMagmaDamage(EntityDamageEvent e) { if (e.getCause() != EntityDamageEvent.DamageCause.HOT_FLOOR) return; if (!(e.getEntity() instanceof LivingEntity livingEntity)) return; - if (!this.isEnchantmentAvailable(livingEntity)) return; + if (!this.isAvailableToUse(livingEntity)) return; EntityEquipment equipment = livingEntity.getEquipment(); if (equipment == null) return; @@ -147,8 +125,7 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn if (boots == null || boots.getType().isAir()) return; int level = EnchantManager.getEnchantmentLevel(boots, this); - if (level < 1) return; - if (!this.checkTriggerChance(level)) return; + if (level <= 0) return; e.setCancelled(true); } @@ -169,7 +146,7 @@ public class EnchantFlameWalker extends IEnchantChanceTemplate implements MoveEn long time = BLOCKS_TO_DESTROY.get(block); if (now >= time) { block.setType(Material.LAVA); - EffectUtil.playEffect(block.getLocation(), Particle.BLOCK_CRACK.name(), Material.MAGMA_BLOCK.name(), 0.5, 0.7, 0.5, 0.03, 50); + EffectUtil.playEffect(block.getLocation(), Particle.BLOCK_CRACK, Material.MAGMA_BLOCK.name(), 0.5, 0.7, 0.5, 0.03, 50); 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 new file mode 100644 index 0000000..ab546de --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantHardened.java @@ -0,0 +1,56 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +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.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantHardened extends PotionEnchant implements Chanced, CombatEnchant { + + public static final String ID = "hardened"; + + private ChanceImplementation chanceImplementation; + + public EnchantHardened(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.DAMAGE_RESISTANCE, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_TORSO; + } + + @Override + public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return false; + } + + @Override + public boolean onProtect(@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; + + return this.addEffect(victim, level); + } +} 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 new file mode 100644 index 0000000..328ffb9 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantIceShield.java @@ -0,0 +1,65 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantIceShield extends PotionEnchant implements Chanced, CombatEnchant { + + public static final String ID = "ice_shield"; + + private ChanceImplementation chanceImplementation; + + public EnchantIceShield(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.SLOW, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_TORSO; + } + + @Override + @NotNull + public Chanced getChanceImplementation() { + return this.chanceImplementation; + } + + @Override + public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return false; + } + + @Override + public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isAvailableToUse(victim)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.addEffect(damager, level)) return false; + + 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); + } + 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 new file mode 100644 index 0000000..e17a10b --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantNightVision.java @@ -0,0 +1,33 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.api.enchantment.type.PassiveEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; + +public class EnchantNightVision extends PotionEnchant implements PassiveEnchant { + + public static final String ID = "night_vision"; + + public EnchantNightVision(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.NIGHT_VISION, true); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_HEAD; + } + + @Override + public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(entity) || this.hasEffect(entity)) return false; + + return this.addEffect(entity, level); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..5cd62d9 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantRegrowth.java @@ -0,0 +1,134 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.Particle; +import org.bukkit.attribute.Attribute; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.utils.EntityUtil; +import su.nexmedia.engine.utils.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.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.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.task.AbstractEnchantmentTask; + +import java.util.function.UnaryOperator; + +public class EnchantRegrowth extends ExcellentEnchant implements PassiveEnchant, ICleanable { + + public static final String ID = "regrowth"; + + private static final String PLACEHOLDER_HEAL_AMOUNT = "%enchantment_heal_amount%"; + private static final String PLACEHOLDER_HEAL_MIN_HEALTH = "%enchantment_heal_min_health%"; + private static final String PLACEHOLDER_HEAL_MAX_HEALTH = "%enchantment_heal_max_health%"; + private static final String PLACEHOLDER_HEAL_INTERVAL = "%enchantment_heal_interval%"; + + private long healInterval; + private EnchantScaler healMinHealth; + private EnchantScaler healMaxHealth; + private EnchantScaler healAmount; + + private Task task; + + public EnchantRegrowth(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + + this.task = new Task(plugin); + this.task.start(); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.healInterval = JOption.create("Settings.Heal.Interval", 100, + "How often (in seconds) enchantment will have effect?").read(cfg); + this.healMinHealth = EnchantScaler.read(this, "Settings.Heal.Min_Health", "0.5", + "Minimal entity health for the enchantment to have effect."); + this.healMaxHealth = EnchantScaler.read(this, "Settings.Heal.Max_Health", "20.0", + "Maximal entity health when the enchantment will not heal anymore."); + this.healAmount = EnchantScaler.read(this, "Settings.Heal.Amount", "0.25", + "Amount of hearts to be restored."); + } + + @Override + public void clear() { + if (this.task != null) { + this.task.stop(); + this.task = null; + } + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str) + .replace(PLACEHOLDER_HEAL_AMOUNT, NumberUtil.format(this.getHealAmount(level))) + .replace(PLACEHOLDER_HEAL_MIN_HEALTH, NumberUtil.format(this.getHealMaxHealth(level))) + .replace(PLACEHOLDER_HEAL_MAX_HEALTH, NumberUtil.format(this.getHealMaxHealth(level))) + .replace(PLACEHOLDER_HEAL_INTERVAL, NumberUtil.format((double) this.healInterval / 20D)) + ; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_TORSO; + } + + public double getHealAmount(int level) { + return this.healAmount.getValue(level); + } + + public double getHealMinHealth(int level) { + return this.healMinHealth.getValue(level); + } + + public double getHealMaxHealth(int level) { + return this.healMaxHealth.getValue(level); + } + + public long getHealInterval() { + return this.healInterval; + } + + @Override + public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(entity)) return false; + + double healthMax = EntityUtil.getAttribute(entity, Attribute.GENERIC_MAX_HEALTH); + double healthHas = entity.getHealth(); + if (healthHas < this.getHealMinHealth(level) || healthHas > this.getHealMaxHealth(level)) return false; + if (healthHas >= healthMax) return false; + + double amount = Math.min(healthMax, healthHas + this.getHealAmount(level)); + entity.setHealth(amount); + + if (this.hasVisualEffects()) { + EffectUtil.playEffect(entity.getEyeLocation(), Particle.HEART, "", 0.3, 0.3, 0.3, 0.1, 5); + } + return true; + } + + class Task extends AbstractEnchantmentTask { + + public Task(@NotNull ExcellentEnchants plugin) { + super(plugin, healInterval, false); + } + + @Override + public void action() { + for (LivingEntity entity : this.getEntities()) { + EnchantManager.getEquippedEnchants(entity, EnchantRegrowth.class).forEach((item, enchants) -> { + enchants.forEach((enchant, level) -> 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 new file mode 100644 index 0000000..e614163 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSaturation.java @@ -0,0 +1,117 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +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.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.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.task.AbstractEnchantmentTask; + +import java.util.function.UnaryOperator; + +public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchant, ICleanable { + + public static final String ID = "saturation"; + + private static final String PLACEHOLDER_SATURATION_AMOUNT = "%enchantment_saturation_amount%"; + private static final String PLACEHOLDER_SATURATION_INTERVAL = "%enchantment_saturation_interval%"; + private static final String PLACEHOLDER_SATURATION_MAX_FOOD_LEVEL = "%enchantment_saturation_max_food_level%"; + + private long saturationInterval; + private EnchantScaler saturationAmount; + private EnchantScaler saturationMaxFoodLevel; + + private Task task; + + public EnchantSaturation(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + + this.task = new Task(plugin); + this.task.start(); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.saturationInterval = JOption.create("Settings.Saturation.Interval", 100, + "How often (in seconds) enchantment will have effect?").read(cfg); + this.saturationAmount = EnchantScaler.read(this, "Settings.Saturation.Amount", Placeholders.ENCHANTMENT_LEVEL, + "Amount of food points to restore."); + this.saturationMaxFoodLevel = EnchantScaler.read(this, "Settings.Saturation.Max_Food_Level", "20", + "Maximal player's food level for the enchantment to stop feeding them."); + } + + @Override + public void clear() { + if (this.task != null) { + this.task.stop(); + this.task = null; + } + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str) + .replace(PLACEHOLDER_SATURATION_AMOUNT, NumberUtil.format(this.getSaturationAmount(level))) + .replace(PLACEHOLDER_SATURATION_INTERVAL, NumberUtil.format((double) this.saturationInterval / 20D)) + .replace(PLACEHOLDER_SATURATION_MAX_FOOD_LEVEL, NumberUtil.format(this.getMaxFoodLevel(level))) + ; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_HEAD; + } + + public final int getSaturationAmount(int level) { + return (int) this.saturationAmount.getValue(level); + } + + public final int getMaxFoodLevel(int level) { + return (int) this.saturationMaxFoodLevel.getValue(level); + } + + public long getSaturationInterval() { + return saturationInterval; + } + + @Override + public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(entity)) return false; + if (!(entity instanceof Player player)) return false; + if (player.getFoodLevel() >= this.getMaxFoodLevel(level)) return false; + + int amount = this.getSaturationAmount(level); + player.setFoodLevel(Math.min(20, player.getFoodLevel() + amount)); + player.setSaturation(Math.min(20, player.getSaturation() + amount)); + return true; + } + + class Task extends AbstractEnchantmentTask { + + public Task(@NotNull ExcellentEnchants plugin) { + super(plugin, saturationInterval, false); + } + + @Override + public void action() { + for (LivingEntity entity : this.getEntities()) { + EnchantManager.getEquippedEnchants(entity, EnchantSaturation.class).forEach((item, enchants) -> { + enchants.forEach((enchant, level) -> enchant.onTrigger(entity, item, level)); + }); + } + } + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSelfDestruction.java similarity index 50% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSelfDestruction.java index 01def0c..1ec305a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSelfDestruction.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSelfDestruction.java @@ -1,49 +1,61 @@ -package su.nightexpress.excellentenchants.manager.enchants.armor; +package su.nightexpress.excellentenchants.enchantment.impl.armor; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +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.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import java.util.function.UnaryOperator; -public class EnchantSelfDestruction extends IEnchantChanceTemplate implements DeathEnchant { - - private Scaler explosionSize; +public class EnchantSelfDestruction extends ExcellentEnchant implements Chanced, DeathEnchant { public static final String ID = "self_destruction"; - private static final String META_EXPLOSION_SOURCE = ID + "_explosion_source"; + + private static final String META_EXPLOSION_SOURCE = ID + "_explosion_source"; private static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; - public EnchantSelfDestruction(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + private EnchantScaler explosionSize; + private ChanceImplementation chanceImplementation; + + public EnchantSelfDestruction(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); } @Override public void loadConfig() { super.loadConfig(); - this.explosionSize = new EnchantScaler(this, "Settings.Explosion.Size"); + this.chanceImplementation = ChanceImplementation.create(this); + 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."); } @Override @NotNull public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str + return str -> super.replacePlaceholders(level).apply(str) .replace(PLACEHOLDER_EXPLOSION_POWER, NumberUtil.format(this.getExplosionSize(level))) - ); + ; + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; } @Override @@ -57,18 +69,22 @@ public class EnchantSelfDestruction extends IEnchantChanceTemplate implements De } @Override - public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level) { - if (!this.isEnchantmentAvailable(dead)) return false; + public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + if (!this.isAvailableToUse(entity)) return false; if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(dead)) return false; float size = (float) this.getExplosionSize(level); - dead.setMetadata(META_EXPLOSION_SOURCE, new FixedMetadataValue(plugin, true)); - boolean exploded = dead.getWorld().createExplosion(dead.getLocation(), size, false, false, dead); - dead.removeMetadata(META_EXPLOSION_SOURCE, plugin); + entity.setMetadata(META_EXPLOSION_SOURCE, new FixedMetadataValue(plugin, true)); + boolean exploded = entity.getWorld().createExplosion(entity.getLocation(), size, false, false, entity); + entity.removeMetadata(META_EXPLOSION_SOURCE, plugin); return exploded; } + @Override + public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + return false; + } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onItemDamage(EntityDamageByEntityEvent e) { if (!e.getDamager().hasMetadata(META_EXPLOSION_SOURCE)) return; 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 new file mode 100644 index 0000000..d59dc39 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSonic.java @@ -0,0 +1,33 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.api.enchantment.type.PassiveEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; + +public class EnchantSonic extends PotionEnchant implements PassiveEnchant { + + public static final String ID = "sonic"; + + public EnchantSonic(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.SPEED, true); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_FEET; + } + + @Override + public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(entity) || this.hasEffect(entity)) return false; + + return this.addEffect(entity, level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantBomber.java similarity index 52% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantBomber.java index 3b3208a..0d1aa2f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantBomber.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantBomber.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.bow; +package su.nightexpress.excellentenchants.enchantment.impl.bow; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; @@ -9,48 +9,49 @@ import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +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.BowEnchant; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import java.util.function.UnaryOperator; -public class EnchantBomber extends IEnchantChanceTemplate implements BowEnchant { - - private Scaler fuseTicks; +public class EnchantBomber extends ExcellentEnchant implements Chanced, BowEnchant { public static final String ID = "bomber"; - public static final String PLACEHOLDER_FUSE_TICKS = "%enchantment_fuse_ticks%"; - public EnchantBomber(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.HIGHEST); + private EnchantScaler fuseTicks; + private ChanceImplementation chanceImplementation; + + public EnchantBomber(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.HIGHEST); } @Override public void loadConfig() { super.loadConfig(); - this.fuseTicks = new EnchantScaler(this, "Settings.Fuse_Ticks"); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - this.cfg.addMissing("Settings.Fuse_Ticks", "100 - %enchantment_level% * 10"); + this.chanceImplementation = ChanceImplementation.create(this); + this.fuseTicks = EnchantScaler.read(this, "Settings.Fuse_Ticks", "100 - " + Placeholders.ENCHANTMENT_LEVEL + " * 10", + "Sets fuse ticks (before it will explode) for the launched TNT."); } @Override @NotNull public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_FUSE_TICKS, NumberUtil.format((double) this.getFuseTicks(level) / 20D)) - ); + return str -> super.replacePlaceholders(level).apply(str) + .replace(PLACEHOLDER_FUSE_TICKS, NumberUtil.format((double) this.getFuseTicks(level) / 20D)); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; } public int getFuseTicks(int level) { @@ -64,11 +65,10 @@ public class EnchantBomber extends IEnchantChanceTemplate implements BowEnchant } @Override - public boolean use(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isEnchantmentAvailable(shooter)) return false; + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; if (!this.checkTriggerChance(level)) return false; if (!(e.getProjectile() instanceof Projectile projectile)) return false; - if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; TNTPrimed primed = projectile.getWorld().spawn(projectile.getLocation(), TNTPrimed.class); primed.setVelocity(projectile.getVelocity().multiply(e.getForce() * 1.25)); @@ -79,12 +79,12 @@ public class EnchantBomber extends IEnchantChanceTemplate implements BowEnchant } @Override - public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return false; } @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } } 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 new file mode 100644 index 0000000..e11203a --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantConfusingArrows.java @@ -0,0 +1,76 @@ +package su.nightexpress.excellentenchants.enchantment.impl.bow; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +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.meta.Arrowed; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantConfusingArrows extends PotionEnchant implements Chanced, Arrowed, BowEnchant { + + public static final String ID = "confusing_arrows"; + + private ArrowImplementation arrowImplementation; + private ChanceImplementation chanceImplementation; + + public EnchantConfusingArrows(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.CONFUSION, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.arrowImplementation = ArrowImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ArrowImplementation getArrowImplementation() { + return arrowImplementation; + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; + if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!this.checkTriggerChance(level)) return false; + + return arrow.addCustomEffect(this.createEffect(level), true); + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return this.isOurProjectile(projectile); + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return this.isOurProjectile(projectile); + } +} 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 new file mode 100644 index 0000000..ef630c5 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantDragonfireArrows.java @@ -0,0 +1,133 @@ +package su.nightexpress.excellentenchants.enchantment.impl.bow; + +import org.bukkit.Location; +import org.bukkit.Particle; +import org.bukkit.World; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.AreaEffectCloud; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.projectiles.ProjectileSource; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +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.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.meta.ArrowImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced, Arrowed, BowEnchant { + + public static final String ID = "dragonfire_arrows"; + + public static final String PLACEHOLDER_FIRE_RADIUS = "%enchantment_fire_radius%"; + public static final String PLACEHOLDER_FIRE_DURATION = "%enchantment_fire_duration%"; + + private EnchantScaler fireDuration; + private EnchantScaler fireRadius; + + private ArrowImplementation arrowImplementation; + private ChanceImplementation chanceImplementation; + + public EnchantDragonfireArrows(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + } + + @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, + "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, + "Sets the dragonfire cloud effect radius."); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str) + .replace(PLACEHOLDER_FIRE_DURATION, NumberUtil.format(this.getFireDuration(level) / 20D)) + .replace(PLACEHOLDER_FIRE_RADIUS, NumberUtil.format(this.getFireRadius(level))) + ; + } + + @NotNull + @Override + public ArrowImplementation getArrowImplementation() { + return arrowImplementation; + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + public int getFireDuration(int level) { + return (int) this.fireDuration.getValue(level); + } + + public double getFireRadius(int level) { + return this.fireRadius.getValue(level); + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; + + return this.checkTriggerChance(level); + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + if (!this.isOurProjectile(projectile)) return false; + if (e.getHitEntity() != null) return false; + + this.createCloud(projectile.getShooter(), projectile.getLocation() , level); + return true; + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isOurProjectile(projectile)) return false; + + this.createCloud(shooter, victim.getLocation(), level); + return true; + } + + private void createCloud(@Nullable ProjectileSource shooter, @NotNull Location location, int level) { + World world = location.getWorld(); + if (world == null) return; + + AreaEffectCloud cloud = world.spawn(location, AreaEffectCloud.class); + cloud.clearCustomEffects(); + cloud.setSource(shooter); + cloud.setParticle(Particle.DRAGON_BREATH); + cloud.setRadius((float) this.getFireRadius(level)); + cloud.setDuration(this.getFireDuration(level)); + cloud.setRadiusPerTick((7.0F - cloud.getRadius()) / (float) cloud.getDuration()); + cloud.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 1, 1), true); + } +} 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 new file mode 100644 index 0000000..2709dd0 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantElectrifiedArrows.java @@ -0,0 +1,92 @@ +package su.nightexpress.excellentenchants.enchantment.impl.bow; + +import org.bukkit.Particle; +import org.bukkit.block.Block; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +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.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.meta.ArrowImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chanced, Arrowed, BowEnchant { + + public static final String ID = "electrified_arrows"; + + private ArrowImplementation arrowImplementation; + private ChanceImplementation chanceImplementation; + + public EnchantElectrifiedArrows(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.arrowImplementation = ArrowImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ArrowImplementation getArrowImplementation() { + return arrowImplementation; + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; + + return this.checkTriggerChance(level); + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + if (!this.isOurProjectile(projectile)) return false; + if (e.getHitEntity() != null || e.getHitBlock() == null) return false; + + Block block = e.getHitBlock(); + block.getWorld().strikeLightning(block.getLocation()); + 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); + } + return true; + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isOurProjectile(projectile)) return false; + + plugin.getServer().getScheduler().runTask(plugin, () -> { + victim.setNoDamageTicks(0); + victim.getWorld().strikeLightning(victim.getLocation()); + }); + + 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 new file mode 100644 index 0000000..8c266f5 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantEnderBow.java @@ -0,0 +1,51 @@ +package su.nightexpress.excellentenchants.enchantment.impl.bow; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +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.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; + +public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant { + + public static final String ID = "ender_bow"; + + public EnchantEnderBow(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.HIGHEST); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; + if (!(e.getProjectile() instanceof Projectile projectile)) return false; + + EnderPearl pearl = shooter.launchProjectile(EnderPearl.class); + pearl.setVelocity(projectile.getVelocity()); + e.setProjectile(pearl); + return true; + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return false; + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return false; + } +} 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 new file mode 100644 index 0000000..f7673a7 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantExplosiveArrows.java @@ -0,0 +1,145 @@ +package su.nightexpress.excellentenchants.enchantment.impl.bow; + +import org.bukkit.World; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +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.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.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.meta.ArrowImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; + +import java.util.function.UnaryOperator; + +public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, Arrowed, BowEnchant { + + public static final String ID = "explosive_arrows"; + public static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; + + private static final String META_EXPLOSION_SOURCE = ID + "_source"; + + private boolean explosionFireSpread; + private boolean explosionDamageItems; + private boolean explosionDamageBlocks; + private EnchantScaler explosionSize; + + private ArrowImplementation arrowImplementation; + private ChanceImplementation chanceImplementation; + + public EnchantExplosiveArrows(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.arrowImplementation = ArrowImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this); + 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, + "Sets the explosion size. The more size - the bigger explosion."); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str) + .replace(PLACEHOLDER_EXPLOSION_POWER, NumberUtil.format(this.getExplosionSize(level))) + ; + } + + @NotNull + @Override + public ArrowImplementation getArrowImplementation() { + return arrowImplementation; + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + public final double getExplosionSize(int level) { + return this.explosionSize.getValue(level); + } + + public final boolean isExplosionFireSpread() { + return this.explosionFireSpread; + } + + public final boolean isExplosionDamageBlocks() { + return this.explosionDamageBlocks; + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; + + return this.checkTriggerChance(level); + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + if (!this.isOurProjectile(projectile)) return false; + + Entity shooter = null; + if (projectile.getShooter() instanceof Entity entity) { + shooter = entity; + shooter.setMetadata(META_EXPLOSION_SOURCE, new FixedMetadataValue(this.plugin, true)); + } + + World world = projectile.getWorld(); + float explSize = (float) this.getExplosionSize(level); + boolean explFire = this.isExplosionFireSpread(); + boolean explBlocks = this.isExplosionDamageBlocks(); + boolean exploded = world.createExplosion(projectile.getLocation(), explSize, explFire, explBlocks, shooter); + if (shooter != null) shooter.removeMetadata(META_EXPLOSION_SOURCE, this.plugin); + return exploded; + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return this.isOurProjectile(projectile); + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onItemDamage(EntityDamageByEntityEvent e) { + if (e.getCause() != EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) return; + if (this.explosionDamageItems) return; + if (!e.getDamager().hasMetadata(META_EXPLOSION_SOURCE)) return; + if (!(e.getEntity() instanceof Item item)) return; + + e.setCancelled(true); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantGhast.java similarity index 50% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantGhast.java index 4e18d5f..5e76735 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantGhast.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantGhast.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.bow; +package su.nightexpress.excellentenchants.enchantment.impl.bow; import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; @@ -11,40 +11,33 @@ import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.utils.Scaler; +import su.nexmedia.engine.api.config.JOption; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; -public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { - - private boolean fireSpread; - private Scaler yield; +public class EnchantGhast extends ExcellentEnchant implements BowEnchant { public static final String ID = "ghast"; - public EnchantGhast(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.HIGHEST); + private boolean fireSpread; + private EnchantScaler yield; + + public EnchantGhast(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.HIGHEST); } @Override public void loadConfig() { super.loadConfig(); - this.fireSpread = cfg.getBoolean("Settings.Fire_Spread"); - this.yield = new EnchantScaler(this, "Settings.Yield"); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.addMissing("Settings.Fire_Spread", true); - cfg.addMissing("Settings.Yield", "1.0 * " + Placeholders.ENCHANTMENT_LEVEL); + 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, + "Fireball explosion size/radius. The more value = the bigger the explosion."); } public boolean isFireSpread() { @@ -62,11 +55,9 @@ public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { } @Override - public boolean use(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isEnchantmentAvailable(shooter)) return false; - if (!this.checkTriggerChance(level)) return false; + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; if (!(e.getProjectile() instanceof Projectile projectile)) return false; - if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; Fireball fireball; @@ -88,18 +79,14 @@ public class EnchantGhast extends IEnchantChanceTemplate implements BowEnchant { } @Override - public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return false; } @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - // Support for the 'Power' enchantment. - int power = EnchantManager.getEnchantmentLevel(weapon, Enchantment.ARROW_DAMAGE); - if (power < 1) return false; - - double damagePower = 0.5 + power * 0.5; - e.setDamage(e.getDamage() + damagePower); - return true; + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, + @NotNull LivingEntity shooter, @NotNull LivingEntity victim, + @NotNull ItemStack weapon, int level) { + return false; } } 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 new file mode 100644 index 0000000..405d206 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantHover.java @@ -0,0 +1,76 @@ +package su.nightexpress.excellentenchants.enchantment.impl.bow; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +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.meta.Arrowed; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantHover extends PotionEnchant implements Chanced, Arrowed, BowEnchant { + + public static final String ID = "hover"; + + private ArrowImplementation arrowImplementation; + private ChanceImplementation chanceImplementation; + + public EnchantHover(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.LEVITATION, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.arrowImplementation = ArrowImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ArrowImplementation getArrowImplementation() { + return arrowImplementation; + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; + if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!this.checkTriggerChance(level)) return false; + + return arrow.addCustomEffect(this.createEffect(level), true); + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return this.isOurProjectile(projectile); + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return this.isOurProjectile(projectile); + } +} 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 new file mode 100644 index 0000000..7764532 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantPoisonedArrows.java @@ -0,0 +1,76 @@ +package su.nightexpress.excellentenchants.enchantment.impl.bow; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +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.meta.Arrowed; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantPoisonedArrows extends PotionEnchant implements Chanced, Arrowed, BowEnchant { + + public static final String ID = "poisoned_arrows"; + + private ArrowImplementation arrowImplementation; + private ChanceImplementation chanceImplementation; + + public EnchantPoisonedArrows(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.POISON, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.arrowImplementation = ArrowImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ArrowImplementation getArrowImplementation() { + return arrowImplementation; + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; + if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!this.checkTriggerChance(level)) return false; + + return arrow.addCustomEffect(this.createEffect(level), true); + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return this.isOurProjectile(projectile); + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return this.isOurProjectile(projectile); + } +} 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 new file mode 100644 index 0000000..5614164 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantWitheredArrows.java @@ -0,0 +1,76 @@ +package su.nightexpress.excellentenchants.enchantment.impl.bow; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +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.meta.Arrowed; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantWitheredArrows extends PotionEnchant implements Chanced, Arrowed, BowEnchant { + + public static final String ID = "withered_arrows"; + + private ArrowImplementation arrowImplementation; + private ChanceImplementation chanceImplementation; + + public EnchantWitheredArrows(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.WITHER, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.arrowImplementation = ArrowImplementation.create(this); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ArrowImplementation getArrowImplementation() { + return arrowImplementation; + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; + if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!this.checkTriggerChance(level)) return false; + + return arrow.addCustomEffect(this.createEffect(level), true); + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return this.isOurProjectile(projectile); + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return this.isOurProjectile(projectile); + } +} 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 new file mode 100644 index 0000000..dee5ebe --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/ArrowImplementation.java @@ -0,0 +1,92 @@ +package su.nightexpress.excellentenchants.enchantment.impl.meta; + +import org.bukkit.NamespacedKey; +import org.bukkit.Particle; +import org.bukkit.entity.Projectile; +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.PDCUtil; +import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; +import su.nightexpress.excellentenchants.enchantment.task.ArrowTrailsTask; + +import java.util.Optional; + +public final class ArrowImplementation implements Arrowed { + + private final ExcellentEnchant enchant; + private final NamespacedKey projectileKey; + + private final Particle trailParticle; + private final String trailData; + + private ArrowImplementation(@NotNull ExcellentEnchant enchant, + @Nullable Particle trailParticle, @Nullable String trailData) { + 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 new ArrowImplementation(enchant, trailParticle, trailData); + } + + @Override + @NotNull + public Arrowed getArrowImplementation() { + return this; + } + + @Override + public void addTrail(@NotNull Projectile projectile) { + 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); + } + + @NotNull + @Override + 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; + } + + @Override + public void addData(@NotNull Projectile projectile) { + PDCUtil.setData(projectile, this.getProjectileKey(), this.enchant.getId()); + } + + @Override + public boolean isOurProjectile(@NotNull Projectile projectile) { + String enchantId = PDCUtil.getStringData(projectile, this.getProjectileKey()); + return this.enchant.getId().equalsIgnoreCase(enchantId); + } +} 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 new file mode 100644 index 0000000..02ef093 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/ChanceImplementation.java @@ -0,0 +1,42 @@ +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.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; + + private ChanceImplementation(@NotNull ExcellentEnchant enchant, @NotNull EnchantScaler triggerChance) { + //this.enchant = enchant; + this.triggerChance = triggerChance; + } + + @NotNull + public static ChanceImplementation create(@NotNull ExcellentEnchant enchant) { + return new ChanceImplementation(enchant, EnchantScaler.read(enchant, "Settings.Trigger_Chance", "100", + "A chance that this enchantment will be triggered.")); + } + + @Override + @NotNull + public Chanced getChanceImplementation() { + return this; + } + + @Override + public double getTriggerChance(int level) { + return this.triggerChance.getValue(level); + } + + @Override + public boolean checkTriggerChance(int level) { + return Rnd.chance(this.getTriggerChance(level)); + } +} 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 new file mode 100644 index 0000000..2a4d287 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PotionImplementation.java @@ -0,0 +1,86 @@ +package su.nightexpress.excellentenchants.enchantment.impl.meta; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.utils.Scaler; +import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; +import su.nightexpress.excellentenchants.enchantment.EnchantManager; +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) { + 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.isPermanent = isPermanent; + } + + @Override + @NotNull + public Potioned getPotionImplementation() { + return this; + } + + public static PotionImplementation create(@NotNull ExcellentEnchant enchant, @NotNull PotionEffectType type, boolean isPermanent) { + return new PotionImplementation(enchant, type, isPermanent); + } + + @Override + public boolean isPermanent() { + return this.isPermanent; + } + + @NotNull + public PotionEffectType getEffectType() { + return this.effectType; + } + + public int getEffectDuration(int level) { + return (int) (this.duration.getValue(level) * 20); + } + + public int getEffectAmplifier(int level) { + return (int) this.amplifier.getValue(level); + } + + @NotNull + public PotionEffect createEffect(int level) { + int duration = this.getEffectDuration(level); + int amplifier = Math.max(0, this.getEffectAmplifier(level) - 1); + + return new PotionEffect(this.getEffectType(), duration, amplifier, false, false); + } + + public boolean hasEffect(@NotNull LivingEntity entity) { + return EnchantManager.hasEnchantmentEffect(entity, this.enchant); + } + + public boolean addEffect(@NotNull LivingEntity target, int level) { + if (this.isPermanent()) { + ExcellentEnchantsAPI.PLUGIN.getEnchantNMS().addEnchantmentEffect(target, this.enchant, this.createEffect(level)); + } + else { + target.addPotionEffect(this.createEffect(level)); + } + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantBlastMining.java similarity index 69% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantBlastMining.java index f28dab5..80605a4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantBlastMining.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantBlastMining.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; +package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.block.Block; import org.bukkit.enchantments.EnchantmentTarget; @@ -13,27 +13,24 @@ import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -import su.nightexpress.excellentenchants.hook.HookNCP; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.EnchantRegister; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; -import su.nightexpress.excellentenchants.manager.type.FitItemType; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; +import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.EnchantRegister; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import java.util.List; import java.util.function.UnaryOperator; -public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockBreakEnchant { - - private Scaler explosionPower; - private Scaler minBlockStrength; +public class EnchantBlastMining extends ExcellentEnchant implements Chanced, BlockBreakEnchant { public static final String ID = "blast_mining"; public static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; @@ -41,15 +38,31 @@ public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockB private static final String META_EXPLOSION_SOURCE = ID + "_explosion_source"; private static final String META_EXPLOSION_MINED = ID + "_explosion_mined"; - public EnchantBlastMining(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + private EnchantScaler explosionPower; + private EnchantScaler minBlockStrength; + + private ChanceImplementation chanceImplementation; + + public EnchantBlastMining(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); } @Override public void loadConfig() { super.loadConfig(); - this.explosionPower = new EnchantScaler(this, "Settings.Explosion.Power"); - this.minBlockStrength = new EnchantScaler(this, "Settings.Min_Block_Strength"); + this.chanceImplementation = ChanceImplementation.create(this); + 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", + "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."); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; } public double getExplosionPower(int level) { @@ -65,19 +78,11 @@ public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockB return (strength >= this.getMinBlockStrength(level)); } - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.addMissing("Settings.Min_Block_Strength", "1.5 - " + Placeholders.ENCHANTMENT_LEVEL + " / 10.0"); - } - @Override @NotNull public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_EXPLOSION_POWER, NumberUtil.format(this.getExplosionPower(level))) - ); + return str -> super.replacePlaceholders(level).apply(str) + .replace(PLACEHOLDER_EXPLOSION_POWER, NumberUtil.format(this.getExplosionPower(level))); } @Override @@ -93,8 +98,8 @@ public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockB } @Override - public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isEnchantmentAvailable(player)) return false; + 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; @@ -104,14 +109,13 @@ public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockB if (!this.isBlockHardEnough(block, level)) return false; if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(player)) return false; float power = (float) this.getExplosionPower(level); player.setMetadata(META_EXPLOSION_SOURCE, new FixedMetadataValue(plugin, level)); - HookNCP.exemptBlocks(player); + NoCheatPlusHook.exemptBlocks(player); boolean exploded = block.getWorld().createExplosion(block.getLocation(), power, false, true, player); - HookNCP.unexemptBlocks(player); + NoCheatPlusHook.unexemptBlocks(player); player.removeMetadata(META_EXPLOSION_SOURCE, plugin); return exploded; } @@ -140,7 +144,7 @@ public class EnchantBlastMining extends IEnchantChanceTemplate implements BlockB blockList.clear(); } - // Do not damage around entities by en enchantment explosion. + // Do not damage around entities by enchantment explosion. @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlastExplosionDamage(EntityDamageByEntityEvent e) { if (e.getCause() != DamageCause.ENTITY_EXPLOSION) return; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfBreaking.java similarity index 54% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfBreaking.java index 0c00d63..95c2a32 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfBreaking.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfBreaking.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; +package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; @@ -7,32 +7,36 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +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.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import java.util.function.UnaryOperator; -public class EnchantCurseOfBreaking extends IEnchantChanceTemplate { - - private Scaler durabilityAmount; +public class EnchantCurseOfBreaking extends ExcellentEnchant implements Chanced { public static final String ID = "curse_of_breaking"; public static final String PLACEHOLDER_DURABILITY_AMOUNT = "%enchantment_durability_amount%"; - public EnchantCurseOfBreaking(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + private EnchantScaler durabilityAmount; + private ChanceImplementation chanceImplementation; + + public EnchantCurseOfBreaking(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); } @Override public void loadConfig() { super.loadConfig(); - this.durabilityAmount = new EnchantScaler(this, "Settings.Durability_Amount"); + this.chanceImplementation = ChanceImplementation.create(this); + this.durabilityAmount = EnchantScaler.read(this, "Settings.Durability_Amount", Placeholders.ENCHANTMENT_LEVEL, + "Amount of durability points to be taken from the item."); } @Override @@ -40,6 +44,12 @@ public class EnchantCurseOfBreaking extends IEnchantChanceTemplate { return true; } + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + public int getDurabilityAmount(int level) { return (int) this.durabilityAmount.getValue(level); } @@ -47,9 +57,8 @@ public class EnchantCurseOfBreaking extends IEnchantChanceTemplate { @Override @NotNull public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_DURABILITY_AMOUNT, NumberUtil.format(this.getDurabilityAmount(level))) - ); + return str -> super.replacePlaceholders(level).apply(str) + .replace(PLACEHOLDER_DURABILITY_AMOUNT, NumberUtil.format(this.getDurabilityAmount(level))); } @NotNull @@ -61,14 +70,13 @@ public class EnchantCurseOfBreaking extends IEnchantChanceTemplate { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onItemDurability(PlayerItemDamageEvent e) { Player player = e.getPlayer(); - if (!this.isEnchantmentAvailable(player)) return; + if (!this.isAvailableToUse(player)) return; ItemStack item = e.getItem(); - int level = EnchantManager.getItemEnchantLevel(item, this); + int level = EnchantManager.getEnchantmentLevel(item, this); if (level < 1) return; if (!this.checkTriggerChance(level)) return; - if (!this.takeCostItem(player)) return; int durabilityAmount = this.getDurabilityAmount(level); if (durabilityAmount <= 0) 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 new file mode 100644 index 0000000..f029aad --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfMisfortune.java @@ -0,0 +1,90 @@ +package su.nightexpress.excellentenchants.enchantment.impl.tool; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +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.nightexpress.excellentenchants.ExcellentEnchants; +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.DeathEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.type.FitItemType; + +public class EnchantCurseOfMisfortune extends ExcellentEnchant implements Chanced, BlockBreakEnchant, DeathEnchant { + + public static final String ID = "curse_of_misfortune"; + + private boolean dropExp; + private ChanceImplementation chanceImplementation; + + public EnchantCurseOfMisfortune(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.LOWEST); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + this.dropExp = JOption.create("Settings.Drop_Exp", false, + "When 'true' allows to drop exp from mobs/blocks.").read(cfg); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + public boolean isDropExp() { + return dropExp; + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[] {FitItemType.WEAPON, FitItemType.TOOL}; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BREAKABLE; + } + + @Override + public boolean isCursed() { + return true; + } + + @Override + public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(player)) return false; + if (!this.checkTriggerChance(level)) return false; + + e.setDropItems(false); + if (!this.isDropExp()) e.setExpToDrop(0); + return true; + } + + @Override + public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + if (!this.isAvailableToUse(killer)) return false; + if (!this.checkTriggerChance(level)) return false; + + e.getDrops().clear(); + if (!this.isDropExp()) e.setDroppedExp(0); + return true; + } + + @Override + public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + return false; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantDivineTouch.java similarity index 60% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantDivineTouch.java index e591e67..eb93fb9 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantDivineTouch.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantDivineTouch.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; +package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.Location; import org.bukkit.Material; @@ -17,46 +17,45 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.LocationUtil; -import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +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.CustomDropEnchant; -import su.nightexpress.excellentenchants.manager.type.FitItemType; +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.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.type.FitItemType; -public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockBreakEnchant, CustomDropEnchant { +public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, BlockBreakEnchant, BlockDropEnchant { public static final String ID = "divine_touch"; private static final String META_HANDLE = ID + "_handle"; - private String particleName; - private String particleData; private String spawnerName; + private ChanceImplementation chanceImplementation; - public EnchantDivineTouch(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + public EnchantDivineTouch(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); } @Override public void loadConfig() { super.loadConfig(); - this.particleName = cfg.getString("Settings.Particle.Name", Particle.VILLAGER_HAPPY.name()); - this.particleData = cfg.getString("Settings.Particle.Data", ""); - this.spawnerName = StringUtil.color(cfg.getString("Settings.Spawner_Item.Name", "&aMob Spawner &7(%type%)")); + this.chanceImplementation = ChanceImplementation.create(this); + 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.").read(cfg); } + @NotNull @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.remove("Settings.Particle_Effect"); - cfg.addMissing("Settings.Particle.Name", Particle.VILLAGER_HAPPY.name()); - cfg.addMissing("Settings.Particle.Data", ""); + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; } @Override @@ -81,34 +80,35 @@ public class EnchantDivineTouch extends IEnchantChanceTemplate implements BlockB spawnerItem.setSpawnedType(spawnerBlock.getSpawnedType()); spawnerItem.update(true); stateItem.setBlockState(spawnerItem); - stateItem.setDisplayName(this.spawnerName.replace("%type%", plugin.getLangManager().getEnum(spawnerBlock.getSpawnedType()))); + stateItem.setDisplayName(this.spawnerName.replace(Placeholders.GENERIC_TYPE, plugin.getLangManager().getEnum(spawnerBlock.getSpawnedType()))); itemSpawner.setItemMeta(stateItem); return itemSpawner; } @Override - public void handleDrop(@NotNull EnchantDropContainer e, @NotNull Player player, @NotNull ItemStack item, int level) { - BlockDropItemEvent parent = e.getParent(); - BlockState state = parent.getBlockState(); + public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + BlockState state = e.getBlockState(); Block block = state.getBlock(); - if (!block.hasMetadata(META_HANDLE)) return; - if (!(state instanceof CreatureSpawner spawnerBlock)) return; + if (!block.hasMetadata(META_HANDLE)) return false; + if (!(state instanceof CreatureSpawner spawnerBlock)) return false; - e.getDrop().add(this.getSpawner(spawnerBlock)); + dropContainer.getDrop().add(this.getSpawner(spawnerBlock)); Location location = LocationUtil.getCenter(block.getLocation()); - EffectUtil.playEffect(location, this.particleName, this.particleData, 0.3f, 0.3f, 0.3f, 0.15f, 30); + if (this.hasVisualEffects()) { + EffectUtil.playEffect(location, Particle.VILLAGER_HAPPY, "", 0.3f, 0.3f, 0.3f, 0.15f, 30); + } block.removeMetadata(META_HANDLE, this.plugin); + return true; } @Override - public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { Block block = e.getBlock(); - if (!this.isEnchantmentAvailable(player)) return false; + if (!this.isAvailableToUse(player)) return false; if (!(block.getState() instanceof CreatureSpawner spawnerBlock)) return false; if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(player)) return false; e.setExpToDrop(0); e.setDropItems(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 new file mode 100644 index 0000000..3009687 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantHaste.java @@ -0,0 +1,33 @@ +package su.nightexpress.excellentenchants.enchantment.impl.tool; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.api.enchantment.type.PassiveEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; + +public class EnchantHaste extends PotionEnchant implements PassiveEnchant { + + public static final String ID = "haste"; + + public EnchantHaste(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.FAST_DIGGING, true); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @Override + public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(entity) || this.hasEffect(entity)) return false; + + return this.addEffect(entity, level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantLuckyMiner.java similarity index 51% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantLuckyMiner.java index 1c31f34..d9b1b36 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantLuckyMiner.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantLuckyMiner.java @@ -1,55 +1,59 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; +package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +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.manager.object.EnchantScaler; -import su.nightexpress.excellentenchants.manager.type.FitItemType; +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.type.FitItemType; import java.util.function.UnaryOperator; -public class EnchantLuckyMiner extends IEnchantChanceTemplate implements BlockBreakEnchant { - - private Scaler expModifier; +public class EnchantLuckyMiner extends ExcellentEnchant implements Chanced, BlockBreakEnchant { public static final String ID = "lucky_miner"; - private static final String PLACEHOLDER_EXP_MODIFIER = "%enchantment_exp_modifier%"; - public EnchantLuckyMiner(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + private EnchantScaler expModifier; + private ChanceImplementation chanceImplementation; + + public EnchantLuckyMiner(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); } @Override public void loadConfig() { super.loadConfig(); - this.expModifier = new EnchantScaler(this, "Settings.Exp_Modifier"); + this.chanceImplementation = ChanceImplementation.create(this); + 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."); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; } public double getExpModifier(int level) { return this.expModifier.getValue(level); } - @Override - protected void updateConfig() { - super.updateConfig(); - } - @Override @NotNull public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str + return str -> super.replacePlaceholders(level).apply(str) .replace(PLACEHOLDER_EXP_MODIFIER, NumberUtil.format(this.getExpModifier(level) * 100D - 100D)) - ); + ; } @Override @@ -65,11 +69,9 @@ public class EnchantLuckyMiner extends IEnchantChanceTemplate implements BlockBr } @Override - public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - if (e.isCancelled()) return false; - if (!this.isEnchantmentAvailable(player)) return false; + public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(player)) return false; double expMod = this.getExpModifier(level); e.setExpToDrop((int) ((double) e.getExpToDrop() * expMod)); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantReplanter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantReplanter.java similarity index 79% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantReplanter.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantReplanter.java index 3ab3f80..d7d0656 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantReplanter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantReplanter.java @@ -1,6 +1,5 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; +package su.nightexpress.excellentenchants.enchantment.impl.tool; -import com.google.common.collect.Sets; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; @@ -15,37 +14,40 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.utils.MessageUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.InteractEnchant; -import su.nightexpress.excellentenchants.manager.type.FitItemType; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import java.util.Set; -public class EnchantReplanter extends IEnchantChanceTemplate implements InteractEnchant, BlockBreakEnchant { +public class EnchantReplanter extends ExcellentEnchant implements InteractEnchant, BlockBreakEnchant { + + public static final String ID = "replanter"; private boolean replantOnRightClick; private boolean replantOnPlantBreak; - public static final String ID = "replanter"; - - private static final Set CROPS = Sets.newHashSet( - Material.WHEAT_SEEDS, Material.BEETROOT_SEEDS, Material.MELON_SEEDS, Material.PUMPKIN_SEEDS, + private static final Set CROPS = Set.of( + Material.WHEAT_SEEDS, Material.BEETROOT_SEEDS, + Material.MELON_SEEDS, Material.PUMPKIN_SEEDS, Material.POTATO, Material.CARROT, Material.NETHER_WART); - public EnchantReplanter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.HIGH); + public EnchantReplanter(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.HIGH); } @Override public void loadConfig() { super.loadConfig(); - this.replantOnRightClick = cfg.getBoolean("Settings.Replant.On_Right_Click"); - this.replantOnPlantBreak = cfg.getBoolean("Settings.Replant.On_Plant_Break"); + 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, + "When 'true', crops will be automatically replanted when player break plants with enchanted tool in hand.").read(cfg); } public boolean isReplantOnPlantBreak() { @@ -91,11 +93,6 @@ public class EnchantReplanter extends IEnchantChanceTemplate implements Interact return true; } - @Override - protected void updateConfig() { - super.updateConfig(); - } - @Override @NotNull public FitItemType[] getFitItemTypes() { @@ -109,8 +106,8 @@ public class EnchantReplanter extends IEnchantChanceTemplate implements Interact } @Override - public boolean use(@NotNull PlayerInteractEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isEnchantmentAvailable(player)) return false; + public boolean onInteract(@NotNull PlayerInteractEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(player)) return false; if (!this.isReplantOnRightClick()) return false; // Check for a event hand. We dont want to trigger it twice. @@ -126,9 +123,6 @@ public class EnchantReplanter extends IEnchantChanceTemplate implements Interact if (blockGround == null) return false; if (blockGround.getType() != Material.FARMLAND && blockGround.getType() != Material.SOUL_SAND) return false; - // Check enchantment trigger chance. - if (!this.checkTriggerChance(level)) return false; - // Check if someting is already growing on the farmland. Block blockPlant = blockGround.getRelative(BlockFace.UP); if (!blockPlant.isEmpty()) return false; @@ -149,8 +143,8 @@ public class EnchantReplanter extends IEnchantChanceTemplate implements Interact } @Override - public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isEnchantmentAvailable(player)) return false; + public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(player)) return false; if (!this.isReplantOnPlantBreak()) return false; Block blockPlant = e.getBlock(); @@ -164,9 +158,6 @@ public class EnchantReplanter extends IEnchantChanceTemplate implements Interact BlockData dataPlant = blockPlant.getBlockData(); if (!(dataPlant instanceof Ageable plant)) return false; - // Check enchantment trigger chance. - if (!this.checkTriggerChance(level)) return false; - // Check if crop is not at its maximal age to prevent accidient replant. /*if (plant.getAge() < plant.getMaximumAge()) { e.setCancelled(true); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java similarity index 57% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java index a5aea8e..ab02777 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSilkChest.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java @@ -1,6 +1,5 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; +package su.nightexpress.excellentenchants.enchantment.impl.tool; -import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -18,48 +17,45 @@ import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.BlockStateMeta; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PDCUtil; -import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; -import su.nightexpress.excellentenchants.manager.type.FitItemType; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.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.type.FitItemType; -import java.util.Map; -import java.util.TreeMap; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; -public class EnchantSilkChest extends IEnchantChanceTemplate implements CustomDropEnchant { - - private final Map keyItems; - - private String chestName; +public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEnchant { public static final String ID = "silk_chest"; - public EnchantSilkChest(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.HIGH); - this.keyItems = new TreeMap<>(); + private String chestName; + private List chestLore; + private final NamespacedKey keyChest; - for (int pos = 0; pos < 27; pos++) { - this.getItemKey(pos); - } + public EnchantSilkChest(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.HIGH); + this.keyChest = new NamespacedKey(plugin, ID + ".item"); } @Override public void loadConfig() { super.loadConfig(); - this.chestName = StringUtil.color(cfg.getString("Settings.Chest_Item.Name", "%name% &7(%items% items)")); - } - - @Override - protected void updateConfig() { - super.updateConfig(); + this.chestName = JOption.create("Settings.Chest_Item.Name", "Chest &7(" + Placeholders.GENERIC_AMOUNT + " items)", + "Chest item display name.", + "Use '" + Placeholders.GENERIC_AMOUNT + "' for items amount.").read(cfg); + this.chestLore = JOption.create("Settings.Chest_Item.Lore", new ArrayList<>(), + "Chest item lore.", + "Use '" + Placeholders.GENERIC_AMOUNT + "' for items amount.").read(cfg); } @Override @@ -74,20 +70,34 @@ public class EnchantSilkChest extends IEnchantChanceTemplate implements CustomDr return EnchantmentTarget.TOOL; } - private NamespacedKey getItemKey(int pos) { - return this.keyItems.computeIfAbsent(pos, key -> new NamespacedKey(plugin, "silkchest_item_" + pos)); - } - public boolean isSilkChest(@NotNull ItemStack item) { - return PDCUtil.getStringData(item, this.getItemKey(0)) != null; + return PDCUtil.getBooleanData(item, this.keyChest); } @NotNull public ItemStack getSilkChest(@NotNull Chest chest) { - ItemStack chestItem = new ItemStack(chest.getType()); + ItemStack chestStack = new ItemStack(chest.getType()); + + BlockStateMeta stateMeta = (BlockStateMeta) chestStack.getItemMeta(); + if (stateMeta == null) return chestStack; + + Chest chestItem = (Chest) stateMeta.getBlockState(); + chestItem.getBlockInventory().setContents(chest.getBlockInventory().getContents()); + chestItem.update(true); + + int amount = (int) Stream.of(chestItem.getBlockInventory().getContents()).filter(i -> i != null && !i.getType().isAir()).count(); + + stateMeta.setBlockState(chestItem); + stateMeta.setDisplayName(this.chestName); + stateMeta.setLore(this.chestLore); + chestStack.setItemMeta(stateMeta); + + ItemUtil.replace(chestStack, str -> str.replace(Placeholders.GENERIC_AMOUNT, String.valueOf(amount))); + PDCUtil.setData(chestStack, this.keyChest, true); + return chestStack; // Store and count chest items. - int amount = 0; + /*int amount = 0; int count = 0; for (ItemStack itemInv : chest.getBlockInventory().getContents()) { if (itemInv == null) itemInv = new ItemStack(Material.AIR); @@ -111,30 +121,29 @@ public class EnchantSilkChest extends IEnchantChanceTemplate implements CustomDr chestItem.setItemMeta(meta); } - return chestItem; + return chestItem;*/ } @Override - public void handleDrop(@NotNull EnchantDropContainer e, @NotNull Player player, @NotNull ItemStack item, int level) { - BlockDropItemEvent parent = e.getParent(); - BlockState state = parent.getBlockState(); + public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + BlockState state = e.getBlockState(); Block block = state.getBlock(); - if (!this.isEnchantmentAvailable(player)) return; - if (!(state instanceof Chest chest)) return; - if (!this.checkTriggerChance(level)) return; - if (!this.takeCostItem(player)) return; + if (!this.isAvailableToUse(player)) return false; + if (!(state instanceof Chest chest)) return false; // Добавляем в сундук обратно предметы из дроп листа, кроме самого сундука. - parent.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType() && drop.getItemStack().getAmount() == 1); - chest.getBlockInventory().addItem(parent.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0])); + e.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType() && drop.getItemStack().getAmount() == 1); + chest.getBlockInventory().addItem(e.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0])); // Добавляем кастомный сундук в кастомный дроп лист. - e.getDrop().add(this.getSilkChest(chest)); + dropContainer.getDrop().add(this.getSilkChest(chest)); // Очищаем инвентарь сундука и дефолтный дроп лист. chest.getBlockInventory().clear(); - parent.getItems().clear(); + e.getItems().clear(); + + return true; } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -149,14 +158,14 @@ public class EnchantSilkChest extends IEnchantChanceTemplate implements CustomDr chest.setCustomName(null); chest.update(true); - Inventory inventory = chest.getBlockInventory(); - for (int pos = 0; pos < inventory.getSize(); pos++) { + //Inventory inventory = chest.getBlockInventory(); + /*for (int pos = 0; pos < inventory.getSize(); pos++) { String data = PDCUtil.getStringData(item, this.getItemKey(pos)); if (data == null) continue; ItemStack itemInv = ItemUtil.fromBase64(data); inventory.setItem(pos, itemInv); - } + }*/ } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSmelter.java similarity index 55% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSmelter.java index a6aa542..02574e9 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantSmelter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSmelter.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; +package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.Location; import org.bukkit.Material; @@ -11,38 +11,43 @@ 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.JYML; +import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.LocationUtil; import su.nexmedia.engine.utils.MessageUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; -import su.nightexpress.excellentenchants.manager.type.FitItemType; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantDropContainer; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import java.util.HashMap; import java.util.Map; -public class EnchantSmelter extends IEnchantChanceTemplate implements BlockDropEnchant { +public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDropEnchant { public static final String ID = "smelter"; private Sound sound; - private String particleName; - private String particleData; private Map smeltingTable; + private ChanceImplementation chanceImplementation; - public EnchantSmelter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + public EnchantSmelter(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); } @Override public void loadConfig() { super.loadConfig(); - this.sound = cfg.getEnum("Settings.Sound", Sound.class); - this.particleName = cfg.getString("Settings.Particle.Name", Particle.FLAME.name()); - this.particleData = cfg.getString("Settings.Particle.Data", ""); + this.chanceImplementation = ChanceImplementation.create(this); + + 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()); @@ -58,16 +63,17 @@ public class EnchantSmelter extends IEnchantChanceTemplate implements BlockDropE } this.smeltingTable.put(mFrom, mTo); } + this.cfg.setComments("Settings.Smelting_Table", + "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"); } + @NotNull @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.remove("Settings.Particle_Effect"); - cfg.addMissing("Settings.Sound", Sound.BLOCK_LAVA_EXTINGUISH.name()); - cfg.addMissing("Settings.Particle.Name", Particle.FLAME.name()); - cfg.addMissing("Settings.Particle.Data", ""); + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; } @Override @@ -76,13 +82,6 @@ public class EnchantSmelter extends IEnchantChanceTemplate implements BlockDropE return new FitItemType[]{FitItemType.PICKAXE, FitItemType.AXE, FitItemType.SHOVEL}; } - /*@Override - protected void addConflicts() { - super.addConflicts(); - this.addConflict(Enchantment.SILK_TOUCH); - this.addConflict(EnchantRegister.DIVINE_TOUCH); - }*/ - @Override @NotNull public EnchantmentTarget getItemTarget() { @@ -90,12 +89,11 @@ public class EnchantSmelter extends IEnchantChanceTemplate implements BlockDropE } @Override - public boolean use(@NotNull BlockDropItemEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { if (e.getBlockState() instanceof Container) return false; - if (!this.isEnchantmentAvailable(player)) return false; + if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; if (e.getItems().stream().noneMatch(drop -> this.isSmeltable(drop.getItemStack().getType()))) return false; - if (!this.takeCostItem(player)) return false; e.getItems().forEach(drop -> { Material material = this.smeltingTable.get(drop.getItemStack().getType()); @@ -103,17 +101,15 @@ public class EnchantSmelter extends IEnchantChanceTemplate implements BlockDropE }); Block block = e.getBlockState().getBlock(); - this.playEffect(block); + 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); + } return true; } public boolean isSmeltable(@NotNull Material material) { return this.smeltingTable.containsKey(material); } - - public void playEffect(@NotNull Block block) { - Location location = LocationUtil.getCenter(block.getLocation(), true); - MessageUtil.sound(location, this.sound); - EffectUtil.playEffect(location, this.particleName, this.particleData, 0.2f, 0.2f, 0.2f, 0.05f, 30); - } } 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 new file mode 100644 index 0000000..8c70c4f --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTelekinesis.java @@ -0,0 +1,56 @@ +package su.nightexpress.excellentenchants.enchantment.impl.tool; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Item; +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.utils.PlayerUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.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.type.FitItemType; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class EnchantTelekinesis extends ExcellentEnchant implements BlockDropEnchant { + + public static final String ID = "telekinesis"; + + public EnchantTelekinesis(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.LOWEST); + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[]{FitItemType.TOOL}; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @Override + public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(player)) return false; + + List drops = new ArrayList<>(); + drops.addAll(e.getItems().stream().map(Item::getItemStack).toList()); + drops.addAll(dropContainer.getDrop()); + drops.removeIf(Objects::isNull); + drops.forEach(drop -> PlayerUtil.addItem(player, drop)); + + dropContainer.getDrop().clear(); + e.getItems().clear(); + + return true; + } +} 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 new file mode 100644 index 0000000..df9f323 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTreasures.java @@ -0,0 +1,121 @@ +package su.nightexpress.excellentenchants.enchantment.impl.tool; + +import org.bukkit.Material; +import org.bukkit.block.Block; +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.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.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.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 static final String ID = "treasures"; + + private Map> treasures; + private ChanceImplementation chanceImplementation; + + private final Predicate blockTracker; + + public EnchantTreasures(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + + PlayerBlockTracker.initialize(plugin); + PlayerBlockTracker.BLOCK_FILTERS.add(this.blockTracker = (block) -> { + return !this.getTreasures(block.getType()).isEmpty(); + }); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + + this.treasures = new HashMap<>(); + for (String sFromArray : cfg.getSection("Settings.Treasures")) { + for (String sFrom : sFromArray.split(",")) { + Material mFrom = Material.getMaterial(sFrom.toUpperCase()); + if (mFrom == null) { + plugin.error("[Treasures] Invalid source material '" + sFrom + "' !"); + continue; + } + Map treasuresList = new HashMap<>(); + + for (String sTo : cfg.getSection("Settings.Treasures." + sFromArray)) { + Material mTo = Material.getMaterial(sTo.toUpperCase()); + if (mTo == null) { + plugin.error("[Treasures] Invalid result material '" + sTo + "' for '" + sFromArray + "' !"); + continue; + } + + double tChance = cfg.getDouble("Settings.Treasures." + sFromArray + "." + sTo); + treasuresList.put(mTo, tChance); + } + this.treasures.put(mFrom, treasuresList); + } + } + + this.cfg.setComments("Settings.Treasures", + "List of source materials (blocks that will drop additional loot). Separated by a comma.", + "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html"); + } + + @Override + public void clear() { + PlayerBlockTracker.BLOCK_FILTERS.remove(this.blockTracker); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[]{FitItemType.PICKAXE, FitItemType.AXE, FitItemType.SHOVEL}; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.TOOL; + } + + @Override + public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + Block block = e.getBlockState().getBlock(); + 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())); + return true; + } + + @NotNull + public final List getTreasures(@NotNull Material type) { + List list = new ArrayList<>(); + Map treasures = this.treasures.getOrDefault(type, Collections.emptyMap()); + treasures.forEach((mat, chance) -> { + if (mat.isAir() || !mat.isItem() || !Rnd.chance(chance)) return; + list.add(new ItemStack(mat)); + }); + return list; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTunnel.java similarity index 77% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTunnel.java index 9424d21..0b027bb 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTunnel.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTunnel.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; +package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.Material; import org.bukkit.Particle; @@ -10,24 +10,22 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.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.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -import su.nightexpress.excellentenchants.hook.HookNCP; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.EnchantRegister; -import su.nightexpress.excellentenchants.manager.type.FitItemType; +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.type.FitItemType; import java.util.HashSet; import java.util.Set; -public class EnchantTunnel extends IEnchantChanceTemplate implements BlockBreakEnchant { - - private boolean disableOnSneak; +public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant { public static final String ID = "tunnel"; private static final String META_BLOCK_TUNNEL = ID + "_block_tunneled"; @@ -40,19 +38,17 @@ public class EnchantTunnel extends IEnchantChanceTemplate implements BlockBreakE INTERACTABLE_BLOCKS.add(Material.DEEPSLATE_REDSTONE_ORE); } - public EnchantTunnel(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.HIGH); + private boolean disableOnSneak; + + public EnchantTunnel(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.HIGH); } @Override public void loadConfig() { super.loadConfig(); - this.disableOnSneak = cfg.getBoolean("Settings.Ignore_When_Sneaking"); - } - - @Override - protected void updateConfig() { - super.updateConfig(); + this.disableOnSneak = JOption.create("Settings.Ignore_When_Sneaking", true, + "When 'true' the enchantment won't be triggered when sneaking.").read(cfg); } @Override @@ -68,17 +64,15 @@ public class EnchantTunnel extends IEnchantChanceTemplate implements BlockBreakE } @Override - public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { Block block = e.getBlock(); - if (!this.isEnchantmentAvailable(player)) return false; + 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 (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; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(player)) return false; BlockFace dir = LocationUtil.getDirection(player); boolean isY = dir != null && block.getRelative(dir.getOppositeFace()).isEmpty(); @@ -90,7 +84,7 @@ public class EnchantTunnel extends IEnchantChanceTemplate implements BlockBreakE else if (level == 2) blocksBroken = 5; else if (level == 3) blocksBroken = 9; - HookNCP.exemptBlocks(player); + NoCheatPlusHook.exemptBlocks(player); for (int i = 0; i < blocksBroken; i++) { if (item.getType().isAir()) break; @@ -127,7 +121,7 @@ public class EnchantTunnel extends IEnchantChanceTemplate implements BlockBreakE blockAdd.removeMetadata(META_BLOCK_TUNNEL, plugin); } - HookNCP.unexemptBlocks(player); + NoCheatPlusHook.unexemptBlocks(player); return true; } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantVeinminer.java similarity index 69% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantVeinminer.java index 62894bf..4a817f0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantVeinminer.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantVeinminer.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; +package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.Material; import org.bukkit.Particle; @@ -10,19 +10,20 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.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.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -import su.nightexpress.excellentenchants.hook.HookNCP; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.EnchantRegister; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; -import su.nightexpress.excellentenchants.manager.type.FitItemType; +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.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import java.util.HashSet; import java.util.Objects; @@ -31,26 +32,31 @@ import java.util.function.UnaryOperator; import java.util.stream.Collectors; import java.util.stream.Stream; -public class EnchantVeinminer extends IEnchantChanceTemplate implements BlockBreakEnchant { +public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnchant { + + public static final String ID = "veinminer"; + + private static final BlockFace[] AREA = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH}; + private static final String META_BLOCK_VEINED = ID + "_block_veined"; + private static final String PLACEHOLDER_BLOCK_LIMIT = "%enchantment_block_limit%"; private Scaler blocksLimit; private Set blocksAffected; - public static final String ID = "veinminer"; - - private static final BlockFace[] AREA = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH}; - private static final String META_BLOCK_VEINED = ID + "_block_veined"; - private static final String PLACEHOLDER_BLOCK_LIMIT = "%enchantment_block_limit%"; - - public EnchantVeinminer(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.HIGH); + public EnchantVeinminer(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.HIGH); } @Override public void loadConfig() { super.loadConfig(); - this.blocksLimit = new EnchantScaler(this, "Settings.Blocks.Max_At_Once"); - this.blocksAffected = cfg.getStringSet("Settings.Blocks.Affected").stream() + + 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<>(), + "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()); } @@ -66,9 +72,9 @@ public class EnchantVeinminer extends IEnchantChanceTemplate implements BlockBre @Override @NotNull public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str + return str -> super.replacePlaceholders(level).apply(str) .replace(PLACEHOLDER_BLOCK_LIMIT, String.valueOf(this.getBlocksLimit(level))) - ); + ; } @Override @@ -114,22 +120,19 @@ public class EnchantVeinminer extends IEnchantChanceTemplate implements BlockBre } @Override - public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack tool, int level) { - if (!this.isEnchantmentAvailable(player)) return false; + 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; Block block = e.getBlock(); if (block.hasMetadata(META_BLOCK_VEINED)) return false; if (block.getDrops(tool).isEmpty()) return false; - if (!this.getBlocksAffected().contains(block.getType())) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(player)) return false; - HookNCP.exemptBlocks(player); + NoCheatPlusHook.exemptBlocks(player); this.vein(player, block, level); - HookNCP.unexemptBlocks(player); + NoCheatPlusHook.unexemptBlocks(player); return true; } 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 new file mode 100644 index 0000000..1f87a7e --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/EnchantCurseOfFragility.java @@ -0,0 +1,77 @@ +package su.nightexpress.excellentenchants.enchantment.impl.universal; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareAnvilEvent; +import org.bukkit.inventory.AnvilInventory; +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; + +public class EnchantCurseOfFragility extends ExcellentEnchant { + + public static final String ID = "curse_of_fragility"; + + public EnchantCurseOfFragility(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BREAKABLE; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onItemAnvil(PrepareAnvilEvent e) { + AnvilInventory inventory = e.getInventory(); + 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); + + if (cursedFirst || cursedSecond) { + e.setResult(null); + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onItemGrindstoneClick(InventoryClickEvent e) { + Inventory inventory = e.getInventory(); + if (inventory.getType() != InventoryType.GRINDSTONE) return; + + this.stopGrindstone(inventory); + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onItemGrindstoneDrag(InventoryDragEvent e) { + Inventory inventory = e.getInventory(); + if (inventory.getType() != InventoryType.GRINDSTONE) return; + + this.stopGrindstone(inventory); + } + + private void stopGrindstone(@NotNull Inventory inventory) { + plugin.getScheduler().runTask(plugin, () -> { + 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); + + 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 new file mode 100644 index 0000000..7b38ea4 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBaneOfNetherspawn.java @@ -0,0 +1,87 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.EntityType; +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.api.config.JOption; +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 java.util.Set; +import java.util.function.UnaryOperator; + +public class EnchantBaneOfNetherspawn extends ExcellentEnchant implements CombatEnchant { + + public static final String ID = "bane_of_netherspawn"; + + private static final String PLACEHOLDER_DAMAGE = "%enchantment_damage%"; + private static final Set ENTITY_TYPES = Set.of( + EntityType.BLAZE, EntityType.MAGMA_CUBE, + EntityType.WITHER_SKELETON, EntityType.GHAST, EntityType.WITHER, + EntityType.PIGLIN, EntityType.PIGLIN_BRUTE, + EntityType.ZOGLIN, EntityType.HOGLIN, + EntityType.STRIDER, EntityType.ZOMBIFIED_PIGLIN + ); + + private boolean damageModifier; + private EnchantScaler damageFormula; + + public EnchantBaneOfNetherspawn(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + 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, + "Amount of additional damage."); + } + + public double getDamageModifier(int level) { + return this.damageFormula.getValue(level); + } + + @Override + @NotNull + public UnaryOperator replacePlaceholders(int level) { + return str -> super.replacePlaceholders(level).apply(str) + .replace(PLACEHOLDER_DAMAGE, NumberUtil.format(this.getDamageModifier(level))); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!ENTITY_TYPES.contains(victim.getType())) return false; + if (!this.isAvailableToUse(damager)) return false; + + double damageEvent = e.getDamage(); + 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); + } + return true; + } + + @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/EnchantBlindness.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBlindness.java new file mode 100644 index 0000000..ebf35a0 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBlindness.java @@ -0,0 +1,62 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantBlindness extends PotionEnchant implements Chanced, CombatEnchant { + + public static final String ID = "blindness"; + + private ChanceImplementation chanceImplementation; + + public EnchantBlindness(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.BLINDNESS, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @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; + + if (this.hasVisualEffects()) { + EffectUtil.playEffect(victim.getEyeLocation(), Particle.SMOKE_NORMAL, "", 0.25, 0.25, 0.25, 0.1f, 30); + } + return true; + } + + @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/EnchantConfusion.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantConfusion.java new file mode 100644 index 0000000..b31e5ef --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantConfusion.java @@ -0,0 +1,63 @@ +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; +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.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantConfusion extends PotionEnchant implements Chanced, CombatEnchant { + + public static final String ID = "confusion"; + + private ChanceImplementation chanceImplementation; + + public EnchantConfusion(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.CONFUSION, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @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; + + if (this.hasVisualEffects()) { + EffectUtil.playEffect(victim.getEyeLocation(), Particle.ITEM_CRACK, Material.ROTTEN_FLESH.name(), 0.25, 0.25, 0.25, 0.1f, 30); + } + return true; + } + + @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/EnchantCure.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCure.java new file mode 100644 index 0000000..90efddd --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCure.java @@ -0,0 +1,78 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import com.google.common.collect.Sets; +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +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.nightexpress.excellentenchants.ExcellentEnchants; +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 java.util.Set; + +public class EnchantCure extends ExcellentEnchant implements Chanced, CombatEnchant { + + public static final String ID = "cure"; + + private ChanceImplementation chanceImplementation; + + private static final Set CUREABLE = Sets.newHashSet(EntityType.ZOMBIFIED_PIGLIN, EntityType.ZOMBIE_VILLAGER); + + public EnchantCure(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @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 (!CUREABLE.contains(victim.getType())) return false; + if (!this.checkTriggerChance(level)) return false; + if (!(damager instanceof Player player)) return false; + + e.setCancelled(true); + + if (this.hasVisualEffects()) { + EffectUtil.playEffect(victim.getEyeLocation(), Particle.CLOUD, "", 0.25, 0.25, 0.25, 0.1f, 30); + } + + if (victim instanceof PigZombie pigZombie) { + victim.getWorld().spawn(victim.getLocation(), Piglin.class); + victim.remove(); + } + else if (victim instanceof ZombieVillager zombieVillager) { + zombieVillager.setConversionTime(1); + zombieVillager.setConversionPlayer(player); + } + return true; + } + + @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/manager/enchants/weapon/EnchantCutter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCutter.java similarity index 56% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCutter.java index ec49c0f..b901c0f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCutter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCutter.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; +package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Particle; import org.bukkit.Sound; @@ -11,57 +11,56 @@ 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.api.config.JYML; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.MessageUtil; import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +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.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import java.util.function.UnaryOperator; -public class EnchantCutter extends IEnchantChanceTemplate implements CombatEnchant { - - protected Scaler durabilityReduction; - protected Sound sound; +public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEnchant { public static final String ID = "cutter"; - private static final String PLACEHOLDER_DURABILITY_DAMAGE = "%enchantment_durability_damage%"; - public EnchantCutter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.LOWEST); + private EnchantScaler durabilityReduction; + private ChanceImplementation chanceImplementation; + + public EnchantCutter(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.LOWEST); } @Override public void loadConfig() { super.loadConfig(); - this.durabilityReduction = new EnchantScaler(this, "Settings.Item.Durability_Reduction"); - this.sound = cfg.getEnum("Settings.Item.Sound", Sound.class); + this.chanceImplementation = ChanceImplementation.create(this); + this.durabilityReduction = EnchantScaler.read(this, "Settings.Item.Durability_Reduction", Placeholders.ENCHANTMENT_LEVEL + " / 100", + "Amount (in percent) of how much item durability will be reduced."); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; } public final double getDurabilityReduction(int level) { return this.durabilityReduction.getValue(level); } - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.addMissing("Settings.Item.Sound", Sound.ENTITY_ITEM_BREAK.name()); - } - @Override @NotNull public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_DURABILITY_DAMAGE, NumberUtil.format(this.getDurabilityReduction(level) * 100D)) - ); + return str -> super.replacePlaceholders(level).apply(str) + .replace(PLACEHOLDER_DURABILITY_DAMAGE, NumberUtil.format(this.getDurabilityReduction(level) * 100D)); } @Override @@ -71,8 +70,8 @@ public class EnchantCutter extends IEnchantChanceTemplate implements CombatEncha } @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(damager)) return false; + public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isAvailableToUse(damager)) return false; EntityEquipment equipment = victim.getEquipment(); if (equipment == null) return false; @@ -88,7 +87,6 @@ public class EnchantCutter extends IEnchantChanceTemplate implements CombatEncha ItemMeta meta = itemCut.getItemMeta(); if (!(meta instanceof Damageable damageable)) return false; if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(damager)) return false; damageable.setDamage((int) (itemCut.getType().getMaxDurability() * this.getDurabilityReduction(level))); itemCut.setItemMeta(damageable); @@ -100,8 +98,15 @@ public class EnchantCutter extends IEnchantChanceTemplate implements CombatEncha drop.setPickupDelay(50); drop.getVelocity().multiply(3D); - EffectUtil.playEffect(victim.getEyeLocation(), Particle.ITEM_CRACK.name(), itemCut.getType().name(), 0.2f, 0.15f, 0.2f, 0.15f, 40); - MessageUtil.sound(victim.getLocation(), this.sound); + if (this.hasVisualEffects()) { + EffectUtil.playEffect(victim.getEyeLocation(), Particle.ITEM_CRACK.name(), itemCut.getType().name(), 0.2f, 0.15f, 0.2f, 0.15f, 40); + MessageUtil.sound(victim.getLocation(), Sound.ENTITY_ITEM_BREAK); + } return true; } + + @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/EnchantDecapitator.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDecapitator.java new file mode 100644 index 0000000..24e327d --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDecapitator.java @@ -0,0 +1,143 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + + +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDeathEvent; +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.utils.EffectUtil; +import su.nexmedia.engine.utils.ItemUtil; +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.meta.ChanceImplementation; + +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 ChanceImplementation chanceImplementation; + + public EnchantDecapitator(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + + 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.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.put(sType.toUpperCase(), cfg.getString("Settings.Head_Item.Textures." + sType, "")); + } + this.cfg.setComments("Settings.Head_Item.Textures", + "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"); + + /*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.", + "You can take some from http://minecraft-heads.com", + "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html").read(cfg);*/ + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + return false; + } + + @Override + public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + if (!this.isAvailableToUse(entity)) return false; + + EntityType entityType = entity.getType(); + if (this.ignoredEntityTypes.contains(entityType.name())) return false; + if (!this.checkTriggerChance(level)) return false; + + ItemStack item; + if (entityType == EntityType.WITHER_SKELETON || entityType == EntityType.WITHER) { + item = new ItemStack(Material.WITHER_SKELETON_SKULL); + } + else if (entityType == EntityType.ZOMBIE || entityType == EntityType.GIANT) { + item = new ItemStack(Material.ZOMBIE_HEAD); + } + else if (entityType == EntityType.SKELETON) { + item = new ItemStack(Material.SKELETON_SKULL); + } + else if (entityType == EntityType.CREEPER) { + item = new ItemStack(Material.CREEPER_HEAD); + } + else if (entityType == EntityType.ENDER_DRAGON) { + item = new ItemStack(Material.DRAGON_HEAD); + } + else { + item = new ItemStack(Material.PLAYER_HEAD); + SkullMeta meta = (SkullMeta) item.getItemMeta(); + if (meta == null) return false; + + String entityName; + if (entity instanceof Player player) { + entityName = this.headName.replace(Placeholders.GENERIC_TYPE, entity.getName()); + meta.setOwningPlayer(player); + } + else { + String texture = this.headTextures.get(entity.getType().name()); + if (texture == null) return false; + + entityName = this.headName.replace(Placeholders.GENERIC_TYPE, plugin.getLangManager().getEnum(entity.getType())); + ItemUtil.setSkullTexture(item, texture); + meta = (SkullMeta) item.getItemMeta(); + } + + meta.setDisplayName(entityName); + item.setItemMeta(meta); + } + + 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); + } + return true; + } +} 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 new file mode 100644 index 0000000..218838a --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDoubleStrike.java @@ -0,0 +1,65 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.Particle; +import org.bukkit.Sound; +import org.bukkit.enchantments.EnchantmentTarget; +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.utils.MessageUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +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; + +public class EnchantDoubleStrike extends ExcellentEnchant implements Chanced, CombatEnchant { + + public static final String ID = "double_strike"; + + private ChanceImplementation chanceImplementation; + + public EnchantDoubleStrike(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.LOW); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @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; + + e.setDamage(e.getDamage() * 2D); + + if (this.hasVisualEffects()) { + EffectUtil.playEffect(victim.getEyeLocation(), Particle.EXPLOSION_NORMAL, "", 0.2f, 0.15f, 0.2f, 0.15f, 20); + MessageUtil.sound(victim.getLocation(), Sound.ENTITY_GENERIC_EXPLODE); + } + return true; + } + + @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/EnchantExhaust.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExhaust.java new file mode 100644 index 0000000..921e238 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExhaust.java @@ -0,0 +1,62 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantExhaust extends PotionEnchant implements Chanced, CombatEnchant { + + public static final String ID = "exhaust"; + + private ChanceImplementation chanceImplementation; + + public EnchantExhaust(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.HUNGER, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @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; + + if (this.hasVisualEffects()) { + EffectUtil.playEffect(victim.getEyeLocation(), Particle.SPELL_MOB, "60,180,20", 0.2f, 0.15f, 0.2f, 0.15f, 20); + } + return true; + } + + @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/manager/enchants/weapon/EnchantExpHunter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExpHunter.java similarity index 55% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExpHunter.java index aff8142..99a0b8d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExpHunter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExpHunter.java @@ -1,53 +1,48 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; +package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDeathEvent; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import java.util.function.UnaryOperator; -public class EnchantExpHunter extends IEnchantChanceTemplate implements DeathEnchant { - - private Scaler expModifier; +public class EnchantExpHunter extends ExcellentEnchant implements DeathEnchant { public static final String ID = "exp_hunter"; public static final String PLACEHOLDER_EXP_MODIFIER = "%enchantment_exp_modifier%"; - public EnchantExpHunter(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + private EnchantScaler expModifier; + + public EnchantExpHunter(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); } @Override public void loadConfig() { super.loadConfig(); - this.expModifier = new EnchantScaler(this, "Settings.Exp_Modifier"); + 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."); } public final double getExpModifier(int level) { return this.expModifier.getValue(level); } - @Override - protected void updateConfig() { - super.updateConfig(); - } - @Override @NotNull public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str + return str -> super.replacePlaceholders(level).apply(str) .replace(PLACEHOLDER_EXP_MODIFIER, NumberUtil.format(this.getExpModifier(level) * 100D - 100D)) - ); + ; } @Override @@ -57,14 +52,8 @@ public class EnchantExpHunter extends IEnchantChanceTemplate implements DeathEnc } @Override - public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level) { - if (!this.isEnchantmentAvailable(dead)) return false; - - Player killer = dead.getKiller(); - if (killer == null) return false; - - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(killer)) return false; + public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + if (!this.isAvailableToUse(entity)) return false; double expModifier = this.getExpModifier(level); double expFinal = Math.ceil((double) e.getDroppedExp() * expModifier); @@ -72,4 +61,9 @@ public class EnchantExpHunter extends IEnchantChanceTemplate implements DeathEnc e.setDroppedExp((int) expFinal); return true; } + + @Override + public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + return false; + } } 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 new file mode 100644 index 0000000..a4bf992 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantIceAspect.java @@ -0,0 +1,48 @@ +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; +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.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; + +public class EnchantIceAspect extends PotionEnchant implements CombatEnchant { + + public static final String ID = "ice_aspect"; + + public EnchantIceAspect(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.SLOW, false); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @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.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); + } + return true; + } + + @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/manager/enchants/weapon/EnchantInfernus.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantInfernus.java similarity index 66% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantInfernus.java index ba30988..51942b0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantInfernus.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantInfernus.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; +package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Entity; @@ -10,49 +10,44 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +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.config.EnchantScaler; import java.util.function.UnaryOperator; -public class EnchantInfernus extends IEnchantChanceTemplate { - - private Scaler fireTicks; +public class EnchantInfernus extends ExcellentEnchant { public static final String ID = "infernus"; public static final String PLACEHOLDER_FIRE_DURATION = "%enchantment_fire_duration%"; - public EnchantInfernus(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + private EnchantScaler fireTicks; + + public EnchantInfernus(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); } @Override public void loadConfig() { super.loadConfig(); - this.fireTicks = new EnchantScaler(this, "Settings.Fire_Ticks"); + 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."); } public int getFireTicks(int level) { return (int) this.fireTicks.getValue(level); } - @Override - protected void updateConfig() { - super.updateConfig(); - } - @Override @NotNull public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str + return str -> super.replacePlaceholders(level).apply(str) .replace(PLACEHOLDER_FIRE_DURATION, NumberUtil.format((double) this.getFireTicks(level) / 20D)) - ); + ; } @Override @@ -66,15 +61,13 @@ public class EnchantInfernus extends IEnchantChanceTemplate { Entity entity = e.getEntity(); if (!(entity instanceof Trident trident)) return; if (!(trident.getShooter() instanceof LivingEntity shooter)) return; - if (!this.isEnchantmentAvailable(shooter)) return; + if (!this.isAvailableToUse(shooter)) return; ItemStack item = trident.getItem(); - int level = EnchantManager.getItemEnchantLevel(item, this); + int level = EnchantManager.getEnchantmentLevel(item, this); if (level <= 0) return; - if (!this.checkTriggerChance(level)) return; - if (!this.takeCostItem(shooter)) return; trident.setFireTicks(Integer.MAX_VALUE); } @@ -85,7 +78,7 @@ public class EnchantInfernus extends IEnchantChanceTemplate { ItemStack item = trident.getItem(); - int level = EnchantManager.getItemEnchantLevel(item, this); + int level = EnchantManager.getEnchantmentLevel(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 new file mode 100644 index 0000000..44f226d --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantNimble.java @@ -0,0 +1,41 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +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.api.enchantment.type.DeathEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; + +public class EnchantNimble extends ExcellentEnchant implements DeathEnchant { + + public static final String ID = "nimble"; + + public EnchantNimble(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.LOWEST); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + if (!this.isAvailableToUse(entity)) return false; + + e.getDrops().forEach(item -> PlayerUtil.addItem(killer, item)); + e.getDrops().clear(); + return true; + } + + @Override + public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + return false; + } +} 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 new file mode 100644 index 0000000..4073d2e --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantParalyze.java @@ -0,0 +1,62 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantParalyze extends PotionEnchant implements Chanced, CombatEnchant { + + public static final String ID = "paralyze"; + + private ChanceImplementation chanceImplementation; + + public EnchantParalyze(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.SLOW_DIGGING, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @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; + + if (this.hasVisualEffects()) { + EffectUtil.playEffect(victim.getEyeLocation(), Particle.CRIT_MAGIC, "", 0.25, 0.25, 0.25, 0.1f, 30); + } + return true; + } + + @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/EnchantRage.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRage.java new file mode 100644 index 0000000..2370954 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRage.java @@ -0,0 +1,62 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantRage extends PotionEnchant implements Chanced, CombatEnchant { + + public static final String ID = "rage"; + + private ChanceImplementation chanceImplementation; + + public EnchantRage(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.INCREASE_DAMAGE, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @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(damager, level)) return false; + + if (this.hasVisualEffects()) { + EffectUtil.playEffect(damager.getEyeLocation(), Particle.LAVA, "", 0.25, 0.25, 0.25, 0.1f, 30); + } + return true; + } + + @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/EnchantRocket.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRocket.java new file mode 100644 index 0000000..761aa2d --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRocket.java @@ -0,0 +1,80 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.Sound; +import org.bukkit.enchantments.EnchantmentTarget; +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.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; + +public class EnchantRocket extends ExcellentEnchant implements Chanced, CombatEnchant { + + public static final String ID = "rocket"; + + private EnchantScaler fireworkPower; + private ChanceImplementation chanceImplementation; + + public EnchantRocket(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + this.fireworkPower = EnchantScaler.read(this, "Settings.Firework_Power", Placeholders.ENCHANTMENT_LEVEL + " * 0.25", + "Firework power. The more power = the higher fly distance."); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + public final double getFireworkPower(int level) { + return this.fireworkPower.getValue(level); + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @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 (victim.isInsideVehicle()) { + victim.leaveVehicle(); + } + + Firework firework = EntityUtil.spawnRandomFirework(victim.getLocation()); + FireworkMeta meta = firework.getFireworkMeta(); + meta.setPower((int) this.getFireworkPower(level)); + firework.setFireworkMeta(meta); + firework.addPassenger(victim); + + MessageUtil.sound(victim.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_LAUNCH); + return true; + } + + @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/manager/enchants/weapon/EnchantScavenger.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantScavenger.java similarity index 61% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantScavenger.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantScavenger.java index e59f9a9..e4b06bb 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantScavenger.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantScavenger.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; +package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Material; import org.bukkit.enchantments.EnchantmentTarget; @@ -8,32 +8,35 @@ 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.api.config.JYML; 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.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +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.meta.ChanceImplementation; -import java.util.AbstractMap; import java.util.HashMap; import java.util.Map; -public class EnchantScavenger extends IEnchantChanceTemplate implements DeathEnchant { - - private Map>> loot; +public class EnchantScavenger extends ExcellentEnchant implements Chanced, DeathEnchant { public static final String ID = "scavenger"; - public EnchantScavenger(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + private Map>> loot; + private ChanceImplementation chanceImplementation; + + public EnchantScavenger(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); } @Override public void loadConfig() { super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); this.loot = new HashMap<>(); for (String eId : cfg.getSection("Settings.Treasures")) { @@ -43,7 +46,7 @@ public class EnchantScavenger extends IEnchantChanceTemplate implements DeathEnc continue; } - Map> items = new HashMap<>(); + Map> items = new HashMap<>(); for (String sFromArray : cfg.getSection("Settings.Treasures." + eId)) { Material material = Material.getMaterial(sFromArray.toUpperCase()); if (material == null) { @@ -60,13 +63,19 @@ public class EnchantScavenger extends IEnchantChanceTemplate implements DeathEnc double chance = cfg.getDouble(path + "Chance"); if (chance <= 0) continue; - Map.Entry item = new AbstractMap.SimpleEntry<>(amount, chance); + Pair item = Pair.of(amount, chance); items.put(material, item); } this.loot.put(eType, items); } } + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + @Override @NotNull public EnchantmentTarget getItemTarget() { @@ -74,23 +83,19 @@ public class EnchantScavenger extends IEnchantChanceTemplate implements DeathEnc } @Override - public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level) { - if (!this.isEnchantmentAvailable(dead)) return false; + public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + if (!this.isAvailableToUse(entity)) return false; - Map> items = this.loot.get(dead.getType()); + Map> items = this.loot.get(entity.getType()); if (items == null) return false; - Player killer = dead.getKiller(); - if (killer == null) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(killer)) return false; items.forEach((material, data) -> { - double chance = data.getValue(); + double chance = data.getSecond(); if (Rnd.get(true) > chance) return; - int amount = Rnd.get(data.getKey()[0], data.getKey()[1]); + int amount = Rnd.get(data.getFirst()[0], data.getFirst()[1]); if (amount <= 0) return; ItemStack item = new ItemStack(material); @@ -99,4 +104,9 @@ public class EnchantScavenger extends IEnchantChanceTemplate implements DeathEnc return true; } + + @Override + public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + return false; + } } 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 new file mode 100644 index 0000000..53b2ccc --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantSurprise.java @@ -0,0 +1,68 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.utils.random.Rnd; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantSurprise extends PotionEnchant implements Chanced, CombatEnchant { + + public static final String ID = "surprise"; + + private ChanceImplementation chanceImplementation; + + public EnchantSurprise(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.BLINDNESS, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public PotionEffectType getEffectType() { + return Rnd.get(PotionEffectType.values()); + } + + @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; + + if (this.hasVisualEffects()) { + EffectUtil.playEffect(victim.getEyeLocation(), Particle.SPELL_WITCH, "", 0.25, 0.25, 0.25, 0.1f, 30); + } + return true; + } + + @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/manager/enchants/weapon/EnchantTemper.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantTemper.java similarity index 64% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantTemper.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantTemper.java index 79551a6..89ace06 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantTemper.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantTemper.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; +package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.attribute.Attribute; import org.bukkit.enchantments.EnchantmentTarget; @@ -6,18 +6,18 @@ 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.api.config.JYML; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import java.util.function.UnaryOperator; -public class EnchantTemper extends IEnchantChanceTemplate implements CombatEnchant { +public class EnchantTemper extends ExcellentEnchant implements CombatEnchant { public static final String ID = "temper"; public static final String PLACEHOLDER_DAMAGE_AMOUNT = "%enchantment_damage_amount%"; @@ -28,16 +28,19 @@ public class EnchantTemper extends IEnchantChanceTemplate implements CombatEncha private EnchantScaler damageCapacity; private EnchantScaler healthPoint; - public EnchantTemper(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + public EnchantTemper(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); } @Override public void loadConfig() { super.loadConfig(); - this.damageAmount = new EnchantScaler(this, "Settings.Damage.Amount"); - this.damageCapacity = new EnchantScaler(this, "Settings.Damage.Capacity"); - this.healthPoint = new EnchantScaler(this, "Settings.Health.Point"); + 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."); + this.healthPoint = EnchantScaler.read(this, "Settings.Health.Point", "0.5", + "For how much every missing hearts damage will be increased?"); } public double getDamageAmount(int level) { @@ -55,11 +58,11 @@ public class EnchantTemper extends IEnchantChanceTemplate implements CombatEncha @Override @NotNull public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str + return str -> super.replacePlaceholders(level).apply(str) .replace(PLACEHOLDER_DAMAGE_AMOUNT, NumberUtil.format(this.getDamageAmount(level) * 100D)) .replace(PLACEHOLDER_DAMAGE_CAPACITY, NumberUtil.format(this.getDamageCapacity(level) * 100D)) .replace(PLACEHOLDER_HEALTH_POINT, NumberUtil.format(this.getHealthPoint(level))) - ); + ; } @NotNull @@ -69,9 +72,8 @@ public class EnchantTemper extends IEnchantChanceTemplate implements CombatEncha } @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(damager)) return false; - if (!this.checkTriggerChance(level)) return false; + public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isAvailableToUse(damager)) return false; double healthPoint = this.getHealthPoint(level); double healthHas = damager.getHealth(); @@ -82,8 +84,6 @@ public class EnchantTemper extends IEnchantChanceTemplate implements CombatEncha int pointAmount = (int) (healthDiff / healthPoint); if (pointAmount == 0) return false; - if (!this.takeCostItem(damager)) return false; - double damageAmount = this.getDamageAmount(level); double damageCap = this.getDamageCapacity(level); double damageFinal = Math.min(damageCap, 1D + damageAmount * pointAmount); @@ -91,4 +91,9 @@ public class EnchantTemper extends IEnchantChanceTemplate implements CombatEncha e.setDamage(e.getDamage() * damageFinal); return true; } + + @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/EnchantThrifty.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThrifty.java new file mode 100644 index 0000000..de746a0 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThrifty.java @@ -0,0 +1,110 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.CreatureSpawnEvent; +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.nightexpress.excellentenchants.ExcellentEnchants; +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.meta.ChanceImplementation; + +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEnchant { + + public static final String ID = "thrifty"; + + private Set ignoredEntityTypes; + private Set ignoredSpawnReasons; + private final NamespacedKey keyEntityIgnored; + + private ChanceImplementation chanceImplementation; + + public EnchantThrifty(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + this.keyEntityIgnored = new NamespacedKey(plugin, ID + "_ignored"); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + + 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)) + .filter(Objects::nonNull).collect(Collectors.toSet()); + + this.ignoredSpawnReasons = JOption.create("Settings.Ignored_Spawn_Reasons", + Set.of(CreatureSpawnEvent.SpawnReason.SPAWNER_EGG.name(), + CreatureSpawnEvent.SpawnReason.SPAWNER.name(), + 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)) + .filter(Objects::nonNull).collect(Collectors.toSet()); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @Override + public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + if (!this.isAvailableToUse(entity)) return false; + + if (this.ignoredEntityTypes.contains(entity.getType())) return false; + if (PDCUtil.getBooleanData(entity, this.keyEntityIgnored)) return false; + if (!this.checkTriggerChance(level)) return false; + + Material material = Material.getMaterial(entity.getType().name() + "_SPAWN_EGG"); + if (material == null) { + if (entity.getType() == EntityType.MUSHROOM_COW) { + material = Material.MOOSHROOM_SPAWN_EGG; + } + else return false; + } + + ItemStack egg = new ItemStack(material); + e.getDrops().add(egg); + return true; + } + + @Override + public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + return false; + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onCreatureSpawn(CreatureSpawnEvent e) { + if (!this.ignoredSpawnReasons.contains(e.getSpawnReason())) return; + + PDCUtil.setData(e.getEntity(), this.keyEntityIgnored, true); + } +} 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 new file mode 100644 index 0000000..5566248 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThunder.java @@ -0,0 +1,70 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.enchantments.EnchantmentTarget; +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.api.config.JOption; +import su.nightexpress.excellentenchants.ExcellentEnchants; +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; + +public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatEnchant { + + public static final String ID = "thunder"; + + private boolean inThunderstormOnly; + private ChanceImplementation chanceImplementation; + + public EnchantThunder(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + 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); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + public boolean isInThunderstormOnly() { + return inThunderstormOnly; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @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.isInThunderstormOnly() && !victim.getWorld().isThundering()) return false; + if (victim.getLocation().getBlock().getLightFromSky() != 15) return false; + if (!this.checkTriggerChance(level)) return false; + + plugin.getServer().getScheduler().runTask(plugin, () -> { + victim.setNoDamageTicks(0); + victim.getWorld().strikeLightning(victim.getLocation()); + }); + + return true; + } + + @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/manager/enchants/weapon/EnchantVampire.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVampire.java similarity index 55% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVampire.java index 5bb11e0..774f38e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVampire.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVampire.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; +package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Particle; import org.bukkit.attribute.Attribute; @@ -8,41 +8,49 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import java.util.function.UnaryOperator; -public class EnchantVampire extends IEnchantChanceTemplate implements CombatEnchant { - - private String particleName; - private String particleData; - private Scaler healAmount; - private boolean healMultiplier; +public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatEnchant { public static final String ID = "vampire"; public static final String PLACEHOLDER_HEAL_AMOUNT = "%enchantment_heal_amount%"; - public EnchantVampire(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.LOWEST); + private EnchantScaler healAmount; + private boolean healMultiplier; + private ChanceImplementation chanceImplementation; + + public EnchantVampire(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.LOWEST); } @Override public void loadConfig() { super.loadConfig(); - this.particleName = cfg.getString("Settings.Particle.Name", Particle.HEART.name()); - this.particleData = cfg.getString("Settings.Particle.Data", ""); - this.healAmount = new EnchantScaler(this, "Settings.Heal.Amount"); - this.healMultiplier = cfg.getBoolean("Settings.Heal.As_Multiplier"); + this.chanceImplementation = ChanceImplementation.create(this); + + 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); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; } public double getHealAmount(int level) { @@ -53,18 +61,6 @@ public class EnchantVampire extends IEnchantChanceTemplate implements CombatEnch return healMultiplier; } - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.remove("Settings.Particle_Effect"); - cfg.remove("Settings.Heal_Of_Damage"); - cfg.addMissing("Settings.Particle.Name", Particle.HEART.name()); - cfg.addMissing("Settings.Particle.Data", ""); - cfg.addMissing("Settings.Heal.Amount", "0.25 * " + Placeholders.ENCHANTMENT_LEVEL); - cfg.addMissing("Settings.Heal.As_Multiplier", false); - } - @Override @NotNull public EnchantmentTarget getItemTarget() { @@ -76,21 +72,20 @@ public class EnchantVampire extends IEnchantChanceTemplate implements CombatEnch public UnaryOperator replacePlaceholders(int level) { double healAmount = this.getHealAmount(level); - return str -> super.replacePlaceholders(level).apply(str + return str -> super.replacePlaceholders(level).apply(str) .replace(PLACEHOLDER_HEAL_AMOUNT, NumberUtil.format(this.isHealMultiplier() ? healAmount * 100D : healAmount)) - ); + ; } @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(damager)) return false; + public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isAvailableToUse(damager)) return false; double healthMax = EntityUtil.getAttribute(damager, Attribute.GENERIC_MAX_HEALTH); double healthHas = damager.getHealth(); if (healthHas == healthMax) return false; if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(damager)) return false; double healAmount = this.getHealAmount(level); double healFinal = this.isHealMultiplier() ? e.getDamage() * healAmount : healAmount; @@ -101,7 +96,14 @@ public class EnchantVampire extends IEnchantChanceTemplate implements CombatEnch damager.setHealth(Math.min(healthMax, healthHas + healthEvent.getAmount())); - EffectUtil.playEffect(damager.getEyeLocation(), this.particleName, this.particleData, 0.2f, 0.15f, 0.2f, 0.15f, 5); + if (this.hasVisualEffects()) { + EffectUtil.playEffect(damager.getEyeLocation(), Particle.HEART, "", 0.2f, 0.15f, 0.2f, 0.15f, 5); + } return true; } + + @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/EnchantVenom.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVenom.java new file mode 100644 index 0000000..556d2cf --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVenom.java @@ -0,0 +1,62 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantVenom extends PotionEnchant implements Chanced, CombatEnchant { + + public static final String ID = "venom"; + + private ChanceImplementation chanceImplementation; + + public EnchantVenom(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.POISON, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @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; + + if (this.hasVisualEffects()) { + EffectUtil.playEffect(victim.getEyeLocation(), Particle.SLIME, "", 0.25, 0.25, 0.25, 0.1f, 30); + } + return true; + } + + @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/manager/enchants/weapon/EnchantVillageDefender.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVillageDefender.java similarity index 50% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVillageDefender.java index e2ab391..46dd024 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVillageDefender.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVillageDefender.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; +package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; @@ -7,39 +7,39 @@ 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.api.config.JYML; +import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import java.util.function.UnaryOperator; -public class EnchantVillageDefender extends IEnchantChanceTemplate implements CombatEnchant { - - private boolean damageMultiplier; - private Scaler damageAmount; - private String particleName; - private String particleData; +public class EnchantVillageDefender extends ExcellentEnchant implements CombatEnchant { public static final String ID = "village_defender"; public static final String PLACEHOLDER_DAMAGE_AMOUNT = "%enchantment_damage_amount%"; - public EnchantVillageDefender(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); + private boolean damageMultiplier; + private EnchantScaler damageAmount; + + public EnchantVillageDefender(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); } @Override public void loadConfig() { super.loadConfig(); - this.damageAmount = new EnchantScaler(this, "Settings.Damage.Formula"); - this.damageMultiplier = cfg.getBoolean("Settings.Damage.As_Modifier"); - this.particleName = cfg.getString("Settings.Particle.Name", Particle.VILLAGER_ANGRY.name()); - this.particleData = cfg.getString("Settings.Particle.Data", ""); + + 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, + "When 'true' the 'Damage.Formula' will work as a multiplier to the original damage.").read(cfg); } public double getDamageAddict(int level) { @@ -53,18 +53,9 @@ public class EnchantVillageDefender extends IEnchantChanceTemplate implements Co @Override @NotNull public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str + return str -> super.replacePlaceholders(level).apply(str) .replace(PLACEHOLDER_DAMAGE_AMOUNT, NumberUtil.format(this.getDamageAddict(level))) - ); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.remove("Settings.Particle_Effect"); - cfg.addMissing("Settings.Particle.Name", Particle.VILLAGER_ANGRY.name()); - cfg.addMissing("Settings.Particle.Data", ""); + ; } @Override @@ -74,18 +65,24 @@ public class EnchantVillageDefender extends IEnchantChanceTemplate implements Co } @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(damager)) return false; + public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isAvailableToUse(damager)) return false; if (!(victim instanceof Illager)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(damager)) return false; double damageAdd = this.getDamageAddict(level); double damageHas = e.getDamage(); double damageFinal = this.isDamageMultiplier() ? (damageHas * damageAdd) : (damageHas + damageAdd); e.setDamage(damageFinal); - EffectUtil.playEffect(victim.getEyeLocation(), this.particleName, this.particleData, 0.15, 0.15, 0.15, 0.13f, 3); + + if (this.hasVisualEffects()) { + EffectUtil.playEffect(victim.getEyeLocation(), Particle.VILLAGER_ANGRY, "", 0.25, 0.25, 0.25, 0.1f, 30); + } return true; } + + @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/EnchantWither.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantWither.java new file mode 100644 index 0000000..4a19eeb --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantWither.java @@ -0,0 +1,62 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.template.PotionEnchant; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class EnchantWither extends PotionEnchant implements Chanced, CombatEnchant { + + public static final String ID = "wither"; + + private ChanceImplementation chanceImplementation; + + public EnchantWither(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM, PotionEffectType.WITHER, false); + } + + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @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; + + if (this.hasVisualEffects()) { + EffectUtil.playEffect(victim.getEyeLocation(), Particle.ASH, "", 0.25, 0.25, 0.25, 0.1f, 30); + } + return true; + } + + @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/listener/EnchantAnvilListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantAnvilListener.java new file mode 100644 index 0000000..2cf3fb4 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantAnvilListener.java @@ -0,0 +1,146 @@ +package su.nightexpress.excellentenchants.enchantment.listener; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.PrepareAnvilEvent; +import org.bukkit.inventory.AnvilInventory; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.manager.AbstractListener; +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 java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +public class EnchantAnvilListener extends AbstractListener { + + private static final NamespacedKey RECHARGED = new NamespacedKey(ExcellentEnchantsAPI.PLUGIN, "item.recharged"); + + public EnchantAnvilListener(@NotNull ExcellentEnchants plugin) { + super(plugin); + } + + @EventHandler(priority = EventPriority.HIGH) + public void onAnvilRename(PrepareAnvilEvent e) { + AnvilInventory inventory = e.getInventory(); + + ItemStack first = inventory.getItem(0); + ItemStack second = inventory.getItem(1); + ItemStack result = e.getResult(); + + if (first == null) first = new ItemStack(Material.AIR); + if (second == null) second = new ItemStack(Material.AIR); + 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 (this.handleRename(e, first, second, result)) return; + if (this.handleRecharge(e, first, second, result)) return; + + this.handleEnchantMerging(e, first, second, result); + } + + private boolean handleRename(@NotNull PrepareAnvilEvent e, + @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) { + + if (!second.getType().isAir()) return false; + if (result.getType() != first.getType()) return false; + + ItemStack result2 = new ItemStack(result); + EnchantManager.getExcellentEnchantments(first).forEach((hasEnch, hasLevel) -> { + EnchantManager.addEnchantment(result2, hasEnch, hasLevel, true); + }); + e.setResult(result2); + return true; + } + + private boolean handleRecharge(@NotNull PrepareAnvilEvent e, + @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) { + if (second.getType().isAir()) return false; + + Set chargeable = EnchantManager.getExcellentEnchantments(first).keySet().stream() + .filter(en -> en.isChargesEnabled() && en.isChargesFuel(second) && !en.isFullOfCharges(first)) + .collect(Collectors.toSet()); + if (chargeable.isEmpty()) return false; + + ItemStack result2 = new ItemStack(first); + chargeable.forEach(enchant -> EnchantManager.rechargeEnchantmentCharges(result2, enchant)); + PDCUtil.setData(result2, RECHARGED, true); + e.setResult(result2); + this.plugin.runTask(c -> e.getInventory().setRepairCost(chargeable.size()), false); + 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 (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); + 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) -> { + enchantments.merge(enchant, level, (oldLvl, newLvl) -> (oldLvl.equals(newLvl)) ? (oldLvl + 1) : (Math.max(oldLvl, newLvl))); + }); + } + + // Recalculate operation cost depends on enchantments merge cost. + enchantments.forEach((enchant, level) -> { + if (EnchantManager.addEnchantment(result2, enchant, level, false)) { + repairCost.addAndGet(enchant.getAnvilMergeCost(level)); + } + }); + + if (first.equals(result2)) return false; + + 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); + return true; + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onClickAnvil(InventoryClickEvent e) { + if (!(e.getInventory() instanceof AnvilInventory inventory)) return; + if (e.getRawSlot() != 2) return; + + ItemStack item = e.getCurrentItem(); + if (item == null || !PDCUtil.getBooleanData(item, RECHARGED)) return; + + Player player = (Player) e.getWhoClicked(); + if (player.getLevel() < inventory.getRepairCost()) return; + + player.setLevel(player.getLevel() - inventory.getRepairCost()); + PDCUtil.removeData(item, RECHARGED); + e.getView().setCursor(item); + e.setCancelled(false); + + MessageUtil.sound(player, Sound.BLOCK_ENCHANTMENT_TABLE_USE); + + ItemStack second = inventory.getItem(1); + if (second != null && !second.getType().isAir()) { + second.setAmount(second.getAmount() - 1); + } + inventory.setItem(0, null); + //inventory.setItem(1, null); + inventory.setItem(2, null); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantGenericListener.java similarity index 66% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantGenericListener.java index e6660a9..b5d1783 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantGenericListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantGenericListener.java @@ -1,6 +1,5 @@ -package su.nightexpress.excellentenchants.manager.listeners; +package su.nightexpress.excellentenchants.enchantment.listener; -import org.bukkit.Material; import org.bukkit.block.Chest; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.*; @@ -12,7 +11,6 @@ import org.bukkit.event.entity.VillagerAcquireTradeEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.inventory.PrepareAnvilEvent; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.LootGenerateEvent; @@ -24,8 +22,8 @@ import su.nexmedia.engine.api.manager.AbstractListener; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Config; -import su.nightexpress.excellentenchants.manager.EnchantManager; -import su.nightexpress.excellentenchants.manager.type.ObtainType; +import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.type.ObtainType; import java.util.HashMap; import java.util.Map; @@ -46,72 +44,6 @@ public class EnchantGenericListener extends AbstractListener }); } - // --------------------------------------------------------------- - // Handle Anvil - // --------------------------------------------------------------- - @EventHandler(priority = EventPriority.HIGH) - public void onEnchantUpdateAnvil(PrepareAnvilEvent e) { - AnvilInventory inventory = e.getInventory(); - - ItemStack first = inventory.getItem(0); - ItemStack second = inventory.getItem(1); - ItemStack result = e.getResult(); - - // Check if source item is an enchantable single item. - if (first == null || !EnchantManager.isEnchantable(first) || first.getAmount() > 1) return; - - // For repair/rename, only re-add item enchants. - if ((second == null || second.getType().isAir() || !EnchantManager.isEnchantable(second)) && (result != null && result.getType() == first.getType())) { - ItemStack result2 = new ItemStack(result); - EnchantManager.getItemCustomEnchants(first).forEach((hasEnch, hasLevel) -> { - EnchantManager.addEnchant(result2, hasEnch, hasLevel, true); - }); - e.setResult(result2); - return; - } - - // Check if the second item is an enchantable single item. - if (second == null || second.getAmount() > 1 || !EnchantManager.isEnchantable(second)) return; - - // Prevent operation if first item is book while the second one is another item. - if (first.getType() == Material.ENCHANTED_BOOK && second.getType() != first.getType()) return; - - // Fine result item in case if it's nulled somehow. - if (result == null || result.getType() == Material.AIR) { - result = new ItemStack(first); - } - - Map enchAdd = EnchantManager.getItemCustomEnchants(first); - int repairCost = inventory.getRepairCost(); - - // If the second item is an enchanted book or the same item type, then - // we can merge our enchantments. - if (second.getType() == Material.ENCHANTED_BOOK || second.getType() == first.getType()) { - for (Map.Entry en : EnchantManager.getItemCustomEnchants(second).entrySet()) { - enchAdd.merge(en.getKey(), en.getValue(), (oldLvl, newLvl) -> (oldLvl.equals(newLvl)) ? (oldLvl + 1) : (Math.max(oldLvl, newLvl))); - } - } - - // Recalculate operation cost depends on enchantments merge cost. - for (Map.Entry ent : enchAdd.entrySet()) { - ExcellentEnchant enchant = ent.getKey(); - int level = Math.min(enchant.getMaxLevel(), ent.getValue()); - if (EnchantManager.addEnchant(result, enchant, level, false)) { - repairCost += enchant.getAnvilMergeCost(level); - } - } - - if (!first.equals(result)) { - //EnchantManager.updateItemLoreEnchants(result); - e.setResult(result); - - // NMS ContainerAnvil will set level cost to 0 right after calling the event - // So we have to change it with a 1 tick delay. - final int repairCost2 = repairCost; - this.plugin.runTask((c) -> inventory.setRepairCost(repairCost2), false); - } - } - // --------------------------------------------------------------- // Update enchantment lore after grindstone // --------------------------------------------------------------- @@ -142,13 +74,12 @@ public class EnchantGenericListener extends AbstractListener ItemStack source = inventory.getItem(slot); if (source == null || source.getType().isAir()) continue; - curses.putAll(EnchantManager.getItemCustomEnchants(source)); + curses.putAll(EnchantManager.getExcellentEnchantments(source)); } curses.entrySet().removeIf(entry -> !entry.getKey().isCursed()); curses.forEach((excellentEnchant, level) -> { - EnchantManager.addEnchant(result, excellentEnchant, level, true); + EnchantManager.addEnchantment(result, excellentEnchant, level, true); }); - //EnchantManager.updateItemLoreEnchants(result); }); } @@ -181,7 +112,12 @@ public class EnchantGenericListener extends AbstractListener result.setItemMeta(storageMeta); } - //EnchantManager.updateItemLoreEnchants(result); + e.getEnchantsToAdd().forEach((enchantment, level) -> { + if (enchantment instanceof ExcellentEnchant enchant && enchant.isChargesEnabled()) { + EnchantManager.restoreEnchantmentCharges(result, enchant); + } + }); + e.getInventory().setItem(0, result); }); } @@ -210,7 +146,7 @@ public class EnchantGenericListener extends AbstractListener @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEnchantPopulateLoot(LootGenerateEvent e) { - if (Config.getObtainSettings(ObtainType.LOOT_GENERATION) == null) return; + if (Config.getObtainSettings(ObtainType.LOOT_GENERATION).isEmpty()) return; Entity entity = e.getEntity(); InventoryHolder holder = e.getInventoryHolder(); @@ -226,7 +162,7 @@ public class EnchantGenericListener extends AbstractListener @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEnchantPopulateFishing(PlayerFishEvent e) { - if (Config.getObtainSettings(ObtainType.FISHING) == null) return; + if (Config.getObtainSettings(ObtainType.FISHING).isEmpty()) return; if (e.getState() != PlayerFishEvent.State.CAUGHT_FISH) return; if (!(e.getCaught() instanceof Item item)) return; @@ -238,7 +174,7 @@ public class EnchantGenericListener extends AbstractListener @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEnchantPopulateSpawn(CreatureSpawnEvent e) { - if (Config.getObtainSettings(ObtainType.MOB_SPAWNING) == null) return; + if (Config.getObtainSettings(ObtainType.MOB_SPAWNING).isEmpty()) return; LivingEntity entity = e.getEntity(); EntityEquipment equipment = entity.getEquipment(); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java similarity index 53% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java index 51d6375..aa91ae0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java @@ -1,8 +1,10 @@ -package su.nightexpress.excellentenchants.manager.listeners; +package su.nightexpress.excellentenchants.enchantment.listener; import org.bukkit.GameMode; +import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.entity.Entity; +import org.bukkit.World; +import org.bukkit.block.BlockState; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; @@ -11,11 +13,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDropItemEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.*; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; @@ -25,9 +24,10 @@ 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.api.enchantment.type.*; -import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; -import su.nightexpress.excellentenchants.manager.EnchantManager; +import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; +import su.nightexpress.excellentenchants.enchantment.EnchantManager; public class EnchantHandlerListener extends AbstractListener { @@ -54,42 +54,51 @@ public class EnchantHandlerListener extends AbstractListener // Combat Attacking Enchants // --------------------------------------------------------------- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantCombatMelee(EntityDamageByEntityEvent e) { + public void onEnchantCombatMelee(EntityDamageEvent e) { if (e.getCause() == DamageCause.THORNS) return; if (!(e.getEntity() instanceof LivingEntity victim)) return; - if (!(e.getDamager() instanceof LivingEntity damager)) return; + if (e instanceof EntityDamageByEntityEvent ede) { + LivingEntity damager = null; + if (ede.getDamager() instanceof LivingEntity living) { + damager = living; + } + else if (ede.getDamager() instanceof Projectile pj && pj.getShooter() instanceof LivingEntity living) { + damager = living; + } + if (damager == null || damager.equals(victim)) return; + + if (ede.getDamager() instanceof Projectile projectile) { + this.handleCombatBowEnchants(ede, projectile, victim); + } + else { + this.handleCombatWeaponEnchants(ede, damager, victim); + } + this.handleCombatArmorEnchants(ede, damager, victim); + } + else { + this.handleArmorEnchants(e, victim); + } + } + + private void handleCombatWeaponEnchants(@NotNull EntityDamageByEntityEvent e, + @NotNull LivingEntity damager, @NotNull LivingEntity victim) { EntityEquipment equipment = damager.getEquipment(); if (equipment == null) return; ItemStack weapon = equipment.getItemInMainHand(); if (weapon.getType().isAir() || weapon.getType() == Material.ENCHANTED_BOOK) return; - EnchantManager.getItemCustomEnchants(weapon, CombatEnchant.class).forEach((combatEnchant, level) -> { - if (combatEnchant instanceof BowEnchant) return; - combatEnchant.use(e, damager, victim, weapon, level); + EnchantManager.getExcellentEnchantments(weapon, CombatEnchant.class).forEach((combatEnchant, level) -> { + if (combatEnchant.isOutOfCharges(weapon)) return; + if (combatEnchant.onAttack(e, damager, victim, weapon, level)) { + combatEnchant.consumeCharges(weapon); + } }); } - // --------------------------------------------------------------- - // Armor Defensive Enchants - // --------------------------------------------------------------- - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantCombatArmor(EntityDamageByEntityEvent e) { - // Prevent armor enchants to have effect if damage is from Thorns. - if (e.getCause() == DamageCause.THORNS) return; - - Entity eVictim = e.getEntity(); - if (!(eVictim instanceof LivingEntity victim)) return; - - Entity eDamager = e.getDamager(); - if (eDamager instanceof Projectile projectile) { - if (projectile.getShooter() instanceof Entity) { - eDamager = (Entity) projectile.getShooter(); - } - } - if (!(eDamager instanceof LivingEntity damager) || eDamager.equals(eVictim)) return; - + private void handleCombatArmorEnchants(@NotNull EntityDamageByEntityEvent e, + @NotNull LivingEntity damager, @NotNull LivingEntity victim) { EntityEquipment equipDamager = damager.getEquipment(); if (equipDamager == null) return; @@ -98,12 +107,38 @@ public class EnchantHandlerListener extends AbstractListener for (ItemStack armor : EntityUtil.getEquippedArmor(victim).values()) { if (armor == null || armor.getType().isAir()) continue; - EnchantManager.getItemCustomEnchants(armor, CombatEnchant.class).forEach((combatEnchant, level) -> { - combatEnchant.use(e, damager, victim, weaponDamager, level); + EnchantManager.getExcellentEnchantments(armor, CombatEnchant.class).forEach((combatEnchant, level) -> { + if (combatEnchant.isOutOfCharges(armor)) return; + if (combatEnchant.onProtect(e, damager, victim, weaponDamager, level)) { + combatEnchant.consumeCharges(armor); + } }); } } + private void handleArmorEnchants(@NotNull EntityDamageEvent e, @NotNull LivingEntity entity) { + EnchantManager.getEquippedEnchants(entity, DamageEnchant.class).forEach((item, enchants) -> { + enchants.forEach((enchant, level) -> { + if (enchant.isOutOfCharges(item)) return; + if (enchant.onDamage(e, entity, item, level)) { + enchant.consumeCharges(item); + } + }); + }); + } + + private void handleCombatBowEnchants(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, + @NotNull LivingEntity victim) { + if (!(projectile.getShooter() instanceof LivingEntity shooter)) return; + + 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) -> { + bowEnchant.onDamage(e, projectile, shooter, victim, bow, level); + }); + } + // --------------------------------------------------------------- // Bow Shooting Enchants // --------------------------------------------------------------- @@ -115,8 +150,15 @@ public class EnchantHandlerListener extends AbstractListener ItemStack bow = e.getBow(); if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; - EnchantManager.getItemCustomEnchants(bow, BowEnchant.class).forEach((bowEnchant, level) -> { - bowEnchant.use(e, shooter, bow, level); + EnchantManager.getExcellentEnchantments(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) { + arrowed.addData(projectile); + arrowed.addTrail(projectile); + } + bowEnchant.consumeCharges(bow); + } }); if (e.getProjectile() instanceof Projectile projectile) { @@ -124,23 +166,6 @@ public class EnchantHandlerListener extends AbstractListener } } - // --------------------------------------------------------------- - // Bow Damage Enchants - // --------------------------------------------------------------- - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantBowDamage(EntityDamageByEntityEvent e) { - if (!(e.getEntity() instanceof LivingEntity victim)) return; - if (!(e.getDamager() instanceof Projectile projectile)) return; - if (!(projectile.getShooter() instanceof LivingEntity damager)) return; - - ItemStack bow = this.getSourceWeapon(projectile); - if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; - - EnchantManager.getItemCustomEnchants(bow, BowEnchant.class).forEach((bowEnchant, level) -> { - bowEnchant.use(e, damager, victim, bow, level); - }); - } - // --------------------------------------------------------------- // Bow Hit Land Enchants // --------------------------------------------------------------- @@ -151,8 +176,8 @@ public class EnchantHandlerListener extends AbstractListener ItemStack bow = this.getSourceWeapon(projectile); if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; - EnchantManager.getItemCustomEnchants(bow, BowEnchant.class).forEach((bowEnchant, level) -> { - bowEnchant.use(e, projectile, bow, level); + EnchantManager.getExcellentEnchantments(bow, BowEnchant.class).forEach((bowEnchant, level) -> { + bowEnchant.onHit(e, projectile, bow, level); }); // Prevent to apply enchants multiple times on hits. @@ -171,8 +196,11 @@ public class EnchantHandlerListener extends AbstractListener if (item == null || item.getType().isAir() || item.getType() == Material.ENCHANTED_BOOK) return; Player player = e.getPlayer(); - EnchantManager.getItemCustomEnchants(item, InteractEnchant.class).forEach((interEnchant, level) -> { - interEnchant.use(e, player, item, level); + EnchantManager.getExcellentEnchantments(item, InteractEnchant.class).forEach((interEnchant, level) -> { + if (interEnchant.isOutOfCharges(item)) return; + if (interEnchant.onInteract(e, player, item, level)) { + interEnchant.consumeCharges(item); + } }); } @@ -181,23 +209,28 @@ public class EnchantHandlerListener extends AbstractListener // --------------------------------------------------------------- @EventHandler(priority = EventPriority.HIGHEST) public void onEnchantDeath(EntityDeathEvent e) { - LivingEntity dead = e.getEntity(); - for (ItemStack armor : EntityUtil.getEquippedArmor(dead).values()) { - if (armor == null || armor.getType().isAir()) continue; + LivingEntity entity = e.getEntity(); - EnchantManager.getItemCustomEnchants(armor, DeathEnchant.class).forEach((deathEnchant, level) -> { - deathEnchant.use(e, dead, level); - }); - } + EnchantManager.getEquippedEnchants(entity, DeathEnchant.class).forEach((item, enchants) -> { + enchants.forEach(((deathEnchant, level) -> { + if (deathEnchant.isOutOfCharges(item)) return; + if (deathEnchant.onDeath(e, entity, level)) { + deathEnchant.consumeCharges(item); + } + })); + }); - Player killer = dead.getKiller(); + Player killer = entity.getKiller(); if (killer == null) return; ItemStack weapon = killer.getInventory().getItemInMainHand(); if (weapon.getType().isAir() || weapon.getType() == Material.ENCHANTED_BOOK) return; - EnchantManager.getItemCustomEnchants(weapon, DeathEnchant.class).forEach((deathEnchant, level) -> { - deathEnchant.use(e, dead, level); + EnchantManager.getExcellentEnchantments(weapon, DeathEnchant.class).forEach((deathEnchant, level) -> { + if (deathEnchant.isOutOfCharges(weapon)) return; + if (deathEnchant.onKill(e, entity, killer, level)) { + deathEnchant.consumeCharges(weapon); + } }); } @@ -210,8 +243,11 @@ public class EnchantHandlerListener extends AbstractListener ItemStack tool = player.getInventory().getItemInMainHand(); if (tool.getType().isAir() || tool.getType() == Material.ENCHANTED_BOOK) return; - EnchantManager.getItemCustomEnchants(tool, BlockBreakEnchant.class).forEach((blockEnchant, level) -> { - blockEnchant.use(e, player, tool, level); + EnchantManager.getExcellentEnchantments(tool, BlockBreakEnchant.class).forEach((blockEnchant, level) -> { + if (blockEnchant.isOutOfCharges(tool)) return; + if (blockEnchant.onBreak(e, player, tool, level)) { + blockEnchant.consumeCharges(tool); + } }); } @@ -223,17 +259,18 @@ public class EnchantHandlerListener extends AbstractListener ItemStack tool = player.getInventory().getItemInMainHand(); if (tool.getType().isAir() || tool.getType() == Material.ENCHANTED_BOOK) return; - EnchantManager.getItemCustomEnchants(tool, BlockDropEnchant.class).forEach((blockEnchant, level) -> { - blockEnchant.use(e, player, tool, level); - }); - EnchantDropContainer dropContainer = new EnchantDropContainer(e); - EnchantManager.getItemCustomEnchants(tool, CustomDropEnchant.class).forEach((blockEnchant, level) -> { - blockEnchant.handleDrop(dropContainer, player, tool, level); + EnchantManager.getExcellentEnchantments(tool, BlockDropEnchant.class).forEach((enchant, level) -> { + if (enchant.isOutOfCharges(tool)) return; + if (enchant.onDrop(e, dropContainer, player, tool, level)) { + enchant.consumeCharges(tool); + } }); - dropContainer.getDrop().forEach(item -> { - e.getBlockState().getBlock().getWorld().dropItem(e.getBlockState().getLocation(), item); - }); + BlockState state = e.getBlockState(); + World world = state.getWorld(); + Location location = state.getLocation(); + + dropContainer.getDrop().forEach(item -> world.dropItem(location, item)); } } 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 new file mode 100644 index 0000000..6d651c3 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/menu/EnchantmentsListMenu.java @@ -0,0 +1,150 @@ +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.MenuItemType; +import su.nexmedia.engine.lang.LangManager; +import su.nexmedia.engine.utils.ItemUtil; +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 java.util.*; + +public class EnchantmentsListMenu extends AbstractMenuAuto { + + 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_OBTAINING = "%obtaining%"; + + private final ItemStack enchantIcon; + private final List enchantLoreConflicts; + private final List enchantLoreCharges; + private final List enchantLoreObtaining; + private final int[] enchantSlots; + + private final NamespacedKey keyLevel; + private final Map> iconCache; + + public EnchantmentsListMenu(@NotNull ExcellentEnchants plugin) { + super(plugin, JYML.loadOrExtract(plugin, PATH), ""); + this.keyLevel = new NamespacedKey(plugin, "list_display_level"); + this.iconCache = new HashMap<>(); + + this.enchantIcon = cfg.getItem("Enchantments.Icon"); + this.enchantLoreConflicts = StringUtil.color(cfg.getStringList("Enchantments.Lore.Conflicts")); + this.enchantLoreCharges = StringUtil.color(cfg.getStringList("Enchantments.Lore.Charges")); + this.enchantLoreObtaining = StringUtil.color(cfg.getStringList("Enchantments.Lore.Obtaining")); + this.enchantSlots = cfg.getIntArray("Enchantments.Slots"); + + MenuClick click = (player, type, e) -> { + if (type instanceof MenuItemType type2) { + this.onItemClickDefault(player, type2); + } + }; + + for (String sId : cfg.getSection("Content")) { + MenuItem menuItem = cfg.getMenuItem("Content." + sId); + + if (menuItem.getType() != null) { + menuItem.setClickHandler(click); + } + this.addItem(menuItem); + } + } + + @Override + public void clear() { + super.clear(); + this.iconCache.clear(); + } + + @Override + protected int[] getObjectSlots() { + return this.enchantSlots; + } + + @Override + @NotNull + protected List getObjects(@NotNull Player player) { + return new ArrayList<>(EnchantRegister.ENCHANT_REGISTRY.values().stream() + .sorted(Comparator.comparing(ExcellentEnchant::getName)).toList()); + } + + @Override + @NotNull + protected 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; + + ItemStack itemClick = e.getCurrentItem(); + if (itemClick == null) return; + + int levelHas = PDCUtil.getIntData(itemClick, this.keyLevel); + if (levelHas == 0) return; + + if (++levelHas > enchant.getMaxLevel()) levelHas = enchant.getStartLevel(); + itemClick = this.getEnchantIcon(enchant, levelHas); + PDCUtil.setData(itemClick, this.keyLevel, levelHas); + + e.setCurrentItem(itemClick); + }; + } + + private ItemStack getEnchantIcon(@NotNull ExcellentEnchant enchant, int level) { + return this.iconCache.computeIfAbsent(enchant.getId(), k -> new HashMap<>()).computeIfAbsent(level, k -> this.buildEnchantIcon(enchant, level)); + } + + @NotNull + private ItemStack buildEnchantIcon(@NotNull ExcellentEnchant enchant, int level) { + ItemStack icon = new ItemStack(this.enchantIcon); + ItemMeta meta = icon.getItemMeta(); + if (meta == null) return icon; + + List lore = meta.getLore(); + if (lore == null) lore = new ArrayList<>(); + + List conflicts = enchant.getConflicts().isEmpty() ? Collections.emptyList() : new ArrayList<>(this.enchantLoreConflicts); + List conflictNames = enchant.getConflicts().stream().map(key -> Enchantment.getByKey(NamespacedKey.minecraft(key))) + .filter(Objects::nonNull).map(LangManager::getEnchantment).toList(); + conflicts = StringUtil.replace(conflicts, Placeholders.ENCHANTMENT_NAME, true, conflictNames); + + List charges = enchant.isChargesEnabled() ? new ArrayList<>(this.enchantLoreCharges) : Collections.emptyList(); + List obtaining = new ArrayList<>(this.enchantLoreObtaining); + + lore = StringUtil.replace(lore, PLACEHOLDER_CONFLICTS, false, conflicts); + lore = StringUtil.replace(lore, PLACEHOLDER_CHARGES, false, charges); + lore = StringUtil.replace(lore, PLACEHOLDER_OBTAINING, false, obtaining); + + meta.setLore(lore); + icon.setItemMeta(meta); + + ItemUtil.replace(icon, enchant.replacePlaceholders(level)); + return icon; + } + + @Override + public boolean cancelClick(@NotNull InventoryClickEvent e, @NotNull SlotType slotType) { + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/AbstractEnchantmentTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/AbstractEnchantmentTask.java new file mode 100644 index 0000000..7c56626 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/AbstractEnchantmentTask.java @@ -0,0 +1,31 @@ +package su.nightexpress.excellentenchants.enchantment.task; + +import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.task.AbstractTask; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.config.Config; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +public abstract class AbstractEnchantmentTask extends AbstractTask { + + public AbstractEnchantmentTask(@NotNull ExcellentEnchants plugin, long interval, boolean async) { + super(plugin, interval, async); + } + + @NotNull + protected Collection<@NotNull ? extends LivingEntity> getEntities() { + Set list = new HashSet<>(plugin.getServer().getOnlinePlayers()); + + if (Config.ENCHANTMENTS_ENTITY_PASSIVE_FOR_MOBS.get()) { + plugin.getServer().getWorlds().stream().filter(world -> !world.getPlayers().isEmpty()).forEach(world -> { + list.addAll(world.getEntitiesByClass(LivingEntity.class)); + }); + } + list.removeIf(e -> e.isDead() || !e.isValid()); + return list; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/ArrowTrailsTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/ArrowTrailsTask.java similarity index 52% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/ArrowTrailsTask.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/ArrowTrailsTask.java index 90a60e4..7b81468 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/ArrowTrailsTask.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/ArrowTrailsTask.java @@ -1,20 +1,25 @@ -package su.nightexpress.excellentenchants.manager.tasks; +package su.nightexpress.excellentenchants.enchantment.task; +import org.bukkit.Particle; import org.bukkit.entity.Projectile; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.task.AbstractTask; import su.nexmedia.engine.utils.EffectUtil; +import su.nexmedia.engine.utils.Pair; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.config.Config; -import java.util.*; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; public class ArrowTrailsTask extends AbstractTask { - private static final Map>> TRAILS_MAP = Collections.synchronizedMap(new HashMap<>()); + private static final Map>> TRAILS_MAP = new ConcurrentHashMap<>(); public ArrowTrailsTask(@NotNull ExcellentEnchants plugin) { - super(plugin, Config.TASKS_ARROW_TRAIL_TICKS_INTERVAL, true); + super(plugin, Config.TASKS_ARROW_TRAIL_TICKS_INTERVAL.get(), true); TRAILS_MAP.clear(); } @@ -24,14 +29,17 @@ public class ArrowTrailsTask extends AbstractTask { TRAILS_MAP.forEach((arrow, effects) -> { effects.forEach(entry -> { - EffectUtil.playEffect(arrow.getLocation(), entry.getKey(), entry.getValue(), 0f, 0f, 0f, 0f, 10); + EffectUtil.playEffect(arrow.getLocation(), entry.getFirst(), entry.getSecond(), 0f, 0f, 0f, 0f, 10); }); }); } + @Deprecated public static void add(@NotNull Projectile projectile, @NotNull String particleName, @NotNull String particleData) { - synchronized (TRAILS_MAP) { - TRAILS_MAP.computeIfAbsent(projectile, list -> new HashSet<>()).add(new AbstractMap.SimpleEntry<>(particleName, 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)); } } \ 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 new file mode 100644 index 0000000..5f366cd --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PotionEffectsTask.java @@ -0,0 +1,21 @@ +package su.nightexpress.excellentenchants.enchantment.task; + +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; + +public class PotionEffectsTask extends AbstractEnchantmentTask { + + public PotionEffectsTask(@NotNull ExcellentEnchants plugin) { + super(plugin, Config.TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL.get(), false); + } + + @Override + public void action() { + for (LivingEntity entity : this.getEntities()) { + EnchantManager.updateEquippedEnchantEffects(entity); + } + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/type/FitItemType.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java similarity index 81% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/type/FitItemType.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java index 7a47feb..f964989 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/type/FitItemType.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.type; +package su.nightexpress.excellentenchants.enchantment.type; import org.bukkit.Material; import org.bukkit.enchantments.EnchantmentTarget; @@ -11,7 +11,7 @@ import su.nightexpress.excellentenchants.config.Config; public enum FitItemType { HELMET, CHESTPLATE, LEGGINGS, BOOTS, ELYTRA, - WEAPON, TOOL, ARMOR, + WEAPON, TOOL, ARMOR, UNIVERSAL, SWORD, TRIDENT, AXE, BOW, CROSSBOW, HOE, PICKAXE, SHOVEL, FISHING_ROD; @@ -29,24 +29,26 @@ public enum FitItemType { case FISHING_ROD -> FISHING_ROD; case TRIDENT -> TRIDENT; case CROSSBOW -> CROSSBOW; + case BREAKABLE, WEARABLE -> UNIVERSAL; default -> null; }; } public boolean isIncluded(@NotNull ItemStack item) { return switch (this) { + case UNIVERSAL -> ARMOR.isIncluded(item) || WEAPON.isIncluded(item) || TOOL.isIncluded(item); case HELMET -> ItemUtil.isHelmet(item); - case CHESTPLATE -> ItemUtil.isChestplate(item) || (Config.ENCHANTMENTS_ITEM_ELYTRA_AS_CHESTPLATE && ELYTRA.isIncluded(item)); + case CHESTPLATE -> ItemUtil.isChestplate(item) || (Config.ENCHANTMENTS_ITEM_CHESTPLATE_ENCHANTS_TO_ELYTRA.get() && ELYTRA.isIncluded(item)); case LEGGINGS -> ItemUtil.isLeggings(item); case BOOTS -> ItemUtil.isBoots(item); case ELYTRA -> item.getType() == Material.ELYTRA; case WEAPON -> ItemUtil.isWeapon(item); case TOOL -> ItemUtil.isTool(item); case ARMOR -> ItemUtil.isArmor(item); - case SWORD -> ItemUtil.isSword(item) || (Config.ENCHANTMENTS_ITEM_AXES_AS_SWORDS && AXE.isIncluded(item)); + case SWORD -> ItemUtil.isSword(item) || (Config.ENCHANTMENTS_ITEM_SWORD_ENCHANTS_TO_AXES.get() && AXE.isIncluded(item)); case TRIDENT -> ItemUtil.isTrident(item); case AXE -> ItemUtil.isAxe(item); - case BOW -> item.getType() == Material.BOW || (Config.ENCHANTMENTS_ITEM_CROSSBOWS_AS_BOWS && CROSSBOW.isIncluded(item)); + case BOW -> item.getType() == Material.BOW || (Config.ENCHANTMENTS_ITEM_BOW_ENCHANTS_TO_CROSSBOW.get() && CROSSBOW.isIncluded(item)); case CROSSBOW -> item.getType() == Material.CROSSBOW; case HOE -> ItemUtil.isHoe(item); case PICKAXE -> ItemUtil.isPickaxe(item); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/type/ObtainType.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/ObtainType.java similarity index 87% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/type/ObtainType.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/ObtainType.java index 7bd0f1c..c4c2ace 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/type/ObtainType.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/ObtainType.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.manager.type; +package su.nightexpress.excellentenchants.enchantment.type; import org.jetbrains.annotations.NotNull; 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 ebc3a0a..5b643c9 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookId.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookId.java @@ -3,4 +3,5 @@ package su.nightexpress.excellentenchants.hook; public class HookId { public static final String NCP = "NoCheatPlus"; + public static final String PROTOCOL_LIB = "ProtocolLib"; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookNCP.java b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/NoCheatPlusHook.java similarity index 85% rename from Core/src/main/java/su/nightexpress/excellentenchants/hook/HookNCP.java rename to Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/NoCheatPlusHook.java index f830c75..2ce103d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/hook/HookNCP.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/NoCheatPlusHook.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.hook; +package su.nightexpress.excellentenchants.hook.impl; import fr.neatmonster.nocheatplus.NCPAPIProvider; import fr.neatmonster.nocheatplus.checks.CheckType; @@ -6,8 +6,9 @@ import fr.neatmonster.nocheatplus.hooks.ExemptionContext; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.hooks.Hooks; +import su.nightexpress.excellentenchants.hook.HookId; -public class HookNCP { +public class NoCheatPlusHook { public static void exemptBlocks(@NotNull Player player) { if (!Hooks.hasPlugin(HookId.NCP)) return; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/hook/ProtocolHook.java b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/ProtocolHook.java similarity index 61% rename from Core/src/main/java/su/nightexpress/excellentenchants/hook/ProtocolHook.java rename to Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/ProtocolHook.java index 80ab216..11ce9f1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/hook/ProtocolHook.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/ProtocolHook.java @@ -1,4 +1,4 @@ -package su.nightexpress.excellentenchants.hook; +package su.nightexpress.excellentenchants.hook.impl; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; @@ -8,12 +8,13 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import org.bukkit.GameMode; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.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.config.Config; -import su.nightexpress.excellentenchants.manager.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.EnchantManager; import java.util.ArrayList; import java.util.List; @@ -34,9 +35,7 @@ public class ProtocolHook { ItemStack item = packet.getItemModifier().read(0); boolean isCreative = event.getPlayer().getGameMode() == GameMode.CREATIVE; - //else { - packet.getItemModifier().write(0, update(item, isCreative)); - //} + packet.getItemModifier().write(0, update(item, isCreative)); } }); @@ -56,6 +55,25 @@ public class ProtocolHook { } }); + manager.addPacketListener(new PacketAdapter(ExcellentEnchantsAPI.PLUGIN, PacketType.Play.Server.OPEN_WINDOW_MERCHANT) { + @Override + public void onPacketSending(PacketEvent event) { + PacketContainer packet = event.getPacket(); + + List list = new ArrayList<>(); + boolean isCreative = event.getPlayer().getGameMode() == GameMode.CREATIVE; + packet.getMerchantRecipeLists().read(0).forEach(recipe -> { + ItemStack result = update(recipe.getResult(), isCreative); + if (result == null) return; + + MerchantRecipe r2 = new MerchantRecipe(result, recipe.getUses(), recipe.getMaxUses(), recipe.hasExperienceReward(), recipe.getVillagerExperience(), recipe.getPriceMultiplier(), recipe.getDemand(), recipe.getSpecialPrice()); + r2.setIngredients(recipe.getIngredients()); + list.add(r2); + }); + packet.getMerchantRecipeLists().write(0, list); + } + }); + isRegistered = true; } @@ -72,17 +90,18 @@ public class ProtocolHook { enchants.keySet().forEach(enchant -> lore.removeIf(line -> line.contains(enchant.getDisplayName()))); if (isCreative) { - enchants.forEach((enchant, integer) -> { - lore.removeAll(Config.formatDescription(enchant.getDescription(integer))); + enchants.forEach((enchant, level) -> { + lore.removeAll(enchant.formatDescription(level)); }); } - if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED && !isCreative) { - enchants.forEach((enchant, integer) -> { - lore.addAll(0, Config.formatDescription(enchant.getDescription(integer))); + if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED.get() && !isCreative) { + enchants.forEach((enchant, level) -> { + lore.addAll(0, enchant.formatDescription(level)); }); } - enchants.forEach((enchant, integer) -> { - lore.add(0, enchant.getNameFormatted(integer)); + enchants.forEach((enchant, level) -> { + int charges = EnchantManager.getEnchantmentCharges(item, enchant); + lore.add(0, enchant.getNameFormatted(level, charges)); }); meta.setLore(lore); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantAquaman.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantAquaman.java deleted file mode 100644 index 5664bb8..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantAquaman.java +++ /dev/null @@ -1,35 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.armor; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; - -public class EnchantAquaman extends IEnchantPotionTemplate implements PassiveEnchant { - - public static final String ID = "aquaman"; - - public EnchantAquaman(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.WATER_BREATHING); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.ARMOR_HEAD; - } - - @Override - public boolean use(@NotNull LivingEntity entity, int level) { - if (!this.isEnchantmentAvailable(entity)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(entity)) return false; - - return this.addEffect(entity, level); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantBunnyHop.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantBunnyHop.java deleted file mode 100644 index 23f57f9..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantBunnyHop.java +++ /dev/null @@ -1,35 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.armor; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; - -public class EnchantBunnyHop extends IEnchantPotionTemplate implements PassiveEnchant { - - public static final String ID = "bunny_hop"; - - public EnchantBunnyHop(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.JUMP); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.ARMOR_FEET; - } - - @Override - public boolean use(@NotNull LivingEntity entity, int level) { - if (!this.isEnchantmentAvailable(entity)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(entity)) return false; - - return this.addEffect(entity, level); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantColdSteel.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantColdSteel.java deleted file mode 100644 index 02a79cc..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantColdSteel.java +++ /dev/null @@ -1,37 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.armor; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -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.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; - -public class EnchantColdSteel extends IEnchantPotionTemplate implements CombatEnchant { - - public static final String ID = "cold_steel"; - - public EnchantColdSteel(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.SLOW_DIGGING); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.ARMOR_TORSO; - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(damager)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(victim)) return false; - - return this.addEffect(damager, level); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFireShield.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFireShield.java deleted file mode 100644 index d177944..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantFireShield.java +++ /dev/null @@ -1,67 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.armor; - -import org.bukkit.enchantments.EnchantmentTarget; -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.api.config.JYML; -import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; - -import java.util.function.UnaryOperator; - -public class EnchantFireShield extends IEnchantChanceTemplate implements CombatEnchant { - - public static final String ID = "fire_shield"; - public static final String PLACEHOLDER_FIRE_DURATION = "%enchantment_fire_duration%"; - - private Scaler fireDuration; - - public EnchantFireShield(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - } - - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_FIRE_DURATION, NumberUtil.format(this.getFireDuration(level))) - ); - } - - @Override - public void loadConfig() { - super.loadConfig(); - - this.fireDuration = new EnchantScaler(this, "Settings.Fire.Duration"); - } - - @NotNull - @Override - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.ARMOR; - } - - public double getFireDuration(int level) { - return this.fireDuration.getValue(level); - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, - @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(victim)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(victim)) return false; - - int fireTicks = (int) (this.getFireDuration(level) * 20); - damager.setFireTicks(fireTicks); - - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantHardened.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantHardened.java deleted file mode 100644 index 74fdbc8..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantHardened.java +++ /dev/null @@ -1,37 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.armor; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -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.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; - -public class EnchantHardened extends IEnchantPotionTemplate implements CombatEnchant { - - public static final String ID = "hardened"; - - public EnchantHardened(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.DAMAGE_RESISTANCE); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.ARMOR_TORSO; - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(damager)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(victim)) return false; - - return this.addEffect(victim, level); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantNightVision.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantNightVision.java deleted file mode 100644 index a6eda1d..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantNightVision.java +++ /dev/null @@ -1,35 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.armor; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; - -public class EnchantNightVision extends IEnchantPotionTemplate implements PassiveEnchant { - - public static final String ID = "night_vision"; - - public EnchantNightVision(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.NIGHT_VISION); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.ARMOR_HEAD; - } - - @Override - public boolean use(@NotNull LivingEntity entity, int level) { - if (!this.isEnchantmentAvailable(entity)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(entity)) return false; - - return this.addEffect(entity, level); - } -} \ No newline at end of file diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java deleted file mode 100644 index eeda95e..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantRegrowth.java +++ /dev/null @@ -1,122 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.armor; - -import org.bukkit.Particle; -import org.bukkit.attribute.Attribute; -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.api.manager.ICleanable; -import su.nexmedia.engine.utils.EffectUtil; -import su.nexmedia.engine.utils.EntityUtil; -import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; -import su.nightexpress.excellentenchants.manager.tasks.AbstractEnchantPassiveTask; - -import java.util.Map; -import java.util.function.UnaryOperator; - -public class EnchantRegrowth extends IEnchantChanceTemplate implements PassiveEnchant, ICleanable { - - public static final String ID = "regrowth"; - - private String particleName; - private String particleData; - private long healthInterval; - private Scaler healthAmount; - private Task healthTask; - - private static final String PLACEHOLDER_HEALTH_AMOUNT = "%enchantment_health_amount%"; - private static final String PLACEHOLDER_HEALTH_INTERVAL = "%enchantment_health_interval%"; - - public EnchantRegrowth(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - - this.healthTask = new Task(plugin); - this.healthTask.start(); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.particleName = cfg.getString("Settings.Particle.Name", Particle.HEART.name()); - this.particleData = cfg.getString("Settings.Particle.Data", ""); - this.healthInterval = cfg.getLong("Settings.Health.Interval", 100); - this.healthAmount = new EnchantScaler(this, "Settings.Health.Amount"); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.addMissing("Settings.Health.Interval", 100); - cfg.addMissing("Settings.Particle.Name", Particle.HEART.name()); - cfg.addMissing("Settings.Particle.Data", ""); - } - - @Override - public void clear() { - if (this.healthTask != null) { - this.healthTask.stop(); - this.healthTask = null; - } - } - - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_HEALTH_AMOUNT, NumberUtil.format(this.getHealthAmount(level))) - .replace(PLACEHOLDER_HEALTH_INTERVAL, NumberUtil.format((double) this.healthInterval / 20D)) - ); - } - - @NotNull - @Override - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.ARMOR_TORSO; - } - - public double getHealthAmount(int level) { - return this.healthAmount.getValue(level); - } - - public long getHealthInterval() { - return this.healthInterval; - } - - @Override - public boolean use(@NotNull LivingEntity entity, int level) { - if (!this.isEnchantmentAvailable(entity)) return false; - if (!this.checkTriggerChance(level)) return false; - - double healthMax = EntityUtil.getAttribute(entity, Attribute.GENERIC_MAX_HEALTH); - double healthHas = entity.getHealth(); - if (healthHas >= healthMax) return false; - if (!this.takeCostItem(entity)) return false; - - double amount = Math.min(healthMax, healthHas + this.getHealthAmount(level)); - - entity.setHealth(amount); - EffectUtil.playEffect(entity.getEyeLocation(), this.particleName, this.particleData, 0.3, 0.3, 0.3, 0.1, 15); - return true; - } - - class Task extends AbstractEnchantPassiveTask { - - public Task(@NotNull ExcellentEnchants plugin) { - super(plugin, healthInterval, false); - } - - @Override - protected void apply(@NotNull LivingEntity entity, @NotNull Map enchants) { - use(entity, enchants.getOrDefault(EnchantRegrowth.this, 0)); - } - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java deleted file mode 100644 index 7af96ca..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSaturation.java +++ /dev/null @@ -1,111 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.armor; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.api.manager.ICleanable; -import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; -import su.nightexpress.excellentenchants.manager.tasks.AbstractEnchantPassiveTask; - -import java.util.Map; -import java.util.function.UnaryOperator; - -public class EnchantSaturation extends IEnchantChanceTemplate implements PassiveEnchant, ICleanable { - - private long saturationInterval; - private Scaler saturationAmount; - private Task saturationTask; - - public static final String ID = "saturation"; - - private static final String PLACEHOLDER_SATURATION_AMOUNT = "%enchantment_saturation_amount%"; - private static final String PLACEHOLDER_SATURATION_INTERVAL = "%enchantment_saturation_interval%"; - - public EnchantSaturation(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - - this.saturationTask = new Task(plugin); - this.saturationTask.start(); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.saturationInterval = cfg.getLong("Settings.Saturation.Interval", 100); - this.saturationAmount = new EnchantScaler(this, "Settings.Saturation.Amount"); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.addMissing("Settings.Saturation.Interval", 100); - } - - @Override - public void clear() { - if (this.saturationTask != null) { - this.saturationTask.stop(); - this.saturationTask = null; - } - } - - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_SATURATION_AMOUNT, NumberUtil.format(this.getSaturationAmount(level))) - .replace(PLACEHOLDER_SATURATION_INTERVAL, NumberUtil.format((double) this.saturationInterval / 20D)) - ); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.ARMOR_HEAD; - } - - public final double getSaturationAmount(int level) { - return this.saturationAmount.getValue(level); - } - - public long getSaturationInterval() { - return saturationInterval; - } - - @Override - public boolean use(@NotNull LivingEntity entity, int level) { - if (!this.isEnchantmentAvailable(entity)) return false; - if (!(entity instanceof Player player)) return false; - if (player.getFoodLevel() >= 20) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(player)) return false; - - float amount = (float) this.getSaturationAmount(level); - player.setFoodLevel((int) Math.min(20, player.getFoodLevel() + amount)); - player.setSaturation(Math.min(20, player.getSaturation() + amount)); - return true; - } - - class Task extends AbstractEnchantPassiveTask { - - public Task(@NotNull ExcellentEnchants plugin) { - super(plugin, saturationInterval, false); - } - - @Override - protected void apply(@NotNull LivingEntity entity, @NotNull Map enchants) { - // TODO Need to use SUM level and bypass the Scaler cap - use(entity, enchants.getOrDefault(EnchantSaturation.this, 0)); - } - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSonic.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSonic.java deleted file mode 100644 index 4e34205..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/armor/EnchantSonic.java +++ /dev/null @@ -1,35 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.armor; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; - -public class EnchantSonic extends IEnchantPotionTemplate implements PassiveEnchant { - - public static final String ID = "sonic"; - - public EnchantSonic(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.SPEED); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.ARMOR_FEET; - } - - @Override - public boolean use(@NotNull LivingEntity entity, int level) { - if (!this.isEnchantmentAvailable(entity)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(entity)) return false; - - return this.addEffect(entity, level); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantConfusingArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantConfusingArrows.java deleted file mode 100644 index e7391b9..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantConfusingArrows.java +++ /dev/null @@ -1,17 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.bow; - -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowPotionTemplate; - -public class EnchantConfusingArrows extends IEnchantBowPotionTemplate { - - public static final String ID = "confusing_arrows"; - - public EnchantConfusingArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.CONFUSION); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java deleted file mode 100644 index 22c8608..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java +++ /dev/null @@ -1,93 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.bow; - -import org.bukkit.Location; -import org.bukkit.Particle; -import org.bukkit.World; -import org.bukkit.entity.AreaEffectCloud; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Projectile; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -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.config.JYML; -import su.nexmedia.engine.utils.NumberUtil; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowTemplate; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; - -import java.util.function.UnaryOperator; - -public class EnchantDragonfireArrows extends IEnchantBowTemplate { - - public static final String ID = "dragonfire_arrows"; - - public static final String PLACEHOLDER_FIRE_RADIUS = "%enchantment_fire_radius%"; - public static final String PLACEHOLDER_FIRE_DURATION = "%enchantment_fire_duration%"; - - private EnchantScaler fireDuration; - private EnchantScaler fireRadius; - - public EnchantDragonfireArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.fireDuration = new EnchantScaler(this, "Settings.Fire.Duration"); - this.fireRadius = new EnchantScaler(this, "Settings.Fire.Radius"); - } - - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_FIRE_DURATION, NumberUtil.format(this.getFireDuration(level) / 20D)) - .replace(PLACEHOLDER_FIRE_RADIUS, NumberUtil.format(this.getFireRadius(level))) - ); - } - - public int getFireDuration(int level) { - return (int) this.fireDuration.getValue(level); - } - - public double getFireRadius(int level) { - return this.fireRadius.getValue(level); - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!super.use(e, damager, victim, weapon, level)) return false; - - this.createCloud(damager, victim.getLocation(), level); - return true; - } - - @Override - public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { - if (!super.use(e, projectile, bow, level)) return false; - - this.createCloud(projectile.getShooter(), projectile.getLocation() , level); - return true; - } - - private void createCloud(@Nullable ProjectileSource shooter, @NotNull Location location, int level) { - World world = location.getWorld(); - if (world == null) return; - - AreaEffectCloud cloud = world.spawn(location, AreaEffectCloud.class); - cloud.clearCustomEffects(); - cloud.setSource(shooter); - cloud.setParticle(Particle.DRAGON_BREATH); - cloud.setRadius((float) this.getFireRadius(level)); - cloud.setDuration(this.getFireDuration(level)); - cloud.setRadiusPerTick((7.0F - cloud.getRadius()) / (float) cloud.getDuration()); - cloud.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 1, 1), true); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java deleted file mode 100644 index b97f186..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java +++ /dev/null @@ -1,50 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.bow; - -import org.bukkit.Particle; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Projectile; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.utils.EffectUtil; -import su.nexmedia.engine.utils.LocationUtil; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowTemplate; - -public class EnchantElectrifiedArrows extends IEnchantBowTemplate { - - public static final String ID = "electrified_arrows"; - - public EnchantElectrifiedArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!super.use(e, damager, victim, weapon, level)) return false; - - plugin.getServer().getScheduler().runTask(plugin, () -> { - victim.setNoDamageTicks(0); - victim.getWorld().strikeLightning(victim.getLocation()); - }); - - return true; - } - - @Override - public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { - if (!super.use(e, projectile, bow, level)) return false; - if (e.getHitEntity() != null || e.getHitBlock() == null) return false; - - Block block = e.getHitBlock(); - block.getWorld().strikeLightning(block.getLocation()); - 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); - - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java deleted file mode 100644 index f2cbc70..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantEnderBow.java +++ /dev/null @@ -1,55 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.bow; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.EnderPearl; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Projectile; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.manager.EnchantManager; - -public class EnchantEnderBow extends IEnchantChanceTemplate implements BowEnchant { - - public static final String ID = "ender_bow"; - - public EnchantEnderBow(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.HIGHEST); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.BOW; - } - - @Override - public boolean use(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isEnchantmentAvailable(shooter)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!(e.getProjectile() instanceof Projectile projectile)) return false; - if (!EnchantManager.hasEnchantment(bow, ARROW_INFINITE) && !this.takeCostItem(shooter)) return false; - - EnderPearl pearl = shooter.launchProjectile(EnderPearl.class); - pearl.setVelocity(projectile.getVelocity()); - e.setProjectile(pearl); - return true; - } - - @Override - public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { - return false; - } - - @Override - public boolean use(@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/manager/enchants/bow/EnchantExplosiveArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java deleted file mode 100644 index 11adde2..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantExplosiveArrows.java +++ /dev/null @@ -1,107 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.bow; - -import org.bukkit.World; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.entity.Projectile; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -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.api.config.JYML; -import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowTemplate; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; - -import java.util.function.UnaryOperator; - -public class EnchantExplosiveArrows extends IEnchantBowTemplate { - - private boolean explosionFireSpread; - private boolean explosionDamageItems; - private boolean explosionDamageBlocks; - private Scaler explosionSize; - - public static final String ID = "explosive_arrows"; - public static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; - - private static final String META_EXPLOSION_SOURCE = ID + "_source"; - - public EnchantExplosiveArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.explosionFireSpread = cfg.getBoolean("Settings.Explosion.Fire_Spread"); - this.explosionDamageItems = cfg.getBoolean("Settings.Explosion.Damage_Items"); - this.explosionDamageBlocks = cfg.getBoolean("Settings.Explosion.Damage_Blocks"); - this.explosionSize = new EnchantScaler(this, "Settings.Explosion.Size"); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - this.cfg.addMissing("Settings.Explosion.Fire_Spread", true); - this.cfg.addMissing("Settings.Explosion.Damage_Items", true); - this.cfg.addMissing("Settings.Explosion.Damage_Blocks", false); - } - - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_EXPLOSION_POWER, NumberUtil.format(this.getExplosionSize(level))) - ); - } - - public final double getExplosionSize(int level) { - return this.explosionSize.getValue(level); - } - - public final boolean isExplosionFireSpread() { - return this.explosionFireSpread; - } - - public final boolean isExplosionDamageBlocks() { - return this.explosionDamageBlocks; - } - - @Override - public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { - if (!super.use(e, projectile, bow, level)) return false; - - Entity shooter = null; - if (projectile.getShooter() instanceof Entity entity) { - shooter = entity; - shooter.setMetadata(META_EXPLOSION_SOURCE, new FixedMetadataValue(this.plugin, true)); - } - - World world = projectile.getWorld(); - float explSize = (float) this.getExplosionSize(level); - boolean explFire = this.isExplosionFireSpread(); - boolean explBlocks = this.isExplosionDamageBlocks(); - boolean exploded = world.createExplosion(projectile.getLocation(), explSize, explFire, explBlocks, shooter); - if (shooter != null) shooter.removeMetadata(META_EXPLOSION_SOURCE, this.plugin); - return exploded; - } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onItemDamage(EntityDamageByEntityEvent e) { - if (e.getCause() != EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) return; - if (this.explosionDamageItems) return; - if (!e.getDamager().hasMetadata(META_EXPLOSION_SOURCE)) return; - if (!(e.getEntity() instanceof Item item)) return; - - e.setCancelled(true); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantHover.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantHover.java deleted file mode 100644 index b708611..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantHover.java +++ /dev/null @@ -1,17 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.bow; - -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowPotionTemplate; - -public class EnchantHover extends IEnchantBowPotionTemplate { - - public static final String ID = "hover"; - - public EnchantHover(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.LEVITATION); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java deleted file mode 100644 index bf4527c..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantPoisonedArrows.java +++ /dev/null @@ -1,17 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.bow; - -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowPotionTemplate; - -public class EnchantPoisonedArrows extends IEnchantBowPotionTemplate { - - public static final String ID = "poisoned_arrows"; - - public EnchantPoisonedArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.POISON); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java deleted file mode 100644 index ab6cb4e..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantWitheredArrows.java +++ /dev/null @@ -1,17 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.bow; - -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantBowPotionTemplate; - -public class EnchantWitheredArrows extends IEnchantBowPotionTemplate { - - public static final String ID = "withered_arrows"; - - public EnchantWitheredArrows(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.WITHER); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java deleted file mode 100644 index ecb92f4..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantCurseOfMisfortune.java +++ /dev/null @@ -1,79 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; -import su.nightexpress.excellentenchants.manager.type.FitItemType; - -public class EnchantCurseOfMisfortune extends IEnchantChanceTemplate implements BlockBreakEnchant, DeathEnchant { - - private boolean dropExp; - - public static final String ID = "curse_of_misfortune"; - - public EnchantCurseOfMisfortune(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.LOWEST); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.dropExp = cfg.getBoolean("Settings.Drop_Exp"); - } - - public boolean isDropExp() { - return dropExp; - } - - @Override - @NotNull - public FitItemType[] getFitItemTypes() { - return new FitItemType[] {FitItemType.WEAPON, FitItemType.TOOL}; - } - - @NotNull - @Override - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.BREAKABLE; - } - - @Override - public boolean isCursed() { - return true; - } - - @Override - public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isEnchantmentAvailable(player)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(player)) return false; - - e.setDropItems(false); - if (!this.isDropExp()) e.setExpToDrop(0); - return true; - } - - @Override - public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level) { - Player player = dead.getKiller(); - if (player == null) return false; - if (!this.isEnchantmentAvailable(player)) return false; - - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(player)) return false; - - e.getDrops().clear(); - if (!this.isDropExp()) e.setDroppedExp(0); - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantHaste.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantHaste.java deleted file mode 100644 index 26eb8ba..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantHaste.java +++ /dev/null @@ -1,35 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantPotionTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; - -public class EnchantHaste extends IEnchantPotionTemplate implements PassiveEnchant { - - public static final String ID = "haste"; - - public EnchantHaste(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.FAST_DIGGING); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.TOOL; - } - - @Override - public boolean use(@NotNull LivingEntity entity, int level) { - if (!this.isEnchantmentAvailable(entity)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(entity)) return false; - - return this.addEffect(entity, level); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java deleted file mode 100644 index 2fdae73..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTelekinesis.java +++ /dev/null @@ -1,105 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; - -import org.bukkit.block.Block; -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.Item; -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.JYML; -import su.nexmedia.engine.api.lang.LangMessage; -import su.nexmedia.engine.utils.ItemUtil; -import su.nexmedia.engine.utils.PlayerUtil; -import su.nexmedia.engine.utils.StringUtil; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; -import su.nightexpress.excellentenchants.manager.type.FitItemType; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.function.UnaryOperator; - -public class EnchantTelekinesis extends IEnchantChanceTemplate implements CustomDropEnchant { - - private LangMessage messageDropReceived; - private String messageItemName; - private String messageItemSeparator; - - public static final String ID = "telekinesis"; - - public EnchantTelekinesis(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.LOWEST); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.messageDropReceived = new LangMessage(plugin, cfg.getString("Settings.Message.Drop_Received", "")); - this.messageItemName = StringUtil.color(cfg.getString("Settings.Message.Item_Name", "&7x%item_amount% &f%item_name%")); - this.messageItemSeparator = StringUtil.color(cfg.getString("Settings.Message.Item_Separator", "&7, ")); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.remove("Settings.Radius"); - cfg.remove("Settings.Power"); - - cfg.addMissing("Settings.Message.Drop_Received", "{message: ~type: ACTION_BAR; ~prefix: false;}%items%"); - cfg.addMissing("Settings.Message.Item_Name", "&7x%item_amount% &f%item_name%"); - cfg.addMissing("Settings.Message.Item_Separator", "&7, "); - } - - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return super.replacePlaceholders(level); - } - - @Override - @NotNull - public FitItemType[] getFitItemTypes() { - return new FitItemType[]{FitItemType.TOOL}; - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.TOOL; - } - - @Override - public void handleDrop(@NotNull EnchantDropContainer container, @NotNull Player player, @NotNull ItemStack item, int level) { - BlockDropItemEvent dropItemEvent = container.getParent(); - Block block = dropItemEvent.getBlockState().getBlock(); - - if (!this.isEnchantmentAvailable(player)) return; - //if (block.getState() instanceof Container) return; - if (!this.checkTriggerChance(level)) return; - - List drops = new ArrayList<>(); - drops.addAll(dropItemEvent.getItems().stream().map(Item::getItemStack).toList()); - drops.addAll(container.getDrop()); - drops.removeIf(Objects::isNull); - - StringBuilder builder = new StringBuilder(); - drops.forEach(drop -> { - PlayerUtil.addItem(player, drop); - - if (!builder.isEmpty()) builder.append(this.messageItemSeparator); - builder.append(this.messageItemName - .replace("%item_name%", ItemUtil.getItemName(drop)) - .replace("%item_amount%", String.valueOf(drop.getAmount()))); - }); - this.messageDropReceived.replace("%items%", builder.toString()).send(player); - - container.getDrop().clear(); - dropItemEvent.getItems().clear(); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java deleted file mode 100644 index fbef4b8..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/tool/EnchantTreasures.java +++ /dev/null @@ -1,138 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.tool; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.Sound; -import org.bukkit.block.Block; -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 org.jetbrains.annotations.Nullable; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.api.manager.ICleanable; -import su.nexmedia.engine.utils.EffectUtil; -import su.nexmedia.engine.utils.LocationUtil; -import su.nexmedia.engine.utils.MessageUtil; -import su.nexmedia.engine.utils.random.Rnd; -import su.nexmedia.playerblocktracker.PlayerBlockTracker; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantDropContainer; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.CustomDropEnchant; -import su.nightexpress.excellentenchants.manager.type.FitItemType; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Predicate; - -public class EnchantTreasures extends IEnchantChanceTemplate implements CustomDropEnchant, ICleanable { - - private String particleName; - private String particleData; - private Sound sound; - private Map> treasures; - private final Predicate blockTracker; - - public static final String ID = "treasures"; - - public EnchantTreasures(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - - PlayerBlockTracker.initialize(plugin); - PlayerBlockTracker.BLOCK_FILTERS.add(this.blockTracker = (block) -> { - return this.getTreasure(block.getType()) != null; - }); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.particleName = cfg.getString("Settings.Particle.Name", Particle.REDSTONE.name()); - this.particleData = cfg.getString("Settings.Particle.Data", "200,180,0"); - this.sound = cfg.getEnum("Settings.Sound", Sound.class, Sound.BLOCK_NOTE_BLOCK_BELL); - this.treasures = new HashMap<>(); - for (String sFromArray : cfg.getSection("Settings.Treasures")) { - for (String sFrom : sFromArray.split(",")) { - Material mFrom = Material.getMaterial(sFrom.toUpperCase()); - if (mFrom == null) { - plugin.error("[Treasures] Invalid source material '" + sFrom + "' !"); - continue; - } - Map treasuresList = new HashMap<>(); - - for (String sTo : cfg.getSection("Settings.Treasures." + sFromArray)) { - Material mTo = Material.getMaterial(sTo.toUpperCase()); - if (mTo == null) { - plugin.error("[Treasures] Invalid result material '" + sTo + "' for '" + sFromArray + "' !"); - continue; - } - - double tChance = cfg.getDouble("Settings.Treasures." + sFromArray + "." + sTo); - treasuresList.put(mTo, tChance); - } - this.treasures.put(mFrom, treasuresList); - } - } - } - - @Override - public void clear() { - PlayerBlockTracker.BLOCK_FILTERS.remove(this.blockTracker); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - cfg.remove("Settings.Particle_Effect"); - cfg.addMissing("Settings.Particle.Name", Particle.REDSTONE.name()); - cfg.addMissing("Settings.Particle.Data", "200,180,0"); - cfg.addMissing("Settings.Sound", Sound.BLOCK_NOTE_BLOCK_BELL.name()); - } - - @Override - @NotNull - public FitItemType[] getFitItemTypes() { - return new FitItemType[]{FitItemType.PICKAXE, FitItemType.AXE, FitItemType.SHOVEL}; - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.TOOL; - } - - @Override - public void handleDrop(@NotNull EnchantDropContainer e, @NotNull Player player, @NotNull ItemStack item, int level) { - BlockDropItemEvent parent = e.getParent(); - Block block = parent.getBlockState().getBlock(); - if (!this.isEnchantmentAvailable(player)) return; - if (PlayerBlockTracker.isTracked(block)) return; - if (!this.checkTriggerChance(level)) return; - if (!this.takeCostItem(player)) return; - - ItemStack treasure = this.getTreasure(parent.getBlockState().getType()); - if (treasure == null) return; - - e.getDrop().add(treasure); - this.playEffect(block); - } - - @Nullable - public final ItemStack getTreasure(@NotNull Material type) { - Map treasures = this.treasures.get(type); - if (treasures == null) return null; - - Material mat = Rnd.get(treasures); - return mat != null && !mat.isAir() ? new ItemStack(mat) : null; - } - - public void playEffect(@NotNull Block block) { - Location location = LocationUtil.getCenter(block.getLocation()); - MessageUtil.sound(location, this.sound); - EffectUtil.playEffect(location, this.particleName, this.particleData, 0.2f, 0.2f, 0.2f, 0.12f, 20); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java deleted file mode 100644 index d6cc057..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBaneOfNetherspawn.java +++ /dev/null @@ -1,99 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import com.google.common.collect.Sets; -import org.bukkit.Particle; -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.EntityType; -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.api.config.JYML; -import su.nexmedia.engine.utils.EffectUtil; -import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; - -import java.util.Set; -import java.util.function.UnaryOperator; - -public class EnchantBaneOfNetherspawn extends IEnchantChanceTemplate implements CombatEnchant { - - private String particleName; - private String particleData; - private boolean damageModifier; - private Scaler damageFormula; - private final Set entityTypes; - - public static final String ID = "bane_of_netherspawn"; - - private static final String PLACEHOLDER_DAMAGE = "%enchantment_damage%"; - - public EnchantBaneOfNetherspawn(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - - this.entityTypes = Sets.newHashSet(EntityType.BLAZE, EntityType.MAGMA_CUBE, - EntityType.WITHER_SKELETON, EntityType.GHAST, EntityType.WITHER); - - this.entityTypes.add(EntityType.PIGLIN); - this.entityTypes.add(EntityType.PIGLIN_BRUTE); - this.entityTypes.add(EntityType.ZOGLIN); - this.entityTypes.add(EntityType.HOGLIN); - this.entityTypes.add(EntityType.STRIDER); - this.entityTypes.add(EntityType.ZOMBIFIED_PIGLIN); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.particleName = cfg.getString("Settings.Particle.Name", ""); - this.particleData = cfg.getString("Settings.Particle.Data", ""); - this.damageModifier = cfg.getBoolean("Settings.Damage.As_Modifier"); - this.damageFormula = new EnchantScaler(this, "Settings.Damage.Formula"); - } - - public double getDamageModifier(int level) { - return this.damageFormula.getValue(level); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.remove("Settings.Particle_Effect"); - cfg.addMissing("Settings.Particle.Name", Particle.SMOKE_NORMAL.name()); - cfg.addMissing("Settings.Particle.Data", ""); - } - - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str - .replace(PLACEHOLDER_DAMAGE, NumberUtil.format(this.getDamageModifier(level))) - ); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.WEAPON; - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(damager)) return false; - if (!this.entityTypes.contains(victim.getType())) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(damager)) return false; - - double damageEvent = e.getDamage(); - double damageAdd = this.getDamageModifier(level); - e.setDamage(this.damageModifier ? damageEvent * damageAdd : damageEvent + damageAdd); - EffectUtil.playEffect(victim.getEyeLocation(), this.particleName, this.particleData, 0.25, 0.25, 0.25, 0.1f, 30); - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBlindness.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBlindness.java deleted file mode 100644 index 9b9bd7e..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantBlindness.java +++ /dev/null @@ -1,17 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; - -public class EnchantBlindness extends IEnchantCombatPotionTemplate { - - public static final String ID = "blindness"; - - public EnchantBlindness(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.BLINDNESS); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantConfusion.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantConfusion.java deleted file mode 100644 index 3eee512..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantConfusion.java +++ /dev/null @@ -1,17 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; - -public class EnchantConfusion extends IEnchantCombatPotionTemplate { - - public static final String ID = "confusion"; - - public EnchantConfusion(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.CONFUSION); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCure.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCure.java deleted file mode 100644 index eb65ca3..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantCure.java +++ /dev/null @@ -1,79 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import com.google.common.collect.Sets; -import org.bukkit.Particle; -import org.bukkit.Sound; -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.*; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.utils.EffectUtil; -import su.nexmedia.engine.utils.MessageUtil; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; - -import java.util.Set; - -public class EnchantCure extends IEnchantChanceTemplate implements CombatEnchant { - - private Sound sound; - private String particleName; - private String particleData; - - public static final String ID = "cure"; - - private static final Set MOBS_TO_CURE = Sets.newHashSet(EntityType.ZOMBIFIED_PIGLIN, EntityType.ZOMBIE_VILLAGER); - - public EnchantCure(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.sound = cfg.getEnum("Settings.Sound", Sound.class); - this.particleName = cfg.getString("Settings.Particle.Name", Particle.CLOUD.name()); - this.particleData = cfg.getString("Settings.Particle.Data", ""); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.remove("Settings.Particle_Effect"); - cfg.addMissing("Settings.Particle.Name", Particle.CLOUD.name()); - cfg.addMissing("Settings.Particle.Data", ""); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.WEAPON; - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(damager)) return false; - if (!MOBS_TO_CURE.contains(victim.getType())) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(damager)) return false; - - e.setCancelled(true); - - EffectUtil.playEffect(victim.getLocation(), this.particleName, this.particleData, 0.25, 0.25, 0.25, 0.1f, 20); - MessageUtil.sound(victim.getLocation(), this.sound); - - if (victim instanceof PigZombie pigZombie) { - victim.getWorld().spawn(victim.getLocation(), Piglin.class); - victim.remove(); - } - else if (victim instanceof ZombieVillager zombieVillager) { - zombieVillager.setConversionTime(1); - } - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java deleted file mode 100644 index ef13794..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDecapitator.java +++ /dev/null @@ -1,126 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - - -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.*; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.utils.EffectUtil; -import su.nexmedia.engine.utils.ItemUtil; -import su.nexmedia.engine.utils.StringUtil; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -public class EnchantDecapitator extends IEnchantChanceTemplate implements DeathEnchant { - - private String particleName; - private String particleData; - private Set ignoredEntityTypes; - private String headName; - private Map headTextures; - - public static final String ID = "decapitator"; - - public EnchantDecapitator(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.particleName = cfg.getString("Settings.Particle.Name", Particle.BLOCK_CRACK.name()); - this.particleData = cfg.getString("Settings.Particle.Data", Material.REDSTONE_BLOCK.name()); - this.ignoredEntityTypes = cfg.getStringSet("Settings.Ignored_Entity_Types").stream().map(String::toUpperCase).collect(Collectors.toSet()); - this.headName = StringUtil.color(cfg.getString("Settings.Head_Item.Name", "&c%entity%'s Head")); - this.headTextures = new HashMap<>(); - for (String sType : cfg.getSection("Settings.Head_Item.Textures")) { - String texture = cfg.getString("Settings.Head_Item.Textures." + sType); - this.headTextures.put(sType.toUpperCase(), texture); - } - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - this.cfg.remove("Settings.Particle_Effect"); - this.cfg.addMissing("Settings.Particle.Name", Particle.BLOCK_CRACK.name()); - this.cfg.addMissing("Settings.Particle.Data", Material.REDSTONE_BLOCK.name()); - this.cfg.addMissing("Settings.Ignored_Entity_Types", Arrays.asList("ENDER_DRAGON", "WITHER_SKELETON", "WITHER")); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.WEAPON; - } - - @Override - public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity victim, int level) { - if (!this.isEnchantmentAvailable(victim)) return false; - - EntityType entityType = victim.getType(); - if (this.ignoredEntityTypes.contains(entityType.name())) return false; - if (!this.checkTriggerChance(level)) return false; - - Player killer = victim.getKiller(); - if (killer == null) return false; - if (!this.takeCostItem(killer)) return false; - - ItemStack item; - if (entityType == EntityType.WITHER_SKELETON || entityType == EntityType.WITHER) { - item = new ItemStack(Material.WITHER_SKELETON_SKULL); - } - else if (entityType == EntityType.ZOMBIE || entityType == EntityType.GIANT) { - item = new ItemStack(Material.ZOMBIE_HEAD); - } - else if (entityType == EntityType.SKELETON) { - item = new ItemStack(Material.SKELETON_SKULL); - } - else if (entityType == EntityType.CREEPER) { - item = new ItemStack(Material.CREEPER_HEAD); - } - else if (entityType == EntityType.ENDER_DRAGON) { - item = new ItemStack(Material.DRAGON_HEAD); - } - else { - item = new ItemStack(Material.PLAYER_HEAD); - SkullMeta meta = (SkullMeta) item.getItemMeta(); - if (meta == null) return false; - - String entityName; - if (victim instanceof Player player) { - entityName = this.headName.replace("%entity%", victim.getName()); - meta.setOwningPlayer(player); - } - else { - String texture = this.headTextures.get(victim.getType().name()); - if (texture == null) return false; - - entityName = this.headName.replace("%entity%", plugin.getLangManager().getEnum(victim.getType())); - ItemUtil.setSkullTexture(item, texture); - meta = (SkullMeta) item.getItemMeta(); - } - - meta.setDisplayName(entityName); - item.setItemMeta(meta); - } - - victim.getWorld().dropItemNaturally(victim.getLocation(), item); - EffectUtil.playEffect(victim.getEyeLocation(), this.particleName, this.particleData, 0.2f, 0.15f, 0.2f, 0.15f, 40); - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDoubleStrike.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDoubleStrike.java deleted file mode 100644 index 0b69bde..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantDoubleStrike.java +++ /dev/null @@ -1,64 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.Particle; -import org.bukkit.Sound; -import org.bukkit.enchantments.EnchantmentTarget; -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.api.config.JYML; -import su.nexmedia.engine.utils.EffectUtil; -import su.nexmedia.engine.utils.MessageUtil; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; - -public class EnchantDoubleStrike extends IEnchantChanceTemplate implements CombatEnchant { - - private String particleName; - private String particleData; - private Sound sound; - - public static final String ID = "double_strike"; - - public EnchantDoubleStrike(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.LOW); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.particleName = cfg.getString("Settings.Particle.Name", Particle.EXPLOSION_NORMAL.name()); - this.particleData = cfg.getString("Settings.Particle.Data", ""); - this.sound = cfg.getEnum("Settings.Sound", Sound.class); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - - cfg.remove("Settings.Particle_Effect"); - cfg.addMissing("Settings.Particle.Name", Particle.EXPLOSION_NORMAL.name()); - cfg.addMissing("Settings.Particle.Data", ""); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.WEAPON; - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(damager)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(damager)) return false; - - e.setDamage(e.getDamage() * 2D); - EffectUtil.playEffect(victim.getEyeLocation(), this.particleName, this.particleData, 0.2f, 0.15f, 0.2f, 0.15f, 20); - if (this.sound != null) MessageUtil.sound(victim.getLocation(), this.sound); - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExhaust.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExhaust.java deleted file mode 100644 index 41501f9..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantExhaust.java +++ /dev/null @@ -1,17 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; - -public class EnchantExhaust extends IEnchantCombatPotionTemplate { - - public static final String ID = "exhaust"; - - public EnchantExhaust(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.HUNGER); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantIceAspect.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantIceAspect.java deleted file mode 100644 index b6878d2..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantIceAspect.java +++ /dev/null @@ -1,28 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.entity.LivingEntity; -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.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; - -public class EnchantIceAspect extends IEnchantCombatPotionTemplate { - - public static final String ID = "ice_aspect"; - - public EnchantIceAspect(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.SLOW); - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!super.use(e, damager, victim, weapon, level)) return false; - - victim.setFreezeTicks(victim.getMaxFreezeTicks()); - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantNimble.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantNimble.java deleted file mode 100644 index 85b13f9..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantNimble.java +++ /dev/null @@ -1,43 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDeathEvent; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.utils.PlayerUtil; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; - -public class EnchantNimble extends IEnchantChanceTemplate implements DeathEnchant { - - public static final String ID = "nimble"; - - public EnchantNimble(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.LOWEST); - } - - @NotNull - @Override - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.WEAPON; - } - - @Override - public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level) { - if (!this.isEnchantmentAvailable(dead)) return false; - - Player player = dead.getKiller(); - if (player == null) return false; - - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(player)) return false; - - e.getDrops().forEach(item -> PlayerUtil.addItem(player, item)); - e.getDrops().clear(); - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantParalyze.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantParalyze.java deleted file mode 100644 index e55d476..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantParalyze.java +++ /dev/null @@ -1,17 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; - -public class EnchantParalyze extends IEnchantCombatPotionTemplate { - - public static final String ID = "paralyze"; - - public EnchantParalyze(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.SLOW_DIGGING); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRage.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRage.java deleted file mode 100644 index 9ce4156..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRage.java +++ /dev/null @@ -1,25 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.entity.LivingEntity; -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.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; - -public class EnchantRage extends IEnchantCombatPotionTemplate { - - public static final String ID = "rage"; - - public EnchantRage(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.INCREASE_DAMAGE); - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - return super.use(e, damager, damager, weapon, level); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java deleted file mode 100644 index f7c397a..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantRocket.java +++ /dev/null @@ -1,66 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.Sound; -import org.bukkit.enchantments.EnchantmentTarget; -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.api.config.JYML; -import su.nexmedia.engine.utils.EntityUtil; -import su.nexmedia.engine.utils.MessageUtil; -import su.nexmedia.engine.utils.Scaler; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.manager.object.EnchantScaler; - -public class EnchantRocket extends IEnchantChanceTemplate implements CombatEnchant { - - private Scaler fireworkPower; - - public static final String ID = "rocket"; - - public EnchantRocket(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.fireworkPower = new EnchantScaler(this, "Settings.Firework_Power"); - } - - public final double getFireworkPower(int level) { - return this.fireworkPower.getValue(level); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.WEAPON; - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(damager)) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(damager)) return false; - - if (victim.isInsideVehicle()) { - victim.leaveVehicle(); - } - - Firework firework = EntityUtil.spawnRandomFirework(victim.getLocation()); - FireworkMeta meta = firework.getFireworkMeta(); - meta.setPower((int) this.getFireworkPower(level)); - firework.setFireworkMeta(meta); - firework.addPassenger(victim); - - MessageUtil.sound(victim.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_LAUNCH); - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantSurprise.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantSurprise.java deleted file mode 100644 index d44ddfb..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantSurprise.java +++ /dev/null @@ -1,28 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.entity.LivingEntity; -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.config.JYML; -import su.nexmedia.engine.utils.random.Rnd; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; - -public class EnchantSurprise extends IEnchantCombatPotionTemplate { - - public static final String ID = "surprise"; - - public EnchantSurprise(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.BLINDNESS); - - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - this.potionEffectType = Rnd.get(PotionEffectType.values()); - return super.use(e, damager, victim, weapon, level); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThrifty.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThrifty.java deleted file mode 100644 index 1f12fc0..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThrifty.java +++ /dev/null @@ -1,87 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.Material; -import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.utils.PDCUtil; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; - -import java.util.Set; -import java.util.stream.Collectors; - -public class EnchantThrifty extends IEnchantChanceTemplate implements DeathEnchant { - - private Set ignoredEntityTypes; - private Set ignoredSpawnReasons; - private final NamespacedKey keyEntityIgnored; - - public static final String ID = "thrifty"; - - public EnchantThrifty(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - this.keyEntityIgnored = new NamespacedKey(plugin, ID + "_ignored"); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.ignoredEntityTypes = cfg.getStringSet("Settings.Ignored_Entity_Types").stream().map(String::toUpperCase).collect(Collectors.toSet()); - this.ignoredSpawnReasons = cfg.getStringSet("Settings.Ignored_Spawn_Reasons").stream().map(String::toUpperCase).collect(Collectors.toSet()); - } - - @Override - protected void updateConfig() { - super.updateConfig(); - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.WEAPON; - } - - @Override - public boolean use(@NotNull EntityDeathEvent e, @NotNull LivingEntity dead, int level) { - if (!this.isEnchantmentAvailable(dead)) return false; - - Player killer = dead.getKiller(); - if (killer == null) return false; - - if (this.ignoredEntityTypes.contains(dead.getType().name())) return false; - if (PDCUtil.getBooleanData(dead, this.keyEntityIgnored)) return false; - if (!this.checkTriggerChance(level)) return false; - - Material material = Material.getMaterial(dead.getType().name() + "_SPAWN_EGG"); - if (material == null) { - if (dead.getType() == EntityType.MUSHROOM_COW) { - material = Material.MOOSHROOM_SPAWN_EGG; - } - else return false; - } - if (!this.takeCostItem(killer)) return false; - - ItemStack egg = new ItemStack(material); - e.getDrops().add(egg); - return true; - } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onSettingCreatureSpawnReason(CreatureSpawnEvent e) { - if (!this.ignoredSpawnReasons.contains(e.getSpawnReason().name())) return; - - PDCUtil.setData(e.getEntity(), this.keyEntityIgnored, true); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThunder.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThunder.java deleted file mode 100644 index fe2965d..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantThunder.java +++ /dev/null @@ -1,55 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.enchantments.EnchantmentTarget; -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.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantChanceTemplate; -import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; - -public class EnchantThunder extends IEnchantChanceTemplate implements CombatEnchant { - - private boolean inThunderstormOnly; - - public static final String ID = "thunder"; - - public EnchantThunder(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM); - } - - @Override - public void loadConfig() { - super.loadConfig(); - this.inThunderstormOnly = cfg.getBoolean("Settings.During_Thunderstorm_Only"); - } - - public boolean isInThunderstormOnly() { - return inThunderstormOnly; - } - - @Override - @NotNull - public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.WEAPON; - } - - @Override - public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isEnchantmentAvailable(damager)) return false; - if (this.isInThunderstormOnly() && !victim.getWorld().isThundering()) return false; - if (victim.getLocation().getBlock().getLightFromSky() != 15) return false; - if (!this.checkTriggerChance(level)) return false; - if (!this.takeCostItem(damager)) return false; - - plugin.getServer().getScheduler().runTask(plugin, () -> { - victim.setNoDamageTicks(0); - victim.getWorld().strikeLightning(victim.getLocation()); - }); - - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVenom.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVenom.java deleted file mode 100644 index c4b3bbe..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantVenom.java +++ /dev/null @@ -1,17 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; - -public class EnchantVenom extends IEnchantCombatPotionTemplate { - - public static final String ID = "venom"; - - public EnchantVenom(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.POISON); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantWither.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantWither.java deleted file mode 100644 index 0f032ca..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/weapon/EnchantWither.java +++ /dev/null @@ -1,17 +0,0 @@ -package su.nightexpress.excellentenchants.manager.enchants.weapon; - -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.EnchantPriority; -import su.nightexpress.excellentenchants.api.enchantment.IEnchantCombatPotionTemplate; - -public class EnchantWither extends IEnchantCombatPotionTemplate { - - public static final String ID = "wither"; - - public EnchantWither(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) { - super(plugin, cfg, EnchantPriority.MEDIUM, PotionEffectType.WITHER); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java deleted file mode 100644 index aa6c268..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantListGUI.java +++ /dev/null @@ -1,123 +0,0 @@ -package su.nightexpress.excellentenchants.manager.object; - -import org.bukkit.NamespacedKey; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JYML; -import su.nexmedia.engine.api.menu.*; -import su.nexmedia.engine.lang.LangManager; -import su.nexmedia.engine.utils.CollectionsUtil; -import su.nexmedia.engine.utils.ItemUtil; -import su.nexmedia.engine.utils.PDCUtil; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.config.Lang; -import su.nightexpress.excellentenchants.manager.EnchantRegister; - -import java.util.*; - -public class EnchantListGUI extends AbstractMenu { - - private final ItemStack enchantIcon; - private final int[] enchantSlots; - - private final NamespacedKey keyLevel; - private final Map> iconCache; - - public EnchantListGUI(@NotNull ExcellentEnchants plugin) { - super(plugin, JYML.loadOrExtract(plugin, "gui.enchants.yml"), ""); - this.keyLevel = new NamespacedKey(plugin, "list_display_level"); - this.iconCache = new HashMap<>(); - - this.enchantIcon = cfg.getItem("Enchantments.Icon"); - this.enchantSlots = cfg.getIntArray("Enchantments.Slots"); - - MenuClick click = (p, type, e) -> { - if (type instanceof MenuItemType type2) { - switch (type2) { - case PAGE_NEXT -> this.open(p, this.getPage(p) + 1); - case PAGE_PREVIOUS -> this.open(p, this.getPage(p) - 1); - case CLOSE -> p.closeInventory(); - } - } - }; - - for (String sId : cfg.getSection("Content")) { - MenuItem menuItem = cfg.getMenuItem("Content." + sId); - - if (menuItem.getType() != null) { - menuItem.setClickHandler(click); - } - this.addItem(menuItem); - } - } - - private ItemStack getEnchantIcon(@NotNull ExcellentEnchant enchant, int level) { - return this.iconCache.computeIfAbsent(enchant.getId(), k -> new HashMap<>()).computeIfAbsent(level, k -> this.buildEnchantIcon(enchant, level)); - } - - @NotNull - private ItemStack buildEnchantIcon(@NotNull ExcellentEnchant enchant, int level) { - ItemStack icon = new ItemStack(this.enchantIcon); - - // Override the conflicts placeholder display to make it in a list. - List conflicts = enchant.getConflicts().isEmpty() - ? plugin.getMessage(Lang.OTHER_NONE).asList() - : enchant.getConflicts().stream().filter(Objects::nonNull) - .map(LangManager::getEnchantment).toList(); - - ItemUtil.replaceLore(icon, Placeholders.ENCHANTMENT_CONFLICTS, conflicts); - ItemUtil.replace(icon, enchant.formatString(level)); - return icon; - } - - @Override - public boolean onPrepare(@NotNull Player player, @NotNull Inventory inventory) { - int page = this.getPage(player); - int length = this.enchantSlots.length; - List list = new ArrayList<>(EnchantRegister.ENCHANT_REGISTRY.values().stream(). - sorted(Comparator.comparing(ExcellentEnchant::getName)).toList()); - List> split = CollectionsUtil.split(list, length); - - int pages = split.size(); - if (pages < 1 || pages < page) list = Collections.emptyList(); - else list = split.get(page - 1); - - int count = 0; - for (ExcellentEnchant enchant : list) { - ItemStack icon = this.getEnchantIcon(enchant, 1); - PDCUtil.setData(icon, this.keyLevel, 1); - - MenuClick click = (p, type, e) -> { - if (!e.isLeftClick()) return; - - ItemStack itemClick = e.getCurrentItem(); - if (itemClick == null) return; - - int levelHas = PDCUtil.getIntData(itemClick, this.keyLevel); - if (levelHas == 0) return; - - if (++levelHas > enchant.getMaxLevel()) levelHas = enchant.getStartLevel(); - itemClick = this.getEnchantIcon(enchant, levelHas); - PDCUtil.setData(itemClick, this.keyLevel, levelHas); - - e.setCurrentItem(itemClick); - }; - - MenuItem menuItem = new MenuItem(icon, this.enchantSlots[count++]); - menuItem.setClickHandler(click); - this.addItem(player, menuItem); - } - this.setPage(player, page, pages); - return true; - } - - @Override - public boolean cancelClick(@NotNull InventoryClickEvent e, @NotNull SlotType slotType) { - return true; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantScaler.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantScaler.java deleted file mode 100644 index 200df18..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantScaler.java +++ /dev/null @@ -1,13 +0,0 @@ -package su.nightexpress.excellentenchants.manager.object; - -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.Scaler; -import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; - -public class EnchantScaler extends Scaler { - - public EnchantScaler(@NotNull ExcellentEnchant enchant, @NotNull String path) { - super(enchant.getConfig(), path, Placeholders.ENCHANTMENT_LEVEL, enchant.getStartLevel(), enchant.getMaxLevel()); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/AbstractEnchantPassiveTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/AbstractEnchantPassiveTask.java deleted file mode 100644 index 93647b4..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/AbstractEnchantPassiveTask.java +++ /dev/null @@ -1,43 +0,0 @@ -package su.nightexpress.excellentenchants.manager.tasks; - -import org.bukkit.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.task.AbstractTask; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.config.Config; -import su.nightexpress.excellentenchants.manager.EnchantManager; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -@Deprecated -public abstract class AbstractEnchantPassiveTask extends AbstractTask { - - public AbstractEnchantPassiveTask(@NotNull ExcellentEnchants plugin, long interval, boolean async) { - super(plugin, interval, async); - } - - protected abstract void apply(@NotNull LivingEntity entity, @NotNull Map enchants); - - @Override - public void action() { - for (LivingEntity entity : this.getEntities()) { - this.apply(entity, EnchantManager.getEquippedEnchantsMax(entity)); - } - } - - @NotNull - protected Collection<@NotNull ? extends LivingEntity> getEntities() { - Set list = new HashSet<>(plugin.getServer().getOnlinePlayers()); - - if (Config.ENCHANTMENTS_ENTITY_PASSIVE_FOR_MOBS) { - plugin.getServer().getWorlds().forEach(world -> { - list.addAll(world.getEntitiesByClass(LivingEntity.class)); - }); - } - return list; - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java deleted file mode 100644 index bd5f123..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/tasks/EnchantEffectPassiveTask.java +++ /dev/null @@ -1,22 +0,0 @@ -package su.nightexpress.excellentenchants.manager.tasks; - -import org.bukkit.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.config.Config; -import su.nightexpress.excellentenchants.manager.EnchantManager; - -import java.util.Map; - -public class EnchantEffectPassiveTask extends AbstractEnchantPassiveTask { - - public EnchantEffectPassiveTask(@NotNull ExcellentEnchants plugin) { - super(plugin, Config.TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL.get(), false); - } - - @Override - protected void apply(@NotNull LivingEntity entity, @NotNull Map enchants) { - EnchantManager.updateEquippedEnchantEffects(entity); - } -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java b/Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.java similarity index 61% rename from Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java rename to Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.java index 3fb1ea0..65c18bc 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/object/EnchantTier.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.java @@ -1,36 +1,58 @@ -package su.nightexpress.excellentenchants.manager.object; +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.utils.StringUtil; +import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; -import su.nightexpress.excellentenchants.manager.type.ObtainType; +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 EnchantTier { +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)); + } private final String id; private final int priority; private final String name; - private final String color; + private final ChatColor color; private final Map chance; private final Set enchants; - public EnchantTier(@NotNull String id, int priority, @NotNull String name, @NotNull String color, @NotNull Map chance) { + public Tier(@NotNull String id, int priority, @NotNull String name, @NotNull ChatColor color, + @NotNull Map chance) { this.id = id.toLowerCase(); this.priority = priority; this.name = StringUtil.color(name); - this.color = StringUtil.color(color); + this.color = color; this.chance = chance; this.enchants = new HashSet<>(); } + @Override + @NotNull + public UnaryOperator replacePlaceholders() { + return str -> str + .replace(Placeholders.TIER_ID, this.getId()) + .replace(Placeholders.TIER_NAME, this.getName()) + ; + } + @NotNull public String getId() { return this.id; @@ -42,11 +64,11 @@ public class EnchantTier { @NotNull public String getName() { - return this.name; + return this.getColor() + this.name; } @NotNull - public String getColor() { + public ChatColor getColor() { return this.color; } @@ -75,7 +97,7 @@ public class EnchantTier { .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()); + 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 new file mode 100644 index 0000000..14b2d85 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java @@ -0,0 +1,98 @@ +package su.nightexpress.excellentenchants.tier; + +import net.md_5.bungee.api.ChatColor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.api.manager.AbstractManager; +import su.nexmedia.engine.utils.random.Rnd; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.enchantment.type.ObtainType; + +import java.util.*; +import java.util.stream.Collectors; + +public class TierManager extends AbstractManager { + + private JYML config; + private final Map tiers; + + public TierManager(@NotNull ExcellentEnchants plugin) { + super(plugin); + this.tiers = new HashMap<>(); + + } + + @Override + protected void onLoad() { + /*if (ExcellentEnchants.isLoaded) { + this.getTiers().forEach(tier -> tier.getEnchants().clear()); + return; + }*/ + + this.config = JYML.loadOrExtract(plugin, "tiers.yml"); + + for (String sId : config.getSection("")) { + String path = sId + "."; + + int priority = config.getInt(path + "Priority"); + String name = config.getString(path + "Name", sId); + + ChatColor color; + try { + color = ChatColor.of(config.getString(path + "Color", ChatColor.WHITE.getName())); + } + catch (IllegalArgumentException e) { + color = ChatColor.WHITE; + } + + Map chance = new HashMap<>(); + for (ObtainType obtainType : ObtainType.values()) { + config.addMissing(path + "Obtain_Chance." + obtainType.name(), 50D); + + double chanceType = config.getDouble(path + "Obtain_Chance." + obtainType.name()); + chance.put(obtainType, chanceType); + } + + Tier tier = new Tier(sId, priority, name, color, chance); + 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()); + } + + @Override + protected void onShutdown() { + this.tiers.clear(); + } + + @NotNull + public JYML getConfig() { + return config; + } + + @Nullable + public Tier getTierById(@NotNull String id) { + return this.tiers.get(id.toLowerCase()); + } + + @NotNull + public Collection getTiers() { + return this.tiers.values(); + } + + @NotNull + public List getTierIds() { + return new ArrayList<>(this.tiers.keySet()); + } + + @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); + } +} diff --git a/Core/src/main/resources/config.yml b/Core/src/main/resources/config.yml index df80ae3..6bf4949 100644 --- a/Core/src/main/resources/config.yml +++ b/Core/src/main/resources/config.yml @@ -1,162 +1,4 @@ -# Plugin engine settings. Plugin: - # Name(s) for the main plugin command. - Command_Aliases: excellentenchants,eenchants - # Plugin language config. - # - # In 'lang' folder there are configs for different languages with a format like 'messages_code.yml', - # where 'code' is the language code which you specify here. - # - # To create a new language config, simply copy the default one and rename it to your language code. - Language: en - # Plugin prefix name. - Name: ExcellentEnchants - Prefix: '&e%plugin_name% &8» &7' - -# General plugin settings. -General: - # Settings for the plugin tasks. - Tasks: - Arrow_Trails: - # Defines the ticks interval (20 ticks = 1 second) for the arrow particle effect spawning. - Ticks_Interval: 1 - # Enchantment global settings. - Enchantments: - # List of disabled custom enchantments. - # Use enchantment file names from the 'enchants' folder without the file extension. - # For example, to disable 'Explosive Arrows' enchantment you have to add 'explosive_arrows' to this list. - Disabled: - - enchant_name - - other_enchant - # Here you can disable certain enchantments in certain worlds. - Disabled_In_Worlds: - # This is your world name with a list of disabled enchantments. - # Enchantment names are the same as in the option above. - # To disable all enchantments, use '*'. - my_world: - - '*' - other_world: - - 'enchant_name' - - 'another_enchant' - # Item settings. - Item: - # How many of custom enchantments the item can contain at the same time? - Max_Custom_Enchants: 3 - # Set this to 'true' to make Sword enchantments apply on Axes. - Axes_As_Swords: true - # Set this to 'true' to make Bow enchantments apply on Crossbows. - Crossbows_As_Bows: true - # Set this to 'true' to make Chestplate enchantments apply on Elytras. - Elytra_As_Chestplate: true - # Non-player entity settings. - Entity: - # When enabled, enchantments with a passive effects (potion effects, regeneration, etc.) - # will be applied to mobs as well (if they are wearing items with such enchantments). - # Enabling this feature may cause performance issues. - Passive_Enchants_Applied_To_Mobs: false - # Enchantment description settings. - Description: - # When enabled, each custom enchantment will add a description in item lore. - Enabled: true - # Description format for the item lore. - # Placeholders: - # - %description% - Enchantment description. - Format: '&8▸ %description%' - # Settings to obtain enchants via Enchanting Table. - Enchanting_Table: - # Enable/Disable this way to obtain custom enchantments. - Enabled: true - Enchantments: - # Max. amount of all (including vanilla) enchantments on the item, when no more enchantments will be added. - Total_Maximum: 4 - # Chance that a custom enchantment will be added. - Custom_Generation_Chance: 90.0 - # Min. amount of custom enchantments to be added. - Custom_Minimum: 0 - # Max. amount of custom enchantments to be added. - Custom_Maximum: 2 - # Settings to obtain enchantments via Villager Trades. - Villagers: - Enabled: true - Enchantments: - Total_Maximum: 4 - Custom_Generation_Chance: 70.0 - Custom_Minimum: 0 - Custom_Maximum: 2 - # Settings to obtain enchantments via Loot Chests in dungeons and other world's structures. - Loot_Generation: - Enabled: true - Enchantments: - Total_Maximum: 4 - Custom_Generation_Chance: 80.0 - Custom_Minimum: 0 - Custom_Maximum: 2 - # Settings to obtain enchantments via Fishing. - Fishing: - Enabled: true - Enchantments: - Total_Maximum: 4 - Custom_Generation_Chance: 70.0 - Custom_Minimum: 0 - Custom_Maximum: 2 - # Settings to generate enchantments on mob equipment on spawn. - Mob_Spawning: - Enabled: true - Enchantments: - Total_Maximum: 4 - Custom_Generation_Chance: 70.0 - Custom_Minimum: 0 - Custom_Maximum: 2 - -# Enchantment tiers. -# You can create as many tiers as you want. -Tiers: - # Tier identifier. Must be unique. - common: - # Tier display name. - Name: '&fCommon' - # Tier color. - Color: '&f' - # Tier obtain chances. - Obtain_Chance: - ENCHANTING: 80.0 - VILLAGER: 80.0 - LOOT_GENERATION: 80.0 - FISHING: 80.0 - MOB_SPAWNING: 80.0 - rare: - Name: '&aRare' - Color: '&a' - Obtain_Chance: - ENCHANTING: 50.0 - VILLAGER: 50.0 - LOOT_GENERATION: 50.0 - FISHING: 50.0 - MOB_SPAWNING: 50.0 - exotic: - Name: '&eExotic' - Color: '&e' - Obtain_Chance: - ENCHANTING: 25.0 - VILLAGER: 25.0 - LOOT_GENERATION: 25.0 - FISHING: 25.0 - MOB_SPAWNING: 25.0 - legendary: - Name: '&6Legendary' - Color: '&6' - Obtain_Chance: - ENCHANTING: 10.0 - VILLAGER: 10.0 - LOOT_GENERATION: 10.0 - FISHING: 10.0 - MOB_SPAWNING: 10.0 - cursed: - Name: '&cCursed' - Color: '&c' - Obtain_Chance: - ENCHANTING: 7.0 - VILLAGER: 5.0 - LOOT_GENERATION: 7.0 - FISHING: 12.0 - MOB_SPAWNING: 0.0 \ No newline at end of file + Command_Aliases: 'excellentenchants,eenchants' + Language: 'en' + Name: 'ExcellentEnchants' \ No newline at end of file diff --git a/Core/src/main/resources/enchants/aquaman.yml b/Core/src/main/resources/enchants/aquaman.yml index 70a4603..d98f1bb 100644 --- a/Core/src/main/resources/enchants/aquaman.yml +++ b/Core/src/main/resources/enchants/aquaman.yml @@ -1,106 +1,8 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Aquaman -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 - %enchantment_cost_item%. -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Grants permanent %enchantment_potion_type% %enchantment_potion_level% effect.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 1 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: '%enchantment_level% * 15.0' - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: true - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: PRISMARINE_SHARD - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. - Potion_Effect: - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '1' - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Duration: '25.0' + 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 index d474baa..9b73299 100644 --- a/Core/src/main/resources/enchants/bane_of_netherspawn.yml +++ b/Core/src/main/resources/enchants/bane_of_netherspawn.yml @@ -1,117 +1,12 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_damage%: Enchantment Damage - -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Bane of Netherspawn -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to inflict %enchantment_damage% more damage - to Nether mobs.' -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Inflicts %enchantment_damage% more damage to nether mobs.' Conflicts: - village_defender - sharpness - smite - bane_of_arthropods -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 6 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 80.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 80.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 80.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: SMOKE_NORMAL - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' - # Enchantment damage settings. - Damage: - # When 'true' damage 'Formula' will work as a multiplier to the original damage. - # When 'false' damage 'Formula' will be added to the original damage. - As_Modifier: false - # Damage formula. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Formula: 0.5 * %enchantment_level% + 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 index 0b19a97..6006b23 100644 --- a/Core/src/main/resources/enchants/blast_mining.yml +++ b/Core/src/main/resources/enchants/blast_mining.yml @@ -1,107 +1,12 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_explosion_power%: Enchantment Explosion Power - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Blast Mining -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: legendary -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to mine blocks by x%enchantment_explosion_power% - power explosion.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to mine blocks by explosion.' Conflicts: - tunnel - veinminer -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 5.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 6.0 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 20.0 * %enchantment_level% - # Minimal block strength value for the enchantment to be triggered. - # Block strength value is how long it takes to break the block by a hand. - # For example, a Stone has 3.0 strength. - Min_Block_Strength: 1.5 - %enchantment_level% / 10 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment explosion settings. - Explosion: - # Explosion power. The more power = the more blocks (area) to explode. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Power: 3.0 + (%enchantment_level% - 1.0 * 0.25) + 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 index 6194520..d7ceaee 100644 --- a/Core/src/main/resources/enchants/blindness.yml +++ b/Core/src/main/resources/enchants/blindness.yml @@ -1,115 +1,13 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Blindness -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% - for %enchantment_potion_duration%s. on hit.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 15.0 + %enchantment_level% * 3 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: 3.5 + %enchantment_level% - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '%enchantment_level%' - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: SMOKE_NORMAL - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' + 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 index d8c0383..44137da 100644 --- a/Core/src/main/resources/enchants/bomber.yml +++ b/Core/src/main/resources/enchants/bomber.yml @@ -1,21 +1,7 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_fuse_ticks%: Enchantment Fuse Ticks - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Bomber -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to launch TNT that explodes in %enchantment_fuse_ticks%s.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. Conflicts: - ender_bow - ghast @@ -28,82 +14,9 @@ Conflicts: - flame - power - punch -# Enchantment level settings. +- hover Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 5.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 4.0 * %enchantment_level% - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: TNT - Amount: 1 - # Fuse ticks value for the TNT launched. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Fuse_Ticks: 100 - %enchantment_level% * 10 + 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 index be7c056..c27acba 100644 --- a/Core/src/main/resources/enchants/bunny_hop.yml +++ b/Core/src/main/resources/enchants/bunny_hop.yml @@ -1,105 +1,8 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. -Name: Bunny Hop -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. -Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders +Name: 'Bunny Hop' +Tier: 'common' Description: -- Grants permanent %enchantment_potion_type% %enchantment_potion_level%. -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Grants permanent %enchantment_potion_type% %enchantment_potion_level% effect.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: RABBIT_FOOT - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. - Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Duration: '25.0' - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '%enchantment_level%' + 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 index 537b0ee..7955bb5 100644 --- a/Core/src/main/resources/enchants/cold_steel.yml +++ b/Core/src/main/resources/enchants/cold_steel.yml @@ -1,106 +1,13 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Cold Steel -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% - for %enchantment_potion_duration%s. to attacker.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on attacker.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 60.0 + %enchantment_level% * 5 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. + Trigger_Chance: '60.0 + %enchantment_level% * 5' Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Duration: 4.0 + %enchantment_level% - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + 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 index 59fd0c8..1d6d724 100644 --- a/Core/src/main/resources/enchants/confusing_arrows.yml +++ b/Core/src/main/resources/enchants/confusing_arrows.yml @@ -1,106 +1,22 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Confusing Arrows -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% - %enchantment_potion_level% (%enchantment_potion_duration%s.)' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. -Conflicts: [] -# Enchantment level settings. +- '%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: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 45.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 75.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 35.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 20.0 + %enchantment_level% * 5.0 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: 6.0 + %enchantment_level% * 3.0 - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/confusion.yml b/Core/src/main/resources/enchants/confusion.yml index 61a5bbb..d3525b7 100644 --- a/Core/src/main/resources/enchants/confusion.yml +++ b/Core/src/main/resources/enchants/confusion.yml @@ -1,115 +1,13 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Confusion -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% - for %enchantment_potion_duration%s. on hit.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 15.0 * %enchantment_level% - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: 5.0 + %enchantment_level% * 1.5 - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '%enchantment_level%' - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: ITEM_CRACK - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: ROTTEN_FLESH + 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 index eaa23f3..3e24590 100644 --- a/Core/src/main/resources/enchants/cure.yml +++ b/Core/src/main/resources/enchants/cure.yml @@ -1,106 +1,10 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Cure -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to cure Zombified Piglins and Zombie Villagers.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to cure Zombified Piglins and Zombie Villagers on hit.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 5 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 75.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 20.0 + %enchantment_level% * 8 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: CLOUD - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' - # Sound that will be played on enchantment trigger. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html - Sound: '' + 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 index 771089d..f6fb9f8 100644 --- a/Core/src/main/resources/enchants/curse_of_breaking.yml +++ b/Core/src/main/resources/enchants/curse_of_breaking.yml @@ -1,100 +1,12 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_durability_amount%: Enchantment Durability Amount - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: true -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Curse of Breaking -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: cursed -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance the item will consume extra %enchantment_durability_amount% - durability points.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to consume extra %enchantment_durability_amount% durability points.' Conflicts: -- durability -# Enchantment level settings. +- unbreaking Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 15.0 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 10.0 * %enchantment_level% - # Amount of durability points to be taken from the item. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Durability_Amount: '%enchantment_level%' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 + 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 new file mode 100644 index 0000000..50e2c21 --- /dev/null +++ b/Core/src/main/resources/enchants/curse_of_fragility.yml @@ -0,0 +1,7 @@ +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 index d49d769..a9f00a6 100644 --- a/Core/src/main/resources/enchants/curse_of_misfortune.yml +++ b/Core/src/main/resources/enchants/curse_of_misfortune.yml @@ -1,98 +1,12 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: true -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Curse of Misfortune -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: cursed -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to have no drops from blocks or mobs.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. Conflicts: - fortune - looting -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 1 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 15.0 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 20.0 * %enchantment_level% - # When 'false', it will also prevent exp drop from the blocks. - Drop_Exp: false - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 + 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 index c9e780c..086afad 100644 --- a/Core/src/main/resources/enchants/cutter.yml +++ b/Core/src/main/resources/enchants/cutter.yml @@ -1,103 +1,10 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_durability_damage%: Enchantment Durability Damage - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Cutter -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to throw away enemy''s armor and damage it - for %enchantment_durability_damage%%.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to throw away enemy''s armor and damage it for %enchantment_durability_damage%%.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 6 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 5.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 1.0 + %enchantment_level% * 0.6 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - Item: - # Amount (in percent) of how much item durability will be reduced. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Durability_Reduction: '%enchantment_level% / 100.0' - # A sound to play when item durability is reduced. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html - Sound: ENTITY_ITEM_BREAK + 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 index 8b03d35..503bd0c 100644 --- a/Core/src/main/resources/enchants/decapitator.yml +++ b/Core/src/main/resources/enchants/decapitator.yml @@ -1,121 +1,20 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Decapitator -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to obtain player''s or mob''s head.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 4 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 7 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 15.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 5.0 + %enchantment_level% * 1.75 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: BLOCK_CRACK - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: REDSTONE_BLOCK - # List of entity types that will not drop the heads. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html Ignored_Entity_Types: - BAT - BEE - ENDER_DRAGON - WITHER_SKELETON - WITHER - # Settings for the head item. Head_Item: - # Item display name. Use '%entity%' for entity name. - Name: '&cHead of &e%entity%' - # 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 Textures: AXOLOTL: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNThkYTFhMGEyYTEzZGQyMDliZmMyNTI5ZDljN2MyOWEyOWRkOWEyM2ZmNGI4MGIzOGI4OTk2MTc3MmU4MDM5ZSJ9fX0= BAT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWU5OWRlZWY5MTlkYjY2YWMyYmQyOGQ2MzAyNzU2Y2NkNTdjN2Y4YjEyYjlkY2E4ZjQxYzNlMGEwNGFjMWNjIn19fQ== diff --git a/Core/src/main/resources/enchants/divine_touch.yml b/Core/src/main/resources/enchants/divine_touch.yml index d21ac5b..fdb7458 100644 --- a/Core/src/main/resources/enchants/divine_touch.yml +++ b/Core/src/main/resources/enchants/divine_touch.yml @@ -1,108 +1,11 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Divine Touch -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: legendary -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to obtain &fMob Spawner&8.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to mine spawner.' Conflicts: - smelter -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 5.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 6.0 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 5.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 5.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 8.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 15.0 * %enchantment_level% - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: VILLAGER_HAPPY - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' - # Spawner item settings. - Spawner_Item: - # Spawner display name. Use '%type%' for entity type name. - Name: '&aMob Spawner &7(%type%)' + 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 index 82ae202..d47a0d6 100644 --- a/Core/src/main/resources/enchants/double_strike.yml +++ b/Core/src/main/resources/enchants/double_strike.yml @@ -1,106 +1,10 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Double Strike -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: legendary -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to inflict double damage.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 4 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 7 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 15.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 4.0 + %enchantment_level% * 0.8 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: EXPLOSION_NORMAL - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' - # Sound that will be played on enchantment trigger. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html - Sound: ENTITY_GENERIC_EXPLODE + 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 index 19aa968..f7563c7 100644 --- a/Core/src/main/resources/enchants/dragonfire_arrows.yml +++ b/Core/src/main/resources/enchants/dragonfire_arrows.yml @@ -1,121 +1,23 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_fire_radius%: Enchantment Fire Radius -# - %enchantment_fire_duration%: Enchantment Fire Duration - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Dragonfire Arrows -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to launch an dragonfire arrow (R=%enchantment_fire_radius%, - %enchantment_fire_duration%s).' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%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 -# Enchantment level settings. +- bomber +- ender_bow +- hover +- ghast Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 5.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 10.0 + %enchantment_level% * 5 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment dragonfire settings. - Fire: - # Dragonfire area cloud effect duration. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Duration: '%enchantment_level% * 100.0' - # Dragonfire area cloud effect radius. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Radius: 2.0 + %enchantment_level% - # Enchantment arrow settings. Arrow: - # A particle effect to play as an arrow trail. - Trail: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Trail_Effect: Name: DRAGON_BREATH - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/electrified_arrows.yml b/Core/src/main/resources/enchants/electrified_arrows.yml index 60f440b..6ae4b30 100644 --- a/Core/src/main/resources/enchants/electrified_arrows.yml +++ b/Core/src/main/resources/enchants/electrified_arrows.yml @@ -1,110 +1,23 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Electrified Arrows -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to launch an electrified arrow.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. Conflicts: - confusing_arrows - poisoned_arrows - explosive_arrows - withered_arrows - dragonfire_arrows -# Enchantment level settings. +- bomber +- ender_bow +- ghast +- hover Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 75.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 45.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 10.0 + %enchantment_level% * 5 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment arrow settings. Arrow: - # A particle effect to play as an arrow trail. - Trail: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Trail_Effect: Name: FIREWORKS_SPARK - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/elemental_protection.yml b/Core/src/main/resources/enchants/elemental_protection.yml index df6078c..81688a4 100644 --- a/Core/src/main/resources/enchants/elemental_protection.yml +++ b/Core/src/main/resources/enchants/elemental_protection.yml @@ -1,108 +1,8 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance value. -# - %enchantment_protection_amount%: Enchantment Protection Amount value. -# - %enchantment_protection_capacity%: Enchantment Protection Capacity value. - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Elemental Protection -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to reduce Poison, Magic, Wither, Lightning, - Freeze damage by %enchantment_protection_amount%.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Reduces Poison, Magic, Wither, Lightning, Freeze damage by %enchantment_protection_amount%.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 6 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 35.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 - -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. - Protection: - # How much incoming damage should be reduced by this enchantment? - # [SCALABLE] - Amount: '%enchantment_level% * 0.1' - # When 'true', 'Protection.Amount' option will be a percent value on which damage will be multiplied. - # When 'false', 'Protection.Amount' option will be a plain number on which damage will be reduced. - As_Modifier: false - # Maximal possible value for the Protection Amount option that sums up from all entity armor items. - Capacity: 1.0 + 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 index 7b77210..dbc4ec1 100644 --- a/Core/src/main/resources/enchants/ender_bow.yml +++ b/Core/src/main/resources/enchants/ender_bow.yml @@ -1,20 +1,7 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Ender Bow -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: legendary -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to shoot Ender Pearl instead of arrows.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Shoots ender pearls instead of arrows.' Conflicts: - bomber - ghast @@ -27,79 +14,7 @@ Conflicts: - flame - power - punch -# Enchantment level settings. +- hover Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 1 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 5.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: '30' - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 5.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 3.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: ENDER_PEARL - Amount: 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 index 4d46493..9a6a3b4 100644 --- a/Core/src/main/resources/enchants/exhaust.yml +++ b/Core/src/main/resources/enchants/exhaust.yml @@ -1,115 +1,13 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Exhaust -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% - for %enchantment_potion_duration%s. on hit.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 20.0 * %enchantment_level% - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: 3.0 + %enchantment_level% * 1.5 - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: '' - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' diff --git a/Core/src/main/resources/enchants/exp_hunter.yml b/Core/src/main/resources/enchants/exp_hunter.yml index 25dc7a4..373ef01 100644 --- a/Core/src/main/resources/enchants/exp_hunter.yml +++ b/Core/src/main/resources/enchants/exp_hunter.yml @@ -1,99 +1,10 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_exp_modifier%: Enchantment Exp Modifier - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Exp Hunter -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to obtain +%enchantment_exp_modifier%% more - exp from mobs.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Increases exp drop from mobs by %enchantment_exp_modifier%%.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 45.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 6 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 45.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 45.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 45.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 50.0 + %enchantment_level% * 5 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Exp modifier value. The original exp amount will be multiplied on this value. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Exp_Modifier: 1.0 + %enchantment_level% * 0.5 + 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 index 5302dab..bab2c79 100644 --- a/Core/src/main/resources/enchants/explosive_arrows.yml +++ b/Core/src/main/resources/enchants/explosive_arrows.yml @@ -1,123 +1,23 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_explosion_power%: Enchantment Explosion Power - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Explosive Arrows -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to launch an explosive arrow with x%enchantment_explosion_power% - power.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to launch an explosive arrow.' Conflicts: - confusing_arrows - poisoned_arrows - dragonfire_arrows - withered_arrows - electrified_arrows -# Enchantment level settings. +- bomber +- ender_bow +- ghast +- hover Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 10.0 + %enchantment_level% * 5 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment explosion settings. - Explosion: - # When 'true' an explosion will create fire on nearby blocks. - Fire_Spread: true - # When 'true' an explosion will destroy all nearby items on the ground. - Damage_Items: true - # When 'true' an explosion will destroy blocks. - Damage_Blocks: false - # Explosion size. The more size = the more damage and explosion area. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Size: 2.0 + %enchantment_level% - # Enchantment arrow settings. Arrow: - # A particle effect to play as an arrow trail. - Trail: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html + Trail_Effect: Name: SMOKE_NORMAL - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) Data: '' diff --git a/Core/src/main/resources/enchants/fire_shield.yml b/Core/src/main/resources/enchants/fire_shield.yml index f3e43bf..ecbea83 100644 --- a/Core/src/main/resources/enchants/fire_shield.yml +++ b/Core/src/main/resources/enchants/fire_shield.yml @@ -1,101 +1,10 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_fire_duration%: Enchantment Fire Duration - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Fire Shield -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to ignite the attacker for %enchantment_fire_duration%s.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # [SCALABLE] Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # [SCALABLE] Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 - -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # [SCALABLE] Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '%enchantment_level% * 10.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. - Fire: - # Fire effect duration (in seconds). - # [SCALABLE] Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Duration: 2.5 + %enchantment_level% + 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 index ce0564c..e3bc6db 100644 --- a/Core/src/main/resources/enchants/flame_walker.yml +++ b/Core/src/main/resources/enchants/flame_walker.yml @@ -1,98 +1,9 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. -Name: Flame Walker -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. -Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders +Name: 'Flame Walker' +Tier: 'exotic' Description: -- Ability to walk on lava and on magma blocks without getting damage. -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Ability to walk on lava and magma blocks without getting damage.' Conflicts: -- frost_walker -# Enchantment level settings. +- 'frost_walker' Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # How soon (in seconds) blocks created by the enchantment will be destroyed back to lava? - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Block_Decay: 5.0 + %enchantment_level% * 2 + 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 index 61fca9b..2972307 100644 --- a/Core/src/main/resources/enchants/ghast.yml +++ b/Core/src/main/resources/enchants/ghast.yml @@ -1,20 +1,7 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Ghast -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to launch a fireball instead of arrow.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Shoots fireballs instead of arrows.' Conflicts: - ender_bow - bomber @@ -26,84 +13,8 @@ Conflicts: - confusing_arrows - flame - punch -# Enchantment level settings. +- hover +- power Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # When 'true' a fireball explosion will ignite nearby blocks. - Fire_Spread: true - # Fireball explosion size/radius. The more value = the bigger the explosion. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Yield: 1.0 * %enchantment_level% - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 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 index 2243310..74062a0 100644 --- a/Core/src/main/resources/enchants/hardened.yml +++ b/Core/src/main/resources/enchants/hardened.yml @@ -1,106 +1,12 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. -Name: Hardened -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. -Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders +Name: 'Hardened' +Tier: 'rare' Description: -- '%enchantment_trigger_chance%% chance to obtain %enchantment_potion_type% %enchantment_potion_level% - for %enchantment_potion_duration%s. when damaged.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to obtain %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) when damaged.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 10.0 + %enchantment_level% * 5 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Duration: 2.5 + %enchantment_level% - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + 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 index 06c4243..06bca78 100644 --- a/Core/src/main/resources/enchants/haste.yml +++ b/Core/src/main/resources/enchants/haste.yml @@ -1,105 +1,8 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Haste -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- Grants %enchantment_potion_type% %enchantment_potion_level% effect. -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Grants permanent %enchantment_potion_type% %enchantment_potion_level% effect.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: SUGAR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. - Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Duration: '25.0' - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '%enchantment_level%' + 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 index 67373bf..ed4f404 100644 --- a/Core/src/main/resources/enchants/hover.yml +++ b/Core/src/main/resources/enchants/hover.yml @@ -1,106 +1,22 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Hover -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% - %enchantment_potion_level% (%enchantment_potion_duration%s.)' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. -Conflicts: [] -# Enchantment level settings. +- '%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: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 10.0 + %enchantment_level% * 5 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: 2.5 + %enchantment_level% - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/ice_aspect.yml b/Core/src/main/resources/enchants/ice_aspect.yml index 33e6797..2345e8d 100644 --- a/Core/src/main/resources/enchants/ice_aspect.yml +++ b/Core/src/main/resources/enchants/ice_aspect.yml @@ -1,115 +1,12 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Ice Aspect -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to freeze and apply %enchantment_potion_type% - %enchantment_potion_level% for %enchantment_potion_duration%s. on hit.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Freezes and applies %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 25.0 * %enchantment_level% - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: 3.0 + %enchantment_level% - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '%enchantment_level%' - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: BLOCK_CRACK - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: ICE + 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 new file mode 100644 index 0000000..6ca6f88 --- /dev/null +++ b/Core/src/main/resources/enchants/ice_shield.yml @@ -0,0 +1,13 @@ +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 index 577c395..d9a02e0 100644 --- a/Core/src/main/resources/enchants/infernus.yml +++ b/Core/src/main/resources/enchants/infernus.yml @@ -1,99 +1,10 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_fire_duration%: Enchantment Fire Duration - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Infernus -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to launch flaming Trident that ignites the - enemy for %enchantment_fire_duration%s.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Launched trident will ignite the enemy for %enchantment_fire_duration%s. on hit.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 45.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 35.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 45.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 45.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # How long (in ticks, 20 ticks = 1 second) the damaged entity will be ignited for? - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats 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 index b925cba..578f0f3 100644 --- a/Core/src/main/resources/enchants/lucky_miner.yml +++ b/Core/src/main/resources/enchants/lucky_miner.yml @@ -1,99 +1,10 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_exp_modifier%: Enchantment Exp Modifier - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Lucky Miner -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to obtain +%enchantment_exp_modifier%% more - exp from ores.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to gain %enchantment_exp_modifier%% more exp from ores.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 6 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 30.0 + %enchantment_level% * 7.0 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Exp modifier value. The original exp amount will be multiplied on this value. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Exp_Modifier: 1.0 + %enchantment_level% * 0.5 + 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 index 2e6aaf8..dde8448 100644 --- a/Core/src/main/resources/enchants/night_vision.yml +++ b/Core/src/main/resources/enchants/night_vision.yml @@ -1,106 +1,7 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Night Vision -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- Grants %enchantment_potion_type% %enchantment_potion_level% effect that costs x1 - %enchantment_cost_item%. -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. -Conflicts: [] -# Enchantment level settings. +- 'Grants permanent %enchantment_potion_type% %enchantment_potion_level% effect.' Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 1 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: '15' - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: true - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: GLOWSTONE_DUST - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. - Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Duration: '60.0' - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '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 index 61a7426..47a8a82 100644 --- a/Core/src/main/resources/enchants/nimble.yml +++ b/Core/src/main/resources/enchants/nimble.yml @@ -1,94 +1,7 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Nimble -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Moves all mob's loot directly to your inventory. -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 1 -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. -Conflicts: [] -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 15 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 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 index 3e57935..6413305 100644 --- a/Core/src/main/resources/enchants/paralyze.yml +++ b/Core/src/main/resources/enchants/paralyze.yml @@ -1,115 +1,13 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Paralyze -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% - for %enchantment_potion_duration%s. on hit.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 10.0 * %enchantment_level% - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: 2.5 + %enchantment_level% * 0.5 - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '%enchantment_level%' - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: CRIT_MAGIC - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' + 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 index bd8174c..37d2f6f 100644 --- a/Core/src/main/resources/enchants/poisoned_arrows.yml +++ b/Core/src/main/resources/enchants/poisoned_arrows.yml @@ -1,111 +1,22 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Poisoned Arrows -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% - %enchantment_potion_level% (%enchantment_potion_duration%s.)' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%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 -# Enchantment level settings. +- bomber +- ghast +- ender_bow +- hover Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 25.0 + %enchantment_level% * 5 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Duration: 2.0 + %enchantment_level% - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats + 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 index a458954..cfee35e 100644 --- a/Core/src/main/resources/enchants/rage.yml +++ b/Core/src/main/resources/enchants/rage.yml @@ -1,115 +1,13 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Rage -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to get %enchantment_potion_type% %enchantment_potion_level% - effect for %enchantment_potion_duration%s. on hit.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to get %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 15.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 7.0 + %enchantment_level% - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: 3.0 + %enchantment_level% * 0.5 - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '%enchantment_level%' - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: LAVA - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' + 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 index 59ec656..0c3308b 100644 --- a/Core/src/main/resources/enchants/regrowth.yml +++ b/Core/src/main/resources/enchants/regrowth.yml @@ -1,113 +1,10 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_health_amount%: Enchantment Health Amount -# - %enchantment_health_interval%: Enchantment Health Interval - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Regrowth -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- Restores %enchantment_health_amount% hearts every %enchantment_health_interval%s. - with %enchantment_trigger_chance%% chance. -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- Restores %enchantment_heal_amount% hearts every %enchantment_heal_interval%s. Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 15.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 6 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 15.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 15.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 20.0 + %enchantment_level% * 5 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: HEART - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' - # Enchantment health restore settings. - Health: - # How many hearts will be restored on enchantment trigger? - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Amount: '%enchantment_level% * 0.25' - # How often (in ticks, 20 ticks = 1 second) enchantment will be triggered? - Interval: 100 + 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 index 3dbce43..f2f6860 100644 --- a/Core/src/main/resources/enchants/replanter.yml +++ b/Core/src/main/resources/enchants/replanter.yml @@ -1,100 +1,7 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Replanter -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- Automatically replant crops on right click and harvest. -# Enchantment level settings. +- Automatically replant crops on right click and when harvest. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 1 -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. -Conflicts: [] -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: '15' - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment replant settings. - Replant: - # When 'true', player will be able to replant crops when right-clicking the farmlang. - On_Right_Click: true - # When 'true', crops will be automatically replanted when player breaks the plant with enchanted tool in hand. - On_Plant_Break: true + 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 index d198c7e..b6927d4 100644 --- a/Core/src/main/resources/enchants/rocket.yml +++ b/Core/src/main/resources/enchants/rocket.yml @@ -1,97 +1,10 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Rocket -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to launch your enemy into the space.' -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. -Conflicts: [] -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 4.0 + %enchantment_level% - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Firework power. The more power = the higher the fly distance. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Firework_Power: '%enchantment_level%' diff --git a/Core/src/main/resources/enchants/saturation.yml b/Core/src/main/resources/enchants/saturation.yml index 47ba5f7..d509d1f 100644 --- a/Core/src/main/resources/enchants/saturation.yml +++ b/Core/src/main/resources/enchants/saturation.yml @@ -1,104 +1,8 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_saturation_amount%: Enchantment Saturation Amount -# - %enchantment_saturation_interval%: Enchantment Saturation Interval - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Saturation -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Restores %enchantment_saturation_amount% food points every %enchantment_saturation_interval%s. - with %enchantment_trigger_chance%% chance. -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 25.0 + %enchantment_level% * 5 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment saturation settings. - Saturation: - # How much of food points will be restored on enchantment trigger? - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Amount: '%enchantment_level%' - # How often (in ticks, 20 ticks = 1 second) this enchantment will be triggered? - Interval: 150 + 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 index 67420fa..504c30b 100644 --- a/Core/src/main/resources/enchants/scavenger.yml +++ b/Core/src/main/resources/enchants/scavenger.yml @@ -1,98 +1,12 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Scavenger -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to obtain additional loot from mobs.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. -Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 4 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 7 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 15.0 + %enchantment_level% * 10 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment treasures table. Treasures: # Entity type to have an additional drop from. # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html @@ -100,9 +14,7 @@ Settings: # Material name for the item to drop. # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html EMERALD: - # Item amount. Syntax: 'Min:Max'. Amount: '1:1' - # Item drop chance. Chance: 5.0 SKELETON: BONE_MEAL: diff --git a/Core/src/main/resources/enchants/self_destruction.yml b/Core/src/main/resources/enchants/self_destruction.yml index 693a5d5..b7f4e7e 100644 --- a/Core/src/main/resources/enchants/self_destruction.yml +++ b/Core/src/main/resources/enchants/self_destruction.yml @@ -1,101 +1,11 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_explosion_power%: Enchantment Explosion Power - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Self-Destruction -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to create an x%enchantment_explosion_power% - power explosion on death.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. -Conflicts: [] -# Enchantment level settings. +- '%enchantment_trigger_chance%% chance to create an explosion on death.' Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 15.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 20.0 + %enchantment_level% * 10 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment explosion settings. Explosion: - # Explosion size. The more size = the bigger the explosion. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats 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 index ed9737d..78b988a 100644 --- a/Core/src/main/resources/enchants/silk_chest.yml +++ b/Core/src/main/resources/enchants/silk_chest.yml @@ -1,101 +1,8 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Silk Chest -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Drop chests and saves all its content. -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 1 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: '30' - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Chest item settings. - Chest_Item: - # Item display name. - # Placeholders: - # - %name% - Item material name. - # - %items% - Amount of items in chest. - Name: '&f%name% &7(%items% items)' + 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 index 8a0c59a..e5c8f55 100644 --- a/Core/src/main/resources/enchants/smelter.yml +++ b/Core/src/main/resources/enchants/smelter.yml @@ -1,117 +1,17 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Smelter -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to smelt ore or a block on mining.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. -Conflicts: [] -# Enchantment level settings. +- '%enchantment_trigger_chance%% chance to smelt a block/ore.' +Conflicts: + - silk_touch + - divine_touch Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 5 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 25.0 + %enchantment_level% * 10 - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: FLAME - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Smelting table. - # 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 Smelting_Table: IRON_ORE: IRON_INGOT - RAW_IRON: IRON_INGOT GOLD_ORE: GOLD_INGOT - RAW_GOLD: GOLD_INGOT - RAW_COPPER: COPPER_INGOT - SAND: GLASS - # Sound that will be played on enchantment trigger. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html - Sound: BLOCK_LAVA_EXTINGUISH + 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 index 72d0516..5804a3e 100644 --- a/Core/src/main/resources/enchants/sonic.yml +++ b/Core/src/main/resources/enchants/sonic.yml @@ -1,105 +1,8 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Sonic -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- Grants %enchantment_potion_type% %enchantment_potion_level% effect. -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- Grants permanent %enchantment_potion_type% %enchantment_potion_level% effect. Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: FEATHER - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. - Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Duration: '25.0' - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '%enchantment_level%' + 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 index b4a7975..d0298fa 100644 --- a/Core/src/main/resources/enchants/surprise.yml +++ b/Core/src/main/resources/enchants/surprise.yml @@ -1,115 +1,12 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Surprise -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to apply random potion effect to enemy on - hit.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. -Conflicts: [] -# Enchantment level settings. +- '%enchantment_trigger_chance%% chance to apply random potion effect to enemy on hit.' Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 2.25 * %enchantment_level% - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: 3.0 + %enchantment_level% - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '%enchantment_level%' - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: SPELL_WITCH - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' + 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 index c4e344a..18687d3 100644 --- a/Core/src/main/resources/enchants/telekinesis.yml +++ b/Core/src/main/resources/enchants/telekinesis.yml @@ -1,99 +1,8 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Telekinesis -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Moves all blocks loot directly to your inventory. -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Message to display for a player with a list of received items. - Message: - Drop_Received: '{message: ~type: ACTION_BAR; ~prefix: false;}%items%' - Item_Name: '&7x%item_amount% &f%item_name%' - Item_Separator: '&7, ' + 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 index 99dad3d..72766a9 100644 --- a/Core/src/main/resources/enchants/temper.yml +++ b/Core/src/main/resources/enchants/temper.yml @@ -1,112 +1,8 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_damage_amount%: Enchantment Damage Amount -# - %enchantment_damage_capacity%: Enchantment Damage Capacity -# - %enchantment_health_point%: Enchantment Health Point - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Temper -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to inflict %enchantment_damage_amount%% (max. - %enchantment_damage_capacity%%) more damage for each %enchantment_health_point% - hearts missing.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Inflicts %enchantment_damage_amount%% (max. %enchantment_damage_capacity%%) more damage for each %enchantment_health_point% hearts missing.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 6 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 15.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment damage settings. - Damage: - # On how much (in percent) the damage will be increased per each Health Point? - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Amount: 0.01 * %enchantment_level% - # The maximal possible value for the Damage Amount. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Capacity: '2.0' - # Enchantment health settings. - Health: - # For how much missing hearts the damage will be increased? - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Point: '0.5' + 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 index e9c9070..6f26018 100644 --- a/Core/src/main/resources/enchants/thrifty.yml +++ b/Core/src/main/resources/enchants/thrifty.yml @@ -1,105 +1,10 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Thrifty -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to obtain mob Spawn Egg on kill.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to obtain mob spawn egg on kill.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 15.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 15.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 10.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 5.0 + %enchantment_level% * 3 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # List of entity types, that will not drop spawn eggs. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html - Ignored_Entity_Types: - - WITHER - - ENDER_DRAGON - # List of spawn reasons, from which entities will not drop spawn eggs. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/CreatureSpawnEvent.SpawnReason.html - Ignored_Spawn_Reasons: - - SPAWNER - - SPAWNER_EGG - - DISPENSE_EGG + 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 index 10bdad0..fee3d31 100644 --- a/Core/src/main/resources/enchants/thunder.yml +++ b/Core/src/main/resources/enchants/thunder.yml @@ -1,96 +1,9 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Thunder -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to summon lightning to enemy on hit.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. -Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 10.0 * %enchantment_level% - # When 'true' the enchantment will be triggered only if there is an active thunderstorm in the world. - During_Thunderstorm_Only: false - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 + 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 index 76cf0a2..2a9490c 100644 --- a/Core/src/main/resources/enchants/treasures.yml +++ b/Core/src/main/resources/enchants/treasures.yml @@ -1,144 +1,33 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Treasures -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - '%enchantment_trigger_chance%% chance to attempt to find a treasure in mined block.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. -Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 6 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 75.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 75.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 10.0 + %enchantment_level% * 4.0 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: REDSTONE - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: 200,180,0 - # Sound that will be played on enchantment trigger. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html - Sound: BLOCK_NOTE_BLOCK_BELL - # Enchantment treasures table. Treasures: - # List of source materials (blocks that will drop additional loot). Separated by a comma. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html STONE,GRANITE,ANDESITE,DIORITE: - # List of Materials and chances for the additional loot. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - AIR: 95.0 BONE_MEAL: 2.0 CLAY: - AIR: 95.0 SLIME_BALL: 7.0 DIRT,PODZOL,COARSE_DIRT,ROOTED_DIRT: - AIR: 95.0 CLAY_BALL: 0.5 BOWL: 1.0 STICK: 2.0 SAND,RED_SAND: - AIR: 95.0 GLOWSTONE_DUST: 1.0 GOLD_NUGGET: 0.3 SOUL_SAND: - AIR: 95.0 FLINT: 1.5 GUNPOWDER: 0.8 COAL: 0.4 NETHERRACK: - AIR: 99.0 BRICK: 0.05 END_STONE: - AIR: 99.0 ENDER_PEARL: 0.1 OAK_LEAVES,BIRCH_LEAVES,SPRUCE_LEAVES,ACACIA_LEAVES,JUNGLE_LEAVES,DARK_OAK_LEAVES: - AIR: 80.0 APPLE: 15.0 MOSSY_COBBLESTONE,MOSSY_STONE_BRICKS: - AIR: 50.0 VINE: 50.0 diff --git a/Core/src/main/resources/enchants/tunnel.yml b/Core/src/main/resources/enchants/tunnel.yml index 2ca0e53..5ef298c 100644 --- a/Core/src/main/resources/enchants/tunnel.yml +++ b/Core/src/main/resources/enchants/tunnel.yml @@ -1,98 +1,10 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Tunnel -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: legendary -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- Allows you to mine multiple blocks at once in a shape. -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- Mines multiple blocks at once in a certain shape. Conflicts: - veinminer - blast_mining -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # When 'true' the enchantment won't be triggered when sneaking. - Ignore_When_Sneaking: true + 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 index a8e2ead..ca12389 100644 --- a/Core/src/main/resources/enchants/vampire.yml +++ b/Core/src/main/resources/enchants/vampire.yml @@ -1,112 +1,10 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_heal_amount%: Enchantment Heal Amount - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Vampire -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: exotic -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to heal yourself for %enchantment_heal_amount% - heart(s) on hit.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to heal for %enchantment_heal_amount% heart(s) on hit.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 4 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 7 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: 10.0 + %enchantment_level% * 5.0 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: HEART - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' - # Enchantment heal settings. - Heal: - # On how much hearts the damager will be healed? - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Amount: 0.35 * %enchantment_level% - # When 'true', the option above will work as a multiplier of the inflicted damage. - As_Multiplier: false + 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 index 409f17d..794eb65 100644 --- a/Core/src/main/resources/enchants/veinminer.yml +++ b/Core/src/main/resources/enchants/veinminer.yml @@ -1,107 +1,16 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_block_limit%: Enchantment Block Limit - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Veinminer -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: - Mines up to %enchantment_block_limit% blocks of the ore vein at once. -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. Conflicts: - blast_mining - tunnel -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 10 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 40.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment blocks settings. Blocks: - # How much amount of blocks can be destroted at single use? - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Max_At_Once: 6 + %enchantment_level% - # List of blocks, that will be affected by this enchantment. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html Affected: - COAL_ORE - GOLD_ORE diff --git a/Core/src/main/resources/enchants/venom.yml b/Core/src/main/resources/enchants/venom.yml index 5346855..fb8d652 100644 --- a/Core/src/main/resources/enchants/venom.yml +++ b/Core/src/main/resources/enchants/venom.yml @@ -1,115 +1,13 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Venom -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% - for %enchantment_potion_duration%s. on hit.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 50.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 30.0 + %enchantment_level% * 10.0 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: 2.0 + %enchantment_level% - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '%enchantment_level%' - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: SLIME - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' + 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 index e9b242a..ee7e62a 100644 --- a/Core/src/main/resources/enchants/village_defender.yml +++ b/Core/src/main/resources/enchants/village_defender.yml @@ -1,116 +1,12 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_damage_amount%: Enchantment Damage Amount - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Village Defender -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: common -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to inflict %enchantment_damage_amount% more - damage on Pillagers.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- 'Inflicts %enchantment_damage_amount% more damage to all pillagers.' Conflicts: - bane_of_netherspawn - sharpness - smite - bane_of_arthropods -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. - Max: 5 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 60.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 6 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 80.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 80.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 70.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 0.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. -Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Trigger_Chance: '100.0' - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: VILLAGER_ANGRY - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' - # Enchantment damage settings. - Damage: - # When 'true' the 'Damage.Formula' will work as a multiplier to the original damage. - As_Modifier: false - # On how much the damage will be increased? - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Formula: 0.5 * %enchantment_level% + 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 index 3576edf..49a3b59 100644 --- a/Core/src/main/resources/enchants/wither.yml +++ b/Core/src/main/resources/enchants/wither.yml @@ -1,115 +1,13 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Wither -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% - for %enchantment_potion_duration%s. on hit.' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%enchantment_trigger_chance%% chance to apply %enchantment_potion_type% %enchantment_potion_level% (%enchantment_potion_duration%s.) on hit.' Conflicts: [] -# Enchantment level settings. Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 20.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 30.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 15.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 10.0 + %enchantment_level% * 5 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: 3.0 + %enchantment_level% - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level: '%enchantment_level%' - # Particle effect that will be played on enchantment trigger. - Particle: - # Particle name. Set this to empty '' or 'NONE' to disable. - # https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html - Name: '' - # Particle data (additional settings). - # - BLOCK_DUST, BLOCK_MARKER, BLOCK_CRACK, ITEM_CRACK, FALLING_DUST: Use https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html - # - REDSTONE: Use RGB (like 255,255,255) - Data: '' + 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 index 157959d..403db5e 100644 --- a/Core/src/main/resources/enchants/withered_arrows.yml +++ b/Core/src/main/resources/enchants/withered_arrows.yml @@ -1,111 +1,22 @@ -# Additional placeholders: -# - %enchantment_trigger_chance%: Enchantment Trigger Chance -# - %enchantment_potion_level%: Enchantment Potion Level -# - %enchantment_potion_duration%: Enchantment Potion Duration -# - %enchantment_potion_type%: Enchantment Potion Type - -# Defines if this enchantment is a treasure enchantment. -# Treasure enchantments can only be received via looting, trading, or fishing. -Is_Treasure: false -# Enchantment display name. This name will be displayed in item lore and in enchantments list GUI. Name: Withered Arrows -# Enchantment tier. Must be a valid tier from the 'config.yml'. Enchantments with invalid tier won't be loaded. Tier: rare -# Enchantment description. Will be displayed in item lore (if not disabled in the main config.yml) and in enchantments list GUI. -# You can use multiple lines here. -# You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders Description: -- '%enchantment_trigger_chance%% chance to launch an arrow with %enchantment_potion_type% - %enchantment_potion_level% (%enchantment_potion_duration%s.)' -# List of the conflicting enchantments. -# Conflicted enchantments can not be applied together on the same item. +- '%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 -# Enchantment level settings. +- bomber +- ender_bow +- ghast +- hover Level: - # Minimal (start) enchantment level. Can not be smaller then 1. Min: 1 - # Maximal (final) enchantment level. - # Keep in mind that while you can enchant items with bypass max. enchantment level, all enchantment 'Scalable' option values will not exceed the max. enchantment level. Max: 3 -# Enchantment settings for Anvil. -Anvil: - # Defines the exp cost to merge this enchantment on other items on anvil. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Merge_Cost: '%enchantment_level%' -Fishing: - # A chance that this enchantment will be populated on items received from fishing. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Fishing - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Enchantment settings for Enchanting Table. -Enchanting_Table: - # Defines which enchantment level will be generated in Enchanting Table depends on the enchanting cost. - # Example: expression '9 * %enchantment_level%' for enchantment levels 1-3 will result in I = 9+ Levels, II = 18+ Levels, III = 27+ Levels. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats - Level_By_Exp_Cost: 9 * %enchantment_level% - # A chance that this enchantment will be appeared in Enchanting Table. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Enchanting Table - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Villagers: - # A chance that this enchantment will be populated on items in Villager trades. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Villagers - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Loot_Generation: - # A chance that this enchantment will be populated on items in cave/dungeon/castle chests/minecarts and other containers. - Chance: 25.0 - # Here you can set min. and max. level for enchantment generated via Loot Generation - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -Mob_Spawning: - # A chance that this enchantment will be populated on items equipped on mob on spawning. - Chance: 15.0 - # Here you can set min. and max. level for enchantment generated via Mob Spawning - # These levels can not be greater or smaller than the default enchantment min. and max levels. - # Set min/max level to -1 to use the default enchantment min/max level value. - Level: - Min: -1 - Max: -1 -# Individual enchantment settings. Settings: - # A chance that this enchantment will be triggered. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Trigger_Chance: 15.0 + %enchantment_level% * 5.0 - # A cost a player will have to pay to have this enchantment triggered. - Cost: - # Enables/Disables cost feature. - Enabled: false - # A (custom) item that player must have in his inventory, that will be consumed to trigger the enchantment effect. - # See http://77.222.60.131:8080/plugin/engine/config/formats for item options. - Item: - Material: AIR - Amount: 1 - # Enchantment settings for the Potion Effect applied to a wearer or victim. Potion_Effect: - # Potion effect duration (in seconds). Keep in mind that settings this to a low value (smaller than Passive Task Interval in the config.yml) will result in effect reappear delay. - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Duration: 2.5 + %enchantment_level% * 0.75 - # Potion effect level (amplifier). - # Scalable. Placeholder: %enchantment_level%. See: http://77.222.60.131:8080/plugin/engine/config/formats Level: '%enchantment_level%' diff --git a/Core/src/main/resources/gui.enchants.yml b/Core/src/main/resources/gui.enchants.yml deleted file mode 100644 index ed9ee64..0000000 --- a/Core/src/main/resources/gui.enchants.yml +++ /dev/null @@ -1,62 +0,0 @@ -# See http://77.222.60.131:8080/plugin/engine/config/menuConfig -# Menu title. -Title: 'Excellent Enchants List' -# Menu size. Allowed values: 9, 18, 27, 36, 45, 54. -Size: 36 - -# Enchantment display settings. -Enchantments: - # Enchantment display item options. - # You can use 'Enchantment' placeholders: http://77.222.60.131:8080/plugin/excellentenchants/utils/placeholders - Icon: - Material: 'ENCHANTED_BOOK' - Name: '%enchantment_name_formatted%' - Lore: - - '%enchantment_description%' - - '&7' - - '&a▸ &7Tier: &a%enchantment_tier%' - - '&a▸ &7Applies to: &a%enchantment_fit_item_types%' - - '&a▸ &7Levels: &a%enchantment_level_min% &7- &a%enchantment_level_max%' - - '&7' - - '&c&lConflicts with:' - - '&c▸ &4%enchantment_conflicts%' - - '&7' - - '&e&lItem Cost to Use:' - - '&e▸ &7%enchantment_cost_item%' - - '&7' - - '&b&lObtain Chance:' - - '&b▸ &7Enchanting Table: &b%enchantment_obtain_chance_enchanting%%' - - '&b▸ &7Villager Trade: &b%enchantment_obtain_chance_villager%%' - - '&b▸ &7Loot Generation: &b%enchantment_obtain_chance_loot_generation%%' - - '&b▸ &7Fishing: &b%enchantment_obtain_chance_fishing%%' - - '&b▸ &7Mob Spawning: &b%enchantment_obtain_chance_mob_spawning%%' - - '&7' - - '&d&lClick to switch enchantment levels!' - # Menu slots to display enchantments. - Slots: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 - -# List of custom menu items. -Content: - page_next: - Display: - default: - Priority: 0 - Item: - Material: ARROW - Name: '&aNext Page' - Lore: - - '&7Click to move &aForward&7!' - Slots: 35 - Type: PAGE_NEXT - - page_prev: - Display: - default: - Priority: 0 - Item: - Material: ARROW - Name: '&cPrevious Page' - Lore: - - '&7Click to move &cBack&7!' - Slots: 27 - Type: PAGE_PREVIOUS \ No newline at end of file diff --git a/Core/src/main/resources/lang/messages_ru.yml b/Core/src/main/resources/lang/messages_ru.yml index e391d9e..9e33cf0 100644 --- a/Core/src/main/resources/lang/messages_ru.yml +++ b/Core/src/main/resources/lang/messages_ru.yml @@ -1,53 +1,41 @@ +# +---------------------------------------------------------+ +# | Официальная русская версия. | +# | Публикация на помойках rubukkit и spigotru ЗАПРЕЩЕНА. | +# +---------------------------------------------------------+ Command: List: - Desc: 'Список всех пользовательских зачарований.' + Desc: 'Список всех нестандартных зачарований.' Enchant: - Usage: '<чары> <уровень>' - Desc: 'Зачаровывает предмет в вашей руке.' + Usage: '<зачарование> <уровень>' + Desc: 'Зачарование предмета в руке.' Done: '&aУспешно зачаровано!' Book: - Usage: '<игрок> <чары> <уровень>' - Desc: 'Даёт книгу с выбранным зачарованием.' - Done: 'Книга зачарования &6%enchant%&7 выдана &6%player%&7.' + Usage: '<игрок> <зачарование> <уровень>' + Desc: 'Выдача книги с указанным зачарованием.' + Done: 'Выдана книга с зачарованием &6%enchant%&7 игроку &6%player_name%&7.' TierBook: - Usage: '<игрок> <класс> <уровень>' - Desc: 'Даёт книгу со случайными чарами определенного класса.' - Error: '&cНеверный уровень!' - Done: 'Зачарованная книга класса &6%tier%&7 выдана &6%player%&7.' + Usage: '<игрок> <ранг> <уровень>' + Desc: 'Выдача книги с произвольным зачарованием указанного ранга.' + Error: '&cТакого ранга не существует!' + Done: 'Выдана книга с зачарованием ранга &6%tier_name%&7 игроку &6%player_name%&7.' Error: - NoEnchant: '&cЗачарование не существует.' -EnchantmentTarget: - ALL: Всё - ARMOR: Броня - ARMOR_FEET: Ботинки - ARMOR_LEGS: Ноги - ARMOR_TORSO: Грудь - ARMOR_HEAD: Голова - WEAPON: Оружие - TOOL: Инструмент - BOW: Лук - FISHING_ROD: Удочка - BREAKABLE: Ломаемое - WEARABLE: Надеваемое - TRIDENT: Трезубец - CROSSBOW: Арбалет - VANISHABLE: Утрачиваемое - BOW_AND_CROSSBOW: Лук и Арбалет + NoEnchant: '&cТакого зачарования не существует.' FitItemType: - HELMET: Шлем - CHESTPLATE: Нагрудник - LEGGINGS: Поножи - BOOTS: Ботинки - ELYTRA: Элитры - WEAPON: Оружие - TOOL: Инструмент - ARMOR: Броня - SWORD: Меч - TRIDENT: Трезубец - AXE: Топор - BOW: Лук - CROSSBOW: Арбалет - HOE: Мотыга - PICKAXE: Кирка - SHOVEL: Лопата - FISHING_ROD: Удочка \ No newline at end of file + HELMET: 'Шлем' + CHESTPLATE: 'Нагрудник' + LEGGINGS: 'Поножи' + BOOTS: 'Ботинки' + ELYTRA: 'Элитры' + WEAPON: 'Оружие' + TOOL: 'Инструмент' + ARMOR: 'Броня' + SWORD: 'Меч' + TRIDENT: 'Трезубец' + AXE: 'Топор' + BOW: 'Лук' + CROSSBOW: 'Арбалет' + HOE: 'Мотыга' + PICKAXE: 'Кирка' + SHOVEL: 'Лопата' + FISHING_ROD: 'Удочка' + UNIVERSAL: 'Универсально' \ No newline at end of file diff --git a/Core/src/main/resources/menu/enchants_list.yml b/Core/src/main/resources/menu/enchants_list.yml new file mode 100644 index 0000000..861e0ea --- /dev/null +++ b/Core/src/main/resources/menu/enchants_list.yml @@ -0,0 +1,71 @@ +Title: ' #a267f3&lCustom Enchants' +Size: 36 +Use_Mini_Message: false + +Enchantments: + Icon: + Material: ENCHANTED_BOOK + Name: '%enchantment_name_formatted%' + Lore: + - '#aeb6bf%enchantment_description%' + - '' + - '#bcff9a&lInfo:' + - '#bcff9a▪ #ddeceeTier: #bcff9a%enchantment_tier%' + - '#bcff9a▪ #ddeceeApplies to: #bcff9a%enchantment_fit_item_types%' + - '#bcff9a▪ #ddeceeLevels: #bcff9a%enchantment_level_min% #ddecee- #bcff9a%enchantment_level_max%' + - '%conflicts%' + - '%charges%' + - '%obtaining%' + - '' + - '#a5ff9a&lActions:' + - '#a5ff9a▪ #ddeceeLeft-Click: #a5ff9aSwitch Level' + Lore: + Conflicts: + - '' + - '#ff9a9a[!] #ddeceeCan not be used together with:' + - '#ff9a9a▸ %enchantment_name%' + Charges: + - '' + - '#d39aff&lCharges:' + - '#d39aff◈ #ddeceeMaximum: #d39aff%enchantment_charges_max_amount%⚡' + - '#d39aff◈ #ddeceePer Use: #d39aff-%enchantment_charges_consume_amount%⚡' + - '#d39aff◈ #ddeceePer Recharge: #d39aff+%enchantment_charges_recharge_amount%⚡' + - '#d39aff◈ #ddeceeFuel Item: #d39aff%enchantment_charges_fuel_item%' + Obtaining: + - '' + - '#9af7ff&lObtain Chance:' + - '#9af7ff┃ #ddeceeEnchanting Table: #9af7ff%enchantment_obtain_chance_enchanting%%' + - '#9af7ff┃ #ddeceeVillager Trade: #9af7ff%enchantment_obtain_chance_villager%%' + - '#9af7ff┃ #ddeceeLoot Generation: #9af7ff%enchantment_obtain_chance_loot_generation%%' + - '#9af7ff┃ #ddeceeFishing: #9af7ff%enchantment_obtain_chance_fishing%%' + - '#9af7ff┃ #ddeceeMob Spawning: #9af7ff%enchantment_obtain_chance_mob_spawning%%' + Slots: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 + +Content: + return: + Priority: 5 + Item: + Material: PLAYER_HEAD + Head_Texture: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmU5YWU3YTRiZTY1ZmNiYWVlNjUxODEzODlhMmY3ZDQ3ZTJlMzI2ZGI1OWVhM2ViNzg5YTkyYzg1ZWE0NiJ9fX0= + Name: '#ffee9a(↓) &fClose Menu' + Lore: [] + Slots: 31 + Type: CLOSE + + page_next: + Slots: 35 + Type: PAGE_NEXT + Item: + Material: PLAYER_HEAD + Head_Texture: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjMyY2E2NjA1NmI3Mjg2M2U5OGY3ZjMyYmQ3ZDk0YzdhMGQ3OTZhZjY5MWM5YWMzYTkxMzYzMzEzNTIyODhmOSJ9fX0= + Name: '#ffee9a(→) &fNext Page' + Priority: 5 + + page_previous: + Slots: 27 + Type: PAGE_PREVIOUS + Item: + Material: PLAYER_HEAD + Head_Texture: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODY5NzFkZDg4MWRiYWY0ZmQ2YmNhYTkzNjE0NDkzYzYxMmY4Njk2NDFlZDU5ZDFjOTM2M2EzNjY2YTVmYTYifX19 + Name: '#ffee9a(←) &fPrevious Page' + Priority: 5 \ No newline at end of file diff --git a/Core/src/main/resources/plugin.yml b/Core/src/main/resources/plugin.yml index 66e9b82..9ab8ab6 100644 --- a/Core/src/main/resources/plugin.yml +++ b/Core/src/main/resources/plugin.yml @@ -4,7 +4,7 @@ name: ExcellentEnchants author: NightExpress desciption: Vanilla-like enchants for your server. depend: [ NexEngine ] -softdepend: [ ProtocolLib, Towny, Residence, WorldGuard, GriefPrevention, Lands ] +softdepend: [ ProtocolLib, NoCheatPlus ] api-version: 1.17 load: STARTUP diff --git a/Core/src/main/resources/tiers.yml b/Core/src/main/resources/tiers.yml new file mode 100644 index 0000000..0d928b4 --- /dev/null +++ b/Core/src/main/resources/tiers.yml @@ -0,0 +1,50 @@ +common: + Name: 'Common' + Color: 'WHITE' + Priority: 1 + Obtain_Chance: + ENCHANTING: 80.0 + VILLAGER: 80.0 + LOOT_GENERATION: 80.0 + FISHING: 80.0 + MOB_SPAWNING: 80.0 +rare: + Name: 'Rare' + Color: 'GREEN' + Priority: 2 + Obtain_Chance: + ENCHANTING: 50.0 + VILLAGER: 50.0 + LOOT_GENERATION: 50.0 + FISHING: 50.0 + MOB_SPAWNING: 50.0 +exotic: + Name: 'Exotic' + Color: 'YELLOW' + Priority: 3 + Obtain_Chance: + ENCHANTING: 25.0 + VILLAGER: 25.0 + LOOT_GENERATION: 25.0 + FISHING: 25.0 + MOB_SPAWNING: 25.0 +legendary: + Name: 'Legendary' + Color: 'GOLD' + Priority: 4 + Obtain_Chance: + ENCHANTING: 10.0 + VILLAGER: 10.0 + LOOT_GENERATION: 10.0 + FISHING: 10.0 + MOB_SPAWNING: 10.0 +cursed: + Name: 'Cursed' + Color: 'RED' + Priority: 0 + Obtain_Chance: + ENCHANTING: 0.0 + VILLAGER: 5.0 + LOOT_GENERATION: 7.0 + FISHING: 12.0 + MOB_SPAWNING: 0.0 \ No newline at end of file diff --git a/NMS/pom.xml b/NMS/pom.xml index 5c8fd3d..16d313f 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.13 + 3.3.0 4.0.0 diff --git a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java index a57a9ef..01df19b 100644 --- a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java +++ b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java @@ -1,21 +1,27 @@ package su.nightexpress.excellentenchants.nms; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffect; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.utils.EntityUtil; +import su.nexmedia.engine.utils.ItemUtil; -import java.util.Objects; +import java.util.Map; import java.util.Set; public interface EnchantNMS { + int EFFECT_DURATION_MAX = 30 * 20; + int EFFECT_DURATION_MIN = 20 * 20; + // TODO Move in 'API' module? @Deprecated static int getEnchantmentLevel(@NotNull ItemStack item, @NotNull Enchantment enchant) { @@ -25,10 +31,24 @@ public interface EnchantNMS { return meta.getEnchantLevel(enchant); } + @NotNull + @Deprecated + 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; + } + // TODO Move in 'API' module? @Deprecated static int getEquippedEnchantLevel(@NotNull LivingEntity entity, @NotNull Enchantment enchant) { - return EntityUtil.getEquippedItems(entity).values().stream().filter(Objects::nonNull).filter(enchant::canEnchantItem) + return getEquipmentEnchanted(entity).values().stream() .map(item -> getEnchantmentLevel(item, enchant)).max(Integer::compareTo).orElse(0); } diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 39c989f..b86ddf7 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.13 + 3.3.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.13 + 3.3.0 diff --git a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java index 3e98c59..30d9e3c 100644 --- a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java +++ b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java @@ -10,12 +10,10 @@ import su.nightexpress.excellentenchants.nms.EnchantNMS; public class CustomEffectInstance extends MobEffectInstance { - private static final int MIN = 60 * 60 * 20; - private final Enchantment enchantment; public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { - super(effect, Integer.MAX_VALUE, amplifier); + super(effect, EnchantNMS.EFFECT_DURATION_MAX, amplifier); this.enchantment = enchantment; } @@ -40,8 +38,8 @@ public class CustomEffectInstance extends MobEffectInstance { return false; } if (super.tick(entity, runnable)) { - if (this.getDuration() <= MIN) { - Reflex.setFieldValue(this, "c", Integer.MAX_VALUE); + if (this.getDuration() <= EnchantNMS.EFFECT_DURATION_MIN) { + Reflex.setFieldValue(this, "c", EnchantNMS.EFFECT_DURATION_MAX); } return true; } diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index a5222ff..c265265 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.13 + 3.3.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.13 + 3.3.0 diff --git a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java index 6f76733..3726d8c 100644 --- a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java +++ b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java @@ -10,12 +10,10 @@ import su.nightexpress.excellentenchants.nms.EnchantNMS; public class CustomEffectInstance extends MobEffectInstance { - private static final int MIN = 60 * 60 * 20; - private final Enchantment enchantment; public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { - super(effect, Integer.MAX_VALUE, amplifier); + super(effect, EnchantNMS.EFFECT_DURATION_MAX, amplifier); this.enchantment = enchantment; } @@ -40,8 +38,8 @@ public class CustomEffectInstance extends MobEffectInstance { return false; } if (super.tick(entity, runnable)) { - if (this.getDuration() <= MIN) { - Reflex.setFieldValue(this, "c", Integer.MAX_VALUE); + if (this.getDuration() <= EnchantNMS.EFFECT_DURATION_MIN) { + Reflex.setFieldValue(this, "c", EnchantNMS.EFFECT_DURATION_MAX); } return true; } diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index 53686f3..3c5889c 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.13 + 3.3.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.13 + 3.3.0 diff --git a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java index f62e277..e1246e9 100644 --- a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java +++ b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java @@ -10,12 +10,10 @@ import su.nightexpress.excellentenchants.nms.EnchantNMS; public class CustomEffectInstance extends MobEffectInstance { - private static final int MIN = 60 * 60 * 20; - private final Enchantment enchantment; public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { - super(effect, Integer.MAX_VALUE, amplifier); + super(effect, EnchantNMS.EFFECT_DURATION_MAX, amplifier); this.enchantment = enchantment; } @@ -40,8 +38,8 @@ public class CustomEffectInstance extends MobEffectInstance { return false; } if (super.tick(entity, runnable)) { - if (this.getDuration() <= MIN) { - Reflex.setFieldValue(this, "c", Integer.MAX_VALUE); + if (this.getDuration() <= EnchantNMS.EFFECT_DURATION_MIN) { + Reflex.setFieldValue(this, "c", EnchantNMS.EFFECT_DURATION_MAX); } return true; } diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml index 051da34..0cd1165 100644 --- a/V1_19_R2/pom.xml +++ b/V1_19_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.2.13 + 3.3.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.2.13 + 3.3.0 diff --git a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java index c4aca5b..1506674 100644 --- a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java +++ b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java @@ -15,7 +15,7 @@ public class CustomEffectInstance extends MobEffectInstance { private final Enchantment enchantment; public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { - super(effect, MIN * 2, amplifier); + super(effect, EnchantNMS.EFFECT_DURATION_MAX, amplifier); this.enchantment = enchantment; } @@ -40,8 +40,8 @@ public class CustomEffectInstance extends MobEffectInstance { return false; } if (super.tick(entity, runnable)) { - if (this.getDuration() <= MIN) { - Reflex.setFieldValue(this, "c", Integer.MAX_VALUE); + if (this.getDuration() <= EnchantNMS.EFFECT_DURATION_MIN) { + Reflex.setFieldValue(this, "c", EnchantNMS.EFFECT_DURATION_MAX); } return true; } diff --git a/pom.xml b/pom.xml index 51ff3c4..fce1012 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.2.13 + 3.3.0 Core NMS From 6cdd7b7dfc3b920094d944f9c85e72571752ee76 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Mon, 23 Jan 2023 11:35:55 +0600 Subject: [PATCH 23/69] Fixed GUI, anvil merging --- Core/pom.xml | 12 ++++----- .../impl/tool/EnchantSilkChest.java | 26 ++++++++++++++----- .../listener/EnchantAnvilListener.java | 2 +- .../menu/EnchantmentsListMenu.java | 2 +- .../hook/impl/ProtocolHook.java | 9 ++++--- 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 +-- pom.xml | 2 +- 11 files changed, 43 insertions(+), 28 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 5146a28..22aa57e 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0 + 3.3.0.2 4.0.0 @@ -45,27 +45,27 @@ su.nightexpress.excellentenchants NMS - 3.3.0 + 3.3.0.2 su.nightexpress.excellentenchants V1_17_R1 - 3.3.0 + 3.3.0.2 su.nightexpress.excellentenchants V1_18_R2 - 3.3.0 + 3.3.0.2 su.nightexpress.excellentenchants V1_19_R1 - 3.3.0 + 3.3.0.2 su.nightexpress.excellentenchants V1_19_R2 - 3.3.0 + 3.3.0.2 fr.neatmonster 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 ab02777..51cc897 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 @@ -32,19 +32,26 @@ import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.TreeMap; import java.util.stream.Stream; public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEnchant { public static final String ID = "silk_chest"; - private String chestName; - private List chestLore; - private final NamespacedKey keyChest; + private String chestName; + private List chestLore; + private final NamespacedKey keyChest; + @Deprecated private final Map keyItems; public EnchantSilkChest(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGH); this.keyChest = new NamespacedKey(plugin, ID + ".item"); + this.keyItems = new TreeMap<>(); + for (int pos = 0; pos < 27; pos++) { + this.getItemKey(pos); + } } @Override @@ -58,6 +65,11 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha "Use '" + Placeholders.GENERIC_AMOUNT + "' for items amount.").read(cfg); } + @Deprecated + private NamespacedKey getItemKey(int pos) { + return this.keyItems.computeIfAbsent(pos, key -> new NamespacedKey(plugin, "silkchest_item_" + pos)); + } + @Override @NotNull public FitItemType[] getFitItemTypes() { @@ -71,7 +83,7 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha } public boolean isSilkChest(@NotNull ItemStack item) { - return PDCUtil.getBooleanData(item, this.keyChest); + return PDCUtil.getBooleanData(item, this.keyChest) || PDCUtil.getStringData(item, this.getItemKey(0)) != null; } @NotNull @@ -158,14 +170,14 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha chest.setCustomName(null); chest.update(true); - //Inventory inventory = chest.getBlockInventory(); - /*for (int pos = 0; pos < inventory.getSize(); pos++) { + Inventory inventory = chest.getBlockInventory(); + for (int pos = 0; pos < inventory.getSize(); pos++) { String data = PDCUtil.getStringData(item, this.getItemKey(pos)); if (data == null) continue; ItemStack itemInv = ItemUtil.fromBase64(data); inventory.setItem(pos, itemInv); - }*/ + } } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = 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 2cf3fb4..d302896 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 @@ -97,7 +97,7 @@ public class EnchantAnvilListener extends AbstractListener { // Merge only if it's Item + Item, Item + Enchanted book or Enchanted Book + Enchanted Book if (second.getType() == Material.ENCHANTED_BOOK || second.getType() == first.getType()) { EnchantManager.getExcellentEnchantments(second).forEach((enchant, level) -> { - enchantments.merge(enchant, level, (oldLvl, newLvl) -> (oldLvl.equals(newLvl)) ? (oldLvl + 1) : (Math.max(oldLvl, newLvl))); + enchantments.merge(enchant, level, (oldLvl, newLvl) -> (oldLvl.equals(newLvl)) ? (Math.min(enchant.getMaxLevel(), oldLvl + 1)) : (Math.max(oldLvl, newLvl))); }); } 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 6d651c3..98e9019 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 @@ -101,7 +101,7 @@ public class EnchantmentsListMenu extends AbstractMenuAuto enchant.getMaxLevel()) levelHas = enchant.getStartLevel(); itemClick = this.getEnchantIcon(enchant, levelHas); 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 11ce9f1..5cd0ee7 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 @@ -16,9 +16,8 @@ import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.EnchantManager; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; public class ProtocolHook { @@ -94,6 +93,10 @@ public class ProtocolHook { lore.removeAll(enchant.formatDescription(level)); }); } + + enchants = enchants.entrySet().stream() + .sorted(Comparator.comparing(e -> e.getKey().getTier().getPriority())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (old,nev) -> nev, LinkedHashMap::new)); if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED.get() && !isCreative) { enchants.forEach((enchant, level) -> { lore.addAll(0, enchant.formatDescription(level)); diff --git a/NMS/pom.xml b/NMS/pom.xml index 16d313f..f543476 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0 + 3.3.0.2 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index b86ddf7..41bd7ab 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0 + 3.3.0.2 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0 + 3.3.0.2 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index c265265..56a51b5 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0 + 3.3.0.2 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0 + 3.3.0.2 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index 3c5889c..7fbd06e 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0 + 3.3.0.2 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0 + 3.3.0.2 diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml index 0cd1165..6a134be 100644 --- a/V1_19_R2/pom.xml +++ b/V1_19_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0 + 3.3.0.2 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0 + 3.3.0.2 diff --git a/pom.xml b/pom.xml index fce1012..e7cbd84 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.3.0 + 3.3.0.2 Core NMS From 3c0473330e4845b9b095484f28b0c8eb4d396bfb Mon Sep 17 00:00:00 2001 From: nulli0n Date: Mon, 23 Jan 2023 21:56:59 +0600 Subject: [PATCH 24/69] Fixed charges check for passive enchants --- .../excellentenchants/enchantment/EnchantManager.java | 1 + 1 file changed, 1 insertion(+) 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 691fe95..3c862a4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java @@ -344,6 +344,7 @@ public class EnchantManager extends AbstractManager { 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); } From d9d2a84805a848b5490434e0656652f31e6a05d7 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Thu, 26 Jan 2023 08:08:43 +0600 Subject: [PATCH 25/69] Fixed EnchantRegrowth and EnchantSaturation --- .../enchantment/impl/armor/EnchantRegrowth.java | 11 ++++++++--- .../enchantment/impl/armor/EnchantSaturation.java | 12 ++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) 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 5cd62d9..c7b6773 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 @@ -40,25 +40,30 @@ public class EnchantRegrowth extends ExcellentEnchant implements PassiveEnchant, public EnchantRegrowth(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); - this.task = new Task(plugin); - this.task.start(); } @Override public void loadConfig() { super.loadConfig(); this.healInterval = JOption.create("Settings.Heal.Interval", 100, - "How often (in seconds) enchantment will have effect?").read(cfg); + "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", "Minimal entity health for the enchantment to have effect."); this.healMaxHealth = EnchantScaler.read(this, "Settings.Heal.Max_Health", "20.0", "Maximal entity health when the enchantment will not heal anymore."); this.healAmount = EnchantScaler.read(this, "Settings.Heal.Amount", "0.25", "Amount of hearts to be restored."); + + this.task = new Task(plugin); + this.task.start(); } @Override public void clear() { + this.stopTask(); + } + + private void stopTask() { if (this.task != null) { this.task.stop(); this.task = null; 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 e614163..0d8b156 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 @@ -35,24 +35,28 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan public EnchantSaturation(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); - - this.task = new Task(plugin); - this.task.start(); } @Override public void loadConfig() { super.loadConfig(); this.saturationInterval = JOption.create("Settings.Saturation.Interval", 100, - "How often (in seconds) enchantment will have effect?").read(cfg); + "How often (in ticks) enchantment will have effect? 1 second = 20 ticks.").read(cfg); this.saturationAmount = EnchantScaler.read(this, "Settings.Saturation.Amount", Placeholders.ENCHANTMENT_LEVEL, "Amount of food points to restore."); this.saturationMaxFoodLevel = EnchantScaler.read(this, "Settings.Saturation.Max_Food_Level", "20", "Maximal player's food level for the enchantment to stop feeding them."); + + this.task = new Task(plugin); + this.task.start(); } @Override public void clear() { + this.stopTask(); + } + + private void stopTask() { if (this.task != null) { this.task.stop(); this.task = null; From a419c9e14760f5e8f6b5bb32b3cd2daea5bb0668 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Thu, 26 Jan 2023 09:49:58 +0600 Subject: [PATCH 26/69] Fixed EnchantThunder and EnchantElectrifiedArrows item damage --- Core/pom.xml | 12 +++++------ .../impl/bow/EnchantElectrifiedArrows.java | 20 +++++++++++++++++-- .../impl/weapon/EnchantThunder.java | 18 ++++++++++++++++- 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 ++-- pom.xml | 2 +- 9 files changed, 51 insertions(+), 19 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 22aa57e..11f6598 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.2 + 3.3.0.3 4.0.0 @@ -45,27 +45,27 @@ su.nightexpress.excellentenchants NMS - 3.3.0.2 + 3.3.0.3 su.nightexpress.excellentenchants V1_17_R1 - 3.3.0.2 + 3.3.0.3 su.nightexpress.excellentenchants V1_18_R2 - 3.3.0.2 + 3.3.0.3 su.nightexpress.excellentenchants V1_19_R1 - 3.3.0.2 + 3.3.0.3 su.nightexpress.excellentenchants V1_19_R2 - 3.3.0.2 + 3.3.0.3 fr.neatmonster 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 2709dd0..cfbdd90 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 @@ -3,12 +3,16 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityShootBowEvent; 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.utils.LocationUtil; @@ -25,6 +29,8 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance public static final String ID = "electrified_arrows"; + private static final String META_NO_ITEM_DAMAGE = "itemNoDamage"; + private ArrowImplementation arrowImplementation; private ChanceImplementation chanceImplementation; @@ -70,7 +76,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance if (e.getHitEntity() != null || e.getHitBlock() == null) return false; Block block = e.getHitBlock(); - block.getWorld().strikeLightning(block.getLocation()); + 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); @@ -83,10 +89,20 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance if (!this.isOurProjectile(projectile)) return false; plugin.getServer().getScheduler().runTask(plugin, () -> { + if (victim.isDead()) return; victim.setNoDamageTicks(0); - victim.getWorld().strikeLightning(victim.getLocation()); + victim.getWorld().strikeLightning(victim.getLocation()).setMetadata(META_NO_ITEM_DAMAGE, new FixedMetadataValue(plugin, true)); }); return true; } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onItemDamage(EntityDamageByEntityEvent e) { + if (!e.getDamager().hasMetadata(META_NO_ITEM_DAMAGE)) return; + if (!(e.getEntity() instanceof Item item)) return; + + e.setCancelled(true); + item.setFireTicks(0); + } } 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 5566248..98e4995 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 @@ -1,9 +1,13 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -16,6 +20,8 @@ import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementat public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatEnchant { public static final String ID = "thunder"; + + private static final String META_NO_ITEM_DAMAGE = "noItemDamage"; private boolean inThunderstormOnly; private ChanceImplementation chanceImplementation; @@ -56,8 +62,9 @@ public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatE if (!this.checkTriggerChance(level)) return false; plugin.getServer().getScheduler().runTask(plugin, () -> { + if (victim.isDead()) return; victim.setNoDamageTicks(0); - victim.getWorld().strikeLightning(victim.getLocation()); + victim.getWorld().strikeLightning(victim.getLocation()).setMetadata(META_NO_ITEM_DAMAGE, new FixedMetadataValue(plugin, true)); }); return true; @@ -67,4 +74,13 @@ public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatE public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onItemDamage(EntityDamageByEntityEvent e) { + if (!e.getDamager().hasMetadata(META_NO_ITEM_DAMAGE)) return; + if (!(e.getEntity() instanceof Item item)) return; + + e.setCancelled(true); + item.setFireTicks(0); + } } diff --git a/NMS/pom.xml b/NMS/pom.xml index f543476..53441d4 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.2 + 3.3.0.3 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 41bd7ab..f60befc 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.2 + 3.3.0.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0.2 + 3.3.0.3 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 56a51b5..1a202cc 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.2 + 3.3.0.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0.2 + 3.3.0.3 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index 7fbd06e..9fa190a 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.2 + 3.3.0.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0.2 + 3.3.0.3 diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml index 6a134be..177f3e2 100644 --- a/V1_19_R2/pom.xml +++ b/V1_19_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.2 + 3.3.0.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0.2 + 3.3.0.3 diff --git a/pom.xml b/pom.xml index e7cbd84..39bd877 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.3.0.2 + 3.3.0.3 Core NMS From 390f7d01491e768a45a449e890dcfb327183c2ad Mon Sep 17 00:00:00 2001 From: nulli0n Date: Sun, 29 Jan 2023 17:43:22 +0600 Subject: [PATCH 27/69] 3.3.0.4 --- Core/pom.xml | 12 ++++---- .../api/enchantment/ExcellentEnchant.java | 5 ++++ .../api/enchantment/IEnchantment.java | 2 ++ .../impl/armor/EnchantRegrowth.java | 6 +++- .../listener/EnchantAnvilListener.java | 29 ++++++++++++++----- .../hook/impl/ProtocolHook.java | 3 +- 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 +-- pom.xml | 2 +- 12 files changed, 51 insertions(+), 26 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 11f6598..1aa7dea 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.3 + 3.3.0.4 4.0.0 @@ -45,27 +45,27 @@ su.nightexpress.excellentenchants NMS - 3.3.0.3 + 3.3.0.4 su.nightexpress.excellentenchants V1_17_R1 - 3.3.0.3 + 3.3.0.4 su.nightexpress.excellentenchants V1_18_R2 - 3.3.0.3 + 3.3.0.4 su.nightexpress.excellentenchants V1_19_R1 - 3.3.0.3 + 3.3.0.4 su.nightexpress.excellentenchants V1_19_R2 - 3.3.0.3 + 3.3.0.4 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index 7d1b016..4070b41 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -420,6 +420,11 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme return EnchantManager.isEnchantmentFullOfCharges(item, this); } + @Override + public int getCharges(@NotNull ItemStack item) { + return EnchantManager.getEnchantmentCharges(item, this); + } + @Override public void consumeCharges(@NotNull ItemStack item) { EnchantManager.consumeEnchantmentCharges(item, this); 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 5fec1c7..962dd98 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 @@ -70,6 +70,8 @@ public interface IEnchantment { boolean isChargesFuel(@NotNull ItemStack item); + int getCharges(@NotNull ItemStack item); + boolean isFullOfCharges(@NotNull ItemStack item); boolean isOutOfCharges(@NotNull ItemStack item); 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 c7b6773..95cebf0 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 @@ -131,7 +131,11 @@ public class EnchantRegrowth extends ExcellentEnchant implements PassiveEnchant, public void action() { for (LivingEntity entity : this.getEntities()) { EnchantManager.getEquippedEnchants(entity, EnchantRegrowth.class).forEach((item, enchants) -> { - enchants.forEach((enchant, level) -> enchant.onTrigger(entity, item, level)); + enchants.forEach((enchant, level) -> { + if (enchant.onTrigger(entity, item, level)) { + enchant.consumeCharges(item); + } + }); }); } } 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 d302896..1e2e33a 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 @@ -19,6 +19,7 @@ import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; @@ -56,7 +57,7 @@ public class EnchantAnvilListener extends AbstractListener { private boolean handleRename(@NotNull PrepareAnvilEvent e, @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) { - if (!second.getType().isAir()) return false; + if (!second.getType().isAir() && (second.getType() == first.getType() || second.getType() == Material.ENCHANTED_BOOK)) return false; if (result.getType() != first.getType()) return false; ItemStack result2 = new ItemStack(result); @@ -71,16 +72,22 @@ public class EnchantAnvilListener extends AbstractListener { @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) { if (second.getType().isAir()) return false; - Set chargeable = EnchantManager.getExcellentEnchantments(first).keySet().stream() + Set chargeables = EnchantManager.getExcellentEnchantments(first).keySet().stream() .filter(en -> en.isChargesEnabled() && en.isChargesFuel(second) && !en.isFullOfCharges(first)) .collect(Collectors.toSet()); - if (chargeable.isEmpty()) return false; + if (chargeables.isEmpty()) return false; ItemStack result2 = new ItemStack(first); - chargeable.forEach(enchant -> EnchantManager.rechargeEnchantmentCharges(result2, enchant)); - PDCUtil.setData(result2, RECHARGED, true); + + int count = 0; + while (count < second.getAmount() && !chargeables.stream().allMatch(en -> en.isFullOfCharges(result2))) { + chargeables.forEach(enchant -> EnchantManager.rechargeEnchantmentCharges(result2, enchant)); + count++; + } + + PDCUtil.setData(result2, RECHARGED, count); e.setResult(result2); - this.plugin.runTask(c -> e.getInventory().setRepairCost(chargeable.size()), false); + this.plugin.runTask(c -> e.getInventory().setRepairCost(chargeables.size()), false); return true; } @@ -92,12 +99,14 @@ public class EnchantAnvilListener extends AbstractListener { ItemStack result2 = new ItemStack(result.getType().isAir() ? first : result); Map enchantments = EnchantManager.getExcellentEnchantments(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) -> { 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); }); } @@ -105,6 +114,7 @@ public class EnchantAnvilListener extends AbstractListener { enchantments.forEach((enchant, level) -> { if (EnchantManager.addEnchantment(result2, enchant, level, false)) { repairCost.addAndGet(enchant.getAnvilMergeCost(level)); + EnchantManager.setEnchantmentCharges(result2, enchant, charges.getOrDefault(enchant, 0)); } }); @@ -123,7 +133,10 @@ public class EnchantAnvilListener extends AbstractListener { if (e.getRawSlot() != 2) return; ItemStack item = e.getCurrentItem(); - if (item == null || !PDCUtil.getBooleanData(item, RECHARGED)) return; + if (item == null) return; + + int count = PDCUtil.getIntData(item, RECHARGED); + if (count == 0) return; Player player = (Player) e.getWhoClicked(); if (player.getLevel() < inventory.getRepairCost()) return; @@ -137,7 +150,7 @@ public class EnchantAnvilListener extends AbstractListener { ItemStack second = inventory.getItem(1); if (second != null && !second.getType().isAir()) { - second.setAmount(second.getAmount() - 1); + second.setAmount(second.getAmount() - count); } inventory.setItem(0, null); //inventory.setItem(1, null); 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 5cd0ee7..600d044 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 @@ -84,9 +84,10 @@ public class ProtocolHook { ItemMeta meta = copy.getItemMeta(); if (meta == null) return item; - List lore = meta.getLore() == null ? new ArrayList<>() : meta.getLore(); Map enchants = EnchantManager.getExcellentEnchantments(item); + if (enchants.isEmpty()) return item; + List lore = meta.getLore() == null ? new ArrayList<>() : meta.getLore(); enchants.keySet().forEach(enchant -> lore.removeIf(line -> line.contains(enchant.getDisplayName()))); if (isCreative) { enchants.forEach((enchant, level) -> { diff --git a/NMS/pom.xml b/NMS/pom.xml index 53441d4..44321c5 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.3 + 3.3.0.4 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index f60befc..6399ebd 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.3 + 3.3.0.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0.3 + 3.3.0.4 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 1a202cc..3d0ad72 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.3 + 3.3.0.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0.3 + 3.3.0.4 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index 9fa190a..7c2aa0c 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.3 + 3.3.0.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0.3 + 3.3.0.4 diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml index 177f3e2..d34d5bb 100644 --- a/V1_19_R2/pom.xml +++ b/V1_19_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.3 + 3.3.0.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0.3 + 3.3.0.4 diff --git a/pom.xml b/pom.xml index 39bd877..0c6d612 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.3.0.3 + 3.3.0.4 Core NMS From 7d82eaa31fa08c7d5670f286a95c2653301756ab Mon Sep 17 00:00:00 2001 From: nulli0n Date: Sun, 29 Jan 2023 18:02:29 +0600 Subject: [PATCH 28/69] Minor performance boost --- .../api/enchantment/ExcellentEnchant.java | 43 +++++++++++-------- .../enchantment/EnchantManager.java | 2 +- .../menu/EnchantmentsListMenu.java | 2 +- .../hook/impl/ProtocolHook.java | 21 ++++----- 4 files changed, 37 insertions(+), 31 deletions(-) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index 4070b41..678c103 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -24,11 +24,11 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.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.config.EnchantScaler; import su.nightexpress.excellentenchants.tier.Tier; import java.util.*; @@ -154,6 +154,28 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme } } + @NotNull + public UnaryOperator replaceAllPlaceholders(int level) { + return str -> this.replacePlaceholders(level).apply(str) + .replace(Placeholders.ENCHANTMENT_NAME, this.getDisplayName()) + .replace(Placeholders.ENCHANTMENT_NAME_FORMATTED, this.getNameFormatted(level)) + .replace(Placeholders.ENCHANTMENT_LEVEL, NumberUtil.toRoman(level)) + .replace(Placeholders.ENCHANTMENT_LEVEL_MIN, String.valueOf(this.getStartLevel())) + .replace(Placeholders.ENCHANTMENT_LEVEL_MAX, String.valueOf(this.getMaxLevel())) + .replace(Placeholders.ENCHANTMENT_TIER, this.getTier().getName()) + .replace(Placeholders.ENCHANTMENT_FIT_ITEM_TYPES, String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList())) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING, NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING))) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_VILLAGER, NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER))) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION, NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION))) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_FISHING, NumberUtil.format(this.getObtainChance(ObtainType.FISHING))) + .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING, NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING))) + .replace(Placeholders.ENCHANTMENT_CHARGES_MAX_AMOUNT, String.valueOf(this.getChargesMax(level))) + .replace(Placeholders.ENCHANTMENT_CHARGES_CONSUME_AMOUNT, String.valueOf(this.getChargesConsumeAmount(level))) + .replace(Placeholders.ENCHANTMENT_CHARGES_RECHARGE_AMOUNT, String.valueOf(this.getChargesRechargeAmount(level))) + .replace(Placeholders.ENCHANTMENT_CHARGES_FUEL_ITEM, ItemUtil.getItemName(this.getChargesFuel())) + ; + } + @NotNull public UnaryOperator replacePlaceholders(int level) { return str -> { @@ -168,24 +190,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme .replace(PotionImplementation.PLACEHOLDER_POTION_DURATION, NumberUtil.format((double) potioned.getEffectDuration(level) / 20D)) .replace(PotionImplementation.PLACEHOLDER_POTION_TYPE, LangManager.getPotionType(potioned.getEffectType())); } - return str - .replace(Placeholders.ENCHANTMENT_NAME, this.getDisplayName()) - .replace(Placeholders.ENCHANTMENT_NAME_FORMATTED, this.getNameFormatted(level)) - .replace(Placeholders.ENCHANTMENT_LEVEL, NumberUtil.toRoman(level)) - .replace(Placeholders.ENCHANTMENT_LEVEL_MIN, String.valueOf(this.getStartLevel())) - .replace(Placeholders.ENCHANTMENT_LEVEL_MAX, String.valueOf(this.getMaxLevel())) - .replace(Placeholders.ENCHANTMENT_TIER, this.getTier().getName()) - .replace(Placeholders.ENCHANTMENT_FIT_ITEM_TYPES, String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList())) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING, NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING))) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_VILLAGER, NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER))) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION, NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION))) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_FISHING, NumberUtil.format(this.getObtainChance(ObtainType.FISHING))) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING, NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING))) - .replace(Placeholders.ENCHANTMENT_CHARGES_MAX_AMOUNT, String.valueOf(this.getChargesMax(level))) - .replace(Placeholders.ENCHANTMENT_CHARGES_CONSUME_AMOUNT, String.valueOf(this.getChargesConsumeAmount(level))) - .replace(Placeholders.ENCHANTMENT_CHARGES_RECHARGE_AMOUNT, String.valueOf(this.getChargesRechargeAmount(level))) - .replace(Placeholders.ENCHANTMENT_CHARGES_FUEL_ITEM, ItemUtil.getItemName(this.getChargesFuel())) - ; + return str; }; } 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 3c862a4..3220c5e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java @@ -275,7 +275,7 @@ public class EnchantManager extends AbstractManager { return enchant == null ? null : Pair.of(enchant, entry.getValue()); }) .filter(Objects::nonNull) - .sorted(Comparator.comparing(p -> p.getFirst().getPriority(), Comparator.reverseOrder())) + //.sorted(Comparator.comparing(p -> p.getFirst().getPriority(), Comparator.reverseOrder())) .collect(Collectors.toMap(Pair::getFirst, Pair::getSecond, (old, nev) -> nev, LinkedHashMap::new)); } 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 98e9019..2c390f3 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 @@ -139,7 +139,7 @@ public class EnchantmentsListMenu extends AbstractMenuAuto enchants = EnchantManager.getExcellentEnchantments(item); + Map enchants = EnchantManager.getExcellentEnchantments(item) + .entrySet().stream() + .sorted(Comparator.comparing(e -> e.getKey().getTier().getPriority())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (old,nev) -> nev, LinkedHashMap::new)); if (enchants.isEmpty()) return item; List lore = meta.getLore() == null ? new ArrayList<>() : meta.getLore(); - enchants.keySet().forEach(enchant -> lore.removeIf(line -> line.contains(enchant.getDisplayName()))); - if (isCreative) { - enchants.forEach((enchant, level) -> { - lore.removeAll(enchant.formatDescription(level)); - }); + if (!lore.isEmpty()) { + enchants.keySet().forEach(enchant -> lore.removeIf(line -> line.contains(enchant.getDisplayName()))); + if (isCreative) { + enchants.forEach((enchant, level) -> { + lore.removeAll(enchant.formatDescription(level)); + }); + } } - - enchants = enchants.entrySet().stream() - .sorted(Comparator.comparing(e -> e.getKey().getTier().getPriority())) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (old,nev) -> nev, LinkedHashMap::new)); if (Config.ENCHANTMENTS_DESCRIPTION_ENABLED.get() && !isCreative) { enchants.forEach((enchant, level) -> { lore.addAll(0, enchant.formatDescription(level)); From 6b0f9cdc433a0b9e98d83b9fc521a058f7be95d0 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Sat, 11 Feb 2023 15:04:45 +0600 Subject: [PATCH 29/69] v3.3.1 --- Core/pom.xml | 18 +++-- .../excellentenchants/ExcellentEnchants.java | 13 ++-- .../api/enchantment/ExcellentEnchant.java | 2 +- .../command/BookCommand.java | 1 + .../command/EnchantCommand.java | 1 + .../command/TierbookCommand.java | 1 + .../excellentenchants/config/Config.java | 10 ++- .../enchantment/EnchantManager.java | 67 +++++++++++++++++-- .../impl/armor/EnchantSaturation.java | 6 +- .../impl/tool/EnchantDivineTouch.java | 2 +- .../listener/EnchantAnvilListener.java | 3 + .../listener/EnchantGenericListener.java | 17 +++++ .../hook/impl/ProtocolHook.java | 7 +- 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 +- pom.xml | 2 +- 19 files changed, 135 insertions(+), 33 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 1aa7dea..f0b2304 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.4 + 3.3.1 4.0.0 @@ -24,10 +24,16 @@ sk89q-repo https://maven.enginehub.org/repo/ + + false + dmulloy2-repo https://repo.dmulloy2.net/repository/public/ + + false + @@ -45,27 +51,27 @@ su.nightexpress.excellentenchants NMS - 3.3.0.4 + 3.3.1 su.nightexpress.excellentenchants V1_17_R1 - 3.3.0.4 + 3.3.1 su.nightexpress.excellentenchants V1_18_R2 - 3.3.0.4 + 3.3.1 su.nightexpress.excellentenchants V1_19_R1 - 3.3.0.4 + 3.3.1 su.nightexpress.excellentenchants V1_19_R2 - 3.3.0.4 + 3.3.1 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 92b344b..c3839ce 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -97,11 +97,14 @@ public class ExcellentEnchants extends NexPlugin { @Override public void registerHooks() { - if (Hooks.hasPlugin(HookId.PROTOCOL_LIB)) { - ProtocolHook.setup(); - } - else { - this.warn(HookId.PROTOCOL_LIB + " is not installed. Enchantments won't be displayed on items."); + if (Config.ENCHANTMENTS_DISPLAY_MODE.get() == 2) { + if (Hooks.hasPlugin(HookId.PROTOCOL_LIB)) { + ProtocolHook.setup(); + } + else { + this.warn(HookId.PROTOCOL_LIB + " is not installed. Set display mode to Plain lore."); + Config.ENCHANTMENTS_DISPLAY_MODE.set(1); + } } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index 678c103..c1adcc2 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -247,7 +247,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme @NotNull public String getNameFormatted(int level, int charges) { - if (!this.isChargesEnabled()) return this.getNameFormatted(level); + if (!this.isChargesEnabled() || charges < 0) return this.getNameFormatted(level); int chargesMax = this.getChargesMax(level); double percent = (double) charges / (double) chargesMax * 100D; 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 9d475a4..8733f39 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java @@ -86,6 +86,7 @@ public class BookCommand extends AbstractCommand { ItemStack item = new ItemStack(Material.ENCHANTED_BOOK); EnchantManager.addEnchantment(item, enchantment, level, true); + EnchantManager.updateEnchantmentsDisplay(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 ef064b1..531be7c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java @@ -83,6 +83,7 @@ public class EnchantCommand extends AbstractCommand { } else EnchantManager.removeEnchantment(item, enchantment); + EnchantManager.updateEnchantmentsDisplay(item); plugin.getMessage(Lang.COMMAND_ENCHANT_DONE).send(sender); } } 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 9849ce8..d5a3da9 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java @@ -91,6 +91,7 @@ public class TierbookCommand extends AbstractCommand { ItemStack item = new ItemStack(Material.ENCHANTED_BOOK); EnchantManager.addEnchantment(item, enchant, level, true); + EnchantManager.updateEnchantmentsDisplay(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 bb333ea..69c26f5 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -26,7 +26,8 @@ public class Config { ); public static final JOption ENCHANTMENTS_CHARGES_ENABLED = JOption.create("Enchantments.Charges.Enabled", false, - "Enables the enchantment Charges feature."); // TODO Wiki link + "Enables the enchantment Charges feature.", + Placeholders.URL_WIKI + "Charges-System"); public static final JOption> ENCHANTMENTS_CHARGES_FORMAT = new JOption>("Enchantments.Charges.Format", (cfg, path, def) -> cfg.getSection(path).stream().collect(Collectors.toMap(k -> StringUtil.getDouble(k, 0), v -> StringUtil.color(cfg.getString(path + "." + v, "")), (o,n) -> n, TreeMap::new)), @@ -64,6 +65,13 @@ public class Config { "To disable all enchantments for a world, use '" + Placeholders.WILDCARD + "' instead of enchantment names.") .setWriter((cfg, path, map) -> map.forEach((world, enchants) -> cfg.set(path + "." + world, enchants))); + public static final JOption ENCHANTMENTS_DISPLAY_MODE = JOption.create("Enchantments.Display.Mode", 1, + "Sets how enchantment names and descriptions will be handled on items.", + "1 = Plain modification of item's lore (lore changes are real and persistent).", + "2 = Packet modification of item's lore (no real changes are made to the items). Requires ProtocolLib.", + "Plain mode is faster, but may not reflect all changes immediately.", + "Packet mode is slower, but instantly reflect all changes. In creative mode, there is a chance for lore duplication."); + public static final JOption ENCHANTMENTS_DESCRIPTION_ENABLED = JOption.create("Enchantments.Description.Enabled", true, "When 'true', adds the enchantment description to item lore under enchantment names.", "Note #1: You must have ProtocolLib installed for this feature to work (as well as for enchantments name display).", 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 3220c5e..e50b469 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java @@ -1,10 +1,12 @@ 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; @@ -114,8 +116,7 @@ public class EnchantManager extends AbstractManager { // Класс для исключения неудачных попыток. EnchantPopulator populator = new EnchantPopulator(obtainType, item); - // Херачим до талого, пока нужное количество не будет добавлено - // или не закончатся чары и/или тиры. + // Добавляем сколько можем, пока нужное количество не будет добавлено или не закончатся чары и/или тиры. while (!populator.isEmpty() && enchRoll > 0) { // Достигнут максимум чар (любых) для итема, заканчиваем. if (enchantsToAdd.size() >= enchMax) break; @@ -159,6 +160,7 @@ public class EnchantManager extends AbstractManager { EnchantManager.getEnchantsToPopulate(item, obtainType).forEach((enchantment, level) -> { EnchantManager.addEnchantment(item, enchantment, level, false); }); + EnchantManager.updateEnchantmentsDisplay(item); return EnchantManager.getEnchantmentsAmount(item) != enchantsHad; } @@ -193,11 +195,52 @@ public class EnchantManager extends AbstractManager { 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() + enchants.keySet().stream().map(ExcellentEnchant::getDescription).mapToInt(List::size).sum(); + + 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); + } + + if (!meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS)) { + enchants.forEach((enchant, level) -> { + lore.addAll(0, enchant.formatDescription(level)); + }); + enchants.forEach((enchant, level) -> { + lore.add(0, enchant.getNameFormatted(level, getEnchantmentCharges(meta, enchant))); + }); + } + + meta.setLore(lore); + PDCUtil.set(meta, KEY_LORE_SIZE, sizeReal); + item.setItemMeta(meta); + return true; + } + @NotNull public static Map getEnchantments(@NotNull ItemStack item) { ItemMeta meta = item.getItemMeta(); - if (meta == null) return Collections.emptyMap(); + return meta == null ? Collections.emptyMap() : getEnchantments(meta); + } + @NotNull + public static Map getEnchantments(@NotNull ItemMeta meta) { return (meta instanceof EnchantmentStorageMeta meta2) ? meta2.getStoredEnchants() : meta.getEnchants(); } @@ -214,7 +257,11 @@ public class EnchantManager extends AbstractManager { } public static int getEnchantmentCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { - return PDCUtil.getIntData(item, enchant.getChargesKey()); + return enchant.isChargesEnabled() ? PDCUtil.getIntData(item, enchant.getChargesKey()) : -1; + } + + public static int getEnchantmentCharges(@NotNull ItemMeta meta, @NotNull ExcellentEnchant enchant) { + return enchant.isChargesEnabled() ? PDCUtil.getIntData(meta, enchant.getChargesKey()) : -1; } public static boolean isEnchantmentOutOfCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { @@ -269,7 +316,17 @@ public class EnchantManager extends AbstractManager { @NotNull public static Map getExcellentEnchantments(@NotNull ItemStack item) { - return EnchantManager.getEnchantments(item).entrySet().stream() + 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) { + return enchants.entrySet().stream() .map(entry -> { ExcellentEnchant enchant = EnchantRegister.get(entry.getKey().getKey()); return enchant == null ? null : Pair.of(enchant, entry.getValue()); 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 0d8b156..a446ee9 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 @@ -113,7 +113,11 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan public void action() { for (LivingEntity entity : this.getEntities()) { EnchantManager.getEquippedEnchants(entity, EnchantSaturation.class).forEach((item, enchants) -> { - enchants.forEach((enchant, level) -> enchant.onTrigger(entity, item, level)); + enchants.forEach((enchant, level) -> { + if (enchant.onTrigger(entity, item, level)) { + enchant.consumeCharges(item); + } + }); }); } } 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 eb93fb9..5bbf247 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 @@ -113,7 +113,7 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo e.setExpToDrop(0); e.setDropItems(true); block.setMetadata(META_HANDLE, new FixedMetadataValue(this.plugin, true)); - return true; + return false; // Do not consume charges } // Update spawner type of the placed spawner mined by Divine Touch. 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 1e2e33a..d35590d 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 @@ -64,6 +64,7 @@ public class EnchantAnvilListener extends AbstractListener { EnchantManager.getExcellentEnchantments(first).forEach((hasEnch, hasLevel) -> { EnchantManager.addEnchantment(result2, hasEnch, hasLevel, true); }); + EnchantManager.updateEnchantmentsDisplay(result2); e.setResult(result2); return true; } @@ -86,6 +87,7 @@ public class EnchantAnvilListener extends AbstractListener { } PDCUtil.setData(result2, RECHARGED, count); + EnchantManager.updateEnchantmentsDisplay(result2); e.setResult(result2); this.plugin.runTask(c -> e.getInventory().setRepairCost(chargeables.size()), false); return true; @@ -120,6 +122,7 @@ public class EnchantAnvilListener extends AbstractListener { if (first.equals(result2)) return false; + EnchantManager.updateEnchantmentsDisplay(result2); e.setResult(result2); // NMS ContainerAnvil will set level cost to 0 right after calling the event, need 1 tick delay. 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 b5d1783..c8b6f14 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 @@ -7,6 +7,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.enchantment.EnchantItemEvent; import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.entity.VillagerAcquireTradeEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; @@ -19,6 +20,7 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; 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.config.Config; @@ -80,9 +82,20 @@ public class EnchantGenericListener extends AbstractListener curses.forEach((excellentEnchant, level) -> { EnchantManager.addEnchantment(result, excellentEnchant, level, true); }); + EnchantManager.updateEnchantmentsDisplay(result); }); } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantUpdatePickup(EntityPickupItemEvent e) { + if (!(e.getEntity() instanceof Player player)) return; + + Item item = e.getItem(); + ItemStack itemStack = item.getItemStack(); + if (EnchantManager.updateEnchantmentsDisplay(itemStack)) { + item.setItemStack(itemStack); + } + } // --------------------------------------------------------------- // Handle Enchanting Table @@ -117,6 +130,7 @@ public class EnchantGenericListener extends AbstractListener EnchantManager.restoreEnchantmentCharges(result, enchant); } }); + EnchantManager.updateEnchantmentsDisplay(result); e.getInventory().setItem(0, result); }); @@ -177,6 +191,8 @@ public class EnchantGenericListener extends AbstractListener if (Config.getObtainSettings(ObtainType.MOB_SPAWNING).isEmpty()) return; LivingEntity entity = e.getEntity(); + if (Hooks.isMythicMob(entity)) return; + EntityEquipment equipment = entity.getEquipment(); if (equipment == null) return; @@ -184,6 +200,7 @@ public class EnchantGenericListener extends AbstractListener ItemStack item = equipment.getItem(slot); if (EnchantManager.isEnchantable(item)) { EnchantManager.populateEnchantments(item, ObtainType.MOB_SPAWNING); + EnchantManager.getExcellentEnchantments(item).keySet().forEach(enchant -> EnchantManager.restoreEnchantmentCharges(item, enchant)); equipment.setItem(slot, item); } } 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 216149a..d7cb47c 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 @@ -7,6 +7,7 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import org.bukkit.GameMode; +import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.MerchantRecipe; import org.bukkit.inventory.meta.ItemMeta; @@ -82,9 +83,9 @@ public class ProtocolHook { ItemStack copy = new ItemStack(item); ItemMeta meta = copy.getItemMeta(); - if (meta == null) return item; + if (meta == null || meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS)) return item; - Map enchants = EnchantManager.getExcellentEnchantments(item) + Map enchants = EnchantManager.getExcellentEnchantments(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)); @@ -105,7 +106,7 @@ public class ProtocolHook { }); } enchants.forEach((enchant, level) -> { - int charges = EnchantManager.getEnchantmentCharges(item, enchant); + int charges = EnchantManager.getEnchantmentCharges(meta, enchant); lore.add(0, enchant.getNameFormatted(level, charges)); }); diff --git a/NMS/pom.xml b/NMS/pom.xml index 44321c5..a927bcd 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.4 + 3.3.1 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 6399ebd..f9cf26e 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.4 + 3.3.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0.4 + 3.3.1 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 3d0ad72..7b086b9 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.4 + 3.3.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0.4 + 3.3.1 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index 7c2aa0c..0e6a1b8 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.4 + 3.3.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0.4 + 3.3.1 diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml index d34d5bb..da7821c 100644 --- a/V1_19_R2/pom.xml +++ b/V1_19_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.0.4 + 3.3.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.0.4 + 3.3.1 diff --git a/pom.xml b/pom.xml index 0c6d612..49c6380 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.3.0.4 + 3.3.1 Core NMS From 2e4d9b45b709b419b6dd24b73775393a1d01d1d5 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Wed, 15 Feb 2023 14:50:02 +0600 Subject: [PATCH 30/69] Enchants fixes --- .../api/enchantment/ExcellentEnchant.java | 1 + .../nightexpress/excellentenchants/config/Config.java | 3 ++- .../excellentenchants/enchantment/EnchantManager.java | 1 + .../enchantment/impl/armor/EnchantRegrowth.java | 1 + .../enchantment/impl/armor/EnchantSaturation.java | 1 + .../enchantment/impl/weapon/EnchantSurprise.java | 10 ++++------ pom.xml | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index c1adcc2..0b6f982 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -433,5 +433,6 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme @Override public void consumeCharges(@NotNull ItemStack item) { EnchantManager.consumeEnchantmentCharges(item, this); + EnchantManager.updateEnchantmentsDisplay(item); } } 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 69c26f5..4e2b866 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -55,7 +55,8 @@ public class Config { Set.of("enchant_name", "other_enchant"), "A list of enchantments, that will be disabled and removed from the game (server).", "Enchantment names are the same as enchantment file name in /enchants/ folder. ! Must be in lower_case !", - "Example: To disable 'Explosive Arrows' you need to add 'explosive_arrows' here."); + "Example: To disable 'Explosive Arrows' you need to add 'explosive_arrows' here.") + .mapReader(set -> set.stream().map(String::toLowerCase).collect(Collectors.toSet())); public static final JOption>> ENCHANTMENTS_DISABLED_IN_WORLDS = new JOption>>("Enchantments.Disabled_In_Worlds", (cfg, path, def) -> cfg.getSection(path).stream().collect(Collectors.toMap(k -> k, worldName -> cfg.getStringSet(path + "." + worldName))), 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 e50b469..b37052d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java @@ -226,6 +226,7 @@ public class EnchantManager extends AbstractManager { lore.add(0, enchant.getNameFormatted(level, getEnchantmentCharges(meta, enchant))); }); } + else sizeReal = 0; meta.setLore(lore); PDCUtil.set(meta, KEY_LORE_SIZE, sizeReal); 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 95cebf0..6a4c363 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 @@ -132,6 +132,7 @@ public class EnchantRegrowth extends ExcellentEnchant implements PassiveEnchant, for (LivingEntity entity : this.getEntities()) { EnchantManager.getEquippedEnchants(entity, EnchantRegrowth.class).forEach((item, enchants) -> { enchants.forEach((enchant, level) -> { + 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/impl/armor/EnchantSaturation.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSaturation.java index a446ee9..47a898b 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 @@ -114,6 +114,7 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan for (LivingEntity entity : this.getEntities()) { EnchantManager.getEquippedEnchants(entity, EnchantSaturation.class).forEach((item, enchants) -> { enchants.forEach((enchant, level) -> { + 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/impl/weapon/EnchantSurprise.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantSurprise.java index 53b2ccc..1805410 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 @@ -5,6 +5,7 @@ import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.EffectUtil; @@ -44,16 +45,13 @@ public class EnchantSurprise extends PotionEnchant implements Chanced, CombatEnc return EnchantmentTarget.WEAPON; } - @Override - public PotionEffectType getEffectType() { - return Rnd.get(PotionEffectType.values()); - } - @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; + + PotionEffect effect = new PotionEffect(Rnd.get(PotionEffectType.values()), this.getEffectDuration(level), Math.max(0, this.getEffectAmplifier(level) - 1), false, false); + if (!victim.addPotionEffect(effect)) return false; if (this.hasVisualEffects()) { EffectUtil.playEffect(victim.getEyeLocation(), Particle.SPELL_WITCH, "", 0.25, 0.25, 0.25, 0.1f, 30); diff --git a/pom.xml b/pom.xml index 49c6380..0a5669b 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ su.nexmedia NexEngine - 2.2.8 + 2.2.9 From 92e28f82391d003a8315a8fcbf2d2ab5ac10725e Mon Sep 17 00:00:00 2001 From: nulli0n Date: Wed, 22 Feb 2023 23:48:03 +0600 Subject: [PATCH 31/69] Enchants fixes, PL lang, PAPI support --- Core/pom.xml | 10 +++ .../excellentenchants/ExcellentEnchants.java | 5 ++ .../excellentenchants/config/Config.java | 3 +- .../enchantment/EnchantManager.java | 11 ++- .../impl/armor/EnchantRegrowth.java | 13 ++- .../impl/bow/EnchantConfusingArrows.java | 2 + .../impl/bow/EnchantElectrifiedArrows.java | 9 +- .../impl/bow/EnchantExplosiveArrows.java | 10 +-- .../enchantment/impl/bow/EnchantHover.java | 2 + .../impl/bow/EnchantPoisonedArrows.java | 2 + .../impl/bow/EnchantWitheredArrows.java | 2 + .../impl/weapon/EnchantDecapitator.java | 50 +++++++++++ .../impl/weapon/EnchantSurprise.java | 7 +- .../listener/EnchantGenericListener.java | 27 +++--- .../hook/impl/PlaceholderHook.java | 85 +++++++++++++++++++ Core/src/main/resources/lang/messages_pl.yml | 45 +++++++--- Core/src/main/resources/plugin.yml | 39 +-------- 17 files changed, 242 insertions(+), 80 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/PlaceholderHook.java diff --git a/Core/pom.xml b/Core/pom.xml index f0b2304..0d3e595 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -35,6 +35,10 @@ false + + placeholderapi + https://repo.extendedclip.com/content/repositories/placeholderapi/ + @@ -90,6 +94,12 @@ ProtocolLib 5.0.0-SNAPSHOT + + me.clip + placeholderapi + 2.11.2 + provided + diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index c3839ce..139ff70 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -15,6 +15,7 @@ import su.nightexpress.excellentenchants.config.Lang; import su.nightexpress.excellentenchants.enchantment.EnchantManager; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import su.nightexpress.excellentenchants.hook.HookId; +import su.nightexpress.excellentenchants.hook.impl.PlaceholderHook; import su.nightexpress.excellentenchants.hook.impl.ProtocolHook; import su.nightexpress.excellentenchants.nms.EnchantNMS; import su.nightexpress.excellentenchants.nms.v1_17_R1.V1_17_R1; @@ -62,6 +63,7 @@ public class ExcellentEnchants extends NexPlugin { this.tierManager.shutdown(); this.tierManager = null; } + PlaceholderHook.shutdown(); } private boolean setNMS() { @@ -106,6 +108,9 @@ public class ExcellentEnchants extends NexPlugin { Config.ENCHANTMENTS_DISPLAY_MODE.set(1); } } + if (Hooks.hasPlaceholderAPI()) { + PlaceholderHook.setup(); + } } @Override 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 4e2b866..04c1e4d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -5,6 +5,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; 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.Placeholders; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; @@ -30,7 +31,7 @@ public class Config { Placeholders.URL_WIKI + "Charges-System"); public static final JOption> ENCHANTMENTS_CHARGES_FORMAT = new JOption>("Enchantments.Charges.Format", - (cfg, path, def) -> cfg.getSection(path).stream().collect(Collectors.toMap(k -> StringUtil.getDouble(k, 0), v -> StringUtil.color(cfg.getString(path + "." + v, "")), (o,n) -> n, TreeMap::new)), + (cfg, path, def) -> cfg.getSection(path).stream().collect(Collectors.toMap(k -> StringUtil.getDouble(k, 0), v -> Colorizer.apply(cfg.getString(path + "." + v, "")), (o,n) -> n, TreeMap::new)), () -> { TreeMap map = new TreeMap<>(); map.put(0D, "#ff9a9a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); 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 b37052d..b907e47 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java @@ -208,7 +208,7 @@ public class EnchantManager extends AbstractManager { Map enchants = EnchantManager.getExcellentEnchantments(item); int sizeHas = PDCUtil.getInt(item, KEY_LORE_SIZE).orElse(0); - int sizeReal = enchants.size() + enchants.keySet().stream().map(ExcellentEnchant::getDescription).mapToInt(List::size).sum(); + int sizeReal = enchants.size(); ItemMeta meta = item.getItemMeta(); if (meta == null) return false; @@ -219,9 +219,12 @@ public class EnchantManager extends AbstractManager { } if (!meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS)) { - enchants.forEach((enchant, level) -> { - lore.addAll(0, enchant.formatDescription(level)); - }); + 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))); }); 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 6a4c363..dba573b 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 @@ -13,15 +13,17 @@ 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.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.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.task.AbstractEnchantmentTask; import java.util.function.UnaryOperator; -public class EnchantRegrowth extends ExcellentEnchant implements PassiveEnchant, ICleanable { +public class EnchantRegrowth extends ExcellentEnchant implements Chanced, PassiveEnchant, ICleanable { public static final String ID = "regrowth"; @@ -35,6 +37,7 @@ public class EnchantRegrowth extends ExcellentEnchant implements PassiveEnchant, private EnchantScaler healMaxHealth; private EnchantScaler healAmount; + private ChanceImplementation chanceImplementation; private Task task; public EnchantRegrowth(@NotNull ExcellentEnchants plugin) { @@ -45,6 +48,7 @@ public class EnchantRegrowth extends ExcellentEnchant implements PassiveEnchant, @Override public void loadConfig() { super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); 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", @@ -81,6 +85,12 @@ public class EnchantRegrowth extends ExcellentEnchant implements PassiveEnchant, ; } + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { @@ -106,6 +116,7 @@ public class EnchantRegrowth extends ExcellentEnchant implements PassiveEnchant, @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { if (!this.isAvailableToUse(entity)) return false; + if (!this.checkTriggerChance(level)) return false; double healthMax = EntityUtil.getAttribute(entity, Attribute.GENERIC_MAX_HEALTH); double healthHas = entity.getHealth(); 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 e11203a..eeebde6 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,6 +1,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; @@ -61,6 +62,7 @@ public class EnchantConfusingArrows extends PotionEnchant implements Chanced, Ar if (!(e.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; + arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); return arrow.addCustomEffect(this.createEffect(level), true); } 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 cfbdd90..bd26d58 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 @@ -4,6 +4,7 @@ import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Item; +import org.bukkit.entity.ItemFrame; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; @@ -100,9 +101,9 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onItemDamage(EntityDamageByEntityEvent e) { if (!e.getDamager().hasMetadata(META_NO_ITEM_DAMAGE)) return; - if (!(e.getEntity() instanceof Item item)) return; - - e.setCancelled(true); - item.setFireTicks(0); + if (e.getEntity() instanceof Item || e.getEntity() instanceof ItemFrame) { + e.setCancelled(true); + e.getEntity().setFireTicks(0); + } } } 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 f7673a7..9686a5d 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 @@ -2,10 +2,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; import org.bukkit.World; import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Projectile; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -138,8 +135,9 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, if (e.getCause() != EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) return; if (this.explosionDamageItems) return; if (!e.getDamager().hasMetadata(META_EXPLOSION_SOURCE)) return; - if (!(e.getEntity() instanceof Item item)) return; - e.setCancelled(true); + if (e.getEntity() instanceof Item || e.getEntity() instanceof ItemFrame) { + e.setCancelled(true); + } } } 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 405d206..76e187d 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,6 +1,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; @@ -61,6 +62,7 @@ public class EnchantHover extends PotionEnchant implements Chanced, Arrowed, Bow if (!(e.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; + arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); return arrow.addCustomEffect(this.createEffect(level), true); } 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 7764532..e05ca02 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,6 +1,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; @@ -61,6 +62,7 @@ public class EnchantPoisonedArrows extends PotionEnchant implements Chanced, Arr if (!(e.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; + arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); return arrow.addCustomEffect(this.createEffect(level), true); } 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 5614164..9f8eca4 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,6 +1,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; @@ -61,6 +62,7 @@ public class EnchantWitheredArrows extends PotionEnchant implements Chanced, Arr if (!(e.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; + arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); return arrow.addCustomEffect(this.createEffect(level), 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 24e327d..5a28bbd 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 @@ -2,18 +2,27 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.Particle; +import org.bukkit.block.Skull; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockDropItemEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDeathEvent; 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.lang.LangManager; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.ItemUtil; +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; @@ -37,8 +46,11 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea private Map headTextures; private ChanceImplementation chanceImplementation; + private final NamespacedKey skullKey; + public EnchantDecapitator(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.skullKey = new NamespacedKey(plugin, this.getId() + ".entity_type"); } @Override @@ -132,6 +144,7 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea meta.setDisplayName(entityName); item.setItemMeta(meta); } + PDCUtil.set(item, this.skullKey, entityType.name()); entity.getWorld().dropItemNaturally(entity.getLocation(), item); @@ -140,4 +153,41 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea } return true; } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBlockPlace(BlockPlaceEvent e) { + if (!(e.getBlock().getState() instanceof Skull skull)) return; + + ItemStack skullItem = e.getItemInHand(); + PDCUtil.getString(skullItem, this.skullKey).ifPresent(type -> { + PDCUtil.set(skull, this.skullKey, type); + skull.update(true); + }); + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBlockPlace(BlockDropItemEvent e) { + 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; + + e.getItems().forEach(item -> { + ItemStack drop = item.getItemStack(); + if (drop.getType() == Material.PLAYER_HEAD) { + ItemUtil.setSkullTexture(drop, texture); + ItemUtil.mapMeta(drop, meta -> { + String name = this.headName.replace(Placeholders.GENERIC_TYPE, LangManager.getEntityType(entityType)); + meta.setDisplayName(name); + PDCUtil.set(meta, this.skullKey, type); + }); + } + item.setItemStack(drop); + }); + }); + } } 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 1805410..9a4ef6c 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 @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; +import org.bukkit.Color; import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; @@ -8,7 +9,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; 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.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -54,7 +55,9 @@ public class EnchantSurprise extends PotionEnchant implements Chanced, CombatEnc if (!victim.addPotionEffect(effect)) return false; if (this.hasVisualEffects()) { - EffectUtil.playEffect(victim.getEyeLocation(), Particle.SPELL_WITCH, "", 0.25, 0.25, 0.25, 0.1f, 30); + Color color = Color.fromRGB(Rnd.nextInt(256), Rnd.nextInt(256), Rnd.nextInt(256)); + Particle.DustOptions dustOptions = new Particle.DustOptions(color, 2f); + SimpleParticle.of(Particle.REDSTONE, dustOptions).play(victim.getEyeLocation(), 0.25, 0.1, 25); } 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 c8b6f14..07f13c5 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 @@ -188,21 +188,24 @@ public class EnchantGenericListener extends AbstractListener @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEnchantPopulateSpawn(CreatureSpawnEvent e) { - if (Config.getObtainSettings(ObtainType.MOB_SPAWNING).isEmpty()) return; - + //if (Config.getObtainSettings(ObtainType.MOB_SPAWNING).isEmpty()) return; LivingEntity entity = e.getEntity(); - if (Hooks.isMythicMob(entity)) return; - EntityEquipment equipment = entity.getEquipment(); - if (equipment == null) return; + this.plugin.runTaskLater(task -> { + EntityEquipment equipment = entity.getEquipment(); + if (equipment == null) return; - for (EquipmentSlot slot : EquipmentSlot.values()) { - ItemStack item = equipment.getItem(slot); - if (EnchantManager.isEnchantable(item)) { - EnchantManager.populateEnchantments(item, ObtainType.MOB_SPAWNING); - EnchantManager.getExcellentEnchantments(item).keySet().forEach(enchant -> EnchantManager.restoreEnchantmentCharges(item, enchant)); - equipment.setItem(slot, item); + boolean isMythic = Hooks.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)); + equipment.setItem(slot, item); + } } - } + }, 40L); } } 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 new file mode 100644 index 0000000..4421ea2 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/PlaceholderHook.java @@ -0,0 +1,85 @@ +package su.nightexpress.excellentenchants.hook.impl; + +import me.clip.placeholderapi.expansion.PlaceholderExpansion; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; +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; + +public class PlaceholderHook { + + private static EnchantsExpansion expansion; + + public static void setup() { + if (expansion == null) { + expansion = new EnchantsExpansion(); + expansion.register(); + } + } + + public static void shutdown() { + if (expansion != null) { + expansion.unregister(); + expansion = null; + } + } + + static class EnchantsExpansion extends PlaceholderExpansion { + + @Override + @NotNull + public String getIdentifier() { + return "excellentenchants"; + } + + @Override + @NotNull + public String getAuthor() { + return ExcellentEnchantsAPI.PLUGIN.getDescription().getAuthors().get(0); + } + + @Override + @NotNull + public String getVersion() { + return ExcellentEnchantsAPI.PLUGIN.getDescription().getVersion(); + } + + @Override + @Nullable + public String onPlaceholderRequest(Player player, @NotNull String params) { + if (params.startsWith("charges_remaining_")) { + String[] chargesSplit = params.substring("charges_remaining_".length()).split(":"); + if (chargesSplit.length < 2) return null; + + EquipmentSlot slot = StringUtil.getEnum(chargesSplit[0], EquipmentSlot.class).orElse(null); + if (slot == null) return null; + + ItemStack item = player.getInventory().getItem(slot); + if (item == null || item.getType().isAir()) return "-"; + + ExcellentEnchant enchant = EnchantRegister.get(NamespacedKey.minecraft(chargesSplit[1].toLowerCase())); + if (enchant == null) return null; + + return String.valueOf(enchant.getCharges(item)); + } + if (params.startsWith("charges_maximum_")) { + String[] chargesSplit = params.substring("charges_maximum_".length()).split(":"); + if (chargesSplit.length < 2) return null; + + ExcellentEnchant enchant = EnchantRegister.get(NamespacedKey.minecraft(chargesSplit[0].toLowerCase())); + if (enchant == null) return null; + + int level = StringUtil.getInteger(chargesSplit[1], 1); + + return String.valueOf(enchant.getChargesMax(level)); + } + return super.onPlaceholderRequest(player, params); + } + } +} diff --git a/Core/src/main/resources/lang/messages_pl.yml b/Core/src/main/resources/lang/messages_pl.yml index 0470bfb..d70c887 100644 --- a/Core/src/main/resources/lang/messages_pl.yml +++ b/Core/src/main/resources/lang/messages_pl.yml @@ -1,18 +1,37 @@ -# Przetłumaczone przez nitolar play -# Tłumaczenie utworzono: 06.11.2020 Command: + List: + Desc: Lista wszystkich customowych enchantów. Enchant: - Usage: - Desc: Zaklnij przedmiot w swojej ręce. - Done: '&aSukcesywnie Zaklnięto!' + Usage: + Desc: Zaklina przedmiot trzymany w łapce. + Done: '&aPomyślnie zaklęto!' Book: - Usage: - Desc: Dodaje niestandardowo zaklniętą książke. - Done: Dodano zaklniętą ksiązke z zaklęciem &6%enchant%&7 do gracza &6%player%&7. + Usage: + Desc: Daje książkę z customowym enchantem. + Done: Przyznano zaklętą książkę &6%enchant%&7 dla &6%player_display_name%&7. TierBook: - Usage: <żadkość> - Desc: Dodaje zaklniętą książke. - Error: '&cZły poziom żadkości!' - Done: Dodano zaklniętą ksiązke z zaklęciem &6%enchant%&7 do gracza &6%player%&7. + Usage: + Desc: Daje książkę z enchantem. + Error: '&cZły poziom!' + Done: Przyznano zaklętą książkę &6%tier_name%&7 dla &6%player_display_name%&7. Error: - NoEnchant: '&cNie ma takiego zaklęcia.' \ No newline at end of file + NoEnchant: '&cNiepoprawny enchant.' +FitItemType: + HELMET: Hełm + CHESTPLATE: Napierśnik + LEGGINGS: Spodnie + BOOTS: Buty + ELYTRA: Elytra + WEAPON: Broń + TOOL: Narzędzie + ARMOR: Zbroja + UNIVERSAL: Uniwersalny + SWORD: Miecz + TRIDENT: Trójząb + AXE: Siekiera + BOW: Łuk + CROSSBOW: Kusza + HOE: Motyka + PICKAXE: Kilof + SHOVEL: Łopata + FISHING_ROD: Wędka \ No newline at end of file diff --git a/Core/src/main/resources/plugin.yml b/Core/src/main/resources/plugin.yml index 9ab8ab6..d51072f 100644 --- a/Core/src/main/resources/plugin.yml +++ b/Core/src/main/resources/plugin.yml @@ -4,41 +4,6 @@ name: ExcellentEnchants author: NightExpress desciption: Vanilla-like enchants for your server. depend: [ NexEngine ] -softdepend: [ ProtocolLib, NoCheatPlus ] +softdepend: [ ProtocolLib, NoCheatPlus, PlaceholderAPI ] api-version: 1.17 -load: STARTUP - -permissions: - excellentenchants.admin: - description: Grants access to all plugin functions. - default: op - children: - excellentenchants.user: true - excellentenchants.command: true - - excellentenchants.user: - description: Grants access to basic player plugin functions. - default: true - - excellentenchants.command: - description: Grants access to all the plugin commands. - default: op - children: - excellentenchants.command.book: true - excellentenchants.command.enchant: true - excellentenchants.command.list: true - excellentenchants.command.tierbook: true - - excellentenchants.command.book: - description: Grants access to /eenchants book command. - default: op - excellentenchants.command.enchant: - description: Grants access to /eenchants enchant command. - default: op - excellentenchants.command.list: - description: Grants access to /eenchants list command. - default: true - excellentenchants.command.tierbook: - description: Grants access to /eenchants tierbook command. - default: op - +load: STARTUP \ No newline at end of file From 38af06c3d362988953a1f109d7084af81a777643 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Wed, 12 Apr 2023 16:04:42 +0600 Subject: [PATCH 32/69] v3.3.3 --- .gitignore | 4 +- Core/pom.xml | 17 +++-- .../excellentenchants/ExcellentEnchants.java | 2 + .../api/enchantment/ExcellentEnchant.java | 15 ++-- .../api/enchantment/meta/Potioned.java | 9 --- .../command/BookCommand.java | 3 +- .../command/TierbookCommand.java | 3 +- .../excellentenchants/config/Config.java | 36 ++++++---- .../enchantment/EnchantManager.java | 64 ++++++----------- .../impl/armor/EnchantAquaman.java | 2 +- .../impl/armor/EnchantBunnyHop.java | 2 +- .../impl/armor/EnchantNightVision.java | 2 +- .../enchantment/impl/armor/EnchantSonic.java | 2 +- .../enchantment/impl/bow/EnchantEnderBow.java | 19 ++++- .../enchantment/impl/bow/EnchantGhast.java | 13 +++- .../impl/meta/ArrowImplementation.java | 4 +- .../impl/meta/PotionImplementation.java | 25 +++---- .../impl/tool/EnchantBlastMining.java | 5 +- .../impl/tool/EnchantDivineTouch.java | 4 +- .../enchantment/impl/tool/EnchantHaste.java | 2 +- .../impl/tool/EnchantReplanter.java | 21 ++++-- .../impl/tool/EnchantSilkChest.java | 11 +-- .../impl/tool/EnchantTelekinesis.java | 19 ++++- .../enchantment/impl/tool/EnchantTunnel.java | 3 +- .../impl/tool/EnchantVeinminer.java | 3 +- .../impl/weapon/EnchantNimble.java | 19 ++++- .../impl/weapon/EnchantThrifty.java | 4 +- .../listener/EnchantAnvilListener.java | 6 +- .../listener/EnchantGenericListener.java | 12 +--- .../menu/EnchantmentsListMenu.java | 11 +-- .../excellentenchants/tier/Tier.java | 4 +- NMS/pom.xml | 2 +- .../excellentenchants/nms/EnchantNMS.java | 48 +------------ V1_17_R1/pom.xml | 4 +- .../nms/v1_17_R1/CustomEffectInstance.java | 48 ------------- .../nms/v1_17_R1/V1_17_R1.java | 28 +++----- V1_18_R2/pom.xml | 4 +- .../nms/v1_18_R2/CustomEffectInstance.java | 48 ------------- .../nms/v1_18_R2/V1_18_R2.java | 28 +++----- V1_19_R1/pom.xml | 4 +- .../nms/v1_19_R1/CustomEffectInstance.java | 48 ------------- .../nms/v1_19_R1/V1_19_R1.java | 28 +++----- V1_19_R2/pom.xml | 4 +- .../nms/v1_19_R2/CustomEffectInstance.java | 50 ------------- .../nms/v1_19_R2/V1_19_R2.java | 28 +++----- V1_19_R3/pom.xml | 71 +++++++++++++++++++ .../nms/v1_19_R3/V1_19_R3.java | 68 ++++++++++++++++++ pom.xml | 5 +- 48 files changed, 389 insertions(+), 473 deletions(-) delete mode 100644 V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java delete mode 100644 V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java delete mode 100644 V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java delete mode 100644 V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java create mode 100644 V1_19_R3/pom.xml create mode 100644 V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java diff --git a/.gitignore b/.gitignore index 3438c0f..e400327 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,6 @@ /V1_19_R1/target/ /V1_19_R1/pom.xml.versionsBackup /V1_19_R2/target/ -/V1_19_R2/pom.xml.versionsBackup \ No newline at end of file +/V1_19_R2/pom.xml.versionsBackup +/V1_19_R3/target/ +/V1_19_R3/pom.xml.versionsBackup \ No newline at end of file diff --git a/Core/pom.xml b/Core/pom.xml index 0d3e595..a3238c8 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.1 + 3.3.3 4.0.0 @@ -55,27 +55,32 @@ su.nightexpress.excellentenchants NMS - 3.3.1 + 3.3.3 su.nightexpress.excellentenchants V1_17_R1 - 3.3.1 + 3.3.3 su.nightexpress.excellentenchants V1_18_R2 - 3.3.1 + 3.3.3 su.nightexpress.excellentenchants V1_19_R1 - 3.3.1 + 3.3.3 su.nightexpress.excellentenchants V1_19_R2 - 3.3.1 + 3.3.3 + + + su.nightexpress.excellentenchants + V1_19_R3 + 3.3.3 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 139ff70..1e39860 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -22,6 +22,7 @@ import su.nightexpress.excellentenchants.nms.v1_17_R1.V1_17_R1; import su.nightexpress.excellentenchants.nms.v1_18_R2.V1_18_R2; import su.nightexpress.excellentenchants.nms.v1_19_R1.V1_19_R1; import su.nightexpress.excellentenchants.nms.v1_19_R2.V1_19_R2; +import su.nightexpress.excellentenchants.nms.v1_19_R3.V1_19_R3; import su.nightexpress.excellentenchants.tier.TierManager; public class ExcellentEnchants extends NexPlugin { @@ -72,6 +73,7 @@ public class ExcellentEnchants extends NexPlugin { case V1_18_R2 -> new V1_18_R2(); case V1_19_R1 -> new V1_19_R1(); case V1_19_R2 -> new V1_19_R2(); + case V1_19_R3 -> new V1_19_R3(); }; return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java index 0b6f982..be97278 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/ExcellentEnchant.java @@ -12,10 +12,7 @@ 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.ItemUtil; -import su.nexmedia.engine.utils.NumberUtil; -import su.nexmedia.engine.utils.Scaler; -import su.nexmedia.engine.utils.StringUtil; +import su.nexmedia.engine.utils.*; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; @@ -77,7 +74,8 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme this.cfg.reload(); this.displayName = JOption.create("Name", StringUtil.capitalizeFully(this.getId().replace("_", " ")), - "Enchantment display name. It will be shown in item lore.").read(cfg); + "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)); @@ -88,7 +86,8 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme 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).read(cfg); + "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.", @@ -250,8 +249,8 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme if (!this.isChargesEnabled() || charges < 0) return this.getNameFormatted(level); int chargesMax = this.getChargesMax(level); - double percent = (double) charges / (double) chargesMax * 100D; - Map.Entry entry = Config.ENCHANTMENTS_CHARGES_FORMAT.get().floorEntry(percent); + int percent = (int) Math.ceil((double) charges / (double) chargesMax * 100D); + Map.Entry entry = Config.ENCHANTMENTS_CHARGES_FORMAT.get().floorEntry(percent); if (entry == null) return this.getNameFormatted(level); String format = entry.getValue().replace(Placeholders.GENERIC_AMOUNT, String.valueOf(charges)); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Potioned.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Potioned.java index ddc2c34..246074a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Potioned.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Potioned.java @@ -9,11 +9,6 @@ public interface Potioned { @NotNull Potioned getPotionImplementation(); - /*@NotNull - default UnaryOperator replacePlaceholders(int level) { - return this.getPotionImplementation().replacePlaceholders(level); - }*/ - default boolean isPermanent() { return this.getPotionImplementation().isPermanent(); } @@ -34,10 +29,6 @@ public interface Potioned { return this.getPotionImplementation().createEffect(level); } - default boolean hasEffect(@NotNull LivingEntity target) { - return this.getPotionImplementation().hasEffect(target); - } - default boolean addEffect(@NotNull LivingEntity target, int level) { return this.getPotionImplementation().addEffect(target, level); } 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 8733f39..8a218a7 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java @@ -9,6 +9,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.command.AbstractCommand; 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; @@ -49,7 +50,7 @@ public class BookCommand extends AbstractCommand { @NotNull public List getTab(@NotNull Player player, int arg, @NotNull String[] args) { if (arg == 1) { - return PlayerUtil.getPlayerNames(); + return CollectionsUtil.playerNames(player); } if (arg == 2) { return Arrays.stream(Enchantment.values()).map(e -> e.getKey().getKey()).toList(); 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 d5a3da9..f39631a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java @@ -6,6 +6,7 @@ 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.CollectionsUtil; import su.nexmedia.engine.utils.Placeholders; import su.nexmedia.engine.utils.PlayerUtil; import su.nexmedia.engine.utils.StringUtil; @@ -48,7 +49,7 @@ public class TierbookCommand extends AbstractCommand { @NotNull public List getTab(@NotNull Player player, int arg, @NotNull String[] args) { if (arg == 1) { - return PlayerUtil.getPlayerNames(); + return CollectionsUtil.playerNames(player); } if (arg == 2) { return plugin.getTierManager().getTierIds(); 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 04c1e4d..0b75685 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -21,23 +21,34 @@ 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", 150L, - "Sets how often (in ticks) the plugin will apply permanent potion effects from enchanted items to an entity who wear them.", - "This setting does NOT refreshes currently active effects, but only attempts to add them if absent." + 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, "Enables the enchantment Charges feature.", Placeholders.URL_WIKI + "Charges-System"); - public static final JOption> ENCHANTMENTS_CHARGES_FORMAT = new JOption>("Enchantments.Charges.Format", - (cfg, path, def) -> cfg.getSection(path).stream().collect(Collectors.toMap(k -> StringUtil.getDouble(k, 0), v -> Colorizer.apply(cfg.getString(path + "." + v, "")), (o,n) -> n, TreeMap::new)), + public static final JOption> ENCHANTMENTS_CHARGES_FORMAT = new JOption>("Enchantments.Charges.Format", + (cfg, path, def) -> { + TreeMap map = new TreeMap<>(); + for (String raw : cfg.getSection(path)) { + int percent = StringUtil.getInteger(raw, -1); + if (percent < 0) continue; + + String format = Colorizer.apply(cfg.getString(path + "." + raw, "")); + if (format.isEmpty()) continue; + + map.put(percent, format); + } + return map; + }, () -> { - TreeMap map = new TreeMap<>(); - map.put(0D, "#ff9a9a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); - map.put(25D, "#ffc39a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); - map.put(50D, "#f6ff9a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); - map.put(75D, "#bcff9a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); + TreeMap map = new TreeMap<>(); + map.put(0, "#ff9a9a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); + map.put(25, "#ffc39a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); + map.put(50, "#f6ff9a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); + map.put(75, "#bcff9a(" + Placeholders.GENERIC_AMOUNT + "⚡)"); return map; }, "Enchantment charges format depends on amount of charges left (in percent).", @@ -76,12 +87,11 @@ public class Config { public static final JOption ENCHANTMENTS_DESCRIPTION_ENABLED = JOption.create("Enchantments.Description.Enabled", true, "When 'true', adds the enchantment description to item lore under enchantment names.", - "Note #1: You must have ProtocolLib installed for this feature to work (as well as for enchantments name display).", - "Note #2: Description is not shown while you're in Creative gamemode."); + "For Display-Mode = 2 description is not shown while you're in Creative gamemode."); public static final JOption ENCHANTMENTS_DESCRIPTION_FORMAT = JOption.create("Enchantments.Description.Format", "&8▸ " + Placeholders.GENERIC_DESCRIPTION, - "Sets the global enchantment description format."); + "Sets the global enchantment description format.").mapReader(Colorizer::apply); public static final JOption ENCHANTMENTS_ITEM_CUSTOM_MAX = JOption.create("Enchantments.Item.Max_Custom_Enchants", 3, "How many of custom enchantments the item can contain at the same time?"); 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 b907e47..d72f33d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java @@ -10,14 +10,12 @@ import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.potion.PotionEffect; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; 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.Pair; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; @@ -38,7 +36,6 @@ 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 EnchantManager extends AbstractManager { @@ -217,6 +214,7 @@ public class EnchantManager extends AbstractManager { 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()) { @@ -232,7 +230,9 @@ public class EnchantManager extends AbstractManager { else sizeReal = 0; meta.setLore(lore); - PDCUtil.set(meta, KEY_LORE_SIZE, sizeReal); + if (sizeReal > 0) { + PDCUtil.set(meta, KEY_LORE_SIZE, sizeReal); + } item.setItemMeta(meta); return true; } @@ -261,11 +261,11 @@ public class EnchantManager extends AbstractManager { } public static int getEnchantmentCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { - return enchant.isChargesEnabled() ? PDCUtil.getIntData(item, enchant.getChargesKey()) : -1; + 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.getIntData(meta, enchant.getChargesKey()) : -1; + return enchant.isChargesEnabled() ? PDCUtil.getInt(meta, enchant.getChargesKey()).orElse(0) : -1; } public static boolean isEnchantmentOutOfCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { @@ -311,7 +311,7 @@ public class EnchantManager extends AbstractManager { int level = getEnchantmentLevel(item, enchant); int max = enchant.getChargesMax(level); - PDCUtil.setData(item, enchant.getChargesKey(), Math.max(0, Math.min(charges, max))); + PDCUtil.set(item, enchant.getChargesKey(), Math.max(0, Math.min(charges, max))); } public static int getExcellentEnchantmentsAmount(@NotNull ItemStack item) { @@ -330,44 +330,26 @@ public class EnchantManager extends AbstractManager { @NotNull private static Map getExcellentEnchantments(@NotNull Map enchants) { - return enchants.entrySet().stream() - .map(entry -> { - ExcellentEnchant enchant = EnchantRegister.get(entry.getKey().getKey()); - return enchant == null ? null : Pair.of(enchant, entry.getValue()); - }) - .filter(Objects::nonNull) - //.sorted(Comparator.comparing(p -> p.getFirst().getPriority(), Comparator.reverseOrder())) - .collect(Collectors.toMap(Pair::getFirst, Pair::getSecond, (old, nev) -> nev, LinkedHashMap::new)); + Map map = new HashMap<>(); + enchants.forEach((enchantment, level) -> { + ExcellentEnchant excellent = EnchantRegister.get(enchantment.getKey()); + if (excellent != null) { + map.put(excellent, level); + } + }); + return map; } - @SuppressWarnings("unchecked") @NotNull public static Map getExcellentEnchantments(@NotNull ItemStack item, @NotNull Class clazz) { - return EnchantManager.getEnchantments(item).entrySet().stream() - .map(entry -> { - ExcellentEnchant enchant = EnchantRegister.get(entry.getKey().getKey()); - if (enchant == null || !clazz.isAssignableFrom(enchant.getClass())) return null; - return Pair.of((T) enchant, entry.getValue()); - }) - .filter(Objects::nonNull) - .sorted(Comparator.comparing(p -> p.getFirst().getPriority(), Comparator.reverseOrder())) - .collect(Collectors.toMap(Pair::getFirst, Pair::getSecond, (old, nev) -> nev, LinkedHashMap::new)); - } + Map map = new HashMap<>(); + EnchantManager.getEnchantments(item).forEach((enchantment, level) -> { + ExcellentEnchant excellent = EnchantRegister.get(enchantment.getKey()); + if (excellent == null || !clazz.isAssignableFrom(excellent.getClass())) return; - @Nullable - public static ExcellentEnchant getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect effect) { - Enchantment enchantment = ExcellentEnchantsAPI.PLUGIN.getEnchantNMS().getEnchantmentByEffect(entity, effect); - if (enchantment instanceof ExcellentEnchant enchant) return enchant; - - return null; - } - - public static boolean isEnchantmentEffect(@NotNull LivingEntity entity, @NotNull PotionEffect effect) { - return getEnchantmentByEffect(entity, effect) != null; - } - - public static boolean hasEnchantmentEffect(@NotNull LivingEntity entity, @NotNull ExcellentEnchant enchant) { - return entity.getActivePotionEffects().stream().anyMatch(effect -> enchant.equals(getEnchantmentByEffect(entity, effect))); + map.put(clazz.cast(excellent), level); + }); + return CollectionsUtil.sort(map, Comparator.comparing(p -> p.getKey().getPriority(), Comparator.reverseOrder())); } @NotNull 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 7739947..86edb87 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 @@ -26,7 +26,7 @@ public class EnchantAquaman extends PotionEnchant implements PassiveEnchant { @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(entity) || this.hasEffect(entity)) return false; + if (!this.isAvailableToUse(entity)) return false; return this.addEffect(entity, level); } 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 3733489..eaae375 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 @@ -26,7 +26,7 @@ public class EnchantBunnyHop extends PotionEnchant implements PassiveEnchant { @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(entity) || this.hasEffect(entity)) return false; + if (!this.isAvailableToUse(entity)) return false; return this.addEffect(entity, level); } 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 e17a10b..ce0cc87 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 @@ -26,7 +26,7 @@ public class EnchantNightVision extends PotionEnchant implements PassiveEnchant @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(entity) || this.hasEffect(entity)) return false; + if (!this.isAvailableToUse(entity)) return false; return this.addEffect(entity, level); } 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 d59dc39..24364db 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 @@ -26,7 +26,7 @@ public class EnchantSonic extends PotionEnchant implements PassiveEnchant { @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(entity) || this.hasEffect(entity)) return false; + if (!this.isAvailableToUse(entity)) return false; return this.addEffect(entity, level); } 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 8c266f5..32ac5a5 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 @@ -11,17 +11,33 @@ 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.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; import su.nightexpress.excellentenchants.api.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; -public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant { +public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Chanced { public static final String ID = "ender_bow"; + private ChanceImplementation chanceImplementation; + public EnchantEnderBow(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGHEST); } + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + @Override @NotNull public EnchantmentTarget getItemTarget() { @@ -31,6 +47,7 @@ public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant { @Override public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; + if (!this.checkTriggerChance(level)) return false; if (!(e.getProjectile() instanceof Projectile projectile)) return false; EnderPearl pearl = shooter.launchProjectile(EnderPearl.class); 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 5e76735..f0f8367 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 @@ -15,17 +15,20 @@ 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.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.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; -public class EnchantGhast extends ExcellentEnchant implements BowEnchant { +public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chanced { public static final String ID = "ghast"; private boolean fireSpread; private EnchantScaler yield; + private ChanceImplementation chanceImplementation; public EnchantGhast(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGHEST); @@ -34,12 +37,19 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant { @Override public void loadConfig() { super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); 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, "Fireball explosion size/radius. The more value = the bigger the explosion."); } + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + public boolean isFireSpread() { return fireSpread; } @@ -57,6 +67,7 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant { @Override public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; + if (!this.checkTriggerChance(level)) return false; if (!(e.getProjectile() instanceof Projectile projectile)) return false; Fireball fireball; 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 dee5ebe..944e9c9 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 @@ -81,12 +81,12 @@ public final class ArrowImplementation implements Arrowed { @Override public void addData(@NotNull Projectile projectile) { - PDCUtil.setData(projectile, this.getProjectileKey(), this.enchant.getId()); + PDCUtil.set(projectile, this.getProjectileKey(), this.enchant.getId()); } @Override public boolean isOurProjectile(@NotNull Projectile projectile) { - String enchantId = PDCUtil.getStringData(projectile, this.getProjectileKey()); + String enchantId = PDCUtil.getString(projectile, this.getProjectileKey()).orElse(null); return this.enchant.getId().equalsIgnoreCase(enchantId); } } 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 2a4d287..84a9c03 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 @@ -5,11 +5,10 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.Scaler; -import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; public final class PotionImplementation implements Potioned { @@ -18,14 +17,14 @@ public final class PotionImplementation implements Potioned { 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 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) { - this.enchant = enchant; + //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."); @@ -55,6 +54,13 @@ public final class PotionImplementation implements Potioned { } public int getEffectDuration(int level) { + if (this.isPermanent()) { + int duration = Config.TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL.get().intValue() + 30; + if (this.getEffectType().getName().equalsIgnoreCase(PotionEffectType.NIGHT_VISION.getName())) { + duration += 30 * 20; + } + return duration; + } return (int) (this.duration.getValue(level) * 20); } @@ -70,17 +76,8 @@ public final class PotionImplementation implements Potioned { return new PotionEffect(this.getEffectType(), duration, amplifier, false, false); } - public boolean hasEffect(@NotNull LivingEntity entity) { - return EnchantManager.hasEnchantmentEffect(entity, this.enchant); - } - public boolean addEffect(@NotNull LivingEntity target, int level) { - if (this.isPermanent()) { - ExcellentEnchantsAPI.PLUGIN.getEnchantNMS().addEnchantmentEffect(target, this.enchant, this.createEffect(level)); - } - else { - target.addPotionEffect(this.createEffect(level)); - } + target.addPotionEffect(this.createEffect(level)); return true; } } 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 80605a4..21ac6c2 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 @@ -74,7 +74,7 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo } private boolean isBlockHardEnough(@NotNull Block block, int level) { - float strength = plugin.getNMS().getBlockStrength(block); + float strength = block.getType().getHardness();//plugin.getNMS().getBlockStrength(block); return (strength >= this.getMinBlockStrength(level)); } @@ -136,7 +136,8 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo // Break all 'exploded' blocks by a player, adding metadata to them to prevent trigger enchantment in a loop. blockList.forEach(block -> { block.setMetadata(META_EXPLOSION_MINED, new FixedMetadataValue(plugin, true)); - plugin.getNMS().breakBlock(player, block); + //plugin.getNMS().breakBlock(player, block); + player.breakBlock(block); block.removeMetadata(META_EXPLOSION_MINED, plugin); }); 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 5bbf247..68a184d 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,6 +18,7 @@ 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.utils.Colorizer; import su.nexmedia.engine.utils.EffectUtil; import su.nexmedia.engine.utils.LocationUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -49,7 +50,8 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo this.chanceImplementation = ChanceImplementation.create(this); 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.").read(cfg); + "Placeholder '" + Placeholders.GENERIC_TYPE + "' for the mob type.") + .mapReader(Colorizer::apply).read(cfg); } @NotNull 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 3009687..ec9b412 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 @@ -26,7 +26,7 @@ public class EnchantHaste extends PotionEnchant implements PassiveEnchant { @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(entity) || this.hasEffect(entity)) return false; + if (!this.isAvailableToUse(entity)) return false; return this.addEffect(entity, level); } 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 d7d0656..c9dc4f9 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 @@ -18,20 +18,24 @@ 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.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.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import java.util.Set; -public class EnchantReplanter extends ExcellentEnchant implements InteractEnchant, BlockBreakEnchant { +public class EnchantReplanter extends ExcellentEnchant implements Chanced, InteractEnchant, BlockBreakEnchant { public static final String ID = "replanter"; private boolean replantOnRightClick; private boolean replantOnPlantBreak; + private ChanceImplementation chanceImplementation; + private static final Set CROPS = Set.of( Material.WHEAT_SEEDS, Material.BEETROOT_SEEDS, Material.MELON_SEEDS, Material.PUMPKIN_SEEDS, @@ -44,12 +48,19 @@ public class EnchantReplanter extends ExcellentEnchant implements InteractEnchan @Override public void loadConfig() { super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); 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, "When 'true', crops will be automatically replanted when player break plants with enchanted tool in hand.").read(cfg); } + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + public boolean isReplantOnPlantBreak() { return replantOnPlantBreak; } @@ -107,8 +118,9 @@ public class EnchantReplanter extends ExcellentEnchant implements InteractEnchan @Override public boolean onInteract(@NotNull PlayerInteractEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(player)) return false; if (!this.isReplantOnRightClick()) return false; + if (!this.isAvailableToUse(player)) return false; + if (!this.checkTriggerChance(level)) return false; // Check for a event hand. We dont want to trigger it twice. if (e.getHand() != EquipmentSlot.HAND) return false; @@ -133,7 +145,7 @@ public class EnchantReplanter extends ExcellentEnchant implements InteractEnchan || seed != Material.NETHER_WART && blockGround.getType() == Material.FARMLAND) { if (this.takeSeeds(player, seed)) { MessageUtil.sound(player, seed == Material.NETHER_WART ? Sound.ITEM_NETHER_WART_PLANT : Sound.ITEM_CROP_PLANT); - plugin.getNMS().sendAttackPacket(player, 0); + plugin.getEnchantNMS().sendAttackPacket(player, 0); blockPlant.setType(this.fineSeedsToBlock(seed)); break; } @@ -144,8 +156,9 @@ public class EnchantReplanter extends ExcellentEnchant implements InteractEnchan @Override public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(player)) return false; if (!this.isReplantOnPlantBreak()) return false; + if (!this.isAvailableToUse(player)) return false; + if (!this.checkTriggerChance(level)) return false; Block blockPlant = e.getBlock(); //if (EnchantTelekinesis.isDropHandled(blockPlant)) return false; 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 51cc897..de82e2f 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 @@ -20,6 +20,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BlockStateMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; +import su.nexmedia.engine.utils.Colorizer; import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PDCUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -59,10 +60,10 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha super.loadConfig(); this.chestName = JOption.create("Settings.Chest_Item.Name", "Chest &7(" + Placeholders.GENERIC_AMOUNT + " items)", "Chest item display name.", - "Use '" + Placeholders.GENERIC_AMOUNT + "' for items amount.").read(cfg); + "Use '" + Placeholders.GENERIC_AMOUNT + "' for items amount.").mapReader(Colorizer::apply).read(cfg); this.chestLore = JOption.create("Settings.Chest_Item.Lore", new ArrayList<>(), "Chest item lore.", - "Use '" + Placeholders.GENERIC_AMOUNT + "' for items amount.").read(cfg); + "Use '" + Placeholders.GENERIC_AMOUNT + "' for items amount.").mapReader(Colorizer::apply).read(cfg); } @Deprecated @@ -83,7 +84,7 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha } public boolean isSilkChest(@NotNull ItemStack item) { - return PDCUtil.getBooleanData(item, this.keyChest) || PDCUtil.getStringData(item, this.getItemKey(0)) != null; + return PDCUtil.getBoolean(item, this.keyChest).orElse(false) || PDCUtil.getString(item, this.getItemKey(0)).orElse(null) != null; } @NotNull @@ -105,7 +106,7 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha chestStack.setItemMeta(stateMeta); ItemUtil.replace(chestStack, str -> str.replace(Placeholders.GENERIC_AMOUNT, String.valueOf(amount))); - PDCUtil.setData(chestStack, this.keyChest, true); + PDCUtil.set(chestStack, this.keyChest, true); return chestStack; // Store and count chest items. @@ -172,7 +173,7 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha Inventory inventory = chest.getBlockInventory(); for (int pos = 0; pos < inventory.getSize(); pos++) { - String data = PDCUtil.getStringData(item, this.getItemKey(pos)); + String data = PDCUtil.getString(item, this.getItemKey(pos)).orElse(null); if (data == null) continue; ItemStack itemInv = ItemUtil.fromBase64(data); 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 8c70c4f..67ee1fd 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 @@ -9,23 +9,39 @@ 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.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.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import java.util.ArrayList; import java.util.List; import java.util.Objects; -public class EnchantTelekinesis extends ExcellentEnchant implements BlockDropEnchant { +public class EnchantTelekinesis extends ExcellentEnchant implements Chanced, BlockDropEnchant { public static final String ID = "telekinesis"; + private ChanceImplementation chanceImplementation; + public EnchantTelekinesis(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.LOWEST); } + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + @Override @NotNull public FitItemType[] getFitItemTypes() { @@ -41,6 +57,7 @@ public class EnchantTelekinesis extends ExcellentEnchant implements BlockDropEnc @Override public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isAvailableToUse(player)) return false; + if (!this.checkTriggerChance(level)) return false; List drops = new ArrayList<>(); drops.addAll(e.getItems().stream().map(Item::getItemStack).toList()); 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 0b027bb..6fb0a47 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 @@ -117,7 +117,8 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant // Add metadata to prevent enchantment triggering in a loop. blockAdd.setMetadata(META_BLOCK_TUNNEL, new FixedMetadataValue(plugin, true)); - plugin.getNMS().breakBlock(player, blockAdd); + //plugin.getNMS().breakBlock(player, blockAdd); + player.breakBlock(blockAdd); blockAdd.removeMetadata(META_BLOCK_TUNNEL, plugin); } 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 4a817f0..8dbbf90 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 @@ -114,7 +114,8 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch 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); + //plugin.getNMS().breakBlock(player, ore); + player.breakBlock(ore); ore.removeMetadata(META_BLOCK_VEINED, plugin); }); } 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 44f226d..ffa26c6 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 @@ -8,17 +8,33 @@ 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.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.meta.ChanceImplementation; -public class EnchantNimble extends ExcellentEnchant implements DeathEnchant { +public class EnchantNimble extends ExcellentEnchant implements Chanced, DeathEnchant { public static final String ID = "nimble"; + private ChanceImplementation chanceImplementation; + public EnchantNimble(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.LOWEST); } + @Override + public void loadConfig() { + super.loadConfig(); + this.chanceImplementation = ChanceImplementation.create(this); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { @@ -28,6 +44,7 @@ public class EnchantNimble extends ExcellentEnchant implements DeathEnchant { @Override public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { if (!this.isAvailableToUse(entity)) return false; + if (!this.checkTriggerChance(level)) return false; e.getDrops().forEach(item -> PlayerUtil.addItem(killer, item)); e.getDrops().clear(); 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 de746a0..12b2afd 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 @@ -80,7 +80,7 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn if (!this.isAvailableToUse(entity)) return false; if (this.ignoredEntityTypes.contains(entity.getType())) return false; - if (PDCUtil.getBooleanData(entity, this.keyEntityIgnored)) return false; + if (PDCUtil.getBoolean(entity, this.keyEntityIgnored).orElse(false)) return false; if (!this.checkTriggerChance(level)) return false; Material material = Material.getMaterial(entity.getType().name() + "_SPAWN_EGG"); @@ -105,6 +105,6 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn public void onCreatureSpawn(CreatureSpawnEvent e) { if (!this.ignoredSpawnReasons.contains(e.getSpawnReason())) return; - PDCUtil.setData(e.getEntity(), this.keyEntityIgnored, true); + PDCUtil.set(e.getEntity(), this.keyEntityIgnored, 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 d35590d..a28e943 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 @@ -86,7 +86,7 @@ public class EnchantAnvilListener extends AbstractListener { count++; } - PDCUtil.setData(result2, RECHARGED, count); + PDCUtil.set(result2, RECHARGED, count); EnchantManager.updateEnchantmentsDisplay(result2); e.setResult(result2); this.plugin.runTask(c -> e.getInventory().setRepairCost(chargeables.size()), false); @@ -138,14 +138,14 @@ public class EnchantAnvilListener extends AbstractListener { ItemStack item = e.getCurrentItem(); if (item == null) return; - int count = PDCUtil.getIntData(item, RECHARGED); + int count = PDCUtil.getInt(item, RECHARGED).orElse(0); if (count == 0) return; Player player = (Player) e.getWhoClicked(); if (player.getLevel() < inventory.getRepairCost()) return; player.setLevel(player.getLevel() - inventory.getRepairCost()); - PDCUtil.removeData(item, RECHARGED); + PDCUtil.remove(item, RECHARGED); e.getView().setCursor(item); e.setCancelled(false); 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 07f13c5..47cc5a8 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 @@ -13,7 +13,6 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerFishEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.LootGenerateEvent; import org.bukkit.inventory.*; import org.bukkit.inventory.meta.EnchantmentStorageMeta; @@ -36,16 +35,6 @@ public class EnchantGenericListener extends AbstractListener super(enchantManager.plugin()); } - @EventHandler(priority = EventPriority.MONITOR) - public void onEnchantPotionEffectQuit(PlayerQuitEvent e) { - Player player = e.getPlayer(); - - player.getActivePotionEffects().stream() - .filter(effect -> EnchantManager.isEnchantmentEffect(player, effect)).forEach(effect -> { - player.removePotionEffect(effect.getType()); - }); - } - // --------------------------------------------------------------- // Update enchantment lore after grindstone // --------------------------------------------------------------- @@ -190,6 +179,7 @@ public class EnchantGenericListener extends AbstractListener public void onEnchantPopulateSpawn(CreatureSpawnEvent e) { //if (Config.getObtainSettings(ObtainType.MOB_SPAWNING).isEmpty()) return; LivingEntity entity = e.getEntity(); + if (entity.getType() == EntityType.ARMOR_STAND) return; this.plugin.runTaskLater(task -> { EntityEquipment equipment = entity.getEquipment(); 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 2c390f3..adb8773 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 @@ -13,6 +13,7 @@ import su.nexmedia.engine.api.menu.MenuClick; import su.nexmedia.engine.api.menu.MenuItem; import su.nexmedia.engine.api.menu.MenuItemType; import su.nexmedia.engine.lang.LangManager; +import su.nexmedia.engine.utils.Colorizer; import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PDCUtil; import su.nexmedia.engine.utils.StringUtil; @@ -46,9 +47,9 @@ public class EnchantmentsListMenu extends AbstractMenuAuto(); this.enchantIcon = cfg.getItem("Enchantments.Icon"); - this.enchantLoreConflicts = StringUtil.color(cfg.getStringList("Enchantments.Lore.Conflicts")); - this.enchantLoreCharges = StringUtil.color(cfg.getStringList("Enchantments.Lore.Charges")); - this.enchantLoreObtaining = StringUtil.color(cfg.getStringList("Enchantments.Lore.Obtaining")); + this.enchantLoreConflicts = Colorizer.apply(cfg.getStringList("Enchantments.Lore.Conflicts")); + this.enchantLoreCharges = Colorizer.apply(cfg.getStringList("Enchantments.Lore.Charges")); + this.enchantLoreObtaining = Colorizer.apply(cfg.getStringList("Enchantments.Lore.Obtaining")); this.enchantSlots = cfg.getIntArray("Enchantments.Slots"); MenuClick click = (player, type, e) -> { @@ -100,12 +101,12 @@ public class EnchantmentsListMenu extends AbstractMenuAuto enchant.getMaxLevel()) levelHas = enchant.getStartLevel(); itemClick = this.getEnchantIcon(enchant, levelHas); - PDCUtil.setData(itemClick, this.keyLevel, levelHas); + PDCUtil.set(itemClick, this.keyLevel, levelHas); e.setCurrentItem(itemClick); }; 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 65c18bc..8110b07 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.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.manager.IPlaceholder; -import su.nexmedia.engine.utils.StringUtil; +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; @@ -38,7 +38,7 @@ public class Tier implements IPlaceholder { @NotNull Map chance) { this.id = id.toLowerCase(); this.priority = priority; - this.name = StringUtil.color(name); + this.name = Colorizer.apply(name); this.color = color; this.chance = chance; this.enchants = new HashSet<>(); diff --git a/NMS/pom.xml b/NMS/pom.xml index a927bcd..f0cbe68 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.1 + 3.3.3 4.0.0 diff --git a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java index 01df19b..cadf840 100644 --- a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java +++ b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java @@ -1,60 +1,16 @@ package su.nightexpress.excellentenchants.nms; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; -import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.potion.PotionEffect; +import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import su.nexmedia.engine.utils.EntityUtil; -import su.nexmedia.engine.utils.ItemUtil; -import java.util.Map; import java.util.Set; public interface EnchantNMS { - int EFFECT_DURATION_MAX = 30 * 20; - int EFFECT_DURATION_MIN = 20 * 20; - - // TODO Move in 'API' module? - @Deprecated - static int getEnchantmentLevel(@NotNull ItemStack item, @NotNull Enchantment enchant) { - ItemMeta meta = item.getItemMeta(); - if (meta == null) return 0; - - return meta.getEnchantLevel(enchant); - } - - @NotNull - @Deprecated - 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; - } - - // TODO Move in 'API' module? - @Deprecated - static int getEquippedEnchantLevel(@NotNull LivingEntity entity, @NotNull Enchantment enchant) { - return getEquipmentEnchanted(entity).values().stream() - .map(item -> getEnchantmentLevel(item, enchant)).max(Integer::compareTo).orElse(0); - } - - void addEnchantmentEffect(@NotNull LivingEntity entity, @NotNull Enchantment enchant, @NotNull PotionEffect effect); - - @Nullable Enchantment getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect type); + void sendAttackPacket(@NotNull Player player, int id); @NotNull Set handleFlameWalker(@NotNull LivingEntity entity, @NotNull Location location, int level); } diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index f9cf26e..d2cac65 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.1 + 3.3.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.1 + 3.3.3 diff --git a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java deleted file mode 100644 index 30d9e3c..0000000 --- a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/CustomEffectInstance.java +++ /dev/null @@ -1,48 +0,0 @@ -package su.nightexpress.excellentenchants.nms.v1_17_R1; - -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.entity.LivingEntity; -import org.bukkit.enchantments.Enchantment; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.Reflex; -import su.nightexpress.excellentenchants.nms.EnchantNMS; - -public class CustomEffectInstance extends MobEffectInstance { - - private final Enchantment enchantment; - - public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { - super(effect, EnchantNMS.EFFECT_DURATION_MAX, amplifier); - this.enchantment = enchantment; - } - - @NotNull - public Enchantment getEnchantment() { - return enchantment; - } - - @Override - public boolean update(MobEffectInstance effect) { - /*if (effect instanceof CustomEffectInstance custom) { - return false; - } - if (effect.getAmplifier() > this.getAmplifier()) { - - }*/ - return false; - } - - public boolean tick(LivingEntity entity, Runnable runnable) { - if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) { - return false; - } - if (super.tick(entity, runnable)) { - if (this.getDuration() <= EnchantNMS.EFFECT_DURATION_MIN) { - Reflex.setFieldValue(this, "c", EnchantNMS.EFFECT_DURATION_MAX); - } - return true; - } - return false; - } -} diff --git a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java index bc6ced2..9e5431d 100644 --- a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java +++ b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java @@ -1,9 +1,8 @@ package su.nightexpress.excellentenchants.nms.v1_17_R1; import net.minecraft.core.BlockPos; +import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; @@ -13,13 +12,11 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityPotionEffectEvent; -import org.bukkit.potion.PotionEffect; +import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import su.nightexpress.excellentenchants.nms.EnchantNMS; import java.util.HashSet; @@ -28,20 +25,11 @@ import java.util.Set; public class V1_17_R1 implements EnchantNMS { @Override - public void addEnchantmentEffect(@NotNull LivingEntity entity, @NotNull Enchantment enchant, @NotNull PotionEffect effect) { - net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); - entity1.addEffect(new CustomEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getAmplifier(), enchant), EntityPotionEffectEvent.Cause.PLUGIN); - } - - @Override - @Nullable - public Enchantment getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect type) { - net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); - MobEffectInstance handle = entity1.getEffect(MobEffect.byId(type.getType().getId())); - if (handle instanceof CustomEffectInstance instance) { - return instance.getEnchantment(); - } - return null; + public void sendAttackPacket(@NotNull Player player, int id) { + CraftPlayer craftPlayer = (CraftPlayer) player; + Entity entity = craftPlayer.getHandle(); + ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id); + craftPlayer.getHandle().connection.send(packet); } @Override diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 7b086b9..1edc824 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.1 + 3.3.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.1 + 3.3.3 diff --git a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java deleted file mode 100644 index 3726d8c..0000000 --- a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/CustomEffectInstance.java +++ /dev/null @@ -1,48 +0,0 @@ -package su.nightexpress.excellentenchants.nms.v1_18_R2; - -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.entity.LivingEntity; -import org.bukkit.enchantments.Enchantment; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.Reflex; -import su.nightexpress.excellentenchants.nms.EnchantNMS; - -public class CustomEffectInstance extends MobEffectInstance { - - private final Enchantment enchantment; - - public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { - super(effect, EnchantNMS.EFFECT_DURATION_MAX, amplifier); - this.enchantment = enchantment; - } - - @NotNull - public Enchantment getEnchantment() { - return enchantment; - } - - @Override - public boolean update(MobEffectInstance effect) { - /*if (effect instanceof CustomEffectInstance custom) { - return false; - } - if (effect.getAmplifier() > this.getAmplifier()) { - - }*/ - return false; - } - - public boolean tick(LivingEntity entity, Runnable runnable) { - if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) { - return false; - } - if (super.tick(entity, runnable)) { - if (this.getDuration() <= EnchantNMS.EFFECT_DURATION_MIN) { - Reflex.setFieldValue(this, "c", EnchantNMS.EFFECT_DURATION_MAX); - } - return true; - } - return false; - } -} diff --git a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java index 15dc5af..2fdf6d3 100644 --- a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java +++ b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java @@ -1,9 +1,8 @@ package su.nightexpress.excellentenchants.nms.v1_18_R2; import net.minecraft.core.BlockPos; +import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; @@ -13,13 +12,11 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityPotionEffectEvent; -import org.bukkit.potion.PotionEffect; +import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import su.nightexpress.excellentenchants.nms.EnchantNMS; import java.util.HashSet; @@ -28,20 +25,11 @@ import java.util.Set; public class V1_18_R2 implements EnchantNMS { @Override - public void addEnchantmentEffect(@NotNull LivingEntity entity, @NotNull Enchantment enchant, @NotNull PotionEffect effect) { - net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); - entity1.addEffect(new CustomEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getAmplifier(), enchant), EntityPotionEffectEvent.Cause.PLUGIN); - } - - @Override - @Nullable - public Enchantment getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect type) { - net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); - MobEffectInstance handle = entity1.getEffect(MobEffect.byId(type.getType().getId())); - if (handle instanceof CustomEffectInstance instance) { - return instance.getEnchantment(); - } - return null; + public void sendAttackPacket(@NotNull Player player, int id) { + CraftPlayer craftPlayer = (CraftPlayer) player; + Entity entity = craftPlayer.getHandle(); + ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id); + craftPlayer.getHandle().connection.send(packet); } @Override diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index 0e6a1b8..5f13bdd 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.1 + 3.3.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.1 + 3.3.3 diff --git a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java deleted file mode 100644 index e1246e9..0000000 --- a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/CustomEffectInstance.java +++ /dev/null @@ -1,48 +0,0 @@ -package su.nightexpress.excellentenchants.nms.v1_19_R1; - -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.entity.LivingEntity; -import org.bukkit.enchantments.Enchantment; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.Reflex; -import su.nightexpress.excellentenchants.nms.EnchantNMS; - -public class CustomEffectInstance extends MobEffectInstance { - - private final Enchantment enchantment; - - public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { - super(effect, EnchantNMS.EFFECT_DURATION_MAX, amplifier); - this.enchantment = enchantment; - } - - @NotNull - public Enchantment getEnchantment() { - return enchantment; - } - - @Override - public boolean update(MobEffectInstance effect) { - /*if (effect instanceof CustomEffectInstance custom) { - return false; - } - if (effect.getAmplifier() > this.getAmplifier()) { - - }*/ - return false; - } - - public boolean tick(LivingEntity entity, Runnable runnable) { - if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) { - return false; - } - if (super.tick(entity, runnable)) { - if (this.getDuration() <= EnchantNMS.EFFECT_DURATION_MIN) { - Reflex.setFieldValue(this, "c", EnchantNMS.EFFECT_DURATION_MAX); - } - return true; - } - return false; - } -} diff --git a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java index 88e9977..bd5bbca 100644 --- a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java +++ b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java @@ -1,9 +1,8 @@ package su.nightexpress.excellentenchants.nms.v1_19_R1; import net.minecraft.core.BlockPos; +import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; @@ -13,13 +12,11 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityPotionEffectEvent; -import org.bukkit.potion.PotionEffect; +import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import su.nightexpress.excellentenchants.nms.EnchantNMS; import java.util.HashSet; @@ -28,20 +25,11 @@ import java.util.Set; public class V1_19_R1 implements EnchantNMS { @Override - public void addEnchantmentEffect(@NotNull LivingEntity entity, @NotNull Enchantment enchant, @NotNull PotionEffect effect) { - net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); - entity1.addEffect(new CustomEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getAmplifier(), enchant), EntityPotionEffectEvent.Cause.PLUGIN); - } - - @Override - @Nullable - public Enchantment getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect type) { - net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); - MobEffectInstance handle = entity1.getEffect(MobEffect.byId(type.getType().getId())); - if (handle instanceof CustomEffectInstance instance) { - return instance.getEnchantment(); - } - return null; + public void sendAttackPacket(@NotNull Player player, int id) { + CraftPlayer craftPlayer = (CraftPlayer) player; + Entity entity = craftPlayer.getHandle(); + ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id); + craftPlayer.getHandle().connection.send(packet); } @Override diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml index da7821c..381ca0d 100644 --- a/V1_19_R2/pom.xml +++ b/V1_19_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.1 + 3.3.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.1 + 3.3.3 diff --git a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java deleted file mode 100644 index 1506674..0000000 --- a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/CustomEffectInstance.java +++ /dev/null @@ -1,50 +0,0 @@ -package su.nightexpress.excellentenchants.nms.v1_19_R2; - -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.entity.LivingEntity; -import org.bukkit.enchantments.Enchantment; -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.utils.Reflex; -import su.nightexpress.excellentenchants.nms.EnchantNMS; - -public class CustomEffectInstance extends MobEffectInstance { - - private static final int MIN = 60 * 60 * 20; - - private final Enchantment enchantment; - - public CustomEffectInstance(MobEffect effect, int amplifier, @NotNull Enchantment enchantment) { - super(effect, EnchantNMS.EFFECT_DURATION_MAX, amplifier); - this.enchantment = enchantment; - } - - @NotNull - public Enchantment getEnchantment() { - return enchantment; - } - - @Override - public boolean update(MobEffectInstance effect) { - /*if (effect instanceof CustomEffectInstance custom) { - return false; - } - if (effect.getAmplifier() > this.getAmplifier()) { - - }*/ - return false; - } - - public boolean tick(LivingEntity entity, Runnable runnable) { - if (EnchantNMS.getEquippedEnchantLevel((org.bukkit.entity.LivingEntity) entity.getBukkitEntity(), this.getEnchantment()) <= 0) { - return false; - } - if (super.tick(entity, runnable)) { - if (this.getDuration() <= EnchantNMS.EFFECT_DURATION_MIN) { - Reflex.setFieldValue(this, "c", EnchantNMS.EFFECT_DURATION_MAX); - } - return true; - } - return false; - } -} diff --git a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java index e5fdfdb..c8a1a95 100644 --- a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java +++ b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java @@ -1,9 +1,8 @@ package su.nightexpress.excellentenchants.nms.v1_19_R2; import net.minecraft.core.BlockPos; +import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; @@ -13,13 +12,11 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_19_R2.CraftWorld; import org.bukkit.craftbukkit.v1_19_R2.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_19_R2.event.CraftEventFactory; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityPotionEffectEvent; -import org.bukkit.potion.PotionEffect; +import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import su.nightexpress.excellentenchants.nms.EnchantNMS; import java.util.HashSet; @@ -28,20 +25,11 @@ import java.util.Set; public class V1_19_R2 implements EnchantNMS { @Override - public void addEnchantmentEffect(@NotNull LivingEntity entity, @NotNull Enchantment enchant, @NotNull PotionEffect effect) { - net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); - entity1.addEffect(new CustomEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getAmplifier(), enchant), EntityPotionEffectEvent.Cause.PLUGIN); - } - - @Override - @Nullable - public Enchantment getEnchantmentByEffect(@NotNull LivingEntity entity, @NotNull PotionEffect type) { - net.minecraft.world.entity.LivingEntity entity1 = ((CraftLivingEntity)entity).getHandle(); - MobEffectInstance handle = entity1.getEffect(MobEffect.byId(type.getType().getId())); - if (handle instanceof CustomEffectInstance instance) { - return instance.getEnchantment(); - } - return null; + public void sendAttackPacket(@NotNull Player player, int id) { + CraftPlayer craftPlayer = (CraftPlayer) player; + Entity entity = craftPlayer.getHandle(); + ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id); + craftPlayer.getHandle().connection.send(packet); } @Override diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml new file mode 100644 index 0000000..c268d67 --- /dev/null +++ b/V1_19_R3/pom.xml @@ -0,0 +1,71 @@ + + + + ExcellentEnchants + su.nightexpress.excellentenchants + 3.3.3 + + 4.0.0 + + V1_19_R3 + + + 16 + 16 + + + + + org.spigotmc + spigot + 1.19.4-R0.1-SNAPSHOT + remapped-mojang + + + su.nightexpress.excellentenchants + NMS + 3.3.3 + + + + + + + net.md-5 + specialsource-maven-plugin + 1.2.4 + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:1.19.4-R0.1-SNAPSHOT:txt:maps-mojang + true + org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:jar:remapped-mojang + true + remapped-obf + + + + package + + remap + + remap-spigot + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:1.19.4-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:jar:remapped-obf + + + + + + + + \ No newline at end of file diff --git a/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java b/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java new file mode 100644 index 0000000..4b4d3a5 --- /dev/null +++ b/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java @@ -0,0 +1,68 @@ +package su.nightexpress.excellentenchants.nms.v1_19_R3; + +import net.minecraft.core.BlockPos; +import net.minecraft.network.protocol.game.ClientboundAnimatePacket; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_19_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_19_R3.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_19_R3.event.CraftEventFactory; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.nms.EnchantNMS; + +import java.util.HashSet; +import java.util.Set; + +public class V1_19_R3 implements EnchantNMS { + + @Override + public void sendAttackPacket(@NotNull Player player, int id) { + CraftPlayer craftPlayer = (CraftPlayer) player; + Entity entity = craftPlayer.getHandle(); + ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id); + craftPlayer.getHandle().connection.send(packet); + } + + @Override + @NotNull + public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { + Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle(); + BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle(); + + int radius = Math.min(16, 2 + level); + BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState(); + BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos(); + + Set blocks = new HashSet<>(); + for (BlockPos posNear : BlockPos.betweenClosed(pos.offset(-radius, -1, -radius), pos.offset(radius, -1, radius))) { + if (!posNear.closerThan(entity.blockPosition(), radius)) continue; + + posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ()); + + BlockState bLavaAbove = world.getBlockState(posAbove); + BlockState bLava = world.getBlockState(posNear); + + if (!bLavaAbove.isAir()) continue; + if (!bLava.getBlock().equals(Blocks.LAVA)) continue; + if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue; + if (!bStone.canSurvive(world, posNear)) continue; + if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue; + if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue; + //world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120)); + + Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ()); + blocks.add(bukkitLoc.getBlock()); + } + return blocks; + } +} diff --git a/pom.xml b/pom.xml index 0a5669b..26401cb 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.3.1 + 3.3.3 Core NMS @@ -15,6 +15,7 @@ V1_18_R2 V1_19_R1 V1_19_R2 + V1_19_R3 @@ -26,7 +27,7 @@ su.nexmedia NexEngine - 2.2.9 + 2.2.10 From 9c2d0911f1600d9a0b6e321d73e330aae746fe9d Mon Sep 17 00:00:00 2001 From: nulli0n Date: Thu, 11 May 2023 17:59:23 +0600 Subject: [PATCH 33/69] 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, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWU5OWRlZWY5MTlkYjY2YWMyYmQyOGQ2MzAyNzU2Y2NkNTdjN2Y4YjEyYjlkY2E4ZjQxYzNlMGEwNGFjMWNjIn19fQ=="); + map.put(EntityType.BEE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTI3MjRhOWE0Y2RkNjhiYTQ5NDE1NTYwZTViZTQwYjRhMWM0N2NiNWJlMWQ2NmFlZGI1MmEzMGU2MmVmMmQ0NyJ9fX0="); + map.put(EntityType.BLAZE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc4ZWYyZTRjZjJjNDFhMmQxNGJmZGU5Y2FmZjEwMjE5ZjViMWJmNWIzNWE0OWViNTFjNjQ2Nzg4MmNiNWYwIn19fQ=="); + map.put(EntityType.CAT, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTRiNDVjYmFhMTlmZTNkNjhjODU2Y2QzODQ2YzAzYjVmNTlkZTgxYTQ4MGVlYzkyMWFiNGZhM2NkODEzMTcifX19"); + map.put(EntityType.CAVE_SPIDER, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTYxN2Y3ZGQ1ZWQxNmYzYmQxODY0NDA1MTdjZDQ0MGExNzAwMTViMWNjNmZjYjJlOTkzYzA1ZGUzM2YifX19"); + map.put(EntityType.CHICKEN, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTYzODQ2OWE1OTljZWVmNzIwNzUzNzYwMzI0OGE5YWIxMWZmNTkxZmQzNzhiZWE0NzM1YjM0NmE3ZmFlODkzIn19fQ=="); + map.put(EntityType.COD, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg5MmQ3ZGQ2YWFkZjM1Zjg2ZGEyN2ZiNjNkYTRlZGRhMjExZGY5NmQyODI5ZjY5MTQ2MmE0ZmIxY2FiMCJ9fX0="); + map.put(EntityType.COW, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2RmYTBhYzM3YmFiYTJhYTI5MGU0ZmFlZTQxOWE2MTNjZDYxMTdmYTU2OGU3MDlkOTAzNzQ3NTNjMDMyZGNiMCJ9fX0="); + map.put(EntityType.DOLPHIN, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGU5Njg4Yjk1MGQ4ODBiNTViN2FhMmNmY2Q3NmU1YTBmYTk0YWFjNmQxNmY3OGU4MzNmNzQ0M2VhMjlmZWQzIn19fQ=="); + map.put(EntityType.DONKEY, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjNhOTc2YzA0N2Y0MTJlYmM1Y2IxOTcxMzFlYmVmMzBjMDA0YzBmYWY0OWQ4ZGQ0MTA1ZmNhMTIwN2VkYWZmMyJ9fX0="); + map.put(EntityType.DROWNED, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzNmN2NjZjYxZGJjM2Y5ZmU5YTYzMzNjZGUwYzBlMTQzOTllYjJlZWE3MWQzNGNmMjIzYjNhY2UyMjA1MSJ9fX0="); + map.put(EntityType.ELDER_GUARDIAN, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWM3OTc0ODJhMTRiZmNiODc3MjU3Y2IyY2ZmMWI2ZTZhOGI4NDEzMzM2ZmZiNGMyOWE2MTM5Mjc4YjQzNmIifX19"); + map.put(EntityType.ENDERMAN, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjMGIzNmQ1M2ZmZjY5YTQ5YzdkNmYzOTMyZjJiMGZlOTQ4ZTAzMjIyNmQ1ZTgwNDVlYzU4NDA4YTM2ZTk1MSJ9fX0="); + map.put(EntityType.ENDERMITE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWExYTA4MzFhYTAzYWZiNDIxMmFkY2JiMjRlNWRmYWE3ZjQ3NmExMTczZmNlMjU5ZWY3NWE4NTg1NSJ9fX0="); + map.put(EntityType.EVOKER, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDk1NDEzNWRjODIyMTM5NzhkYjQ3ODc3OGFlMTIxMzU5MWI5M2QyMjhkMzZkZDU0ZjFlYTFkYTQ4ZTdjYmE2In19fQ=="); + map.put(EntityType.FOX, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDg5NTRhNDJlNjllMDg4MWFlNmQyNGQ0MjgxNDU5YzE0NGEwZDVhOTY4YWVkMzVkNmQzZDczYTNjNjVkMjZhIn19fQ=="); + map.put(EntityType.GHAST, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGU4YTM4ZTlhZmJkM2RhMTBkMTliNTc3YzU1YzdiZmQ2YjRmMmU0MDdlNDRkNDAxN2IyM2JlOTE2N2FiZmYwMiJ9fX0="); + map.put(EntityType.GOAT, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDU3YTBkNTM4ZmEwOGE3YWZmZTMxMjkwMzQ2ODg2MTcyMGY5ZmEzNGU4NmQ0NGI4OWRjZWM1NjM5MjY1ZjAzIn19fQ=="); + map.put(EntityType.GUARDIAN, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTBiZjM0YTcxZTc3MTViNmJhNTJkNWRkMWJhZTVjYjg1Zjc3M2RjOWIwZDQ1N2I0YmZjNWY5ZGQzY2M3Yzk0In19fQ=="); + map.put(EntityType.HOGLIN, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWJiOWJjMGYwMWRiZDc2MmEwOGQ5ZTc3YzA4MDY5ZWQ3Yzk1MzY0YWEzMGNhMTA3MjIwODU2MWI3MzBlOGQ3NSJ9fX0="); + map.put(EntityType.HORSE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjY2YjJiMzJkMzE1MzljNzM4M2Q5MjNiYWU0ZmFhZjY1ZGE2NzE1Y2Q1MjZjMzVkMmU0ZTY4MjVkYTExZmIifX19"); + map.put(EntityType.HUSK, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDY3NGM2M2M4ZGI1ZjRjYTYyOGQ2OWEzYjFmOGEzNmUyOWQ4ZmQ3NzVlMWE2YmRiNmNhYmI0YmU0ZGIxMjEifX19"); + map.put(EntityType.ILLUSIONER, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmYyODgyZGQwOTcyM2U0N2MwYWI5NjYzZWFiMDgzZDZhNTk2OTI3MzcwNjExMGM4MjkxMGU2MWJmOGE4ZjA3ZSJ9fX0="); + map.put(EntityType.IRON_GOLEM, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODkwOTFkNzllYTBmNTllZjdlZjk0ZDdiYmE2ZTVmMTdmMmY3ZDQ1NzJjNDRmOTBmNzZjNDgxOWE3MTQifX19"); + map.put(EntityType.LLAMA, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODNkOWI1OTE1OTEyZmZjMmI4NTc2MWQ2YWRjYjQyOGE4MTJmOWI4M2ZmNjM0ZTMzMTE2MmNlNDZjOTllOSJ9fX0="); + map.put(EntityType.MAGMA_CUBE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTFjOTdhMDZlZmRlMDRkMDAyODdiZjIwNDE2NDA0YWIyMTAzZTEwZjA4NjIzMDg3ZTFiMGMxMjY0YTFjMGYwYyJ9fX0="); + map.put(EntityType.MULE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDZkY2RhMjY1ZTU3ZTRmNTFiMTQ1YWFjYmY1YjU5YmRjNjA5OWZmZDNjY2UwYTY2MWIyYzAwNjVkODA5MzBkOCJ9fX0="); + map.put(EntityType.MUSHROOM_COW, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmI1Mjg0MWYyZmQ1ODllMGJjODRjYmFiZjllMWMyN2NiNzBjYWM5OGY4ZDZiM2RkMDY1ZTU1YTRkY2I3MGQ3NyJ9fX0="); + map.put(EntityType.OCELOT, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTY1N2NkNWMyOTg5ZmY5NzU3MGZlYzRkZGNkYzY5MjZhNjhhMzM5MzI1MGMxYmUxZjBiMTE0YTFkYjEifX19"); + map.put(EntityType.PANDA, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDE4OGM5ODBhYWNmYTk0Y2YzMzA4ODUxMmIxYjk1MTdiYTgyNmIxNTRkNGNhZmMyNjJhZmY2OTc3YmU4YSJ9fX0="); + map.put(EntityType.PARROT, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjBiZmE4NTBmNWRlNGIyOTgxY2NlNzhmNTJmYzJjYzdjZDdiNWM2MmNhZWZlZGRlYjljZjMxMWU4M2Q5MDk3In19fQ=="); + map.put(EntityType.PHANTOM, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDExZDI1YmNkYWJhZmFkNWZkNmUwMTBjNWIxY2Y3YTAwYzljY2E0MGM1YTQ2NzQ3ZjcwNmRjOWNiM2EifX19"); + map.put(EntityType.PIG, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWEzNzFhMDZlYTc4NThmODlkMjdjYzEwNTVjMzE3YjIzZjEwNWM5MTI1YmM1MTZkMzg5MWFhNGM4MzVjMjk5In19fQ=="); + map.put(EntityType.PIGLIN, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2NlZDlkODAxYWE2ZjgzZjhlNDlmOTBkOWE4Yjg1YjdmOGZkYTU4M2Q4NWY3MmNmZmI2OTg2NzI1Nzg5ZjYzNiJ9fX0="); + map.put(EntityType.PIGLIN_BRUTE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2NlZDlkODAxYWE2ZjgzZjhlNDlmOTBkOWE4Yjg1YjdmOGZkYTU4M2Q4NWY3MmNmZmI2OTg2NzI1Nzg5ZjYzNiJ9fX0="); + map.put(EntityType.PILLAGER, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGFlZTZiYjM3Y2JmYzkyYjBkODZkYjVhZGE0NzkwYzY0ZmY0NDY4ZDY4Yjg0OTQyZmRlMDQ0MDVlOGVmNTMzMyJ9fX0="); + map.put(EntityType.POLAR_BEAR, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzRmZTkyNjkyMmZiYjQwNmYzNDNiMzRhMTBiYjk4OTkyY2VlNDQxMDEzN2QzZjg4MDk5NDI3YjIyZGUzYWI5MCJ9fX0="); + map.put(EntityType.PUFFERFISH, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjkyMzUwYzlmMDk5M2VkNTRkYjJjNzExMzkzNjMyNTY4M2ZmYzIwMTA0YTliNjIyYWE0NTdkMzdlNzA4ZDkzMSJ9fX0="); + map.put(EntityType.RABBIT, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzk3N2EzMjY2YmYzYjllYWYxN2U1YTAyZWE1ZmJiNDY4MDExNTk4NjNkZDI4OGI5M2U2YzEyYzljYiJ9fX0="); + map.put(EntityType.RAVAGER, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2QyMGJmNTJlYzM5MGEwNzk5Mjk5MTg0ZmM2NzhiZjg0Y2Y3MzJiYjFiZDc4ZmQxYzRiNDQxODU4ZjAyMzVhOCJ9fX0="); + map.put(EntityType.SALMON, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjBlYTlhMjIzNjIwY2RiNTRiMzU3NDEzZDQzYmQ4OWM0MDA4YmNhNmEyMjdmM2I3ZGI5N2Y3NzMzZWFkNWZjZiJ9fX0="); + map.put(EntityType.SHEEP, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjMxZjljY2M2YjNlMzJlY2YxM2I4YTExYWMyOWNkMzNkMThjOTVmYzczZGI4YTY2YzVkNjU3Y2NiOGJlNzAifX19"); + map.put(EntityType.SILVERFISH, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGE5MWRhYjgzOTFhZjVmZGE1NGFjZDJjMGIxOGZiZDgxOWI4NjVlMWE4ZjFkNjIzODEzZmE3NjFlOTI0NTQwIn19fQ=="); + map.put(EntityType.SLIME, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODk1YWVlYzZiODQyYWRhODY2OWY4NDZkNjViYzQ5NzYyNTk3ODI0YWI5NDRmMjJmNDViZjNiYmI5NDFhYmU2YyJ9fX0="); + map.put(EntityType.SNOWMAN, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGU4ZDIwNmY2MWU2ZGU4YTc5ZDBjYjBiY2Q5OGFjZWQ0NjRjYmZlZmM5MjFiNDE2MGEyNTI4MjE2MzExMmEifX19"); + map.put(EntityType.SPIDER, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2Q1NDE1NDFkYWFmZjUwODk2Y2QyNThiZGJkZDRjZjgwYzNiYTgxNjczNTcyNjA3OGJmZTM5MzkyN2U1N2YxIn19fQ=="); + map.put(EntityType.SQUID, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDljMmM5Y2U2N2ViNTk3MWNjNTk1ODQ2M2U2YzlhYmFiOGU1OTlhZGMyOTVmNGQ0MjQ5OTM2YjAwOTU3NjlkZCJ9fX0="); + map.put(EntityType.STRAY, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmM1MDk3OTE2YmMwNTY1ZDMwNjAxYzBlZWJmZWIyODcyNzdhMzRlODY3YjRlYTQzYzYzODE5ZDUzZTg5ZWRlNyJ9fX0="); + map.put(EntityType.STRIDER, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2I3ZmZkZGE2NTZjNjhkODg4NTFhOGUwNWI0OGNkMjQ5Mzc3M2ZmYzRhYjdkNjRlOTMwMjIyOWZlMzU3MTA1OSJ9fX0="); + map.put(EntityType.TRADER_LLAMA, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODQyNDc4MGIzYzVjNTM1MWNmNDlmYjViZjQxZmNiMjg5NDkxZGY2YzQzMDY4M2M4NGQ3ODQ2MTg4ZGI0Zjg0ZCJ9fX0="); + map.put(EntityType.TROPICAL_FISH, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDZkZDVlNmFkZGI1NmFjYmM2OTRlYTRiYTU5MjNiMWIyNTY4ODE3OGZlZmZhNzIyOTAyOTllMjUwNWM5NzI4MSJ9fX0="); + map.put(EntityType.TURTLE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMGE0MDUwZTdhYWNjNDUzOTIwMjY1OGZkYzMzOWRkMTgyZDdlMzIyZjlmYmNjNGQ1Zjk5YjU3MThhIn19fQ=="); + map.put(EntityType.VEX, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJlYzVhNTE2NjE3ZmYxNTczY2QyZjlkNWYzOTY5ZjU2ZDU1NzVjNGZmNGVmZWZhYmQyYTE4ZGM3YWI5OGNkIn19fQ=="); + map.put(EntityType.VILLAGER, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDFiODMwZWI0MDgyYWNlYzgzNmJjODM1ZTQwYTExMjgyYmI1MTE5MzMxNWY5MTE4NDMzN2U4ZDM1NTU1ODMifX19"); + map.put(EntityType.VINDICATOR, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmRlYWVjMzQ0YWIwOTViNDhjZWFkNzUyN2Y3ZGVlNjFiMDYzZmY3OTFmNzZhOGZhNzY2NDJjODY3NmUyMTczIn19fQ=="); + map.put(EntityType.WANDERING_TRADER, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWYxMzc5YTgyMjkwZDdhYmUxZWZhYWJiYzcwNzEwZmYyZWMwMmRkMzRhZGUzODZiYzAwYzkzMGM0NjFjZjkzMiJ9fX0="); + map.put(EntityType.WITCH, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjBlMTNkMTg0NzRmYzk0ZWQ1NWFlYjcwNjk1NjZlNDY4N2Q3NzNkYWMxNmY0YzNmODcyMmZjOTViZjlmMmRmYSJ9fX0="); + map.put(EntityType.WOLF, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA0OThkZTZmNWIwOWUwY2UzNWE3MjkyZmU1MGI3OWZjZTkwNjVkOWJlOGUyYTg3YzdhMTM1NjZlZmIyNmQ3MiJ9fX0="); + map.put(EntityType.ZOGLIN, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTY3ZTE4NjAyZTAzMDM1YWQ2ODk2N2NlMDkwMjM1ZDg5OTY2NjNmYjllYTQ3NTc4ZDNhN2ViYmM0MmE1Y2NmOSJ9fX0="); + map.put(EntityType.ZOMBIFIED_PIGLIN, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2VhYmFlY2M1ZmFlNWE4YTQ5Yzg4NjNmZjQ4MzFhYWEyODQxOThmMWEyMzk4ODkwYzc2NWUwYThkZTE4ZGE4YyJ9fX0="); + map.put(EntityType.ZOMBIE_HORSE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDIyOTUwZjJkM2VmZGRiMThkZTg2ZjhmNTVhYzUxOGRjZTczZjEyYTZlMGY4NjM2ZDU1MWQ4ZWI0ODBjZWVjIn19fQ=="); + map.put(EntityType.ZOMBIE_VILLAGER, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTVlMDhhODc3NmMxNzY0YzNmZTZhNmRkZDQxMmRmY2I4N2Y0MTMzMWRhZDQ3OWFjOTZjMjFkZjRiZjNhYzg5YyJ9fX0="); + map.put(EntityType.SKELETON_HORSE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDdlZmZjZTM1MTMyYzg2ZmY3MmJjYWU3N2RmYmIxZDIyNTg3ZTk0ZGYzY2JjMjU3MGVkMTdjZjg5NzNhIn19fQ=="); + 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: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNThkYTFhMGEyYTEzZGQyMDliZmMyNTI5ZDljN2MyOWEyOWRkOWEyM2ZmNGI4MGIzOGI4OTk2MTc3MmU4MDM5ZSJ9fX0= - BAT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWU5OWRlZWY5MTlkYjY2YWMyYmQyOGQ2MzAyNzU2Y2NkNTdjN2Y4YjEyYjlkY2E4ZjQxYzNlMGEwNGFjMWNjIn19fQ== - BEE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTI3MjRhOWE0Y2RkNjhiYTQ5NDE1NTYwZTViZTQwYjRhMWM0N2NiNWJlMWQ2NmFlZGI1MmEzMGU2MmVmMmQ0NyJ9fX0= - BLAZE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc4ZWYyZTRjZjJjNDFhMmQxNGJmZGU5Y2FmZjEwMjE5ZjViMWJmNWIzNWE0OWViNTFjNjQ2Nzg4MmNiNWYwIn19fQ== - CAT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTRiNDVjYmFhMTlmZTNkNjhjODU2Y2QzODQ2YzAzYjVmNTlkZTgxYTQ4MGVlYzkyMWFiNGZhM2NkODEzMTcifX19 - CAVE_SPIDER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTYxN2Y3ZGQ1ZWQxNmYzYmQxODY0NDA1MTdjZDQ0MGExNzAwMTViMWNjNmZjYjJlOTkzYzA1ZGUzM2YifX19 - CHICKEN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTYzODQ2OWE1OTljZWVmNzIwNzUzNzYwMzI0OGE5YWIxMWZmNTkxZmQzNzhiZWE0NzM1YjM0NmE3ZmFlODkzIn19fQ== - COD: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg5MmQ3ZGQ2YWFkZjM1Zjg2ZGEyN2ZiNjNkYTRlZGRhMjExZGY5NmQyODI5ZjY5MTQ2MmE0ZmIxY2FiMCJ9fX0= - COW: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2RmYTBhYzM3YmFiYTJhYTI5MGU0ZmFlZTQxOWE2MTNjZDYxMTdmYTU2OGU3MDlkOTAzNzQ3NTNjMDMyZGNiMCJ9fX0= - DOLPHIN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGU5Njg4Yjk1MGQ4ODBiNTViN2FhMmNmY2Q3NmU1YTBmYTk0YWFjNmQxNmY3OGU4MzNmNzQ0M2VhMjlmZWQzIn19fQ== - DONKEY: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjNhOTc2YzA0N2Y0MTJlYmM1Y2IxOTcxMzFlYmVmMzBjMDA0YzBmYWY0OWQ4ZGQ0MTA1ZmNhMTIwN2VkYWZmMyJ9fX0= - DROWNED: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzNmN2NjZjYxZGJjM2Y5ZmU5YTYzMzNjZGUwYzBlMTQzOTllYjJlZWE3MWQzNGNmMjIzYjNhY2UyMjA1MSJ9fX0= - ELDER_GUARDIAN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWM3OTc0ODJhMTRiZmNiODc3MjU3Y2IyY2ZmMWI2ZTZhOGI4NDEzMzM2ZmZiNGMyOWE2MTM5Mjc4YjQzNmIifX19 - ENDERMAN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjMGIzNmQ1M2ZmZjY5YTQ5YzdkNmYzOTMyZjJiMGZlOTQ4ZTAzMjIyNmQ1ZTgwNDVlYzU4NDA4YTM2ZTk1MSJ9fX0= - ENDERMITE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWExYTA4MzFhYTAzYWZiNDIxMmFkY2JiMjRlNWRmYWE3ZjQ3NmExMTczZmNlMjU5ZWY3NWE4NTg1NSJ9fX0= - EVOKER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDk1NDEzNWRjODIyMTM5NzhkYjQ3ODc3OGFlMTIxMzU5MWI5M2QyMjhkMzZkZDU0ZjFlYTFkYTQ4ZTdjYmE2In19fQ== - FOX: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDg5NTRhNDJlNjllMDg4MWFlNmQyNGQ0MjgxNDU5YzE0NGEwZDVhOTY4YWVkMzVkNmQzZDczYTNjNjVkMjZhIn19fQ== - GHAST: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGU4YTM4ZTlhZmJkM2RhMTBkMTliNTc3YzU1YzdiZmQ2YjRmMmU0MDdlNDRkNDAxN2IyM2JlOTE2N2FiZmYwMiJ9fX0= - GOAT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDU3YTBkNTM4ZmEwOGE3YWZmZTMxMjkwMzQ2ODg2MTcyMGY5ZmEzNGU4NmQ0NGI4OWRjZWM1NjM5MjY1ZjAzIn19fQ== - GUARDIAN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTBiZjM0YTcxZTc3MTViNmJhNTJkNWRkMWJhZTVjYjg1Zjc3M2RjOWIwZDQ1N2I0YmZjNWY5ZGQzY2M3Yzk0In19fQ== - HOGLIN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWJiOWJjMGYwMWRiZDc2MmEwOGQ5ZTc3YzA4MDY5ZWQ3Yzk1MzY0YWEzMGNhMTA3MjIwODU2MWI3MzBlOGQ3NSJ9fX0= - HORSE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjY2YjJiMzJkMzE1MzljNzM4M2Q5MjNiYWU0ZmFhZjY1ZGE2NzE1Y2Q1MjZjMzVkMmU0ZTY4MjVkYTExZmIifX19 - HUSK: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDY3NGM2M2M4ZGI1ZjRjYTYyOGQ2OWEzYjFmOGEzNmUyOWQ4ZmQ3NzVlMWE2YmRiNmNhYmI0YmU0ZGIxMjEifX19 - ILLUSIONER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmYyODgyZGQwOTcyM2U0N2MwYWI5NjYzZWFiMDgzZDZhNTk2OTI3MzcwNjExMGM4MjkxMGU2MWJmOGE4ZjA3ZSJ9fX0= - IRON_GOLEM: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODkwOTFkNzllYTBmNTllZjdlZjk0ZDdiYmE2ZTVmMTdmMmY3ZDQ1NzJjNDRmOTBmNzZjNDgxOWE3MTQifX19 - LLAMA: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODNkOWI1OTE1OTEyZmZjMmI4NTc2MWQ2YWRjYjQyOGE4MTJmOWI4M2ZmNjM0ZTMzMTE2MmNlNDZjOTllOSJ9fX0= - MAGMA_CUBE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTFjOTdhMDZlZmRlMDRkMDAyODdiZjIwNDE2NDA0YWIyMTAzZTEwZjA4NjIzMDg3ZTFiMGMxMjY0YTFjMGYwYyJ9fX0= - MULE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDZkY2RhMjY1ZTU3ZTRmNTFiMTQ1YWFjYmY1YjU5YmRjNjA5OWZmZDNjY2UwYTY2MWIyYzAwNjVkODA5MzBkOCJ9fX0= - MUSHROOM_COW: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmI1Mjg0MWYyZmQ1ODllMGJjODRjYmFiZjllMWMyN2NiNzBjYWM5OGY4ZDZiM2RkMDY1ZTU1YTRkY2I3MGQ3NyJ9fX0= - OCELOT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTY1N2NkNWMyOTg5ZmY5NzU3MGZlYzRkZGNkYzY5MjZhNjhhMzM5MzI1MGMxYmUxZjBiMTE0YTFkYjEifX19 - PANDA: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDE4OGM5ODBhYWNmYTk0Y2YzMzA4ODUxMmIxYjk1MTdiYTgyNmIxNTRkNGNhZmMyNjJhZmY2OTc3YmU4YSJ9fX0= - PARROT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjBiZmE4NTBmNWRlNGIyOTgxY2NlNzhmNTJmYzJjYzdjZDdiNWM2MmNhZWZlZGRlYjljZjMxMWU4M2Q5MDk3In19fQ== - PHANTOM: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDExZDI1YmNkYWJhZmFkNWZkNmUwMTBjNWIxY2Y3YTAwYzljY2E0MGM1YTQ2NzQ3ZjcwNmRjOWNiM2EifX19 - PIG: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWEzNzFhMDZlYTc4NThmODlkMjdjYzEwNTVjMzE3YjIzZjEwNWM5MTI1YmM1MTZkMzg5MWFhNGM4MzVjMjk5In19fQ== - PIGLIN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2NlZDlkODAxYWE2ZjgzZjhlNDlmOTBkOWE4Yjg1YjdmOGZkYTU4M2Q4NWY3MmNmZmI2OTg2NzI1Nzg5ZjYzNiJ9fX0= - PIGLIN_BRUTE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2NlZDlkODAxYWE2ZjgzZjhlNDlmOTBkOWE4Yjg1YjdmOGZkYTU4M2Q4NWY3MmNmZmI2OTg2NzI1Nzg5ZjYzNiJ9fX0= - PILLAGER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGFlZTZiYjM3Y2JmYzkyYjBkODZkYjVhZGE0NzkwYzY0ZmY0NDY4ZDY4Yjg0OTQyZmRlMDQ0MDVlOGVmNTMzMyJ9fX0= - POLAR_BEAR: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzRmZTkyNjkyMmZiYjQwNmYzNDNiMzRhMTBiYjk4OTkyY2VlNDQxMDEzN2QzZjg4MDk5NDI3YjIyZGUzYWI5MCJ9fX0= - PUFFERFISH: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjkyMzUwYzlmMDk5M2VkNTRkYjJjNzExMzkzNjMyNTY4M2ZmYzIwMTA0YTliNjIyYWE0NTdkMzdlNzA4ZDkzMSJ9fX0= - RABBIT: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzk3N2EzMjY2YmYzYjllYWYxN2U1YTAyZWE1ZmJiNDY4MDExNTk4NjNkZDI4OGI5M2U2YzEyYzljYiJ9fX0= - RAVAGER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2QyMGJmNTJlYzM5MGEwNzk5Mjk5MTg0ZmM2NzhiZjg0Y2Y3MzJiYjFiZDc4ZmQxYzRiNDQxODU4ZjAyMzVhOCJ9fX0= - SALMON: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjBlYTlhMjIzNjIwY2RiNTRiMzU3NDEzZDQzYmQ4OWM0MDA4YmNhNmEyMjdmM2I3ZGI5N2Y3NzMzZWFkNWZjZiJ9fX0= - SHEEP: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjMxZjljY2M2YjNlMzJlY2YxM2I4YTExYWMyOWNkMzNkMThjOTVmYzczZGI4YTY2YzVkNjU3Y2NiOGJlNzAifX19 - SILVERFISH: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGE5MWRhYjgzOTFhZjVmZGE1NGFjZDJjMGIxOGZiZDgxOWI4NjVlMWE4ZjFkNjIzODEzZmE3NjFlOTI0NTQwIn19fQ== - SLIME: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODk1YWVlYzZiODQyYWRhODY2OWY4NDZkNjViYzQ5NzYyNTk3ODI0YWI5NDRmMjJmNDViZjNiYmI5NDFhYmU2YyJ9fX0= - SNOWMAN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGU4ZDIwNmY2MWU2ZGU4YTc5ZDBjYjBiY2Q5OGFjZWQ0NjRjYmZlZmM5MjFiNDE2MGEyNTI4MjE2MzExMmEifX19 - SPIDER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2Q1NDE1NDFkYWFmZjUwODk2Y2QyNThiZGJkZDRjZjgwYzNiYTgxNjczNTcyNjA3OGJmZTM5MzkyN2U1N2YxIn19fQ== - SQUID: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDljMmM5Y2U2N2ViNTk3MWNjNTk1ODQ2M2U2YzlhYmFiOGU1OTlhZGMyOTVmNGQ0MjQ5OTM2YjAwOTU3NjlkZCJ9fX0= - STRAY: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmM1MDk3OTE2YmMwNTY1ZDMwNjAxYzBlZWJmZWIyODcyNzdhMzRlODY3YjRlYTQzYzYzODE5ZDUzZTg5ZWRlNyJ9fX0= - STRIDER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2I3ZmZkZGE2NTZjNjhkODg4NTFhOGUwNWI0OGNkMjQ5Mzc3M2ZmYzRhYjdkNjRlOTMwMjIyOWZlMzU3MTA1OSJ9fX0= - TRADER_LLAMA: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODQyNDc4MGIzYzVjNTM1MWNmNDlmYjViZjQxZmNiMjg5NDkxZGY2YzQzMDY4M2M4NGQ3ODQ2MTg4ZGI0Zjg0ZCJ9fX0= - TROPICAL_FISH: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDZkZDVlNmFkZGI1NmFjYmM2OTRlYTRiYTU5MjNiMWIyNTY4ODE3OGZlZmZhNzIyOTAyOTllMjUwNWM5NzI4MSJ9fX0= - TURTLE: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMGE0MDUwZTdhYWNjNDUzOTIwMjY1OGZkYzMzOWRkMTgyZDdlMzIyZjlmYmNjNGQ1Zjk5YjU3MThhIn19fQ== - VEX: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJlYzVhNTE2NjE3ZmYxNTczY2QyZjlkNWYzOTY5ZjU2ZDU1NzVjNGZmNGVmZWZhYmQyYTE4ZGM3YWI5OGNkIn19fQ== - VILLAGER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDFiODMwZWI0MDgyYWNlYzgzNmJjODM1ZTQwYTExMjgyYmI1MTE5MzMxNWY5MTE4NDMzN2U4ZDM1NTU1ODMifX19 - VINDICATOR: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmRlYWVjMzQ0YWIwOTViNDhjZWFkNzUyN2Y3ZGVlNjFiMDYzZmY3OTFmNzZhOGZhNzY2NDJjODY3NmUyMTczIn19fQ== - WANDERING_TRADER: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWYxMzc5YTgyMjkwZDdhYmUxZWZhYWJiYzcwNzEwZmYyZWMwMmRkMzRhZGUzODZiYzAwYzkzMGM0NjFjZjkzMiJ9fX0= - WITCH: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjBlMTNkMTg0NzRmYzk0ZWQ1NWFlYjcwNjk1NjZlNDY4N2Q3NzNkYWMxNmY0YzNmODcyMmZjOTViZjlmMmRmYSJ9fX0= - WOLF: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA0OThkZTZmNWIwOWUwY2UzNWE3MjkyZmU1MGI3OWZjZTkwNjVkOWJlOGUyYTg3YzdhMTM1NjZlZmIyNmQ3MiJ9fX0= - ZOGLIN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTY3ZTE4NjAyZTAzMDM1YWQ2ODk2N2NlMDkwMjM1ZDg5OTY2NjNmYjllYTQ3NTc4ZDNhN2ViYmM0MmE1Y2NmOSJ9fX0= - ZOMBIFIED_PIGLIN: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2VhYmFlY2M1ZmFlNWE4YTQ5Yzg4NjNmZjQ4MzFhYWEyODQxOThmMWEyMzk4ODkwYzc2NWUwYThkZTE4ZGE4YyJ9fX0= - 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 From ce07be4c8fd15c7dba8b8b5fdbefec32d14ced6a Mon Sep 17 00:00:00 2001 From: nulli0n Date: Sun, 14 May 2023 02:43:33 +0600 Subject: [PATCH 34/69] Code improvements --- .../excellentenchants/ExcellentEnchants.java | 20 +- .../api/enchantment/type/FishingEnchant.java | 11 + .../enchantment/EnchantManager.java | 3 - .../enchantment/EnchantRegistry.java | 283 +++++++----------- .../enchantment/impl/ExcellentEnchant.java | 89 +++--- .../impl/armor/EnchantAquaman.java | 4 +- .../impl/armor/EnchantBunnyHop.java | 4 +- .../impl/armor/EnchantColdSteel.java | 4 +- .../armor/EnchantElementalProtection.java | 19 +- .../impl/armor/EnchantFireShield.java | 22 +- .../impl/armor/EnchantFlameWalker.java | 4 +- .../impl/armor/EnchantHardened.java | 4 +- .../impl/armor/EnchantIceShield.java | 4 +- .../impl/armor/EnchantNightVision.java | 4 +- .../impl/armor/EnchantRegrowth.java | 22 +- .../impl/armor/EnchantSaturation.java | 24 +- .../impl/armor/EnchantSelfDestruction.java | 20 +- .../enchantment/impl/armor/EnchantSonic.java | 4 +- .../enchantment/impl/bow/EnchantBomber.java | 19 +- .../impl/bow/EnchantConfusingArrows.java | 4 +- .../impl/bow/EnchantDragonfireArrows.java | 22 +- .../impl/bow/EnchantElectrifiedArrows.java | 4 +- .../enchantment/impl/bow/EnchantEnderBow.java | 4 +- .../impl/bow/EnchantExplosiveArrows.java | 20 +- .../enchantment/impl/bow/EnchantGhast.java | 4 +- .../enchantment/impl/bow/EnchantHover.java | 4 +- .../impl/bow/EnchantPoisonedArrows.java | 4 +- .../impl/bow/EnchantWitheredArrows.java | 4 +- .../impl/fishing/AutoFishEnchant.java | 41 +++ .../impl/fishing/SpeedFishingEnchant.java | 5 - .../impl/tool/EnchantBlastMining.java | 27 +- .../impl/tool/EnchantCurseOfBreaking.java | 21 +- .../impl/tool/EnchantCurseOfMisfortune.java | 4 +- .../impl/tool/EnchantDivineTouch.java | 4 +- .../enchantment/impl/tool/EnchantHaste.java | 4 +- .../impl/tool/EnchantLuckyMiner.java | 22 +- .../impl/tool/EnchantReplanter.java | 4 +- .../impl/tool/EnchantSilkChest.java | 4 +- .../enchantment/impl/tool/EnchantSmelter.java | 11 +- .../impl/tool/EnchantTelekinesis.java | 4 +- .../impl/tool/EnchantTreasures.java | 4 +- .../enchantment/impl/tool/EnchantTunnel.java | 9 +- .../impl/tool/EnchantVeinminer.java | 20 +- .../impl/weapon/EnchantBaneOfNetherspawn.java | 14 +- .../impl/weapon/EnchantBlindness.java | 4 +- .../impl/weapon/EnchantConfusion.java | 4 +- .../enchantment/impl/weapon/EnchantCure.java | 4 +- .../impl/weapon/EnchantCutter.java | 15 +- .../impl/weapon/EnchantDecapitator.java | 5 +- .../impl/weapon/EnchantDoubleStrike.java | 4 +- .../impl/weapon/EnchantExhaust.java | 4 +- .../impl/weapon/EnchantExpHunter.java | 20 +- .../impl/weapon/EnchantIceAspect.java | 4 +- .../impl/weapon/EnchantInfernus.java | 18 +- .../impl/weapon/EnchantNimble.java | 4 +- .../impl/weapon/EnchantParalyze.java | 4 +- .../enchantment/impl/weapon/EnchantRage.java | 4 +- .../impl/weapon/EnchantRocket.java | 4 +- .../impl/weapon/EnchantScavenger.java | 4 +- .../impl/weapon/EnchantSurprise.java | 4 +- .../impl/weapon/EnchantTemper.java | 24 +- .../impl/weapon/EnchantThrifty.java | 4 +- .../impl/weapon/EnchantThunder.java | 4 +- .../impl/weapon/EnchantVampire.java | 18 +- .../enchantment/impl/weapon/EnchantVenom.java | 4 +- .../impl/weapon/EnchantVillageDefender.java | 17 +- .../impl/weapon/EnchantWither.java | 5 +- .../listener/EnchantHandlerListener.java | 21 ++ .../menu/EnchantmentsListMenu.java | 34 +-- .../enchantment/util/EnchantUtils.java | 16 +- .../hook/impl/PlaceholderHook.java | 4 +- .../excellentenchants/nms/EnchantNMS.java | 4 + .../nms/v1_17_R1/V1_17_R1.java | 12 + .../nms/v1_18_R2/V1_18_R2.java | 12 + .../nms/v1_19_R1/V1_19_R1.java | 12 + .../nms/v1_19_R2/V1_19_R2.java | 12 + .../nms/v1_19_R3/V1_19_R3.java | 12 + 77 files changed, 542 insertions(+), 611 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/FishingEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoFishEnchant.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SpeedFishingEnchant.java diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 949eaeb..458eaa6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -13,6 +13,7 @@ import su.nightexpress.excellentenchants.command.TierbookCommand; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.config.Lang; import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import su.nightexpress.excellentenchants.hook.HookId; import su.nightexpress.excellentenchants.hook.impl.PlaceholderHook; @@ -27,10 +28,9 @@ import su.nightexpress.excellentenchants.tier.TierManager; public class ExcellentEnchants extends NexPlugin { - public static boolean isLoaded = false; - - private EnchantNMS enchantNMS; + private EnchantRegistry enchantRegistry; private EnchantManager enchantManager; + private EnchantNMS enchantNMS; private TierManager tierManager; @Override @@ -39,6 +39,12 @@ public class ExcellentEnchants extends NexPlugin { return this; } + @Override + public void onLoad() { + super.onLoad(); + this.enchantRegistry = new EnchantRegistry(this); + } + @Override public void enable() { this.setNMS(); @@ -46,6 +52,8 @@ public class ExcellentEnchants extends NexPlugin { this.tierManager = new TierManager(this); this.tierManager.setup(); + this.enchantRegistry.setup(); + this.enchantManager = new EnchantManager(this); this.enchantManager.setup(); } @@ -61,6 +69,7 @@ public class ExcellentEnchants extends NexPlugin { this.tierManager = null; } PlaceholderHook.shutdown(); + //this.enchantRegistry.shutdown(); Do we ever need this at all? } private void setNMS() { @@ -120,6 +129,11 @@ public class ExcellentEnchants extends NexPlugin { return tierManager; } + @NotNull + public EnchantRegistry getEnchantRegistry() { + return this.enchantRegistry; + } + @NotNull public EnchantManager getEnchantManager() { return this.enchantManager; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/FishingEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/FishingEnchant.java new file mode 100644 index 0000000..1665720 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/FishingEnchant.java @@ -0,0 +1,11 @@ +package su.nightexpress.excellentenchants.api.enchantment.type; + +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; + +public interface FishingEnchant extends IEnchantment { + + boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level); +} 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 569971f..6e46f73 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java @@ -25,8 +25,6 @@ public class EnchantManager extends AbstractManager { @Override protected void onLoad() { - EnchantRegistry.setup(); - this.enchantmentsListMenu = new EnchantmentsListMenu(this.plugin); this.addListener(new EnchantHandlerListener(this)); this.addListener(new EnchantGenericListener(this)); @@ -53,7 +51,6 @@ public class EnchantManager extends AbstractManager { this.potionEffectsTask.stop(); this.potionEffectsTask = null; } - EnchantRegistry.shutdown(); } @NotNull diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java index ef6c937..dd8e386 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java @@ -4,197 +4,125 @@ import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.jetbrains.annotations.NotNull; 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.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.fishing.AutoFishEnchant; 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.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.tier.Tier; -import java.lang.reflect.Field; import java.util.*; +import java.util.function.Supplier; import java.util.stream.Collectors; public class EnchantRegistry { - private static final ExcellentEnchants PLUGIN; - public static final Map REGISTRY_MAP; + public static final Map REGISTRY_MAP = new HashMap<>(); - public static final EnchantBlastMining BLAST_MINING; - public static final EnchantCurseOfBreaking CURSE_OF_BREAKING; - public static final EnchantCurseOfMisfortune CURSE_OF_MISFORTUNE; - public static final EnchantDivineTouch DIVINE_TOUCH; - public static final EnchantHaste HASTE; - public static final EnchantLuckyMiner LUCKY_MINER; - public static final EnchantReplanter REPLANTER; - public static final EnchantSilkChest SILK_CHEST; - public static final EnchantSmelter SMELTER; - public static final EnchantTelekinesis TELEKINESIS; - public static final EnchantTreasures TREASURES; - public static final EnchantTunnel TUNNEL; - public static final EnchantVeinminer VEINMINER; + private final ExcellentEnchants plugin; + private boolean isLocked; - public static final EnchantBaneOfNetherspawn BANE_OF_NETHERSPAWN; - public static final EnchantIceAspect ICE_ASPECT; - public static final EnchantInfernus INFERNUS; - public static final EnchantVenom VENOM; - public static final EnchantExhaust EXHAUST; - public static final EnchantWither WITHER; - public static final EnchantParalyze PARALYZE; - public static final EnchantExpHunter EXP_HUNTER; - public static final EnchantDecapitator DECAPITATOR; - public static final EnchantCutter CUTTER; - public static final EnchantConfusion CONFUSION; - public static final EnchantDoubleStrike DOUBLE_STRIKE; - public static final EnchantNimble NIMBLE; - public static final EnchantBlindness BLINDNESS; - public static final EnchantVampire VAMPIRE; - public static final EnchantCure CURE; - public static final EnchantRage RAGE; - public static final EnchantScavenger SCAVENGER; - public static final EnchantSurprise SURPRISE; - public static final EnchantTemper TEMPER; - public static final EnchantThrifty THRIFTY; - public static final EnchantThunder THUNDER; - public static final EnchantVillageDefender VILLAGE_DEFENDER; - public static final EnchantRocket ROCKET; - - public static final EnchantElementalProtection ELEMENTAL_PROTECTION; - public static final EnchantFireShield FIRE_SHIELD; - public static final EnchantFlameWalker FLAME_WALKER; - public static final EnchantHardened HARDENED; - public static final EnchantIceShield ICE_SHIELD; - public static final EnchantColdSteel COLD_STEEL; - public static final EnchantSelfDestruction SELF_DESTRUCTION; - public static final EnchantSaturation SATURATION; - public static final EnchantAquaman AQUAMAN; - public static final EnchantNightVision NIGHT_VISION; - public static final EnchantBunnyHop BUNNY_HOP; - public static final EnchantSonic SONIC; - public static final EnchantRegrowth REGROWTH; - - public static final EnchantBomber BOMBER; - public static final EnchantConfusingArrows CONFUSING_ARROWS; - public static final EnchantDragonfireArrows DRAGONFIRE_ARROWS; - public static final EnchantElectrifiedArrows ELECTRIFIED_ARROWS; - public static final EnchantEnderBow ENDER_BOW; - public static final EnchantGhast GHAST; - public static final EnchantHover HOVER; - public static final EnchantPoisonedArrows POISONED_ARROWS; - public static final EnchantWitheredArrows WITHERED_ARROWS; - public static final EnchantExplosiveArrows EXPLOSIVE_ARROWS; - - public static final EnchantCurseOfFragility CURSE_OF_FRAGILITY; - - static { - PLUGIN = ExcellentEnchants.getPlugin(ExcellentEnchants.class); - REGISTRY_MAP = new HashMap<>(); - - // Tool enchants - BLAST_MINING = init(EnchantBlastMining.class, EnchantBlastMining.ID); - CURSE_OF_BREAKING = init(EnchantCurseOfBreaking.class, EnchantCurseOfBreaking.ID); - CURSE_OF_MISFORTUNE = init(EnchantCurseOfMisfortune.class, EnchantCurseOfMisfortune.ID); - DIVINE_TOUCH = init(EnchantDivineTouch.class, EnchantDivineTouch.ID); - HASTE = init(EnchantHaste.class, EnchantHaste.ID); - LUCKY_MINER = init(EnchantLuckyMiner.class, EnchantLuckyMiner.ID); - REPLANTER = init(EnchantReplanter.class, EnchantReplanter.ID); - SILK_CHEST = init(EnchantSilkChest.class, EnchantSilkChest.ID); - SMELTER = init(EnchantSmelter.class, EnchantSmelter.ID); - TELEKINESIS = init(EnchantTelekinesis.class, EnchantTelekinesis.ID); - TREASURES = init(EnchantTreasures.class, EnchantTreasures.ID); - TUNNEL = init(EnchantTunnel.class, EnchantTunnel.ID); - VEINMINER = init(EnchantVeinminer.class, EnchantVeinminer.ID); - - // Weapon enchants - BANE_OF_NETHERSPAWN = init(EnchantBaneOfNetherspawn.class, EnchantBaneOfNetherspawn.ID); - BLINDNESS = init(EnchantBlindness.class, EnchantBlindness.ID); - CONFUSION = init(EnchantConfusion.class, EnchantConfusion.ID); - CUTTER = init(EnchantCutter.class, EnchantCutter.ID); - DECAPITATOR = init(EnchantDecapitator.class, EnchantDecapitator.ID); - DOUBLE_STRIKE = init(EnchantDoubleStrike.class, EnchantDoubleStrike.ID); - EXHAUST = init(EnchantExhaust.class, EnchantExhaust.ID); - EXP_HUNTER = init(EnchantExpHunter.class, EnchantExpHunter.ID); - ICE_ASPECT = init(EnchantIceAspect.class, EnchantIceAspect.ID); - INFERNUS = init(EnchantInfernus.class, EnchantInfernus.ID); - NIMBLE = init(EnchantNimble.class, EnchantNimble.ID); - PARALYZE = init(EnchantParalyze.class, EnchantParalyze.ID); - CURE = init(EnchantCure.class, EnchantCure.ID); - RAGE = init(EnchantRage.class, EnchantRage.ID); - ROCKET = init(EnchantRocket.class, EnchantRocket.ID); - SCAVENGER = init(EnchantScavenger.class, EnchantScavenger.ID); - SURPRISE = init(EnchantSurprise.class, EnchantSurprise.ID); - TEMPER = init(EnchantTemper.class, EnchantTemper.ID); - THRIFTY = init(EnchantThrifty.class, EnchantThrifty.ID); - THUNDER = init(EnchantThunder.class, EnchantThunder.ID); - VAMPIRE = init(EnchantVampire.class, EnchantVampire.ID); - VENOM = init(EnchantVenom.class, EnchantVenom.ID); - VILLAGE_DEFENDER = init(EnchantVillageDefender.class, EnchantVillageDefender.ID); - WITHER = init(EnchantWither.class, EnchantWither.ID); - - // Armor enchants - AQUAMAN = init(EnchantAquaman.class, EnchantAquaman.ID); - BUNNY_HOP = init(EnchantBunnyHop.class, EnchantBunnyHop.ID); - COLD_STEEL = init(EnchantColdSteel.class, EnchantColdSteel.ID); - ICE_SHIELD = init(EnchantIceShield.class, EnchantIceShield.ID); - ELEMENTAL_PROTECTION = init(EnchantElementalProtection.class, EnchantElementalProtection.ID); - FIRE_SHIELD = init(EnchantFireShield.class, EnchantFireShield.ID); - FLAME_WALKER = init(EnchantFlameWalker.class, EnchantFlameWalker.ID); - HARDENED = init(EnchantHardened.class, EnchantHardened.ID); - NIGHT_VISION = init(EnchantNightVision.class, EnchantNightVision.ID); - REGROWTH = init(EnchantRegrowth.class, EnchantRegrowth.ID); - SATURATION = init(EnchantSaturation.class, EnchantSaturation.ID); - SELF_DESTRUCTION = init(EnchantSelfDestruction.class, EnchantSelfDestruction.ID); - SONIC = init(EnchantSonic.class, EnchantSonic.ID); - - // Bow enchants - BOMBER = init(EnchantBomber.class, EnchantBomber.ID); - CONFUSING_ARROWS = init(EnchantConfusingArrows.class, EnchantConfusingArrows.ID); - DRAGONFIRE_ARROWS = init(EnchantDragonfireArrows.class, EnchantDragonfireArrows.ID); - ELECTRIFIED_ARROWS = init(EnchantElectrifiedArrows.class, EnchantElectrifiedArrows.ID); - ENDER_BOW = init(EnchantEnderBow.class, EnchantEnderBow.ID); - EXPLOSIVE_ARROWS = init(EnchantExplosiveArrows.class, EnchantExplosiveArrows.ID); - GHAST = init(EnchantGhast.class, EnchantGhast.ID); - HOVER = init(EnchantHover.class, EnchantHover.ID); - POISONED_ARROWS = init(EnchantPoisonedArrows.class, EnchantPoisonedArrows.ID); - WITHERED_ARROWS = init(EnchantWitheredArrows.class, EnchantWitheredArrows.ID); - - // Universal - CURSE_OF_FRAGILITY = init(EnchantCurseOfFragility.class, EnchantCurseOfFragility.ID); + public EnchantRegistry(@NotNull ExcellentEnchants plugin) { + this.plugin = plugin; } - public static void setup() { + public void setup() { // Prevent to register enchantments during the runtime. - if (ExcellentEnchants.isLoaded) { - REGISTRY_MAP.values().forEach(ExcellentEnchant::loadConfig); + if (this.isLocked) { + REGISTRY_MAP.values().forEach(ExcellentEnchant::loadSettings); return; } Reflex.setFieldValue(Enchantment.class, "acceptingNew", true); - for (Field field : EnchantRegistry.class.getFields()) { - if (!ExcellentEnchant.class.isAssignableFrom(field.getType())) continue; - try { - ExcellentEnchant enchant = (ExcellentEnchant) field.get(null); - EnchantRegistry.register(enchant); - } - catch (Exception e) { - e.printStackTrace(); - } - } + // Fising Enchants + this.register(AutoFishEnchant.ID,() -> new AutoFishEnchant(plugin)); + + // Tool enchants + this.register(EnchantBlastMining.ID, () -> new EnchantBlastMining(plugin)); + this.register(EnchantCurseOfBreaking.ID, () -> new EnchantCurseOfBreaking(plugin)); + this.register(EnchantCurseOfMisfortune.ID, () -> new EnchantCurseOfMisfortune(plugin)); + this.register(EnchantDivineTouch.ID, () -> new EnchantDivineTouch(plugin)); + this.register(EnchantHaste.ID, () -> new EnchantHaste(plugin)); + this.register(EnchantLuckyMiner.ID, () -> new EnchantLuckyMiner(plugin)); + this.register(EnchantReplanter.ID, () -> new EnchantReplanter(plugin)); + this.register(EnchantSilkChest.ID, () -> new EnchantSilkChest(plugin)); + this.register(EnchantSmelter.ID, () -> new EnchantSmelter(plugin)); + this.register(EnchantTelekinesis.ID, () -> new EnchantTelekinesis(plugin)); + this.register(EnchantTreasures.ID, () -> new EnchantTreasures(plugin)); + this.register(EnchantTunnel.ID, () -> new EnchantTunnel(plugin)); + this.register(EnchantVeinminer.ID, () -> new EnchantVeinminer(plugin)); + + // Weapon enchants + this.register(EnchantBaneOfNetherspawn.ID, () -> new EnchantBaneOfNetherspawn(plugin)); + this.register(EnchantBlindness.ID, () -> new EnchantBlindness(plugin)); + this.register(EnchantConfusion.ID, () -> new EnchantConfusion(plugin)); + this.register(EnchantCutter.ID, () -> new EnchantCutter(plugin)); + this.register(EnchantDecapitator.ID, () -> new EnchantDecapitator(plugin)); + this.register(EnchantDoubleStrike.ID, () -> new EnchantDoubleStrike(plugin)); + this.register(EnchantExhaust.ID, () -> new EnchantExhaust(plugin)); + this.register(EnchantExpHunter.ID, () -> new EnchantExpHunter(plugin)); + this.register(EnchantIceAspect.ID, () -> new EnchantIceAspect(plugin)); + this.register(EnchantInfernus.ID, () -> new EnchantInfernus(plugin)); + this.register(EnchantNimble.ID, () -> new EnchantNimble(plugin)); + this.register(EnchantParalyze.ID, () -> new EnchantParalyze(plugin)); + this.register(EnchantCure.ID, () -> new EnchantCure(plugin)); + this.register(EnchantRage.ID, () -> new EnchantRage(plugin)); + this.register(EnchantRocket.ID, () -> new EnchantRocket(plugin)); + this.register(EnchantScavenger.ID, () -> new EnchantScavenger(plugin)); + this.register(EnchantSurprise.ID, () -> new EnchantSurprise(plugin)); + this.register(EnchantTemper.ID, () -> new EnchantTemper(plugin)); + this.register(EnchantThrifty.ID, () -> new EnchantThrifty(plugin)); + this.register(EnchantThunder.ID, () -> new EnchantThunder(plugin)); + this.register(EnchantVampire.ID, () -> new EnchantVampire(plugin)); + this.register(EnchantVenom.ID, () -> new EnchantVenom(plugin)); + this.register(EnchantVillageDefender.ID, () -> new EnchantVillageDefender(plugin)); + this.register(EnchantWither.ID, () -> new EnchantWither(plugin)); + + // Armor enchants + this.register(EnchantAquaman.ID, () -> new EnchantAquaman(plugin)); + this.register(EnchantBunnyHop.ID, () -> new EnchantBunnyHop(plugin)); + this.register(EnchantColdSteel.ID, () -> new EnchantColdSteel(plugin)); + this.register(EnchantIceShield.ID, () -> new EnchantIceShield(plugin)); + this.register(EnchantElementalProtection.ID, () -> new EnchantElementalProtection(plugin)); + this.register(EnchantFireShield.ID, () -> new EnchantFireShield(plugin)); + this.register(EnchantFlameWalker.ID, () -> new EnchantFlameWalker(plugin)); + this.register(EnchantHardened.ID, () -> new EnchantHardened(plugin)); + this.register(EnchantNightVision.ID, () -> new EnchantNightVision(plugin)); + this.register(EnchantRegrowth.ID, () -> new EnchantRegrowth(plugin)); + this.register(EnchantSaturation.ID, () -> new EnchantSaturation(plugin)); + this.register(EnchantSelfDestruction.ID, () -> new EnchantSelfDestruction(plugin)); + this.register(EnchantSonic.ID, () -> new EnchantSonic(plugin)); + + // Bow enchants + this.register(EnchantBomber.ID, () -> new EnchantBomber(plugin)); + this.register(EnchantConfusingArrows.ID, () -> new EnchantConfusingArrows(plugin)); + this.register(EnchantDragonfireArrows.ID, () -> new EnchantDragonfireArrows(plugin)); + this.register(EnchantElectrifiedArrows.ID, () -> new EnchantElectrifiedArrows(plugin)); + this.register(EnchantEnderBow.ID, () -> new EnchantEnderBow(plugin)); + this.register(EnchantExplosiveArrows.ID, () -> new EnchantExplosiveArrows(plugin)); + this.register(EnchantGhast.ID, () -> new EnchantGhast(plugin)); + this.register(EnchantHover.ID, () -> new EnchantHover(plugin)); + this.register(EnchantPoisonedArrows.ID, () -> new EnchantPoisonedArrows(plugin)); + this.register(EnchantWitheredArrows.ID, () -> new EnchantWitheredArrows(plugin)); + + // Universal + this.register(EnchantCurseOfFragility.ID, () -> new EnchantCurseOfFragility(plugin)); Enchantment.stopAcceptingRegistrations(); - PLUGIN.info("Enchantments Registered: " + REGISTRY_MAP.size()); - ExcellentEnchants.isLoaded = true; + this.plugin.info("Enchantments Registered: " + getRegistered().size()); + this.isLocked = true; } - @SuppressWarnings("unchecked") - public static void shutdown() { - if (PLUGIN.isEnabled()) return; // Prevent to unregister enchantments during the runtime. + /*@SuppressWarnings("unchecked") + public void shutdown() { + if (this.plugin.isEnabled()) return; // Prevent to unregister enchantments during the runtime. Map byKey = (Map) Reflex.getFieldValue(Enchantment.class, "byKey"); Map byName = (Map) Reflex.getFieldValue(Enchantment.class, "byName"); @@ -211,35 +139,28 @@ public class EnchantRegistry { enchant.unregisterListeners(); } REGISTRY_MAP.clear(); - PLUGIN.info("All enchants are unregistered."); - } + this.plugin.info("All enchants are unregistered."); + }*/ - @Nullable - private static T init(@NotNull Class clazz, @NotNull String id) { - if (Config.ENCHANTMENTS_DISABLED.get().contains(id)) return null; - - try { - return clazz.getConstructor(ExcellentEnchants.class).newInstance(PLUGIN); - } - catch (Exception ex) { - ex.printStackTrace(); - return null; - } - } - - private static void register(@Nullable ExcellentEnchant enchant) { - if (enchant == null) return; + private void register(@NotNull String id, @NotNull Supplier supplier) { + if (Config.ENCHANTMENTS_DISABLED.get().contains(id)) return; + ExcellentEnchant enchant = supplier.get(); Enchantment.registerEnchantment(enchant); REGISTRY_MAP.put(enchant.getKey(), enchant); - enchant.loadConfig(); + enchant.loadSettings(); enchant.getConfig().saveChanges(); enchant.registerListeners(); - PLUGIN.info("Registered enchantment: " + enchant.getId()); + this.plugin.info("Registered enchantment: " + enchant.getId()); } @Nullable - public static ExcellentEnchant get(@NotNull NamespacedKey key) { + public static ExcellentEnchant getById(@NotNull String id) { + return getByKey(EnchantUtils.createKey(id)); + } + + @Nullable + public static ExcellentEnchant getByKey(@NotNull NamespacedKey key) { return REGISTRY_MAP.get(key); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index 892310f..e8c6755 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.IListener; +import su.nexmedia.engine.api.placeholder.PlaceholderMap; import su.nexmedia.engine.lang.LangManager; import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.NumberUtil; @@ -19,16 +20,17 @@ 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.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.EnchantDefaults; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.tier.Tier; import java.util.*; -import java.util.function.UnaryOperator; +import java.util.function.Function; import java.util.stream.Stream; public abstract class ExcellentEnchant extends Enchantment implements IEnchantment, IListener { @@ -39,60 +41,69 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme protected final EnchantPriority priority; protected final EnchantDefaults defaults; protected final NamespacedKey chargesKey; + protected final Map placeholdersMap; 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 = new JYML(plugin.getDataFolder() + "/enchants/", id + ".yml"); + this.cfg = new JYML(plugin.getDataFolder() + EnchantManager.DIR_ENCHANTS, id + ".yml"); this.priority = priority; this.chargesKey = new NamespacedKey(plugin, this.getId() + ".charges"); this.defaults = new EnchantDefaults(this); + this.placeholdersMap = new HashMap<>(); } - public void loadConfig() { + public void loadSettings() { this.cfg.reload(); + this.placeholdersMap.clear(); + this.getDefaults().load(this); - } - @NotNull - public UnaryOperator replaceAllPlaceholders(int level) { - return str -> this.replacePlaceholders(level).apply(str) - .replace(Placeholders.ENCHANTMENT_NAME, this.getDisplayName()) - .replace(Placeholders.ENCHANTMENT_NAME_FORMATTED, this.getNameFormatted(level)) - .replace(Placeholders.ENCHANTMENT_LEVEL, NumberUtil.toRoman(level)) - .replace(Placeholders.ENCHANTMENT_LEVEL_MIN, String.valueOf(this.getStartLevel())) - .replace(Placeholders.ENCHANTMENT_LEVEL_MAX, String.valueOf(this.getMaxLevel())) - .replace(Placeholders.ENCHANTMENT_TIER, this.getTier().getName()) - .replace(Placeholders.ENCHANTMENT_FIT_ITEM_TYPES, String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList())) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING, NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING))) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_VILLAGER, NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER))) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION, NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION))) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_FISHING, NumberUtil.format(this.getObtainChance(ObtainType.FISHING))) - .replace(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING, NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING))) - .replace(Placeholders.ENCHANTMENT_CHARGES_MAX_AMOUNT, String.valueOf(this.getChargesMax(level))) - .replace(Placeholders.ENCHANTMENT_CHARGES_CONSUME_AMOUNT, String.valueOf(this.getChargesConsumeAmount(level))) - .replace(Placeholders.ENCHANTMENT_CHARGES_RECHARGE_AMOUNT, String.valueOf(this.getChargesRechargeAmount(level))) - .replace(Placeholders.ENCHANTMENT_CHARGES_FUEL_ITEM, ItemUtil.getItemName(this.getChargesFuel())) - ; - } + for (int i = this.getStartLevel(); i < this.getMaxLevel() + 1; i++) { + int level = i; - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> { - str = str.replace(Placeholders.ENCHANTMENT_DESCRIPTION, String.join("\n", this.getDescription())); + PlaceholderMap map = new PlaceholderMap() + .add(Placeholders.ENCHANTMENT_DESCRIPTION, () -> String.join("\n", this.getDescription())) + .add(Placeholders.ENCHANTMENT_NAME, this::getDisplayName) + .add(Placeholders.ENCHANTMENT_NAME_FORMATTED, () -> this.getNameFormatted(level)) + .add(Placeholders.ENCHANTMENT_LEVEL, () -> NumberUtil.toRoman(level)) + .add(Placeholders.ENCHANTMENT_LEVEL_MIN, () -> String.valueOf(this.getStartLevel())) + .add(Placeholders.ENCHANTMENT_LEVEL_MAX, () -> String.valueOf(this.getMaxLevel())) + .add(Placeholders.ENCHANTMENT_TIER, () -> this.getTier().getName()) + .add(Placeholders.ENCHANTMENT_FIT_ITEM_TYPES, () -> String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList())) + .add(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING, () -> NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING))) + .add(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_VILLAGER, () -> NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER))) + .add(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION, () -> NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION))) + .add(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_FISHING, () -> NumberUtil.format(this.getObtainChance(ObtainType.FISHING))) + .add(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING, () -> NumberUtil.format(this.getObtainChance(ObtainType.MOB_SPAWNING))) + .add(Placeholders.ENCHANTMENT_CHARGES_MAX_AMOUNT, () -> NumberUtil.format(this.getChargesMax(level))) + .add(Placeholders.ENCHANTMENT_CHARGES_CONSUME_AMOUNT, () -> NumberUtil.format(this.getChargesConsumeAmount(level))) + .add(Placeholders.ENCHANTMENT_CHARGES_RECHARGE_AMOUNT, () -> NumberUtil.format(this.getChargesRechargeAmount(level))) + .add(Placeholders.ENCHANTMENT_CHARGES_FUEL_ITEM, () -> ItemUtil.getItemName(this.getChargesFuel())); if (this instanceof Chanced chanced) { - str = str.replace(Placeholders.ENCHANTMENT_CHANCE, NumberUtil.format(chanced.getTriggerChance(level))); + map.add(Placeholders.ENCHANTMENT_CHANCE, () -> NumberUtil.format(chanced.getTriggerChance(level))); } if (this instanceof Potioned potioned) { - str = str - .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())); + map.add(Placeholders.ENCHANTMENT_POTION_LEVEL, () -> NumberUtil.toRoman(potioned.getEffectAmplifier(level))); + map.add(Placeholders.ENCHANTMENT_POTION_DURATION, () -> NumberUtil.format(potioned.getEffectDuration(level) / 20D)); + map.add(Placeholders.ENCHANTMENT_POTION_TYPE, () -> LangManager.getPotionType(potioned.getEffectType())); } - return str; - }; + + this.placeholdersMap.put(level, map); + } + } + + @NotNull + public PlaceholderMap getPlaceholders(int level) { + return this.placeholdersMap.get(level); + } + + public void addPlaceholder(@NotNull String key, @NotNull Function replacer) { + for (int level = this.getStartLevel(); level < this.getMaxLevel() + 1; level++) { + this.getPlaceholders(level).add(key, replacer.apply(level)); + } } @Override @@ -172,7 +183,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme @NotNull public List getDescription(int level) { List description = new ArrayList<>(this.getDescription()); - description.replaceAll(this.replacePlaceholders(level)); + description.replaceAll(this.getPlaceholders(level).replacer()); return description; } 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 8784a88..67de252 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 @@ -27,8 +27,8 @@ public class EnchantAquaman extends ExcellentEnchant implements Potioned, Passiv } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.WATER_BREATHING, true); } 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 6ed17b8..a08aae3 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 @@ -27,8 +27,8 @@ public class EnchantBunnyHop extends ExcellentEnchant implements Potioned, Passi } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.JUMP, true); } 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 548a0cc..712c3d6 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 @@ -32,8 +32,8 @@ public class EnchantColdSteel extends ExcellentEnchant implements Chanced, Potio } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "60 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); 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 53518aa..fe02a04 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,13 +11,12 @@ 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.enchantment.config.EnchantScaler; 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; public class EnchantElementalProtection extends ExcellentEnchant { @@ -42,17 +41,8 @@ public class EnchantElementalProtection extends ExcellentEnchant { } @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_PROTECTION_AMOUNT, NumberUtil.format(this.getProtectionAmount(level))) - .replace(PLACEHOLDER_PROTECTION_CAPACITY, NumberUtil.format(this.getProtectionCapacity())) - ; - } - - @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.protectionAmount = EnchantScaler.read(this, "Settings.Protection.Amount", "0.05 * " + Placeholders.ENCHANTMENT_LEVEL, @@ -62,6 +52,9 @@ public class EnchantElementalProtection extends ExcellentEnchant { this.protectionAsModifier = JOption.create("Settings.Protection.As_Modifier", false, "When 'true' damage will be reduced by a percent of protection value.", "When 'false' damage will be reduced by a plain protection value.").read(cfg); + + this.addPlaceholder(PLACEHOLDER_PROTECTION_AMOUNT, level -> NumberUtil.format(this.getProtectionAmount(level))); + this.addPlaceholder(PLACEHOLDER_PROTECTION_CAPACITY, level -> NumberUtil.format(this.getProtectionCapacity())); } @NotNull 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 fbad30a..db63449 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,14 +8,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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; - -import java.util.function.UnaryOperator; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantFireShield extends ExcellentEnchant implements Chanced, CombatEnchant { @@ -33,16 +31,8 @@ public class EnchantFireShield extends ExcellentEnchant implements Chanced, Comb } @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_FIRE_DURATION, NumberUtil.format(this.getFireDuration(level))) - ; - } - - @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, Placeholders.ENCHANTMENT_LEVEL + " * 15.0"); @@ -51,6 +41,8 @@ public class EnchantFireShield extends ExcellentEnchant implements Chanced, Comb "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."); + + this.addPlaceholder(PLACEHOLDER_FIRE_DURATION, level -> NumberUtil.format(this.getFireDuration(level))); } @NotNull 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 a2633f6..5cb4a01 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 @@ -53,8 +53,8 @@ public class EnchantFlameWalker extends ExcellentEnchant implements ICleanable { } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.blockDecayTime = EnchantScaler.read(this, "Settings.Block_Decay", "12.0", "Sets up to how long (in seconds) blocks will stay before turn back to lava."); } 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 3653fbe..d15c978 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 @@ -31,8 +31,8 @@ public class EnchantHardened extends ExcellentEnchant implements Chanced, Potion } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "30.0 * " + Placeholders.ENCHANTMENT_LEVEL); 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 0d2b3af..d65bccb 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 @@ -34,8 +34,8 @@ public class EnchantIceShield extends ExcellentEnchant implements Chanced, Potio } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "25.0 * " + Placeholders.ENCHANTMENT_LEVEL); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.SLOW, false, "3.0 + " + Placeholders.ENCHANTMENT_LEVEL, 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 fcf52cf..9ddafa5 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 @@ -27,8 +27,8 @@ public class EnchantNightVision extends ExcellentEnchant implements Potioned, Pa } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.NIGHT_VISION, true); } 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 3552237..af82685 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 @@ -22,8 +22,6 @@ import su.nightexpress.excellentenchants.enchantment.task.AbstractEnchantmentTas import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; -import java.util.function.UnaryOperator; - public class EnchantRegrowth extends ExcellentEnchant implements Chanced, PassiveEnchant, ICleanable { public static final String ID = "regrowth"; @@ -49,8 +47,8 @@ public class EnchantRegrowth extends ExcellentEnchant implements Chanced, Passiv } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "20.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); this.healInterval = JOption.create("Settings.Heal.Interval", 100, @@ -62,6 +60,11 @@ public class EnchantRegrowth extends ExcellentEnchant implements Chanced, Passiv this.healAmount = EnchantScaler.read(this, "Settings.Heal.Amount", "0.25", "Amount of hearts to be restored."); + this.addPlaceholder(PLACEHOLDER_HEAL_AMOUNT, level -> NumberUtil.format(this.getHealAmount(level))); + this.addPlaceholder(PLACEHOLDER_HEAL_MIN_HEALTH, level -> NumberUtil.format(this.getHealMaxHealth(level))); + this.addPlaceholder(PLACEHOLDER_HEAL_MAX_HEALTH, level -> NumberUtil.format(this.getHealMaxHealth(level))); + this.addPlaceholder(PLACEHOLDER_HEAL_INTERVAL, level -> NumberUtil.format((double) this.healInterval / 20D)); + this.task = new Task(plugin); this.task.start(); } @@ -78,17 +81,6 @@ public class EnchantRegrowth extends ExcellentEnchant implements Chanced, Passiv } } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_HEAL_AMOUNT, NumberUtil.format(this.getHealAmount(level))) - .replace(PLACEHOLDER_HEAL_MIN_HEALTH, NumberUtil.format(this.getHealMaxHealth(level))) - .replace(PLACEHOLDER_HEAL_MAX_HEALTH, NumberUtil.format(this.getHealMaxHealth(level))) - .replace(PLACEHOLDER_HEAL_INTERVAL, NumberUtil.format((double) this.healInterval / 20D)) - ; - } - @NotNull @Override public ChanceImplementation getChanceImplementation() { 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 d98bae4..a4acd16 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,15 +10,13 @@ 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; 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; - public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchant, ICleanable { public static final String ID = "saturation"; @@ -41,8 +39,8 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.saturationInterval = JOption.create("Settings.Saturation.Interval", 100, "How often (in ticks) enchantment will have effect? 1 second = 20 ticks.").read(cfg); this.saturationAmount = EnchantScaler.read(this, "Settings.Saturation.Amount", Placeholders.ENCHANTMENT_LEVEL, @@ -50,6 +48,10 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan this.saturationMaxFoodLevel = EnchantScaler.read(this, "Settings.Saturation.Max_Food_Level", "20", "Maximal player's food level for the enchantment to stop feeding them."); + this.addPlaceholder(PLACEHOLDER_SATURATION_AMOUNT, level -> NumberUtil.format(this.getSaturationAmount(level))); + this.addPlaceholder(PLACEHOLDER_SATURATION_INTERVAL, level -> NumberUtil.format((double) this.saturationInterval / 20D)); + this.addPlaceholder(PLACEHOLDER_SATURATION_MAX_FOOD_LEVEL, level -> NumberUtil.format(this.getMaxFoodLevel(level))); + this.task = new Task(plugin); this.task.start(); } @@ -66,16 +68,6 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan } } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_SATURATION_AMOUNT, NumberUtil.format(this.getSaturationAmount(level))) - .replace(PLACEHOLDER_SATURATION_INTERVAL, NumberUtil.format((double) this.saturationInterval / 20D)) - .replace(PLACEHOLDER_SATURATION_MAX_FOOD_LEVEL, NumberUtil.format(this.getMaxFoodLevel(level))) - ; - } - @Override @NotNull public EnchantmentTarget getItemTarget() { 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 2d836c9..eb6a380 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,14 +13,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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; - -import java.util.function.UnaryOperator; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantSelfDestruction extends ExcellentEnchant implements Chanced, DeathEnchant { @@ -40,21 +38,15 @@ public class EnchantSelfDestruction extends ExcellentEnchant implements Chanced, } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); 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."); - } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_EXPLOSION_POWER, NumberUtil.format(this.getExplosionSize(level))) - ; + this.addPlaceholder(PLACEHOLDER_EXPLOSION_POWER, level -> NumberUtil.format(this.getExplosionSize(level))); } @NotNull 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 4be2cda..9e97483 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 @@ -27,8 +27,8 @@ public class EnchantSonic extends ExcellentEnchant implements Potioned, PassiveE } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.SPEED, true); } 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 9cd1839..a7116ab 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 @@ -13,14 +13,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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; - -import java.util.function.UnaryOperator; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantBomber extends ExcellentEnchant implements Chanced, BowEnchant { @@ -47,20 +45,15 @@ public class EnchantBomber extends ExcellentEnchant implements Chanced, BowEncha } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); 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."); - } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_FUSE_TICKS, NumberUtil.format((double) this.getFuseTicks(level) / 20D)); + this.addPlaceholder(PLACEHOLDER_FUSE_TICKS, level -> NumberUtil.format((double) this.getFuseTicks(level) / 20D)); } @NotNull 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 1061945..f749165 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 @@ -46,8 +46,8 @@ public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.SPELL_MOB)); this.chanceImplementation = ChanceImplementation.create(this, "20.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5.0"); 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 a14aca5..6aeb214 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 @@ -20,16 +20,14 @@ 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.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.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +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.config.EnchantScaler; - -import java.util.function.UnaryOperator; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced, Arrowed, BowEnchant { @@ -58,8 +56,8 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.DRAGON_BREATH)); this.chanceImplementation = ChanceImplementation.create(this, "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); @@ -69,15 +67,9 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced this.fireRadius = EnchantScaler.read(this, "Settings.Fire.Radius", "2.0 + " + Placeholders.ENCHANTMENT_LEVEL, "Sets the dragonfire cloud effect radius."); - } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_FIRE_DURATION, NumberUtil.format(this.getFireDuration(level) / 20D)) - .replace(PLACEHOLDER_FIRE_RADIUS, NumberUtil.format(this.getFireRadius(level))) - ; + this.addPlaceholder(PLACEHOLDER_FIRE_DURATION, level -> NumberUtil.format(this.getFireDuration(level) / 20D)); + this.addPlaceholder(PLACEHOLDER_FIRE_RADIUS, level -> NumberUtil.format(this.getFireRadius(level))); } @NotNull 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 fed3c1c..8f7dc00 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 @@ -51,8 +51,8 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.FIREWORKS_SPARK)); this.chanceImplementation = ChanceImplementation.create(this, "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); 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 9b6f048..e623526 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 @@ -41,8 +41,8 @@ public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Cha } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "100"); } 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 2a86755..99ebe9c 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 @@ -18,16 +18,14 @@ 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.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.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +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.config.EnchantScaler; - -import java.util.function.UnaryOperator; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, Arrowed, BowEnchant { @@ -58,8 +56,8 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.SMOKE_NORMAL)); this.chanceImplementation = ChanceImplementation.create(this, "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); @@ -72,14 +70,8 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, this.explosionSize = EnchantScaler.read(this, "Settings.Explosion.Size", "2.0 + " + Placeholders.ENCHANTMENT_LEVEL, "Sets the explosion size. The more size - the bigger explosion."); - } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_EXPLOSION_POWER, NumberUtil.format(this.getExplosionSize(level))) - ; + this.addPlaceholder(PLACEHOLDER_EXPLOSION_POWER, level -> NumberUtil.format(this.getExplosionSize(level))); } @NotNull 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 96982b3..233a14f 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 @@ -48,8 +48,8 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "100"); this.fireSpread = JOption.create("Settings.Fire_Spread", true, "When 'true' creates fire on nearby blocks.").read(cfg); 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 f1ecdec..88d34d5 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 @@ -46,8 +46,8 @@ public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.BUBBLE_POP)); this.chanceImplementation = ChanceImplementation.create(this, "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); 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 78e3a45..d435a1d 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 @@ -47,8 +47,8 @@ public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.SLIME)); this.chanceImplementation = ChanceImplementation.create(this, "25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); 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 dd7def6..7facc29 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 @@ -47,8 +47,8 @@ public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.SPELL_WITCH)); this.chanceImplementation = ChanceImplementation.create(this, "15.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5.0"); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoFishEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoFishEnchant.java new file mode 100644 index 0000000..473469b --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoFishEnchant.java @@ -0,0 +1,41 @@ +package su.nightexpress.excellentenchants.enchantment.impl.fishing; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; + +public class AutoFishEnchant extends ExcellentEnchant implements FishingEnchant { + + public static final String ID = "auto_fish"; + + public AutoFishEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Automatically reels in a hook on bite."); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(1.0); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.FISHING_ROD; + } + + @Override + public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { + if (event.getState() != PlayerFishEvent.State.BITE) return false; + + this.plugin.runTask(task -> { + if (event.isCancelled()) return; + + plugin.getEnchantNMS().sendAttackPacket(event.getPlayer(), 0); + plugin.getEnchantNMS().retrieveHook(event.getHook(), item); + }); + return true; + } +} 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 deleted file mode 100644 index 50c8b8b..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SpeedFishingEnchant.java +++ /dev/null @@ -1,5 +0,0 @@ -package su.nightexpress.excellentenchants.enchantment.impl.fishing; - -public class SpeedFishingEnchant { - -} 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 c254b82..6f34627 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,19 +16,17 @@ 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +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.type.FitItemType; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; -import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; -import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; -import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import java.util.List; -import java.util.function.UnaryOperator; public class EnchantBlastMining extends ExcellentEnchant implements Chanced, BlockBreakEnchant { @@ -52,8 +50,8 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "20.0 * " + Placeholders.ENCHANTMENT_LEVEL); this.explosionPower = EnchantScaler.read(this, "Settings.Explosion.Power", @@ -64,6 +62,8 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo "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."); + + this.addPlaceholder(PLACEHOLDER_EXPLOSION_POWER, level -> NumberUtil.format(this.getExplosionPower(level))); } @NotNull @@ -85,13 +85,6 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo return (strength >= this.getMinBlockStrength(level)); } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_EXPLOSION_POWER, NumberUtil.format(this.getExplosionPower(level))); - } - @Override @NotNull public FitItemType[] getFitItemTypes() { @@ -108,8 +101,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 (EnchantRegistry.VEINMINER != null && EnchantUtils.contains(item, EnchantRegistry.VEINMINER)) return false; - if (EnchantRegistry.TUNNEL != null && EnchantUtils.contains(item, EnchantRegistry.TUNNEL)) return false; + if (EnchantUtils.contains(item, EnchantVeinminer.ID)) return false; + if (EnchantUtils.contains(item, EnchantTunnel.ID)) 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 0261b1f..bc88ee9 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,15 +10,13 @@ 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; -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.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; -import java.util.function.UnaryOperator; - public class EnchantCurseOfBreaking extends ExcellentEnchant implements Chanced { public static final String ID = "curse_of_breaking"; @@ -35,13 +33,15 @@ public class EnchantCurseOfBreaking extends ExcellentEnchant implements Chanced } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); 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."); + + this.addPlaceholder(PLACEHOLDER_DURABILITY_AMOUNT, level -> NumberUtil.format(this.getDurabilityAmount(level))); } @Override @@ -59,13 +59,6 @@ public class EnchantCurseOfBreaking extends ExcellentEnchant implements Chanced return (int) this.durabilityAmount.getValue(level); } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_DURABILITY_AMOUNT, NumberUtil.format(this.getDurabilityAmount(level))); - } - @NotNull @Override public EnchantmentTarget getItemTarget() { 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 9f6d407..6fd9b8a 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 @@ -38,8 +38,8 @@ public class EnchantCurseOfMisfortune extends ExcellentEnchant implements Chance } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "20.0 * " + Placeholders.ENCHANTMENT_LEVEL); this.dropExp = JOption.create("Settings.Drop_Exp", false, 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 839e0b1..06735f6 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 @@ -49,8 +49,8 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "15.0 * " + Placeholders.ENCHANTMENT_LEVEL); this.spawnerName = JOption.create("Settings.Spawner_Item.Name", 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 1e1699e..2ed436e 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 @@ -27,8 +27,8 @@ public class EnchantHaste extends ExcellentEnchant implements Potioned, PassiveE } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.FAST_DIGGING, true); } 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 402c956..6bcecfe 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,15 +8,13 @@ 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -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.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; - -import java.util.function.UnaryOperator; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantLuckyMiner extends ExcellentEnchant implements Chanced, BlockBreakEnchant { @@ -34,13 +32,15 @@ public class EnchantLuckyMiner extends ExcellentEnchant implements Chanced, Bloc } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); 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."); + + this.addPlaceholder(PLACEHOLDER_EXP_MODIFIER, level -> NumberUtil.format(this.getExpModifier(level) * 100D - 100D)); } @NotNull @@ -53,14 +53,6 @@ public class EnchantLuckyMiner extends ExcellentEnchant implements Chanced, Bloc return this.expModifier.getValue(level); } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_EXP_MODIFIER, NumberUtil.format(this.getExpModifier(level) * 100D - 100D)) - ; - } - @Override @NotNull public FitItemType[] getFitItemTypes() { 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 826e2e8..ce9d047 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 @@ -49,8 +49,8 @@ public class EnchantReplanter extends ExcellentEnchant implements Chanced, Inter } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); 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); 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 894706a..3356c76 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 @@ -60,8 +60,8 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chestName = JOption.create("Settings.Chest_Item.Name", "Chest &7(" + Placeholders.GENERIC_AMOUNT + " items)", "Chest item display name.", "Use '" + Placeholders.GENERIC_AMOUNT + "' for items amount.").mapReader(Colorizer::apply).read(cfg); 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 2cbe021..b8d16cd 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 @@ -27,7 +27,6 @@ import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import java.util.Map; -import java.util.Objects; public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDropEnchant { @@ -49,8 +48,8 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 10"); @@ -59,8 +58,8 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html").read(cfg); this.smeltingTable = JOption.forMap("Settings.Smelting_Table", - str -> Material.getMaterial(str.toLowerCase()), - (cfg, path, id) -> Material.getMaterial(cfg.getString(path + "." + id, "").toUpperCase()), + key -> Material.getMaterial(key.toUpperCase()), + (cfg, path, key) -> Material.getMaterial(cfg.getString(path + "." + key, "").toUpperCase()), Map.of( Material.RAW_IRON, Material.IRON_INGOT, Material.RAW_GOLD, Material.GOLD_INGOT @@ -70,8 +69,6 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr "Note: Material source is material name of the dropped item, not the broken block!", "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 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 66c1371..73c720f 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 @@ -34,8 +34,8 @@ public class EnchantTelekinesis extends ExcellentEnchant implements Chanced, Blo } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "100"); } 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 70146cd..a9e6078 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 @@ -50,8 +50,8 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 4.0"); 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 a36946d..fd72c51 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 @@ -13,7 +13,6 @@ import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.utils.LocationUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -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; @@ -47,8 +46,8 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.disableOnSneak = JOption.create("Settings.Ignore_When_Sneaking", true, "When 'true' the enchantment won't be triggered when sneaking.").read(cfg); } @@ -70,8 +69,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 (EnchantRegistry.VEINMINER != null && EnchantUtils.contains(item, EnchantRegistry.VEINMINER)) return false; - if (EnchantRegistry.BLAST_MINING != null && EnchantUtils.contains(item, EnchantRegistry.BLAST_MINING)) return false; + if (EnchantUtils.contains(item, EnchantVeinminer.ID)) return false; + if (EnchantUtils.contains(item, EnchantBlastMining.ID)) 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; 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 c90f5a3..07fd5e2 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 @@ -15,7 +15,6 @@ import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; -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; @@ -25,7 +24,6 @@ import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; import java.util.HashSet; import java.util.Set; -import java.util.function.UnaryOperator; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -49,8 +47,8 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.blocksLimit = EnchantScaler.read(this, "Settings.Blocks.Max_At_Once", "6 + " + Placeholders.ENCHANTMENT_LEVEL, @@ -75,6 +73,8 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch "List of blocks, that will be affected by this enchantment.", "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); + + this.addPlaceholder(PLACEHOLDER_BLOCK_LIMIT, level -> String.valueOf(this.getBlocksLimit(level))); } @NotNull @@ -86,14 +86,6 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch return (int) this.blocksLimit.getValue(level); } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_BLOCK_LIMIT, String.valueOf(this.getBlocksLimit(level))) - ; - } - @Override @NotNull public FitItemType[] getFitItemTypes() { @@ -140,8 +132,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 (EnchantRegistry.TUNNEL != null && EnchantUtils.contains(tool, EnchantRegistry.TUNNEL)) return false; - if (EnchantRegistry.BLAST_MINING != null && EnchantUtils.contains(tool, EnchantRegistry.BLAST_MINING)) return false; + if (EnchantUtils.contains(tool, EnchantBlastMining.ID)) return false; + if (EnchantUtils.contains(tool, EnchantTunnel.ID)) 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/weapon/EnchantBaneOfNetherspawn.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBaneOfNetherspawn.java index d452aff..f2538de 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 @@ -18,7 +18,6 @@ import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import java.util.Set; -import java.util.function.UnaryOperator; public class EnchantBaneOfNetherspawn extends ExcellentEnchant implements CombatEnchant { @@ -44,26 +43,21 @@ public class EnchantBaneOfNetherspawn extends ExcellentEnchant implements Combat } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); 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, "Amount of additional damage."); + + this.addPlaceholder(PLACEHOLDER_DAMAGE, level -> NumberUtil.format(this.getDamageModifier(level))); } public double getDamageModifier(int level) { return this.damageFormula.getValue(level); } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_DAMAGE, NumberUtil.format(this.getDamageModifier(level))); - } - @Override @NotNull public EnchantmentTarget getItemTarget() { 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 d11c372..06c54c9 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 @@ -33,8 +33,8 @@ public class EnchantBlindness extends ExcellentEnchant implements Chanced, Potio } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "15.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 3"); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.BLINDNESS, false, 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 b68b89d..a88928e 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 @@ -34,8 +34,8 @@ public class EnchantConfusion extends ExcellentEnchant implements Chanced, Potio } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "15.0 * " + Placeholders.ENCHANTMENT_LEVEL); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.CONFUSION, false, 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 6a5813a..2f760e1 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 @@ -34,8 +34,8 @@ public class EnchantCure extends ExcellentEnchant implements Chanced, CombatEnch } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "20.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 8"); } 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 2cb403f..3f9b8c6 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 @@ -24,8 +24,6 @@ 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; - public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEnchant { public static final String ID = "cutter"; @@ -42,13 +40,15 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); 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."); + + this.addPlaceholder(PLACEHOLDER_DURABILITY_DAMAGE, level -> NumberUtil.format(this.getDurabilityReduction(level) * 100D)); } @NotNull @@ -61,13 +61,6 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn return this.durabilityReduction.getValue(level); } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_DURABILITY_DAMAGE, NumberUtil.format(this.getDurabilityReduction(level) * 100D)); - } - @Override @NotNull public EnchantmentTarget getItemTarget() { 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 66e8be4..7937fe2 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 @@ -20,7 +20,6 @@ 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; import su.nexmedia.engine.utils.PDCUtil; import su.nexmedia.engine.utils.StringUtil; @@ -58,8 +57,8 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "5.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 1.75"); 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 dc30d1b..491d70b 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 @@ -31,8 +31,8 @@ public class EnchantDoubleStrike extends ExcellentEnchant implements Chanced, Co } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "4.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 0.8"); } 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 e611e9d..d0345b8 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 @@ -34,8 +34,8 @@ public class EnchantExhaust extends ExcellentEnchant implements Chanced, Potione } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "20.0 * " + Placeholders.ENCHANTMENT_LEVEL); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.HUNGER, false, 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 ce88174..5a7ddce 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,12 +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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; - -import java.util.function.UnaryOperator; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantExpHunter extends ExcellentEnchant implements DeathEnchant { @@ -30,25 +28,19 @@ public class EnchantExpHunter extends ExcellentEnchant implements DeathEnchant { } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); 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."); + + this.addPlaceholder(PLACEHOLDER_EXP_MODIFIER, level -> NumberUtil.format(this.getExpModifier(level) * 100D - 100D)); } public final double getExpModifier(int level) { return this.expModifier.getValue(level); } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_EXP_MODIFIER, NumberUtil.format(this.getExpModifier(level) * 100D - 100D)) - ; - } - @Override @NotNull public EnchantmentTarget getItemTarget() { 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 04b07a1..368790f 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 @@ -34,8 +34,8 @@ public class EnchantIceAspect extends ExcellentEnchant implements Chanced, Potio } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "100"); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.SLOW, false, "3.0 + " + Placeholders.ENCHANTMENT_LEVEL, 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 b4bf5dc..b0600c6 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,13 +13,11 @@ 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.enchantment.config.EnchantScaler; 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; - public class EnchantInfernus extends ExcellentEnchant { public static final String ID = "infernus"; @@ -35,25 +33,19 @@ public class EnchantInfernus extends ExcellentEnchant { } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); 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."); + + this.addPlaceholder(PLACEHOLDER_FIRE_DURATION, level -> NumberUtil.format((double) this.getFireTicks(level) / 20D)); } public int getFireTicks(int level) { return (int) this.fireTicks.getValue(level); } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_FIRE_DURATION, NumberUtil.format((double) this.getFireTicks(level) / 20D)) - ; - } - @Override @NotNull public EnchantmentTarget getItemTarget() { 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 07e5c95..f874c47 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 @@ -27,8 +27,8 @@ public class EnchantNimble extends ExcellentEnchant implements Chanced, DeathEnc } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this); } 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 0f76234..f50ed68 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 @@ -33,8 +33,8 @@ public class EnchantParalyze extends ExcellentEnchant implements Chanced, Potion } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "10.0 * " + Placeholders.ENCHANTMENT_LEVEL); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.SLOW_DIGGING, false, 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 6403677..f83be3d 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 @@ -33,8 +33,8 @@ public class EnchantRage extends ExcellentEnchant implements Chanced, Potioned, } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "7.0 + " + Placeholders.ENCHANTMENT_LEVEL); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.INCREASE_DAMAGE, false, 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 4f73460..0ef7d67 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 @@ -35,8 +35,8 @@ public class EnchantRocket extends ExcellentEnchant implements Chanced, CombatEn } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "4.0 + " + Placeholders.ENCHANTMENT_LEVEL); this.fireworkPower = EnchantScaler.read(this, "Settings.Firework_Power", 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 c12d076..e3be45a 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 @@ -38,8 +38,8 @@ public class EnchantScavenger extends ExcellentEnchant implements Chanced, Death } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "15.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 10"); 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 519f1c4..943aaef 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 @@ -36,8 +36,8 @@ public class EnchantSurprise extends ExcellentEnchant implements Chanced, Potion } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "2.25 * " + Placeholders.ENCHANTMENT_LEVEL); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.BLINDNESS, false, 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 92b72a0..63a4651 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,12 +10,10 @@ 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; - -import java.util.function.UnaryOperator; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantTemper extends ExcellentEnchant implements CombatEnchant { @@ -36,8 +34,8 @@ public class EnchantTemper extends ExcellentEnchant implements CombatEnchant { } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); 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?"); @@ -45,6 +43,10 @@ public class EnchantTemper extends ExcellentEnchant implements CombatEnchant { "Maximal possible value for the Damage.Amount."); this.healthPoint = EnchantScaler.read(this, "Settings.Health.Point", "0.5", "For how much every missing hearts damage will be increased?"); + + this.addPlaceholder(PLACEHOLDER_DAMAGE_AMOUNT, level -> NumberUtil.format(this.getDamageAmount(level) * 100D)); + this.addPlaceholder(PLACEHOLDER_DAMAGE_CAPACITY, level -> NumberUtil.format(this.getDamageCapacity(level) * 100D)); + this.addPlaceholder(PLACEHOLDER_HEALTH_POINT, level -> NumberUtil.format(this.getHealthPoint(level))); } public double getDamageAmount(int level) { @@ -59,16 +61,6 @@ public class EnchantTemper extends ExcellentEnchant implements CombatEnchant { return this.healthPoint.getValue(level); } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_DAMAGE_AMOUNT, NumberUtil.format(this.getDamageAmount(level) * 100D)) - .replace(PLACEHOLDER_DAMAGE_CAPACITY, NumberUtil.format(this.getDamageCapacity(level) * 100D)) - .replace(PLACEHOLDER_HEALTH_POINT, NumberUtil.format(this.getHealthPoint(level))) - ; - } - @NotNull @Override public EnchantmentTarget getItemTarget() { 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 a3d6269..5a303f2 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 @@ -47,8 +47,8 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "5.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 3"); 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 e5faaf6..8072c01 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 @@ -35,8 +35,8 @@ public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatE } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "10.0 * " + Placeholders.ENCHANTMENT_LEVEL); this.inThunderstormOnly = JOption.create("Settings.During_Thunderstorm_Only", false, 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 abecf76..774fc59 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 @@ -21,8 +21,6 @@ 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; - public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatEnchant { public static final String ID = "vampire"; @@ -40,8 +38,8 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5.0"); @@ -50,6 +48,8 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE "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); + + this.addPlaceholder(PLACEHOLDER_HEAL_AMOUNT, level -> NumberUtil.format(this.isHealMultiplier() ? getHealAmount(level) * 100D : getHealAmount(level))); } @NotNull @@ -72,16 +72,6 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE return EnchantmentTarget.WEAPON; } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - double healAmount = this.getHealAmount(level); - - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_HEAL_AMOUNT, NumberUtil.format(this.isHealMultiplier() ? healAmount * 100D : healAmount)) - ; - } - @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; 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 b8b3e3d..a07b315 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 @@ -33,8 +33,8 @@ public class EnchantVenom extends ExcellentEnchant implements Chanced, Potioned, } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "30.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 10.0"); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.POISON, false, 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 2897fa2..1f1a524 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 @@ -9,7 +9,6 @@ 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; @@ -18,8 +17,6 @@ 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; - public class EnchantVillageDefender extends ExcellentEnchant implements CombatEnchant { public static final String ID = "village_defender"; @@ -36,8 +33,8 @@ public class EnchantVillageDefender extends ExcellentEnchant implements CombatEn } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.damageAmount = EnchantScaler.read(this, "Settings.Damage.Formula", "0.5 * " + Placeholders.ENCHANTMENT_LEVEL, @@ -45,6 +42,8 @@ public class EnchantVillageDefender extends ExcellentEnchant implements CombatEn this.damageMultiplier = JOption.create("Settings.Damage.As_Modifier", false, "When 'true' the 'Damage.Formula' will work as a multiplier to the original damage.").read(cfg); + + this.addPlaceholder(PLACEHOLDER_DAMAGE_AMOUNT, level -> NumberUtil.format(this.getDamageAddict(level))); } public double getDamageAddict(int level) { @@ -55,14 +54,6 @@ public class EnchantVillageDefender extends ExcellentEnchant implements CombatEn return damageMultiplier; } - @Override - @NotNull - public UnaryOperator replacePlaceholders(int level) { - return str -> super.replacePlaceholders(level).apply(str) - .replace(PLACEHOLDER_DAMAGE_AMOUNT, NumberUtil.format(this.getDamageAddict(level))) - ; - } - @Override @NotNull public EnchantmentTarget getItemTarget() { 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 0e739f7..e39a6bb 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 @@ -8,7 +8,6 @@ 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; @@ -34,8 +33,8 @@ public class EnchantWither extends ExcellentEnchant implements Chanced, Potioned } @Override - public void loadConfig() { - super.loadConfig(); + public void loadSettings() { + super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.WITHER, false, 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 2f429cc..da4dc34 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 @@ -15,8 +15,10 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.event.entity.*; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; @@ -205,6 +207,25 @@ public class EnchantHandlerListener extends AbstractListener }); } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEnchantFishing(PlayerFishEvent event) { + Player player = event.getPlayer(); + + ItemStack item; + ItemStack main = player.getInventory().getItem(EquipmentSlot.HAND); + ItemStack off = player.getInventory().getItem(EquipmentSlot.OFF_HAND); + if (main != null && main.getType() == Material.FISHING_ROD) item = main; + else if (off != null && off.getType() == Material.FISHING_ROD) item = off; + else return; + + EnchantUtils.getExcellents(item, FishingEnchant.class).forEach((enchant, level) -> { + if (enchant.isOutOfCharges(item)) return; + if (enchant.onFishing(event, item, level)) { + enchant.consumeCharges(item); + } + }); + } + // --------------------------------------------------------------- // Death Related Enchants // --------------------------------------------------------------- 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 c447a11..82493f1 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 @@ -4,7 +4,6 @@ import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; 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.AutoPaged; @@ -125,28 +124,27 @@ public class EnchantmentsListMenu extends ConfigMenu implemen @NotNull private ItemStack buildEnchantIcon(@NotNull ExcellentEnchant enchant, int level) { ItemStack icon = new ItemStack(this.enchantIcon); - ItemMeta meta = icon.getItemMeta(); - if (meta == null) return icon; + ItemUtil.mapMeta(icon, meta -> { + List lore = meta.getLore(); + if (lore == null) lore = new ArrayList<>(); - List lore = meta.getLore(); - if (lore == null) lore = new ArrayList<>(); + List conflicts = enchant.getConflicts().isEmpty() ? Collections.emptyList() : new ArrayList<>(this.enchantLoreConflicts); + List conflictNames = enchant.getConflicts().stream().map(key -> Enchantment.getByKey(NamespacedKey.minecraft(key))) + .filter(Objects::nonNull).map(LangManager::getEnchantment).toList(); + conflicts = StringUtil.replace(conflicts, Placeholders.ENCHANTMENT_NAME, true, conflictNames); - List conflicts = enchant.getConflicts().isEmpty() ? Collections.emptyList() : new ArrayList<>(this.enchantLoreConflicts); - List conflictNames = enchant.getConflicts().stream().map(key -> Enchantment.getByKey(NamespacedKey.minecraft(key))) - .filter(Objects::nonNull).map(LangManager::getEnchantment).toList(); - conflicts = StringUtil.replace(conflicts, Placeholders.ENCHANTMENT_NAME, true, conflictNames); + List charges = enchant.isChargesEnabled() ? new ArrayList<>(this.enchantLoreCharges) : Collections.emptyList(); + List obtaining = new ArrayList<>(this.enchantLoreObtaining); - List charges = enchant.isChargesEnabled() ? new ArrayList<>(this.enchantLoreCharges) : Collections.emptyList(); - List obtaining = new ArrayList<>(this.enchantLoreObtaining); + lore = StringUtil.replace(lore, PLACEHOLDER_CONFLICTS, false, conflicts); + lore = StringUtil.replace(lore, PLACEHOLDER_CHARGES, false, charges); + lore = StringUtil.replace(lore, PLACEHOLDER_OBTAINING, false, obtaining); + lore = StringUtil.replace(lore, Placeholders.ENCHANTMENT_DESCRIPTION, true, enchant.getDescription()); - lore = StringUtil.replace(lore, PLACEHOLDER_CONFLICTS, false, conflicts); - lore = StringUtil.replace(lore, PLACEHOLDER_CHARGES, false, charges); - lore = StringUtil.replace(lore, PLACEHOLDER_OBTAINING, false, obtaining); + meta.setLore(lore); + ItemUtil.replace(meta, enchant.getPlaceholders(level).replacer()); + }); - meta.setLore(lore); - icon.setItemMeta(meta); - - ItemUtil.replace(icon, enchant.replaceAllPlaceholders(level)); return icon; } } 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 index d3e8f65..b0fd032 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -38,6 +38,11 @@ public class EnchantUtils { public static final NamespacedKey KEY_LORE_SIZE = new NamespacedKey(ExcellentEnchantsAPI.PLUGIN, "lore_size"); + @NotNull + public static NamespacedKey createKey(@NotNull String id) { + return NamespacedKey.minecraft(id.toLowerCase()); + } + public static boolean isEnchantable(@NotNull ItemStack item) { if (item.getType().isAir()) return false; @@ -212,6 +217,13 @@ public class EnchantUtils { return getAll(item).size(); } + public static boolean contains(@NotNull ItemStack item, @NotNull String id) { + ExcellentEnchant enchant = EnchantRegistry.getById(id); + if (enchant == null) return false; + + return contains(item, enchant); + } + public static boolean contains(@NotNull ItemStack item, @NotNull Enchantment enchantment) { return getLevel(item, enchantment) > 0; } @@ -292,7 +304,7 @@ public class EnchantUtils { private static Map getExcellents(@NotNull Map enchants) { Map map = new HashMap<>(); enchants.forEach((enchantment, level) -> { - ExcellentEnchant excellent = EnchantRegistry.get(enchantment.getKey()); + ExcellentEnchant excellent = EnchantRegistry.getByKey(enchantment.getKey()); if (excellent != null) { map.put(excellent, level); } @@ -304,7 +316,7 @@ public class EnchantUtils { 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()); + ExcellentEnchant excellent = EnchantRegistry.getByKey(enchantment.getKey()); if (excellent == null || !clazz.isAssignableFrom(excellent.getClass())) return; map.put(clazz.cast(excellent), level); 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 a8621b6..c20da53 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 @@ -63,7 +63,7 @@ public class PlaceholderHook { ItemStack item = player.getInventory().getItem(slot); if (item == null || item.getType().isAir()) return "-"; - ExcellentEnchant enchant = EnchantRegistry.get(NamespacedKey.minecraft(chargesSplit[1].toLowerCase())); + ExcellentEnchant enchant = EnchantRegistry.getByKey(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 = EnchantRegistry.get(NamespacedKey.minecraft(chargesSplit[0].toLowerCase())); + ExcellentEnchant enchant = EnchantRegistry.getByKey(NamespacedKey.minecraft(chargesSplit[0].toLowerCase())); if (enchant == null) return null; int level = StringUtil.getInteger(chargesSplit[1], 1); diff --git a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java index cadf840..8bc10ba 100644 --- a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java +++ b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java @@ -2,8 +2,10 @@ package su.nightexpress.excellentenchants.nms; import org.bukkit.Location; import org.bukkit.block.Block; +import org.bukkit.entity.FishHook; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import java.util.Set; @@ -12,5 +14,7 @@ public interface EnchantNMS { void sendAttackPacket(@NotNull Player player, int id); + void retrieveHook(@NotNull FishHook hook, @NotNull ItemStack item); + @NotNull Set handleFlameWalker(@NotNull LivingEntity entity, @NotNull Location location, int level); } diff --git a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java index 9e5431d..6d64803 100644 --- a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java +++ b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.projectile.FishingHook; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -11,11 +12,15 @@ import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftFishHook; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; +import org.bukkit.entity.FishHook; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.nms.EnchantNMS; @@ -32,6 +37,13 @@ public class V1_17_R1 implements EnchantNMS { craftPlayer.getHandle().connection.send(packet); } + @Override + public void retrieveHook(@NotNull FishHook hook, @NotNull ItemStack item) { + CraftFishHook craftFishHook = (CraftFishHook) hook; + FishingHook handle = craftFishHook.getHandle(); + handle.retrieve(CraftItemStack.asNMSCopy(item)); + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { diff --git a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java index 2fdf6d3..42bd1da 100644 --- a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java +++ b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.projectile.FishingHook; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -11,11 +12,15 @@ import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_18_R2.entity.CraftFishHook; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack; +import org.bukkit.entity.FishHook; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.nms.EnchantNMS; @@ -32,6 +37,13 @@ public class V1_18_R2 implements EnchantNMS { craftPlayer.getHandle().connection.send(packet); } + @Override + public void retrieveHook(@NotNull FishHook hook, @NotNull ItemStack item) { + CraftFishHook craftFishHook = (CraftFishHook) hook; + FishingHook handle = craftFishHook.getHandle(); + handle.retrieve(CraftItemStack.asNMSCopy(item)); + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { diff --git a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java index bd5bbca..841aab7 100644 --- a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java +++ b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.projectile.FishingHook; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -11,11 +12,15 @@ import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_19_R1.entity.CraftFishHook; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack; +import org.bukkit.entity.FishHook; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.nms.EnchantNMS; @@ -32,6 +37,13 @@ public class V1_19_R1 implements EnchantNMS { craftPlayer.getHandle().connection.send(packet); } + @Override + public void retrieveHook(@NotNull FishHook hook, @NotNull ItemStack item) { + CraftFishHook craftFishHook = (CraftFishHook) hook; + FishingHook handle = craftFishHook.getHandle(); + handle.retrieve(CraftItemStack.asNMSCopy(item)); + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { diff --git a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java index c8a1a95..3a1de22 100644 --- a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java +++ b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.projectile.FishingHook; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -11,11 +12,15 @@ import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_19_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftFishHook; import org.bukkit.craftbukkit.v1_19_R2.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_19_R2.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack; +import org.bukkit.entity.FishHook; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.nms.EnchantNMS; @@ -32,6 +37,13 @@ public class V1_19_R2 implements EnchantNMS { craftPlayer.getHandle().connection.send(packet); } + @Override + public void retrieveHook(@NotNull FishHook hook, @NotNull ItemStack item) { + CraftFishHook craftFishHook = (CraftFishHook) hook; + FishingHook handle = craftFishHook.getHandle(); + handle.retrieve(CraftItemStack.asNMSCopy(item)); + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { diff --git a/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java b/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java index 4b4d3a5..5da9592 100644 --- a/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java +++ b/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.projectile.FishingHook; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -11,11 +12,15 @@ import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_19_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_19_R3.entity.CraftFishHook; import org.bukkit.craftbukkit.v1_19_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_19_R3.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack; +import org.bukkit.entity.FishHook; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.nms.EnchantNMS; @@ -32,6 +37,13 @@ public class V1_19_R3 implements EnchantNMS { craftPlayer.getHandle().connection.send(packet); } + @Override + public void retrieveHook(@NotNull FishHook hook, @NotNull ItemStack item) { + CraftFishHook craftFishHook = (CraftFishHook) hook; + FishingHook handle = craftFishHook.getHandle(); + handle.retrieve(CraftItemStack.asNMSCopy(item)); + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { From 15f367c22f621e24b09fbee17f875f801d4c34e9 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Tue, 16 May 2023 01:53:13 +0600 Subject: [PATCH 35/69] v3.4.0 --- Core/pom.xml | 14 ++-- .../excellentenchants/ExcellentEnchants.java | 6 +- .../enchantment/EnchantRegistry.java | 14 +++- .../enchantment/impl/ExcellentEnchant.java | 3 + .../impl/armor/EnchantFlameWalker.java | 29 ++++++- .../impl/armor/EnchantIceShield.java | 2 +- .../impl/bow/EnchantElectrifiedArrows.java | 2 +- ...oFishEnchant.java => AutoReelEnchant.java} | 7 +- .../impl/fishing/CurseOfDrownedEnchant.java | 72 +++++++++++++++++ .../impl/fishing/DoubleCatchEnchant.java | 61 +++++++++++++++ .../impl/fishing/RiverMasterEnchant.java | 68 ++++++++++++++++ .../impl/fishing/SeasonedAnglerEnchant.java | 61 +++++++++++++++ .../impl/fishing/SurvivalistEnchant.java | 78 +++++++++++++++++++ .../impl/meta/PotionImplementation.java | 6 +- .../impl/weapon/EnchantDecapitator.java | 2 +- .../impl/weapon/EnchantIceAspect.java | 2 +- .../impl/weapon/EnchantThrifty.java | 13 +--- .../listener/EnchantGenericListener.java | 5 +- .../listener/EnchantHandlerListener.java | 14 ++-- .../enchantment/util/EnchantUtils.java | 20 ++++- NMS/pom.xml | 2 +- .../excellentenchants/nms/EnchantNMS.java | 3 + V1_17_R1/pom.xml | 4 +- .../nms/v1_17_R1/V1_17_R1.java | 14 ++++ V1_18_R2/pom.xml | 4 +- .../nms/v1_18_R2/V1_18_R2.java | 14 ++++ V1_19_R1/pom.xml | 4 +- .../nms/v1_19_R1/V1_19_R1.java | 14 ++++ V1_19_R2/pom.xml | 4 +- .../nms/v1_19_R2/V1_19_R2.java | 14 ++++ V1_19_R3/pom.xml | 4 +- .../nms/v1_19_R3/V1_19_R3.java | 14 ++++ pom.xml | 2 +- 33 files changed, 513 insertions(+), 63 deletions(-) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/{AutoFishEnchant.java => AutoReelEnchant.java} (84%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/DoubleCatchEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/RiverMasterEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SeasonedAnglerEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SurvivalistEnchant.java diff --git a/Core/pom.xml b/Core/pom.xml index 60fd057..374e291 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.4 + 3.4.0 4.0.0 @@ -72,32 +72,32 @@ su.nightexpress.excellentenchants NMS - 3.3.4 + 3.4.0 su.nightexpress.excellentenchants V1_19_R3 - 3.3.4 + 3.4.0 su.nightexpress.excellentenchants V1_19_R2 - 3.3.4 + 3.4.0 su.nightexpress.excellentenchants V1_19_R1 - 3.3.4 + 3.4.0 su.nightexpress.excellentenchants V1_18_R2 - 3.3.4 + 3.4.0 su.nightexpress.excellentenchants V1_17_R1 - 3.3.4 + 3.4.0 fr.neatmonster diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 458eaa6..966f7d6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -29,9 +29,9 @@ import su.nightexpress.excellentenchants.tier.TierManager; public class ExcellentEnchants extends NexPlugin { private EnchantRegistry enchantRegistry; - private EnchantManager enchantManager; - private EnchantNMS enchantNMS; - private TierManager tierManager; + private EnchantManager enchantManager; + private EnchantNMS enchantNMS; + private TierManager tierManager; @Override @NotNull diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java index dd8e386..1cc3cb8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java @@ -10,7 +10,7 @@ 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.fishing.AutoFishEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.fishing.*; import su.nightexpress.excellentenchants.enchantment.impl.tool.*; import su.nightexpress.excellentenchants.enchantment.impl.universal.EnchantCurseOfFragility; import su.nightexpress.excellentenchants.enchantment.impl.weapon.*; @@ -35,14 +35,22 @@ public class EnchantRegistry { public void setup() { // Prevent to register enchantments during the runtime. if (this.isLocked) { - REGISTRY_MAP.values().forEach(ExcellentEnchant::loadSettings); + REGISTRY_MAP.values().forEach(enchant -> { + enchant.loadSettings(); + enchant.registerListeners(); + }); return; } Reflex.setFieldValue(Enchantment.class, "acceptingNew", true); // Fising Enchants - this.register(AutoFishEnchant.ID,() -> new AutoFishEnchant(plugin)); + this.register(AutoReelEnchant.ID,() -> new AutoReelEnchant(plugin)); + this.register(DoubleCatchEnchant.ID, () -> new DoubleCatchEnchant(plugin)); + this.register(SeasonedAnglerEnchant.ID, () -> new SeasonedAnglerEnchant(plugin)); + this.register(SurvivalistEnchant.ID, () -> new SurvivalistEnchant(plugin)); + this.register(CurseOfDrownedEnchant.ID, () -> new CurseOfDrownedEnchant(plugin)); + this.register(RiverMasterEnchant.ID, () -> new RiverMasterEnchant(plugin)); // Tool enchants this.register(EnchantBlastMining.ID, () -> new EnchantBlastMining(plugin)); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index e8c6755..718688b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -97,6 +97,9 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme @NotNull public PlaceholderMap getPlaceholders(int level) { + if (level > this.getMaxLevel()) level = this.getMaxLevel(); + if (level < this.getStartLevel()) level = this.getStartLevel(); + return this.placeholdersMap.get(level); } 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 5cb4a01..61363e8 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 @@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.manager.ICleanable; import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.api.server.AbstractTask; +import su.nexmedia.engine.utils.Pair; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; @@ -29,6 +30,7 @@ import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; import java.util.stream.Stream; public class EnchantFlameWalker extends ExcellentEnchant implements ICleanable { @@ -36,7 +38,7 @@ public class EnchantFlameWalker extends ExcellentEnchant implements ICleanable { public static final String ID = "flame_walker"; private static final BlockFace[] FACES = {BlockFace.SOUTH, BlockFace.NORTH, BlockFace.EAST, BlockFace.WEST}; - private static final Map BLOCKS_TO_DESTROY = new ConcurrentHashMap<>(); + private static final Map> BLOCKS_TO_DESTROY = new ConcurrentHashMap<>(); private EnchantScaler blockDecayTime; private BlockTickTask blockTickTask; @@ -70,7 +72,7 @@ public class EnchantFlameWalker extends ExcellentEnchant implements ICleanable { } public static void addBlock(@NotNull Block block, double seconds) { - BLOCKS_TO_DESTROY.put(block, (long) (System.currentTimeMillis() + seconds * 1000L)); + BLOCKS_TO_DESTROY.put(block, Pair.of(System.currentTimeMillis() + (long) seconds * 1000L, Rnd.get(100))); } @Override @@ -148,13 +150,32 @@ public class EnchantFlameWalker extends ExcellentEnchant implements ICleanable { BLOCKS_TO_DESTROY.keySet().removeIf(block -> { if (block.isEmpty()) return true; - long time = BLOCKS_TO_DESTROY.get(block); + Pair pair = BLOCKS_TO_DESTROY.get(block); + long time = pair.getFirst(); if (now >= time) { + block.getWorld().getPlayers().forEach(player -> { + player.sendBlockDamage(block.getLocation(), 0F, pair.getSecond()); + }); + block.setType(Material.LAVA); - SimpleParticle.of(Particle.BLOCK_CRACK, Material.MAGMA_BLOCK) + + SimpleParticle.of(Particle.BLOCK_CRACK, Material.MAGMA_BLOCK.createBlockData()) .play(block.getLocation(), 0.5, 0.7, 0.5, 0.03, 30); + return true; } + else { + long diff = TimeUnit.MILLISECONDS.toSeconds(time - now); + + float progress = (float) (1D - Math.min(1D, diff / 5D)); + if (progress > 1F) progress = 1F; + if (progress < 0F) progress = 0F; + + float finalProgress = progress; + block.getWorld().getPlayers().forEach(player -> { + player.sendBlockDamage(block.getLocation(), finalProgress, pair.getSecond()); + }); + } return false; }); } 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 d65bccb..06bbc66 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 @@ -74,7 +74,7 @@ public class EnchantIceShield extends ExcellentEnchant implements Chanced, Potio damager.setFreezeTicks(damager.getMaxFreezeTicks()); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.BLOCK_CRACK, Material.ICE) + SimpleParticle.of(Particle.BLOCK_CRACK, Material.ICE.createBlockData()) .play(damager.getEyeLocation(), 0.25, 0.1, 20); } return true; 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 8f7dc00..d959a48 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 @@ -92,7 +92,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance block.getWorld().strikeLightning(block.getLocation()).setMetadata(META_NO_ITEM_DAMAGE, new FixedMetadataValue(plugin, true)); if (this.hasVisualEffects()) { Location center = LocationUtil.getCenter(block.getLocation()); - SimpleParticle.of(Particle.BLOCK_CRACK, block.getType()).play(center, 1, 0.05, 120); + SimpleParticle.of(Particle.BLOCK_CRACK, block.getType().createBlockData()).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/fishing/AutoFishEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoReelEnchant.java similarity index 84% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoFishEnchant.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoReelEnchant.java index 473469b..4e13cde 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoFishEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoReelEnchant.java @@ -9,11 +9,11 @@ import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -public class AutoFishEnchant extends ExcellentEnchant implements FishingEnchant { +public class AutoReelEnchant extends ExcellentEnchant implements FishingEnchant { - public static final String ID = "auto_fish"; + public static final String ID = "auto_reel"; - public AutoFishEnchant(@NotNull ExcellentEnchants plugin) { + public AutoReelEnchant(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); this.getDefaults().setDescription("Automatically reels in a hook on bite."); this.getDefaults().setLevelMax(1); @@ -29,6 +29,7 @@ public class AutoFishEnchant extends ExcellentEnchant implements FishingEnchant @Override public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { if (event.getState() != PlayerFishEvent.State.BITE) return false; + if (!this.isAvailableToUse(event.getPlayer())) return false; this.plugin.runTask(task -> { if (event.isCancelled()) return; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java new file mode 100644 index 0000000..e265a41 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java @@ -0,0 +1,72 @@ +package su.nightexpress.excellentenchants.enchantment.impl.fishing; + +import org.bukkit.Particle; +import org.bukkit.Sound; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Drowned; +import org.bukkit.entity.FishHook; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.particle.SimpleParticle; +import su.nexmedia.engine.utils.MessageUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; + +public class CurseOfDrownedEnchant extends ExcellentEnchant implements FishingEnchant, Chanced { + + public static final String ID = "curse_of_drowned"; + + private ChanceImplementation chanceImplementation; + + public CurseOfDrownedEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.HIGHEST); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to fish up a Drowned Zombie."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0D); + } + + @Override + public void loadSettings() { + super.loadSettings(); + this.chanceImplementation = ChanceImplementation.create(this, + "5.0 + " + Placeholders.ENCHANTMENT_LEVEL); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.FISHING_ROD; + } + + @Override + public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { + if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return false; + if (!this.isAvailableToUse(event.getPlayer())) return false; + if (!this.checkTriggerChance(level)) return false; + + FishHook hook = event.getHook(); + Drowned drowned = hook.getWorld().spawn(hook.getLocation(), Drowned.class); + hook.setHookedEntity(drowned); + hook.pullHookedEntity(); + + event.setCancelled(true); + + if (this.hasVisualEffects()) { + SimpleParticle.of(Particle.WATER_SPLASH).play(hook.getLocation(), 0.5, 0.1, 50); + MessageUtil.sound(event.getPlayer(), Sound.ENTITY_DROWNED_AMBIENT); + } + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/DoubleCatchEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/DoubleCatchEnchant.java new file mode 100644 index 0000000..f793cbf --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/DoubleCatchEnchant.java @@ -0,0 +1,61 @@ +package su.nightexpress.excellentenchants.enchantment.impl.fishing; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Item; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; + +public class DoubleCatchEnchant extends ExcellentEnchant implements FishingEnchant, Chanced { + + public static final String ID = "double_catch"; + + private ChanceImplementation chanceImplementation; + + public DoubleCatchEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.LOWEST); + this.getDefaults().setDescription("Increases amount of caught item by x2 with " + Placeholders.ENCHANTMENT_CHANCE + "% chance."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.5); + } + + @Override + public void loadSettings() { + super.loadSettings(); + this.chanceImplementation = ChanceImplementation.create(this, + "10.0 * " + Placeholders.ENCHANTMENT_LEVEL); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.FISHING_ROD; + } + + @Override + @NotNull + public ChanceImplementation getChanceImplementation() { + return this.chanceImplementation; + } + + @Override + public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { + if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return false; + if (!(event.getCaught() instanceof Item drop)) return false; + if (!this.isAvailableToUse(event.getPlayer())) return false; + if (!this.checkTriggerChance(level)) return false; + + ItemStack stack = drop.getItemStack(); + stack.setAmount(Math.min(stack.getMaxStackSize(), stack.getAmount() * 2)); + drop.setItemStack(stack); + + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/RiverMasterEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/RiverMasterEnchant.java new file mode 100644 index 0000000..4057e1a --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/RiverMasterEnchant.java @@ -0,0 +1,68 @@ +package su.nightexpress.excellentenchants.enchantment.impl.fishing; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.FishHook; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +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; + +public class RiverMasterEnchant extends ExcellentEnchant { + + public static final String ID = "river_master"; + + private EnchantScaler distanceMod; + + public RiverMasterEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Increases casting distance."); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.1); + } + + @Override + public void loadSettings() { + super.loadSettings(); + this.distanceMod = EnchantScaler.read(this, "Settings.Distance_Modifier", + "1.25 + " + Placeholders.ENCHANTMENT_LEVEL + " / 5", + "Multiplies the casted fish hook's velocity by specified value.", + "Setting too high values will result in hook auto removal by vanilla game/server mechanics."); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.FISHING_ROD; + } + + public double getDistanceMod(int level) { + return this.distanceMod.getValue(level); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onHookLaunch(ProjectileLaunchEvent event) { + if (!(event.getEntity() instanceof FishHook hook)) return; + if (!(hook.getShooter() instanceof Player player)) return; + if (!this.isAvailableToUse(player)) return; + + ItemStack rod = EnchantUtils.getFishingRod(player); + if (rod == null) return; + + int level = EnchantUtils.getLevel(rod, this); + if (level < 1) return; + + if (this.isOutOfCharges(rod)) return; + + hook.setVelocity(hook.getVelocity().multiply(this.getDistanceMod(level))); + + this.consumeCharges(rod); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SeasonedAnglerEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SeasonedAnglerEnchant.java new file mode 100644 index 0000000..7a2d0c5 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SeasonedAnglerEnchant.java @@ -0,0 +1,61 @@ +package su.nightexpress.excellentenchants.enchantment.impl.fishing; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.inventory.ItemStack; +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.type.FishingEnchant; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; + +public class SeasonedAnglerEnchant extends ExcellentEnchant implements FishingEnchant { + + public static final String ID = "seasoned_angler"; + + private EnchantScaler expMod; + + public SeasonedAnglerEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription("Increases amount of XP gained from fishing by " + Placeholders.GENERIC_AMOUNT + "%."); + this.getDefaults().setLevelMax(4); + this.getDefaults().setTier(0.1); + } + + @Override + public void loadSettings() { + super.loadSettings(); + this.expMod = EnchantScaler.read(this, "Settings.Exp_Percent", + "25.0 * " + Placeholders.ENCHANTMENT_LEVEL, + "Amount (in percent) of additional XP from fishing."); + + this.addPlaceholder(Placeholders.GENERIC_AMOUNT, level -> NumberUtil.format(this.getExpPercent(level))); + } + + public int getExpPercent(int level) { + return (int) this.expMod.getValue(level); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.FISHING_ROD; + } + + @Override + public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { + if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return false; + if (!this.isAvailableToUse(event.getPlayer())) return false; + if (event.getExpToDrop() == 0) return false; + + int expDrop = event.getExpToDrop(); + int expPercent = this.getExpPercent(level); + int expModified = (int) Math.ceil(expDrop * (1D + expPercent / 100D)); + + event.setExpToDrop(expModified); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SurvivalistEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SurvivalistEnchant.java new file mode 100644 index 0000000..e40c3c0 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SurvivalistEnchant.java @@ -0,0 +1,78 @@ +package su.nightexpress.excellentenchants.enchantment.impl.fishing; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Item; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.inventory.CookingRecipe; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; +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.HashSet; +import java.util.Set; + +public class SurvivalistEnchant extends ExcellentEnchant implements FishingEnchant, Chanced { + + public static final String ID = "survivalist"; + + private final Set> cookingRecipes; + + private ChanceImplementation chanceImplementation; + + public SurvivalistEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.HIGH); + this.getDefaults().setDescription("Automatically cooks fish if what is caught is raw."); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(0.4); + + this.cookingRecipes = new HashSet<>(); + } + + @Override + public void loadSettings() { + super.loadSettings(); + this.chanceImplementation = ChanceImplementation.create(this, "100"); + + this.cookingRecipes.clear(); + this.plugin.getServer().recipeIterator().forEachRemaining(recipe -> { + if (recipe instanceof CookingRecipe cookingRecipe) { + this.cookingRecipes.add(cookingRecipe); + } + }); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.FISHING_ROD; + } + + @Override + public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { + if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return false; + if (!this.isAvailableToUse(event.getPlayer())) return false; + if (!this.checkTriggerChance(level)) return false; + if (!(event.getCaught() instanceof Item drop)) return false; + + ItemStack stack = drop.getItemStack(); + + CookingRecipe recipe = this.cookingRecipes.stream().filter(r -> r.getInput().isSimilar(stack)).findFirst().orElse(null); + if (recipe == null) return false; + + ItemStack cooked = recipe.getResult(); + cooked.setAmount(stack.getAmount()); + drop.setItemStack(cooked); + return false; + } +} 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 d089168..5f8f885 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 @@ -13,7 +13,7 @@ import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; public final class PotionImplementation implements Potioned { - //private final ExcellentEnchant enchant; + private final ExcellentEnchant enchant; private final PotionEffectType effectType; private final Scaler duration; private final Scaler amplifier; @@ -22,7 +22,7 @@ public final class PotionImplementation implements Potioned { private PotionImplementation(@NotNull ExcellentEnchant enchant, @NotNull PotionEffectType effectType, boolean isPermanent, @NotNull EnchantScaler duration, @NotNull EnchantScaler amplifier) { - //this.enchant = enchant; + this.enchant = enchant; this.effectType = effectType; this.duration = duration; this.amplifier = amplifier; @@ -82,7 +82,7 @@ public final class PotionImplementation implements Potioned { int duration = this.getEffectDuration(level); int amplifier = Math.max(0, this.getEffectAmplifier(level) - 1); - return new PotionEffect(this.getEffectType(), duration, amplifier, false, false); + return new PotionEffect(this.getEffectType(), duration, amplifier, false, this.enchant.hasVisualEffects()); } public boolean addEffect(@NotNull LivingEntity target, int level) { 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 7937fe2..5535a43 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 @@ -233,7 +233,7 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea entity.getWorld().dropItemNaturally(entity.getLocation(), item); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.BLOCK_CRACK, Material.REDSTONE_BLOCK).play(entity.getEyeLocation(), 0.25, 0.15, 30); + SimpleParticle.of(Particle.BLOCK_CRACK, Material.REDSTONE_BLOCK.createBlockData()).play(entity.getEyeLocation(), 0.25, 0.15, 30); } return true; } 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 368790f..6aa4805 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 @@ -69,7 +69,7 @@ public class EnchantIceAspect extends ExcellentEnchant implements Chanced, Potio victim.setFreezeTicks(victim.getMaxFreezeTicks()); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.BLOCK_CRACK, Material.ICE).play(victim.getEyeLocation(), 0.25, 0.15, 30); + SimpleParticle.of(Particle.BLOCK_CRACK, Material.ICE.createBlockData()).play(victim.getEyeLocation(), 0.25, 0.15, 30); } return true; } 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 5a303f2..019ad66 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 @@ -1,6 +1,5 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; -import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.EntityType; @@ -89,16 +88,10 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn if (PDCUtil.getBoolean(entity, this.keyEntityIgnored).orElse(false)) return false; if (!this.checkTriggerChance(level)) return false; - Material material = Material.getMaterial(entity.getType().name() + "_SPAWN_EGG"); - if (material == null) { - if (entity.getType() == EntityType.MUSHROOM_COW) { - material = Material.MOOSHROOM_SPAWN_EGG; - } - else return false; - } + ItemStack eggItem = plugin.getEnchantNMS().getSpawnEgg(entity); + if (eggItem == null) return false; - ItemStack egg = new ItemStack(material); - e.getDrops().add(egg); + e.getDrops().add(eggItem); 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 821d90a..73902b8 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 @@ -144,8 +144,11 @@ public class EnchantGenericListener extends AbstractListener boolean expReward = recipe.hasExperienceReward(); int villagerExperience = recipe.getVillagerExperience(); float priceMultiplier = recipe.getPriceMultiplier(); + int demand = recipe.getDemand(); + int specialPrice = recipe.getSpecialPrice(); - MerchantRecipe recipe2 = new MerchantRecipe(result, uses, maxUses, expReward, villagerExperience, priceMultiplier); + MerchantRecipe recipe2 = new MerchantRecipe(result, uses, maxUses, expReward, villagerExperience, + priceMultiplier, demand, specialPrice); recipe2.setIngredients(recipe.getIngredients()); e.setRecipe(recipe2); } 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 da4dc34..2b5b22b 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 @@ -18,7 +18,6 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EntityEquipment; -import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; @@ -26,10 +25,10 @@ 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.enchantment.util.EnchantDropContainer; -import su.nightexpress.excellentenchants.api.enchantment.type.*; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; +import su.nightexpress.excellentenchants.api.enchantment.type.*; import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; public class EnchantHandlerListener extends AbstractListener { @@ -211,14 +210,11 @@ public class EnchantHandlerListener extends AbstractListener public void onEnchantFishing(PlayerFishEvent event) { Player player = event.getPlayer(); - ItemStack item; - ItemStack main = player.getInventory().getItem(EquipmentSlot.HAND); - ItemStack off = player.getInventory().getItem(EquipmentSlot.OFF_HAND); - if (main != null && main.getType() == Material.FISHING_ROD) item = main; - else if (off != null && off.getType() == Material.FISHING_ROD) item = off; - else return; + ItemStack item = EnchantUtils.getFishingRod(player); + if (item == null) return; EnchantUtils.getExcellents(item, FishingEnchant.class).forEach((enchant, level) -> { + if (event.isCancelled()) return; // Check if event was cancelled by some enchantment. if (enchant.isOutOfCharges(item)) return; if (enchant.onFishing(event, item, level)) { enchant.consumeCharges(item); 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 index b0fd032..f38ce2e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -5,6 +5,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; @@ -102,14 +103,14 @@ public class EnchantUtils { ExcellentEnchant enchant = populator.getEnchantByChance(tier); // В тире нет подходящих чар (вообще) для итема, исключаем и идем дальше. if (enchant == null) { - populator.getEnchants().remove(tier); + populator.purge(tier); continue; } // Среди уже добавленных чар есть конфликты с тем, что нашли. // Исключаем, идем дальше. if (enchantsToAdd.keySet().stream().anyMatch(has -> has.conflictsWith(enchant) || enchant.conflictsWith(has))) { - populator.getEnchants(tier).remove(enchant); + populator.purge(tier, enchant); continue; } @@ -117,12 +118,12 @@ public class EnchantUtils { // Исключаем, идем дальше. int level = levelFunc.apply(enchant); if (level < enchant.getStartLevel()) { - populator.getEnchants(tier).remove(enchant); + populator.purge(tier, enchant); continue; } // Добавляем чар, засчитываем попытку. - populator.getEnchants(tier).remove(enchant); + populator.purge(tier, enchant); enchantsToAdd.put(enchant, level); enchRoll--; } @@ -202,6 +203,17 @@ public class EnchantUtils { return true; } + @Nullable + public static ItemStack getFishingRod(@NotNull Player player) { + ItemStack main = player.getInventory().getItem(EquipmentSlot.HAND); + if (main != null && main.getType() == Material.FISHING_ROD) return main; + + ItemStack off = player.getInventory().getItem(EquipmentSlot.OFF_HAND); + if (off != null && off.getType() == Material.FISHING_ROD) return off; + + return null; + } + @NotNull public static Map getAll(@NotNull ItemStack item) { ItemMeta meta = item.getItemMeta(); diff --git a/NMS/pom.xml b/NMS/pom.xml index 881f994..5879297 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.4 + 3.4.0 4.0.0 diff --git a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java index 8bc10ba..2cd518d 100644 --- a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java +++ b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java @@ -7,6 +7,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Set; @@ -16,5 +17,7 @@ public interface EnchantNMS { void retrieveHook(@NotNull FishHook hook, @NotNull ItemStack item); + @Nullable ItemStack getSpawnEgg(@NotNull LivingEntity entity); + @NotNull Set handleFlameWalker(@NotNull LivingEntity entity, @NotNull Location location, int level); } diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index fec6efa..8e7f38f 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.4 + 3.4.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.4 + 3.4.0 diff --git a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java index 6d64803..552eb7e 100644 --- a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java +++ b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java @@ -5,6 +5,7 @@ import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.projectile.FishingHook; +import net.minecraft.world.item.SpawnEggItem; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -22,6 +23,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import su.nightexpress.excellentenchants.nms.EnchantNMS; import java.util.HashSet; @@ -44,6 +46,18 @@ public class V1_17_R1 implements EnchantNMS { handle.retrieve(CraftItemStack.asNMSCopy(item)); } + @Override + @Nullable + public ItemStack getSpawnEgg(@NotNull LivingEntity entity) { + CraftLivingEntity craftLivingEntity = (CraftLivingEntity) entity; + net.minecraft.world.entity.LivingEntity livingEntity = craftLivingEntity.getHandle(); + + SpawnEggItem eggItem = SpawnEggItem.byId(livingEntity.getType()); + if (eggItem == null) return null; + + return CraftItemStack.asBukkitCopy(eggItem.getDefaultInstance()); + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 113c38c..6f81230 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.4 + 3.4.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.4 + 3.4.0 diff --git a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java index 42bd1da..32a1472 100644 --- a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java +++ b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java @@ -5,6 +5,7 @@ import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.projectile.FishingHook; +import net.minecraft.world.item.SpawnEggItem; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -22,6 +23,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import su.nightexpress.excellentenchants.nms.EnchantNMS; import java.util.HashSet; @@ -44,6 +46,18 @@ public class V1_18_R2 implements EnchantNMS { handle.retrieve(CraftItemStack.asNMSCopy(item)); } + @Override + @Nullable + public ItemStack getSpawnEgg(@NotNull LivingEntity entity) { + CraftLivingEntity craftLivingEntity = (CraftLivingEntity) entity; + net.minecraft.world.entity.LivingEntity livingEntity = craftLivingEntity.getHandle(); + + SpawnEggItem eggItem = SpawnEggItem.byId(livingEntity.getType()); + if (eggItem == null) return null; + + return CraftItemStack.asBukkitCopy(eggItem.getDefaultInstance()); + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index e2121b0..cae16e3 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.4 + 3.4.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.4 + 3.4.0 diff --git a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java index 841aab7..0cd82d6 100644 --- a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java +++ b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java @@ -5,6 +5,7 @@ import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.projectile.FishingHook; +import net.minecraft.world.item.SpawnEggItem; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -22,6 +23,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import su.nightexpress.excellentenchants.nms.EnchantNMS; import java.util.HashSet; @@ -44,6 +46,18 @@ public class V1_19_R1 implements EnchantNMS { handle.retrieve(CraftItemStack.asNMSCopy(item)); } + @Override + @Nullable + public ItemStack getSpawnEgg(@NotNull LivingEntity entity) { + CraftLivingEntity craftLivingEntity = (CraftLivingEntity) entity; + net.minecraft.world.entity.LivingEntity livingEntity = craftLivingEntity.getHandle(); + + SpawnEggItem eggItem = SpawnEggItem.byId(livingEntity.getType()); + if (eggItem == null) return null; + + return CraftItemStack.asBukkitCopy(eggItem.getDefaultInstance()); + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml index 10cd8f8..8d443db 100644 --- a/V1_19_R2/pom.xml +++ b/V1_19_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.4 + 3.4.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.4 + 3.4.0 diff --git a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java index 3a1de22..9542b37 100644 --- a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java +++ b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java @@ -5,6 +5,7 @@ import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.projectile.FishingHook; +import net.minecraft.world.item.SpawnEggItem; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -22,6 +23,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import su.nightexpress.excellentenchants.nms.EnchantNMS; import java.util.HashSet; @@ -44,6 +46,18 @@ public class V1_19_R2 implements EnchantNMS { handle.retrieve(CraftItemStack.asNMSCopy(item)); } + @Override + @Nullable + public ItemStack getSpawnEgg(@NotNull LivingEntity entity) { + CraftLivingEntity craftLivingEntity = (CraftLivingEntity) entity; + net.minecraft.world.entity.LivingEntity livingEntity = craftLivingEntity.getHandle(); + + SpawnEggItem eggItem = SpawnEggItem.byId(livingEntity.getType()); + if (eggItem == null) return null; + + return CraftItemStack.asBukkitCopy(eggItem.getDefaultInstance()); + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 00991b8..d94498d 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.3.4 + 3.4.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.3.4 + 3.4.0 diff --git a/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java b/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java index 5da9592..d451be8 100644 --- a/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java +++ b/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java @@ -5,6 +5,7 @@ import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.projectile.FishingHook; +import net.minecraft.world.item.SpawnEggItem; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -22,6 +23,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import su.nightexpress.excellentenchants.nms.EnchantNMS; import java.util.HashSet; @@ -44,6 +46,18 @@ public class V1_19_R3 implements EnchantNMS { handle.retrieve(CraftItemStack.asNMSCopy(item)); } + @Override + @Nullable + public ItemStack getSpawnEgg(@NotNull LivingEntity entity) { + CraftLivingEntity craftLivingEntity = (CraftLivingEntity) entity; + net.minecraft.world.entity.LivingEntity livingEntity = craftLivingEntity.getHandle(); + + SpawnEggItem eggItem = SpawnEggItem.byId(livingEntity.getType()); + if (eggItem == null) return null; + + return CraftItemStack.asBukkitCopy(eggItem.getDefaultInstance()); + } + @Override @NotNull public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { diff --git a/pom.xml b/pom.xml index 9743b28..dec9a7b 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.3.4 + 3.4.0 Core NMS From 4dd67922764a7f885bf878d0cbb880c03c467666 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Mon, 29 May 2023 09:32:30 +0600 Subject: [PATCH 36/69] v3.4.1 --- Core/pom.xml | 14 +++++++------- .../enchantment/impl/weapon/EnchantConfusion.java | 2 +- .../enchantment/impl/weapon/EnchantCutter.java | 2 +- .../enchantment/impl/weapon/EnchantExhaust.java | 2 +- .../excellentenchants/tier/TierManager.java | 3 ++- 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 | 2 +- 12 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 374e291..91ee7f1 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.0 + 3.4.1 4.0.0 @@ -72,32 +72,32 @@ su.nightexpress.excellentenchants NMS - 3.4.0 + 3.4.1 su.nightexpress.excellentenchants V1_19_R3 - 3.4.0 + 3.4.1 su.nightexpress.excellentenchants V1_19_R2 - 3.4.0 + 3.4.1 su.nightexpress.excellentenchants V1_19_R1 - 3.4.0 + 3.4.1 su.nightexpress.excellentenchants V1_18_R2 - 3.4.0 + 3.4.1 su.nightexpress.excellentenchants V1_17_R1 - 3.4.0 + 3.4.1 fr.neatmonster 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 a88928e..aa456a1 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 @@ -68,7 +68,7 @@ public class EnchantConfusion extends ExcellentEnchant implements Chanced, Potio if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.ITEM_CRACK, Material.ROTTEN_FLESH) + SimpleParticle.of(Particle.ITEM_CRACK, new ItemStack(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/EnchantCutter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCutter.java index 3f9b8c6..3e22cf5 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 @@ -97,7 +97,7 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn drop.getVelocity().multiply(3D); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.ITEM_CRACK, itemCut.getType()).play(victim.getEyeLocation(), 0.25, 0.15, 30); + SimpleParticle.of(Particle.ITEM_CRACK, itemCut).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/EnchantExhaust.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExhaust.java index d0345b8..ad671b6 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 @@ -68,7 +68,7 @@ public class EnchantExhaust extends ExcellentEnchant implements Chanced, Potione if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.ITEM_CRACK, Material.ROTTEN_FLESH).play(victim.getEyeLocation(), 0.25, 0.1, 30); + SimpleParticle.of(Particle.ITEM_CRACK, new ItemStack(Material.ROTTEN_FLESH)).play(victim.getEyeLocation(), 0.25, 0.1, 30); } return true; } 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 a0cbc46..86ccaea 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java @@ -10,6 +10,7 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; public class TierManager extends AbstractManager { @@ -21,7 +22,7 @@ public class TierManager extends AbstractManager { public TierManager(@NotNull ExcellentEnchants plugin) { super(plugin); - this.tiers = new HashMap<>(); + this.tiers = new ConcurrentHashMap<>(); } diff --git a/NMS/pom.xml b/NMS/pom.xml index 5879297..1114606 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.0 + 3.4.1 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 8e7f38f..18bfc79 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.0 + 3.4.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.0 + 3.4.1 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 6f81230..8621259 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.0 + 3.4.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.0 + 3.4.1 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index cae16e3..ccc39d1 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.0 + 3.4.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.0 + 3.4.1 diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml index 8d443db..055a99d 100644 --- a/V1_19_R2/pom.xml +++ b/V1_19_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.0 + 3.4.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.0 + 3.4.1 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index d94498d..f60cc8b 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.0 + 3.4.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.0 + 3.4.1 diff --git a/pom.xml b/pom.xml index dec9a7b..63c1ec0 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.4.0 + 3.4.1 Core NMS From 11f0b489a589a365218c5d984d44bb419cf79ab2 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Wed, 31 May 2023 11:32:48 +0600 Subject: [PATCH 37/69] Minor fixes --- .../excellentenchants/enchantment/EnchantRegistry.java | 6 ++++++ .../su/nightexpress/excellentenchants/tier/TierManager.java | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java index 1cc3cb8..40a5ca0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java @@ -153,7 +153,13 @@ public class EnchantRegistry { private void register(@NotNull String id, @NotNull Supplier supplier) { if (Config.ENCHANTMENTS_DISABLED.get().contains(id)) return; + ExcellentEnchant enchant = supplier.get(); + if (Enchantment.getByKey(enchant.getKey()) != null) { + this.plugin.error("Could not register '" + enchant.getId() + "': Such enchantment already registered."); + return; + } + Enchantment.registerEnchantment(enchant); REGISTRY_MAP.put(enchant.getKey(), enchant); enchant.loadSettings(); 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 86ccaea..68384f4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java @@ -11,7 +11,6 @@ import su.nightexpress.excellentenchants.enchantment.type.ObtainType; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; public class TierManager extends AbstractManager { @@ -91,7 +90,9 @@ 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))); + Map map = new HashMap<>(); + this.getTiers().forEach(tier -> map.put(tier, tier.getChance(obtainType))); + map.values().removeIf(chance -> chance <= 0D); return Rnd.getByWeight(map); } From f153b00c7bc9f62babf536f86b6cd8ed1974b967 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Fri, 2 Jun 2023 13:13:35 +0600 Subject: [PATCH 38/69] v3.4.2 --- .../excellentenchants/enchantment/EnchantPopulator.java | 8 ++++++-- .../nightexpress/excellentenchants/tier/TierManager.java | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) 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 97c830e..63fa0d8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java @@ -72,8 +72,12 @@ public class EnchantPopulator { @Nullable public Tier getTierByChance() { - if (this.getEnchants().keySet().isEmpty()) return null; - return ExcellentEnchantsAPI.getTierManager().getTierByChance(this.getObtainType()); + Map map = this.getEnchants().keySet().stream() + .filter(tier -> tier.getChance(this.getObtainType()) > 0D) + .collect(Collectors.toMap(k -> k, v -> v.getChance(this.getObtainType()), (o, n) -> n, HashMap::new)); + if (map.isEmpty()) return null; + + return Rnd.getByWeight(map); } @Nullable 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 68384f4..94a9630 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java @@ -11,6 +11,7 @@ import su.nightexpress.excellentenchants.enchantment.type.ObtainType; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; public class TierManager extends AbstractManager { @@ -90,9 +91,11 @@ public class TierManager extends AbstractManager { @Nullable public Tier getTierByChance(@NotNull ObtainType obtainType) { - Map map = new HashMap<>(); - this.getTiers().forEach(tier -> map.put(tier, tier.getChance(obtainType))); - map.values().removeIf(chance -> chance <= 0D); + Map map = this.getTiers().stream() + .filter(tier -> tier.getChance(obtainType) > 0D) + .collect(Collectors.toMap(k -> k, v -> v.getChance(obtainType), (o, n) -> n, HashMap::new)); + if (map.isEmpty()) return null; + return Rnd.getByWeight(map); } From 82fb6dbb3b5c2d901cac280b2d44d7ce0933b259 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Thu, 15 Jun 2023 13:02:44 +0500 Subject: [PATCH 39/69] v3.4.3 --- .gitignore | 4 +- Core/pom.xml | 79 ++++++++-------- .../excellentenchants/ExcellentEnchants.java | 2 + .../impl/armor/EnchantFlameWalker.java | 2 +- .../task/AbstractEnchantmentTask.java | 2 +- 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 +- V1_20_R1/pom.xml | 71 ++++++++++++++ .../nms/v1_20_R1/V1_20_R1.java | 94 +++++++++++++++++++ pom.xml | 3 +- 14 files changed, 227 insertions(+), 52 deletions(-) create mode 100644 V1_20_R1/pom.xml create mode 100644 V1_20_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_20_R1/V1_20_R1.java diff --git a/.gitignore b/.gitignore index e400327..b413499 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,6 @@ /V1_19_R2/target/ /V1_19_R2/pom.xml.versionsBackup /V1_19_R3/target/ -/V1_19_R3/pom.xml.versionsBackup \ No newline at end of file +/V1_19_R3/pom.xml.versionsBackup +/V1_20_R1/target/ +/V1_20_R1/pom.xml.versionsBackup \ No newline at end of file diff --git a/Core/pom.xml b/Core/pom.xml index 91ee7f1..a54054a 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.1 + 3.4.3 4.0.0 @@ -62,42 +62,7 @@ org.spigotmc spigot-api - 1.19.4-R0.1-SNAPSHOT - - - su.nexmedia.playerblocktracker - PlayerBlockTracker - 1.0.1 - - - su.nightexpress.excellentenchants - NMS - 3.4.1 - - - su.nightexpress.excellentenchants - V1_19_R3 - 3.4.1 - - - su.nightexpress.excellentenchants - V1_19_R2 - 3.4.1 - - - su.nightexpress.excellentenchants - V1_19_R1 - 3.4.1 - - - su.nightexpress.excellentenchants - V1_18_R2 - 3.4.1 - - - su.nightexpress.excellentenchants - V1_17_R1 - 3.4.1 + 1.20.1-R0.1-SNAPSHOT fr.neatmonster @@ -122,6 +87,46 @@ 2.11.2 provided + + su.nexmedia.playerblocktracker + PlayerBlockTracker + 1.0.1 + + + su.nightexpress.excellentenchants + NMS + 3.4.3 + + + su.nightexpress.excellentenchants + V1_17_R1 + 3.4.3 + + + su.nightexpress.excellentenchants + V1_18_R2 + 3.4.3 + + + su.nightexpress.excellentenchants + V1_19_R1 + 3.4.3 + + + su.nightexpress.excellentenchants + V1_19_R2 + 3.4.3 + + + su.nightexpress.excellentenchants + V1_19_R3 + 3.4.3 + + + su.nightexpress.excellentenchants + V1_20_R1 + 3.4.3 + diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 966f7d6..22b20cd 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -24,6 +24,7 @@ import su.nightexpress.excellentenchants.nms.v1_18_R2.V1_18_R2; import su.nightexpress.excellentenchants.nms.v1_19_R1.V1_19_R1; import su.nightexpress.excellentenchants.nms.v1_19_R2.V1_19_R2; import su.nightexpress.excellentenchants.nms.v1_19_R3.V1_19_R3; +import su.nightexpress.excellentenchants.nms.v1_20_R1.V1_20_R1; import su.nightexpress.excellentenchants.tier.TierManager; public class ExcellentEnchants extends NexPlugin { @@ -79,6 +80,7 @@ public class ExcellentEnchants extends NexPlugin { case V1_19_R1 -> new V1_19_R1(); case V1_19_R2 -> new V1_19_R2(); case V1_19_R3 -> new V1_19_R3(); + case V1_20_R1 -> new V1_20_R1(); }; } 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 61363e8..09cd0d8 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 @@ -148,7 +148,7 @@ public class EnchantFlameWalker extends ExcellentEnchant implements ICleanable { long now = System.currentTimeMillis(); BLOCKS_TO_DESTROY.keySet().removeIf(block -> { - if (block.isEmpty()) return true; + if (block.isEmpty() || block.getType() != Material.MAGMA_BLOCK) return true; Pair pair = BLOCKS_TO_DESTROY.get(block); long time = pair.getFirst(); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/AbstractEnchantmentTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/AbstractEnchantmentTask.java index 525cb96..df7d292 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/AbstractEnchantmentTask.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/AbstractEnchantmentTask.java @@ -17,7 +17,7 @@ public abstract class AbstractEnchantmentTask extends AbstractTask getEntities() { + protected Collection getEntities() { Set list = new HashSet<>(plugin.getServer().getOnlinePlayers()); if (Config.ENCHANTMENTS_ENTITY_PASSIVE_FOR_MOBS.get()) { diff --git a/NMS/pom.xml b/NMS/pom.xml index 1114606..381596e 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.1 + 3.4.3 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 18bfc79..91407e6 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.1 + 3.4.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.1 + 3.4.3 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 8621259..fb1ff53 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.1 + 3.4.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.1 + 3.4.3 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml index ccc39d1..0a4ed48 100644 --- a/V1_19_R1/pom.xml +++ b/V1_19_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.1 + 3.4.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.1 + 3.4.3 diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml index 055a99d..8a8913c 100644 --- a/V1_19_R2/pom.xml +++ b/V1_19_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.1 + 3.4.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.1 + 3.4.3 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index f60cc8b..0d2a789 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.1 + 3.4.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.1 + 3.4.3 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml new file mode 100644 index 0000000..4a5d1ea --- /dev/null +++ b/V1_20_R1/pom.xml @@ -0,0 +1,71 @@ + + + + ExcellentEnchants + su.nightexpress.excellentenchants + 3.4.3 + + 4.0.0 + + V1_20_R1 + + + 16 + 16 + + + + + org.spigotmc + spigot + 1.20.1-R0.1-SNAPSHOT + remapped-mojang + + + su.nightexpress.excellentenchants + NMS + 3.4.3 + + + + + + + net.md-5 + specialsource-maven-plugin + 1.2.4 + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:1.20.1-R0.1-SNAPSHOT:txt:maps-mojang + true + org.spigotmc:spigot:1.20.1-R0.1-SNAPSHOT:jar:remapped-mojang + true + remapped-obf + + + + package + + remap + + remap-spigot + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:1.20.1-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.20.1-R0.1-SNAPSHOT:jar:remapped-obf + + + + + + + + \ No newline at end of file diff --git a/V1_20_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_20_R1/V1_20_R1.java b/V1_20_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_20_R1/V1_20_R1.java new file mode 100644 index 0000000..4a2dfe4 --- /dev/null +++ b/V1_20_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_20_R1/V1_20_R1.java @@ -0,0 +1,94 @@ +package su.nightexpress.excellentenchants.nms.v1_20_R1; + +import net.minecraft.core.BlockPos; +import net.minecraft.network.protocol.game.ClientboundAnimatePacket; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.projectile.FishingHook; +import net.minecraft.world.item.SpawnEggItem; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_20_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R1.entity.CraftFishHook; +import org.bukkit.craftbukkit.v1_20_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R1.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack; +import org.bukkit.entity.FishHook; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nightexpress.excellentenchants.nms.EnchantNMS; + +import java.util.HashSet; +import java.util.Set; + +public class V1_20_R1 implements EnchantNMS { + + @Override + public void sendAttackPacket(@NotNull Player player, int id) { + CraftPlayer craftPlayer = (CraftPlayer) player; + Entity entity = craftPlayer.getHandle(); + ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id); + craftPlayer.getHandle().connection.send(packet); + } + + @Override + public void retrieveHook(@NotNull FishHook hook, @NotNull ItemStack item) { + CraftFishHook craftFishHook = (CraftFishHook) hook; + FishingHook handle = craftFishHook.getHandle(); + handle.retrieve(CraftItemStack.asNMSCopy(item)); + } + + @Override + @Nullable + public ItemStack getSpawnEgg(@NotNull LivingEntity entity) { + CraftLivingEntity craftLivingEntity = (CraftLivingEntity) entity; + net.minecraft.world.entity.LivingEntity livingEntity = craftLivingEntity.getHandle(); + + SpawnEggItem eggItem = SpawnEggItem.byId(livingEntity.getType()); + if (eggItem == null) return null; + + return CraftItemStack.asBukkitCopy(eggItem.getDefaultInstance()); + } + + @Override + @NotNull + public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { + Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle(); + BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle(); + + int radius = Math.min(16, 2 + level); + BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState(); + BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos(); + + Set blocks = new HashSet<>(); + for (BlockPos posNear : BlockPos.betweenClosed(pos.offset(-radius, -1, -radius), pos.offset(radius, -1, radius))) { + if (!posNear.closerThan(entity.blockPosition(), radius)) continue; + + posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ()); + + BlockState bLavaAbove = world.getBlockState(posAbove); + BlockState bLava = world.getBlockState(posNear); + + if (!bLavaAbove.isAir()) continue; + if (!bLava.getBlock().equals(Blocks.LAVA)) continue; + if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue; + if (!bStone.canSurvive(world, posNear)) continue; + if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue; + if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue; + //world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120)); + + Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ()); + blocks.add(bukkitLoc.getBlock()); + } + return blocks; + } +} diff --git a/pom.xml b/pom.xml index 63c1ec0..3d18962 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.4.1 + 3.4.3 Core NMS @@ -16,6 +16,7 @@ V1_19_R1 V1_19_R2 V1_19_R3 + V1_20_R1 From 74c0ce96665fee928871839f4495419e1aa44895 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Fri, 16 Jun 2023 15:56:33 +0500 Subject: [PATCH 40/69] v3.4.4 Engine API Update --- .../enchantment/impl/tool/EnchantDivineTouch.java | 2 +- .../enchantment/menu/EnchantmentsListMenu.java | 6 ------ .../excellentenchants/enchantment/type/FitItemType.java | 2 +- .../su/nightexpress/excellentenchants/tier/TierManager.java | 5 ----- Core/src/main/resources/plugin.yml | 2 +- 5 files changed, 3 insertions(+), 14 deletions(-) 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 06735f6..bbf68e6 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 @@ -82,7 +82,7 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo public ItemStack getSpawner(@NotNull CreatureSpawner spawnerBlock) { ItemStack itemSpawner = new ItemStack(Material.SPAWNER); BlockStateMeta stateItem = (BlockStateMeta) itemSpawner.getItemMeta(); - if (stateItem == null) return itemSpawner; + if (stateItem == null || spawnerBlock.getSpawnedType() == null) return itemSpawner; CreatureSpawner spawnerItem = (CreatureSpawner) stateItem.getBlockState(); spawnerItem.setSpawnedType(spawnerBlock.getSpawnedType()); 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 82493f1..da3dc15 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 @@ -78,12 +78,6 @@ public class EnchantmentsListMenu extends ConfigMenu implemen return this.enchantSlots; } - @Override - @NotNull - public Comparator getObjectSorter() { - return (o1, o2) -> 0; - } - @Override @NotNull public List getObjects(@NotNull Player player) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java index f964989..ef32ade 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java @@ -42,7 +42,7 @@ public enum FitItemType { case LEGGINGS -> ItemUtil.isLeggings(item); case BOOTS -> ItemUtil.isBoots(item); case ELYTRA -> item.getType() == Material.ELYTRA; - case WEAPON -> ItemUtil.isWeapon(item); + case WEAPON -> SWORD.isIncluded(item) || ItemUtil.isTrident(item); case TOOL -> ItemUtil.isTool(item); case ARMOR -> ItemUtil.isArmor(item); case SWORD -> ItemUtil.isSword(item) || (Config.ENCHANTMENTS_ITEM_SWORD_ENCHANTS_TO_AXES.get() && AXE.isIncluded(item)); 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 94a9630..98d8b23 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java @@ -28,11 +28,6 @@ public class TierManager extends AbstractManager { @Override protected void onLoad() { - /*if (ExcellentEnchants.isLoaded) { - this.getTiers().forEach(tier -> tier.getEnchants().clear()); - return; - }*/ - this.config = JYML.loadOrExtract(plugin, FILE_NAME); for (String sId : config.getSection("")) { diff --git a/Core/src/main/resources/plugin.yml b/Core/src/main/resources/plugin.yml index d51072f..ae3c11b 100644 --- a/Core/src/main/resources/plugin.yml +++ b/Core/src/main/resources/plugin.yml @@ -4,6 +4,6 @@ name: ExcellentEnchants author: NightExpress desciption: Vanilla-like enchants for your server. depend: [ NexEngine ] -softdepend: [ ProtocolLib, NoCheatPlus, PlaceholderAPI ] +softdepend: [ ProtocolLib, NoCheatPlus, PlaceholderAPI, MythicMobs ] api-version: 1.17 load: STARTUP \ No newline at end of file From c534fa7caaa4b0ad5255edda49548227b8f765ab Mon Sep 17 00:00:00 2001 From: nulli0n Date: Tue, 11 Jul 2023 18:20:16 +0500 Subject: [PATCH 41/69] v3.4.5 --- Core/pom.xml | 22 ++--- .../excellentenchants/ExcellentEnchants.java | 15 ++- .../api/enchantment/Cleanable.java | 6 ++ .../command/BookCommand.java | 2 +- .../command/EnchantCommand.java | 2 +- .../command/TierbookCommand.java | 2 +- .../excellentenchants/config/Lang.java | 11 ++- .../enchantment/impl/ExcellentEnchant.java | 4 +- .../impl/armor/EnchantFlameWalker.java | 4 +- .../impl/armor/EnchantRegrowth.java | 4 +- .../impl/armor/EnchantSaturation.java | 4 +- .../impl/fishing/CurseOfDrownedEnchant.java | 4 +- .../impl/meta/ArrowImplementation.java | 2 +- .../impl/tool/EnchantDivineTouch.java | 8 ++ .../impl/tool/EnchantReplanter.java | 8 +- .../impl/tool/EnchantSilkChest.java | 27 +----- .../enchantment/impl/tool/EnchantSmelter.java | 3 +- .../impl/tool/EnchantTreasures.java | 10 +- .../enchantment/impl/tool/EnchantTunnel.java | 4 +- .../impl/weapon/EnchantCutter.java | 4 +- .../impl/weapon/EnchantDecapitator.java | 4 +- .../impl/weapon/EnchantDoubleStrike.java | 4 +- .../impl/weapon/EnchantRocket.java | 4 +- .../listener/EnchantAnvilListener.java | 4 +- .../listener/EnchantGenericListener.java | 6 +- .../menu/EnchantmentsListMenu.java | 6 +- .../hook/impl/NoCheatPlusHook.java | 6 +- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 +- V1_18_R2/pom.xml | 4 +- V1_19_R1/pom.xml | 71 -------------- .../nms/v1_19_R1/V1_19_R1.java | 94 ------------------- V1_19_R2/pom.xml | 70 -------------- .../nms/v1_19_R2/V1_19_R2.java | 94 ------------------- V1_19_R3/pom.xml | 4 +- V1_20_R1/pom.xml | 4 +- pom.xml | 6 +- 37 files changed, 92 insertions(+), 441 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/Cleanable.java delete mode 100644 V1_19_R1/pom.xml delete mode 100644 V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java delete mode 100644 V1_19_R2/pom.xml delete mode 100644 V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java diff --git a/Core/pom.xml b/Core/pom.xml index a54054a..8c4fc26 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.3 + 3.4.5 4.0.0 @@ -95,37 +95,27 @@ su.nightexpress.excellentenchants NMS - 3.4.3 + 3.4.5 su.nightexpress.excellentenchants V1_17_R1 - 3.4.3 + 3.4.5 su.nightexpress.excellentenchants V1_18_R2 - 3.4.3 - - - su.nightexpress.excellentenchants - V1_19_R1 - 3.4.3 - - - su.nightexpress.excellentenchants - V1_19_R2 - 3.4.3 + 3.4.5 su.nightexpress.excellentenchants V1_19_R3 - 3.4.3 + 3.4.5 su.nightexpress.excellentenchants V1_20_R1 - 3.4.3 + 3.4.5 diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 22b20cd..f07a0e6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -5,7 +5,7 @@ import su.nexmedia.engine.NexPlugin; import su.nexmedia.engine.Version; import su.nexmedia.engine.api.command.GeneralCommand; import su.nexmedia.engine.command.list.ReloadSubCommand; -import su.nexmedia.engine.hooks.Hooks; +import su.nexmedia.engine.utils.EngineUtils; import su.nightexpress.excellentenchants.command.BookCommand; import su.nightexpress.excellentenchants.command.EnchantCommand; import su.nightexpress.excellentenchants.command.ListCommand; @@ -21,8 +21,6 @@ import su.nightexpress.excellentenchants.hook.impl.ProtocolHook; import su.nightexpress.excellentenchants.nms.EnchantNMS; import su.nightexpress.excellentenchants.nms.v1_17_R1.V1_17_R1; import su.nightexpress.excellentenchants.nms.v1_18_R2.V1_18_R2; -import su.nightexpress.excellentenchants.nms.v1_19_R1.V1_19_R1; -import su.nightexpress.excellentenchants.nms.v1_19_R2.V1_19_R2; import su.nightexpress.excellentenchants.nms.v1_19_R3.V1_19_R3; import su.nightexpress.excellentenchants.nms.v1_20_R1.V1_20_R1; import su.nightexpress.excellentenchants.tier.TierManager; @@ -74,13 +72,12 @@ public class ExcellentEnchants extends NexPlugin { } private void setNMS() { - this.enchantNMS = switch (Version.CURRENT) { + this.enchantNMS = switch (Version.getCurrent()) { case V1_17_R1 -> new V1_17_R1(); case V1_18_R2 -> new V1_18_R2(); - case V1_19_R1 -> new V1_19_R1(); - case V1_19_R2 -> new V1_19_R2(); case V1_19_R3 -> new V1_19_R3(); case V1_20_R1 -> new V1_20_R1(); + default -> null; }; } @@ -92,7 +89,7 @@ public class ExcellentEnchants extends NexPlugin { @Override public void loadLang() { this.getLangManager().loadMissing(Lang.class); - this.getLangManager().setupEnum(FitItemType.class); + this.getLangManager().loadEnum(FitItemType.class); this.getLang().saveChanges(); } @@ -108,7 +105,7 @@ public class ExcellentEnchants extends NexPlugin { @Override public void registerHooks() { if (Config.ENCHANTMENTS_DISPLAY_MODE.get() == 2) { - if (Hooks.hasPlugin(HookId.PROTOCOL_LIB)) { + if (EngineUtils.hasPlugin(HookId.PROTOCOL_LIB)) { ProtocolHook.setup(); } else { @@ -116,7 +113,7 @@ public class ExcellentEnchants extends NexPlugin { Config.ENCHANTMENTS_DISPLAY_MODE.set(1); } } - if (Hooks.hasPlaceholderAPI()) { + if (EngineUtils.hasPlaceholderAPI()) { PlaceholderHook.setup(); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/Cleanable.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/Cleanable.java new file mode 100644 index 0000000..4cc9d59 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/Cleanable.java @@ -0,0 +1,6 @@ +package su.nightexpress.excellentenchants.api.enchantment; + +public interface Cleanable { + + void clear(); +} 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 2843570..6afe3e3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java @@ -76,7 +76,7 @@ public class BookCommand extends AbstractCommand { plugin.getMessage(Lang.COMMAND_BOOK_DONE) .replace(Placeholders.GENERIC_ENCHANT, LangManager.getEnchantment(enchantment)) - .replace(Placeholders.Player.replacer(player)) + .replace(Placeholders.forPlayer(player)) .send(sender); } } 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 dc9e383..94ff2fb 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java @@ -48,7 +48,7 @@ public class EnchantCommand extends AbstractCommand { Player player = (Player) sender; ItemStack item = player.getInventory().getItemInMainHand(); if (item.getType().isAir()) { - this.errorItem(sender); + this.plugin.getMessage(Lang.COMMAND_ENCHANT_ERROR_NO_ITEM).send(sender); return; } 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 f4768e6..f0d9950 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java @@ -84,7 +84,7 @@ public class TierbookCommand extends AbstractCommand { plugin.getMessage(Lang.COMMAND_TIER_BOOK_DONE) .replace(tier.replacePlaceholders()) - .replace(Placeholders.Player.replacer(player)) + .replace(Placeholders.forPlayer(player)) .send(sender); } } 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 6ce89f2..54fd362 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java @@ -8,18 +8,19 @@ public class Lang extends EngineLang { public static final LangKey COMMAND_LIST_DESC = LangKey.of("Command.List.Desc", "List of all custom enchantments."); - 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_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_ENCHANT_ERROR_NO_ITEM = LangKey.of("Command.Enchant.Error.NoItem", RED + "You must hold an item to enchant it!"); 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_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 = 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 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 = LangKey.of("Error.NoEnchant", "&cInvalid enchantment."); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index 718688b..07f4f8e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -9,7 +9,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.nexmedia.engine.api.manager.IListener; +import su.nexmedia.engine.api.manager.EventListener; import su.nexmedia.engine.api.placeholder.PlaceholderMap; import su.nexmedia.engine.lang.LangManager; import su.nexmedia.engine.utils.ItemUtil; @@ -33,7 +33,7 @@ import java.util.*; import java.util.function.Function; import java.util.stream.Stream; -public abstract class ExcellentEnchant extends Enchantment implements IEnchantment, IListener { +public abstract class ExcellentEnchant extends Enchantment implements IEnchantment, EventListener { protected final ExcellentEnchants plugin; protected final JYML cfg; 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 09cd0d8..7fb54fd 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 @@ -17,12 +17,12 @@ import org.bukkit.event.player.PlayerMoveEvent; 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.particle.SimpleParticle; import su.nexmedia.engine.api.server.AbstractTask; import su.nexmedia.engine.utils.Pair; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.Cleanable; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; @@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; -public class EnchantFlameWalker extends ExcellentEnchant implements ICleanable { +public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { public static final String ID = "flame_walker"; 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 af82685..292a3f8 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 @@ -7,12 +7,12 @@ import org.bukkit.entity.LivingEntity; 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.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.Cleanable; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; @@ -22,7 +22,7 @@ import su.nightexpress.excellentenchants.enchantment.task.AbstractEnchantmentTas import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; -public class EnchantRegrowth extends ExcellentEnchant implements Chanced, PassiveEnchant, ICleanable { +public class EnchantRegrowth extends ExcellentEnchant implements Chanced, PassiveEnchant, Cleanable { public static final String ID = "regrowth"; 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 a4acd16..a34c4e4 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 @@ -6,10 +6,10 @@ import org.bukkit.entity.Player; 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.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.Cleanable; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; @@ -17,7 +17,7 @@ import su.nightexpress.excellentenchants.enchantment.task.AbstractEnchantmentTas import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; -public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchant, ICleanable { +public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchant, Cleanable { public static final String ID = "saturation"; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java index e265a41..cf526ee 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java @@ -9,7 +9,7 @@ import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.particle.SimpleParticle; -import su.nexmedia.engine.utils.MessageUtil; +import su.nexmedia.engine.utils.PlayerUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -65,7 +65,7 @@ public class CurseOfDrownedEnchant extends ExcellentEnchant implements FishingEn if (this.hasVisualEffects()) { SimpleParticle.of(Particle.WATER_SPLASH).play(hook.getLocation(), 0.5, 0.1, 50); - MessageUtil.sound(event.getPlayer(), Sound.ENTITY_DROWNED_AMBIENT); + PlayerUtil.sound(event.getPlayer(), Sound.ENTITY_DROWNED_AMBIENT); } return true; } 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 7903f4f..dbdca1b 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 @@ -42,7 +42,7 @@ public final class ArrowImplementation implements Arrowed { (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); + ).setWriter((cfg1, path, particle1) -> particle1.write(cfg1, path)).read(cfg); return new ArrowImplementation(enchant, effect); } 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 bbf68e6..6b9643b 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 @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -21,6 +22,7 @@ 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.LocationUtil; +import su.nexmedia.engine.utils.PDCUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -40,8 +42,12 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo private String spawnerName; private ChanceImplementation chanceImplementation; + private final NamespacedKey key; + public EnchantDivineTouch(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); + this.key = new NamespacedKey(plugin, "divine_spawner"); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to mine spawner."); this.getDefaults().setLevelMax(5); this.getDefaults().setTier(1.0); @@ -91,6 +97,7 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo stateItem.setDisplayName(this.spawnerName.replace(Placeholders.GENERIC_TYPE, plugin.getLangManager().getEnum(spawnerBlock.getSpawnedType()))); itemSpawner.setItemMeta(stateItem); + PDCUtil.set(itemSpawner, this.key, true); return itemSpawner; } @@ -133,6 +140,7 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo Player player = e.getPlayer(); ItemStack spawner = player.getInventory().getItem(e.getHand()); if (spawner == null || spawner.getType() != Material.SPAWNER || !(spawner.getItemMeta() instanceof BlockStateMeta meta)) return; + if (PDCUtil.getBoolean(spawner, this.key).isEmpty()) return; CreatureSpawner spawnerItem = (CreatureSpawner) meta.getBlockState(); CreatureSpawner spawnerBlock = (CreatureSpawner) block.getState(); 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 ce9d047..ae96884 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 @@ -15,15 +15,15 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; -import su.nexmedia.engine.utils.MessageUtil; +import su.nexmedia.engine.utils.PlayerUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; -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.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.EnchantPriority; import java.util.Set; @@ -147,7 +147,7 @@ public class EnchantReplanter extends ExcellentEnchant implements Chanced, Inter if (seed == Material.NETHER_WART && blockGround.getType() == Material.SOUL_SAND || seed != Material.NETHER_WART && blockGround.getType() == Material.FARMLAND) { if (this.takeSeeds(player, seed)) { - MessageUtil.sound(player, seed == Material.NETHER_WART ? Sound.ITEM_NETHER_WART_PLANT : Sound.ITEM_CROP_PLANT); + PlayerUtil.sound(player, seed == Material.NETHER_WART ? Sound.ITEM_NETHER_WART_PLANT : Sound.ITEM_CROP_PLANT); plugin.getEnchantNMS().sendAttackPacket(player, 0); blockPlant.setType(this.fineSeedsToBlock(seed)); break; 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 3356c76..3c5b5aa 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,16 +25,14 @@ 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.type.FitItemType; 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; import java.util.List; -import java.util.Map; -import java.util.TreeMap; import java.util.stream.Stream; public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEnchant { @@ -44,7 +42,6 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha private String chestName; private List chestLore; private final NamespacedKey keyChest; - @Deprecated private final Map keyItems; public EnchantSilkChest(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGH); @@ -53,10 +50,6 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha this.getDefaults().setTier(0.5); this.keyChest = new NamespacedKey(plugin, ID + ".item"); - this.keyItems = new TreeMap<>(); - for (int pos = 0; pos < 27; pos++) { - this.getItemKey(pos); - } } @Override @@ -70,11 +63,6 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha "Use '" + Placeholders.GENERIC_AMOUNT + "' for items amount.").mapReader(Colorizer::apply).read(cfg); } - @Deprecated - private NamespacedKey getItemKey(int pos) { - return this.keyItems.computeIfAbsent(pos, key -> new NamespacedKey(plugin, "silkchest_item_" + pos)); - } - @Override @NotNull public FitItemType[] getFitItemTypes() { @@ -88,7 +76,7 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha } public boolean isSilkChest(@NotNull ItemStack item) { - return PDCUtil.getBoolean(item, this.keyChest).orElse(false) || PDCUtil.getString(item, this.getItemKey(0)).orElse(null) != null; + return PDCUtil.getBoolean(item, this.keyChest).isPresent(); } @NotNull @@ -174,15 +162,6 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha chest.setCustomName(null); chest.update(true); - - Inventory inventory = chest.getBlockInventory(); - for (int pos = 0; pos < inventory.getSize(); pos++) { - String data = PDCUtil.getString(item, this.getItemKey(pos)).orElse(null); - if (data == null) continue; - - ItemStack itemInv = ItemUtil.fromBase64(data); - inventory.setItem(pos, itemInv); - } } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) 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 b8d16cd..96419f5 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 @@ -15,7 +15,6 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; 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.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -104,7 +103,7 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr Block block = e.getBlockState().getBlock(); if (this.hasVisualEffects()) { Location location = LocationUtil.getCenter(block.getLocation(), true); - MessageUtil.sound(location, this.sound); + LocationUtil.sound(location, this.sound); 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/EnchantTreasures.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTreasures.java index a9e6078..387092a 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 @@ -10,24 +10,24 @@ 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.Placeholders; -import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.api.enchantment.Cleanable; 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.enchantment.util.EnchantDropContainer; -import su.nightexpress.excellentenchants.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.*; import java.util.function.Predicate; -public class EnchantTreasures extends ExcellentEnchant implements Chanced, BlockBreakEnchant, BlockDropEnchant, ICleanable { +public class EnchantTreasures extends ExcellentEnchant implements Chanced, BlockBreakEnchant, BlockDropEnchant, Cleanable { public static final String ID = "treasures"; private static final String META = "wasted"; 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 fd72c51..ba28789 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 @@ -10,7 +10,7 @@ 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.LocationUtil; +import su.nexmedia.engine.utils.EntityUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; @@ -75,7 +75,7 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant if (block.getType().isInteractable() && !INTERACTABLE_BLOCKS.contains(block.getType())) return false; if (block.getDrops(item).isEmpty()) return false; - BlockFace dir = LocationUtil.getDirection(player); + BlockFace dir = EntityUtil.getDirection(player); boolean isY = dir != null && block.getRelative(dir.getOppositeFace()).isEmpty(); boolean isZ = dir == BlockFace.EAST || dir == BlockFace.WEST; 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 3e22cf5..4095c45 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 @@ -12,7 +12,7 @@ import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.particle.SimpleParticle; -import su.nexmedia.engine.utils.MessageUtil; +import su.nexmedia.engine.utils.LocationUtil; import su.nexmedia.engine.utils.NumberUtil; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -98,7 +98,7 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn if (this.hasVisualEffects()) { SimpleParticle.of(Particle.ITEM_CRACK, itemCut).play(victim.getEyeLocation(), 0.25, 0.15, 30); - MessageUtil.sound(victim.getLocation(), Sound.ENTITY_ITEM_BREAK); + LocationUtil.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 5535a43..621ca7b 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 @@ -20,6 +20,7 @@ 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.Colorizer; import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PDCUtil; import su.nexmedia.engine.utils.StringUtil; @@ -71,7 +72,8 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea ).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); + "Head item display name. Use '" + Placeholders.GENERIC_TYPE + "' for entity name.") + .mapReader(Colorizer::apply).read(cfg); this.headTextures = JOption.forMap("Settings.Head_Item.Textures", id -> StringUtil.getEnum(id, EntityType.class).orElse(null), 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 491d70b..c6f5225 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 @@ -8,7 +8,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.particle.SimpleParticle; -import su.nexmedia.engine.utils.MessageUtil; +import su.nexmedia.engine.utils.LocationUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -58,7 +58,7 @@ public class EnchantDoubleStrike extends ExcellentEnchant implements Chanced, Co if (this.hasVisualEffects()) { SimpleParticle.of(Particle.EXPLOSION_NORMAL).play(victim.getEyeLocation(), 0.25, 0.15, 15); - MessageUtil.sound(victim.getLocation(), Sound.ENTITY_GENERIC_EXPLODE); + LocationUtil.sound(victim.getLocation(), Sound.ENTITY_GENERIC_EXPLODE); } 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 0ef7d67..9613c3e 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 @@ -9,7 +9,7 @@ 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.MessageUtil; +import su.nexmedia.engine.utils.LocationUtil; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; @@ -72,7 +72,7 @@ public class EnchantRocket extends ExcellentEnchant implements Chanced, CombatEn Firework firework = this.createRocket(victim.getLocation(), level); firework.addPassenger(victim); - MessageUtil.sound(victim.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_LAUNCH); + LocationUtil.sound(victim.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_LAUNCH); 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 1683df4..5abae87 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 @@ -12,8 +12,8 @@ import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.manager.AbstractListener; -import su.nexmedia.engine.utils.MessageUtil; import su.nexmedia.engine.utils.PDCUtil; +import su.nexmedia.engine.utils.PlayerUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; @@ -149,7 +149,7 @@ public class EnchantAnvilListener extends AbstractListener { e.getView().setCursor(item); e.setCancelled(false); - MessageUtil.sound(player, Sound.BLOCK_ENCHANTMENT_TABLE_USE); + PlayerUtil.sound(player, Sound.BLOCK_ENCHANTMENT_TABLE_USE); ItemStack second = inventory.getItem(1); if (second != null && !second.getType().isAir()) { 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 73902b8..0b7e213 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 @@ -19,11 +19,11 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.manager.AbstractListener; -import su.nexmedia.engine.hooks.Hooks; +import su.nexmedia.engine.utils.EngineUtils; import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.EnchantManager; +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.hook.HookId; @@ -191,7 +191,7 @@ public class EnchantGenericListener extends AbstractListener EntityEquipment equipment = entity.getEquipment(); if (equipment == null) return; - boolean isMythic = Hooks.hasPlugin(HookId.MYTHIC_MOBS) && MythicMobsHook.isMythicMob(entity); + boolean isMythic = EngineUtils.hasPlugin(HookId.MYTHIC_MOBS) && MythicMobsHook.isMythicMob(entity); boolean doPopulation = Config.getObtainSettings(ObtainType.MOB_SPAWNING).isPresent() && !isMythic; for (EquipmentSlot slot : EquipmentSlot.values()) { 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 da3dc15..5dd50f3 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 @@ -130,9 +130,9 @@ public class EnchantmentsListMenu extends ConfigMenu implemen List charges = enchant.isChargesEnabled() ? new ArrayList<>(this.enchantLoreCharges) : Collections.emptyList(); List obtaining = new ArrayList<>(this.enchantLoreObtaining); - lore = StringUtil.replace(lore, PLACEHOLDER_CONFLICTS, false, conflicts); - lore = StringUtil.replace(lore, PLACEHOLDER_CHARGES, false, charges); - lore = StringUtil.replace(lore, PLACEHOLDER_OBTAINING, false, obtaining); + lore = StringUtil.replaceInList(lore, PLACEHOLDER_CONFLICTS, conflicts); + lore = StringUtil.replaceInList(lore, PLACEHOLDER_CHARGES, charges); + lore = StringUtil.replaceInList(lore, PLACEHOLDER_OBTAINING, obtaining); lore = StringUtil.replace(lore, Placeholders.ENCHANTMENT_DESCRIPTION, true, enchant.getDescription()); meta.setLore(lore); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/NoCheatPlusHook.java b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/NoCheatPlusHook.java index 2ce103d..9cc6458 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/NoCheatPlusHook.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/hook/impl/NoCheatPlusHook.java @@ -5,19 +5,19 @@ import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.hooks.ExemptionContext; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.hooks.Hooks; +import su.nexmedia.engine.utils.EngineUtils; import su.nightexpress.excellentenchants.hook.HookId; public class NoCheatPlusHook { public static void exemptBlocks(@NotNull Player player) { - if (!Hooks.hasPlugin(HookId.NCP)) return; + if (!EngineUtils.hasPlugin(HookId.NCP)) return; NCPAPIProvider.getNoCheatPlusAPI().getPlayerDataManager().getPlayerData(player).exempt(CheckType.BLOCKBREAK, ExemptionContext.ANONYMOUS_NESTED); } public static void unexemptBlocks(@NotNull Player player) { - if (!Hooks.hasPlugin(HookId.NCP)) return; + if (!EngineUtils.hasPlugin(HookId.NCP)) return; NCPAPIProvider.getNoCheatPlusAPI().getPlayerDataManager().getPlayerData(player).unexempt(CheckType.BLOCKBREAK, ExemptionContext.ANONYMOUS_NESTED); } diff --git a/NMS/pom.xml b/NMS/pom.xml index 381596e..57c1252 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.3 + 3.4.5 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 91407e6..f949ea7 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.3 + 3.4.5 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.3 + 3.4.5 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index fb1ff53..18554b4 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.3 + 3.4.5 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.3 + 3.4.5 diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml deleted file mode 100644 index 0a4ed48..0000000 --- a/V1_19_R1/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - ExcellentEnchants - su.nightexpress.excellentenchants - 3.4.3 - - 4.0.0 - - V1_19_R1 - - - 16 - 16 - - - - - org.spigotmc - spigot - 1.19.2-R0.1-SNAPSHOT - remapped-mojang - - - su.nightexpress.excellentenchants - NMS - 3.4.3 - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:1.19.2-R0.1-SNAPSHOT:txt:maps-mojang - true - org.spigotmc:spigot:1.19.2-R0.1-SNAPSHOT:jar:remapped-mojang - true - remapped-obf - - - - package - - remap - - remap-spigot - - ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.19.2-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.19.2-R0.1-SNAPSHOT:jar:remapped-obf - - - - - - - - \ No newline at end of file diff --git a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java b/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java deleted file mode 100644 index 0cd82d6..0000000 --- a/V1_19_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R1/V1_19_R1.java +++ /dev/null @@ -1,94 +0,0 @@ -package su.nightexpress.excellentenchants.nms.v1_19_R1; - -import net.minecraft.core.BlockPos; -import net.minecraft.network.protocol.game.ClientboundAnimatePacket; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.projectile.FishingHook; -import net.minecraft.world.item.SpawnEggItem; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.LiquidBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.shapes.CollisionContext; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_19_R1.entity.CraftFishHook; -import org.bukkit.craftbukkit.v1_19_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory; -import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack; -import org.bukkit.entity.FishHook; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import su.nightexpress.excellentenchants.nms.EnchantNMS; - -import java.util.HashSet; -import java.util.Set; - -public class V1_19_R1 implements EnchantNMS { - - @Override - public void sendAttackPacket(@NotNull Player player, int id) { - CraftPlayer craftPlayer = (CraftPlayer) player; - Entity entity = craftPlayer.getHandle(); - ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id); - craftPlayer.getHandle().connection.send(packet); - } - - @Override - public void retrieveHook(@NotNull FishHook hook, @NotNull ItemStack item) { - CraftFishHook craftFishHook = (CraftFishHook) hook; - FishingHook handle = craftFishHook.getHandle(); - handle.retrieve(CraftItemStack.asNMSCopy(item)); - } - - @Override - @Nullable - public ItemStack getSpawnEgg(@NotNull LivingEntity entity) { - CraftLivingEntity craftLivingEntity = (CraftLivingEntity) entity; - net.minecraft.world.entity.LivingEntity livingEntity = craftLivingEntity.getHandle(); - - SpawnEggItem eggItem = SpawnEggItem.byId(livingEntity.getType()); - if (eggItem == null) return null; - - return CraftItemStack.asBukkitCopy(eggItem.getDefaultInstance()); - } - - @Override - @NotNull - public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { - Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle(); - BlockPos pos = new BlockPos(location.getX(), location.getY(), location.getZ()); - ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle(); - - float radius = Math.min(16F, 2F + level); - BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState(); - BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos(); - - Set blocks = new HashSet<>(); - for (BlockPos posNear : BlockPos.betweenClosed(pos.offset(-radius, -1.0, -radius), pos.offset(radius, -1.0, radius))) { - if (!posNear.closerThan(entity.blockPosition(), radius)) continue; - - posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ()); - - BlockState bLavaAbove = world.getBlockState(posAbove); - BlockState bLava = world.getBlockState(posNear); - - if (!bLavaAbove.isAir()) continue; - if (!bLava.getBlock().equals(Blocks.LAVA)) continue; - if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue; - if (!bStone.canSurvive(world, posNear)) continue; - if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue; - if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue; - //world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120)); - - Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ()); - blocks.add(bukkitLoc.getBlock()); - } - return blocks; - } -} diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml deleted file mode 100644 index 8a8913c..0000000 --- a/V1_19_R2/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - ExcellentEnchants - su.nightexpress.excellentenchants - 3.4.3 - - 4.0.0 - - V1_19_R2 - - - 16 - 16 - - - - - org.spigotmc - spigot - 1.19.3-R0.1-SNAPSHOT - remapped-mojang - - - su.nightexpress.excellentenchants - NMS - 3.4.3 - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:txt:maps-mojang - true - org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-mojang - true - remapped-obf - - - - package - - remap - - remap-spigot - - ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-obf - - - - - - - \ No newline at end of file diff --git a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java b/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java deleted file mode 100644 index 9542b37..0000000 --- a/V1_19_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R2/V1_19_R2.java +++ /dev/null @@ -1,94 +0,0 @@ -package su.nightexpress.excellentenchants.nms.v1_19_R2; - -import net.minecraft.core.BlockPos; -import net.minecraft.network.protocol.game.ClientboundAnimatePacket; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.projectile.FishingHook; -import net.minecraft.world.item.SpawnEggItem; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.LiquidBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.shapes.CollisionContext; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_19_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_19_R2.entity.CraftFishHook; -import org.bukkit.craftbukkit.v1_19_R2.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_19_R2.event.CraftEventFactory; -import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack; -import org.bukkit.entity.FishHook; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import su.nightexpress.excellentenchants.nms.EnchantNMS; - -import java.util.HashSet; -import java.util.Set; - -public class V1_19_R2 implements EnchantNMS { - - @Override - public void sendAttackPacket(@NotNull Player player, int id) { - CraftPlayer craftPlayer = (CraftPlayer) player; - Entity entity = craftPlayer.getHandle(); - ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id); - craftPlayer.getHandle().connection.send(packet); - } - - @Override - public void retrieveHook(@NotNull FishHook hook, @NotNull ItemStack item) { - CraftFishHook craftFishHook = (CraftFishHook) hook; - FishingHook handle = craftFishHook.getHandle(); - handle.retrieve(CraftItemStack.asNMSCopy(item)); - } - - @Override - @Nullable - public ItemStack getSpawnEgg(@NotNull LivingEntity entity) { - CraftLivingEntity craftLivingEntity = (CraftLivingEntity) entity; - net.minecraft.world.entity.LivingEntity livingEntity = craftLivingEntity.getHandle(); - - SpawnEggItem eggItem = SpawnEggItem.byId(livingEntity.getType()); - if (eggItem == null) return null; - - return CraftItemStack.asBukkitCopy(eggItem.getDefaultInstance()); - } - - @Override - @NotNull - public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { - Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle(); - BlockPos pos = new BlockPos(location.getX(), location.getY(), location.getZ()); - ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle(); - - float radius = Math.min(16F, 2F + level); - BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState(); - BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos(); - - Set blocks = new HashSet<>(); - for (BlockPos posNear : BlockPos.betweenClosed(pos.offset(-radius, -1.0, -radius), pos.offset(radius, -1.0, radius))) { - if (!posNear.closerThan(entity.blockPosition(), radius)) continue; - - posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ()); - - BlockState bLavaAbove = world.getBlockState(posAbove); - BlockState bLava = world.getBlockState(posNear); - - if (!bLavaAbove.isAir()) continue; - if (!bLava.getBlock().equals(Blocks.LAVA)) continue; - if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue; - if (!bStone.canSurvive(world, posNear)) continue; - if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue; - if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue; - //world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120)); - - Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ()); - blocks.add(bukkitLoc.getBlock()); - } - return blocks; - } -} diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 0d2a789..a0f13b0 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.3 + 3.4.5 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.3 + 3.4.5 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index 4a5d1ea..f879353 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.3 + 3.4.5 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.3 + 3.4.5 diff --git a/pom.xml b/pom.xml index 3d18962..d4960c9 100644 --- a/pom.xml +++ b/pom.xml @@ -7,14 +7,12 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.4.3 + 3.4.5 Core NMS V1_17_R1 V1_18_R2 - V1_19_R1 - V1_19_R2 V1_19_R3 V1_20_R1 @@ -30,7 +28,7 @@ su.nexmedia NexEngine - 2.2.10 + 2.2.11 From 7635ab4082cfab995301fa3688b4316f8b652ba2 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Thu, 13 Jul 2023 20:24:17 +0500 Subject: [PATCH 42/69] v3.5.0 New Enchants! --- Core/pom.xml | 12 +- .../excellentenchants/Placeholders.java | 1 + .../enchantment/EnchantRegistry.java | 3 + .../enchantment/config/EnchantDefaults.java | 17 ++- .../enchantment/impl/ExcellentEnchant.java | 1 + .../impl/armor/EnchantHardened.java | 4 +- .../impl/armor/StoppingForceEnchant.java | 76 ++++++++++++ .../enchantment/impl/bow/FlareEnchant.java | 115 ++++++++++++++++++ .../impl/tool/CurseOfMediocrityEnchant.java | 105 ++++++++++++++++ .../enchantment/impl/tool/EnchantTunnel.java | 28 ++--- .../impl/tool/EnchantVeinminer.java | 30 +++-- .../impl/weapon/EnchantCutter.java | 13 ++ .../menu/EnchantmentsListMenu.java | 2 + .../enchantment/util/EnchantUtils.java | 1 + NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 +- V1_18_R2/pom.xml | 4 +- V1_19_R3/pom.xml | 4 +- V1_20_R1/pom.xml | 4 +- pom.xml | 2 +- 20 files changed, 380 insertions(+), 48 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/StoppingForceEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java diff --git a/Core/pom.xml b/Core/pom.xml index 8c4fc26..59c391b 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.5 + 3.5.0 4.0.0 @@ -95,27 +95,27 @@ su.nightexpress.excellentenchants NMS - 3.4.5 + 3.5.0 su.nightexpress.excellentenchants V1_17_R1 - 3.4.5 + 3.5.0 su.nightexpress.excellentenchants V1_18_R2 - 3.4.5 + 3.5.0 su.nightexpress.excellentenchants V1_19_R3 - 3.4.5 + 3.5.0 su.nightexpress.excellentenchants V1_20_R1 - 3.4.5 + 3.5.0 diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java index 8387f9c..2c6a306 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java @@ -17,6 +17,7 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders { 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_ID = "%enchantment_id%"; 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%"; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java index 40a5ca0..81578ba 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java @@ -106,6 +106,7 @@ public class EnchantRegistry { this.register(EnchantRegrowth.ID, () -> new EnchantRegrowth(plugin)); this.register(EnchantSaturation.ID, () -> new EnchantSaturation(plugin)); this.register(EnchantSelfDestruction.ID, () -> new EnchantSelfDestruction(plugin)); + this.register(StoppingForceEnchant.ID, () -> new StoppingForceEnchant(plugin)); this.register(EnchantSonic.ID, () -> new EnchantSonic(plugin)); // Bow enchants @@ -115,6 +116,7 @@ public class EnchantRegistry { this.register(EnchantElectrifiedArrows.ID, () -> new EnchantElectrifiedArrows(plugin)); this.register(EnchantEnderBow.ID, () -> new EnchantEnderBow(plugin)); this.register(EnchantExplosiveArrows.ID, () -> new EnchantExplosiveArrows(plugin)); + this.register(FlareEnchant.ID, () -> new FlareEnchant(plugin)); this.register(EnchantGhast.ID, () -> new EnchantGhast(plugin)); this.register(EnchantHover.ID, () -> new EnchantHover(plugin)); this.register(EnchantPoisonedArrows.ID, () -> new EnchantPoisonedArrows(plugin)); @@ -122,6 +124,7 @@ public class EnchantRegistry { // Universal this.register(EnchantCurseOfFragility.ID, () -> new EnchantCurseOfFragility(plugin)); + this.register(CurseOfMediocrityEnchant.ID, () -> new CurseOfMediocrityEnchant(plugin)); Enchantment.stopAcceptingRegistrations(); this.plugin.info("Enchantments Registered: " + getRegistered().size()); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java index 4daa453..c7be3ac 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java @@ -26,8 +26,9 @@ public class EnchantDefaults { private String displayName; private Tier tier; - private List description; - private boolean isTreasure; + private List description; + private boolean hiddenFromList; + private boolean isTreasure; private int levelMin; private int levelMax; private EnchantScaler levelByEnchantCost; @@ -46,6 +47,7 @@ public class EnchantDefaults { this.setDisplayName(StringUtil.capitalizeUnderscored(enchant.getId())); this.setTier(0.1); this.setDescription(new ArrayList<>()); + this.setHiddenFromList(false); this.setTreasure(false); this.setLevelMin(1); this.setLevelMax(3); @@ -72,6 +74,9 @@ public class EnchantDefaults { "You can use 'Enchantment' placeholders: " + Placeholders.URL_PLACEHOLDERS) .read(cfg)); + this.setHiddenFromList(JOption.create("Hide_From_List", false, + "Sets whether or not this enchantment will be hidden from Enchants GUI.").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)); @@ -169,6 +174,14 @@ public class EnchantDefaults { return description; } + public boolean isHiddenFromList() { + return hiddenFromList; + } + + public void setHiddenFromList(boolean hiddenFromList) { + this.hiddenFromList = hiddenFromList; + } + public boolean isTreasure() { return isTreasure; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index 07f4f8e..91d14ba 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -65,6 +65,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme PlaceholderMap map = new PlaceholderMap() .add(Placeholders.ENCHANTMENT_DESCRIPTION, () -> String.join("\n", this.getDescription())) + .add(Placeholders.ENCHANTMENT_ID, this::getId) .add(Placeholders.ENCHANTMENT_NAME, this::getDisplayName) .add(Placeholders.ENCHANTMENT_NAME_FORMATTED, () -> this.getNameFormatted(level)) .add(Placeholders.ENCHANTMENT_LEVEL, () -> NumberUtil.toRoman(level)) 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 d15c978..c15b446 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 @@ -8,13 +8,13 @@ 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.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.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 EnchantHardened extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/StoppingForceEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/StoppingForceEnchant.java new file mode 100644 index 0000000..f51a849 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/StoppingForceEnchant.java @@ -0,0 +1,76 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.enchantments.EnchantmentTarget; +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.NumberUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +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.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 StoppingForceEnchant extends ExcellentEnchant implements Chanced, CombatEnchant { + + public static final String ID = "stopping_force"; + + public static final String PLACEHOLDER_KNOCKBACK_RESISTANCE = "%knockback_resistance%"; + + private ChanceImplementation chanceImplementation; + private EnchantScaler knockbackModifier; + + public StoppingForceEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to resist knockback in combat by " + PLACEHOLDER_KNOCKBACK_RESISTANCE + "%."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.5); + } + + @Override + public void loadSettings() { + super.loadSettings(); + this.chanceImplementation = ChanceImplementation.create(this, "100.0"); + this.knockbackModifier = EnchantScaler.read(this, "Settings.Knockback_Modifier", + "0.7 - " + Placeholders.ENCHANTMENT_LEVEL + " / 5.0", + "Sets the knockback multiplier when taking damage.", "Lower value = less knockback."); + + this.addPlaceholder(PLACEHOLDER_KNOCKBACK_RESISTANCE, level -> NumberUtil.format(this.getKnockbackModifier(level) * 100)); + } + + public double getKnockbackModifier(int level) { + return this.knockbackModifier.getValue(level); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_LEGS; + } + + @NotNull + @Override + public Chanced getChanceImplementation() { + return this.chanceImplementation; + } + + @Override + public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return false; + } + + @Override + public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isAvailableToUse(victim)) return false; + if (!this.checkTriggerChance(level)) return false; + + this.plugin.runTask(task -> { + victim.setVelocity(victim.getVelocity().multiply(this.getKnockbackModifier(level))); + }); + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java new file mode 100644 index 0000000..2ca511c --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java @@ -0,0 +1,115 @@ +package su.nightexpress.excellentenchants.enchantment.impl.bow; + +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Directional; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.block.BlockCanBuildEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +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.api.enchantment.meta.Arrowed; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +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 FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed, BowEnchant { + + public static final String ID = "flare"; + + private ChanceImplementation chanceImplementation; + private ArrowImplementation arrowImplementation; + + public FlareEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.LOWEST); + + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to create a torch where arrow lands."); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(0.4); + } + + @Override + public void loadSettings() { + super.loadSettings(); + this.chanceImplementation = ChanceImplementation.create(this, "100.0"); + this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.FIREWORKS_SPARK)); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @NotNull + @Override + public Chanced getChanceImplementation() { + return this.chanceImplementation; + } + + @NotNull + @Override + public ArrowImplementation getArrowImplementation() { + return this.arrowImplementation; + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!this.isAvailableToUse(shooter)) return false; + if (!this.checkTriggerChance(level)) return false; + + this.addData(arrow); + return true; + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + Block block = e.getHitBlock(); + if (block == null) return false; + + BlockFace face = e.getHitBlockFace(); + if (face == null || face == BlockFace.DOWN) return false; + + Block relative = block.getRelative(face); + if (!relative.getType().isAir()) return false; + + if (projectile.getShooter() instanceof Player player) { + BlockCanBuildEvent event = new BlockCanBuildEvent(relative, player, Material.TORCH.createBlockData(), true); + plugin.getPluginManager().callEvent(event); + if (!event.isBuildable()) return false; + } + + if (face == BlockFace.UP) { + relative.setType(Material.TORCH); + } + else { + relative.setType(Material.WALL_TORCH); + + Directional directional = (Directional) relative.getBlockData(); + directional.setFacing(face); + relative.setBlockData(directional, true); + } + + return true; + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return false; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java new file mode 100644 index 0000000..77b218b --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java @@ -0,0 +1,105 @@ +package su.nightexpress.excellentenchants.enchantment.impl.tool; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockDropItemEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.utils.ItemUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; +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.type.DeathEnchant; +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 CurseOfMediocrityEnchant extends ExcellentEnchant implements Chanced, BlockDropEnchant, DeathEnchant { + + public static final String ID = "curse_of_mediocrity"; + + private ChanceImplementation chanceImplementation; + + public CurseOfMediocrityEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.LOWEST); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to disenchant item drops."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0D); + } + + @Override + public void loadSettings() { + super.loadSettings(); + this.chanceImplementation = ChanceImplementation.create(this, "25.0 * " + Placeholders.ENCHANTMENT_LEVEL); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BREAKABLE; + } + + @Override + @NotNull + public FitItemType[] getFitItemTypes() { + return new FitItemType[] {FitItemType.WEAPON, FitItemType.TOOL}; + } + + @NotNull + @Override + public Chanced getChanceImplementation() { + return this.chanceImplementation; + } + + @Override + public boolean isCursed() { + return true; + } + + @Override + public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, + @NotNull Player player, @NotNull ItemStack item, int level) { + if (!this.isAvailableToUse(player)) return false; + if (!this.checkTriggerChance(level)) return false; + + e.getItems().forEach(drop -> { + ItemStack stack = drop.getItemStack(); + ItemUtil.mapMeta(stack, meta -> { + meta.getEnchants().keySet().forEach(meta::removeEnchant); + }); + drop.setItemStack(stack); + }); + + dropContainer.getDrop().forEach(stack -> { + ItemUtil.mapMeta(stack, meta -> { + meta.getEnchants().keySet().forEach(meta::removeEnchant); + }); + }); + + return true; + } + + @Override + public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + return false; + } + + @Override + public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + if (!this.isAvailableToUse(killer)) return false; + if (!this.checkTriggerChance(level)) return false; + + e.getDrops().forEach(stack -> { + ItemUtil.mapMeta(stack, meta -> { + meta.getEnchants().keySet().forEach(meta::removeEnchant); + }); + }); + + return true; + } +} 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 ba28789..c10d3c9 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 @@ -7,7 +7,6 @@ import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; 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.EntityUtil; @@ -21,11 +20,11 @@ import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; import java.util.HashSet; import java.util.Set; +import java.util.UUID; public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant { public static final String ID = "tunnel"; - private static final String META_BLOCK_TUNNEL = ID + "_block_tunneled"; // X and Z offsets for each block AoE mined private static final int[][] MINING_COORD_OFFSETS = new int[][]{{0, 0}, {0, -1}, {-1, 0}, {0, 1}, {1, 0}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1},}; private static final Set INTERACTABLE_BLOCKS = new HashSet<>(); @@ -35,10 +34,13 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant INTERACTABLE_BLOCKS.add(Material.DEEPSLATE_REDSTONE_ORE); } + private final Set activePlayers; private boolean disableOnSneak; public EnchantTunnel(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGH); + this.activePlayers = new HashSet<>(); + this.getDefaults().setDescription("Mines multiple blocks at once in a certain shape."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(1.0); @@ -64,14 +66,19 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant return EnchantmentTarget.TOOL; } + public boolean isTunneling(@NotNull Player player) { + return this.activePlayers.contains(player.getUniqueId()); + } + @Override public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - Block block = e.getBlock(); + if (this.isTunneling(player)) return false; if (!this.isAvailableToUse(player)) return false; if (this.disableOnSneak && player.isSneaking()) return false; if (EnchantUtils.contains(item, EnchantVeinminer.ID)) return false; if (EnchantUtils.contains(item, EnchantBlastMining.ID)) return false; - if (block.hasMetadata(META_BLOCK_TUNNEL)) return false; + + Block block = e.getBlock(); if (block.getType().isInteractable() && !INTERACTABLE_BLOCKS.contains(block.getType())) return false; if (block.getDrops(item).isEmpty()) return false; @@ -85,6 +92,7 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant else if (level == 2) blocksBroken = 5; else if (level == 3) blocksBroken = 9; + this.activePlayers.add(player.getUniqueId()); NoCheatPlusHook.exemptBlocks(player); for (int i = 0; i < blocksBroken; i++) { @@ -113,21 +121,11 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant if (addType == Material.BEDROCK || addType == Material.END_PORTAL || addType == Material.END_PORTAL_FRAME) continue; 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); player.breakBlock(blockAdd); - blockAdd.removeMetadata(META_BLOCK_TUNNEL, plugin); } NoCheatPlusHook.unexemptBlocks(player); + this.activePlayers.remove(player.getUniqueId()); return true; } } 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 07fd5e2..4889c7a 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 @@ -8,7 +8,6 @@ import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; 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.Scaler; @@ -24,6 +23,7 @@ import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; import java.util.HashSet; import java.util.Set; +import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -31,15 +31,21 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch public static final String ID = "veinminer"; - private static final BlockFace[] AREA = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH}; - private static final String META_BLOCK_VEINED = ID + "_block_veined"; + private static final BlockFace[] AREA = { + BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, + BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH + }; + private static final String PLACEHOLDER_BLOCK_LIMIT = "%enchantment_block_limit%"; private Scaler blocksLimit; private Set blocksAffected; + private final Set activePlayers; public EnchantVeinminer(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGH); + this.activePlayers = new HashSet<>(); + 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); @@ -104,6 +110,10 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch .filter(blockAdded -> blockAdded.getType() == block.getType()).collect(Collectors.toSet()); } + public boolean isInVein(@NotNull Player player) { + return this.activePlayers.contains(player.getUniqueId()); + } + private void vein(@NotNull Player player, @NotNull Block source, int level) { Set ores = new HashSet<>(); Set prepare = new HashSet<>(this.getNearby(source)); @@ -118,31 +128,25 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch prepare.addAll(nearby); } 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); - - ore.setMetadata(META_BLOCK_VEINED, new FixedMetadataValue(plugin, true)); - //plugin.getNMS().breakBlock(player, ore); - player.breakBlock(ore); - ore.removeMetadata(META_BLOCK_VEINED, plugin); - }); + ores.forEach(player::breakBlock); } @Override public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack tool, int level) { + if (this.isInVein(player)) return false; if (!this.isAvailableToUse(player)) return false; if (EnchantUtils.contains(tool, EnchantBlastMining.ID)) return false; if (EnchantUtils.contains(tool, EnchantTunnel.ID)) return false; Block block = e.getBlock(); - if (block.hasMetadata(META_BLOCK_VEINED)) return false; if (block.getDrops(tool).isEmpty()) return false; if (!this.getBlocksAffected().contains(block.getType())) return false; + this.activePlayers.add(player.getUniqueId()); NoCheatPlusHook.exemptBlocks(player); this.vein(player, block, level); NoCheatPlusHook.unexemptBlocks(player); + this.activePlayers.remove(player.getUniqueId()); return true; } 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 4095c45..3d570da 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 @@ -5,12 +5,14 @@ import org.bukkit.Sound; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.EntityEquipment; 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.api.config.JOption; import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.LocationUtil; import su.nexmedia.engine.utils.NumberUtil; @@ -31,6 +33,8 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn private EnchantScaler durabilityReduction; private ChanceImplementation chanceImplementation; + private boolean allowPlayers; + private boolean allowMobs; public EnchantCutter(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.LOWEST); @@ -48,6 +52,12 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn Placeholders.ENCHANTMENT_LEVEL + " / 100", "Amount (in percent) of how much item durability will be reduced."); + this.allowPlayers = JOption.create("Settings.Allow_Players", true, + "Sets whether or not this enchantment will have effect on players.").read(cfg); + + this.allowMobs = JOption.create("Settings.Allow_Mobs", true, + "Sets whether or not this enchantment will have effect on mobs.").read(cfg); + this.addPlaceholder(PLACEHOLDER_DURABILITY_DAMAGE, level -> NumberUtil.format(this.getDurabilityReduction(level) * 100D)); } @@ -77,6 +87,9 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn ItemStack[] armor = equipment.getArmorContents(); if (armor.length == 0) return false; + boolean isPlayer = victim instanceof Player; + if (isPlayer && !this.allowPlayers || (!isPlayer && !this.allowMobs)) return false; + int get = Rnd.get(armor.length); ItemStack itemCut = armor[get]; 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 5dd50f3..77aeea2 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 @@ -24,6 +24,7 @@ import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import java.util.*; +import java.util.function.Predicate; public class EnchantmentsListMenu extends ConfigMenu implements AutoPaged { @@ -82,6 +83,7 @@ public class EnchantmentsListMenu extends ConfigMenu implemen @NotNull public List getObjects(@NotNull Player player) { return new ArrayList<>(EnchantRegistry.getRegistered().stream() + .filter(Predicate.not(enchant -> enchant.getDefaults().isHiddenFromList())) .sorted(Comparator.comparing(ExcellentEnchant::getName)).toList()); } 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 index f38ce2e..9f679e5 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -199,6 +199,7 @@ public class EnchantUtils { if (sizeReal > 0) { PDCUtil.set(meta, KEY_LORE_SIZE, sizeReal); } + else PDCUtil.remove(meta, KEY_LORE_SIZE); item.setItemMeta(meta); return true; } diff --git a/NMS/pom.xml b/NMS/pom.xml index 57c1252..fdadd60 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.5 + 3.5.0 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index f949ea7..7ca0768 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.5 + 3.5.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.5 + 3.5.0 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 18554b4..b0e98e7 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.5 + 3.5.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.5 + 3.5.0 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index a0f13b0..2802c8a 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.5 + 3.5.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.5 + 3.5.0 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index f879353..bc8ef76 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.4.5 + 3.5.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.4.5 + 3.5.0 diff --git a/pom.xml b/pom.xml index d4960c9..c9f83d3 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.4.5 + 3.5.0 Core NMS From 6bd2119de606eed85a1e2f9bc922d7d0885e3780 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 18 Jul 2023 23:44:43 +0500 Subject: [PATCH 43/69] Minor fixes (v3.5.1) --- Core/pom.xml | 38 ++++++------------- .../excellentenchants/Placeholders.java | 9 ++++- .../command/BookCommand.java | 3 +- .../enchantment/impl/ExcellentEnchant.java | 1 + .../enchantment/impl/bow/FlareEnchant.java | 7 ++-- .../menu/EnchantmentsListMenu.java | 8 ++-- .../enchantment/util/EnchantUtils.java | 15 ++++++++ .../excellentenchants/tier/Tier.java | 6 +++ NMS/pom.xml | 4 +- 9 files changed, 51 insertions(+), 40 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 59c391b..994ce0c 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.0 + 3.5.1 4.0.0 @@ -21,40 +21,25 @@ md_5-releases https://repo.md-5.net/content/repositories/releases/ - - sk89q-repo - https://maven.enginehub.org/repo/ - - false - - dmulloy2-repo https://repo.dmulloy2.net/repository/public/ - - false - + 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 - + @@ -79,7 +64,8 @@ com.comphenix.protocol ProtocolLib - 5.0.0-SNAPSHOT + 5.0.0 + provided me.clip @@ -95,27 +81,27 @@ su.nightexpress.excellentenchants NMS - 3.5.0 + 3.5.1 su.nightexpress.excellentenchants V1_17_R1 - 3.5.0 + 3.5.1 su.nightexpress.excellentenchants V1_18_R2 - 3.5.0 + 3.5.1 su.nightexpress.excellentenchants V1_19_R3 - 3.5.0 + 3.5.1 su.nightexpress.excellentenchants V1_20_R1 - 3.5.0 + 3.5.1 diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java index 2c6a306..12bc277 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java @@ -36,8 +36,13 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders { public static final String ENCHANTMENT_CHARGES_RECHARGE_AMOUNT = "%enchantment_charges_recharge_amount%"; 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_ID = "%tier_id%"; + public static final String TIER_NAME = "%tier_name%"; + public static final String TIER_OBTAIN_CHANCE_ENCHANTING = "%tier_obtain_chance_enchanting%"; + public static final String TIER_OBTAIN_CHANCE_VILLAGER = "%tier_obtain_chance_villager%"; + public static final String TIER_OBTAIN_CHANCE_LOOT_GENERATION = "%tier_obtain_chance_loot_generation%"; + public static final String TIER_OBTAIN_CHANCE_FISHING = "%tier_obtain_chance_fishing%"; + public static final String TIER_OBTAIN_CHANCE_MOB_SPAWNING = "%tier_obtain_chance_mob_spawning%"; } 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 6afe3e3..ba28383 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java @@ -9,7 +9,6 @@ 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.random.Rnd; @@ -75,7 +74,7 @@ public class BookCommand extends AbstractCommand { PlayerUtil.addItem(player, item); plugin.getMessage(Lang.COMMAND_BOOK_DONE) - .replace(Placeholders.GENERIC_ENCHANT, LangManager.getEnchantment(enchantment)) + .replace(Placeholders.GENERIC_ENCHANT, EnchantUtils.getLocalized(enchantment)) .replace(Placeholders.forPlayer(player)) .send(sender); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index 91d14ba..49020fc 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -91,6 +91,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme map.add(Placeholders.ENCHANTMENT_POTION_DURATION, () -> NumberUtil.format(potioned.getEffectDuration(level) / 20D)); map.add(Placeholders.ENCHANTMENT_POTION_TYPE, () -> LangManager.getPotionType(potioned.getEffectType())); } + map.add(this.getTier().getPlaceholders()); this.placeholdersMap.put(level, map); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java index 2ca511c..0394371 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java @@ -10,10 +10,11 @@ import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; -import org.bukkit.event.block.BlockCanBuildEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.particle.SimpleParticle; @@ -89,9 +90,9 @@ public class FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed, if (!relative.getType().isAir()) return false; if (projectile.getShooter() instanceof Player player) { - BlockCanBuildEvent event = new BlockCanBuildEvent(relative, player, Material.TORCH.createBlockData(), true); + BlockPlaceEvent event = new BlockPlaceEvent(relative, relative.getState(), block, new ItemStack(Material.TORCH), player,true, EquipmentSlot.HAND); plugin.getPluginManager().callEvent(event); - if (!event.isBuildable()) return false; + if (event.isCancelled() || !event.canBuild()) return false; } if (face == BlockFace.UP) { 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 77aeea2..8e61b11 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 @@ -1,7 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.menu; import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -13,7 +12,6 @@ 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; import su.nexmedia.engine.utils.PDCUtil; @@ -22,6 +20,7 @@ import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.*; import java.util.function.Predicate; @@ -84,7 +83,7 @@ public class EnchantmentsListMenu extends ConfigMenu implemen public List getObjects(@NotNull Player player) { return new ArrayList<>(EnchantRegistry.getRegistered().stream() .filter(Predicate.not(enchant -> enchant.getDefaults().isHiddenFromList())) - .sorted(Comparator.comparing(ExcellentEnchant::getName)).toList()); + .sorted(Comparator.comparing(e -> Colorizer.strip(e.getDisplayName()))).toList()); } @Override @@ -125,8 +124,7 @@ public class EnchantmentsListMenu extends ConfigMenu implemen if (lore == null) lore = new ArrayList<>(); List conflicts = enchant.getConflicts().isEmpty() ? Collections.emptyList() : new ArrayList<>(this.enchantLoreConflicts); - List conflictNames = enchant.getConflicts().stream().map(key -> Enchantment.getByKey(NamespacedKey.minecraft(key))) - .filter(Objects::nonNull).map(LangManager::getEnchantment).toList(); + List conflictNames = enchant.getConflicts().stream().map(EnchantUtils::getLocalized).toList(); conflicts = StringUtil.replace(conflicts, Placeholders.ENCHANTMENT_NAME, true, conflictNames); List charges = enchant.isChargesEnabled() ? new ArrayList<>(this.enchantLoreCharges) : Collections.emptyList(); 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 index 9f679e5..b02ef07 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -13,6 +13,7 @@ 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.lang.LangManager; import su.nexmedia.engine.utils.CollectionsUtil; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.ItemUtil; @@ -44,6 +45,20 @@ public class EnchantUtils { return NamespacedKey.minecraft(id.toLowerCase()); } + @NotNull + public static String getLocalized(@NotNull String keyRaw) { + Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(keyRaw)); + return enchantment == null ? "null" : getLocalized(enchantment); + } + + @NotNull + public static String getLocalized(@NotNull Enchantment enchantment) { + if (enchantment instanceof ExcellentEnchant excellentEnchant) { + return excellentEnchant.getDisplayName(); + } + return LangManager.getEnchantment(enchantment); + } + public static boolean isEnchantable(@NotNull ItemStack item) { if (item.getType().isAir()) return false; 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 ca21aa4..49a9cdd 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.java @@ -5,6 +5,7 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.placeholder.Placeholder; import su.nexmedia.engine.api.placeholder.PlaceholderMap; import su.nexmedia.engine.utils.Colorizer; +import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; @@ -29,6 +30,11 @@ public class Tier implements Placeholder { this.placeholderMap = new PlaceholderMap() .add(Placeholders.TIER_ID, this::getId) .add(Placeholders.TIER_NAME, this::getName) + .add(Placeholders.TIER_OBTAIN_CHANCE_ENCHANTING, () -> NumberUtil.format(this.getChance(ObtainType.ENCHANTING))) + .add(Placeholders.TIER_OBTAIN_CHANCE_VILLAGER, () -> NumberUtil.format(this.getChance(ObtainType.VILLAGER))) + .add(Placeholders.TIER_OBTAIN_CHANCE_LOOT_GENERATION, () -> NumberUtil.format(this.getChance(ObtainType.LOOT_GENERATION))) + .add(Placeholders.TIER_OBTAIN_CHANCE_FISHING, () -> NumberUtil.format(this.getChance(ObtainType.FISHING))) + .add(Placeholders.TIER_OBTAIN_CHANCE_MOB_SPAWNING, () -> NumberUtil.format(this.getChance(ObtainType.MOB_SPAWNING))) ; } diff --git a/NMS/pom.xml b/NMS/pom.xml index fdadd60..8ae3187 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.0 + 3.5.1 4.0.0 @@ -27,7 +27,7 @@ org.spigotmc spigot-api - 1.18.1-R0.1-SNAPSHOT + 1.20.1-R0.1-SNAPSHOT From 4648f48aa556ed17975e598dc76b598c51847021 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 18 Jul 2023 23:45:31 +0500 Subject: [PATCH 44/69] Minor fixes (v3.5.1) --- V1_17_R1/pom.xml | 4 ++-- V1_18_R2/pom.xml | 4 ++-- V1_19_R3/pom.xml | 4 ++-- V1_20_R1/pom.xml | 4 ++-- pom.xml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 7ca0768..5f370f9 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.0 + 3.5.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.0 + 3.5.1 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index b0e98e7..311405c 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.0 + 3.5.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.0 + 3.5.1 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 2802c8a..5710584 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.0 + 3.5.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.0 + 3.5.1 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index bc8ef76..241f495 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.0 + 3.5.1 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.0 + 3.5.1 diff --git a/pom.xml b/pom.xml index c9f83d3..615d8b7 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.5.0 + 3.5.1 Core NMS From e57e2ab26eca418a080f2525e488e5f92980fc5d Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 29 Jul 2023 18:56:44 +0500 Subject: [PATCH 45/69] v3.5.2 --- Core/pom.xml | 12 +-- .../api/enchantment/IEnchantment.java | 4 +- .../enchantment/EnchantRegistry.java | 1 + .../enchantment/impl/ExcellentEnchant.java | 15 +++- .../armor/EnchantElementalProtection.java | 2 +- .../impl/armor/EnchantRegrowth.java | 2 +- .../impl/armor/EnchantSaturation.java | 2 +- .../enchantment/impl/bow/SniperEnchant.java | 90 +++++++++++++++++++ .../impl/fishing/RiverMasterEnchant.java | 2 +- .../listener/EnchantAnvilListener.java | 20 +++-- .../listener/EnchantGenericListener.java | 4 +- .../listener/EnchantHandlerListener.java | 30 ++++--- .../enchantment/util/EnchantUtils.java | 51 ++++++----- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 +- V1_18_R2/pom.xml | 4 +- V1_19_R3/pom.xml | 4 +- V1_20_R1/pom.xml | 4 +- pom.xml | 2 +- 19 files changed, 189 insertions(+), 66 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/SniperEnchant.java diff --git a/Core/pom.xml b/Core/pom.xml index 994ce0c..51964ad 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.1 + 3.5.2 4.0.0 @@ -81,27 +81,27 @@ su.nightexpress.excellentenchants NMS - 3.5.1 + 3.5.2 su.nightexpress.excellentenchants V1_17_R1 - 3.5.1 + 3.5.2 su.nightexpress.excellentenchants V1_18_R2 - 3.5.1 + 3.5.2 su.nightexpress.excellentenchants V1_19_R3 - 3.5.1 + 3.5.2 su.nightexpress.excellentenchants V1_20_R1 - 3.5.1 + 3.5.2 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 5cbdb86..4d1fefc 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 @@ -76,5 +76,7 @@ public interface IEnchantment { boolean isOutOfCharges(@NotNull ItemStack item); - void consumeCharges(@NotNull ItemStack item); + void consumeCharges(@NotNull ItemStack item, int level); + + void consumeChargesNoUpdate(@NotNull ItemStack item, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java index 81578ba..e2ba0ba 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java @@ -119,6 +119,7 @@ public class EnchantRegistry { this.register(FlareEnchant.ID, () -> new FlareEnchant(plugin)); this.register(EnchantGhast.ID, () -> new EnchantGhast(plugin)); this.register(EnchantHover.ID, () -> new EnchantHover(plugin)); + this.register(SniperEnchant.ID, () -> new SniperEnchant(plugin)); this.register(EnchantPoisonedArrows.ID, () -> new EnchantPoisonedArrows(plugin)); this.register(EnchantWitheredArrows.ID, () -> new EnchantWitheredArrows(plugin)); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index 49020fc..7855d54 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -164,7 +164,11 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme @NotNull public String getNameFormatted(int level) { - return this.getTier().getColor() + this.getDisplayName() + " " + NumberUtil.toRoman(level); + String name = this.getTier().getColor() + this.getDisplayName(); + if (level > 1 || this.getMaxLevel() > 1) { + name += " " + NumberUtil.toRoman(level); + } + return name; } @NotNull @@ -353,8 +357,13 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme } @Override - public void consumeCharges(@NotNull ItemStack item) { - EnchantUtils.consumeCharges(item, this); + public void consumeChargesNoUpdate(@NotNull ItemStack item, int level) { + EnchantUtils.consumeCharges(item, this, level); + } + + @Override + public void consumeCharges(@NotNull ItemStack item, int level) { + this.consumeChargesNoUpdate(item, level); EnchantUtils.updateDisplay(item); } } 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 fe02a04..3be551f 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 @@ -87,7 +87,7 @@ public class EnchantElementalProtection extends ExcellentEnchant { if (level <= 0) continue; protectionAmount += this.getProtectionAmount(level); - this.consumeCharges(armor); + this.consumeCharges(armor, level); } if (protectionAmount <= 0D) return; 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 292a3f8..dcc3332 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 @@ -141,7 +141,7 @@ public class EnchantRegrowth extends ExcellentEnchant implements Chanced, Passiv enchants.forEach((enchant, level) -> { if (enchant.isOutOfCharges(item)) return; if (enchant.onTrigger(entity, item, level)) { - enchant.consumeCharges(item); + enchant.consumeCharges(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 a34c4e4..1af04ac 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 @@ -111,7 +111,7 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan enchants.forEach((enchant, level) -> { if (enchant.isOutOfCharges(item)) return; if (enchant.onTrigger(entity, item, level)) { - enchant.consumeCharges(item); + enchant.consumeCharges(item, level); } }); }); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/SniperEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/SniperEnchant.java new file mode 100644 index 0000000..1f7f941 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/SniperEnchant.java @@ -0,0 +1,90 @@ +package su.nightexpress.excellentenchants.enchantment.impl.bow; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; +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.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +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 SniperEnchant extends ExcellentEnchant implements BowEnchant, Chanced { + + public static final String ID = "sniper"; + + private static final String PLACEHOLDER_PROJECTILE_SPEED = "%enchantment_projectile_speed%"; + + private ChanceImplementation chanceImplementation; + private EnchantScaler speedModifier; + + public SniperEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.LOWEST); + + this.getDefaults().setDescription("Increases projectile speed by " + PLACEHOLDER_PROJECTILE_SPEED + "%"); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.3); + } + + @Override + public void loadSettings() { + super.loadSettings(); + + this.chanceImplementation = ChanceImplementation.create(this, "100.0"); + this.speedModifier = EnchantScaler.read(this, "Settings.Speed_Modifier", + "1.0 + " + Placeholders.ENCHANTMENT_LEVEL + " / 5.0", "Sets projectile's speed modifier."); + + this.addPlaceholder(PLACEHOLDER_PROJECTILE_SPEED, level -> NumberUtil.format(this.getSpeedModifier(level) * 100D)); + } + + public double getSpeedModifier(int level) { + return this.speedModifier.getValue(level); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @NotNull + @Override + public Chanced getChanceImplementation() { + return this.chanceImplementation; + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; + if (!this.checkTriggerChance(level)) return false; + + double modifier = this.getSpeedModifier(level); + + Entity entity = e.getProjectile(); + Vector vector = entity.getVelocity(); + entity.setVelocity(vector.multiply(modifier)); + + return true; + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return false; + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return false; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/RiverMasterEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/RiverMasterEnchant.java index 4057e1a..b339ecc 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/RiverMasterEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/RiverMasterEnchant.java @@ -63,6 +63,6 @@ public class RiverMasterEnchant extends ExcellentEnchant { hook.setVelocity(hook.getVelocity().multiply(this.getDistanceMod(level))); - this.consumeCharges(rod); + this.consumeCharges(rod, level); } } 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 5abae87..75968f9 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 @@ -21,7 +21,6 @@ import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.HashMap; import java.util.Map; -import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -73,23 +72,26 @@ public class EnchantAnvilListener extends AbstractListener { @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) { if (second.getType().isAir()) return false; - 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; + Map chargable = new HashMap<>(); + EnchantUtils.getExcellents(first).forEach((enchant, level) -> { + if (enchant.isChargesEnabled() && enchant.isChargesFuel(second) && !enchant.isFullOfCharges(first)) { + chargable.put(enchant, level); + } + }); + if (chargable.isEmpty()) return false; ItemStack result2 = new ItemStack(first); int count = 0; - while (count < second.getAmount() && !chargeables.stream().allMatch(en -> en.isFullOfCharges(result2))) { - chargeables.forEach(enchant -> EnchantUtils.rechargeCharges(result2, enchant)); + while (count < second.getAmount() && !chargable.keySet().stream().allMatch(en -> en.isFullOfCharges(result2))) { + chargable.forEach((enchant, level) -> EnchantUtils.rechargeCharges(result2, enchant, level)); count++; } PDCUtil.set(result2, RECHARGED, count); EnchantUtils.updateDisplay(result2); e.setResult(result2); - this.plugin.runTask(task -> e.getInventory().setRepairCost(chargeables.size())); + this.plugin.runTask(task -> e.getInventory().setRepairCost(chargable.size())); return true; } @@ -116,7 +118,7 @@ public class EnchantAnvilListener extends AbstractListener { enchantments.forEach((enchant, level) -> { if (EnchantUtils.add(result2, enchant, level, false)) { repairCost.addAndGet(enchant.getAnvilMergeCost(level)); - EnchantUtils.setCharges(result2, enchant, charges.getOrDefault(enchant, 0)); + EnchantUtils.setCharges(result2, enchant, level, charges.getOrDefault(enchant, 0)); } }); 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 0b7e213..915a059 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 @@ -119,7 +119,7 @@ public class EnchantGenericListener extends AbstractListener e.getEnchantsToAdd().forEach((enchantment, level) -> { if (enchantment instanceof ExcellentEnchant enchant && enchant.isChargesEnabled()) { - EnchantUtils.restoreCharges(result, enchant); + EnchantUtils.restoreCharges(result, enchant, level); } }); EnchantUtils.updateDisplay(result); @@ -198,7 +198,7 @@ public class EnchantGenericListener extends AbstractListener ItemStack item = equipment.getItem(slot); if (EnchantUtils.isEnchantable(item)) { if (doPopulation) EnchantUtils.populate(item, ObtainType.MOB_SPAWNING); - EnchantUtils.getExcellents(item).keySet().forEach(enchant -> EnchantUtils.restoreCharges(item, enchant)); + EnchantUtils.getExcellents(item).forEach((enchant, level) -> EnchantUtils.restoreCharges(item, enchant, level)); 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 2b5b22b..56deb54 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 @@ -94,9 +94,10 @@ public class EnchantHandlerListener extends AbstractListener EnchantUtils.getExcellents(weapon, CombatEnchant.class).forEach((combatEnchant, level) -> { if (combatEnchant.isOutOfCharges(weapon)) return; if (combatEnchant.onAttack(e, damager, victim, weapon, level)) { - combatEnchant.consumeCharges(weapon); + combatEnchant.consumeChargesNoUpdate(weapon, level); } }); + EnchantUtils.updateDisplay(weapon); } private void handleCombatArmorEnchants(@NotNull EntityDamageByEntityEvent e, @@ -112,9 +113,10 @@ public class EnchantHandlerListener extends AbstractListener EnchantUtils.getExcellents(armor, CombatEnchant.class).forEach((combatEnchant, level) -> { if (combatEnchant.isOutOfCharges(armor)) return; if (combatEnchant.onProtect(e, damager, victim, weaponDamager, level)) { - combatEnchant.consumeCharges(armor); + combatEnchant.consumeChargesNoUpdate(armor, level); } }); + EnchantUtils.updateDisplay(armor); } } @@ -123,9 +125,10 @@ public class EnchantHandlerListener extends AbstractListener enchants.forEach((enchant, level) -> { if (enchant.isOutOfCharges(item)) return; if (enchant.onDamage(e, entity, item, level)) { - enchant.consumeCharges(item); + enchant.consumeChargesNoUpdate(item, level); } }); + EnchantUtils.updateDisplay(item); }); } @@ -159,9 +162,10 @@ public class EnchantHandlerListener extends AbstractListener arrowed.addData(projectile); arrowed.addTrail(projectile); } - bowEnchant.consumeCharges(bow); + bowEnchant.consumeChargesNoUpdate(bow, level); } }); + EnchantUtils.updateDisplay(bow); if (e.getProjectile() instanceof Projectile projectile) { this.setSourceWeapon(projectile, bow); @@ -201,9 +205,10 @@ public class EnchantHandlerListener extends AbstractListener EnchantUtils.getExcellents(item, InteractEnchant.class).forEach((interEnchant, level) -> { if (interEnchant.isOutOfCharges(item)) return; if (interEnchant.onInteract(e, player, item, level)) { - interEnchant.consumeCharges(item); + interEnchant.consumeChargesNoUpdate(item, level); } }); + EnchantUtils.updateDisplay(item); } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @@ -217,9 +222,10 @@ public class EnchantHandlerListener extends AbstractListener if (event.isCancelled()) return; // Check if event was cancelled by some enchantment. if (enchant.isOutOfCharges(item)) return; if (enchant.onFishing(event, item, level)) { - enchant.consumeCharges(item); + enchant.consumeChargesNoUpdate(item, level); } }); + EnchantUtils.updateDisplay(item); } // --------------------------------------------------------------- @@ -233,9 +239,10 @@ public class EnchantHandlerListener extends AbstractListener enchants.forEach(((deathEnchant, level) -> { if (deathEnchant.isOutOfCharges(item)) return; if (deathEnchant.onDeath(e, entity, level)) { - deathEnchant.consumeCharges(item); + deathEnchant.consumeChargesNoUpdate(item, level); } })); + EnchantUtils.updateDisplay(item); }); Player killer = entity.getKiller(); @@ -247,9 +254,10 @@ public class EnchantHandlerListener extends AbstractListener EnchantUtils.getExcellents(weapon, DeathEnchant.class).forEach((deathEnchant, level) -> { if (deathEnchant.isOutOfCharges(weapon)) return; if (deathEnchant.onKill(e, entity, killer, level)) { - deathEnchant.consumeCharges(weapon); + deathEnchant.consumeChargesNoUpdate(weapon, level); } }); + EnchantUtils.updateDisplay(weapon); } // Handle BlockBreak enchantments. @@ -264,9 +272,10 @@ public class EnchantHandlerListener extends AbstractListener EnchantUtils.getExcellents(tool, BlockBreakEnchant.class).forEach((blockEnchant, level) -> { if (blockEnchant.isOutOfCharges(tool)) return; if (blockEnchant.onBreak(e, player, tool, level)) { - blockEnchant.consumeCharges(tool); + blockEnchant.consumeChargesNoUpdate(tool, level); } }); + EnchantUtils.updateDisplay(tool); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -281,9 +290,10 @@ public class EnchantHandlerListener extends AbstractListener EnchantUtils.getExcellents(tool, BlockDropEnchant.class).forEach((enchant, level) -> { if (enchant.isOutOfCharges(tool)) return; if (enchant.onDrop(e, dropContainer, player, tool, level)) { - enchant.consumeCharges(tool); + enchant.consumeChargesNoUpdate(tool, level); } }); + EnchantUtils.updateDisplay(tool); BlockState state = e.getBlockState(); World world = state.getWorld(); 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 index b02ef07..54daf9d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -178,6 +178,9 @@ public class EnchantUtils { public static boolean updateDisplay(@NotNull ItemStack item) { if (Config.ENCHANTMENTS_DISPLAY_MODE.get() != 1) return false; + ItemMeta meta = item.getItemMeta(); + if (meta == null) return false; + if (!isEnchantable(item)) { PDCUtil.remove(item, KEY_LORE_SIZE); return false; @@ -185,14 +188,12 @@ public class EnchantUtils { Map enchants = getExcellents(item); - int sizeHas = PDCUtil.getInt(item, KEY_LORE_SIZE).orElse(0); + int sizeCached = PDCUtil.getInt(item, KEY_LORE_SIZE).orElse(0); int sizeReal = enchants.size(); - - ItemMeta meta = item.getItemMeta(); - if (meta == null) return false; + if (sizeCached == 0 && sizeReal == 0) return false; List lore = meta.getLore() == null ? new ArrayList<>() : meta.getLore(); - for (int index = 0; index < sizeHas && !lore.isEmpty(); index++) { + for (int index = 0; index < sizeCached && !lore.isEmpty(); index++) { lore.remove(0); } //lore.removeIf(str -> enchants.keySet().stream().anyMatch(enchant -> str.contains(enchant.getDisplayName()))); @@ -280,38 +281,45 @@ public class EnchantUtils { return getCharges(item, enchant) == max; } - public static void consumeCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { + public static void consumeCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int level) { if (!enchant.isChargesEnabled()) return; - int level = getLevel(item, enchant); + //int level = getLevel(item, enchant); int has = getCharges(item, enchant); int use = enchant.getChargesConsumeAmount(level); - setCharges(item, enchant, has - use); + setCharges(item, enchant, level,has - use); } - public static void restoreCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { - if (!enchant.isChargesEnabled()) return; - + /*public static void restoreCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { int level = getLevel(item, enchant); - int max = enchant.getChargesMax(level); - setCharges(item, enchant, max); + restoreCharges(item, enchant, level); + }*/ + + public static void restoreCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int level) { + setCharges(item, enchant, level, Integer.MAX_VALUE); } - public static void rechargeCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { - if (!enchant.isChargesEnabled()) return; + public static void rechargeCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int level) { + //if (!enchant.isChargesEnabled()) return; - int level = getLevel(item, enchant); + //int level = getLevel(item, enchant); int recharge = enchant.getChargesRechargeAmount(level); int has = getCharges(item, enchant); - setCharges(item, enchant, has + recharge); + int set = has + recharge; + setCharges(item, enchant, level, set); } - public static void setCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int charges) { + /*public static void setCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int charges) { + int level = getLevel(item, enchant); + setCharges(item, enchant, level, charges); + }*/ + + public static void setCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int level, 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))); + int set = Math.min(Math.abs(charges), max); + PDCUtil.set(item, enchant.getChargesKey(), set); } public static int getExcellentAmount(@NotNull ItemStack item) { @@ -390,10 +398,11 @@ public class EnchantUtils { if (enchant instanceof Potioned potioned) { if (enchant.isOutOfCharges(item)) return; if (enchant.onTrigger(entity, item, level)) { - enchant.consumeCharges(item); + enchant.consumeChargesNoUpdate(item, level); } } }); + EnchantUtils.updateDisplay(item); }); } } diff --git a/NMS/pom.xml b/NMS/pom.xml index 8ae3187..9aabc23 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.1 + 3.5.2 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 5f370f9..724ecba 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.1 + 3.5.2 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.1 + 3.5.2 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 311405c..e347222 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.1 + 3.5.2 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.1 + 3.5.2 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 5710584..65ca84e 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.1 + 3.5.2 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.1 + 3.5.2 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index 241f495..092c028 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.1 + 3.5.2 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.1 + 3.5.2 diff --git a/pom.xml b/pom.xml index 615d8b7..d6e8cb3 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.5.1 + 3.5.2 Core NMS From a952a70f01a96296b2c49d92a1a429ee2f335bfe Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 29 Jul 2023 20:22:24 +0500 Subject: [PATCH 46/69] v3.5.2 --- .../enchantment/type/BlockDropEnchant.java | 2 +- .../enchantment/EnchantRegistry.java | 6 ++ .../impl/armor/DarknessCloakEnchant.java | 81 +++++++++++++++ .../impl/armor/EnchantFlameWalker.java | 37 ++++++- .../impl/bow/DarknessArrowsEnchant.java | 98 +++++++++++++++++++ .../enchantment/impl/bow/EnchantBomber.java | 3 +- .../impl/bow/EnchantConfusingArrows.java | 6 +- .../impl/bow/EnchantDragonfireArrows.java | 7 +- .../impl/bow/EnchantElectrifiedArrows.java | 7 +- .../enchantment/impl/bow/EnchantEnderBow.java | 3 +- .../impl/bow/EnchantExplosiveArrows.java | 7 +- .../enchantment/impl/bow/EnchantGhast.java | 3 +- .../enchantment/impl/bow/EnchantHover.java | 6 +- .../impl/bow/EnchantPoisonedArrows.java | 7 +- .../impl/bow/EnchantWitheredArrows.java | 7 +- .../impl/tool/CurseOfMediocrityEnchant.java | 4 +- .../impl/tool/EnchantDivineTouch.java | 4 +- .../impl/tool/EnchantSilkChest.java | 16 ++- .../enchantment/impl/tool/EnchantSmelter.java | 10 +- .../impl/tool/EnchantTelekinesis.java | 6 +- .../impl/tool/EnchantTreasures.java | 6 +- Core/src/main/resources/lang/messages_ru.yml | 6 +- 22 files changed, 258 insertions(+), 74 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java 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 777145d..ea44355 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 @@ -9,6 +9,6 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface BlockDropEnchant extends IEnchantment { - boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, + boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java index e2ba0ba..4ed5b3e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java @@ -4,6 +4,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.Version; import su.nexmedia.engine.utils.Reflex; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.config.Config; @@ -123,6 +124,11 @@ public class EnchantRegistry { this.register(EnchantPoisonedArrows.ID, () -> new EnchantPoisonedArrows(plugin)); this.register(EnchantWitheredArrows.ID, () -> new EnchantWitheredArrows(plugin)); + if (Version.isAbove(Version.V1_18_R2)) { + this.register(DarknessArrowsEnchant.ID, () -> new DarknessArrowsEnchant(plugin)); + this.register(DarknessCloakEnchant.ID, () -> new DarknessCloakEnchant(plugin)); + } + // Universal this.register(EnchantCurseOfFragility.ID, () -> new EnchantCurseOfFragility(plugin)); this.register(CurseOfMediocrityEnchant.ID, () -> new CurseOfMediocrityEnchant(plugin)); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java new file mode 100644 index 0000000..be1432a --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java @@ -0,0 +1,81 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +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.nightexpress.excellentenchants.ExcellentEnchants; +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.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 DarknessCloakEnchant extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { + + public static final String ID = "darkness_cloak"; + + private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; + + public DarknessCloakEnchant(@NotNull ExcellentEnchants plugin) { + 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().setLevelMax(3); + this.getDefaults().setTier(0.2); + } + + @Override + public void loadSettings() { + super.loadSettings(); + this.chanceImplementation = ChanceImplementation.create(this, + "20.0 * " + Placeholders.ENCHANTMENT_LEVEL + " * 0.75"); + + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.DARKNESS, false, + "2.5" + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_TORSO; + } + + @Override + public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return false; + } + + @Override + public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isAvailableToUse(victim)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.addEffect(damager, level)) return false; + + if (this.hasVisualEffects()) { + SimpleParticle.of(Particle.ASH).play(damager.getEyeLocation(), 0.75, 0.1, 30); + } + + return true; + } +} 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 7fb54fd..43817a1 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 @@ -12,7 +12,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; @@ -28,6 +30,7 @@ import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; +import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -75,6 +78,10 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { BLOCKS_TO_DESTROY.put(block, Pair.of(System.currentTimeMillis() + (long) seconds * 1000L, Rnd.get(100))); } + public static boolean isBlock(@NotNull Block block) { + return BLOCKS_TO_DESTROY.containsKey(block); + } + @Override @NotNull public EnchantmentTarget getItemTarget() { @@ -111,14 +118,34 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onFlameWalkerBlock(BlockBreakEvent e) { - if (BLOCKS_TO_DESTROY.containsKey(e.getBlock())) { - e.setDropItems(false); - e.setExpToDrop(0); - e.getBlock().setType(Material.LAVA); + public void onFlameWalkerBlock(BlockBreakEvent event) { + if (isBlock(event.getBlock())) { + event.setDropItems(false); + event.setExpToDrop(0); + event.getBlock().setType(Material.LAVA); } } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlockExplode(EntityExplodeEvent event) { + this.processExplosion(event.blockList()); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlockExplode2(BlockExplodeEvent event) { + this.processExplosion(event.blockList()); + } + + private void processExplosion(@NotNull List blocks) { + blocks.removeIf(block -> { + if (isBlock(block)) { + block.setType(Material.AIR); + return true; + } + return false; + }); + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onMagmaDamage(EntityDamageEvent e) { if (e.getCause() != EntityDamageEvent.DamageCause.HOT_FLOOR) return; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java new file mode 100644 index 0000000..dfd41ff --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java @@ -0,0 +1,98 @@ +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; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +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.api.enchantment.meta.Arrowed; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +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.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; + +public class DarknessArrowsEnchant extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { + + public static final String ID = "darkness_arrows"; + + private ArrowImplementation arrowImplementation; + private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; + + public DarknessArrowsEnchant(@NotNull ExcellentEnchants plugin) { + 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, EnchantBomber.ID); + } + + @Override + public void loadSettings() { + super.loadSettings(); + this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.ASH)); + this.chanceImplementation = ChanceImplementation.create(this, + "25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5.0"); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.DARKNESS, false, + "4.0 + " + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); + } + + @NotNull + @Override + public ArrowImplementation getArrowImplementation() { + return arrowImplementation; + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; + if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!this.checkTriggerChance(level)) return false; + + arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); + return arrow.addCustomEffect(this.createEffect(level), true); + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return this.isOurProjectile(projectile); + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return this.isOurProjectile(projectile); + } +} 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 a7116ab..4f6d58f 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 @@ -37,7 +37,8 @@ public class EnchantBomber extends ExcellentEnchant implements Chanced, BowEncha EnchantEnderBow.ID, EnchantGhast.ID, EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID, - EnchantHover.ID, + DarknessArrowsEnchant.ID, + EnchantHover.ID, FlareEnchant.ID, Enchantment.ARROW_FIRE.getKey().getKey(), Enchantment.ARROW_KNOCKBACK.getKey().getKey(), Enchantment.ARROW_DAMAGE.getKey().getKey() 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 f749165..0b17a99 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 @@ -38,11 +38,7 @@ public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, 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 - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override 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 6aeb214..401b792 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 @@ -47,12 +47,7 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced 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 - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override 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 d959a48..62f7d0c 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 @@ -42,12 +42,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance 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 - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override 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 e623526..17d0cad 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 @@ -33,7 +33,8 @@ public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Cha EnchantBomber.ID, EnchantGhast.ID, EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID, - EnchantHover.ID, + DarknessArrowsEnchant.ID, + EnchantHover.ID, FlareEnchant.ID, Enchantment.ARROW_FIRE.getKey().getKey(), Enchantment.ARROW_KNOCKBACK.getKey().getKey(), Enchantment.ARROW_DAMAGE.getKey().getKey() 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 99ebe9c..58c18a3 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 @@ -47,12 +47,7 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, 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 - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override 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 233a14f..5f63afe 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 @@ -40,7 +40,8 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance EnchantEnderBow.ID, EnchantBomber.ID, EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID, - EnchantHover.ID, + DarknessArrowsEnchant.ID, + EnchantHover.ID, FlareEnchant.ID, Enchantment.ARROW_FIRE.getKey().getKey(), Enchantment.ARROW_KNOCKBACK.getKey().getKey(), Enchantment.ARROW_DAMAGE.getKey().getKey() 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 88d34d5..da52935 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 @@ -38,11 +38,7 @@ public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, 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 - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override 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 d435a1d..133da9c 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 @@ -38,12 +38,7 @@ public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, 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 - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override 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 7facc29..74f8231 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 @@ -38,12 +38,7 @@ public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, 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 - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java index 77b218b..197692e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java @@ -62,12 +62,12 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance } @Override - public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; - e.getItems().forEach(drop -> { + event.getItems().forEach(drop -> { ItemStack stack = drop.getItemStack(); ItemUtil.mapMeta(stack, meta -> { meta.getEnchants().keySet().forEach(meta::removeEnchant); 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 6b9643b..c92c32d 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 @@ -102,8 +102,8 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo } @Override - public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { - BlockState state = e.getBlockState(); + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + BlockState state = event.getBlockState(); Block block = state.getBlock(); if (!block.hasMetadata(META_HANDLE)) return false; if (!(state instanceof CreatureSpawner spawnerBlock)) return false; 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 3c5b5aa..a289d30 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 @@ -130,23 +130,29 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha } @Override - public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { - BlockState state = e.getBlockState(); + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, + @NotNull Player player, @NotNull ItemStack item, int level) { + BlockState state = event.getBlockState(); Block block = state.getBlock(); if (!this.isAvailableToUse(player)) return false; if (!(state instanceof Chest chest)) return false; // Добавляем в сундук обратно предметы из дроп листа, кроме самого сундука. - e.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType() && drop.getItemStack().getAmount() == 1); - chest.getBlockInventory().addItem(e.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0])); + event.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType() && drop.getItemStack().getAmount() == 1); + chest.getBlockInventory().addItem(event.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0])); + + if (chest.getBlockInventory().isEmpty()) { + dropContainer.getDrop().add(new ItemStack(chest.getType())); + return false; + } // Добавляем кастомный сундук в кастомный дроп лист. dropContainer.getDrop().add(this.getSilkChest(chest)); // Очищаем инвентарь сундука и дефолтный дроп лист. chest.getBlockInventory().clear(); - e.getItems().clear(); + event.getItems().clear(); return true; } 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 96419f5..d544ebe 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 @@ -89,18 +89,18 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr } @Override - public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { - if (e.getBlockState() instanceof Container) return false; + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + if (event.getBlockState() instanceof Container) return false; if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; - if (e.getItems().stream().noneMatch(drop -> this.isSmeltable(drop.getItemStack().getType()))) return false; + if (event.getItems().stream().noneMatch(drop -> this.isSmeltable(drop.getItemStack().getType()))) return false; - e.getItems().forEach(drop -> { + event.getItems().forEach(drop -> { Material material = this.smeltingTable.get(drop.getItemStack().getType()); if (material != null) drop.getItemStack().setType(material); }); - Block block = e.getBlockState().getBlock(); + Block block = event.getBlockState().getBlock(); if (this.hasVisualEffects()) { Location location = LocationUtil.getCenter(block.getLocation(), true); LocationUtil.sound(location, this.sound); 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 73c720f..8fde3f0 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 @@ -58,18 +58,18 @@ public class EnchantTelekinesis extends ExcellentEnchant implements Chanced, Blo } @Override - public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; List drops = new ArrayList<>(); - drops.addAll(e.getItems().stream().map(Item::getItemStack).toList()); + drops.addAll(event.getItems().stream().map(Item::getItemStack).toList()); drops.addAll(dropContainer.getDrop()); drops.removeIf(Objects::isNull); drops.forEach(drop -> PlayerUtil.addItem(player, drop)); dropContainer.getDrop().clear(); - e.getItems().clear(); + event.getItems().clear(); return true; } 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 387092a..e2b5d9f 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 @@ -136,8 +136,8 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block } @Override - public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { - Block block = e.getBlockState().getBlock(); + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + Block block = event.getBlockState().getBlock(); if (block.hasMetadata(META)) { block.removeMetadata(META, plugin); return false; @@ -145,7 +145,7 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; - dropContainer.getDrop().addAll(this.getTreasures(e.getBlockState().getType())); + dropContainer.getDrop().addAll(this.getTreasures(event.getBlockState().getType())); return true; } diff --git a/Core/src/main/resources/lang/messages_ru.yml b/Core/src/main/resources/lang/messages_ru.yml index 9e33cf0..e0f46f1 100644 --- a/Core/src/main/resources/lang/messages_ru.yml +++ b/Core/src/main/resources/lang/messages_ru.yml @@ -1,10 +1,6 @@ -# +---------------------------------------------------------+ -# | Официальная русская версия. | -# | Публикация на помойках rubukkit и spigotru ЗАПРЕЩЕНА. | -# +---------------------------------------------------------+ Command: List: - Desc: 'Список всех нестандартных зачарований.' + Desc: 'Меню дополнительных зачарований.' Enchant: Usage: '<зачарование> <уровень>' Desc: 'Зачарование предмета в руке.' From f753189e5b69842876cbf0583b5292c9ea4329b7 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 3 Aug 2023 07:39:29 +0500 Subject: [PATCH 47/69] v3.5.3 --- Core/pom.xml | 12 ++-- .../api/enchantment/type/DeathEnchant.java | 5 +- .../enchantment/EnchantRegistry.java | 2 + .../impl/armor/EnchantSelfDestruction.java | 5 +- .../impl/tool/CurseOfMediocrityEnchant.java | 6 +- .../impl/tool/EnchantCurseOfMisfortune.java | 8 +-- .../impl/universal/SoulboundEnchant.java | 63 +++++++++++++++++++ .../impl/weapon/EnchantDecapitator.java | 4 +- .../impl/weapon/EnchantExpHunter.java | 9 +-- .../impl/weapon/EnchantNimble.java | 9 +-- .../impl/weapon/EnchantScavenger.java | 6 +- .../impl/weapon/EnchantThrifty.java | 6 +- .../listener/EnchantHandlerListener.java | 8 +-- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 +- V1_18_R2/pom.xml | 4 +- V1_19_R3/pom.xml | 4 +- V1_20_R1/pom.xml | 4 +- pom.xml | 2 +- 19 files changed, 116 insertions(+), 47 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java diff --git a/Core/pom.xml b/Core/pom.xml index 51964ad..54ccd51 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.2 + 3.5.3 4.0.0 @@ -81,27 +81,27 @@ su.nightexpress.excellentenchants NMS - 3.5.2 + 3.5.3 su.nightexpress.excellentenchants V1_17_R1 - 3.5.2 + 3.5.3 su.nightexpress.excellentenchants V1_18_R2 - 3.5.2 + 3.5.3 su.nightexpress.excellentenchants V1_19_R3 - 3.5.2 + 3.5.3 su.nightexpress.excellentenchants V1_20_R1 - 3.5.2 + 3.5.3 diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java index 0d5af0f..78e3387 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java @@ -3,12 +3,13 @@ package su.nightexpress.excellentenchants.api.enchantment.type; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface DeathEnchant extends IEnchantment { - boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level); + boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level); - boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level); + boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java index 4ed5b3e..52fdc55 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java @@ -14,6 +14,7 @@ import su.nightexpress.excellentenchants.enchantment.impl.bow.*; import su.nightexpress.excellentenchants.enchantment.impl.fishing.*; import su.nightexpress.excellentenchants.enchantment.impl.tool.*; import su.nightexpress.excellentenchants.enchantment.impl.universal.EnchantCurseOfFragility; +import su.nightexpress.excellentenchants.enchantment.impl.universal.SoulboundEnchant; import su.nightexpress.excellentenchants.enchantment.impl.weapon.*; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.tier.Tier; @@ -132,6 +133,7 @@ public class EnchantRegistry { // Universal this.register(EnchantCurseOfFragility.ID, () -> new EnchantCurseOfFragility(plugin)); this.register(CurseOfMediocrityEnchant.ID, () -> new CurseOfMediocrityEnchant(plugin)); + this.register(SoulboundEnchant.ID, () -> new SoulboundEnchant(plugin)); Enchantment.stopAcceptingRegistrations(); this.plugin.info("Enchantments Registered: " + getRegistered().size()); 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 eb6a380..688741a 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 @@ -8,6 +8,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.NumberUtil; @@ -66,7 +67,7 @@ public class EnchantSelfDestruction extends ExcellentEnchant implements Chanced, } @Override - public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) { if (!this.isAvailableToUse(entity)) return false; if (!this.checkTriggerChance(level)) return false; @@ -78,7 +79,7 @@ public class EnchantSelfDestruction extends ExcellentEnchant implements Chanced, } @Override - public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { return false; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java index 197692e..e4887ff 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java @@ -85,16 +85,16 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance } @Override - public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) { return false; } @Override - public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { if (!this.isAvailableToUse(killer)) return false; if (!this.checkTriggerChance(level)) return false; - e.getDrops().forEach(stack -> { + event.getDrops().forEach(stack -> { ItemUtil.mapMeta(stack, meta -> { meta.getEnchants().keySet().forEach(meta::removeEnchant); }); 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 6fd9b8a..ca40ad4 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 @@ -84,17 +84,17 @@ public class EnchantCurseOfMisfortune extends ExcellentEnchant implements Chance } @Override - public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { if (!this.isAvailableToUse(killer)) return false; if (!this.checkTriggerChance(level)) return false; - e.getDrops().clear(); - if (!this.isDropExp()) e.setDroppedExp(0); + event.getDrops().clear(); + if (!this.isDropExp()) event.setDroppedExp(0); return true; } @Override - public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) { return false; } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java new file mode 100644 index 0000000..680be4c --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java @@ -0,0 +1,63 @@ +package su.nightexpress.excellentenchants.enchantment.impl.universal; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; + +import java.util.ArrayList; +import java.util.List; + +public class SoulboundEnchant extends ExcellentEnchant { + + public static final String ID = "soulbound"; + + public SoulboundEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.LOWEST); + this.getDefaults().setDescription("Protects from being dropped on death."); + this.getDefaults().setLevelMax(1); + this.getDefaults().setTier(0.8); + this.getDefaults().setConflicts(Enchantment.VANISHING_CURSE.getKey().getKey()); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BREAKABLE; + } + + @EventHandler + public void onDeath(@NotNull PlayerDeathEvent deathEvent) { + Player player = deathEvent.getEntity(); + if (!this.isAvailableToUse(player)) return; + if (deathEvent.getKeepInventory()) return; + + List saveList = new ArrayList<>(); + + deathEvent.getDrops().removeIf(drop -> { + if (EnchantUtils.getLevel(drop, this) > 0) { + if (this.isOutOfCharges(drop)) return false; + + saveList.add(drop); + return true; + } + return false; + }); + + if (saveList.isEmpty()) return; + + this.plugin.runTask(task -> { + saveList.forEach(save -> { + this.consumeCharges(save, EnchantUtils.getLevel(save, this)); + player.getInventory().addItem(save); + }); + }); + } +} 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 621ca7b..387b2ab 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 @@ -180,12 +180,12 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea } @Override - public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) { return false; } @Override - public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { if (!this.isAvailableToUse(entity)) return false; EntityType entityType = entity.getType(); 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 5a7ddce..64faa91 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 @@ -4,6 +4,7 @@ import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; 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.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -48,18 +49,18 @@ public class EnchantExpHunter extends ExcellentEnchant implements DeathEnchant { } @Override - public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { if (!this.isAvailableToUse(entity)) return false; double expModifier = this.getExpModifier(level); - double expFinal = Math.ceil((double) e.getDroppedExp() * expModifier); + double expFinal = Math.ceil((double) event.getDroppedExp() * expModifier); - e.setDroppedExp((int) expFinal); + event.setDroppedExp((int) expFinal); return true; } @Override - public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) { return false; } } 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 f874c47..0e1d620 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 @@ -4,6 +4,7 @@ import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; 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.PlayerUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -45,17 +46,17 @@ public class EnchantNimble extends ExcellentEnchant implements Chanced, DeathEnc } @Override - public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { if (!this.isAvailableToUse(entity)) return false; if (!this.checkTriggerChance(level)) return false; - e.getDrops().forEach(item -> PlayerUtil.addItem(killer, item)); - e.getDrops().clear(); + event.getDrops().forEach(item -> PlayerUtil.addItem(killer, item)); + event.getDrops().clear(); return true; } @Override - public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, 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 e3be45a..55be0dd 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 @@ -99,7 +99,7 @@ public class EnchantScavenger extends ExcellentEnchant implements Chanced, Death } @Override - public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { if (!this.isAvailableToUse(entity)) return false; Map> items = this.loot.get(entity.getType()); @@ -115,14 +115,14 @@ public class EnchantScavenger extends ExcellentEnchant implements Chanced, Death if (amount <= 0) return; ItemStack item = new ItemStack(material); - e.getDrops().add(item); + event.getDrops().add(item); }); return true; } @Override - public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) { return false; } } 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 019ad66..e7f2b83 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 @@ -81,7 +81,7 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn } @Override - public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { if (!this.isAvailableToUse(entity)) return false; if (this.ignoredEntityTypes.contains(entity.getType())) return false; @@ -91,12 +91,12 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn ItemStack eggItem = plugin.getEnchantNMS().getSpawnEgg(entity); if (eggItem == null) return false; - e.getDrops().add(eggItem); + event.getDrops().add(eggItem); return true; } @Override - public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) { + public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) { return false; } 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 56deb54..f3cb69f 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 @@ -232,13 +232,13 @@ public class EnchantHandlerListener extends AbstractListener // Death Related Enchants // --------------------------------------------------------------- @EventHandler(priority = EventPriority.HIGHEST) - public void onEnchantDeath(EntityDeathEvent e) { - LivingEntity entity = e.getEntity(); + public void onEnchantDeath(EntityDeathEvent event) { + LivingEntity entity = event.getEntity(); EnchantUtils.getEquipped(entity, DeathEnchant.class).forEach((item, enchants) -> { enchants.forEach(((deathEnchant, level) -> { if (deathEnchant.isOutOfCharges(item)) return; - if (deathEnchant.onDeath(e, entity, level)) { + if (deathEnchant.onDeath(event, entity, item, level)) { deathEnchant.consumeChargesNoUpdate(item, level); } })); @@ -253,7 +253,7 @@ public class EnchantHandlerListener extends AbstractListener EnchantUtils.getExcellents(weapon, DeathEnchant.class).forEach((deathEnchant, level) -> { if (deathEnchant.isOutOfCharges(weapon)) return; - if (deathEnchant.onKill(e, entity, killer, level)) { + if (deathEnchant.onKill(event, entity, killer, level)) { deathEnchant.consumeChargesNoUpdate(weapon, level); } }); diff --git a/NMS/pom.xml b/NMS/pom.xml index 9aabc23..83502de 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.2 + 3.5.3 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 724ecba..966cfed 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.2 + 3.5.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.2 + 3.5.3 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index e347222..d5af126 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.2 + 3.5.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.2 + 3.5.3 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 65ca84e..42beb6d 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.2 + 3.5.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.2 + 3.5.3 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index 092c028..c4f881d 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.2 + 3.5.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.2 + 3.5.3 diff --git a/pom.xml b/pom.xml index d6e8cb3..6032ef6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.5.2 + 3.5.3 Core NMS From 4a05fc50bd579403102087caa8a2bdaa79e0a2e4 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 5 Aug 2023 13:25:42 +0500 Subject: [PATCH 48/69] Compatibility fixes --- .../impl/bow/EnchantDragonfireArrows.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) 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 401b792..1e67940 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 @@ -1,22 +1,26 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.World; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.AreaEffectCloud; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; +import org.bukkit.entity.ThrownPotion; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.LingeringPotionSplashEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionEffect; 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.ItemUtil; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; @@ -104,6 +108,7 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { if (!this.isOurProjectile(projectile)) return false; if (e.getHitEntity() != null) return false; + if (projectile.getShooter() == null) return false; this.createCloud(projectile.getShooter(), projectile.getLocation() , level); return true; @@ -117,10 +122,23 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced return true; } - private void createCloud(@Nullable ProjectileSource shooter, @NotNull Location location, int level) { + private void createCloud(@NotNull ProjectileSource shooter, @NotNull Location location, int level) { World world = location.getWorld(); if (world == null) return; + // There are some tweaks to respect protection plugins using even call. + + ItemStack item = new ItemStack(Material.LINGERING_POTION); + ItemUtil.mapMeta(item, meta -> { + if (meta instanceof PotionMeta potionMeta) { + potionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 20, 0), true); + } + }); + + ThrownPotion potion = shooter.launchProjectile(ThrownPotion.class); + potion.setItem(item); + potion.teleport(location); + AreaEffectCloud cloud = world.spawn(location, AreaEffectCloud.class); cloud.clearCustomEffects(); cloud.setSource(shooter); @@ -129,5 +147,12 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced cloud.setDuration(this.getFireDuration(level)); cloud.setRadiusPerTick((7.0F - cloud.getRadius()) / (float) cloud.getDuration()); cloud.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 1, 1), true); + + LingeringPotionSplashEvent splashEvent = new LingeringPotionSplashEvent(potion, cloud); + plugin.getPluginManager().callEvent(splashEvent); + if (splashEvent.isCancelled()) { + cloud.remove(); + } + potion.remove(); } } From a8750a17e4f1b3d3742ef41be6ef6a1d25896b41 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 11 Aug 2023 00:14:03 +0500 Subject: [PATCH 49/69] Added missing charges check --- Core/pom.xml | 12 ++++++------ .../enchantment/impl/ExcellentEnchant.java | 4 ++++ .../enchantment/util/EnchantUtils.java | 3 --- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 ++-- V1_18_R2/pom.xml | 4 ++-- V1_19_R3/pom.xml | 4 ++-- V1_20_R1/pom.xml | 4 ++-- pom.xml | 2 +- 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 54ccd51..685c3d6 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.3 + 3.5.4 4.0.0 @@ -81,27 +81,27 @@ su.nightexpress.excellentenchants NMS - 3.5.3 + 3.5.4 su.nightexpress.excellentenchants V1_17_R1 - 3.5.3 + 3.5.4 su.nightexpress.excellentenchants V1_18_R2 - 3.5.3 + 3.5.4 su.nightexpress.excellentenchants V1_19_R3 - 3.5.3 + 3.5.4 su.nightexpress.excellentenchants V1_20_R1 - 3.5.3 + 3.5.4 diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index 7855d54..4fbe20b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -358,11 +358,15 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme @Override public void consumeChargesNoUpdate(@NotNull ItemStack item, int level) { + if (!this.isChargesEnabled()) return; + EnchantUtils.consumeCharges(item, this, level); } @Override public void consumeCharges(@NotNull ItemStack item, int level) { + if (!this.isChargesEnabled()) return; + this.consumeChargesNoUpdate(item, level); EnchantUtils.updateDisplay(item); } 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 index 54daf9d..746a549 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -282,9 +282,6 @@ public class EnchantUtils { } public static void consumeCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int level) { - if (!enchant.isChargesEnabled()) return; - - //int level = getLevel(item, enchant); int has = getCharges(item, enchant); int use = enchant.getChargesConsumeAmount(level); setCharges(item, enchant, level,has - use); diff --git a/NMS/pom.xml b/NMS/pom.xml index 83502de..7ee132a 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.3 + 3.5.4 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 966cfed..644d8f2 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.3 + 3.5.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.3 + 3.5.4 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index d5af126..79c49b1 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.3 + 3.5.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.3 + 3.5.4 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 42beb6d..26110ed 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.3 + 3.5.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.3 + 3.5.4 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index c4f881d..0921015 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.3 + 3.5.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.3 + 3.5.4 diff --git a/pom.xml b/pom.xml index 6032ef6..e15dd08 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.5.3 + 3.5.4 Core NMS From e48e76e503f317bdf30fbc4fcc8768e973af9838 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 21 Aug 2023 12:47:42 +0500 Subject: [PATCH 50/69] v3.5.5 --- Core/pom.xml | 12 +++++----- .../excellentenchants/config/Config.java | 4 ++++ .../enchantment/impl/ExcellentEnchant.java | 3 +++ .../listener/EnchantHandlerListener.java | 23 +++++++++++-------- .../menu/EnchantmentsListMenu.java | 2 +- .../enchantment/util/EnchantUtils.java | 12 +++++++--- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 ++-- V1_18_R2/pom.xml | 4 ++-- V1_19_R3/pom.xml | 4 ++-- V1_20_R1/pom.xml | 4 ++-- pom.xml | 2 +- 12 files changed, 46 insertions(+), 30 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 685c3d6..27dffd8 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.4 + 3.5.5 4.0.0 @@ -81,27 +81,27 @@ su.nightexpress.excellentenchants NMS - 3.5.4 + 3.5.5 su.nightexpress.excellentenchants V1_17_R1 - 3.5.4 + 3.5.5 su.nightexpress.excellentenchants V1_18_R2 - 3.5.4 + 3.5.5 su.nightexpress.excellentenchants V1_19_R3 - 3.5.4 + 3.5.5 su.nightexpress.excellentenchants V1_20_R1 - 3.5.4 + 3.5.5 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 0003f82..7e0aa92 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -60,6 +60,10 @@ public class Config { "Use '" + Placeholders.GENERIC_AMOUNT + "' placeholder for amount of charges.") .setWriter((cfg, path, map) -> map.forEach((perc, str) -> cfg.set(path + "." + perc, str))); + public static final JOption ENCHANTMENTS_CHARGES_COMPARE_TYPE_ONLY = JOption.create("Enchantments.Charges.Compare_Material_Only", false, + "When enabled, only item material will be checked to determine if item can be used as an enchantment fuel.", + "When disabled (default), it will compare the whole item meta including name, lore, model data etc."); + public static final JOption ENCHANTMENTS_CHARGES_FUEL_ITEM = JOption.create("Enchantments.Charges.Fuel_Item", new ItemStack(Material.LAPIS_LAZULI), "Default item used to recharge item's enchantments on anvils.", diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index 4fbe20b..28ebee4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -333,6 +333,9 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme } public boolean isChargesFuel(@NotNull ItemStack item) { + if (Config.ENCHANTMENTS_CHARGES_COMPARE_TYPE_ONLY.get()) { + return item.getType() == this.getChargesFuel().getType(); + } return item.isSimilar(this.getChargesFuel()); } 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 f3cb69f..fe145a8 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 @@ -27,6 +27,7 @@ import su.nexmedia.engine.utils.EntityUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; import su.nightexpress.excellentenchants.api.enchantment.type.*; +import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.EnchantManager; import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; @@ -97,7 +98,7 @@ public class EnchantHandlerListener extends AbstractListener combatEnchant.consumeChargesNoUpdate(weapon, level); } }); - EnchantUtils.updateDisplay(weapon); + EnchantUtils.updateChargesDisplay(weapon); } private void handleCombatArmorEnchants(@NotNull EntityDamageByEntityEvent e, @@ -116,7 +117,7 @@ public class EnchantHandlerListener extends AbstractListener combatEnchant.consumeChargesNoUpdate(armor, level); } }); - EnchantUtils.updateDisplay(armor); + EnchantUtils.updateChargesDisplay(armor); } } @@ -128,7 +129,7 @@ public class EnchantHandlerListener extends AbstractListener enchant.consumeChargesNoUpdate(item, level); } }); - EnchantUtils.updateDisplay(item); + EnchantUtils.updateChargesDisplay(item); }); } @@ -165,7 +166,7 @@ public class EnchantHandlerListener extends AbstractListener bowEnchant.consumeChargesNoUpdate(bow, level); } }); - EnchantUtils.updateDisplay(bow); + EnchantUtils.updateChargesDisplay(bow); if (e.getProjectile() instanceof Projectile projectile) { this.setSourceWeapon(projectile, bow); @@ -208,7 +209,7 @@ public class EnchantHandlerListener extends AbstractListener interEnchant.consumeChargesNoUpdate(item, level); } }); - EnchantUtils.updateDisplay(item); + EnchantUtils.updateChargesDisplay(item); } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @@ -225,7 +226,7 @@ public class EnchantHandlerListener extends AbstractListener enchant.consumeChargesNoUpdate(item, level); } }); - EnchantUtils.updateDisplay(item); + EnchantUtils.updateChargesDisplay(item); } // --------------------------------------------------------------- @@ -242,7 +243,9 @@ public class EnchantHandlerListener extends AbstractListener deathEnchant.consumeChargesNoUpdate(item, level); } })); - EnchantUtils.updateDisplay(item); + if (Config.ENCHANTMENTS_CHARGES_ENABLED.get()) { + EnchantUtils.updateChargesDisplay(item); + } }); Player killer = entity.getKiller(); @@ -257,7 +260,7 @@ public class EnchantHandlerListener extends AbstractListener deathEnchant.consumeChargesNoUpdate(weapon, level); } }); - EnchantUtils.updateDisplay(weapon); + EnchantUtils.updateChargesDisplay(weapon); } // Handle BlockBreak enchantments. @@ -275,7 +278,7 @@ public class EnchantHandlerListener extends AbstractListener blockEnchant.consumeChargesNoUpdate(tool, level); } }); - EnchantUtils.updateDisplay(tool); + EnchantUtils.updateChargesDisplay(tool); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -293,7 +296,7 @@ public class EnchantHandlerListener extends AbstractListener enchant.consumeChargesNoUpdate(tool, level); } }); - EnchantUtils.updateDisplay(tool); + EnchantUtils.updateChargesDisplay(tool); BlockState state = e.getBlockState(); World world = state.getWorld(); 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 8e61b11..a7e1980 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 @@ -124,7 +124,7 @@ public class EnchantmentsListMenu extends ConfigMenu implemen if (lore == null) lore = new ArrayList<>(); List conflicts = enchant.getConflicts().isEmpty() ? Collections.emptyList() : new ArrayList<>(this.enchantLoreConflicts); - List conflictNames = enchant.getConflicts().stream().map(EnchantUtils::getLocalized).toList(); + List conflictNames = enchant.getConflicts().stream().map(EnchantUtils::getLocalized).filter(Objects::nonNull).toList(); conflicts = StringUtil.replace(conflicts, Placeholders.ENCHANTMENT_NAME, true, conflictNames); List charges = enchant.isChargesEnabled() ? new ArrayList<>(this.enchantLoreCharges) : Collections.emptyList(); 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 index 746a549..9aa5a55 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -45,10 +45,10 @@ public class EnchantUtils { return NamespacedKey.minecraft(id.toLowerCase()); } - @NotNull + @Nullable public static String getLocalized(@NotNull String keyRaw) { Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(keyRaw)); - return enchantment == null ? "null" : getLocalized(enchantment); + return enchantment == null ? null : getLocalized(enchantment); } @NotNull @@ -175,6 +175,12 @@ public class EnchantUtils { item.setItemMeta(meta); } + public static void updateChargesDisplay(@NotNull ItemStack item) { + if (Config.ENCHANTMENTS_CHARGES_ENABLED.get()) { + updateDisplay(item); + } + } + public static boolean updateDisplay(@NotNull ItemStack item) { if (Config.ENCHANTMENTS_DISPLAY_MODE.get() != 1) return false; @@ -399,7 +405,7 @@ public class EnchantUtils { } } }); - EnchantUtils.updateDisplay(item); + EnchantUtils.updateChargesDisplay(item); }); } } diff --git a/NMS/pom.xml b/NMS/pom.xml index 7ee132a..2c0c747 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.4 + 3.5.5 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 644d8f2..3b104fa 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.4 + 3.5.5 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.4 + 3.5.5 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 79c49b1..9c59476 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.4 + 3.5.5 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.4 + 3.5.5 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 26110ed..29c4c8f 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.4 + 3.5.5 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.4 + 3.5.5 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index 0921015..b2b86c8 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.4 + 3.5.5 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.4 + 3.5.5 diff --git a/pom.xml b/pom.xml index e15dd08..7af8f5f 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.5.4 + 3.5.5 Core NMS From 2cec377dfd18aa70cca5701b0491a1061de6d8a5 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 26 Aug 2023 16:57:45 +0500 Subject: [PATCH 51/69] Packet fixes --- .../excellentenchants/ExcellentEnchants.java | 19 ++++++++++--------- .../impl/universal/SoulboundEnchant.java | 13 +++++++++++-- .../hook/impl/ProtocolHook.java | 2 +- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index f07a0e6..9e7b424 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -55,6 +55,16 @@ public class ExcellentEnchants extends NexPlugin { this.enchantManager = new EnchantManager(this); this.enchantManager.setup(); + + if (Config.ENCHANTMENTS_DISPLAY_MODE.get() == 2) { + if (EngineUtils.hasPlugin(HookId.PROTOCOL_LIB)) { + ProtocolHook.setup(); + } + else { + this.warn(HookId.PROTOCOL_LIB + " is not installed. Set display mode to Plain lore."); + Config.ENCHANTMENTS_DISPLAY_MODE.set(1); + } + } } @Override @@ -104,15 +114,6 @@ public class ExcellentEnchants extends NexPlugin { @Override public void registerHooks() { - if (Config.ENCHANTMENTS_DISPLAY_MODE.get() == 2) { - if (EngineUtils.hasPlugin(HookId.PROTOCOL_LIB)) { - ProtocolHook.setup(); - } - else { - this.warn(HookId.PROTOCOL_LIB + " is not installed. Set display mode to Plain lore."); - Config.ENCHANTMENTS_DISPLAY_MODE.set(1); - } - } if (EngineUtils.hasPlaceholderAPI()) { PlaceholderHook.setup(); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java index 680be4c..99c968a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java @@ -1,5 +1,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.universal; +import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; @@ -40,6 +42,8 @@ public class SoulboundEnchant extends ExcellentEnchant { if (deathEvent.getKeepInventory()) return; List saveList = new ArrayList<>(); + Location location = player.getLocation(); + World world = player.getWorld(); deathEvent.getDrops().removeIf(drop -> { if (EnchantUtils.getLevel(drop, this) > 0) { @@ -55,8 +59,13 @@ public class SoulboundEnchant extends ExcellentEnchant { this.plugin.runTask(task -> { saveList.forEach(save -> { - this.consumeCharges(save, EnchantUtils.getLevel(save, this)); - player.getInventory().addItem(save); + if (player.getInventory().firstEmpty() == -1) { + world.dropItemNaturally(location, save); + } + else { + this.consumeCharges(save, EnchantUtils.getLevel(save, this)); + player.getInventory().addItem(save); + } }); }); } 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 351fc82..de94899 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 @@ -78,7 +78,7 @@ public class ProtocolHook { } @Nullable - private static ItemStack update(@Nullable ItemStack item, boolean isCreative) { + public static ItemStack update(@Nullable ItemStack item, boolean isCreative) { if (item == null || item.getType().isAir()) return item; ItemStack copy = new ItemStack(item); From 7b8d7aad51d158e059ac79ed42109cbe86c6a530 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 4 Sep 2023 16:41:08 +0500 Subject: [PATCH 52/69] v3.5.6 --- .../enchantment/type/BlockBreakEnchant.java | 2 +- .../enchantment/type/BlockDropEnchant.java | 4 +- .../api/enchantment/type/BowEnchant.java | 6 +- .../api/enchantment/type/CombatEnchant.java | 4 +- .../api/enchantment/type/DamageEnchant.java | 2 +- .../api/enchantment/type/InteractEnchant.java | 2 +- .../enchantment/EnchantRegistry.java | 1 - .../impl/armor/DarknessCloakEnchant.java | 4 +- .../impl/armor/EnchantColdSteel.java | 4 +- .../impl/armor/EnchantFireShield.java | 4 +- .../impl/armor/EnchantFlameWalker.java | 11 ++- .../impl/armor/EnchantHardened.java | 4 +- .../impl/armor/EnchantIceShield.java | 4 +- .../impl/armor/StoppingForceEnchant.java | 4 +- .../impl/bow/DarknessArrowsEnchant.java | 8 +- .../enchantment/impl/bow/EnchantBomber.java | 12 +-- .../impl/bow/EnchantConfusingArrows.java | 8 +- .../impl/bow/EnchantDragonfireArrows.java | 8 +- .../impl/bow/EnchantElectrifiedArrows.java | 10 +-- .../enchantment/impl/bow/EnchantEnderBow.java | 10 +-- .../impl/bow/EnchantExplosiveArrows.java | 6 +- .../enchantment/impl/bow/EnchantGhast.java | 10 +-- .../enchantment/impl/bow/EnchantHover.java | 8 +- .../impl/bow/EnchantPoisonedArrows.java | 8 +- .../impl/bow/EnchantWitheredArrows.java | 8 +- .../enchantment/impl/bow/FlareEnchant.java | 6 +- .../enchantment/impl/bow/SniperEnchant.java | 8 +- .../impl/tool/CurseOfMediocrityEnchant.java | 9 +- .../impl/tool/EnchantBlastMining.java | 61 +++++-------- .../impl/tool/EnchantCurseOfMisfortune.java | 6 +- .../impl/tool/EnchantDivineTouch.java | 16 ++-- .../impl/tool/EnchantLuckyMiner.java | 4 +- .../impl/tool/EnchantReplanter.java | 12 +-- .../impl/tool/EnchantSilkChest.java | 8 +- .../enchantment/impl/tool/EnchantSmelter.java | 6 +- .../impl/tool/EnchantTelekinesis.java | 16 ++-- .../impl/tool/EnchantTreasures.java | 16 ++-- .../enchantment/impl/tool/EnchantTunnel.java | 21 ++--- .../impl/tool/EnchantVeinminer.java | 24 ++--- .../impl/weapon/EnchantBaneOfNetherspawn.java | 8 +- .../impl/weapon/EnchantBlindness.java | 4 +- .../impl/weapon/EnchantConfusion.java | 4 +- .../enchantment/impl/weapon/EnchantCure.java | 6 +- .../impl/weapon/EnchantCutter.java | 4 +- .../impl/weapon/EnchantDoubleStrike.java | 6 +- .../impl/weapon/EnchantExhaust.java | 4 +- .../impl/weapon/EnchantIceAspect.java | 4 +- .../impl/weapon/EnchantParalyze.java | 4 +- .../enchantment/impl/weapon/EnchantRage.java | 4 +- .../impl/weapon/EnchantRocket.java | 4 +- .../impl/weapon/EnchantSurprise.java | 4 +- .../impl/weapon/EnchantTemper.java | 6 +- .../impl/weapon/EnchantThunder.java | 4 +- .../impl/weapon/EnchantVampire.java | 6 +- .../enchantment/impl/weapon/EnchantVenom.java | 4 +- .../impl/weapon/EnchantVillageDefender.java | 8 +- .../impl/weapon/EnchantWither.java | 4 +- .../listener/EnchantGenericListener.java | 54 +++++++----- .../listener/EnchantHandlerListener.java | 20 ++--- .../util/EnchantDropContainer.java | 1 + .../enchantment/util/EnchantUtils.java | 88 +++++++++++++++---- .../excellentenchants/nms/EnchantNMS.java | 3 + .../nms/v1_17_R1/V1_17_R1.java | 22 +++++ .../nms/v1_18_R2/V1_18_R2.java | 22 +++++ .../nms/v1_19_R3/V1_19_R3.java | 22 +++++ .../nms/v1_20_R1/V1_20_R1.java | 52 +++++++++++ 66 files changed, 437 insertions(+), 300 deletions(-) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java index f1300eb..6cce6ad 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java @@ -8,5 +8,5 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface BlockBreakEnchant extends IEnchantment { - boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level); + boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level); } 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 ea44355..fbccb78 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,11 +4,9 @@ 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.enchantment.util.EnchantDropContainer; import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface BlockDropEnchant extends IEnchantment { - boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, - @NotNull Player player, @NotNull ItemStack item, int level); + boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java index 6845c15..8b4df42 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java @@ -11,11 +11,11 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface BowEnchant extends IEnchantment { - boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level); + boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level); - boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level); + boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level); - boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, + boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java index 6386f6f..32d0fe8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java @@ -8,11 +8,11 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface CombatEnchant extends IEnchantment { - boolean onAttack(@NotNull EntityDamageByEntityEvent e, + boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level); - boolean onProtect(@NotNull EntityDamageByEntityEvent e, + boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DamageEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DamageEnchant.java index 1e295c6..12448ad 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DamageEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DamageEnchant.java @@ -8,5 +8,5 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface DamageEnchant extends IEnchantment { - boolean onDamage(@NotNull EntityDamageEvent e, @NotNull LivingEntity entity, @NotNull ItemStack item, int level); + boolean onDamage(@NotNull EntityDamageEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java index 1d9b54e..2193876 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java @@ -8,5 +8,5 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface InteractEnchant extends IEnchantment { - boolean onInteract(@NotNull PlayerInteractEvent e, @NotNull Player player, @NotNull ItemStack item, int level); + boolean onInteract(@NotNull PlayerInteractEvent event, @NotNull Player player, @NotNull ItemStack item, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java index 52fdc55..eee5431 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java @@ -124,7 +124,6 @@ public class EnchantRegistry { this.register(SniperEnchant.ID, () -> new SniperEnchant(plugin)); this.register(EnchantPoisonedArrows.ID, () -> new EnchantPoisonedArrows(plugin)); this.register(EnchantWitheredArrows.ID, () -> new EnchantWitheredArrows(plugin)); - if (Version.isAbove(Version.V1_18_R2)) { this.register(DarknessArrowsEnchant.ID, () -> new DarknessArrowsEnchant(plugin)); this.register(DarknessCloakEnchant.ID, () -> new DarknessCloakEnchant(plugin)); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java index be1432a..c2600bf 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java @@ -62,12 +62,12 @@ public class DarknessCloakEnchant extends ExcellentEnchant implements Chanced, P } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(victim)) return false; if (!this.checkTriggerChance(level)) return false; if (!this.addEffect(damager, level)) return false; 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 712c3d6..e6ac365 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 @@ -61,12 +61,12 @@ public class EnchantColdSteel extends ExcellentEnchant implements Chanced, Potio } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; if (!this.checkTriggerChance(level)) return false; 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 db63449..6c11e5d 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 @@ -62,12 +62,12 @@ public class EnchantFireShield extends ExcellentEnchant implements Chanced, Comb } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(victim)) return false; 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 43817a1..95ccb28 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 @@ -19,6 +19,7 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.Version; import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.api.server.AbstractTask; import su.nexmedia.engine.utils.Pair; @@ -180,9 +181,11 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { Pair pair = BLOCKS_TO_DESTROY.get(block); long time = pair.getFirst(); if (now >= time) { - block.getWorld().getPlayers().forEach(player -> { - player.sendBlockDamage(block.getLocation(), 0F, pair.getSecond()); - }); + if (Version.isAtLeast(Version.V1_19_R3)) { + block.getWorld().getPlayers().forEach(player -> { + player.sendBlockDamage(block.getLocation(), 0F, pair.getSecond()); + }); + } block.setType(Material.LAVA); @@ -191,7 +194,7 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { return true; } - else { + else if (Version.isAtLeast(Version.V1_19_R3)) { long diff = TimeUnit.MILLISECONDS.toSeconds(time - now); float progress = (float) (1D - Math.min(1D, diff / 5D)); 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 c15b446..504f8db 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 @@ -60,12 +60,12 @@ public class EnchantHardened extends ExcellentEnchant implements Chanced, Potion } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; if (!this.checkTriggerChance(level)) return false; 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 06bbc66..5735c4b 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 @@ -61,12 +61,12 @@ public class EnchantIceShield extends ExcellentEnchant implements Chanced, Potio } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(victim)) return false; if (!this.checkTriggerChance(level)) return false; if (!this.addEffect(damager, level)) return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/StoppingForceEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/StoppingForceEnchant.java index f51a849..87db573 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/StoppingForceEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/StoppingForceEnchant.java @@ -59,12 +59,12 @@ public class StoppingForceEnchant extends ExcellentEnchant implements Chanced, C } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(victim)) return false; if (!this.checkTriggerChance(level)) return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java index dfd41ff..9570c2f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java @@ -77,9 +77,9 @@ public class DarknessArrowsEnchant extends ExcellentEnchant implements Chanced, } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; - if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); @@ -87,12 +87,12 @@ public class DarknessArrowsEnchant extends ExcellentEnchant implements Chanced, } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return this.isOurProjectile(projectile); } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return this.isOurProjectile(projectile); } } 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 4f6d58f..1a15d85 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 @@ -74,26 +74,26 @@ public class EnchantBomber extends ExcellentEnchant implements Chanced, BowEncha } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; if (!this.checkTriggerChance(level)) return false; - if (!(e.getProjectile() instanceof Projectile projectile)) return false; + if (!(event.getProjectile() instanceof Projectile projectile)) return false; TNTPrimed primed = projectile.getWorld().spawn(projectile.getLocation(), TNTPrimed.class); - primed.setVelocity(projectile.getVelocity().multiply(e.getForce() * 1.25)); + primed.setVelocity(projectile.getVelocity().multiply(event.getForce() * 1.25)); primed.setFuseTicks(this.getFuseTicks(level)); primed.setSource(shooter); - e.setProjectile(primed); + event.setProjectile(primed); return true; } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return false; } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } } 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 0b17a99..ef4fd4a 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 @@ -77,9 +77,9 @@ public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; - if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); @@ -87,12 +87,12 @@ public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return this.isOurProjectile(projectile); } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return this.isOurProjectile(projectile); } } 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 1e67940..c21f35d 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 @@ -98,16 +98,16 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; return this.checkTriggerChance(level); } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { if (!this.isOurProjectile(projectile)) return false; - if (e.getHitEntity() != null) return false; + if (event.getHitEntity() != null) return false; if (projectile.getShooter() == null) return false; this.createCloud(projectile.getShooter(), projectile.getLocation() , level); @@ -115,7 +115,7 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isOurProjectile(projectile)) return false; this.createCloud(shooter, victim.getLocation(), level); 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 62f7d0c..274541a 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 @@ -72,18 +72,18 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; return this.checkTriggerChance(level); } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { if (!this.isOurProjectile(projectile)) return false; - if (e.getHitEntity() != null || e.getHitBlock() == null) return false; + if (event.getHitEntity() != null || event.getHitBlock() == null) return false; - Block block = e.getHitBlock(); + Block block = event.getHitBlock(); block.getWorld().strikeLightning(block.getLocation()).setMetadata(META_NO_ITEM_DAMAGE, new FixedMetadataValue(plugin, true)); if (this.hasVisualEffects()) { Location center = LocationUtil.getCenter(block.getLocation()); @@ -94,7 +94,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isOurProjectile(projectile)) return false; plugin.getServer().getScheduler().runTask(plugin, () -> { 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 17d0cad..795ff07 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 @@ -60,24 +60,24 @@ public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Cha } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; if (!this.checkTriggerChance(level)) return false; - if (!(e.getProjectile() instanceof Projectile projectile)) return false; + if (!(event.getProjectile() instanceof Projectile projectile)) return false; EnderPearl pearl = shooter.launchProjectile(EnderPearl.class); pearl.setVelocity(projectile.getVelocity()); - e.setProjectile(pearl); + event.setProjectile(pearl); return true; } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return false; } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } } 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 58c18a3..e61bd74 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 @@ -100,14 +100,14 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; return this.checkTriggerChance(level); } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { if (!this.isOurProjectile(projectile)) return false; Entity shooter = null; @@ -126,7 +126,7 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return this.isOurProjectile(projectile); } 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 5f63afe..949a0f1 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 @@ -79,10 +79,10 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; if (!this.checkTriggerChance(level)) return false; - if (!(e.getProjectile() instanceof Projectile projectile)) return false; + if (!(event.getProjectile() instanceof Projectile projectile)) return false; Fireball fireball; @@ -99,17 +99,17 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance fireball.setIsIncendiary(this.isFireSpread()); fireball.setYield(this.getYield(level)); - e.setProjectile(fireball); + event.setProjectile(fireball); return true; } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return false; } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; 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 da52935..08f8683 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 @@ -77,9 +77,9 @@ public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; - if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); @@ -87,12 +87,12 @@ public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return this.isOurProjectile(projectile); } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return this.isOurProjectile(projectile); } } 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 133da9c..52b1822 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 @@ -77,9 +77,9 @@ public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; - if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); @@ -87,12 +87,12 @@ public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return this.isOurProjectile(projectile); } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return this.isOurProjectile(projectile); } } 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 74f8231..70472fc 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 @@ -77,9 +77,9 @@ public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; - if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); @@ -87,12 +87,12 @@ public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return this.isOurProjectile(projectile); } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return this.isOurProjectile(projectile); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java index 0394371..ec6bc95 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java @@ -69,8 +69,8 @@ public class FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed, } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!(e.getProjectile() instanceof Arrow arrow)) return false; + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!this.isAvailableToUse(shooter)) return false; if (!this.checkTriggerChance(level)) return false; @@ -110,7 +110,7 @@ public class FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed, } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/SniperEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/SniperEnchant.java index 1f7f941..6fc6e77 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/SniperEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/SniperEnchant.java @@ -65,13 +65,13 @@ public class SniperEnchant extends ExcellentEnchant implements BowEnchant, Chanc } @Override - public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!this.isAvailableToUse(shooter)) return false; if (!this.checkTriggerChance(level)) return false; double modifier = this.getSpeedModifier(level); - Entity entity = e.getProjectile(); + Entity entity = event.getProjectile(); Vector vector = entity.getVelocity(); entity.setVelocity(vector.multiply(modifier)); @@ -79,12 +79,12 @@ public class SniperEnchant extends ExcellentEnchant implements BowEnchant, Chanc } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return false; } @Override - public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java index e4887ff..6607314 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java @@ -16,7 +16,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; 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 CurseOfMediocrityEnchant extends ExcellentEnchant implements Chanced, BlockDropEnchant, DeathEnchant { @@ -62,7 +61,7 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance } @Override - public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; @@ -75,12 +74,6 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance drop.setItemStack(stack); }); - dropContainer.getDrop().forEach(stack -> { - ItemUtil.mapMeta(stack, meta -> { - meta.getEnchants().keySet().forEach(meta::removeEnchant); - }); - }); - return true; } 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 6f34627..8c0042d 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 @@ -11,7 +11,6 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -33,14 +32,12 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo public static final String ID = "blast_mining"; public static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; - private static final String META_EXPLOSION_SOURCE = ID + "_explosion_source"; - private static final String META_EXPLOSION_MINED = ID + "_explosion_mined"; - private EnchantScaler explosionPower; private EnchantScaler minBlockStrength; - private ChanceImplementation chanceImplementation; + private int explodeLevel; + public EnchantBlastMining(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.MEDIUM); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to mine blocks by explosion."); @@ -52,11 +49,14 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo @Override public void loadSettings() { super.loadSettings(); + 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", "Minimal block strength value for the enchantment to have effect.", @@ -80,8 +80,8 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo return (float) minBlockStrength.getValue(level); } - private boolean isBlockHardEnough(@NotNull Block block, int level) { - float strength = block.getType().getHardness();//plugin.getNMS().getBlockStrength(block); + private boolean isHardEnough(@NotNull Block block, int level) { + float strength = block.getType().getHardness(); return (strength >= this.getMinBlockStrength(level)); } @@ -98,50 +98,37 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo } @Override - public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isAvailableToUse(player)) return false; + if (EnchantUtils.isBusy()) return false; - if (EnchantUtils.contains(item, EnchantVeinminer.ID)) return false; - if (EnchantUtils.contains(item, EnchantTunnel.ID)) return false; - - Block block = e.getBlock(); - if (block.hasMetadata(META_EXPLOSION_MINED)) return false; - - if (!this.isBlockHardEnough(block, level)) return false; + Block block = event.getBlock(); + if (!this.isHardEnough(block, level)) return false; if (!this.checkTriggerChance(level)) return false; float power = (float) this.getExplosionPower(level); - player.setMetadata(META_EXPLOSION_SOURCE, new FixedMetadataValue(plugin, level)); + this.explodeLevel = level; NoCheatPlusHook.exemptBlocks(player); boolean exploded = block.getWorld().createExplosion(block.getLocation(), power, false, true, player); NoCheatPlusHook.unexemptBlocks(player); - player.removeMetadata(META_EXPLOSION_SOURCE, plugin); + this.explodeLevel = -1; + return exploded; } // Process explosion event to mine blocks. @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onBlastExplosionEvent(EntityExplodeEvent e) { - if (!(e.getEntity() instanceof Player player)) return; - if (!player.hasMetadata(META_EXPLOSION_SOURCE)) return; + public void onBlastExplosionEvent(EntityExplodeEvent event) { + if (this.explodeLevel <= 0) return; + if (!(event.getEntity() instanceof Player player)) return; - int level = player.getMetadata(META_EXPLOSION_SOURCE).get(0).asInt(); - List blockList = e.blockList(); - - // Remove the 'source' block which player mined and caused the explosion to prevent duplicated drops. - // Remove all the 'soft' blocks that should not be exploded. - blockList.removeIf(block -> block.getLocation().equals(e.getLocation()) || !this.isBlockHardEnough(block, level)); - - // Break all 'exploded' blocks by a player, adding metadata to them to prevent trigger enchantment in a loop. + List blockList = event.blockList(); blockList.forEach(block -> { - block.setMetadata(META_EXPLOSION_MINED, new FixedMetadataValue(plugin, true)); - //plugin.getNMS().breakBlock(player, block); - player.breakBlock(block); - block.removeMetadata(META_EXPLOSION_MINED, plugin); - }); + if (block.getLocation().equals(event.getLocation()) || !this.isHardEnough(block, this.explodeLevel)) return; - // Clear list of 'exploded' blocks so the event won't affect them, as they are already mined by a player. + EnchantUtils.safeBusyBreak(player, block); + }); blockList.clear(); } @@ -151,14 +138,12 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo if (e.getCause() != DamageCause.ENTITY_EXPLOSION) return; if (!(e.getDamager() instanceof Player player)) return; - e.setCancelled(player.hasMetadata(META_EXPLOSION_SOURCE)); + e.setCancelled(this.explodeLevel > 0); } // Do not reduce item durability for 'exploded' blocks. @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlastExplosionItemDamage(PlayerItemDamageEvent e) { - if (!e.getPlayer().hasMetadata(META_EXPLOSION_SOURCE)) return; - - e.setCancelled(true); + e.setCancelled(this.explodeLevel > 0); } } 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 ca40ad4..7e4098f 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 @@ -74,12 +74,12 @@ public class EnchantCurseOfMisfortune extends ExcellentEnchant implements Chance } @Override - public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; - e.setDropItems(false); - if (!this.isDropExp()) e.setExpToDrop(0); + event.setDropItems(false); + if (!this.isDropExp()) event.setExpToDrop(0); return true; } 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 c92c32d..316142e 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 @@ -31,8 +31,8 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; 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 su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, BlockBreakEnchant, BlockDropEnchant { @@ -102,16 +102,16 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo } @Override - public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { BlockState state = event.getBlockState(); Block block = state.getBlock(); if (!block.hasMetadata(META_HANDLE)) return false; if (!(state instanceof CreatureSpawner spawnerBlock)) return false; - dropContainer.getDrop().add(this.getSpawner(spawnerBlock)); + EnchantUtils.popResource(event, this.getSpawner(spawnerBlock)); - Location location = LocationUtil.getCenter(block.getLocation()); if (this.hasVisualEffects()) { + Location location = LocationUtil.getCenter(block.getLocation()); SimpleParticle.of(Particle.VILLAGER_HAPPY).play(location, 0.3, 0.15, 30); } block.removeMetadata(META_HANDLE, this.plugin); @@ -119,14 +119,14 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo } @Override - public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - Block block = e.getBlock(); + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { + Block block = event.getBlock(); if (!this.isAvailableToUse(player)) return false; if (!(block.getState() instanceof CreatureSpawner spawnerBlock)) return false; if (!this.checkTriggerChance(level)) return false; - e.setExpToDrop(0); - e.setDropItems(true); + event.setExpToDrop(0); + event.setDropItems(true); block.setMetadata(META_HANDLE, new FixedMetadataValue(this.plugin, true)); return false; // Do not consume charges } 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 6bcecfe..0c559cd 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 @@ -66,12 +66,12 @@ public class EnchantLuckyMiner extends ExcellentEnchant implements Chanced, Bloc } @Override - public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; double expMod = this.getExpModifier(level); - e.setExpToDrop((int) ((double) e.getExpToDrop() * expMod)); + event.setExpToDrop((int) ((double) event.getExpToDrop() * expMod)); return true; } } 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 ae96884..1295971 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 @@ -120,21 +120,21 @@ public class EnchantReplanter extends ExcellentEnchant implements Chanced, Inter } @Override - public boolean onInteract(@NotNull PlayerInteractEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onInteract(@NotNull PlayerInteractEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isReplantOnRightClick()) return false; if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; // Check for a event hand. We dont want to trigger it twice. - if (e.getHand() != EquipmentSlot.HAND) return false; - if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return false; + if (event.getHand() != EquipmentSlot.HAND) return false; + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return false; // Check if player holds seeds to plant them by offhand interaction. ItemStack off = player.getInventory().getItemInOffHand(); if (!off.getType().isAir() && CROPS.contains(off.getType())) return false; // Check if clicked block is a farmland. - Block blockGround = e.getClickedBlock(); + Block blockGround = event.getClickedBlock(); if (blockGround == null) return false; if (blockGround.getType() != Material.FARMLAND && blockGround.getType() != Material.SOUL_SAND) return false; @@ -158,12 +158,12 @@ public class EnchantReplanter extends ExcellentEnchant implements Chanced, Inter } @Override - public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isReplantOnPlantBreak()) return false; if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; - Block blockPlant = e.getBlock(); + Block blockPlant = event.getBlock(); //if (EnchantTelekinesis.isDropHandled(blockPlant)) return false; //if (EnchantRegister.TELEKINESIS != null && item.containsEnchantment(EnchantRegister.TELEKINESIS)) return false; 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 a289d30..434afc0 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 @@ -28,8 +28,8 @@ import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; -import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.ArrayList; import java.util.List; @@ -130,7 +130,7 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha } @Override - public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { BlockState state = event.getBlockState(); Block block = state.getBlock(); @@ -143,12 +143,12 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha chest.getBlockInventory().addItem(event.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0])); if (chest.getBlockInventory().isEmpty()) { - dropContainer.getDrop().add(new ItemStack(chest.getType())); + EnchantUtils.popResource(event, new ItemStack(chest.getType())); return false; } // Добавляем кастомный сундук в кастомный дроп лист. - dropContainer.getDrop().add(this.getSilkChest(chest)); + EnchantUtils.popResource(event, this.getSilkChest(chest)); // Очищаем инвентарь сундука и дефолтный дроп лист. chest.getBlockInventory().clear(); 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 d544ebe..34aa611 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 @@ -22,7 +22,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; 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.Map; @@ -89,7 +88,10 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr } @Override - public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { + // TODO Use furnace recipes + // TODO Re-add smelted items instead of setType + if (event.getBlockState() instanceof Container) return false; if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; 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 8fde3f0..756224f 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,17 +8,15 @@ 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; -import su.nightexpress.excellentenchants.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.EnchantPriority; import java.util.ArrayList; import java.util.List; -import java.util.Objects; public class EnchantTelekinesis extends ExcellentEnchant implements Chanced, BlockDropEnchant { @@ -58,17 +56,15 @@ public class EnchantTelekinesis extends ExcellentEnchant implements Chanced, Blo } @Override - public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; - List drops = new ArrayList<>(); - drops.addAll(event.getItems().stream().map(Item::getItemStack).toList()); - drops.addAll(dropContainer.getDrop()); - drops.removeIf(Objects::isNull); + List drops = new ArrayList<>(event.getItems().stream().map(Item::getItemStack).toList()); + //drops.addAll(dropContainer.getDrop()); + //drops.removeIf(Objects::isNull); drops.forEach(drop -> PlayerUtil.addItem(player, drop)); - dropContainer.getDrop().clear(); event.getItems().clear(); return true; 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 e2b5d9f..4ad2c34 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 @@ -21,8 +21,8 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; 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 su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.*; import java.util.function.Predicate; @@ -128,15 +128,15 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block } @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)); + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { + if (PlayerBlockTracker.isTracked(event.getBlock())) { + event.getBlock().setMetadata(META, new FixedMetadataValue(plugin, true)); } return false; } @Override - public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { Block block = event.getBlockState().getBlock(); if (block.hasMetadata(META)) { block.removeMetadata(META, plugin); @@ -145,7 +145,11 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; - dropContainer.getDrop().addAll(this.getTreasures(event.getBlockState().getType())); + this.getTreasures(event.getBlockState().getType()).forEach(treasure -> { + EnchantUtils.popResource(event, treasure); + }); + + //dropContainer.getDrop().addAll(this.getTreasures(event.getBlockState().getType())); return true; } 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 c10d3c9..9f1a731 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 @@ -20,7 +20,6 @@ import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; import java.util.HashSet; import java.util.Set; -import java.util.UUID; public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant { @@ -34,12 +33,10 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant INTERACTABLE_BLOCKS.add(Material.DEEPSLATE_REDSTONE_ORE); } - private final Set activePlayers; private boolean disableOnSneak; public EnchantTunnel(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGH); - this.activePlayers = new HashSet<>(); this.getDefaults().setDescription("Mines multiple blocks at once in a certain shape."); this.getDefaults().setLevelMax(3); @@ -66,19 +63,13 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant return EnchantmentTarget.TOOL; } - public boolean isTunneling(@NotNull Player player) { - return this.activePlayers.contains(player.getUniqueId()); - } - @Override - public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) { - if (this.isTunneling(player)) return false; + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { + if (EnchantUtils.isBusy()) return false; if (!this.isAvailableToUse(player)) return false; if (this.disableOnSneak && player.isSneaking()) return false; - if (EnchantUtils.contains(item, EnchantVeinminer.ID)) return false; - if (EnchantUtils.contains(item, EnchantBlastMining.ID)) return false; - Block block = e.getBlock(); + Block block = event.getBlock(); if (block.getType().isInteractable() && !INTERACTABLE_BLOCKS.contains(block.getType())) return false; if (block.getDrops(item).isEmpty()) return false; @@ -90,9 +81,8 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant int blocksBroken = 1; if (level == 1) blocksBroken = 2; else if (level == 2) blocksBroken = 5; - else if (level == 3) blocksBroken = 9; + else if (level >= 3) blocksBroken = 9; - this.activePlayers.add(player.getUniqueId()); NoCheatPlusHook.exemptBlocks(player); for (int i = 0; i < blocksBroken; i++) { @@ -121,11 +111,10 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant if (addType == Material.BEDROCK || addType == Material.END_PORTAL || addType == Material.END_PORTAL_FRAME) continue; if (addType == Material.OBSIDIAN && addType != block.getType()) continue; - player.breakBlock(blockAdd); + EnchantUtils.safeBusyBreak(player, blockAdd); } NoCheatPlusHook.unexemptBlocks(player); - this.activePlayers.remove(player.getUniqueId()); return true; } } 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 4889c7a..a11e299 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 @@ -23,7 +23,6 @@ import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; import java.util.HashSet; import java.util.Set; -import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -36,15 +35,13 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH }; - private static final String PLACEHOLDER_BLOCK_LIMIT = "%enchantment_block_limit%"; + private static final String PLACEHOLDER_BLOCK_LIMIT = "%enchantment_block_limit%"; private Scaler blocksLimit; private Set blocksAffected; - private final Set activePlayers; public EnchantVeinminer(@NotNull ExcellentEnchants plugin) { super(plugin, ID, EnchantPriority.HIGH); - this.activePlayers = new HashSet<>(); this.getDefaults().setDescription("Mines up to " + PLACEHOLDER_BLOCK_LIMIT + " blocks of the ore vein at once."); this.getDefaults().setLevelMax(3); @@ -110,10 +107,6 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch .filter(blockAdded -> blockAdded.getType() == block.getType()).collect(Collectors.toSet()); } - public boolean isInVein(@NotNull Player player) { - return this.activePlayers.contains(player.getUniqueId()); - } - private void vein(@NotNull Player player, @NotNull Block source, int level) { Set ores = new HashSet<>(); Set prepare = new HashSet<>(this.getNearby(source)); @@ -128,26 +121,21 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch prepare.addAll(nearby); } ores.remove(source); - ores.forEach(player::breakBlock); + ores.forEach(ore -> EnchantUtils.safeBusyBreak(player, ore)); } @Override - public boolean onBreak(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack tool, int level) { - if (this.isInVein(player)) return false; + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack tool, int level) { if (!this.isAvailableToUse(player)) return false; - if (EnchantUtils.contains(tool, EnchantBlastMining.ID)) return false; - if (EnchantUtils.contains(tool, EnchantTunnel.ID)) return false; + if (EnchantUtils.isBusy()) return false; - Block block = e.getBlock(); - if (block.getDrops(tool).isEmpty()) return false; + Block block = event.getBlock(); + if (block.getDrops(tool, player).isEmpty()) return false; if (!this.getBlocksAffected().contains(block.getType())) return false; - this.activePlayers.add(player.getUniqueId()); NoCheatPlusHook.exemptBlocks(player); this.vein(player, block, level); NoCheatPlusHook.unexemptBlocks(player); - this.activePlayers.remove(player.getUniqueId()); - return true; } } 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 f2538de..9e13639 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 @@ -65,13 +65,13 @@ public class EnchantBaneOfNetherspawn extends ExcellentEnchant implements Combat } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!ENTITY_TYPES.contains(victim.getType())) return false; if (!this.isAvailableToUse(damager)) return false; - double damageEvent = e.getDamage(); + double damageEvent = event.getDamage(); double damageAdd = this.getDamageModifier(level); - e.setDamage(this.damageModifier ? damageEvent * damageAdd : damageEvent + damageAdd); + event.setDamage(this.damageModifier ? damageEvent * damageAdd : damageEvent + damageAdd); if (this.hasVisualEffects()) { SimpleParticle.of(Particle.SMOKE_NORMAL).play(victim.getEyeLocation(), 0.25, 0.1, 30); } @@ -79,7 +79,7 @@ public class EnchantBaneOfNetherspawn extends ExcellentEnchant implements Combat } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantBlindness.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantBlindness.java index 06c54c9..78e7f7a 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 @@ -61,7 +61,7 @@ public class EnchantBlindness extends ExcellentEnchant implements Chanced, Potio } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; @@ -73,7 +73,7 @@ public class EnchantBlindness extends ExcellentEnchant implements Chanced, Potio } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantConfusion.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantConfusion.java index aa456a1..a534885 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 @@ -62,7 +62,7 @@ public class EnchantConfusion extends ExcellentEnchant implements Chanced, Potio } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; @@ -75,7 +75,7 @@ public class EnchantConfusion extends ExcellentEnchant implements Chanced, Potio } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantCure.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCure.java index 2f760e1..78ecc8a 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 @@ -53,13 +53,13 @@ public class EnchantCure extends ExcellentEnchant implements Chanced, CombatEnch } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; if (!CUREABLE.contains(victim.getType())) return false; if (!this.checkTriggerChance(level)) return false; if (!(damager instanceof Player player)) return false; - e.setCancelled(true); + event.setCancelled(true); if (this.hasVisualEffects()) { SimpleParticle.of(Particle.CLOUD).play(victim.getEyeLocation(), 0.25, 0.1, 30); @@ -77,7 +77,7 @@ public class EnchantCure extends ExcellentEnchant implements Chanced, CombatEnch } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantCutter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantCutter.java index 3d570da..e98b170 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 @@ -78,7 +78,7 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; EntityEquipment equipment = victim.getEquipment(); @@ -117,7 +117,7 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantDoubleStrike.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDoubleStrike.java index c6f5225..546f820 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 @@ -50,11 +50,11 @@ public class EnchantDoubleStrike extends ExcellentEnchant implements Chanced, Co } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; if (!this.checkTriggerChance(level)) return false; - e.setDamage(e.getDamage() * 2D); + event.setDamage(event.getDamage() * 2D); if (this.hasVisualEffects()) { SimpleParticle.of(Particle.EXPLOSION_NORMAL).play(victim.getEyeLocation(), 0.25, 0.15, 15); @@ -64,7 +64,7 @@ public class EnchantDoubleStrike extends ExcellentEnchant implements Chanced, Co } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantExhaust.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExhaust.java index ad671b6..339b37c 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 @@ -62,7 +62,7 @@ public class EnchantExhaust extends ExcellentEnchant implements Chanced, Potione } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; @@ -74,7 +74,7 @@ public class EnchantExhaust extends ExcellentEnchant implements Chanced, Potione } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantIceAspect.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantIceAspect.java index 6aa4805..11c5ba5 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 @@ -61,7 +61,7 @@ public class EnchantIceAspect extends ExcellentEnchant implements Chanced, Potio } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; @@ -75,7 +75,7 @@ public class EnchantIceAspect extends ExcellentEnchant implements Chanced, Potio } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantParalyze.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantParalyze.java index f50ed68..58d9def 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 @@ -61,7 +61,7 @@ public class EnchantParalyze extends ExcellentEnchant implements Chanced, Potion } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; @@ -73,7 +73,7 @@ public class EnchantParalyze extends ExcellentEnchant implements Chanced, Potion } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantRage.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRage.java index f83be3d..d42899a 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 @@ -61,7 +61,7 @@ public class EnchantRage extends ExcellentEnchant implements Chanced, Potioned, } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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(damager, level)) return false; @@ -73,7 +73,7 @@ public class EnchantRage extends ExcellentEnchant implements Chanced, Potioned, } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantRocket.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantRocket.java index 9613c3e..e8b3c8a 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 @@ -61,7 +61,7 @@ public class EnchantRocket extends ExcellentEnchant implements Chanced, CombatEn } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; if (!this.checkTriggerChance(level)) return false; @@ -96,7 +96,7 @@ public class EnchantRocket extends ExcellentEnchant implements Chanced, CombatEn } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantSurprise.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantSurprise.java index 943aaef..407b000 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 @@ -64,7 +64,7 @@ public class EnchantSurprise extends ExcellentEnchant implements Chanced, Potion } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; if (!this.checkTriggerChance(level)) return false; @@ -80,7 +80,7 @@ public class EnchantSurprise extends ExcellentEnchant implements Chanced, Potion } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantTemper.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantTemper.java index 63a4651..0cc08a8 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 @@ -68,7 +68,7 @@ public class EnchantTemper extends ExcellentEnchant implements CombatEnchant { } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; double healthPoint = this.getHealthPoint(level); @@ -84,12 +84,12 @@ public class EnchantTemper extends ExcellentEnchant implements CombatEnchant { double damageCap = this.getDamageCapacity(level); double damageFinal = Math.min(damageCap, 1D + damageAmount * pointAmount); - e.setDamage(e.getDamage() * damageFinal); + event.setDamage(event.getDamage() * damageFinal); return true; } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantThunder.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThunder.java index 8072c01..85a6447 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 @@ -60,7 +60,7 @@ public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatE } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; if (this.isInThunderstormOnly() && !victim.getWorld().isThundering()) return false; if (victim.getLocation().getBlock().getLightFromSky() != 15) return false; @@ -76,7 +76,7 @@ public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatE } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantVampire.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVampire.java index 774fc59..073b116 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 @@ -73,7 +73,7 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; double healthMax = EntityUtil.getAttribute(damager, Attribute.GENERIC_MAX_HEALTH); @@ -83,7 +83,7 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE if (!this.checkTriggerChance(level)) return false; double healAmount = this.getHealAmount(level); - double healFinal = this.isHealMultiplier() ? e.getDamage() * healAmount : healAmount; + double healFinal = this.isHealMultiplier() ? event.getDamage() * healAmount : healAmount; EntityRegainHealthEvent healthEvent = new EntityRegainHealthEvent(damager, healFinal, EntityRegainHealthEvent.RegainReason.CUSTOM); plugin.getPluginManager().callEvent(healthEvent); @@ -98,7 +98,7 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantVenom.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVenom.java index a07b315..9feda0b 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 @@ -61,7 +61,7 @@ public class EnchantVenom extends ExcellentEnchant implements Chanced, Potioned, } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; @@ -73,7 +73,7 @@ public class EnchantVenom extends ExcellentEnchant implements Chanced, Potioned, } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantVillageDefender.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantVillageDefender.java index 1f1a524..f7692ac 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 @@ -61,15 +61,15 @@ public class EnchantVillageDefender extends ExcellentEnchant implements CombatEn } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!this.isAvailableToUse(damager)) return false; if (!(victim instanceof Illager)) return false; double damageAdd = this.getDamageAddict(level); - double damageHas = e.getDamage(); + double damageHas = event.getDamage(); double damageFinal = this.isDamageMultiplier() ? (damageHas * damageAdd) : (damageHas + damageAdd); - e.setDamage(damageFinal); + event.setDamage(damageFinal); if (this.hasVisualEffects()) { SimpleParticle.of(Particle.VILLAGER_ANGRY).play(victim.getEyeLocation(), 0.25, 0.1, 30); @@ -78,7 +78,7 @@ public class EnchantVillageDefender extends ExcellentEnchant implements CombatEn } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @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/EnchantWither.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantWither.java index e39a6bb..6460a6f 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 @@ -61,7 +61,7 @@ public class EnchantWither extends ExcellentEnchant implements Chanced, Potioned } @Override - public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; @@ -73,7 +73,7 @@ public class EnchantWither extends ExcellentEnchant implements Chanced, Potioned } @Override - public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; } } 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 915a059..bbd2e34 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 @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.listener; +import org.bukkit.World; import org.bukkit.block.Chest; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.*; @@ -93,15 +94,20 @@ public class EnchantGenericListener extends AbstractListener // Handle Enchanting Table // --------------------------------------------------------------- @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void onEnchantPopulateEnchantingTable(final EnchantItemEvent e) { - ItemStack target = e.getItem(); - Map enchantsPrepared = e.getEnchantsToAdd(); - Map enchantsToPopulate = EnchantUtils.getPopulationCandidates(target, ObtainType.ENCHANTING, enchantsPrepared, enchant -> enchant.getLevelByEnchantCost(e.getExpLevelCost())); + public void onEnchantPopulateEnchantingTable(final EnchantItemEvent event) { + ItemStack target = event.getItem(); + World world = event.getEnchanter().getWorld(); + + Map enchantsPrepared = event.getEnchantsToAdd(); + Map enchantsToPopulate = EnchantUtils.getPopulationCandidates( + target, ObtainType.ENCHANTING, enchantsPrepared, + enchant -> enchant.getLevelByEnchantCost(event.getExpLevelCost()), + world); enchantsPrepared.putAll(enchantsToPopulate); plugin.getServer().getScheduler().runTask(plugin, () -> { - ItemStack result = e.getInventory().getItem(0); + ItemStack result = event.getInventory().getItem(0); if (result == null) return; // Fix enchantments for Enchant Books. @@ -109,7 +115,7 @@ public class EnchantGenericListener extends AbstractListener // Server gets enchants from NMS to apply it on Book NBT tags. ItemMeta meta = result.getItemMeta(); if (meta instanceof EnchantmentStorageMeta storageMeta) { - e.getEnchantsToAdd().forEach((enchantment, level) -> { + event.getEnchantsToAdd().forEach((enchantment, level) -> { if (!storageMeta.hasStoredEnchant(enchantment)) { storageMeta.addStoredEnchant(enchantment, level, true); } @@ -117,14 +123,14 @@ public class EnchantGenericListener extends AbstractListener result.setItemMeta(storageMeta); } - e.getEnchantsToAdd().forEach((enchantment, level) -> { + event.getEnchantsToAdd().forEach((enchantment, level) -> { if (enchantment instanceof ExcellentEnchant enchant && enchant.isChargesEnabled()) { EnchantUtils.restoreCharges(result, enchant, level); } }); EnchantUtils.updateDisplay(result); - e.getInventory().setItem(0, result); + event.getInventory().setItem(0, result); }); } @@ -132,12 +138,13 @@ public class EnchantGenericListener extends AbstractListener // Adding Enchants to Villagers // --------------------------------------------------------------- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantPopulateVillagerAcquire(VillagerAcquireTradeEvent e) { - MerchantRecipe recipe = e.getRecipe(); + public void onEnchantPopulateVillagerAcquire(VillagerAcquireTradeEvent event) { + MerchantRecipe recipe = event.getRecipe(); ItemStack result = recipe.getResult(); + World world = event.getEntity().getWorld(); if (!EnchantUtils.isEnchantable(result)) return; - if (!EnchantUtils.populate(result, ObtainType.VILLAGER)) return; + if (!EnchantUtils.populate(result, ObtainType.VILLAGER, world)) return; int uses = recipe.getUses(); int maxUses = recipe.getMaxUses(); @@ -150,34 +157,36 @@ public class EnchantGenericListener extends AbstractListener MerchantRecipe recipe2 = new MerchantRecipe(result, uses, maxUses, expReward, villagerExperience, priceMultiplier, demand, specialPrice); recipe2.setIngredients(recipe.getIngredients()); - e.setRecipe(recipe2); + event.setRecipe(recipe2); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantPopulateLoot(LootGenerateEvent e) { + public void onEnchantPopulateLoot(LootGenerateEvent event) { if (Config.getObtainSettings(ObtainType.LOOT_GENERATION).isEmpty()) return; - Entity entity = e.getEntity(); - InventoryHolder holder = e.getInventoryHolder(); + Entity entity = event.getEntity(); + InventoryHolder holder = event.getInventoryHolder(); + World world = event.getWorld(); if (entity instanceof Minecart || holder instanceof Chest) { - e.getLoot().forEach(item -> { + event.getLoot().forEach(item -> { if (item != null && EnchantUtils.isEnchantable(item)) { - EnchantUtils.populate(item, ObtainType.LOOT_GENERATION); + EnchantUtils.populate(item, ObtainType.LOOT_GENERATION, world); } }); } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantPopulateFishing(PlayerFishEvent e) { + public void onEnchantPopulateFishing(PlayerFishEvent event) { if (Config.getObtainSettings(ObtainType.FISHING).isEmpty()) return; - if (e.getState() != PlayerFishEvent.State.CAUGHT_FISH) return; - if (!(e.getCaught() instanceof Item item)) return; + if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return; + if (!(event.getCaught() instanceof Item item)) return; ItemStack itemStack = item.getItemStack(); + World world = item.getWorld(); if (EnchantUtils.isEnchantable(itemStack)) { - EnchantUtils.populate(itemStack, ObtainType.FISHING); + EnchantUtils.populate(itemStack, ObtainType.FISHING, world); } } @@ -191,13 +200,14 @@ public class EnchantGenericListener extends AbstractListener EntityEquipment equipment = entity.getEquipment(); if (equipment == null) return; + World world = entity.getWorld(); boolean isMythic = EngineUtils.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 (EnchantUtils.isEnchantable(item)) { - if (doPopulation) EnchantUtils.populate(item, ObtainType.MOB_SPAWNING); + if (doPopulation) EnchantUtils.populate(item, ObtainType.MOB_SPAWNING, world); EnchantUtils.getExcellents(item).forEach((enchant, level) -> EnchantUtils.restoreCharges(item, enchant, level)); 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 fe145a8..6931d08 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 @@ -1,10 +1,7 @@ package su.nightexpress.excellentenchants.enchantment.listener; import org.bukkit.GameMode; -import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.BlockState; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; @@ -29,7 +26,6 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; import su.nightexpress.excellentenchants.api.enchantment.type.*; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.EnchantManager; -import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; public class EnchantHandlerListener extends AbstractListener { @@ -282,26 +278,26 @@ public class EnchantHandlerListener extends AbstractListener } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantBlockDropItem(BlockDropItemEvent e) { - Player player = e.getPlayer(); + public void onEnchantBlockDropItem(BlockDropItemEvent event) { + Player player = event.getPlayer(); if (player.getGameMode() == GameMode.CREATIVE) return; ItemStack tool = player.getInventory().getItemInMainHand(); if (tool.getType().isAir() || tool.getType() == Material.ENCHANTED_BOOK) return; - EnchantDropContainer dropContainer = new EnchantDropContainer(e); + //EnchantDropContainer dropContainer = new EnchantDropContainer(e); EnchantUtils.getExcellents(tool, BlockDropEnchant.class).forEach((enchant, level) -> { if (enchant.isOutOfCharges(tool)) return; - if (enchant.onDrop(e, dropContainer, player, tool, level)) { + if (enchant.onDrop(event, player, tool, level)) { enchant.consumeChargesNoUpdate(tool, level); } }); EnchantUtils.updateChargesDisplay(tool); - BlockState state = e.getBlockState(); - World world = state.getWorld(); - Location location = state.getLocation(); + //BlockState state = e.getBlockState(); + //World world = state.getWorld(); + //Location location = state.getLocation(); - dropContainer.getDrop().forEach(item -> world.dropItem(location, item)); + //dropContainer.getDrop().forEach(item -> world.dropItem(location, item)); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantDropContainer.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantDropContainer.java index a570150..723b5a9 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantDropContainer.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantDropContainer.java @@ -7,6 +7,7 @@ import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; +@Deprecated public class EnchantDropContainer { private final BlockDropItemEvent parent; 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 index 9aa5a55..a307e64 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -2,10 +2,14 @@ package su.nightexpress.excellentenchants.enchantment.util; import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.World; +import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; @@ -32,6 +36,7 @@ import su.nightexpress.excellentenchants.enchantment.type.ObtainType; import su.nightexpress.excellentenchants.tier.Tier; import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -40,6 +45,37 @@ public class EnchantUtils { public static final NamespacedKey KEY_LORE_SIZE = new NamespacedKey(ExcellentEnchantsAPI.PLUGIN, "lore_size"); + private static boolean busyBreak = false; + + public static void popResource(@NotNull BlockDropItemEvent event, @NotNull ItemStack itemStack) { + Item item = ExcellentEnchantsAPI.PLUGIN.getEnchantNMS().popResource(event.getBlock(), itemStack); + event.getItems().add(item); + } + + public static boolean isBusyByOthers() { + return false; + } + + public static boolean isBusyByEnchant() { + return busyBreak; + } + + public static boolean isBusy() { + return isBusyByEnchant() || isBusyByOthers(); + } + + public static void busyBreak(@NotNull Player player, @NotNull Block block) { + busyBreak = true; + player.breakBlock(block); + busyBreak = false; + } + + public static void safeBusyBreak(@NotNull Player player, @NotNull Block block) { + if (!isBusy()) { + busyBreak(player, block); + } + } + @NotNull public static NamespacedKey createKey(@NotNull String id) { return NamespacedKey.minecraft(id.toLowerCase()); @@ -65,15 +101,19 @@ public class EnchantUtils { 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); + // TODO Move in populator class - getPopulationCandidates(item, obtainType).forEach((enchantment, level) -> { - add(item, enchantment, level, false); + public static boolean populate(@NotNull ItemStack item, @NotNull ObtainType obtainType, @Nullable World world) { + AtomicBoolean status = new AtomicBoolean(false); + + getPopulationCandidates(item, obtainType, world).forEach((enchantment, level) -> { + if (add(item, enchantment, level, false)) { + status.set(true); + } }); updateDisplay(item); - return getAmount(item) != enchantsHad; + return status.get(); } @NotNull @@ -88,14 +128,16 @@ public class EnchantUtils { } @NotNull - public static Map getPopulationCandidates(@NotNull ItemStack item, @NotNull ObtainType obtainType) { - return getPopulationCandidates(item, obtainType, new HashMap<>(), (enchant) -> enchant.generateLevel(obtainType)); + public static Map getPopulationCandidates(@NotNull ItemStack item, @NotNull ObtainType obtainType, + @Nullable World world) { + return getPopulationCandidates(item, obtainType, new HashMap<>(), (enchant) -> enchant.generateLevel(obtainType), world); } @NotNull public static Map getPopulationCandidates(@NotNull ItemStack item, @NotNull ObtainType obtainType, @NotNull Map enchantsPrepared, - @NotNull Function levelFunc) { + @NotNull Function levelFunc, + @Nullable World world) { Map enchantsToAdd = new HashMap<>(enchantsPrepared); ObtainSettings settings = Config.getObtainSettings(obtainType).orElse(null); @@ -104,44 +146,54 @@ public class EnchantUtils { int enchMax = settings.getEnchantsTotalMax(); int enchRoll = Rnd.get(settings.getEnchantsCustomMin(), settings.getEnchantsCustomMax()); - // Класс для исключения неудачных попыток. EnchantPopulator populator = new EnchantPopulator(obtainType, item); - // Добавляем сколько можем, пока нужное количество не будет добавлено или не закончатся чары и/или тиры. + // Try to populate as many as possible. while (!populator.isEmpty() && enchRoll > 0) { - // Достигнут максимум чар (любых) для итема, заканчиваем. + // Limit reached. if (enchantsToAdd.size() >= enchMax) break; Tier tier = populator.getTierByChance(); - if (tier == null) break; // Нет тира? + if (tier == null) break; // no tiers left. ExcellentEnchant enchant = populator.getEnchantByChance(tier); - // В тире нет подходящих чар (вообще) для итема, исключаем и идем дальше. + // Remove entire tier if no enchants can be selected. if (enchant == null) { populator.purge(tier); continue; } - // Среди уже добавленных чар есть конфликты с тем, что нашли. - // Исключаем, идем дальше. + // Remove disabled world enchants. + if (world != null && enchant.isDisabledInWorld(world)) { + populator.purge(tier, enchant); + continue; + } + + // Remove conflicting enchants. if (enchantsToAdd.keySet().stream().anyMatch(has -> has.conflictsWith(enchant) || enchant.conflictsWith(has))) { populator.purge(tier, enchant); continue; } - // Не получилось сгенерировать подходящий уровень. - // Исключаем, идем дальше. + // Level generation failed. int level = levelFunc.apply(enchant); if (level < enchant.getStartLevel()) { populator.purge(tier, enchant); continue; } - // Добавляем чар, засчитываем попытку. + // All good! populator.purge(tier, enchant); enchantsToAdd.put(enchant, level); enchRoll--; } + + if (!enchantsToAdd.isEmpty()) { + if (obtainType == ObtainType.VILLAGER && item.getType() == Material.ENCHANTED_BOOK && enchRoll == 1) { + getAll(item).keySet().forEach(enchantment -> remove(item, enchantment)); + } + } + return enchantsToAdd; } diff --git a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java index 2cd518d..bf9f1eb 100644 --- a/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java +++ b/NMS/src/main/java/su/nightexpress/excellentenchants/nms/EnchantNMS.java @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.nms; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.FishHook; +import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -20,4 +21,6 @@ public interface EnchantNMS { @Nullable ItemStack getSpawnEgg(@NotNull LivingEntity entity); @NotNull Set handleFlameWalker(@NotNull LivingEntity entity, @NotNull Location location, int level); + + @NotNull Item popResource(@NotNull Block block, @NotNull ItemStack item); } diff --git a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java index 552eb7e..2612742 100644 --- a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java +++ b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java @@ -3,9 +3,13 @@ package su.nightexpress.excellentenchants.nms.v1_17_R1; import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.projectile.FishingHook; import net.minecraft.world.item.SpawnEggItem; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -13,12 +17,14 @@ import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftFishHook; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory; import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; import org.bukkit.entity.FishHook; +import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -91,4 +97,20 @@ public class V1_17_R1 implements EnchantNMS { } return blocks; } + + @NotNull + public Item popResource(@NotNull Block block, @NotNull ItemStack item) { + Level world = ((CraftWorld)block.getWorld()).getHandle(); + BlockPos pos = ((CraftBlock)block).getPosition(); + net.minecraft.world.item.ItemStack itemstack = CraftItemStack.asNMSCopy(item); + + float yMod = EntityType.ITEM.getHeight() / 2.0F; + double x = (pos.getX() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D); + double y = (pos.getY() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D) - yMod; + double z = (pos.getZ() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D); + + ItemEntity itemEntity = new ItemEntity(world, x, y, z, itemstack); + itemEntity.setDefaultPickUpDelay(); + return (Item) itemEntity.getBukkitEntity(); + } } diff --git a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java index 32a1472..8a97690 100644 --- a/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java +++ b/V1_18_R2/src/main/java/su/nightexpress/excellentenchants/nms/v1_18_R2/V1_18_R2.java @@ -3,9 +3,13 @@ package su.nightexpress.excellentenchants.nms.v1_18_R2; import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.projectile.FishingHook; import net.minecraft.world.item.SpawnEggItem; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -13,12 +17,14 @@ import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftFishHook; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory; import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack; import org.bukkit.entity.FishHook; +import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -91,4 +97,20 @@ public class V1_18_R2 implements EnchantNMS { } return blocks; } + + @NotNull + public Item popResource(@NotNull Block block, @NotNull ItemStack item) { + Level world = ((CraftWorld)block.getWorld()).getHandle(); + BlockPos pos = ((CraftBlock)block).getPosition(); + net.minecraft.world.item.ItemStack itemstack = CraftItemStack.asNMSCopy(item); + + float yMod = EntityType.ITEM.getHeight() / 2.0F; + double x = (pos.getX() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D); + double y = (pos.getY() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D) - yMod; + double z = (pos.getZ() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D); + + ItemEntity itemEntity = new ItemEntity(world, x, y, z, itemstack); + itemEntity.setDefaultPickUpDelay(); + return (Item) itemEntity.getBukkitEntity(); + } } diff --git a/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java b/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java index d451be8..aece021 100644 --- a/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java +++ b/V1_19_R3/src/main/java/su/nightexpress/excellentenchants/nms/v1_19_R3/V1_19_R3.java @@ -3,9 +3,13 @@ package su.nightexpress.excellentenchants.nms.v1_19_R3; import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.projectile.FishingHook; import net.minecraft.world.item.SpawnEggItem; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -13,12 +17,14 @@ import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_19_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_19_R3.block.CraftBlock; import org.bukkit.craftbukkit.v1_19_R3.entity.CraftFishHook; import org.bukkit.craftbukkit.v1_19_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_19_R3.event.CraftEventFactory; import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack; import org.bukkit.entity.FishHook; +import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -91,4 +97,20 @@ public class V1_19_R3 implements EnchantNMS { } return blocks; } + + @NotNull + public Item popResource(@NotNull Block block, @NotNull ItemStack item) { + Level world = ((CraftWorld)block.getWorld()).getHandle(); + BlockPos pos = ((CraftBlock)block).getPosition(); + net.minecraft.world.item.ItemStack itemstack = CraftItemStack.asNMSCopy(item); + + float yMod = EntityType.ITEM.getHeight() / 2.0F; + double x = (pos.getX() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D); + double y = (pos.getY() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D) - yMod; + double z = (pos.getZ() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D); + + ItemEntity itemEntity = new ItemEntity(world, x, y, z, itemstack); + itemEntity.setDefaultPickUpDelay(); + return (Item) itemEntity.getBukkitEntity(); + } } diff --git a/V1_20_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_20_R1/V1_20_R1.java b/V1_20_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_20_R1/V1_20_R1.java index 4a2dfe4..ee8f237 100644 --- a/V1_20_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_20_R1/V1_20_R1.java +++ b/V1_20_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_20_R1/V1_20_R1.java @@ -3,9 +3,13 @@ package su.nightexpress.excellentenchants.nms.v1_20_R1; import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.projectile.FishingHook; import net.minecraft.world.item.SpawnEggItem; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; @@ -13,12 +17,14 @@ import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_20_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_20_R1.entity.CraftFishHook; import org.bukkit.craftbukkit.v1_20_R1.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_20_R1.event.CraftEventFactory; import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack; import org.bukkit.entity.FishHook; +import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -91,4 +97,50 @@ public class V1_20_R1 implements EnchantNMS { } return blocks; } + + @NotNull + public Item popResource(@NotNull Block block, @NotNull ItemStack item) { + Level world = ((CraftWorld)block.getWorld()).getHandle(); + BlockPos pos = ((CraftBlock)block).getPosition(); + net.minecraft.world.item.ItemStack itemstack = CraftItemStack.asNMSCopy(item); + + float yMod = EntityType.ITEM.getHeight() / 2.0F; + double x = (pos.getX() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D); + double y = (pos.getY() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D) - yMod; + double z = (pos.getZ() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D); + + ItemEntity itemEntity = new ItemEntity(world, x, y, z, itemstack); + itemEntity.setDefaultPickUpDelay(); + return (Item) itemEntity.getBukkitEntity(); + } + + /*public static void popResourceFromFace(Level world, BlockPos blockposition, Direction enumdirection, ItemStack itemstack) { + int i = enumdirection.getStepX(); + int j = enumdirection.getStepY(); + int k = enumdirection.getStepZ(); + float f = EntityType.ITEM.getWidth() / 2.0F; + float f1 = EntityType.ITEM.getHeight() / 2.0F; + double d0 = (double)((float)blockposition.getX() + 0.5F) + (i == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double)((float)i * (0.5F + f))); + double d1 = (double)((float)blockposition.getY() + 0.5F) + (j == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double)((float)j * (0.5F + f1))) - (double)f1; + double d2 = (double)((float)blockposition.getZ() + 0.5F) + (k == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double)((float)k * (0.5F + f))); + double d3 = i == 0 ? Mth.nextDouble(world.random, -0.1D, 0.1D) : (double)i * 0.1D; + double d4 = j == 0 ? Mth.nextDouble(world.random, 0.0D, 0.1D) : (double)j * 0.1D + 0.1D; + double d5 = k == 0 ? Mth.nextDouble(world.random, -0.1D, 0.1D) : (double)k * 0.1D; + popResource(world, () -> { + return new ItemEntity(world, d0, d1, d2, itemstack, d3, d4, d5); + }, itemstack); + } + + private static void popResource(Level world, Supplier supplier, ItemStack itemstack) { + if (!world.isClientSide && !itemstack.isEmpty() && world.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { + ItemEntity entityitem = (ItemEntity)supplier.get(); + entityitem.setDefaultPickUpDelay(); + if (world.captureDrops != null) { + world.captureDrops.add(entityitem); + } else { + world.addFreshEntity(entityitem); + } + } + + }*/ } From 53b81df34b51e3e4f511ece394791ed0672dc47e Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 4 Sep 2023 16:41:17 +0500 Subject: [PATCH 53/69] v3.5.6 --- Core/pom.xml | 12 ++++++------ NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 ++-- V1_18_R2/pom.xml | 4 ++-- V1_19_R3/pom.xml | 4 ++-- V1_20_R1/pom.xml | 4 ++-- pom.xml | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 27dffd8..85b949f 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.5 + 3.5.6 4.0.0 @@ -81,27 +81,27 @@ su.nightexpress.excellentenchants NMS - 3.5.5 + 3.5.6 su.nightexpress.excellentenchants V1_17_R1 - 3.5.5 + 3.5.6 su.nightexpress.excellentenchants V1_18_R2 - 3.5.5 + 3.5.6 su.nightexpress.excellentenchants V1_19_R3 - 3.5.5 + 3.5.6 su.nightexpress.excellentenchants V1_20_R1 - 3.5.5 + 3.5.6 diff --git a/NMS/pom.xml b/NMS/pom.xml index 2c0c747..f54595a 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.5 + 3.5.6 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 3b104fa..75bb700 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.5 + 3.5.6 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.5 + 3.5.6 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 9c59476..cbdb8ee 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.5 + 3.5.6 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.5 + 3.5.6 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 29c4c8f..5069b45 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.5 + 3.5.6 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.5 + 3.5.6 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index b2b86c8..92dc538 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.5 + 3.5.6 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.5 + 3.5.6 diff --git a/pom.xml b/pom.xml index 7af8f5f..48acfd6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.5.5 + 3.5.6 Core NMS From f5109635ff04f9e9b71d288f73009904cba64f96 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 6 Sep 2023 15:48:50 +0500 Subject: [PATCH 54/69] Fix for villager books --- .../excellentenchants/config/Config.java | 3 +++ .../enchantment/util/EnchantUtils.java | 21 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) 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 7e0aa92..4fe365c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -117,6 +117,9 @@ public class Config { "When enabled, passive enchantments (permanent potion effects, regeneration, etc.) will be applied to mobs as well.", "Disable this if you're experiencing performance issues."); + public static final JOption ENCHANTMENTS_SINGLE_ENCHANT_IN_VILLAGER_BOOKS = JOption.create("Enchantments.Single_Enchant_In_Villager_Books", true, + "Sets whether or not enchanted books in villager trades will have only 1 enchant, vanilla or custom one."); + private static final JOption> OBTAIN_SETTINGS = new JOption>("Enchantments.Obtaining", (cfg, path, def) -> Stream.of(ObtainType.values()).collect(Collectors.toMap(k -> k, v -> ObtainSettings.read(cfg, path + "." + v.getPathName()))), () -> Stream.of(ObtainType.values()).collect(Collectors.toMap(k -> k, v -> new ObtainSettings(true, 4, 80D, 0, 2))), 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 index a307e64..c781005 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -106,12 +106,23 @@ public class EnchantUtils { public static boolean populate(@NotNull ItemStack item, @NotNull ObtainType obtainType, @Nullable World world) { AtomicBoolean status = new AtomicBoolean(false); - getPopulationCandidates(item, obtainType, world).forEach((enchantment, level) -> { + var population = getPopulationCandidates(item, obtainType, world); + + if (obtainType == ObtainType.VILLAGER && item.getType() == Material.ENCHANTED_BOOK) { + if (Config.ENCHANTMENTS_SINGLE_ENCHANT_IN_VILLAGER_BOOKS.get() && !population.isEmpty()) { + getAll(item).keySet().forEach(enchantment -> remove(item, enchantment)); + } + } + + population.forEach((enchantment, level) -> { if (add(item, enchantment, level, false)) { status.set(true); } }); - updateDisplay(item); + + if (status.get()) { + updateDisplay(item); + } return status.get(); } @@ -188,12 +199,6 @@ public class EnchantUtils { enchRoll--; } - if (!enchantsToAdd.isEmpty()) { - if (obtainType == ObtainType.VILLAGER && item.getType() == Material.ENCHANTED_BOOK && enchRoll == 1) { - getAll(item).keySet().forEach(enchantment -> remove(item, enchantment)); - } - } - return enchantsToAdd; } From 0914f8433b02c1cd061fa1ebf977ce1614bb0b33 Mon Sep 17 00:00:00 2001 From: kFor Date: Fri, 15 Sep 2023 20:15:55 +0300 Subject: [PATCH 55/69] fix tunnel enchantment --- .../enchantment/impl/tool/EnchantTunnel.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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 9f1a731..dc540a7 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 @@ -19,6 +19,7 @@ import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook; import java.util.HashSet; +import java.util.List; import java.util.Set; public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant { @@ -73,8 +74,14 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant if (block.getType().isInteractable() && !INTERACTABLE_BLOCKS.contains(block.getType())) return false; if (block.getDrops(item).isEmpty()) return false; - BlockFace dir = EntityUtil.getDirection(player); - boolean isY = dir != null && block.getRelative(dir.getOppositeFace()).isEmpty(); + + final List lastTwoTargetBlocks = player.getLastTwoTargetBlocks(null, 10); + if (lastTwoTargetBlocks.size() != 2 || !lastTwoTargetBlocks.get(1).getType().isOccluding()) { + return false; + } + final Block targetBlock = lastTwoTargetBlocks.get(1); + final Block adjacentBlock = lastTwoTargetBlocks.get(0); + final BlockFace dir = targetBlock.getFace(adjacentBlock); boolean isZ = dir == BlockFace.EAST || dir == BlockFace.WEST; // Mine + shape if Tunnel I, 3x3 if Tunnel II @@ -92,11 +99,10 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant int zAdd = MINING_COORD_OFFSETS[i][1]; Block blockAdd; - if (isY) { - blockAdd = block.getLocation().clone().add(isZ ? 0 : xAdd, zAdd, isZ ? xAdd : 0).getBlock(); - } - else { + if (dir == BlockFace.UP || dir == BlockFace.DOWN) { blockAdd = block.getLocation().clone().add(xAdd, 0, zAdd).getBlock(); + } else { + blockAdd = block.getLocation().clone().add(isZ ? 0 : xAdd, zAdd, isZ ? xAdd : 0).getBlock(); } // Skip blocks that should not be mined From fe8108ca623f024563fec13974f1ba287b06bfe8 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 21 Sep 2023 15:30:32 +0500 Subject: [PATCH 56/69] v3.5.7 --- Core/pom.xml | 12 ++++++------ .../enchantment/impl/tool/EnchantSilkChest.java | 4 +--- .../enchantment/impl/tool/EnchantSmelter.java | 9 ++++++--- .../enchantment/util/EnchantUtils.java | 2 +- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 ++-- V1_18_R2/pom.xml | 4 ++-- V1_19_R3/pom.xml | 4 ++-- V1_20_R1/pom.xml | 4 ++-- .../excellentenchants/nms/v1_20_R1/V1_20_R1.java | 3 ++- pom.xml | 2 +- 11 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 85b949f..2d2e185 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.6 + 3.5.7 4.0.0 @@ -81,27 +81,27 @@ su.nightexpress.excellentenchants NMS - 3.5.6 + 3.5.7 su.nightexpress.excellentenchants V1_17_R1 - 3.5.6 + 3.5.7 su.nightexpress.excellentenchants V1_18_R2 - 3.5.6 + 3.5.7 su.nightexpress.excellentenchants V1_19_R3 - 3.5.6 + 3.5.7 su.nightexpress.excellentenchants V1_20_R1 - 3.5.6 + 3.5.7 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 434afc0..f00a733 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 @@ -141,18 +141,16 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha // Добавляем в сундук обратно предметы из дроп листа, кроме самого сундука. event.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType() && drop.getItemStack().getAmount() == 1); chest.getBlockInventory().addItem(event.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0])); + event.getItems().clear(); if (chest.getBlockInventory().isEmpty()) { EnchantUtils.popResource(event, new ItemStack(chest.getType())); return false; } - // Добавляем кастомный сундук в кастомный дроп лист. EnchantUtils.popResource(event, this.getSilkChest(chest)); - // Очищаем инвентарь сундука и дефолтный дроп лист. chest.getBlockInventory().clear(); - event.getItems().clear(); return true; } 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 34aa611..4572fed 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 @@ -89,8 +89,7 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr @Override public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { - // TODO Use furnace recipes - // TODO Re-add smelted items instead of setType + // TODO Use furnace recipes & Re-add smelted items instead of setType if (event.getBlockState() instanceof Container) return false; if (!this.isAvailableToUse(player)) return false; @@ -99,7 +98,11 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr event.getItems().forEach(drop -> { Material material = this.smeltingTable.get(drop.getItemStack().getType()); - if (material != null) drop.getItemStack().setType(material); + if (material != null) { + ItemStack stack = drop.getItemStack(); + stack.setType(material); + drop.setItemStack(stack); + } }); Block block = event.getBlockState().getBlock(); 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 index c781005..c039999 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -347,7 +347,7 @@ public class EnchantUtils { public static void consumeCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int level) { int has = getCharges(item, enchant); int use = enchant.getChargesConsumeAmount(level); - setCharges(item, enchant, level,has - use); + setCharges(item, enchant, level,has < use ? 0 : has - use); } /*public static void restoreCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { diff --git a/NMS/pom.xml b/NMS/pom.xml index f54595a..1d7f568 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.6 + 3.5.7 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 75bb700..e8ecc1c 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.6 + 3.5.7 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.6 + 3.5.7 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index cbdb8ee..81b4e3c 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.6 + 3.5.7 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.6 + 3.5.7 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 5069b45..83f488a 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.6 + 3.5.7 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.6 + 3.5.7 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index 92dc538..d2cec44 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.6 + 3.5.7 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.6 + 3.5.7 diff --git a/V1_20_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_20_R1/V1_20_R1.java b/V1_20_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_20_R1/V1_20_R1.java index ee8f237..a8acb5c 100644 --- a/V1_20_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_20_R1/V1_20_R1.java +++ b/V1_20_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_20_R1/V1_20_R1.java @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.nms.v1_20_R1; import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -40,7 +41,7 @@ public class V1_20_R1 implements EnchantNMS { @Override public void sendAttackPacket(@NotNull Player player, int id) { CraftPlayer craftPlayer = (CraftPlayer) player; - Entity entity = craftPlayer.getHandle(); + ServerPlayer entity = craftPlayer.getHandle(); ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id); craftPlayer.getHandle().connection.send(packet); } diff --git a/pom.xml b/pom.xml index 48acfd6..1c9ab8d 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.5.6 + 3.5.7 Core NMS From 1087e345a0fd896f1f470b123b65771612c78f77 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 28 Sep 2023 18:45:22 +0500 Subject: [PATCH 57/69] v3.5.8 --- .gitignore | 8 +- Core/pom.xml | 29 ++--- .../excellentenchants/ExcellentEnchants.java | 2 + .../api/enchantment/meta/Arrowed.java | 4 +- .../excellentenchants/config/Lang.java | 2 + .../impl/armor/DarknessCloakEnchant.java | 4 +- .../impl/armor/EnchantFlameWalker.java | 8 +- .../impl/armor/EnchantIceShield.java | 6 +- .../impl/armor/EnchantRegrowth.java | 4 +- .../impl/bow/DarknessArrowsEnchant.java | 4 +- .../impl/bow/EnchantConfusingArrows.java | 8 +- .../impl/bow/EnchantDragonfireArrows.java | 4 +- .../impl/bow/EnchantElectrifiedArrows.java | 8 +- .../impl/bow/EnchantExplosiveArrows.java | 4 +- .../enchantment/impl/bow/EnchantHover.java | 8 +- .../impl/bow/EnchantPoisonedArrows.java | 8 +- .../impl/bow/EnchantWitheredArrows.java | 8 +- .../enchantment/impl/bow/FlareEnchant.java | 4 +- .../impl/fishing/CurseOfDrownedEnchant.java | 8 +- .../impl/meta/ArrowImplementation.java | 18 +-- .../impl/tool/EnchantDivineTouch.java | 4 +- .../impl/tool/EnchantReplanter.java | 4 +- .../enchantment/impl/tool/EnchantSmelter.java | 11 +- .../impl/tool/EnchantTreasures.java | 7 +- .../impl/weapon/EnchantBaneOfNetherspawn.java | 4 +- .../impl/weapon/EnchantBlindness.java | 4 +- .../impl/weapon/EnchantConfusion.java | 6 +- .../enchantment/impl/weapon/EnchantCure.java | 4 +- .../impl/weapon/EnchantCutter.java | 9 +- .../impl/weapon/EnchantDecapitator.java | 5 +- .../impl/weapon/EnchantDoubleStrike.java | 8 +- .../impl/weapon/EnchantExhaust.java | 5 +- .../impl/weapon/EnchantIceAspect.java | 5 +- .../impl/weapon/EnchantParalyze.java | 4 +- .../enchantment/impl/weapon/EnchantRage.java | 4 +- .../impl/weapon/EnchantRocket.java | 4 +- .../impl/weapon/EnchantSurprise.java | 8 +- .../impl/weapon/EnchantVampire.java | 4 +- .../enchantment/impl/weapon/EnchantVenom.java | 4 +- .../impl/weapon/EnchantVillageDefender.java | 4 +- .../impl/weapon/EnchantWither.java | 4 +- .../listener/EnchantAnvilListener.java | 4 +- .../enchantment/task/ArrowTrailsTask.java | 6 +- .../util/EnchantDropContainer.java | 30 ----- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 +- V1_18_R2/pom.xml | 4 +- V1_19_R3/pom.xml | 4 +- V1_20_R1/pom.xml | 8 +- V1_20_R2/pom.xml | 71 +++++++++++ .../excellentenchants/nms/V1_20_R2.java | 116 ++++++++++++++++++ pom.xml | 5 +- 52 files changed, 328 insertions(+), 187 deletions(-) delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantDropContainer.java create mode 100644 V1_20_R2/pom.xml create mode 100644 V1_20_R2/src/main/java/su/nightexpress/excellentenchants/nms/V1_20_R2.java diff --git a/.gitignore b/.gitignore index b413499..94be98e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,11 +9,9 @@ /V1_17_R1/pom.xml.versionsBackup /V1_18_R2/target/ /V1_18_R2/pom.xml.versionsBackup -/V1_19_R1/target/ -/V1_19_R1/pom.xml.versionsBackup -/V1_19_R2/target/ -/V1_19_R2/pom.xml.versionsBackup /V1_19_R3/target/ /V1_19_R3/pom.xml.versionsBackup /V1_20_R1/target/ -/V1_20_R1/pom.xml.versionsBackup \ No newline at end of file +/V1_20_R1/pom.xml.versionsBackup +/V1_20_R2/target/ +/V1_20_R2/pom.xml.versionsBackup \ No newline at end of file diff --git a/Core/pom.xml b/Core/pom.xml index 2d2e185..ec12f26 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.7 + 3.5.8 4.0.0 @@ -73,35 +73,35 @@ 2.11.2 provided - - su.nexmedia.playerblocktracker - PlayerBlockTracker - 1.0.1 - su.nightexpress.excellentenchants NMS - 3.5.7 + 3.5.8 su.nightexpress.excellentenchants V1_17_R1 - 3.5.7 + 3.5.8 su.nightexpress.excellentenchants V1_18_R2 - 3.5.7 + 3.5.8 su.nightexpress.excellentenchants V1_19_R3 - 3.5.7 + 3.5.8 su.nightexpress.excellentenchants V1_20_R1 - 3.5.7 + 3.5.8 + + + su.nightexpress.excellentenchants + V1_20_R2 + 3.5.8 @@ -141,15 +141,8 @@ su.nightexpress.excellentenchants* - su.nexmedia.playerblocktracker:* - - - su.nexmedia.playerblocktracker. - su.nightexpress.excellentenchants.playerblocktracker. - - diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 9e7b424..34c0b84 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -19,6 +19,7 @@ import su.nightexpress.excellentenchants.hook.HookId; import su.nightexpress.excellentenchants.hook.impl.PlaceholderHook; import su.nightexpress.excellentenchants.hook.impl.ProtocolHook; import su.nightexpress.excellentenchants.nms.EnchantNMS; +import su.nightexpress.excellentenchants.nms.V1_20_R2; import su.nightexpress.excellentenchants.nms.v1_17_R1.V1_17_R1; import su.nightexpress.excellentenchants.nms.v1_18_R2.V1_18_R2; import su.nightexpress.excellentenchants.nms.v1_19_R3.V1_19_R3; @@ -87,6 +88,7 @@ public class ExcellentEnchants extends NexPlugin { case V1_18_R2 -> new V1_18_R2(); case V1_19_R3 -> new V1_19_R3(); case V1_20_R1 -> new V1_20_R1(); + case V1_20_R2 -> new V1_20_R2(); default -> null; }; } 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 155e66b..d9ff04b 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 @@ -2,7 +2,7 @@ package su.nightexpress.excellentenchants.api.enchantment.meta; import org.bukkit.entity.Projectile; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.particle.SimpleParticle; +import su.nexmedia.engine.utils.values.UniParticle; import java.util.Optional; @@ -11,7 +11,7 @@ public interface Arrowed { @NotNull Arrowed getArrowImplementation(); @NotNull - default Optional getTrailParticle() { + default Optional getTrailParticle() { return this.getArrowImplementation().getTrailParticle(); } 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 54fd362..301e437 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java @@ -4,6 +4,8 @@ import su.nexmedia.engine.api.lang.LangKey; import su.nexmedia.engine.lang.EngineLang; import su.nightexpress.excellentenchants.Placeholders; +import static su.nexmedia.engine.utils.Colors.*; + public class Lang extends EngineLang { public static final LangKey COMMAND_LIST_DESC = LangKey.of("Command.List.Desc", "List of all custom enchantments."); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java index c2600bf..c879bad 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java @@ -7,7 +7,7 @@ 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.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -73,7 +73,7 @@ public class DarknessCloakEnchant extends ExcellentEnchant implements Chanced, P if (!this.addEffect(damager, level)) return false; if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.ASH).play(damager.getEyeLocation(), 0.75, 0.1, 30); + UniParticle.of(Particle.ASH).play(damager.getEyeLocation(), 0.75, 0.1, 30); } return true; 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 95ccb28..2012b33 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 @@ -2,7 +2,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.armor; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; @@ -20,10 +19,10 @@ import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.Version; -import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.api.server.AbstractTask; import su.nexmedia.engine.utils.Pair; import su.nexmedia.engine.utils.random.Rnd; +import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.Cleanable; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; @@ -188,10 +187,7 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { } block.setType(Material.LAVA); - - SimpleParticle.of(Particle.BLOCK_CRACK, Material.MAGMA_BLOCK.createBlockData()) - .play(block.getLocation(), 0.5, 0.7, 0.5, 0.03, 30); - + UniParticle.blockCrack(Material.MAGMA_BLOCK).play(block.getLocation(), 0.5, 0.7, 0.5, 0.03, 30); return true; } else if (Version.isAtLeast(Version.V1_19_R3)) { 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 5735c4b..ec4bca6 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 @@ -1,14 +1,13 @@ package su.nightexpress.excellentenchants.enchantment.impl.armor; import org.bukkit.Material; -import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; 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.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -74,8 +73,7 @@ public class EnchantIceShield extends ExcellentEnchant implements Chanced, Potio damager.setFreezeTicks(damager.getMaxFreezeTicks()); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.BLOCK_CRACK, Material.ICE.createBlockData()) - .play(damager.getEyeLocation(), 0.25, 0.1, 20); + UniParticle.blockCrack(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/EnchantRegrowth.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantRegrowth.java index dcc3332..c0c17e2 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 @@ -7,9 +7,9 @@ import org.bukkit.entity.LivingEntity; 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.EntityUtil; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.Cleanable; @@ -123,7 +123,7 @@ public class EnchantRegrowth extends ExcellentEnchant implements Chanced, Passiv entity.setHealth(amount); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.HEART).play(entity.getEyeLocation(), 0.25, 0.1, 5); + UniParticle.of(Particle.HEART).play(entity.getEyeLocation(), 0.25, 0.1, 5); } return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java index 9570c2f..9910666 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java @@ -12,7 +12,7 @@ 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.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; @@ -44,7 +44,7 @@ public class DarknessArrowsEnchant extends ExcellentEnchant implements Chanced, @Override public void loadSettings() { super.loadSettings(); - this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.ASH)); + this.arrowImplementation = ArrowImplementation.create(this, UniParticle.of(Particle.ASH)); this.chanceImplementation = ChanceImplementation.create(this, "25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5.0"); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.DARKNESS, false, 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 ef4fd4a..0480ecc 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 @@ -12,18 +12,18 @@ 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.nexmedia.engine.utils.values.UniParticle; 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.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.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.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { @@ -44,7 +44,7 @@ public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, @Override public void loadSettings() { super.loadSettings(); - this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.SPELL_MOB)); + this.arrowImplementation = ArrowImplementation.create(this, UniParticle.of(Particle.SPELL_MOB)); this.chanceImplementation = ChanceImplementation.create(this, "20.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5.0"); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.CONFUSION, false, 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 c21f35d..1ea26f0 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 @@ -19,9 +19,9 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.projectiles.ProjectileSource; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; @@ -57,7 +57,7 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced @Override public void loadSettings() { super.loadSettings(); - this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.DRAGON_BREATH)); + this.arrowImplementation = ArrowImplementation.create(this, UniParticle.of(Particle.DRAGON_BREATH)); this.chanceImplementation = ChanceImplementation.create(this, "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); this.fireDuration = EnchantScaler.read(this, "Settings.Fire.Duration", 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 274541a..292f32d 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 @@ -16,8 +16,8 @@ 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.api.particle.SimpleParticle; import su.nexmedia.engine.utils.LocationUtil; +import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; @@ -48,7 +48,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance @Override public void loadSettings() { super.loadSettings(); - this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.FIREWORKS_SPARK)); + this.arrowImplementation = ArrowImplementation.create(this, UniParticle.of(Particle.FIREWORKS_SPARK)); this.chanceImplementation = ChanceImplementation.create(this, "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); } @@ -87,8 +87,8 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance block.getWorld().strikeLightning(block.getLocation()).setMetadata(META_NO_ITEM_DAMAGE, new FixedMetadataValue(plugin, true)); if (this.hasVisualEffects()) { Location center = LocationUtil.getCenter(block.getLocation()); - SimpleParticle.of(Particle.BLOCK_CRACK, block.getType().createBlockData()).play(center, 1, 0.05, 120); - SimpleParticle.of(Particle.FIREWORKS_SPARK).play(center, 1, 0.05, 120); + UniParticle.blockCrack(block.getType()).play(center, 1, 0.05, 120); + UniParticle.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/EnchantExplosiveArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantExplosiveArrows.java index e61bd74..29bfbf4 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 @@ -14,8 +14,8 @@ 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.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; @@ -53,7 +53,7 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, @Override public void loadSettings() { super.loadSettings(); - this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.SMOKE_NORMAL)); + this.arrowImplementation = ArrowImplementation.create(this, UniParticle.of(Particle.SMOKE_NORMAL)); this.chanceImplementation = ChanceImplementation.create(this, "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); this.explosionFireSpread = JOption.create("Settings.Explosion.Fire_Spread", true, 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 08f8683..f2dba34 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 @@ -12,18 +12,18 @@ 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.nexmedia.engine.utils.values.UniParticle; 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.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.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.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { @@ -44,7 +44,7 @@ public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, @Override public void loadSettings() { super.loadSettings(); - this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.BUBBLE_POP)); + this.arrowImplementation = ArrowImplementation.create(this, UniParticle.of(Particle.BUBBLE_POP)); this.chanceImplementation = ChanceImplementation.create(this, "10.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.LEVITATION, false, 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 52b1822..430634e 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 @@ -12,18 +12,18 @@ 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.nexmedia.engine.utils.values.UniParticle; 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.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.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.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { @@ -44,7 +44,7 @@ public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, @Override public void loadSettings() { super.loadSettings(); - this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.SLIME)); + this.arrowImplementation = ArrowImplementation.create(this, UniParticle.of(Particle.SLIME)); this.chanceImplementation = ChanceImplementation.create(this, "25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5"); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.POISON, false, 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 70472fc..65de8eb 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 @@ -12,18 +12,18 @@ 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.nexmedia.engine.utils.values.UniParticle; 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.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.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.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { @@ -44,7 +44,7 @@ public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, @Override public void loadSettings() { super.loadSettings(); - this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.SPELL_WITCH)); + this.arrowImplementation = ArrowImplementation.create(this, UniParticle.of(Particle.SPELL_WITCH)); this.chanceImplementation = ChanceImplementation.create(this, "15.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5.0"); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.WITHER, false, diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java index ec6bc95..3d110a6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java @@ -17,7 +17,7 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.particle.SimpleParticle; +import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; @@ -47,7 +47,7 @@ public class FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed, public void loadSettings() { super.loadSettings(); this.chanceImplementation = ChanceImplementation.create(this, "100.0"); - this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.FIREWORKS_SPARK)); + this.arrowImplementation = ArrowImplementation.create(this, UniParticle.of(Particle.FIREWORKS_SPARK)); } @NotNull diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java index cf526ee..5486825 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java @@ -8,8 +8,8 @@ import org.bukkit.entity.FishHook; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.particle.SimpleParticle; -import su.nexmedia.engine.utils.PlayerUtil; +import su.nexmedia.engine.utils.values.UniParticle; +import su.nexmedia.engine.utils.values.UniSound; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -64,8 +64,8 @@ public class CurseOfDrownedEnchant extends ExcellentEnchant implements FishingEn event.setCancelled(true); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.WATER_SPLASH).play(hook.getLocation(), 0.5, 0.1, 50); - PlayerUtil.sound(event.getPlayer(), Sound.ENTITY_DROWNED_AMBIENT); + UniParticle.of(Particle.WATER_SPLASH).play(hook.getLocation(), 0.5, 0.1, 50); + UniSound.of(Sound.ENTITY_DROWNED_AMBIENT).play(event.getPlayer()); } return true; } 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 dbdca1b..c4aaf56 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,11 +7,11 @@ 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.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; -import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.task.ArrowTrailsTask; import java.util.Optional; @@ -21,9 +21,9 @@ public final class ArrowImplementation implements Arrowed { private final ExcellentEnchant enchant; private final NamespacedKey projectileKey; - private final SimpleParticle trailParticle; + private final UniParticle trailParticle; - private ArrowImplementation(@NotNull ExcellentEnchant enchant, @Nullable SimpleParticle trailParticle) { + private ArrowImplementation(@NotNull ExcellentEnchant enchant, @Nullable UniParticle trailParticle) { this.enchant = enchant; this.projectileKey = new NamespacedKey(ExcellentEnchantsAPI.PLUGIN, "arrow.enchant_id"); this.trailParticle = trailParticle; @@ -31,15 +31,15 @@ public final class ArrowImplementation implements Arrowed { @NotNull public static ArrowImplementation create(@NotNull ExcellentEnchant enchant) { - return create(enchant, SimpleParticle.of(Particle.REDSTONE)); + return create(enchant, UniParticle.of(Particle.REDSTONE)); } @NotNull - public static ArrowImplementation create(@NotNull ExcellentEnchant enchant, @NotNull SimpleParticle particle) { + public static ArrowImplementation create(@NotNull ExcellentEnchant enchant, @NotNull UniParticle particle) { JYML cfg = enchant.getConfig(); - SimpleParticle effect = new JOption<>("Settings.Arrow.Trail_Effect", - (cfg1, path, def) -> SimpleParticle.read(cfg1, path), + UniParticle effect = new JOption<>("Settings.Arrow.Trail_Effect", + (cfg1, path, def) -> UniParticle.read(cfg1, path), particle, "Sets particle effect for the arrow trail of this enchantment." ).setWriter((cfg1, path, particle1) -> particle1.write(cfg1, path)).read(cfg); @@ -65,7 +65,7 @@ public final class ArrowImplementation implements Arrowed { @NotNull @Override - public Optional getTrailParticle() { + public Optional getTrailParticle() { return trailParticle == null ? Optional.empty() : Optional.of(trailParticle); } 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 316142e..d9871c2 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 @@ -19,10 +19,10 @@ 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.LocationUtil; import su.nexmedia.engine.utils.PDCUtil; +import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -112,7 +112,7 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo if (this.hasVisualEffects()) { Location location = LocationUtil.getCenter(block.getLocation()); - SimpleParticle.of(Particle.VILLAGER_HAPPY).play(location, 0.3, 0.15, 30); + UniParticle.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/EnchantReplanter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantReplanter.java index 1295971..54cf16b 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 @@ -15,7 +15,7 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; -import su.nexmedia.engine.utils.PlayerUtil; +import su.nexmedia.engine.utils.values.UniSound; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; @@ -147,7 +147,7 @@ public class EnchantReplanter extends ExcellentEnchant implements Chanced, Inter if (seed == Material.NETHER_WART && blockGround.getType() == Material.SOUL_SAND || seed != Material.NETHER_WART && blockGround.getType() == Material.FARMLAND) { if (this.takeSeeds(player, seed)) { - PlayerUtil.sound(player, seed == Material.NETHER_WART ? Sound.ITEM_NETHER_WART_PLANT : Sound.ITEM_CROP_PLANT); + UniSound.of(seed == Material.NETHER_WART ? Sound.ITEM_NETHER_WART_PLANT : Sound.ITEM_CROP_PLANT).play(player); plugin.getEnchantNMS().sendAttackPacket(player, 0); blockPlant.setType(this.fineSeedsToBlock(seed)); break; 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 4572fed..1f771cb 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 @@ -13,8 +13,9 @@ 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.api.particle.SimpleParticle; import su.nexmedia.engine.utils.LocationUtil; +import su.nexmedia.engine.utils.values.UniParticle; +import su.nexmedia.engine.utils.values.UniSound; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -30,7 +31,7 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr public static final String ID = "smelter"; - private Sound sound; + private UniSound sound; private Map smeltingTable; private ChanceImplementation chanceImplementation; @@ -51,7 +52,7 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr this.chanceImplementation = ChanceImplementation.create(this, "25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 10"); - this.sound = JOption.create("Settings.Sound", Sound.class, Sound.BLOCK_LAVA_EXTINGUISH, + this.sound = JOption.create("Settings.Sound",UniSound.of(Sound.BLOCK_LAVA_EXTINGUISH), "Sound to play on smelting.", "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html").read(cfg); @@ -108,8 +109,8 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr Block block = event.getBlockState().getBlock(); if (this.hasVisualEffects()) { Location location = LocationUtil.getCenter(block.getLocation(), true); - LocationUtil.sound(location, this.sound); - SimpleParticle.of(Particle.FLAME).play(location, 0.25, 0.05, 20); + UniParticle.of(Particle.FLAME).play(location, 0.25, 0.05, 20); + this.sound.play(location); } return true; } 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 4ad2c34..6de1f92 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 @@ -10,8 +10,8 @@ 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.utils.blocktracker.PlayerBlockTracker; import su.nexmedia.engine.utils.random.Rnd; -import su.nexmedia.playerblocktracker.PlayerBlockTracker; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.Cleanable; @@ -30,7 +30,7 @@ import java.util.function.Predicate; public class EnchantTreasures extends ExcellentEnchant implements Chanced, BlockBreakEnchant, BlockDropEnchant, Cleanable { public static final String ID = "treasures"; - private static final String META = "wasted"; + @Deprecated private static final String META = "wasted"; private Map> treasures; private ChanceImplementation chanceImplementation; @@ -43,7 +43,7 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block this.getDefaults().setLevelMax(5); this.getDefaults().setTier(0.1); - PlayerBlockTracker.initialize(plugin); + PlayerBlockTracker.initialize(); PlayerBlockTracker.BLOCK_FILTERS.add(this.blockTracker = (block) -> { return this.treasures.containsKey(block.getType()); }); @@ -106,7 +106,6 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block @Override public void clear() { PlayerBlockTracker.BLOCK_FILTERS.remove(this.blockTracker); - PlayerBlockTracker.shutdown(); } @NotNull 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 9e13639..a9f742d 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,8 +8,8 @@ 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.NumberUtil; +import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; @@ -73,7 +73,7 @@ public class EnchantBaneOfNetherspawn extends ExcellentEnchant implements Combat double damageAdd = this.getDamageModifier(level); event.setDamage(this.damageModifier ? damageEvent * damageAdd : damageEvent + damageAdd); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.SMOKE_NORMAL).play(victim.getEyeLocation(), 0.25, 0.1, 30); + UniParticle.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 78e7f7a..3342488 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,7 +7,7 @@ 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.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -67,7 +67,7 @@ public class EnchantBlindness extends ExcellentEnchant implements Chanced, Potio if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.SMOKE_NORMAL).play(victim.getEyeLocation(), 0.25, 0.1, 30); + UniParticle.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 a534885..5b8acec 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 @@ -1,14 +1,13 @@ 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; 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.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -68,8 +67,7 @@ public class EnchantConfusion extends ExcellentEnchant implements Chanced, Potio if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.ITEM_CRACK, new ItemStack(Material.ROTTEN_FLESH)) - .play(victim.getEyeLocation(), 0.25, 0.1, 30); + UniParticle.itemCrack(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 78ecc8a..55e1d9e 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,7 +7,7 @@ import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.particle.SimpleParticle; +import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -62,7 +62,7 @@ public class EnchantCure extends ExcellentEnchant implements Chanced, CombatEnch event.setCancelled(true); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.CLOUD).play(victim.getEyeLocation(), 0.25, 0.1, 30); + UniParticle.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 e98b170..bf87080 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 @@ -1,6 +1,5 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; -import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Item; @@ -13,10 +12,10 @@ import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; -import su.nexmedia.engine.api.particle.SimpleParticle; -import su.nexmedia.engine.utils.LocationUtil; import su.nexmedia.engine.utils.NumberUtil; import su.nexmedia.engine.utils.random.Rnd; +import su.nexmedia.engine.utils.values.UniParticle; +import su.nexmedia.engine.utils.values.UniSound; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -110,8 +109,8 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn drop.getVelocity().multiply(3D); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.ITEM_CRACK, itemCut).play(victim.getEyeLocation(), 0.25, 0.15, 30); - LocationUtil.sound(victim.getLocation(), Sound.ENTITY_ITEM_BREAK); + UniParticle.itemCrack(itemCut).play(victim.getEyeLocation(), 0.25, 0.15, 30); + UniSound.of(Sound.ENTITY_ITEM_BREAK).play(victim.getLocation()); } 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 387b2ab..44201c6 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 @@ -3,7 +3,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.Particle; import org.bukkit.block.Skull; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.EntityType; @@ -18,12 +17,12 @@ 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.Colorizer; import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PDCUtil; import su.nexmedia.engine.utils.StringUtil; +import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -235,7 +234,7 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea entity.getWorld().dropItemNaturally(entity.getLocation(), item); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.BLOCK_CRACK, Material.REDSTONE_BLOCK.createBlockData()).play(entity.getEyeLocation(), 0.25, 0.15, 30); + UniParticle.blockCrack(Material.REDSTONE_BLOCK).play(entity.getEyeLocation(), 0.25, 0.15, 30); } return true; } 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 546f820..7e26d9f 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,8 +7,8 @@ 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.api.particle.SimpleParticle; -import su.nexmedia.engine.utils.LocationUtil; +import su.nexmedia.engine.utils.values.UniParticle; +import su.nexmedia.engine.utils.values.UniSound; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -57,8 +57,8 @@ public class EnchantDoubleStrike extends ExcellentEnchant implements Chanced, Co event.setDamage(event.getDamage() * 2D); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.EXPLOSION_NORMAL).play(victim.getEyeLocation(), 0.25, 0.15, 15); - LocationUtil.sound(victim.getLocation(), Sound.ENTITY_GENERIC_EXPLODE); + UniParticle.of(Particle.EXPLOSION_NORMAL).play(victim.getEyeLocation(), 0.25, 0.15, 15); + UniSound.of(Sound.ENTITY_GENERIC_EXPLODE).play(victim.getLocation()); } 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 339b37c..e538f56 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,14 +1,13 @@ 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; 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.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -68,7 +67,7 @@ public class EnchantExhaust extends ExcellentEnchant implements Chanced, Potione if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.ITEM_CRACK, new ItemStack(Material.ROTTEN_FLESH)).play(victim.getEyeLocation(), 0.25, 0.1, 30); + UniParticle.itemCrack(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/EnchantIceAspect.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantIceAspect.java index 11c5ba5..df2354c 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 @@ -1,14 +1,13 @@ 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; 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.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -69,7 +68,7 @@ public class EnchantIceAspect extends ExcellentEnchant implements Chanced, Potio victim.setFreezeTicks(victim.getMaxFreezeTicks()); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.BLOCK_CRACK, Material.ICE.createBlockData()).play(victim.getEyeLocation(), 0.25, 0.15, 30); + UniParticle.blockCrack(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/EnchantParalyze.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantParalyze.java index 58d9def..fd55183 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,7 +7,7 @@ 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.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -67,7 +67,7 @@ public class EnchantParalyze extends ExcellentEnchant implements Chanced, Potion if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.CRIT_MAGIC).play(victim.getEyeLocation(), 0.25, 0.1, 30); + UniParticle.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 d42899a..312c288 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,7 +7,7 @@ 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.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -67,7 +67,7 @@ public class EnchantRage extends ExcellentEnchant implements Chanced, Potioned, if (!this.addEffect(damager, level)) return false; if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.LAVA).play(damager.getEyeLocation(), 0.25, 0.1, 30); + UniParticle.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 e8b3c8a..d928f75 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 @@ -9,8 +9,8 @@ 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.LocationUtil; import su.nexmedia.engine.utils.random.Rnd; +import su.nexmedia.engine.utils.values.UniSound; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -72,7 +72,7 @@ public class EnchantRocket extends ExcellentEnchant implements Chanced, CombatEn Firework firework = this.createRocket(victim.getLocation(), level); firework.addPassenger(victim); - LocationUtil.sound(victim.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_LAUNCH); + UniSound.of(Sound.ENTITY_FIREWORK_ROCKET_LAUNCH).play(victim.getLocation()); return true; } 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 407b000..ab646a7 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 @@ -9,17 +9,17 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.utils.random.Rnd; +import su.nexmedia.engine.utils.values.UniParticle; 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.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.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 EnchantSurprise extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { @@ -74,7 +74,7 @@ public class EnchantSurprise extends ExcellentEnchant implements Chanced, Potion if (this.hasVisualEffects()) { Color color = Color.fromRGB(Rnd.nextInt(256), Rnd.nextInt(256), Rnd.nextInt(256)); Particle.DustOptions dustOptions = new Particle.DustOptions(color, 2f); - SimpleParticle.of(Particle.REDSTONE, dustOptions).play(victim.getEyeLocation(), 0.25, 0.1, 25); + UniParticle.of(Particle.REDSTONE, dustOptions).play(victim.getEyeLocation(), 0.25, 0.1, 25); } return true; } 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 073b116..c2fb76e 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,9 +9,9 @@ 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.api.particle.SimpleParticle; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -92,7 +92,7 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE damager.setHealth(Math.min(healthMax, healthHas + healthEvent.getAmount())); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.HEART).play(damager.getEyeLocation(), 0.25, 0.15, 5); + UniParticle.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 9feda0b..2703ad1 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,7 +7,7 @@ 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.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -67,7 +67,7 @@ public class EnchantVenom extends ExcellentEnchant implements Chanced, Potioned, if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.SLIME).play(victim.getEyeLocation(), 0.25, 0.1, 30); + UniParticle.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 f7692ac..c79c404 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,8 +8,8 @@ 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.NumberUtil; +import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; @@ -72,7 +72,7 @@ public class EnchantVillageDefender extends ExcellentEnchant implements CombatEn event.setDamage(damageFinal); if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.VILLAGER_ANGRY).play(victim.getEyeLocation(), 0.25, 0.1, 30); + UniParticle.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 6460a6f..f229498 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,7 +7,7 @@ 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.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; @@ -67,7 +67,7 @@ public class EnchantWither extends ExcellentEnchant implements Chanced, Potioned if (!this.addEffect(victim, level)) return false; if (this.hasVisualEffects()) { - SimpleParticle.of(Particle.ASH).play(victim.getEyeLocation(), 0.25, 0.1, 30); + UniParticle.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 75968f9..14c2d0c 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 @@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.manager.AbstractListener; import su.nexmedia.engine.utils.PDCUtil; -import su.nexmedia.engine.utils.PlayerUtil; +import su.nexmedia.engine.utils.values.UniSound; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; @@ -151,7 +151,7 @@ public class EnchantAnvilListener extends AbstractListener { e.getView().setCursor(item); e.setCancelled(false); - PlayerUtil.sound(player, Sound.BLOCK_ENCHANTMENT_TABLE_USE); + UniSound.of(Sound.BLOCK_ENCHANTMENT_TABLE_USE).play(player); ItemStack second = inventory.getItem(1); if (second != null && !second.getType().isAir()) { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/ArrowTrailsTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/ArrowTrailsTask.java index 44bdf5e..e5b8705 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/ArrowTrailsTask.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/ArrowTrailsTask.java @@ -2,8 +2,8 @@ package su.nightexpress.excellentenchants.enchantment.task; import org.bukkit.entity.Projectile; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.particle.SimpleParticle; import su.nexmedia.engine.api.server.AbstractTask; +import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.config.Config; @@ -14,7 +14,7 @@ import java.util.concurrent.ConcurrentHashMap; public class ArrowTrailsTask extends AbstractTask { - 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); @@ -32,7 +32,7 @@ public class ArrowTrailsTask extends AbstractTask { }); } - public static void add(@NotNull Projectile projectile, @NotNull SimpleParticle particle) { + public static void add(@NotNull Projectile projectile, @NotNull UniParticle 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/util/EnchantDropContainer.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantDropContainer.java deleted file mode 100644 index 723b5a9..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantDropContainer.java +++ /dev/null @@ -1,30 +0,0 @@ -package su.nightexpress.excellentenchants.enchantment.util; - -import org.bukkit.event.block.BlockDropItemEvent; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; - -@Deprecated -public class EnchantDropContainer { - - private final BlockDropItemEvent parent; - private final List drop; - - public EnchantDropContainer(@NotNull BlockDropItemEvent parent) { - this.parent = parent; - this.drop = new ArrayList<>(); - } - - @NotNull - public BlockDropItemEvent getParent() { - return parent; - } - - @NotNull - public List getDrop() { - return drop; - } -} diff --git a/NMS/pom.xml b/NMS/pom.xml index 1d7f568..50c9ef7 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.7 + 3.5.8 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index e8ecc1c..e48bc89 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.7 + 3.5.8 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.7 + 3.5.8 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 81b4e3c..2a21e2c 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.7 + 3.5.8 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.7 + 3.5.8 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 83f488a..26bd766 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.7 + 3.5.8 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.7 + 3.5.8 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index d2cec44..5813cfc 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,15 +5,15 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.7 + 3.5.8 4.0.0 V1_20_R1 - 16 - 16 + 17 + 17 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.7 + 3.5.8 diff --git a/V1_20_R2/pom.xml b/V1_20_R2/pom.xml new file mode 100644 index 0000000..a3ffdf1 --- /dev/null +++ b/V1_20_R2/pom.xml @@ -0,0 +1,71 @@ + + + + ExcellentEnchants + su.nightexpress.excellentenchants + 3.5.8 + + 4.0.0 + + V1_20_R2 + + + 17 + 17 + + + + + org.spigotmc + spigot + 1.20.2-R0.1-SNAPSHOT + remapped-mojang + + + su.nightexpress.excellentenchants + NMS + 3.5.8 + + + + + + + net.md-5 + specialsource-maven-plugin + 1.2.4 + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:1.20.2-R0.1-SNAPSHOT:txt:maps-mojang + true + org.spigotmc:spigot:1.20.2-R0.1-SNAPSHOT:jar:remapped-mojang + true + remapped-obf + + + + package + + remap + + remap-spigot + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:1.20.2-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.20.2-R0.1-SNAPSHOT:jar:remapped-obf + + + + + + + + \ No newline at end of file diff --git a/V1_20_R2/src/main/java/su/nightexpress/excellentenchants/nms/V1_20_R2.java b/V1_20_R2/src/main/java/su/nightexpress/excellentenchants/nms/V1_20_R2.java new file mode 100644 index 0000000..333b2e4 --- /dev/null +++ b/V1_20_R2/src/main/java/su/nightexpress/excellentenchants/nms/V1_20_R2.java @@ -0,0 +1,116 @@ +package su.nightexpress.excellentenchants.nms; + +import net.minecraft.core.BlockPos; +import net.minecraft.network.protocol.game.ClientboundAnimatePacket; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.projectile.FishingHook; +import net.minecraft.world.item.SpawnEggItem; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_20_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R2.block.CraftBlock; +import org.bukkit.craftbukkit.v1_20_R2.entity.CraftFishHook; +import org.bukkit.craftbukkit.v1_20_R2.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack; +import org.bukkit.entity.FishHook; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.HashSet; +import java.util.Set; + +public class V1_20_R2 implements EnchantNMS { + + @Override + public void sendAttackPacket(@NotNull Player player, int id) { + CraftPlayer craftPlayer = (CraftPlayer) player; + ServerPlayer entity = craftPlayer.getHandle(); + ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id); + craftPlayer.getHandle().connection.send(packet); + } + + @Override + public void retrieveHook(@NotNull FishHook hook, @NotNull ItemStack item) { + CraftFishHook craftFishHook = (CraftFishHook) hook; + FishingHook handle = craftFishHook.getHandle(); + handle.retrieve(CraftItemStack.asNMSCopy(item)); + } + + @Override + @Nullable + public ItemStack getSpawnEgg(@NotNull LivingEntity entity) { + CraftLivingEntity craftLivingEntity = (CraftLivingEntity) entity; + net.minecraft.world.entity.LivingEntity livingEntity = craftLivingEntity.getHandle(); + + SpawnEggItem eggItem = SpawnEggItem.byId(livingEntity.getType()); + if (eggItem == null) return null; + + return CraftItemStack.asBukkitCopy(eggItem.getDefaultInstance()); + } + + @Override + @NotNull + public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { + Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle(); + BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle(); + + int radius = Math.min(16, 2 + level); + BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState(); + BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos(); + + Set blocks = new HashSet<>(); + for (BlockPos posNear : BlockPos.betweenClosed(pos.offset(-radius, -1, -radius), pos.offset(radius, -1, radius))) { + if (!posNear.closerThan(entity.blockPosition(), radius)) continue; + + posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ()); + + BlockState bLavaAbove = world.getBlockState(posAbove); + BlockState bLava = world.getBlockState(posNear); + + if (!bLavaAbove.isAir()) continue; + if (!bLava.getBlock().equals(Blocks.LAVA)) continue; + if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue; + if (!bStone.canSurvive(world, posNear)) continue; + if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue; + if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue; + //world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120)); + + Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ()); + blocks.add(bukkitLoc.getBlock()); + } + return blocks; + } + + @NotNull + public Item popResource(@NotNull Block block, @NotNull ItemStack item) { + Level world = ((CraftWorld)block.getWorld()).getHandle(); + BlockPos pos = ((CraftBlock)block).getPosition(); + net.minecraft.world.item.ItemStack itemstack = CraftItemStack.asNMSCopy(item); + + float yMod = EntityType.ITEM.getHeight() / 2.0F; + double x = (pos.getX() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D); + double y = (pos.getY() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D) - yMod; + double z = (pos.getZ() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D); + + ItemEntity itemEntity = new ItemEntity(world, x, y, z, itemstack); + itemEntity.setDefaultPickUpDelay(); + return (Item) itemEntity.getBukkitEntity(); + } +} diff --git a/pom.xml b/pom.xml index 1c9ab8d..965af82 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.5.7 + 3.5.8 Core NMS @@ -15,6 +15,7 @@ V1_18_R2 V1_19_R3 V1_20_R1 + V1_20_R2 @@ -28,7 +29,7 @@ su.nexmedia NexEngine - 2.2.11 + 2.2.12 From eeef240e4940ab3484a797ae08c9711eb43c7f17 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 3 Oct 2023 18:07:42 +0500 Subject: [PATCH 58/69] v3.5.9 --- Core/pom.xml | 14 +- .../excellentenchants/ExcellentEnchants.java | 22 +- .../api/enchantment/IEnchantment.java | 12 +- .../enchantment/type/BlockBreakEnchant.java | 10 +- .../enchantment/type/BlockDropEnchant.java | 10 +- .../api/enchantment/type/BowEnchant.java | 18 +- .../api/enchantment/type/CombatEnchant.java | 11 + .../api/enchantment/type/DamageEnchant.java | 6 + .../api/enchantment/type/DeathEnchant.java | 11 + .../api/enchantment/type/FishingEnchant.java | 6 + .../api/enchantment/type/GenericEnchant.java | 7 + .../api/enchantment/type/InteractEnchant.java | 10 +- .../command/TierbookCommand.java | 2 +- .../excellentenchants/config/Lang.java | 2 +- .../enchantment/EnchantManager.java | 3 +- .../enchantment/EnchantPopulator.java | 185 +++++++-- .../enchantment/impl/ExcellentEnchant.java | 28 +- ...nchantAquaman.java => AquamanEnchant.java} | 11 +- ...ntColdSteel.java => ColdSteelEnchant.java} | 17 +- .../impl/armor/DarknessCloakEnchant.java | 11 +- ...n.java => ElementalProtectionEnchant.java} | 19 +- ...FireShield.java => FireShieldEnchant.java} | 15 +- ...ameWalker.java => FlameWalkerEnchant.java} | 25 +- ...hantHardened.java => HardenedEnchant.java} | 15 +- ...ntIceShield.java => IceShieldEnchant.java} | 15 +- ...chantBunnyHop.java => JumpingEnchant.java} | 11 +- ...Destruction.java => KamikadzeEnchant.java} | 26 +- ...ghtVision.java => NightVisionEnchant.java} | 11 +- ...hantRegrowth.java => RegrowthEnchant.java} | 10 +- ...Saturation.java => SaturationEnchant.java} | 11 +- .../{EnchantSonic.java => SpeedyEnchant.java} | 11 +- .../impl/armor/StoppingForceEnchant.java | 11 +- .../impl/bow/DarknessArrowsEnchant.java | 10 +- .../enchantment/impl/bow/EnchantBomber.java | 13 +- .../impl/bow/EnchantConfusingArrows.java | 10 +- .../impl/bow/EnchantDragonfireArrows.java | 11 +- .../impl/bow/EnchantElectrifiedArrows.java | 11 +- .../enchantment/impl/bow/EnchantEnderBow.java | 15 +- .../impl/bow/EnchantExplosiveArrows.java | 34 +- .../enchantment/impl/bow/EnchantGhast.java | 15 +- .../enchantment/impl/bow/EnchantHover.java | 10 +- .../impl/bow/EnchantPoisonedArrows.java | 10 +- .../impl/bow/EnchantWitheredArrows.java | 10 +- .../enchantment/impl/bow/FlareEnchant.java | 15 +- .../enchantment/impl/bow/SniperEnchant.java | 17 +- .../impl/fishing/AutoReelEnchant.java | 4 +- .../impl/fishing/CurseOfDrownedEnchant.java | 4 +- .../impl/fishing/DoubleCatchEnchant.java | 11 +- .../impl/fishing/RiverMasterEnchant.java | 8 +- .../impl/fishing/SeasonedAnglerEnchant.java | 4 +- .../impl/fishing/SurvivalistEnchant.java | 11 +- .../impl/meta/ChanceImplementation.java | 2 +- .../impl/meta/PotionImplementation.java | 2 +- ...astMining.java => BlastMiningEnchant.java} | 15 +- ...aking.java => CurseOfBreakingEnchant.java} | 17 +- .../impl/tool/CurseOfMediocrityEnchant.java | 14 +- ...une.java => CurseOfMisfortuneEnchant.java} | 26 +- ...vineTouch.java => DivineTouchEnchant.java} | 53 ++- .../{EnchantHaste.java => HasteEnchant.java} | 11 +- ...LuckyMiner.java => LuckyMinerEnchant.java} | 12 +- ...ntReplanter.java => ReplanterEnchant.java} | 23 +- ...ntSilkChest.java => SilkChestEnchant.java} | 18 +- ...nchantSmelter.java => SmelterEnchant.java} | 21 +- ...lekinesis.java => TelekinesisEnchant.java} | 32 +- ...ntTreasures.java => TreasuresEnchant.java} | 44 +-- ...{EnchantTunnel.java => TunnelEnchant.java} | 15 +- ...ntVeinminer.java => VeinminerEnchant.java} | 14 +- ...lity.java => CurseOfFragilityEnchant.java} | 9 +- .../impl/universal/SoulboundEnchant.java | 7 +- .../impl/weapon/EnchantBaneOfNetherspawn.java | 4 +- .../impl/weapon/EnchantBlindness.java | 11 +- .../impl/weapon/EnchantConfusion.java | 11 +- .../enchantment/impl/weapon/EnchantCure.java | 11 +- .../impl/weapon/EnchantCutter.java | 12 +- .../impl/weapon/EnchantDecapitator.java | 5 +- .../impl/weapon/EnchantDoubleStrike.java | 11 +- .../impl/weapon/EnchantExhaust.java | 11 +- .../impl/weapon/EnchantExpHunter.java | 5 +- .../impl/weapon/EnchantIceAspect.java | 11 +- .../impl/weapon/EnchantInfernus.java | 7 +- .../impl/weapon/EnchantNimble.java | 13 +- .../impl/weapon/EnchantParalyze.java | 11 +- .../enchantment/impl/weapon/EnchantRage.java | 11 +- .../impl/weapon/EnchantRocket.java | 11 +- .../impl/weapon/EnchantScavenger.java | 5 +- .../impl/weapon/EnchantSurprise.java | 11 +- .../impl/weapon/EnchantTemper.java | 12 +- .../impl/weapon/EnchantThrifty.java | 5 +- .../impl/weapon/EnchantThunder.java | 12 +- .../impl/weapon/EnchantVampire.java | 14 +- .../enchantment/impl/weapon/EnchantVenom.java | 11 +- .../impl/weapon/EnchantVillageDefender.java | 4 +- .../impl/weapon/EnchantWither.java | 11 +- .../listener/EnchantAnvilListener.java | 32 +- .../listener/EnchantGenericListener.java | 69 ++-- .../listener/EnchantHandlerListener.java | 116 ++---- .../menu/EnchantmentsListMenu.java | 2 +- .../{ => registry}/EnchantRegistry.java | 168 ++++++--- .../registry/wrapper/DataGather.java | 31 ++ .../registry/wrapper/DataGathers.java | 351 ++++++++++++++++++ .../registry/wrapper/WrappedEvent.java | 56 +++ .../enchantment/util/EnchantPriority.java | 6 - .../enchantment/util/EnchantUtils.java | 150 ++------ .../hook/impl/PlaceholderHook.java | 2 +- .../hook/impl/ProtocolHook.java | 2 +- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 +- V1_18_R2/pom.xml | 4 +- V1_19_R3/pom.xml | 4 +- V1_20_R1/pom.xml | 4 +- V1_20_R2/pom.xml | 4 +- pom.xml | 2 +- 112 files changed, 1550 insertions(+), 823 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/GenericEnchant.java rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantAquaman.java => AquamanEnchant.java} (84%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantColdSteel.java => ColdSteelEnchant.java} (89%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantElementalProtection.java => ElementalProtectionEnchant.java} (85%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantFireShield.java => FireShieldEnchant.java} (91%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantFlameWalker.java => FlameWalkerEnchant.java} (90%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantHardened.java => HardenedEnchant.java} (89%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantIceShield.java => IceShieldEnchant.java} (90%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantBunnyHop.java => JumpingEnchant.java} (83%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantSelfDestruction.java => KamikadzeEnchant.java} (78%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantNightVision.java => NightVisionEnchant.java} (84%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantRegrowth.java => RegrowthEnchant.java} (93%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantSaturation.java => SaturationEnchant.java} (90%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/{EnchantSonic.java => SpeedyEnchant.java} (83%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantBlastMining.java => BlastMiningEnchant.java} (91%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantCurseOfBreaking.java => CurseOfBreakingEnchant.java} (83%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantCurseOfMisfortune.java => CurseOfMisfortuneEnchant.java} (86%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantDivineTouch.java => DivineTouchEnchant.java} (80%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantHaste.java => HasteEnchant.java} (84%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantLuckyMiner.java => LuckyMinerEnchant.java} (87%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantReplanter.java => ReplanterEnchant.java} (92%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantSilkChest.java => SilkChestEnchant.java} (93%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantSmelter.java => SmelterEnchant.java} (91%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantTelekinesis.java => TelekinesisEnchant.java} (71%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantTreasures.java => TreasuresEnchant.java} (85%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantTunnel.java => TunnelEnchant.java} (90%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/{EnchantVeinminer.java => VeinminerEnchant.java} (91%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/{EnchantCurseOfFragility.java => CurseOfFragilityEnchant.java} (89%) rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/{ => registry}/EnchantRegistry.java (50%) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGather.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/WrappedEvent.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantPriority.java diff --git a/Core/pom.xml b/Core/pom.xml index ec12f26..611fd6a 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.8 + 3.5.9 4.0.0 @@ -76,32 +76,32 @@ su.nightexpress.excellentenchants NMS - 3.5.8 + 3.5.9 su.nightexpress.excellentenchants V1_17_R1 - 3.5.8 + 3.5.9 su.nightexpress.excellentenchants V1_18_R2 - 3.5.8 + 3.5.9 su.nightexpress.excellentenchants V1_19_R3 - 3.5.8 + 3.5.9 su.nightexpress.excellentenchants V1_20_R1 - 3.5.8 + 3.5.9 su.nightexpress.excellentenchants V1_20_R2 - 3.5.8 + 3.5.9 diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 34c0b84..6e733a0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.NexPlugin; import su.nexmedia.engine.Version; @@ -13,8 +14,10 @@ import su.nightexpress.excellentenchants.command.TierbookCommand; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.config.Lang; import su.nightexpress.excellentenchants.enchantment.EnchantManager; -import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; +import su.nightexpress.excellentenchants.enchantment.EnchantPopulator; +import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; +import su.nightexpress.excellentenchants.enchantment.type.ObtainType; import su.nightexpress.excellentenchants.hook.HookId; import su.nightexpress.excellentenchants.hook.impl.PlaceholderHook; import su.nightexpress.excellentenchants.hook.impl.ProtocolHook; @@ -28,7 +31,7 @@ import su.nightexpress.excellentenchants.tier.TierManager; public class ExcellentEnchants extends NexPlugin { - private EnchantRegistry enchantRegistry; + private EnchantRegistry registry; private EnchantManager enchantManager; private EnchantNMS enchantNMS; private TierManager tierManager; @@ -42,7 +45,7 @@ public class ExcellentEnchants extends NexPlugin { @Override public void onLoad() { super.onLoad(); - this.enchantRegistry = new EnchantRegistry(this); + this.registry = new EnchantRegistry(this); } @Override @@ -52,7 +55,7 @@ public class ExcellentEnchants extends NexPlugin { this.tierManager = new TierManager(this); this.tierManager.setup(); - this.enchantRegistry.setup(); + this.registry.setup(); this.enchantManager = new EnchantManager(this); this.enchantManager.setup(); @@ -79,7 +82,7 @@ public class ExcellentEnchants extends NexPlugin { this.tierManager = null; } PlaceholderHook.shutdown(); - //this.enchantRegistry.shutdown(); Do we ever need this at all? + this.registry.shutdown(); } private void setNMS() { @@ -126,14 +129,19 @@ public class ExcellentEnchants extends NexPlugin { this.registerPermissions(Perms.class); } + @NotNull + public EnchantPopulator createPopulator(@NotNull ItemStack item, @NotNull ObtainType obtainType) { + return new EnchantPopulator(this, item, obtainType); + } + @NotNull public TierManager getTierManager() { return tierManager; } @NotNull - public EnchantRegistry getEnchantRegistry() { - return this.enchantRegistry; + public EnchantRegistry getRegistry() { + return registry; } @NotNull 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 4d1fefc..b5c3e8b 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 @@ -1,25 +1,27 @@ package su.nightexpress.excellentenchants.api.enchantment; +import org.bukkit.Keyed; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; 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.enchantment.util.EnchantPriority; -import su.nightexpress.excellentenchants.tier.Tier; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; +import su.nightexpress.excellentenchants.tier.Tier; import java.util.List; import java.util.Set; -public interface IEnchantment { +public interface IEnchantment extends Keyed { + + boolean isAvailableToUse(@NotNull LivingEntity entity); @NotNull JYML getConfig(); @NotNull String getId(); - @NotNull EnchantPriority getPriority(); - @NotNull String getDisplayName(); @NotNull String getNameFormatted(int level); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java index 6cce6ad..32de3aa 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockBreakEnchant.java @@ -1,6 +1,7 @@ package su.nightexpress.excellentenchants.api.enchantment.type; -import org.bukkit.entity.Player; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -8,5 +9,10 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface BlockBreakEnchant extends IEnchantment { - boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level); + boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity player, @NotNull ItemStack item, int level); + + @NotNull + default EventPriority getBreakPriority() { + return EventPriority.HIGH; + } } 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 fbccb78..e8c3268 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 @@ -1,6 +1,7 @@ package su.nightexpress.excellentenchants.api.enchantment.type; -import org.bukkit.entity.Player; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -8,5 +9,10 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface BlockDropEnchant extends IEnchantment { - boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level); + boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull LivingEntity player, @NotNull ItemStack item, int level); + + @NotNull + default EventPriority getDropPriority() { + return EventPriority.NORMAL; + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java index 8b4df42..4653606 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BowEnchant.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.api.enchantment.type; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; @@ -13,9 +14,24 @@ public interface BowEnchant extends IEnchantment { boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level); - boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level); + boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level); boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level); + + @NotNull + default EventPriority getShootPriority() { + return EventPriority.NORMAL; + } + + @NotNull + default EventPriority getHitPriority() { + return EventPriority.NORMAL; + } + + @NotNull + default EventPriority getDamagePriority() { + return EventPriority.NORMAL; + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java index 32d0fe8..54e9535 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/CombatEnchant.java @@ -1,6 +1,7 @@ package su.nightexpress.excellentenchants.api.enchantment.type; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -15,4 +16,14 @@ public interface CombatEnchant extends IEnchantment { boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level); + + @NotNull + default EventPriority getAttackPriority() { + return EventPriority.NORMAL; + } + + @NotNull + default EventPriority getProtectPriority() { + return EventPriority.NORMAL; + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DamageEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DamageEnchant.java index 12448ad..8099f3f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DamageEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DamageEnchant.java @@ -1,6 +1,7 @@ package su.nightexpress.excellentenchants.api.enchantment.type; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -9,4 +10,9 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface DamageEnchant extends IEnchantment { boolean onDamage(@NotNull EntityDamageEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level); + + @NotNull + default EventPriority getDamagePriority() { + return EventPriority.NORMAL; + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java index 78e3387..e42468e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.api.enchantment.type; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -12,4 +13,14 @@ public interface DeathEnchant extends IEnchantment { boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level); boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level); + + @NotNull + default EventPriority getDeathPriority() { + return EventPriority.NORMAL; + } + + @NotNull + default EventPriority getKillPriority() { + return EventPriority.NORMAL; + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/FishingEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/FishingEnchant.java index 1665720..cc45db4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/FishingEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/FishingEnchant.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.api.enchantment.type; +import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -8,4 +9,9 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface FishingEnchant extends IEnchantment { boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level); + + @NotNull + default EventPriority getFishingPriority() { + return EventPriority.NORMAL; + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/GenericEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/GenericEnchant.java new file mode 100644 index 0000000..f7aa000 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/GenericEnchant.java @@ -0,0 +1,7 @@ +package su.nightexpress.excellentenchants.api.enchantment.type; + +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; + +public interface GenericEnchant extends IEnchantment { + +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java index 2193876..e4e526c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/InteractEnchant.java @@ -1,6 +1,7 @@ package su.nightexpress.excellentenchants.api.enchantment.type; -import org.bukkit.entity.Player; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -8,5 +9,10 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface InteractEnchant extends IEnchantment { - boolean onInteract(@NotNull PlayerInteractEvent event, @NotNull Player player, @NotNull ItemStack item, int level); + boolean onInteract(@NotNull PlayerInteractEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level); + + @NotNull + default EventPriority getInteractPriority() { + return EventPriority.NORMAL; + } } 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 f0d9950..a7bddce 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java @@ -14,8 +14,8 @@ 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.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.tier.Tier; 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 301e437..eaff27a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java @@ -4,7 +4,7 @@ import su.nexmedia.engine.api.lang.LangKey; import su.nexmedia.engine.lang.EngineLang; import su.nightexpress.excellentenchants.Placeholders; -import static su.nexmedia.engine.utils.Colors.*; +import static su.nexmedia.engine.utils.Colors.RED; public class Lang extends EngineLang { 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 6e46f73..3e3dabe 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java @@ -5,7 +5,6 @@ import su.nexmedia.engine.api.manager.AbstractManager; import su.nightexpress.excellentenchants.ExcellentEnchants; 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; @@ -26,7 +25,7 @@ public class EnchantManager extends AbstractManager { @Override protected void onLoad() { this.enchantmentsListMenu = new EnchantmentsListMenu(this.plugin); - this.addListener(new EnchantHandlerListener(this)); + //this.addListener(new EnchantHandlerListener(this)); this.addListener(new EnchantGenericListener(this)); this.addListener(new EnchantAnvilListener(this.plugin)); 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 63fa0d8..d093c32 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java @@ -1,11 +1,17 @@ package su.nightexpress.excellentenchants.enchantment; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; 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.ExcellentEnchants; +import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.config.ObtainSettings; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.tier.Tier; @@ -14,45 +20,80 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Function; import java.util.stream.Collectors; public class EnchantPopulator { + private final ExcellentEnchants plugin; private final ObtainType obtainType; private final ItemStack item; - private final Map> enchants; + private final Map> candidates; + private final Map population; - public EnchantPopulator(@NotNull ObtainType obtainType, @NotNull ItemStack item) { - this.obtainType = obtainType; + private World world; + private Function levelGenerator; + + public EnchantPopulator(@NotNull ExcellentEnchants plugin, @NotNull ItemStack item, @NotNull ObtainType obtainType) { + this.plugin = plugin; this.item = item; - this.enchants = new HashMap<>(); + this.obtainType = obtainType; + this.candidates = new HashMap<>(); + this.population = new HashMap<>(); + this.withLevelGenerator(enchant -> enchant.generateLevel(this.getObtainType())); - ExcellentEnchantsAPI.getTierManager().getTiers().forEach(tier -> { + this.fillDefaultCandidates(); + } + + @NotNull + public EnchantPopulator withWorld(@NotNull World world) { + this.world = world; + return this; + } + + @NotNull + public EnchantPopulator withLevelGenerator(@NotNull Function levelGenerator) { + this.levelGenerator = levelGenerator; + return this; + } + + @NotNull + public EnchantPopulator withDefaultPopulation(@NotNull Map population) { + this.getPopulation().putAll(population); + return this; + } + + private void fillDefaultCandidates() { + this.plugin.getTierManager().getTiers().forEach(tier -> { Set enchants = EnchantRegistry.getOfTier(tier); - this.enchants.put(tier, EnchantUtils.populateFilter(enchants, obtainType, item)); + + enchants.removeIf(enchant -> { + if (enchant.getObtainChance(this.getObtainType()) <= 0D) return true; + if (!enchant.canEnchantItem(this.getItem())) return true; + + return this.getObtainType() == ObtainType.ENCHANTING && (enchant.isTreasure() || enchant.isCursed()); + }); + + this.candidates.put(tier, enchants); }); } public boolean isEmpty() { - return this.getEnchants().isEmpty() || this.getEnchants().values().stream().allMatch(Set::isEmpty); + return this.getCandidates().isEmpty() || this.getCandidates().values().stream().allMatch(Set::isEmpty); } public boolean isEmpty(@NotNull Tier tier) { - return this.getEnchants(tier).isEmpty(); + return this.getCandidates(tier).isEmpty(); } public void purge(@NotNull Tier tier) { - this.getEnchants().remove(tier); + this.getCandidates().remove(tier); } public void purge(@NotNull Tier tier, @NotNull ExcellentEnchant enchant) { - this.getEnchants(tier).remove(enchant); - this.getEnchants().keySet().removeIf(this::isEmpty); - } - - @NotNull - public ObtainType getObtainType() { - return obtainType; + this.getCandidates(tier).remove(enchant); + this.getCandidates().keySet().removeIf(this::isEmpty); } @NotNull @@ -61,18 +102,38 @@ public class EnchantPopulator { } @NotNull - public Map> getEnchants() { - return this.enchants; + public ObtainType getObtainType() { + return obtainType; + } + + @Nullable + public World getWorld() { + return world; } @NotNull - public Set getEnchants(@NotNull Tier tier) { - return this.getEnchants().getOrDefault(tier, new HashSet<>()); + public Function getLevelGenerator() { + return levelGenerator; + } + + @NotNull + public Map> getCandidates() { + return this.candidates; + } + + @NotNull + public Set getCandidates(@NotNull Tier tier) { + return this.getCandidates().getOrDefault(tier, new HashSet<>()); + } + + @NotNull + public Map getPopulation() { + return this.population; } @Nullable public Tier getTierByChance() { - Map map = this.getEnchants().keySet().stream() + Map map = this.getCandidates().keySet().stream() .filter(tier -> tier.getChance(this.getObtainType()) > 0D) .collect(Collectors.toMap(k -> k, v -> v.getChance(this.getObtainType()), (o, n) -> n, HashMap::new)); if (map.isEmpty()) return null; @@ -82,8 +143,86 @@ public class EnchantPopulator { @Nullable public ExcellentEnchant getEnchantByChance(@NotNull Tier tier) { - Map map = this.getEnchants(tier).stream() + Map map = this.getCandidates(tier).stream() .collect(Collectors.toMap(k -> k, v -> v.getObtainChance(this.getObtainType()))); return map.isEmpty() ? null : Rnd.getByWeight(map); } + + @NotNull + public Map createPopulation() { + Map population = this.getPopulation(); + + ObtainSettings settings = Config.getObtainSettings(this.getObtainType()).orElse(null); + if (settings == null || !Rnd.chance(settings.getEnchantsCustomGenerationChance())) return population; + + int enchantsLimit = settings.getEnchantsTotalMax(); + int enchantsRolled = Rnd.get(settings.getEnchantsCustomMin(), settings.getEnchantsCustomMax()); + + // Try to populate as many as possible. + while (!this.isEmpty() && enchantsRolled > 0) { + // Limit reached. + if (population.size() >= enchantsLimit) break; + + Tier tier = this.getTierByChance(); + if (tier == null) break; // no tiers left. + + ExcellentEnchant enchant = this.getEnchantByChance(tier); + // Remove entire tier if no enchants can be selected. + if (enchant == null) { + this.purge(tier); + continue; + } + + // Remove disabled world enchants. + if (world != null && enchant.isDisabledInWorld(world)) { + this.purge(tier, enchant); + continue; + } + + // Remove conflicting enchants. + if (population.keySet().stream().anyMatch(has -> has.conflictsWith(enchant) || enchant.conflictsWith(has))) { + this.purge(tier, enchant); + continue; + } + + // Level generation failed. + int level = this.getLevelGenerator().apply(enchant); + if (level < enchant.getStartLevel()) { + this.purge(tier, enchant); + continue; + } + + // All good! + this.purge(tier, enchant); + population.put(enchant, level); + enchantsRolled--; + } + + return population; + } + + public boolean populate() { + ItemStack item = this.getItem(); + AtomicBoolean status = new AtomicBoolean(false); + + var population = this.getPopulation().isEmpty() ? this.createPopulation() : this.getPopulation(); + + if (this.getObtainType() == ObtainType.VILLAGER && item.getType() == Material.ENCHANTED_BOOK) { + if (Config.ENCHANTMENTS_SINGLE_ENCHANT_IN_VILLAGER_BOOKS.get() && !population.isEmpty()) { + EnchantUtils.getAll(item).keySet().forEach(enchantment -> EnchantUtils.remove(item, enchantment)); + } + } + + population.forEach((enchantment, level) -> { + if (EnchantUtils.add(item, enchantment, level, false)) { + status.set(true); + } + }); + + if (status.get()) { + EnchantUtils.updateDisplay(item); + } + + return status.get(); + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index 28ebee4..bf95036 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -25,7 +25,6 @@ import su.nightexpress.excellentenchants.enchantment.EnchantManager; import su.nightexpress.excellentenchants.enchantment.config.EnchantDefaults; import su.nightexpress.excellentenchants.enchantment.type.FitItemType; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.tier.Tier; @@ -33,22 +32,20 @@ import java.util.*; import java.util.function.Function; import java.util.stream.Stream; -public abstract class ExcellentEnchant extends Enchantment implements IEnchantment, EventListener { +public abstract class ExcellentEnchant extends Enchantment implements IEnchantment { - protected final ExcellentEnchants plugin; - protected final JYML cfg; - protected final String id; - protected final EnchantPriority priority; - protected final EnchantDefaults defaults; - protected final NamespacedKey chargesKey; + protected final ExcellentEnchants plugin; + protected final JYML cfg; + protected final String id; + protected final EnchantDefaults defaults; + protected final NamespacedKey chargesKey; protected final Map placeholdersMap; - public ExcellentEnchant(@NotNull ExcellentEnchants plugin, @NotNull String id, @NotNull EnchantPriority priority) { + public ExcellentEnchant(@NotNull ExcellentEnchants plugin, @NotNull String id) { super(NamespacedKey.minecraft(id.toLowerCase())); this.plugin = plugin; this.id = this.getKey().getKey(); this.cfg = new JYML(plugin.getDataFolder() + EnchantManager.DIR_ENCHANTS, id + ".yml"); - this.priority = priority; this.chargesKey = new NamespacedKey(plugin, this.getId() + ".charges"); this.defaults = new EnchantDefaults(this); this.placeholdersMap = new HashMap<>(); @@ -111,9 +108,10 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme } } - @Override public void registerListeners() { - this.plugin.getPluginManager().registerEvents(this, plugin); + if (this instanceof EventListener listener) { + this.plugin.getPluginManager().registerEvents(listener, plugin); + } } @NotNull @@ -127,6 +125,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme return disabled.contains(this.getKey().getKey()) || disabled.contains(Placeholders.WILDCARD); } + @Override public boolean isAvailableToUse(@NotNull LivingEntity entity) { return !this.isDisabledInWorld(entity.getWorld()); } @@ -141,11 +140,6 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme return this.id; } - @NotNull - public EnchantPriority getPriority() { - return priority; - } - @NotNull public EnchantDefaults getDefaults() { return defaults; 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/AquamanEnchant.java similarity index 84% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantAquaman.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/AquamanEnchant.java index 67de252..c3f969a 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/AquamanEnchant.java @@ -7,20 +7,19 @@ 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.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantAquaman extends ExcellentEnchant implements Potioned, PassiveEnchant { +public class AquamanEnchant extends ExcellentEnchant implements Potioned, PassiveEnchant { public static final String ID = "aquaman"; private PotionImplementation potionImplementation; - public EnchantAquaman(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public AquamanEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setLevelMax(1); this.getDefaults().setTier(0.4); this.getDefaults().setDescription("Grants permanent " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " effect."); @@ -46,8 +45,6 @@ public class EnchantAquaman extends ExcellentEnchant implements Potioned, Passiv @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(entity)) return false; - return this.addEffect(entity, level); } } 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/ColdSteelEnchant.java similarity index 89% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantColdSteel.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/ColdSteelEnchant.java index e6ac365..2ea973b 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/ColdSteelEnchant.java @@ -2,29 +2,29 @@ package su.nightexpress.excellentenchants.enchantment.impl.armor; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; 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.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.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; -public class EnchantColdSteel extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { +public class ColdSteelEnchant 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); + public ColdSteelEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); 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); @@ -60,6 +60,12 @@ public class EnchantColdSteel extends ExcellentEnchant implements Chanced, Potio return EnchantmentTarget.ARMOR_TORSO; } + @NotNull + @Override + public EventPriority getProtectPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; @@ -67,7 +73,6 @@ public class EnchantColdSteel extends ExcellentEnchant implements Chanced, Potio @Override public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(damager)) return false; if (!this.checkTriggerChance(level)) return false; return this.addEffect(damager, level); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java index c879bad..bace779 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.armor; import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; @@ -16,7 +17,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 DarknessCloakEnchant extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { @@ -26,7 +26,7 @@ public class DarknessCloakEnchant extends ExcellentEnchant implements Chanced, P private PotionImplementation potionImplementation; public DarknessCloakEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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().setLevelMax(3); this.getDefaults().setTier(0.2); @@ -61,6 +61,12 @@ public class DarknessCloakEnchant extends ExcellentEnchant implements Chanced, P return EnchantmentTarget.ARMOR_TORSO; } + @NotNull + @Override + public EventPriority getProtectPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; @@ -68,7 +74,6 @@ public class DarknessCloakEnchant extends ExcellentEnchant implements Chanced, P @Override public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(victim)) return false; if (!this.checkTriggerChance(level)) return false; if (!this.addEffect(damager, level)) return false; 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/ElementalProtectionEnchant.java similarity index 85% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantElementalProtection.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/ElementalProtectionEnchant.java index 3be551f..f962f9e 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/ElementalProtectionEnchant.java @@ -8,17 +8,18 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; +import su.nexmedia.engine.api.manager.EventListener; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; 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.Set; -public class EnchantElementalProtection extends ExcellentEnchant { +public class ElementalProtectionEnchant extends ExcellentEnchant implements GenericEnchant, EventListener { public static final String ID = "elemental_protection"; public static final String PLACEHOLDER_PROTECTION_AMOUNT = "%enchantment_protection_amount%"; @@ -33,8 +34,8 @@ public class EnchantElementalProtection extends ExcellentEnchant { private double protectionCapacity; private boolean protectionAsModifier; - public EnchantElementalProtection(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public ElementalProtectionEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription("Reduces Poison, Magic, Wither, Lightning, Freeze damage by " + PLACEHOLDER_PROTECTION_AMOUNT + "."); this.getDefaults().setLevelMax(5); this.getDefaults().setTier(0.2); @@ -76,9 +77,9 @@ public class EnchantElementalProtection extends ExcellentEnchant { } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onDamage(EntityDamageEvent e) { - if (!DAMAGE_CAUSES.contains(e.getCause())) return; - if (!(e.getEntity() instanceof LivingEntity entity)) return; + public void onDamage(EntityDamageEvent event) { + if (!DAMAGE_CAUSES.contains(event.getCause())) return; + if (!(event.getEntity() instanceof LivingEntity entity)) return; if (!this.isAvailableToUse(entity)) return; double protectionAmount = 0D; @@ -96,10 +97,10 @@ public class EnchantElementalProtection extends ExcellentEnchant { } if (this.isProtectionAsModifier()) { - e.setDamage(Math.max(0, e.getDamage() * (1D - protectionAmount))); + event.setDamage(Math.max(0, event.getDamage() * (1D - protectionAmount))); } else { - e.setDamage(Math.max(0, e.getDamage() - protectionAmount)); + event.setDamage(Math.max(0, event.getDamage() - protectionAmount)); } } } 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/FireShieldEnchant.java similarity index 91% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFireShield.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/FireShieldEnchant.java index 6c11e5d..83d1db5 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/FireShieldEnchant.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.armor; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -13,9 +14,8 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 EnchantFireShield extends ExcellentEnchant implements Chanced, CombatEnchant { +public class FireShieldEnchant extends ExcellentEnchant implements Chanced, CombatEnchant { public static final String ID = "fire_shield"; public static final String PLACEHOLDER_FIRE_DURATION = "%enchantment_fire_duration%"; @@ -23,8 +23,8 @@ public class EnchantFireShield extends ExcellentEnchant implements Chanced, Comb private EnchantScaler fireDuration; private ChanceImplementation chanceImplementation; - public EnchantFireShield(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public FireShieldEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); 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); @@ -57,6 +57,12 @@ public class EnchantFireShield extends ExcellentEnchant implements Chanced, Comb return EnchantmentTarget.ARMOR; } + @NotNull + @Override + public EventPriority getProtectPriority() { + return EventPriority.HIGHEST; + } + public double getFireDuration(int level) { return this.fireDuration.getValue(level); } @@ -70,7 +76,6 @@ public class EnchantFireShield extends ExcellentEnchant implements Chanced, Comb public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(victim)) return false; if (!this.checkTriggerChance(level)) return false; int ticksToSet = (int) (this.getFireDuration(level) * 20); 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/FlameWalkerEnchant.java similarity index 90% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFlameWalker.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/FlameWalkerEnchant.java index 2012b33..54d500d 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/FlameWalkerEnchant.java @@ -19,15 +19,16 @@ import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.Version; +import su.nexmedia.engine.api.manager.EventListener; import su.nexmedia.engine.api.server.AbstractTask; import su.nexmedia.engine.utils.Pair; import su.nexmedia.engine.utils.random.Rnd; import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.Cleanable; +import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; 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.List; @@ -36,7 +37,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; -public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { +public class FlameWalkerEnchant extends ExcellentEnchant implements GenericEnchant, EventListener, Cleanable { public static final String ID = "flame_walker"; @@ -46,8 +47,8 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { private EnchantScaler blockDecayTime; private BlockTickTask blockTickTask; - public EnchantFlameWalker(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public FlameWalkerEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription("Ability to walk on lava and magma blocks without getting damage."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.7); @@ -93,12 +94,12 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void onPlayerMove(PlayerMoveEvent e) { - Player player = e.getPlayer(); + public void onPlayerMove(PlayerMoveEvent event) { + Player player = event.getPlayer(); if (player.isFlying() || !this.isAvailableToUse(player)) return; - Location from = e.getFrom(); - Location to = e.getTo(); + Location from = event.getFrom(); + Location to = event.getTo(); if (to == null) return; if (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()) return; @@ -147,9 +148,9 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onMagmaDamage(EntityDamageEvent e) { - if (e.getCause() != EntityDamageEvent.DamageCause.HOT_FLOOR) return; - if (!(e.getEntity() instanceof LivingEntity livingEntity)) return; + public void onMagmaDamage(EntityDamageEvent event) { + if (event.getCause() != EntityDamageEvent.DamageCause.HOT_FLOOR) return; + if (!(event.getEntity() instanceof LivingEntity livingEntity)) return; if (!this.isAvailableToUse(livingEntity)) return; EntityEquipment equipment = livingEntity.getEquipment(); @@ -161,7 +162,7 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { int level = EnchantUtils.getLevel(boots, this); if (level <= 0) return; - e.setCancelled(true); + event.setCancelled(true); } static class BlockTickTask extends AbstractTask { 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/HardenedEnchant.java similarity index 89% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantHardened.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/HardenedEnchant.java index 504f8db..2f87402 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/HardenedEnchant.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.armor; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; @@ -14,17 +15,16 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 EnchantHardened extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { +public class HardenedEnchant 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); + public HardenedEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); 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); @@ -59,6 +59,12 @@ public class EnchantHardened extends ExcellentEnchant implements Chanced, Potion return EnchantmentTarget.ARMOR_TORSO; } + @NotNull + @Override + public EventPriority getProtectPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { return false; @@ -66,7 +72,6 @@ public class EnchantHardened extends ExcellentEnchant implements Chanced, Potion @Override public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(damager)) return false; if (!this.checkTriggerChance(level)) return false; return this.addEffect(victim, level); 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/IceShieldEnchant.java similarity index 90% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantIceShield.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/IceShieldEnchant.java index ec4bca6..96a1ff6 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/IceShieldEnchant.java @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.armor; import org.bukkit.Material; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; @@ -16,17 +17,16 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 ExcellentEnchant implements Chanced, Potioned, CombatEnchant { +public class IceShieldEnchant 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); + public IceShieldEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); 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); @@ -47,6 +47,12 @@ public class EnchantIceShield extends ExcellentEnchant implements Chanced, Potio return EnchantmentTarget.ARMOR_TORSO; } + @NotNull + @Override + public EventPriority getProtectPriority() { + return EventPriority.HIGHEST; + } + @Override @NotNull public Chanced getChanceImplementation() { @@ -66,7 +72,6 @@ public class EnchantIceShield extends ExcellentEnchant implements Chanced, Potio @Override public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(victim)) return false; if (!this.checkTriggerChance(level)) return false; if (!this.addEffect(damager, level)) return false; 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/JumpingEnchant.java similarity index 83% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantBunnyHop.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/JumpingEnchant.java index a08aae3..b7dc33a 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/JumpingEnchant.java @@ -7,20 +7,19 @@ 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.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantBunnyHop extends ExcellentEnchant implements Potioned, PassiveEnchant { +public class JumpingEnchant 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); + public JumpingEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.1); this.getDefaults().setDescription("Grants permanent " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " effect."); @@ -46,8 +45,6 @@ public class EnchantBunnyHop extends ExcellentEnchant implements Potioned, Passi @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(entity)) return false; - return this.addEffect(entity, 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/KamikadzeEnchant.java similarity index 78% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSelfDestruction.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/KamikadzeEnchant.java index 688741a..7bc9bbe 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/KamikadzeEnchant.java @@ -1,6 +1,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.armor; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -9,7 +10,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -19,20 +19,19 @@ import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; 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 EnchantSelfDestruction extends ExcellentEnchant implements Chanced, DeathEnchant { +public class KamikadzeEnchant extends ExcellentEnchant implements Chanced, DeathEnchant { public static final String ID = "self_destruction"; - - private static final String META_EXPLOSION_SOURCE = ID + "_explosion_source"; private static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; private EnchantScaler explosionSize; private ChanceImplementation chanceImplementation; - public EnchantSelfDestruction(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + private Entity exploder; + + public KamikadzeEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription("%enchantment_trigger_chance%% chance to create an explosion on death."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.3); @@ -68,13 +67,12 @@ public class EnchantSelfDestruction extends ExcellentEnchant implements Chanced, @Override public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) { - if (!this.isAvailableToUse(entity)) return false; if (!this.checkTriggerChance(level)) return false; float size = (float) this.getExplosionSize(level); - entity.setMetadata(META_EXPLOSION_SOURCE, new FixedMetadataValue(plugin, true)); + this.exploder = entity; boolean exploded = entity.getWorld().createExplosion(entity.getLocation(), size, false, false, entity); - entity.removeMetadata(META_EXPLOSION_SOURCE, plugin); + this.exploder = null; return exploded; } @@ -84,10 +82,10 @@ public class EnchantSelfDestruction extends ExcellentEnchant implements Chanced, } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onItemDamage(EntityDamageByEntityEvent e) { - if (!e.getDamager().hasMetadata(META_EXPLOSION_SOURCE)) return; - if (!(e.getEntity() instanceof Item item)) return; + public void onItemDamage(EntityDamageByEntityEvent event) { + if (this.exploder == null || event.getDamager() != this.exploder) return; + if (!(event.getEntity() instanceof Item item)) return; - e.setCancelled(true); + event.setCancelled(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/NightVisionEnchant.java similarity index 84% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantNightVision.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/NightVisionEnchant.java index 9ddafa5..6589f35 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/NightVisionEnchant.java @@ -7,20 +7,19 @@ 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.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantNightVision extends ExcellentEnchant implements Potioned, PassiveEnchant { +public class NightVisionEnchant 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); + public NightVisionEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription("Grants permanent " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " effect."); this.getDefaults().setLevelMax(1); this.getDefaults().setTier(0.7); @@ -46,8 +45,6 @@ public class EnchantNightVision extends ExcellentEnchant implements Potioned, Pa @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(entity)) return false; - return this.addEffect(entity, level); } } \ No newline at end of file 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/RegrowthEnchant.java similarity index 93% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantRegrowth.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java index c0c17e2..0620744 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/RegrowthEnchant.java @@ -19,10 +19,9 @@ 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; -public class EnchantRegrowth extends ExcellentEnchant implements Chanced, PassiveEnchant, Cleanable { +public class RegrowthEnchant extends ExcellentEnchant implements Chanced, PassiveEnchant, Cleanable { public static final String ID = "regrowth"; @@ -39,8 +38,8 @@ public class EnchantRegrowth extends ExcellentEnchant implements Chanced, Passiv private ChanceImplementation chanceImplementation; private Task task; - public EnchantRegrowth(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public RegrowthEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription("Restores " + PLACEHOLDER_HEAL_AMOUNT + " hearts every " + PLACEHOLDER_HEAL_INTERVAL + "s."); this.getDefaults().setLevelMax(5); this.getDefaults().setTier(0.7); @@ -111,7 +110,6 @@ public class EnchantRegrowth extends ExcellentEnchant implements Chanced, Passiv @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(entity)) return false; if (!this.checkTriggerChance(level)) return false; double healthMax = EntityUtil.getAttribute(entity, Attribute.GENERIC_MAX_HEALTH); @@ -137,7 +135,7 @@ public class EnchantRegrowth extends ExcellentEnchant implements Chanced, Passiv @Override public void action() { for (LivingEntity entity : this.getEntities()) { - EnchantUtils.getEquipped(entity, EnchantRegrowth.class).forEach((item, enchants) -> { + EnchantUtils.getEquipped(entity, RegrowthEnchant.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/SaturationEnchant.java similarity index 90% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSaturation.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java index 1af04ac..263a8b1 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/SaturationEnchant.java @@ -14,10 +14,9 @@ import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.task.AbstractEnchantmentTask; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; -public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchant, Cleanable { +public class SaturationEnchant extends ExcellentEnchant implements PassiveEnchant, Cleanable { public static final String ID = "saturation"; @@ -31,8 +30,8 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan private Task task; - public EnchantSaturation(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public SaturationEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription("Restores " + PLACEHOLDER_SATURATION_AMOUNT + " food points every " + PLACEHOLDER_SATURATION_INTERVAL + "s."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.5); @@ -88,13 +87,11 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(entity)) return false; if (!(entity instanceof Player player)) return false; if (player.getFoodLevel() >= this.getMaxFoodLevel(level)) return false; int amount = this.getSaturationAmount(level); player.setFoodLevel(Math.min(20, player.getFoodLevel() + amount)); - player.setSaturation(Math.min(20, player.getSaturation() + amount)); return true; } @@ -107,7 +104,7 @@ public class EnchantSaturation extends ExcellentEnchant implements PassiveEnchan @Override public void action() { for (LivingEntity entity : this.getEntities()) { - EnchantUtils.getEquipped(entity, EnchantSaturation.class).forEach((item, enchants) -> { + EnchantUtils.getEquipped(entity, SaturationEnchant.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/EnchantSonic.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SpeedyEnchant.java similarity index 83% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSonic.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SpeedyEnchant.java index 9e97483..116c70d 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/SpeedyEnchant.java @@ -7,20 +7,19 @@ 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.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantSonic extends ExcellentEnchant implements Potioned, PassiveEnchant { +public class SpeedyEnchant extends ExcellentEnchant implements Potioned, PassiveEnchant { public static final String ID = "sonic"; private PotionImplementation potionImplementation; - public EnchantSonic(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public SpeedyEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription("Grants permanent " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " effect."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.3); @@ -46,8 +45,6 @@ public class EnchantSonic extends ExcellentEnchant implements Potioned, PassiveE @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(entity)) return false; - return this.addEffect(entity, level); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/StoppingForceEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/StoppingForceEnchant.java index 87db573..e111910 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/StoppingForceEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/StoppingForceEnchant.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.armor; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -13,7 +14,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 StoppingForceEnchant extends ExcellentEnchant implements Chanced, CombatEnchant { @@ -25,7 +25,7 @@ public class StoppingForceEnchant extends ExcellentEnchant implements Chanced, C private EnchantScaler knockbackModifier; public StoppingForceEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to resist knockback in combat by " + PLACEHOLDER_KNOCKBACK_RESISTANCE + "%."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.5); @@ -52,6 +52,12 @@ public class StoppingForceEnchant extends ExcellentEnchant implements Chanced, C return EnchantmentTarget.ARMOR_LEGS; } + @NotNull + @Override + public EventPriority getProtectPriority() { + return EventPriority.HIGHEST; + } + @NotNull @Override public Chanced getChanceImplementation() { @@ -65,7 +71,6 @@ public class StoppingForceEnchant extends ExcellentEnchant implements Chanced, C @Override public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(victim)) return false; if (!this.checkTriggerChance(level)) return false; this.plugin.runTask(task -> { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java index 9910666..d2cc8d1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java @@ -23,7 +23,6 @@ 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.impl.meta.PotionImplementation; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class DarknessArrowsEnchant extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { @@ -34,7 +33,7 @@ public class DarknessArrowsEnchant extends ExcellentEnchant implements Chanced, private PotionImplementation potionImplementation; public DarknessArrowsEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -78,7 +77,6 @@ public class DarknessArrowsEnchant extends ExcellentEnchant implements Chanced, @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isAvailableToUse(shooter)) return false; if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; @@ -87,12 +85,12 @@ public class DarknessArrowsEnchant extends ExcellentEnchant implements Chanced, } @Override - public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { - return this.isOurProjectile(projectile); + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return false; } @Override public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - return this.isOurProjectile(projectile); + return false; } } 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 1a15d85..037f547 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 @@ -5,6 +5,7 @@ import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; @@ -18,7 +19,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; 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 EnchantBomber extends ExcellentEnchant implements Chanced, BowEnchant { @@ -29,7 +29,7 @@ public class EnchantBomber extends ExcellentEnchant implements Chanced, BowEncha private ChanceImplementation chanceImplementation; public EnchantBomber(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.HIGHEST); + super(plugin, ID); 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); @@ -73,9 +73,14 @@ public class EnchantBomber extends ExcellentEnchant implements Chanced, BowEncha return EnchantmentTarget.BOW; } + @NotNull + @Override + public EventPriority getShootPriority() { + return EventPriority.LOWEST; + } + @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isAvailableToUse(shooter)) return false; if (!this.checkTriggerChance(level)) return false; if (!(event.getProjectile() instanceof Projectile projectile)) return false; @@ -88,7 +93,7 @@ public class EnchantBomber extends ExcellentEnchant implements Chanced, BowEncha } @Override - public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return false; } 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 0480ecc..d830c10 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 @@ -23,7 +23,6 @@ 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.impl.meta.PotionImplementation; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { @@ -34,7 +33,7 @@ public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, private PotionImplementation potionImplementation; public EnchantConfusingArrows(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -78,7 +77,6 @@ public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isAvailableToUse(shooter)) return false; if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; @@ -87,12 +85,12 @@ public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, } @Override - public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { - return this.isOurProjectile(projectile); + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return false; } @Override public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - return this.isOurProjectile(projectile); + return false; } } 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 1ea26f0..15bfd31 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 @@ -31,7 +31,6 @@ import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; 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 EnchantDragonfireArrows extends ExcellentEnchant implements Chanced, Arrowed, BowEnchant { @@ -47,7 +46,7 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced private ChanceImplementation chanceImplementation; public EnchantDragonfireArrows(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -99,19 +98,17 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isAvailableToUse(shooter)) return false; - return this.checkTriggerChance(level); } @Override - public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { if (!this.isOurProjectile(projectile)) return false; if (event.getHitEntity() != null) return false; if (projectile.getShooter() == null) return false; this.createCloud(projectile.getShooter(), projectile.getLocation() , level); - return true; + return false; } @Override @@ -119,7 +116,7 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced if (!this.isOurProjectile(projectile)) return false; this.createCloud(shooter, victim.getLocation(), level); - return true; + return false; } private void createCloud(@NotNull ProjectileSource shooter, @NotNull Location location, int level) { 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 292f32d..d86aab8 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 @@ -26,7 +26,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; 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 { @@ -38,7 +37,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance private ChanceImplementation chanceImplementation; public EnchantElectrifiedArrows(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an electrified arrow."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.3); @@ -73,13 +72,11 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isAvailableToUse(shooter)) return false; - return this.checkTriggerChance(level); } @Override - public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { if (!this.isOurProjectile(projectile)) return false; if (event.getHitEntity() != null || event.getHitBlock() == null) return false; @@ -90,7 +87,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance UniParticle.blockCrack(block.getType()).play(center, 1, 0.05, 120); UniParticle.of(Particle.FIREWORKS_SPARK).play(center, 1, 0.05, 120); } - return true; + return false; } @Override @@ -103,7 +100,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance victim.getWorld().strikeLightning(victim.getLocation()).setMetadata(META_NO_ITEM_DAMAGE, new FixedMetadataValue(plugin, true)); }); - return true; + return false; } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = 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 795ff07..de01b2f 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 @@ -5,16 +5,16 @@ import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.EnderPearl; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityShootBowEvent; 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Chanced { @@ -24,7 +24,7 @@ public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Cha private ChanceImplementation chanceImplementation; public EnchantEnderBow(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.HIGHEST); + super(plugin, ID); this.getDefaults().setDescription("Shoots ender pearls instead of arrows."); this.getDefaults().setLevelMax(1); this.getDefaults().setTier(1.0); @@ -59,9 +59,14 @@ public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Cha return EnchantmentTarget.BOW; } + @NotNull + @Override + public EventPriority getShootPriority() { + return EventPriority.LOWEST; + } + @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isAvailableToUse(shooter)) return false; if (!this.checkTriggerChance(level)) return false; if (!(event.getProjectile() instanceof Projectile projectile)) return false; @@ -72,7 +77,7 @@ public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Cha } @Override - public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return false; } 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 29bfbf4..8cedd07 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 @@ -11,7 +11,6 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityShootBowEvent; 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.api.config.JOption; import su.nexmedia.engine.utils.NumberUtil; @@ -25,15 +24,12 @@ import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; 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 EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, Arrowed, BowEnchant { public static final String ID = "explosive_arrows"; public static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; - private static final String META_EXPLOSION_SOURCE = ID + "_source"; - private boolean explosionFireSpread; private boolean explosionDamageItems; private boolean explosionDamageBlocks; @@ -42,8 +38,10 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, private ArrowImplementation arrowImplementation; private ChanceImplementation chanceImplementation; + private Entity lastExploder; + public EnchantExplosiveArrows(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an explosive arrow."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.7); @@ -101,43 +99,39 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isAvailableToUse(shooter)) return false; - return this.checkTriggerChance(level); } @Override - public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { if (!this.isOurProjectile(projectile)) return false; - Entity shooter = null; if (projectile.getShooter() instanceof Entity entity) { - shooter = entity; - shooter.setMetadata(META_EXPLOSION_SOURCE, new FixedMetadataValue(this.plugin, true)); + this.lastExploder = entity; } World world = projectile.getWorld(); float explSize = (float) this.getExplosionSize(level); boolean explFire = this.isExplosionFireSpread(); boolean explBlocks = this.isExplosionDamageBlocks(); - boolean exploded = world.createExplosion(projectile.getLocation(), explSize, explFire, explBlocks, shooter); - if (shooter != null) shooter.removeMetadata(META_EXPLOSION_SOURCE, this.plugin); - return exploded; + boolean exploded = world.createExplosion(projectile.getLocation(), explSize, explFire, explBlocks, this.lastExploder); + this.lastExploder = null; + return false; } @Override public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - return this.isOurProjectile(projectile); + return false; } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onItemDamage(EntityDamageByEntityEvent e) { - if (e.getCause() != EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) return; + public void onItemDamage(EntityDamageByEntityEvent event) { + if (event.getCause() != EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) return; if (this.explosionDamageItems) return; - if (!e.getDamager().hasMetadata(META_EXPLOSION_SOURCE)) return; + if (this.lastExploder == null || this.lastExploder != event.getDamager()) return; - if (e.getEntity() instanceof Item || e.getEntity() instanceof ItemFrame) { - e.setCancelled(true); + if (event.getEntity() instanceof Item || event.getEntity() instanceof ItemFrame) { + event.setCancelled(true); } } } 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 949a0f1..9d54165 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 @@ -6,6 +6,7 @@ import org.bukkit.entity.Fireball; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.entity.SmallFireball; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; @@ -14,11 +15,10 @@ 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; 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.EnchantUtils; @@ -31,7 +31,7 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance private ChanceImplementation chanceImplementation; public EnchantGhast(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.HIGHEST); + super(plugin, ID); this.getDefaults().setDescription("Shoots fireballs instead of arrows."); this.getDefaults().setLevelMax(1); this.getDefaults().setTier(0.3); @@ -78,9 +78,14 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance return EnchantmentTarget.BOW; } + @NotNull + @Override + public EventPriority getShootPriority() { + return EventPriority.LOWEST; + } + @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isAvailableToUse(shooter)) return false; if (!this.checkTriggerChance(level)) return false; if (!(event.getProjectile() instanceof Projectile projectile)) return false; @@ -104,7 +109,7 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance } @Override - public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return false; } 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 f2dba34..440fda4 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 @@ -23,7 +23,6 @@ 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.impl.meta.PotionImplementation; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { @@ -34,7 +33,7 @@ public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, private PotionImplementation potionImplementation; public EnchantHover(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -78,7 +77,6 @@ public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isAvailableToUse(shooter)) return false; if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; @@ -87,12 +85,12 @@ public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, } @Override - public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { - return this.isOurProjectile(projectile); + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return false; } @Override public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - return this.isOurProjectile(projectile); + return false; } } 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 430634e..e56fd82 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 @@ -23,7 +23,6 @@ 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.impl.meta.PotionImplementation; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { @@ -34,7 +33,7 @@ public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, private PotionImplementation potionImplementation; public EnchantPoisonedArrows(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -78,7 +77,6 @@ public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isAvailableToUse(shooter)) return false; if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; @@ -87,12 +85,12 @@ public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, } @Override - public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { - return this.isOurProjectile(projectile); + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return false; } @Override public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - return this.isOurProjectile(projectile); + return false; } } 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 65de8eb..6f22ad3 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 @@ -23,7 +23,6 @@ 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.impl.meta.PotionImplementation; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { @@ -34,7 +33,7 @@ public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, private PotionImplementation potionImplementation; public EnchantWitheredArrows(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -78,7 +77,6 @@ public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isAvailableToUse(shooter)) return false; if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!this.checkTriggerChance(level)) return false; @@ -87,12 +85,12 @@ public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, } @Override - public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { - return this.isOurProjectile(projectile); + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return false; } @Override public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - return this.isOurProjectile(projectile); + return false; } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java index 3d110a6..5438f90 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/FlareEnchant.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityShootBowEvent; @@ -26,7 +27,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; 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 FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed, BowEnchant { @@ -36,7 +36,7 @@ public class FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed, private ArrowImplementation arrowImplementation; public FlareEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.LOWEST); + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to create a torch where arrow lands."); this.getDefaults().setLevelMax(1); @@ -56,6 +56,12 @@ public class FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed, return EnchantmentTarget.BOW; } + @NotNull + @Override + public EventPriority getHitPriority() { + return EventPriority.HIGHEST; + } + @NotNull @Override public Chanced getChanceImplementation() { @@ -71,7 +77,6 @@ public class FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed, @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { if (!(event.getProjectile() instanceof Arrow arrow)) return false; - if (!this.isAvailableToUse(shooter)) return false; if (!this.checkTriggerChance(level)) return false; this.addData(arrow); @@ -79,7 +84,7 @@ public class FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed, } @Override - public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent e, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { Block block = e.getHitBlock(); if (block == null) return false; @@ -106,7 +111,7 @@ public class FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed, relative.setBlockData(directional, true); } - return true; + return false; } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/SniperEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/SniperEnchant.java index 6fc6e77..2be71dc 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/SniperEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/SniperEnchant.java @@ -4,6 +4,7 @@ import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; @@ -18,7 +19,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; 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 SniperEnchant extends ExcellentEnchant implements BowEnchant, Chanced { @@ -30,7 +30,7 @@ public class SniperEnchant extends ExcellentEnchant implements BowEnchant, Chanc private EnchantScaler speedModifier; public SniperEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.LOWEST); + super(plugin, ID); this.getDefaults().setDescription("Increases projectile speed by " + PLACEHOLDER_PROJECTILE_SPEED + "%"); this.getDefaults().setLevelMax(5); @@ -48,6 +48,12 @@ public class SniperEnchant extends ExcellentEnchant implements BowEnchant, Chanc this.addPlaceholder(PLACEHOLDER_PROJECTILE_SPEED, level -> NumberUtil.format(this.getSpeedModifier(level) * 100D)); } + @NotNull + @Override + public Chanced getChanceImplementation() { + return this.chanceImplementation; + } + public double getSpeedModifier(int level) { return this.speedModifier.getValue(level); } @@ -60,13 +66,12 @@ public class SniperEnchant extends ExcellentEnchant implements BowEnchant, Chanc @NotNull @Override - public Chanced getChanceImplementation() { - return this.chanceImplementation; + public EventPriority getShootPriority() { + return EventPriority.LOWEST; } @Override public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { - if (!this.isAvailableToUse(shooter)) return false; if (!this.checkTriggerChance(level)) return false; double modifier = this.getSpeedModifier(level); @@ -79,7 +84,7 @@ public class SniperEnchant extends ExcellentEnchant implements BowEnchant, Chanc } @Override - public boolean onHit(@NotNull ProjectileHitEvent event, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { return false; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoReelEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoReelEnchant.java index 4e13cde..f5d8808 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoReelEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/AutoReelEnchant.java @@ -7,14 +7,13 @@ import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class AutoReelEnchant extends ExcellentEnchant implements FishingEnchant { public static final String ID = "auto_reel"; public AutoReelEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription("Automatically reels in a hook on bite."); this.getDefaults().setLevelMax(1); this.getDefaults().setTier(1.0); @@ -29,7 +28,6 @@ public class AutoReelEnchant extends ExcellentEnchant implements FishingEnchant @Override public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { if (event.getState() != PlayerFishEvent.State.BITE) return false; - if (!this.isAvailableToUse(event.getPlayer())) return false; this.plugin.runTask(task -> { if (event.isCancelled()) return; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java index 5486825..9a6d510 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/CurseOfDrownedEnchant.java @@ -16,7 +16,6 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class CurseOfDrownedEnchant extends ExcellentEnchant implements FishingEnchant, Chanced { @@ -25,7 +24,7 @@ public class CurseOfDrownedEnchant extends ExcellentEnchant implements FishingEn private ChanceImplementation chanceImplementation; public CurseOfDrownedEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.HIGHEST); + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to fish up a Drowned Zombie."); this.getDefaults().setLevelMax(5); this.getDefaults().setTier(0D); @@ -53,7 +52,6 @@ public class CurseOfDrownedEnchant extends ExcellentEnchant implements FishingEn @Override public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return false; - if (!this.isAvailableToUse(event.getPlayer())) return false; if (!this.checkTriggerChance(level)) return false; FishHook hook = event.getHook(); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/DoubleCatchEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/DoubleCatchEnchant.java index f793cbf..a2b9e4b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/DoubleCatchEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/DoubleCatchEnchant.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.fishing; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Item; +import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -11,7 +12,6 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class DoubleCatchEnchant extends ExcellentEnchant implements FishingEnchant, Chanced { @@ -20,7 +20,7 @@ public class DoubleCatchEnchant extends ExcellentEnchant implements FishingEncha private ChanceImplementation chanceImplementation; public DoubleCatchEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.LOWEST); + super(plugin, ID); this.getDefaults().setDescription("Increases amount of caught item by x2 with " + Placeholders.ENCHANTMENT_CHANCE + "% chance."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.5); @@ -39,6 +39,12 @@ public class DoubleCatchEnchant extends ExcellentEnchant implements FishingEncha return EnchantmentTarget.FISHING_ROD; } + @NotNull + @Override + public EventPriority getFishingPriority() { + return EventPriority.HIGHEST; + } + @Override @NotNull public ChanceImplementation getChanceImplementation() { @@ -49,7 +55,6 @@ public class DoubleCatchEnchant extends ExcellentEnchant implements FishingEncha public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return false; if (!(event.getCaught() instanceof Item drop)) return false; - if (!this.isAvailableToUse(event.getPlayer())) return false; if (!this.checkTriggerChance(level)) return false; ItemStack stack = drop.getItemStack(); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/RiverMasterEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/RiverMasterEnchant.java index b339ecc..67a2666 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/RiverMasterEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/RiverMasterEnchant.java @@ -8,21 +8,22 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.manager.EventListener; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; 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; -public class RiverMasterEnchant extends ExcellentEnchant { +public class RiverMasterEnchant extends ExcellentEnchant implements GenericEnchant, EventListener { public static final String ID = "river_master"; private EnchantScaler distanceMod; public RiverMasterEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription("Increases casting distance."); this.getDefaults().setLevelMax(5); this.getDefaults().setTier(0.1); @@ -51,7 +52,6 @@ public class RiverMasterEnchant extends ExcellentEnchant { public void onHookLaunch(ProjectileLaunchEvent event) { if (!(event.getEntity() instanceof FishHook hook)) return; if (!(hook.getShooter() instanceof Player player)) return; - if (!this.isAvailableToUse(player)) return; ItemStack rod = EnchantUtils.getFishingRod(player); if (rod == null) return; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SeasonedAnglerEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SeasonedAnglerEnchant.java index 7a2d0c5..ce3f0e3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SeasonedAnglerEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SeasonedAnglerEnchant.java @@ -10,7 +10,6 @@ import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class SeasonedAnglerEnchant extends ExcellentEnchant implements FishingEnchant { @@ -19,7 +18,7 @@ public class SeasonedAnglerEnchant extends ExcellentEnchant implements FishingEn private EnchantScaler expMod; public SeasonedAnglerEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription("Increases amount of XP gained from fishing by " + Placeholders.GENERIC_AMOUNT + "%."); this.getDefaults().setLevelMax(4); this.getDefaults().setTier(0.1); @@ -48,7 +47,6 @@ public class SeasonedAnglerEnchant extends ExcellentEnchant implements FishingEn @Override public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return false; - if (!this.isAvailableToUse(event.getPlayer())) return false; if (event.getExpToDrop() == 0) return false; int expDrop = event.getExpToDrop(); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SurvivalistEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SurvivalistEnchant.java index e40c3c0..3729622 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SurvivalistEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/fishing/SurvivalistEnchant.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.fishing; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Item; +import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.inventory.CookingRecipe; import org.bukkit.inventory.ItemStack; @@ -11,7 +12,6 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; 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.HashSet; import java.util.Set; @@ -25,7 +25,7 @@ public class SurvivalistEnchant extends ExcellentEnchant implements FishingEncha private ChanceImplementation chanceImplementation; public SurvivalistEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.HIGH); + super(plugin, ID); this.getDefaults().setDescription("Automatically cooks fish if what is caught is raw."); this.getDefaults().setLevelMax(1); this.getDefaults().setTier(0.4); @@ -58,10 +58,15 @@ public class SurvivalistEnchant extends ExcellentEnchant implements FishingEncha return EnchantmentTarget.FISHING_ROD; } + @NotNull + @Override + public EventPriority getFishingPriority() { + return EventPriority.HIGH; + } + @Override public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return false; - if (!this.isAvailableToUse(event.getPlayer())) return false; if (!this.checkTriggerChance(level)) return false; if (!(event.getCaught() instanceof Item drop)) return false; 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 165121b..c1bad7f 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,9 +2,9 @@ package su.nightexpress.excellentenchants.enchantment.impl.meta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.utils.random.Rnd; -import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; public final class ChanceImplementation implements Chanced { 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 5f8f885..9ec91f2 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,10 +6,10 @@ 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; public final class PotionImplementation implements Potioned { 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/BlastMiningEnchant.java similarity index 91% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantBlastMining.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/BlastMiningEnchant.java index 8c0042d..4f5af6d 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/BlastMiningEnchant.java @@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.block.Block; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -12,6 +13,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.manager.EventListener; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; @@ -21,13 +23,12 @@ 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.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.List; -public class EnchantBlastMining extends ExcellentEnchant implements Chanced, BlockBreakEnchant { +public class BlastMiningEnchant extends ExcellentEnchant implements Chanced, BlockBreakEnchant, EventListener { public static final String ID = "blast_mining"; public static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%"; @@ -38,12 +39,12 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo private int explodeLevel; - public EnchantBlastMining(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public BlastMiningEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); 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); + this.getDefaults().setConflicts(VeinminerEnchant.ID, TunnelEnchant.ID); } @Override @@ -98,8 +99,8 @@ public class EnchantBlastMining extends ExcellentEnchant implements Chanced, Blo } @Override - public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(player)) return false; + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) { + if (!(entity instanceof Player player)) return false; if (EnchantUtils.isBusy()) return false; Block block = event.getBlock(); 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/CurseOfBreakingEnchant.java similarity index 83% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfBreaking.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfBreakingEnchant.java index bc88ee9..cc0582b 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/CurseOfBreakingEnchant.java @@ -7,17 +7,18 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.manager.EventListener; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; 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 su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; -public class EnchantCurseOfBreaking extends ExcellentEnchant implements Chanced { +public class CurseOfBreakingEnchant extends ExcellentEnchant implements GenericEnchant, EventListener, Chanced { public static final String ID = "curse_of_breaking"; public static final String PLACEHOLDER_DURABILITY_AMOUNT = "%enchantment_durability_amount%"; @@ -25,8 +26,8 @@ public class EnchantCurseOfBreaking extends ExcellentEnchant implements Chanced private EnchantScaler durabilityAmount; private ChanceImplementation chanceImplementation; - public EnchantCurseOfBreaking(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public CurseOfBreakingEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to consume extra " + PLACEHOLDER_DURABILITY_AMOUNT + " durability points."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0D); @@ -66,11 +67,11 @@ public class EnchantCurseOfBreaking extends ExcellentEnchant implements Chanced } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void onItemDurability(PlayerItemDamageEvent e) { - Player player = e.getPlayer(); + public void onItemDurability(PlayerItemDamageEvent event) { + Player player = event.getPlayer(); if (!this.isAvailableToUse(player)) return; - ItemStack item = e.getItem(); + ItemStack item = event.getItem(); int level = EnchantUtils.getLevel(item, this); if (level < 1) return; @@ -79,6 +80,6 @@ public class EnchantCurseOfBreaking extends ExcellentEnchant implements Chanced int durabilityAmount = this.getDurabilityAmount(level); if (durabilityAmount <= 0) return; - e.setDamage(e.getDamage() + durabilityAmount); + event.setDamage(event.getDamage() + durabilityAmount); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java index 6607314..d167001 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; @@ -16,7 +17,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; 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.EnchantPriority; public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chanced, BlockDropEnchant, DeathEnchant { @@ -25,7 +25,7 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance private ChanceImplementation chanceImplementation; public CurseOfMediocrityEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.LOWEST); + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to disenchant item drops."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0D); @@ -49,6 +49,12 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance return new FitItemType[] {FitItemType.WEAPON, FitItemType.TOOL}; } + @NotNull + @Override + public EventPriority getDropPriority() { + return EventPriority.HIGHEST; + } + @NotNull @Override public Chanced getChanceImplementation() { @@ -62,8 +68,7 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance @Override public boolean onDrop(@NotNull BlockDropItemEvent event, - @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(player)) return false; + @NotNull LivingEntity player, @NotNull ItemStack item, int level) { if (!this.checkTriggerChance(level)) return false; event.getItems().forEach(drop -> { @@ -84,7 +89,6 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance @Override public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { - if (!this.isAvailableToUse(killer)) return false; if (!this.checkTriggerChance(level)) return false; event.getDrops().forEach(stack -> { 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/CurseOfMisfortuneEnchant.java similarity index 86% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfMisfortune.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMisfortuneEnchant.java index 7e4098f..683f37c 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/CurseOfMisfortuneEnchant.java @@ -4,6 +4,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; @@ -11,23 +12,22 @@ 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.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.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; -public class EnchantCurseOfMisfortune extends ExcellentEnchant implements Chanced, BlockBreakEnchant, DeathEnchant { +public class CurseOfMisfortuneEnchant extends ExcellentEnchant implements Chanced, BlockBreakEnchant, DeathEnchant { public static final String ID = "curse_of_misfortune"; private boolean dropExp; private ChanceImplementation chanceImplementation; - public EnchantCurseOfMisfortune(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.LOWEST); + public CurseOfMisfortuneEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to have no drops from blocks or mobs."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0D); @@ -68,14 +68,25 @@ public class EnchantCurseOfMisfortune extends ExcellentEnchant implements Chance return EnchantmentTarget.BREAKABLE; } + @NotNull + @Override + public EventPriority getBreakPriority() { + return EventPriority.HIGHEST; + } + + @NotNull + @Override + public EventPriority getKillPriority() { + return EventPriority.HIGH; + } + @Override public boolean isCursed() { return true; } @Override - public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(player)) return false; + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity player, @NotNull ItemStack item, int level) { if (!this.checkTriggerChance(level)) return false; event.setDropItems(false); @@ -85,7 +96,6 @@ public class EnchantCurseOfMisfortune extends ExcellentEnchant implements Chance @Override public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { - if (!this.isAvailableToUse(killer)) return false; if (!this.checkTriggerChance(level)) return false; event.getDrops().clear(); 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/DivineTouchEnchant.java similarity index 80% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantDivineTouch.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/DivineTouchEnchant.java index d9871c2..a3f649d 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/DivineTouchEnchant.java @@ -8,6 +8,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.CreatureSpawner; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -16,10 +17,12 @@ import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; 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.manager.EventListener; +import su.nexmedia.engine.lang.LangManager; import su.nexmedia.engine.utils.Colorizer; +import su.nexmedia.engine.utils.Colors; import su.nexmedia.engine.utils.LocationUtil; import su.nexmedia.engine.utils.PDCUtil; import su.nexmedia.engine.utils.values.UniParticle; @@ -31,39 +34,41 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; 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.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; -public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, BlockBreakEnchant, BlockDropEnchant { +public class DivineTouchEnchant extends ExcellentEnchant implements Chanced, BlockBreakEnchant, BlockDropEnchant, EventListener { public static final String ID = "divine_touch"; - private static final String META_HANDLE = ID + "_handle"; + + private final NamespacedKey key; private String spawnerName; private ChanceImplementation chanceImplementation; - private final NamespacedKey key; + private Location handleSpawner; - public EnchantDivineTouch(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public DivineTouchEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.key = new NamespacedKey(plugin, "divine_spawner"); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to mine spawner."); this.getDefaults().setLevelMax(5); this.getDefaults().setTier(1.0); - this.getDefaults().setConflicts(EnchantSmelter.ID); + this.getDefaults().setConflicts(SmelterEnchant.ID); } @Override public void loadSettings() { super.loadSettings(); + this.chanceImplementation = ChanceImplementation.create(this, "15.0 * " + Placeholders.ENCHANTMENT_LEVEL); + this.spawnerName = JOption.create("Settings.Spawner_Item.Name", - "&aMob Spawner &7(" + Placeholders.GENERIC_TYPE + ")", + Colors.GREEN + "Mob Spawner " + Colors.GRAY + "(" + Placeholders.GENERIC_TYPE + ")", "Spawner item display name.", - "Placeholder '" + Placeholders.GENERIC_TYPE + "' for the mob type.") - .mapReader(Colorizer::apply).read(cfg); + "Placeholder '" + Placeholders.GENERIC_TYPE + "' for the mob type." + ).mapReader(Colorizer::apply).read(cfg); } @NotNull @@ -84,6 +89,18 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo return EnchantmentTarget.TOOL; } + @NotNull + @Override + public EventPriority getDropPriority() { + return EventPriority.NORMAL; + } + + @NotNull + @Override + public EventPriority getBreakPriority() { + return EventPriority.HIGH; + } + @NotNull public ItemStack getSpawner(@NotNull CreatureSpawner spawnerBlock) { ItemStack itemSpawner = new ItemStack(Material.SPAWNER); @@ -94,7 +111,7 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo spawnerItem.setSpawnedType(spawnerBlock.getSpawnedType()); spawnerItem.update(true); stateItem.setBlockState(spawnerItem); - stateItem.setDisplayName(this.spawnerName.replace(Placeholders.GENERIC_TYPE, plugin.getLangManager().getEnum(spawnerBlock.getSpawnedType()))); + stateItem.setDisplayName(this.spawnerName.replace(Placeholders.GENERIC_TYPE, LangManager.getEntityType(spawnerBlock.getSpawnedType()))); itemSpawner.setItemMeta(stateItem); PDCUtil.set(itemSpawner, this.key, true); @@ -102,10 +119,12 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo } @Override - public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull LivingEntity player, @NotNull ItemStack item, int level) { BlockState state = event.getBlockState(); Block block = state.getBlock(); - if (!block.hasMetadata(META_HANDLE)) return false; + if (this.handleSpawner == null || !this.handleSpawner.equals(block.getLocation())) return false; + this.handleSpawner = null; + if (!(state instanceof CreatureSpawner spawnerBlock)) return false; EnchantUtils.popResource(event, this.getSpawner(spawnerBlock)); @@ -114,20 +133,18 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo Location location = LocationUtil.getCenter(block.getLocation()); UniParticle.of(Particle.VILLAGER_HAPPY).play(location, 0.3, 0.15, 30); } - block.removeMetadata(META_HANDLE, this.plugin); return true; } @Override - public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity player, @NotNull ItemStack item, int level) { Block block = event.getBlock(); - if (!this.isAvailableToUse(player)) return false; if (!(block.getState() instanceof CreatureSpawner spawnerBlock)) return false; if (!this.checkTriggerChance(level)) return false; event.setExpToDrop(0); event.setDropItems(true); - block.setMetadata(META_HANDLE, new FixedMetadataValue(this.plugin, true)); + this.handleSpawner = block.getLocation(); return false; // Do not consume charges } 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/HasteEnchant.java similarity index 84% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantHaste.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/HasteEnchant.java index 2ed436e..4fd578b 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/HasteEnchant.java @@ -7,20 +7,19 @@ 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.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; -public class EnchantHaste extends ExcellentEnchant implements Potioned, PassiveEnchant { +public class HasteEnchant extends ExcellentEnchant implements Potioned, PassiveEnchant { public static final String ID = "haste"; private PotionImplementation potionImplementation; - public EnchantHaste(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public HasteEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription("Grants permanent " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " effect."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.3); @@ -46,8 +45,6 @@ public class EnchantHaste extends ExcellentEnchant implements Potioned, PassiveE @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(entity)) return false; - return this.addEffect(entity, level); } } 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/LuckyMinerEnchant.java similarity index 87% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantLuckyMiner.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/LuckyMinerEnchant.java index 0c559cd..0a90278 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/LuckyMinerEnchant.java @@ -1,7 +1,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.Player; +import org.bukkit.entity.LivingEntity; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -14,9 +14,8 @@ 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.type.FitItemType; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; -public class EnchantLuckyMiner extends ExcellentEnchant implements Chanced, BlockBreakEnchant { +public class LuckyMinerEnchant extends ExcellentEnchant implements Chanced, BlockBreakEnchant { public static final String ID = "lucky_miner"; private static final String PLACEHOLDER_EXP_MODIFIER = "%enchantment_exp_modifier%"; @@ -24,8 +23,8 @@ public class EnchantLuckyMiner extends ExcellentEnchant implements Chanced, Bloc private EnchantScaler expModifier; private ChanceImplementation chanceImplementation; - public EnchantLuckyMiner(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public LuckyMinerEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); 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); @@ -66,8 +65,7 @@ public class EnchantLuckyMiner extends ExcellentEnchant implements Chanced, Bloc } @Override - public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(player)) return false; + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity player, @NotNull ItemStack item, int level) { if (!this.checkTriggerChance(level)) return false; double expMod = this.getExpModifier(level); 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/ReplanterEnchant.java similarity index 92% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantReplanter.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/ReplanterEnchant.java index 54cf16b..9d09522 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/ReplanterEnchant.java @@ -7,7 +7,9 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.data.Ageable; import org.bukkit.block.data.BlockData; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -23,11 +25,10 @@ import su.nightexpress.excellentenchants.api.enchantment.type.InteractEnchant; 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.EnchantPriority; import java.util.Set; -public class EnchantReplanter extends ExcellentEnchant implements Chanced, InteractEnchant, BlockBreakEnchant { +public class ReplanterEnchant extends ExcellentEnchant implements Chanced, InteractEnchant, BlockBreakEnchant { public static final String ID = "replanter"; @@ -41,8 +42,8 @@ public class EnchantReplanter extends ExcellentEnchant implements Chanced, Inter Material.MELON_SEEDS, Material.PUMPKIN_SEEDS, Material.POTATO, Material.CARROT, Material.NETHER_WART); - public EnchantReplanter(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.HIGH); + public ReplanterEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription("Automatically replant crops on right click and when harvest."); this.getDefaults().setLevelMax(1); this.getDefaults().setTier(0.3); @@ -119,10 +120,16 @@ public class EnchantReplanter extends ExcellentEnchant implements Chanced, Inter return EnchantmentTarget.TOOL; } + @NotNull @Override - public boolean onInteract(@NotNull PlayerInteractEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { + public EventPriority getInteractPriority() { + return EventPriority.HIGHEST; + } + + @Override + public boolean onInteract(@NotNull PlayerInteractEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) { + if (!(entity instanceof Player player)) return false; if (!this.isReplantOnRightClick()) return false; - if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; // Check for a event hand. We dont want to trigger it twice. @@ -158,9 +165,9 @@ public class EnchantReplanter extends ExcellentEnchant implements Chanced, Inter } @Override - public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) { + if (!(entity instanceof Player player)) return false; if (!this.isReplantOnPlantBreak()) return false; - if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; Block blockPlant = event.getBlock(); 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/SilkChestEnchant.java similarity index 93% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/SilkChestEnchant.java index f00a733..78b0f2e 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/SilkChestEnchant.java @@ -6,6 +6,7 @@ import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -20,6 +21,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BlockStateMeta; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; +import su.nexmedia.engine.api.manager.EventListener; import su.nexmedia.engine.utils.Colorizer; import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PDCUtil; @@ -28,14 +30,13 @@ import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; 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 java.util.ArrayList; import java.util.List; import java.util.stream.Stream; -public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEnchant { +public class SilkChestEnchant extends ExcellentEnchant implements BlockDropEnchant, EventListener { public static final String ID = "silk_chest"; @@ -43,8 +44,8 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha private List chestLore; private final NamespacedKey keyChest; - public EnchantSilkChest(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.HIGH); + public SilkChestEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription("Drop chests and saves all its content."); this.getDefaults().setLevelMax(1); this.getDefaults().setTier(0.5); @@ -75,6 +76,12 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha return EnchantmentTarget.TOOL; } + @NotNull + @Override + public EventPriority getDropPriority() { + return EventPriority.NORMAL; + } + public boolean isSilkChest(@NotNull ItemStack item) { return PDCUtil.getBoolean(item, this.keyChest).isPresent(); } @@ -131,11 +138,10 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha @Override public boolean onDrop(@NotNull BlockDropItemEvent event, - @NotNull Player player, @NotNull ItemStack item, int level) { + @NotNull LivingEntity player, @NotNull ItemStack item, int level) { BlockState state = event.getBlockState(); Block block = state.getBlock(); - if (!this.isAvailableToUse(player)) return false; if (!(state instanceof Chest chest)) return false; // Добавляем в сундук обратно предметы из дроп листа, кроме самого сундука. 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/SmelterEnchant.java similarity index 91% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSmelter.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/SmelterEnchant.java index 1f771cb..13d347c 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/SmelterEnchant.java @@ -8,7 +8,8 @@ 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.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -23,11 +24,10 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; 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.EnchantPriority; import java.util.Map; -public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDropEnchant { +public class SmelterEnchant extends ExcellentEnchant implements Chanced, BlockDropEnchant { public static final String ID = "smelter"; @@ -35,13 +35,13 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr private Map smeltingTable; private ChanceImplementation chanceImplementation; - public EnchantSmelter(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public SmelterEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); 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, + DivineTouchEnchant.ID, Enchantment.SILK_TOUCH.getKey().getKey() ); } @@ -88,12 +88,17 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr return EnchantmentTarget.TOOL; } + @NotNull @Override - public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { + public EventPriority getDropPriority() { + return EventPriority.NORMAL; + } + + @Override + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull LivingEntity player, @NotNull ItemStack item, int level) { // TODO Use furnace recipes & Re-add smelted items instead of setType if (event.getBlockState() instanceof Container) return false; - if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; if (event.getItems().stream().noneMatch(drop -> this.isSmeltable(drop.getItemStack().getType()))) return false; 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/TelekinesisEnchant.java similarity index 71% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTelekinesis.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/TelekinesisEnchant.java index 756224f..2888a2a 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/TelekinesisEnchant.java @@ -1,8 +1,9 @@ package su.nightexpress.excellentenchants.enchantment.impl.tool; import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -13,19 +14,15 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; 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.EnchantPriority; -import java.util.ArrayList; -import java.util.List; - -public class EnchantTelekinesis extends ExcellentEnchant implements Chanced, BlockDropEnchant { +public class TelekinesisEnchant extends ExcellentEnchant implements Chanced, BlockDropEnchant { public static final String ID = "telekinesis"; private ChanceImplementation chanceImplementation; - public EnchantTelekinesis(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.LOWEST); + public TelekinesisEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription("Moves all blocks loot directly to your inventory."); this.getDefaults().setLevelMax(1); this.getDefaults().setTier(0.75); @@ -55,18 +52,21 @@ public class EnchantTelekinesis extends ExcellentEnchant implements Chanced, Blo return EnchantmentTarget.TOOL; } + @NotNull @Override - public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { - if (!this.isAvailableToUse(player)) return false; + public EventPriority getDropPriority() { + return EventPriority.HIGHEST; + } + + @Override + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) { + if (!(entity instanceof Player player)) return false; if (!this.checkTriggerChance(level)) return false; - List drops = new ArrayList<>(event.getItems().stream().map(Item::getItemStack).toList()); - //drops.addAll(dropContainer.getDrop()); - //drops.removeIf(Objects::isNull); - drops.forEach(drop -> PlayerUtil.addItem(player, drop)); - + event.getItems().forEach(drop -> { + PlayerUtil.addItem(player, drop.getItemStack()); + }); event.getItems().clear(); - return true; } } 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/TreasuresEnchant.java similarity index 85% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTreasures.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/TreasuresEnchant.java index 6de1f92..2fc01e7 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/TreasuresEnchant.java @@ -4,11 +4,11 @@ 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.entity.LivingEntity; +import org.bukkit.event.EventPriority; 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.utils.blocktracker.PlayerBlockTracker; import su.nexmedia.engine.utils.random.Rnd; @@ -21,24 +21,24 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; 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.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.*; import java.util.function.Predicate; -public class EnchantTreasures extends ExcellentEnchant implements Chanced, BlockBreakEnchant, BlockDropEnchant, Cleanable { +public class TreasuresEnchant extends ExcellentEnchant implements Chanced, BlockBreakEnchant, BlockDropEnchant, Cleanable { public static final String ID = "treasures"; - @Deprecated private static final String META = "wasted"; + + private final Predicate blockTracker; private Map> treasures; private ChanceImplementation chanceImplementation; - private final Predicate blockTracker; + private Block handleDrop; - public EnchantTreasures(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public TreasuresEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); 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); @@ -126,29 +126,31 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block return EnchantmentTarget.TOOL; } + @NotNull @Override - public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { - if (PlayerBlockTracker.isTracked(event.getBlock())) { - event.getBlock().setMetadata(META, new FixedMetadataValue(plugin, true)); - } + public EventPriority getDropPriority() { + return EventPriority.NORMAL; + } + + @Override + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity player, @NotNull ItemStack item, int level) { + if (!event.isDropItems()) return false; + if (PlayerBlockTracker.isTracked(event.getBlock())) return false; + + this.handleDrop = event.getBlock(); return false; } @Override - public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { - Block block = event.getBlockState().getBlock(); - if (block.hasMetadata(META)) { - block.removeMetadata(META, plugin); - return false; - } - if (!this.isAvailableToUse(player)) return false; + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull LivingEntity player, @NotNull ItemStack item, int level) { + if (this.handleDrop != event.getBlock()) return false; + this.handleDrop = null; + if (!this.checkTriggerChance(level)) return false; this.getTreasures(event.getBlockState().getType()).forEach(treasure -> { EnchantUtils.popResource(event, treasure); }); - - //dropContainer.getDrop().addAll(this.getTreasures(event.getBlockState().getType())); return true; } 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/TunnelEnchant.java similarity index 90% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTunnel.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/TunnelEnchant.java index dc540a7..1bae4ef 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/TunnelEnchant.java @@ -4,17 +4,16 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; -import su.nexmedia.engine.utils.EntityUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; 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; @@ -22,7 +21,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant { +public class TunnelEnchant extends ExcellentEnchant implements BlockBreakEnchant { public static final String ID = "tunnel"; // X and Z offsets for each block AoE mined @@ -36,13 +35,13 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant private boolean disableOnSneak; - public EnchantTunnel(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.HIGH); + public TunnelEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); 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); + this.getDefaults().setConflicts(VeinminerEnchant.ID, BlastMiningEnchant.ID); } @Override @@ -65,9 +64,9 @@ public class EnchantTunnel extends ExcellentEnchant implements BlockBreakEnchant } @Override - public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) { + if (!(entity instanceof Player player)) return false; if (EnchantUtils.isBusy()) return false; - if (!this.isAvailableToUse(player)) return false; if (this.disableOnSneak && player.isSneaking()) return false; Block block = event.getBlock(); 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/VeinminerEnchant.java similarity index 91% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantVeinminer.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/VeinminerEnchant.java index a11e299..7c2bb15 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/VeinminerEnchant.java @@ -5,6 +5,7 @@ import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; @@ -17,7 +18,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; 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; @@ -26,7 +26,7 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnchant { +public class VeinminerEnchant extends ExcellentEnchant implements BlockBreakEnchant { public static final String ID = "veinminer"; @@ -40,13 +40,13 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch private Scaler blocksLimit; private Set blocksAffected; - public EnchantVeinminer(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.HIGH); + public VeinminerEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); 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); + this.getDefaults().setConflicts(BlastMiningEnchant.ID, TunnelEnchant.ID); } @Override @@ -125,8 +125,8 @@ public class EnchantVeinminer extends ExcellentEnchant implements BlockBreakEnch } @Override - public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull Player player, @NotNull ItemStack tool, int level) { - if (!this.isAvailableToUse(player)) return false; + public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity entity, @NotNull ItemStack tool, int level) { + if (!(entity instanceof Player player)) return false; if (EnchantUtils.isBusy()) return false; Block block = event.getBlock(); 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/CurseOfFragilityEnchant.java similarity index 89% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/EnchantCurseOfFragility.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/CurseOfFragilityEnchant.java index 01a729c..9e12173 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/CurseOfFragilityEnchant.java @@ -11,17 +11,18 @@ import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.manager.EventListener; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; 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 { +public class CurseOfFragilityEnchant extends ExcellentEnchant implements GenericEnchant, EventListener { public static final String ID = "curse_of_fragility"; - public EnchantCurseOfFragility(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + public CurseOfFragilityEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); this.getDefaults().setDescription("Prevents an item from being grindstoned or anviled."); this.getDefaults().setLevelMax(1); this.getDefaults().setTier(0D); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java index 99c968a..c68ebf2 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java @@ -9,20 +9,21 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.manager.EventListener; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.ArrayList; import java.util.List; -public class SoulboundEnchant extends ExcellentEnchant { +public class SoulboundEnchant extends ExcellentEnchant implements GenericEnchant, EventListener { public static final String ID = "soulbound"; public SoulboundEnchant(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.LOWEST); + super(plugin, ID); this.getDefaults().setDescription("Protects from being dropped on death."); this.getDefaults().setLevelMax(1); this.getDefaults().setTier(0.8); 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 a9f742d..5c9a91b 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 @@ -15,7 +15,6 @@ import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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; @@ -36,7 +35,7 @@ public class EnchantBaneOfNetherspawn extends ExcellentEnchant implements Combat private EnchantScaler damageFormula; public EnchantBaneOfNetherspawn(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription("Inflicts " + PLACEHOLDER_DAMAGE + " more damage to nether mobs."); this.getDefaults().setLevelMax(5); this.getDefaults().setTier(0.1); @@ -67,7 +66,6 @@ public class EnchantBaneOfNetherspawn extends ExcellentEnchant implements Combat @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { if (!ENTITY_TYPES.contains(victim.getType())) return false; - if (!this.isAvailableToUse(damager)) return false; double damageEvent = event.getDamage(); double damageAdd = this.getDamageModifier(level); 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 3342488..98a9c73 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 @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; @@ -16,7 +17,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 ExcellentEnchant implements Chanced, Potioned, CombatEnchant { @@ -26,7 +26,7 @@ public class EnchantBlindness extends ExcellentEnchant implements Chanced, Potio private PotionImplementation potionImplementation; public EnchantBlindness(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -60,9 +60,14 @@ public class EnchantBlindness extends ExcellentEnchant implements Chanced, Potio return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; 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 5b8acec..6bd0e12 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 @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Material; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; @@ -16,7 +17,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 ExcellentEnchant implements Chanced, Potioned, CombatEnchant { @@ -26,7 +26,7 @@ public class EnchantConfusion extends ExcellentEnchant implements Chanced, Potio private PotionImplementation potionImplementation; public EnchantConfusion(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -60,9 +60,14 @@ public class EnchantConfusion extends ExcellentEnchant implements Chanced, Potio return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; 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 55e1d9e..3422111 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 @@ -4,6 +4,7 @@ import com.google.common.collect.Sets; import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.*; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -14,7 +15,6 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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,7 +27,7 @@ public class EnchantCure extends ExcellentEnchant implements Chanced, CombatEnch private static final Set CUREABLE = Sets.newHashSet(EntityType.ZOMBIFIED_PIGLIN, EntityType.ZOMBIE_VILLAGER); public EnchantCure(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -52,9 +52,14 @@ public class EnchantCure extends ExcellentEnchant implements Chanced, CombatEnch return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(damager)) return false; if (!CUREABLE.contains(victim.getType())) return false; if (!this.checkTriggerChance(level)) return false; if (!(damager instanceof Player player)) return false; 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 bf87080..f7ed994 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 @@ -5,6 +5,7 @@ import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; @@ -23,7 +24,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 EnchantCutter extends ExcellentEnchant implements Chanced, CombatEnchant { @@ -36,7 +36,7 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn private boolean allowMobs; public EnchantCutter(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.LOWEST); + super(plugin, ID); 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); @@ -76,10 +76,14 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(damager)) return false; - EntityEquipment equipment = victim.getEquipment(); if (equipment == null) return false; 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 44201c6..8a90738 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 @@ -29,7 +29,6 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; 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; @@ -48,7 +47,7 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea private final NamespacedKey skullKey; public EnchantDecapitator(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to obtain player''s or mob''s head."); this.getDefaults().setLevelMax(4); this.getDefaults().setTier(0.75); @@ -185,8 +184,6 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea @Override public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { - if (!this.isAvailableToUse(entity)) return false; - EntityType entityType = entity.getType(); if (this.ignoredEntityTypes.contains(entityType)) return false; if (!this.checkTriggerChance(level)) return false; 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 7e26d9f..12f8ede 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 @@ -4,6 +4,7 @@ import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -15,7 +16,6 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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,7 +24,7 @@ public class EnchantDoubleStrike extends ExcellentEnchant implements Chanced, Co private ChanceImplementation chanceImplementation; public EnchantDoubleStrike(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.LOW); + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to inflict double damage."); this.getDefaults().setLevelMax(4); this.getDefaults().setTier(1.0); @@ -49,9 +49,14 @@ public class EnchantDoubleStrike extends ExcellentEnchant implements Chanced, Co return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(damager)) return false; if (!this.checkTriggerChance(level)) return false; event.setDamage(event.getDamage() * 2D); 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 e538f56..38c2f34 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 @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Material; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; @@ -16,7 +17,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 ExcellentEnchant implements Chanced, Potioned, CombatEnchant { @@ -26,7 +26,7 @@ public class EnchantExhaust extends ExcellentEnchant implements Chanced, Potione private PotionImplementation potionImplementation; public EnchantExhaust(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -60,9 +60,14 @@ public class EnchantExhaust extends ExcellentEnchant implements Chanced, Potione return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; 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 64faa91..0217c56 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 @@ -12,7 +12,6 @@ import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantExpHunter extends ExcellentEnchant implements DeathEnchant { @@ -22,7 +21,7 @@ public class EnchantExpHunter extends ExcellentEnchant implements DeathEnchant { private EnchantScaler expModifier; public EnchantExpHunter(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription("Increases exp drop from mobs by " + PLACEHOLDER_EXP_MODIFIER + "%."); this.getDefaults().setLevelMax(5); this.getDefaults().setTier(0.3); @@ -50,8 +49,6 @@ public class EnchantExpHunter extends ExcellentEnchant implements DeathEnchant { @Override public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { - if (!this.isAvailableToUse(entity)) return false; - double expModifier = this.getExpModifier(level); double expFinal = Math.ceil((double) event.getDroppedExp() * expModifier); 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 df2354c..22355c1 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 @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Material; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; @@ -16,7 +17,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 ExcellentEnchant implements Chanced, Potioned, CombatEnchant { @@ -26,7 +26,7 @@ public class EnchantIceAspect extends ExcellentEnchant implements Chanced, Potio private PotionImplementation potionImplementation; public EnchantIceAspect(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -59,9 +59,14 @@ public class EnchantIceAspect extends ExcellentEnchant implements Chanced, Potio return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; 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 b0600c6..734106c 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 @@ -10,15 +10,16 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.manager.EventListener; import su.nexmedia.engine.utils.NumberUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; 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; -public class EnchantInfernus extends ExcellentEnchant { +public class EnchantInfernus extends ExcellentEnchant implements GenericEnchant, EventListener { public static final String ID = "infernus"; public static final String PLACEHOLDER_FIRE_DURATION = "%enchantment_fire_duration%"; @@ -26,7 +27,7 @@ public class EnchantInfernus extends ExcellentEnchant { private EnchantScaler fireTicks; public EnchantInfernus(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); 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 0e1d620..f0b9c90 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 @@ -3,15 +3,15 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDeathEvent; 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; public class EnchantNimble extends ExcellentEnchant implements Chanced, DeathEnchant { @@ -21,7 +21,7 @@ public class EnchantNimble extends ExcellentEnchant implements Chanced, DeathEnc private ChanceImplementation chanceImplementation; public EnchantNimble(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.LOWEST); + super(plugin, ID); this.getDefaults().setDescription("Moves all mob's loot directly to your inventory."); this.getDefaults().setLevelMax(1); this.getDefaults().setTier(0.4); @@ -45,9 +45,14 @@ public class EnchantNimble extends ExcellentEnchant implements Chanced, DeathEnc return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getKillPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { - if (!this.isAvailableToUse(entity)) return false; if (!this.checkTriggerChance(level)) return false; event.getDrops().forEach(item -> PlayerUtil.addItem(killer, item)); 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 fd55183..e06a05d 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 @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; @@ -16,7 +17,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 ExcellentEnchant implements Chanced, Potioned, CombatEnchant { @@ -26,7 +26,7 @@ public class EnchantParalyze extends ExcellentEnchant implements Chanced, Potion private PotionImplementation potionImplementation; public EnchantParalyze(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -60,9 +60,14 @@ public class EnchantParalyze extends ExcellentEnchant implements Chanced, Potion return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; 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 312c288..077c4e0 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 @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; @@ -16,7 +17,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 ExcellentEnchant implements Chanced, Potioned, CombatEnchant { @@ -26,7 +26,7 @@ public class EnchantRage extends ExcellentEnchant implements Chanced, Potioned, private PotionImplementation potionImplementation; public EnchantRage(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -60,9 +60,14 @@ public class EnchantRage extends ExcellentEnchant implements Chanced, Potioned, return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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(damager, level)) return false; 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 d928f75..4627fcf 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 @@ -5,6 +5,7 @@ import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.FireworkMeta; @@ -18,7 +19,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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,7 +28,7 @@ public class EnchantRocket extends ExcellentEnchant implements Chanced, CombatEn private ChanceImplementation chanceImplementation; public EnchantRocket(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch your enemy into the space."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.5); @@ -60,9 +60,14 @@ public class EnchantRocket extends ExcellentEnchant implements Chanced, CombatEn return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(damager)) return false; if (!this.checkTriggerChance(level)) return false; if (victim.isInsideVehicle()) { 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 55be0dd..19da38d 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 @@ -17,7 +17,6 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; 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; @@ -31,7 +30,7 @@ public class EnchantScavenger extends ExcellentEnchant implements Chanced, Death private ChanceImplementation chanceImplementation; public EnchantScavenger(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to obtain additional loot from mobs."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.3); @@ -100,8 +99,6 @@ public class EnchantScavenger extends ExcellentEnchant implements Chanced, Death @Override public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { - if (!this.isAvailableToUse(entity)) return false; - Map> items = this.loot.get(entity.getType()); if (items == null) return false; 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 ab646a7..5a33521 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 @@ -4,6 +4,7 @@ import org.bukkit.Color; import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; @@ -19,7 +20,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 EnchantSurprise extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { @@ -29,7 +29,7 @@ public class EnchantSurprise extends ExcellentEnchant implements Chanced, Potion private PotionImplementation potionImplementation; public EnchantSurprise(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -63,9 +63,14 @@ public class EnchantSurprise extends ExcellentEnchant implements Chanced, Potion return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(damager)) return false; if (!this.checkTriggerChance(level)) return false; PotionEffect effect = new PotionEffect(Rnd.get(PotionEffectType.values()), this.getEffectDuration(level), Math.max(0, this.getEffectAmplifier(level) - 1), false, false); 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 0cc08a8..8eba614 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 @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.attribute.Attribute; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -13,7 +14,6 @@ import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantTemper extends ExcellentEnchant implements CombatEnchant { @@ -27,7 +27,7 @@ public class EnchantTemper extends ExcellentEnchant implements CombatEnchant { private EnchantScaler healthPoint; public EnchantTemper(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -67,10 +67,14 @@ public class EnchantTemper extends ExcellentEnchant implements CombatEnchant { return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.NORMAL; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(damager)) return false; - double healthPoint = this.getHealthPoint(level); double healthHas = damager.getHealth(); double healthMax = EntityUtil.getAttribute(damager, Attribute.GENERIC_MAX_HEALTH); 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 e7f2b83..bde26a3 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 @@ -20,7 +20,6 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; 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; @@ -37,7 +36,7 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn private ChanceImplementation chanceImplementation; public EnchantThrifty(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to obtain mob spawn egg on kill."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.75); @@ -82,8 +81,6 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn @Override public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { - if (!this.isAvailableToUse(entity)) return false; - if (this.ignoredEntityTypes.contains(entity.getType())) return false; if (PDCUtil.getBoolean(entity, this.keyEntityIgnored).orElse(false)) return false; if (!this.checkTriggerChance(level)) return false; 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 85a6447..269ccec 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 @@ -12,10 +12,9 @@ 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatEnchant { @@ -28,7 +27,7 @@ public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatE private ChanceImplementation chanceImplementation; public EnchantThunder(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to summon lightning to enemy on hit."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.3); @@ -59,9 +58,14 @@ public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatE return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(damager)) return false; if (this.isInThunderstormOnly() && !victim.getWorld().isThundering()) return false; if (victim.getLocation().getBlock().getLightFromSky() != 15) return false; if (!this.checkTriggerChance(level)) return false; 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 c2fb76e..a1e6f07 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 @@ -4,6 +4,7 @@ import org.bukkit.Particle; import org.bukkit.attribute.Attribute; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.inventory.ItemStack; @@ -19,7 +20,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 EnchantVampire extends ExcellentEnchant implements Chanced, CombatEnchant { @@ -31,7 +31,7 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE private ChanceImplementation chanceImplementation; public EnchantVampire(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.LOWEST); + super(plugin, ID); 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); @@ -72,10 +72,14 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.MONITOR; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(damager)) return false; - double healthMax = EntityUtil.getAttribute(damager, Attribute.GENERIC_MAX_HEALTH); double healthHas = damager.getHealth(); if (healthHas == healthMax) return false; @@ -83,7 +87,7 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE if (!this.checkTriggerChance(level)) return false; double healAmount = this.getHealAmount(level); - double healFinal = this.isHealMultiplier() ? event.getDamage() * healAmount : healAmount; + double healFinal = this.isHealMultiplier() ? event.getFinalDamage() * healAmount : healAmount; EntityRegainHealthEvent healthEvent = new EntityRegainHealthEvent(damager, healFinal, EntityRegainHealthEvent.RegainReason.CUSTOM); plugin.getPluginManager().callEvent(healthEvent); 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 2703ad1..922fbb3 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 @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; @@ -16,7 +17,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 ExcellentEnchant implements Chanced, Potioned, CombatEnchant { @@ -26,7 +26,7 @@ public class EnchantVenom extends ExcellentEnchant implements Chanced, Potioned, private PotionImplementation potionImplementation; public EnchantVenom(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -60,9 +60,14 @@ public class EnchantVenom extends ExcellentEnchant implements Chanced, Potioned, return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; 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 c79c404..719ea14 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 @@ -15,7 +15,6 @@ import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; -import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; public class EnchantVillageDefender extends ExcellentEnchant implements CombatEnchant { @@ -26,7 +25,7 @@ public class EnchantVillageDefender extends ExcellentEnchant implements CombatEn private EnchantScaler damageAmount; public EnchantVillageDefender(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); this.getDefaults().setDescription("Inflicts " + PLACEHOLDER_DAMAGE_AMOUNT + " more damage to all pillagers."); this.getDefaults().setLevelMax(5); this.getDefaults().setTier(0.1); @@ -62,7 +61,6 @@ public class EnchantVillageDefender extends ExcellentEnchant implements CombatEn @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { - if (!this.isAvailableToUse(damager)) return false; if (!(victim instanceof Illager)) return false; double damageAdd = this.getDamageAddict(level); 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 f229498..3e8c7be 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 @@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon; import org.bukkit.Particle; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; @@ -16,7 +17,6 @@ import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; 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 ExcellentEnchant implements Chanced, Potioned, CombatEnchant { @@ -26,7 +26,7 @@ public class EnchantWither extends ExcellentEnchant implements Chanced, Potioned private PotionImplementation potionImplementation; public EnchantWither(@NotNull ExcellentEnchants plugin) { - super(plugin, ID, EnchantPriority.MEDIUM); + super(plugin, ID); 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); @@ -60,9 +60,14 @@ public class EnchantWither extends ExcellentEnchant implements Chanced, Potioned return EnchantmentTarget.WEAPON; } + @NotNull + @Override + public EventPriority getAttackPriority() { + return EventPriority.HIGHEST; + } + @Override public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @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; 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 14c2d0c..997a83b 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 @@ -53,7 +53,7 @@ public class EnchantAnvilListener extends AbstractListener { this.handleEnchantMerging(e, first, second, result); } - private boolean handleRename(@NotNull PrepareAnvilEvent e, + private boolean handleRename(@NotNull PrepareAnvilEvent event, @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) { if (!second.getType().isAir() && (second.getType() == first.getType() || second.getType() == Material.ENCHANTED_BOOK)) return false; @@ -64,11 +64,11 @@ public class EnchantAnvilListener extends AbstractListener { EnchantUtils.add(result2, hasEnch, hasLevel, true); }); EnchantUtils.updateDisplay(result2); - e.setResult(result2); + event.setResult(result2); return true; } - private boolean handleRecharge(@NotNull PrepareAnvilEvent e, + private boolean handleRecharge(@NotNull PrepareAnvilEvent event, @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) { if (second.getType().isAir()) return false; @@ -90,12 +90,12 @@ public class EnchantAnvilListener extends AbstractListener { PDCUtil.set(result2, RECHARGED, count); EnchantUtils.updateDisplay(result2); - e.setResult(result2); - this.plugin.runTask(task -> e.getInventory().setRepairCost(chargable.size())); + event.setResult(result2); + this.plugin.runTask(task -> event.getInventory().setRepairCost(chargable.size())); return true; } - private boolean handleEnchantMerging(@NotNull PrepareAnvilEvent e, + private boolean handleEnchantMerging(@NotNull PrepareAnvilEvent event, @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) { // Validate items in the first two slots. if (second.getType().isAir() || second.getAmount() > 1 || !EnchantUtils.isEnchantable(second)) return false; @@ -104,7 +104,7 @@ public class EnchantAnvilListener extends AbstractListener { ItemStack result2 = new ItemStack(result.getType().isAir() ? first : result); 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()); + AtomicInteger repairCost = new AtomicInteger(event.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()) { @@ -125,31 +125,31 @@ public class EnchantAnvilListener extends AbstractListener { if (first.equals(result2)) return false; EnchantUtils.updateDisplay(result2); - e.setResult(result2); + event.setResult(result2); // NMS ContainerAnvil will set level cost to 0 right after calling the event, need 1 tick delay. - this.plugin.runTask(task -> e.getInventory().setRepairCost(repairCost.get())); + this.plugin.runTask(task -> event.getInventory().setRepairCost(repairCost.get())); return true; } @EventHandler(priority = EventPriority.NORMAL) - public void onClickAnvil(InventoryClickEvent e) { - if (!(e.getInventory() instanceof AnvilInventory inventory)) return; - if (e.getRawSlot() != 2) return; + public void onClickAnvil(InventoryClickEvent event) { + if (!(event.getInventory() instanceof AnvilInventory inventory)) return; + if (event.getRawSlot() != 2) return; - ItemStack item = e.getCurrentItem(); + ItemStack item = event.getCurrentItem(); if (item == null) return; int count = PDCUtil.getInt(item, RECHARGED).orElse(0); if (count == 0) return; - Player player = (Player) e.getWhoClicked(); + Player player = (Player) event.getWhoClicked(); if (player.getLevel() < inventory.getRepairCost()) return; player.setLevel(player.getLevel() - inventory.getRepairCost()); PDCUtil.remove(item, RECHARGED); - e.getView().setCursor(item); - e.setCancelled(false); + event.getView().setCursor(item); + event.setCancelled(false); UniSound.of(Sound.BLOCK_ENCHANTMENT_TABLE_USE).play(player); 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 bbd2e34..48a5ec2 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 @@ -2,14 +2,11 @@ package su.nightexpress.excellentenchants.enchantment.listener; import org.bukkit.World; import org.bukkit.block.Chest; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.enchantment.EnchantItemEvent; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityPickupItemEvent; -import org.bukkit.event.entity.VillagerAcquireTradeEvent; +import org.bukkit.event.entity.*; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryType; @@ -24,6 +21,7 @@ import su.nexmedia.engine.utils.EngineUtils; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.EnchantManager; +import su.nightexpress.excellentenchants.enchantment.EnchantPopulator; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; @@ -39,21 +37,33 @@ public class EnchantGenericListener extends AbstractListener super(enchantManager.plugin()); } + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onEnchantProjectileShoot(EntityShootBowEvent event) { + if (event.getProjectile() instanceof Projectile projectile) { + EnchantUtils.setSourceWeapon(projectile, event.getBow()); + } + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onEnchantProjectileLand(ProjectileHitEvent event) { + EnchantUtils.removeSourceWeapon(event.getEntity()); + } + // --------------------------------------------------------------- // Update enchantment lore after grindstone // --------------------------------------------------------------- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantUpdateGrindstoneClick(InventoryClickEvent e) { - Inventory inventory = e.getInventory(); + public void onEnchantUpdateGrindstoneClick(InventoryClickEvent event) { + Inventory inventory = event.getInventory(); if (inventory.getType() != InventoryType.GRINDSTONE) return; - if (e.getRawSlot() == 2) return; + if (event.getRawSlot() == 2) return; this.updateGrindstone(inventory); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantUpdateGrindstoneDrag(InventoryDragEvent e) { - Inventory inventory = e.getInventory(); + public void onEnchantUpdateGrindstoneDrag(InventoryDragEvent event) { + Inventory inventory = event.getInventory(); if (inventory.getType() != InventoryType.GRINDSTONE) return; this.updateGrindstone(inventory); @@ -80,10 +90,10 @@ public class EnchantGenericListener extends AbstractListener } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantUpdatePickup(EntityPickupItemEvent e) { - if (!(e.getEntity() instanceof Player player)) return; + public void onEnchantUpdatePickup(EntityPickupItemEvent event) { + if (!(event.getEntity() instanceof Player player)) return; - Item item = e.getItem(); + Item item = event.getItem(); ItemStack itemStack = item.getItemStack(); if (EnchantUtils.updateDisplay(itemStack)) { item.setItemStack(itemStack); @@ -98,13 +108,12 @@ public class EnchantGenericListener extends AbstractListener ItemStack target = event.getItem(); World world = event.getEnchanter().getWorld(); - Map enchantsPrepared = event.getEnchantsToAdd(); - Map enchantsToPopulate = EnchantUtils.getPopulationCandidates( - target, ObtainType.ENCHANTING, enchantsPrepared, - enchant -> enchant.getLevelByEnchantCost(event.getExpLevelCost()), - world); + EnchantPopulator populator = this.plugin.createPopulator(target, ObtainType.ENCHANTING) + .withWorld(world) + .withLevelGenerator(enchant -> enchant.getLevelByEnchantCost(event.getExpLevelCost())) + .withDefaultPopulation(event.getEnchantsToAdd()); - enchantsPrepared.putAll(enchantsToPopulate); + event.getEnchantsToAdd().putAll(populator.createPopulation()); plugin.getServer().getScheduler().runTask(plugin, () -> { ItemStack result = event.getInventory().getItem(0); @@ -141,10 +150,11 @@ public class EnchantGenericListener extends AbstractListener public void onEnchantPopulateVillagerAcquire(VillagerAcquireTradeEvent event) { MerchantRecipe recipe = event.getRecipe(); ItemStack result = recipe.getResult(); - World world = event.getEntity().getWorld(); - if (!EnchantUtils.isEnchantable(result)) return; - if (!EnchantUtils.populate(result, ObtainType.VILLAGER, world)) return; + + EnchantPopulator populator = this.plugin.createPopulator(result, ObtainType.VILLAGER) + .withWorld(event.getEntity().getWorld()); + if (!populator.populate()) return; int uses = recipe.getUses(); int maxUses = recipe.getMaxUses(); @@ -171,7 +181,9 @@ public class EnchantGenericListener extends AbstractListener if (entity instanceof Minecart || holder instanceof Chest) { event.getLoot().forEach(item -> { if (item != null && EnchantUtils.isEnchantable(item)) { - EnchantUtils.populate(item, ObtainType.LOOT_GENERATION, world); + this.plugin.createPopulator(item, ObtainType.LOOT_GENERATION) + .withWorld(world) + .populate(); } }); } @@ -186,15 +198,18 @@ public class EnchantGenericListener extends AbstractListener ItemStack itemStack = item.getItemStack(); World world = item.getWorld(); if (EnchantUtils.isEnchantable(itemStack)) { - EnchantUtils.populate(itemStack, ObtainType.FISHING, world); + this.plugin.createPopulator(itemStack, ObtainType.FISHING).withWorld(world).populate(); } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantPopulateSpawn(CreatureSpawnEvent e) { + public void onEnchantPopulateSpawn(CreatureSpawnEvent event) { //if (Config.getObtainSettings(ObtainType.MOB_SPAWNING).isEmpty()) return; - LivingEntity entity = e.getEntity(); + LivingEntity entity = event.getEntity(); if (entity.getType() == EntityType.ARMOR_STAND) return; + if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.DISPENSE_EGG) return; + if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG) return; + if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SPAWNER) return; this.plugin.runTaskLater(task -> { EntityEquipment equipment = entity.getEquipment(); @@ -207,7 +222,9 @@ public class EnchantGenericListener extends AbstractListener for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack item = equipment.getItem(slot); if (EnchantUtils.isEnchantable(item)) { - if (doPopulation) EnchantUtils.populate(item, ObtainType.MOB_SPAWNING, world); + if (doPopulation) { + this.plugin.createPopulator(item, ObtainType.MOB_SPAWNING).withWorld(world).populate(); + } EnchantUtils.getExcellents(item).forEach((enchant, level) -> EnchantUtils.restoreCharges(item, enchant, level)); 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 6931d08..5a71e2c 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 @@ -1,82 +1,37 @@ package su.nightexpress.excellentenchants.enchantment.listener; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.event.Event.Result; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockDropItemEvent; -import org.bukkit.event.entity.*; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerFishEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.EntityEquipment; -import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; -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.meta.Arrowed; -import su.nightexpress.excellentenchants.api.enchantment.type.*; -import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.EnchantManager; -import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; public class EnchantHandlerListener extends AbstractListener { - private static final String META_PROJECTILE_WEAPON = "sourceWeapon"; - public EnchantHandlerListener(@NotNull EnchantManager enchantManager) { super(enchantManager.plugin()); } - private void setSourceWeapon(@NotNull Projectile projectile, @NotNull ItemStack item) { - projectile.setMetadata(META_PROJECTILE_WEAPON, new FixedMetadataValue(plugin, item)); - } - - @Nullable - private ItemStack getSourceWeapon(@NotNull Projectile projectile) { - return projectile.hasMetadata(META_PROJECTILE_WEAPON) ? (ItemStack) projectile.getMetadata(META_PROJECTILE_WEAPON).get(0).value() : null; - } - - private void removeSourceWeapon(@NotNull Projectile projectile) { - projectile.removeMetadata(META_PROJECTILE_WEAPON, plugin); - } - // --------------------------------------------------------------- // Combat Attacking Enchants // --------------------------------------------------------------- - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantCombatMelee(EntityDamageEvent e) { - if (e.getCause() == DamageCause.THORNS) return; - if (!(e.getEntity() instanceof LivingEntity victim)) return; + /*@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEnchantCombatMelee(EntityDamageEvent event) { + if (event.getCause() == DamageCause.THORNS) return; + if (!(event.getEntity() instanceof LivingEntity victim)) return; - if (e instanceof EntityDamageByEntityEvent ede) { - LivingEntity damager = null; - if (ede.getDamager() instanceof LivingEntity living) { - damager = living; - } - else if (ede.getDamager() instanceof Projectile pj && pj.getShooter() instanceof LivingEntity living) { - damager = living; - } - if (damager == null || damager.equals(victim)) return; - - if (ede.getDamager() instanceof Projectile projectile) { + if (event instanceof EntityDamageByEntityEvent ede) { + if (ede.getDamager() instanceof Projectile projectile && this.getSourceWeapon(projectile) != null) { this.handleCombatBowEnchants(ede, projectile, victim); + return; } - else { - this.handleCombatWeaponEnchants(ede, damager, victim); - } + + if (!(ede.getDamager() instanceof LivingEntity damager) || damager == victim) return; + + this.handleCombatWeaponEnchants(ede, damager, victim); this.handleCombatArmorEnchants(ede, damager, victim); } else { - this.handleArmorEnchants(e, victim); + this.handleArmorEnchants(event, victim); } } @@ -145,17 +100,17 @@ public class EnchantHandlerListener extends AbstractListener // Bow Shooting Enchants // --------------------------------------------------------------- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantBowShoot(EntityShootBowEvent e) { - LivingEntity shooter = e.getEntity(); + public void onEnchantBowShoot(EntityShootBowEvent event) { + LivingEntity shooter = event.getEntity(); if (shooter.getEquipment() == null) return; - ItemStack bow = e.getBow(); + ItemStack bow = event.getBow(); if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; 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) { + if (bowEnchant.onShoot(event, shooter, bow, level)) { + if (bowEnchant instanceof Arrowed arrowed && event.getProjectile() instanceof Projectile projectile) { arrowed.addData(projectile); arrowed.addTrail(projectile); } @@ -164,7 +119,7 @@ public class EnchantHandlerListener extends AbstractListener }); EnchantUtils.updateChargesDisplay(bow); - if (e.getProjectile() instanceof Projectile projectile) { + if (event.getProjectile() instanceof Projectile projectile) { this.setSourceWeapon(projectile, bow); } } @@ -173,35 +128,35 @@ public class EnchantHandlerListener extends AbstractListener // Bow Hit Land Enchants // --------------------------------------------------------------- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantBowHit(ProjectileHitEvent e) { - Projectile projectile = e.getEntity(); + public void onEnchantBowHit(ProjectileHitEvent event) { + Projectile projectile = event.getEntity(); ItemStack bow = this.getSourceWeapon(projectile); if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; EnchantUtils.getExcellents(bow, BowEnchant.class).forEach((bowEnchant, level) -> { - bowEnchant.onHit(e, projectile, bow, level); + bowEnchant.onHit(event, null, projectile, bow, level); }); // Prevent to apply enchants multiple times on hits. - this.plugin.getScheduler().runTask(this.plugin, c -> this.removeSourceWeapon(projectile)); + this.plugin.runTask(task -> this.removeSourceWeapon(projectile)); } // --------------------------------------------------------------- // Interaction Related Enchants // --------------------------------------------------------------- @EventHandler(priority = EventPriority.HIGHEST) - public void onEnchantInteract(PlayerInteractEvent e) { - if (e.useInteractedBlock() == Result.DENY) return; - if (e.useItemInHand() == Result.DENY) return; + public void onEnchantInteract(PlayerInteractEvent event) { + if (event.useInteractedBlock() == Result.DENY) return; + if (event.useItemInHand() == Result.DENY) return; - ItemStack item = e.getItem(); + ItemStack item = event.getItem(); if (item == null || item.getType().isAir() || item.getType() == Material.ENCHANTED_BOOK) return; - Player player = e.getPlayer(); + Player player = event.getPlayer(); EnchantUtils.getExcellents(item, InteractEnchant.class).forEach((interEnchant, level) -> { if (interEnchant.isOutOfCharges(item)) return; - if (interEnchant.onInteract(e, player, item, level)) { + if (interEnchant.onInteract(event, player, item, level)) { interEnchant.consumeChargesNoUpdate(item, level); } }); @@ -261,8 +216,8 @@ public class EnchantHandlerListener extends AbstractListener // Handle BlockBreak enchantments. @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantBlockBreak(BlockBreakEvent e) { - Player player = e.getPlayer(); + public void onEnchantBlockBreak(BlockBreakEvent event) { + Player player = event.getPlayer(); if (player.getGameMode() == GameMode.CREATIVE) return; ItemStack tool = player.getInventory().getItemInMainHand(); @@ -270,7 +225,7 @@ public class EnchantHandlerListener extends AbstractListener EnchantUtils.getExcellents(tool, BlockBreakEnchant.class).forEach((blockEnchant, level) -> { if (blockEnchant.isOutOfCharges(tool)) return; - if (blockEnchant.onBreak(e, player, tool, level)) { + if (blockEnchant.onBreak(event, player, tool, level)) { blockEnchant.consumeChargesNoUpdate(tool, level); } }); @@ -285,7 +240,6 @@ public class EnchantHandlerListener extends AbstractListener ItemStack tool = player.getInventory().getItemInMainHand(); if (tool.getType().isAir() || tool.getType() == Material.ENCHANTED_BOOK) return; - //EnchantDropContainer dropContainer = new EnchantDropContainer(e); EnchantUtils.getExcellents(tool, BlockDropEnchant.class).forEach((enchant, level) -> { if (enchant.isOutOfCharges(tool)) return; if (enchant.onDrop(event, player, tool, level)) { @@ -293,11 +247,5 @@ public class EnchantHandlerListener extends AbstractListener } }); EnchantUtils.updateChargesDisplay(tool); - - //BlockState state = e.getBlockState(); - //World world = state.getWorld(); - //Location location = state.getLocation(); - - //dropContainer.getDrop().forEach(item -> world.dropItem(location, item)); - } + }*/ } 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 a7e1980..7e9a649 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 @@ -18,8 +18,8 @@ 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.enchantment.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.*; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java similarity index 50% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java index eee5431..a158045 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java @@ -1,21 +1,37 @@ -package su.nightexpress.excellentenchants.enchantment; +package su.nightexpress.excellentenchants.enchantment.registry; import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; +import org.bukkit.event.Event; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDropItemEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.Version; +import su.nexmedia.engine.api.manager.AbstractManager; import su.nexmedia.engine.utils.Reflex; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; +import su.nightexpress.excellentenchants.api.enchantment.type.*; 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.fishing.*; import su.nightexpress.excellentenchants.enchantment.impl.tool.*; -import su.nightexpress.excellentenchants.enchantment.impl.universal.EnchantCurseOfFragility; +import su.nightexpress.excellentenchants.enchantment.impl.universal.CurseOfFragilityEnchant; import su.nightexpress.excellentenchants.enchantment.impl.universal.SoulboundEnchant; import su.nightexpress.excellentenchants.enchantment.impl.weapon.*; +import su.nightexpress.excellentenchants.enchantment.registry.wrapper.DataGather; +import su.nightexpress.excellentenchants.enchantment.registry.wrapper.DataGathers; +import su.nightexpress.excellentenchants.enchantment.registry.wrapper.WrappedEvent; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.tier.Tier; @@ -23,18 +39,34 @@ import java.util.*; import java.util.function.Supplier; import java.util.stream.Collectors; -public class EnchantRegistry { +public class EnchantRegistry extends AbstractManager { public static final Map REGISTRY_MAP = new HashMap<>(); + private static final Map, Set> ENCHANTS_MAP = new HashMap<>(); - private final ExcellentEnchants plugin; private boolean isLocked; public EnchantRegistry(@NotNull ExcellentEnchants plugin) { - this.plugin = plugin; + super(plugin); } - public void setup() { + @Override + protected void onLoad() { + this.registerType(GenericEnchant.class); + this.registerType(PassiveEnchant.class); + + this.registerWrapper(BlockBreakEvent.class, BlockBreakEnchant.class, DataGathers.BLOCK_BREAK); + this.registerWrapper(BlockDropItemEvent.class, BlockDropEnchant.class, DataGathers.BLOCK_DROP); + this.registerWrapper(EntityShootBowEvent.class, BowEnchant.class, DataGathers.BOW_SHOOT); + this.registerWrapper(ProjectileHitEvent.class, BowEnchant.class, DataGathers.PROJECTILE_HIT); + this.registerWrapper(EntityDamageByEntityEvent.class, BowEnchant.class, DataGathers.ENTITY_DAMAGE_SHOOT); + this.registerWrapper(EntityDamageByEntityEvent.class, CombatEnchant.class, DataGathers.ENTITY_DAMAGE_ATTACK); + this.registerWrapper(EntityDamageByEntityEvent.class, CombatEnchant.class, DataGathers.ENTITY_DAMAGE_DEFENSE); + this.registerWrapper(EntityDeathEvent.class, DeathEnchant.class, DataGathers.ENTITY_KILL); + this.registerWrapper(EntityDeathEvent.class, DeathEnchant.class, DataGathers.ENTITY_DEATH); + this.registerWrapper(PlayerFishEvent.class, FishingEnchant.class, DataGathers.FISHING); + this.registerWrapper(PlayerInteractEvent.class, InteractEnchant.class, DataGathers.INTERACT); + // Prevent to register enchantments during the runtime. if (this.isLocked) { REGISTRY_MAP.values().forEach(enchant -> { @@ -46,7 +78,7 @@ public class EnchantRegistry { Reflex.setFieldValue(Enchantment.class, "acceptingNew", true); - // Fising Enchants + // Fishing Enchants this.register(AutoReelEnchant.ID,() -> new AutoReelEnchant(plugin)); this.register(DoubleCatchEnchant.ID, () -> new DoubleCatchEnchant(plugin)); this.register(SeasonedAnglerEnchant.ID, () -> new SeasonedAnglerEnchant(plugin)); @@ -55,19 +87,19 @@ public class EnchantRegistry { this.register(RiverMasterEnchant.ID, () -> new RiverMasterEnchant(plugin)); // Tool enchants - this.register(EnchantBlastMining.ID, () -> new EnchantBlastMining(plugin)); - this.register(EnchantCurseOfBreaking.ID, () -> new EnchantCurseOfBreaking(plugin)); - this.register(EnchantCurseOfMisfortune.ID, () -> new EnchantCurseOfMisfortune(plugin)); - this.register(EnchantDivineTouch.ID, () -> new EnchantDivineTouch(plugin)); - this.register(EnchantHaste.ID, () -> new EnchantHaste(plugin)); - this.register(EnchantLuckyMiner.ID, () -> new EnchantLuckyMiner(plugin)); - this.register(EnchantReplanter.ID, () -> new EnchantReplanter(plugin)); - this.register(EnchantSilkChest.ID, () -> new EnchantSilkChest(plugin)); - this.register(EnchantSmelter.ID, () -> new EnchantSmelter(plugin)); - this.register(EnchantTelekinesis.ID, () -> new EnchantTelekinesis(plugin)); - this.register(EnchantTreasures.ID, () -> new EnchantTreasures(plugin)); - this.register(EnchantTunnel.ID, () -> new EnchantTunnel(plugin)); - this.register(EnchantVeinminer.ID, () -> new EnchantVeinminer(plugin)); + this.register(BlastMiningEnchant.ID, () -> new BlastMiningEnchant(plugin)); + this.register(CurseOfBreakingEnchant.ID, () -> new CurseOfBreakingEnchant(plugin)); + this.register(CurseOfMisfortuneEnchant.ID, () -> new CurseOfMisfortuneEnchant(plugin)); + this.register(DivineTouchEnchant.ID, () -> new DivineTouchEnchant(plugin)); + this.register(HasteEnchant.ID, () -> new HasteEnchant(plugin)); + this.register(LuckyMinerEnchant.ID, () -> new LuckyMinerEnchant(plugin)); + this.register(ReplanterEnchant.ID, () -> new ReplanterEnchant(plugin)); + this.register(SilkChestEnchant.ID, () -> new SilkChestEnchant(plugin)); + this.register(SmelterEnchant.ID, () -> new SmelterEnchant(plugin)); + this.register(TelekinesisEnchant.ID, () -> new TelekinesisEnchant(plugin)); + this.register(TreasuresEnchant.ID, () -> new TreasuresEnchant(plugin)); + this.register(TunnelEnchant.ID, () -> new TunnelEnchant(plugin)); + this.register(VeinminerEnchant.ID, () -> new VeinminerEnchant(plugin)); // Weapon enchants this.register(EnchantBaneOfNetherspawn.ID, () -> new EnchantBaneOfNetherspawn(plugin)); @@ -96,20 +128,20 @@ public class EnchantRegistry { this.register(EnchantWither.ID, () -> new EnchantWither(plugin)); // Armor enchants - this.register(EnchantAquaman.ID, () -> new EnchantAquaman(plugin)); - this.register(EnchantBunnyHop.ID, () -> new EnchantBunnyHop(plugin)); - this.register(EnchantColdSteel.ID, () -> new EnchantColdSteel(plugin)); - this.register(EnchantIceShield.ID, () -> new EnchantIceShield(plugin)); - this.register(EnchantElementalProtection.ID, () -> new EnchantElementalProtection(plugin)); - this.register(EnchantFireShield.ID, () -> new EnchantFireShield(plugin)); - this.register(EnchantFlameWalker.ID, () -> new EnchantFlameWalker(plugin)); - this.register(EnchantHardened.ID, () -> new EnchantHardened(plugin)); - this.register(EnchantNightVision.ID, () -> new EnchantNightVision(plugin)); - this.register(EnchantRegrowth.ID, () -> new EnchantRegrowth(plugin)); - this.register(EnchantSaturation.ID, () -> new EnchantSaturation(plugin)); - this.register(EnchantSelfDestruction.ID, () -> new EnchantSelfDestruction(plugin)); + this.register(AquamanEnchant.ID, () -> new AquamanEnchant(plugin)); + this.register(JumpingEnchant.ID, () -> new JumpingEnchant(plugin)); + this.register(ColdSteelEnchant.ID, () -> new ColdSteelEnchant(plugin)); + this.register(IceShieldEnchant.ID, () -> new IceShieldEnchant(plugin)); + this.register(ElementalProtectionEnchant.ID, () -> new ElementalProtectionEnchant(plugin)); + this.register(FireShieldEnchant.ID, () -> new FireShieldEnchant(plugin)); + this.register(FlameWalkerEnchant.ID, () -> new FlameWalkerEnchant(plugin)); + this.register(HardenedEnchant.ID, () -> new HardenedEnchant(plugin)); + this.register(NightVisionEnchant.ID, () -> new NightVisionEnchant(plugin)); + this.register(RegrowthEnchant.ID, () -> new RegrowthEnchant(plugin)); + this.register(SaturationEnchant.ID, () -> new SaturationEnchant(plugin)); + this.register(KamikadzeEnchant.ID, () -> new KamikadzeEnchant(plugin)); this.register(StoppingForceEnchant.ID, () -> new StoppingForceEnchant(plugin)); - this.register(EnchantSonic.ID, () -> new EnchantSonic(plugin)); + this.register(SpeedyEnchant.ID, () -> new SpeedyEnchant(plugin)); // Bow enchants this.register(EnchantBomber.ID, () -> new EnchantBomber(plugin)); @@ -130,36 +162,48 @@ public class EnchantRegistry { } // Universal - this.register(EnchantCurseOfFragility.ID, () -> new EnchantCurseOfFragility(plugin)); + this.register(CurseOfFragilityEnchant.ID, () -> new CurseOfFragilityEnchant(plugin)); this.register(CurseOfMediocrityEnchant.ID, () -> new CurseOfMediocrityEnchant(plugin)); this.register(SoulboundEnchant.ID, () -> new SoulboundEnchant(plugin)); Enchantment.stopAcceptingRegistrations(); - this.plugin.info("Enchantments Registered: " + getRegistered().size()); + this.plugin.info("Enchantments Registered: " + EnchantRegistry.getRegistered().size()); this.isLocked = true; } - /*@SuppressWarnings("unchecked") - public void shutdown() { - if (this.plugin.isEnabled()) return; // Prevent to unregister enchantments during the runtime. + @Override + protected void onShutdown() { + ENCHANTS_MAP.clear(); + } - Map byKey = (Map) Reflex.getFieldValue(Enchantment.class, "byKey"); - Map byName = (Map) Reflex.getFieldValue(Enchantment.class, "byName"); + public void registerType(@NotNull Class enchantClass) { + ENCHANTS_MAP.computeIfAbsent(enchantClass, k -> new HashSet<>()); + } - if (byKey == null || byName == null) return; + public void registerWrapper(@NotNull Class eventClass, + @NotNull Class enchantClass, + @NotNull DataGather dataGather) { - for (ExcellentEnchant enchant : REGISTRY_MAP.values()) { - if (enchant instanceof ICleanable cleanable) { - cleanable.clear(); - } - - byKey.remove(enchant.getKey()); - byName.remove(enchant.getName()); - enchant.unregisterListeners(); + for (EventPriority priority : EventPriority.values()) { + WrappedEvent event = new WrappedEvent<>(plugin, priority, eventClass, enchantClass, dataGather); + plugin.getPluginManager().registerEvent(eventClass, event, priority, event, plugin, true); } - REGISTRY_MAP.clear(); - this.plugin.info("All enchants are unregistered."); - }*/ + + this.registerType(enchantClass); + } + + private boolean registerEnchantType(@NotNull T enchant) { + Class enchantClass = enchant.getClass(); + + Set> assignables = ENCHANTS_MAP.keySet().stream().filter(clazz -> clazz.isAssignableFrom(enchantClass)).collect(Collectors.toSet()); + if (assignables.isEmpty()) { + this.plugin.warn("Could not register enchantment '" + enchant.getId() + "': Enchantment type is not registered."); + return false; + } + + assignables.forEach(clazz -> ENCHANTS_MAP.get(clazz).add(enchant)); + return true; + } private void register(@NotNull String id, @NotNull Supplier supplier) { if (Config.ENCHANTMENTS_DISABLED.get().contains(id)) return; @@ -171,6 +215,10 @@ public class EnchantRegistry { return; } + if (!this.registerEnchantType(enchant)) { + return; + } + Enchantment.registerEnchantment(enchant); REGISTRY_MAP.put(enchant.getKey(), enchant); enchant.loadSettings(); @@ -179,6 +227,18 @@ public class EnchantRegistry { this.plugin.info("Registered enchantment: " + enchant.getId()); } + @NotNull + public static Set getPeriodicTalents() { + return getEnchantments(PassiveEnchant.class); + } + + @NotNull + @SuppressWarnings("unchecked") + public static Set getEnchantments(@NotNull Class clazz) { + Set set = new HashSet<>(ENCHANTS_MAP.getOrDefault(clazz, Collections.emptySet())); + return (Set) set; + } + @Nullable public static ExcellentEnchant getById(@NotNull String id) { return getByKey(EnchantUtils.createKey(id)); @@ -196,8 +256,6 @@ public class EnchantRegistry { @NotNull public static Set getOfTier(@NotNull Tier tier) { - return getRegistered().stream().filter(enchant -> enchant.getTier() == tier) - .collect(Collectors.toCollection(HashSet::new)); + return getRegistered().stream().filter(enchant -> enchant.getTier() == tier).collect(Collectors.toCollection(HashSet::new)); } - } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGather.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGather.java new file mode 100644 index 0000000..92c9679 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGather.java @@ -0,0 +1,31 @@ +package su.nightexpress.excellentenchants.enchantment.registry.wrapper; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.Event; +import org.bukkit.event.EventPriority; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; + +import java.util.Map; + +public abstract class DataGather { + + @Nullable + public abstract LivingEntity getEntity(@NotNull E event); + + @NotNull + public abstract EquipmentSlot[] getEnchantSlots(@NotNull E event); + + public abstract boolean checkPriority(@NotNull T enchant, @NotNull EventPriority priority); + + @NotNull + public Map> getEnchants(@NotNull E event, @NotNull Class enchantClass, @NotNull LivingEntity entity) { + return EnchantUtils.getEquipped(entity, enchantClass, this.getEnchantSlots(event)); + } + + public abstract boolean useEnchant(@NotNull E event, @NotNull LivingEntity entity, @NotNull ItemStack item, @NotNull T enchant, int level); +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java new file mode 100644 index 0000000..0df6e3b --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java @@ -0,0 +1,351 @@ +package su.nightexpress.excellentenchants.enchantment.registry.wrapper; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDropItemEvent; +import org.bukkit.event.entity.*; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; +import su.nightexpress.excellentenchants.api.enchantment.type.*; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +public class DataGathers { + + public static final DataGather BLOCK_BREAK = new DataGather<>() { + + @Override + @NotNull + public LivingEntity getEntity(@NotNull BlockBreakEvent event) { + return event.getPlayer(); + } + + @Override + public boolean checkPriority(@NotNull BlockBreakEnchant enchant, @NotNull EventPriority priority) { + return enchant.getBreakPriority() == priority; + } + + @NotNull + @Override + public EquipmentSlot[] getEnchantSlots(@NotNull BlockBreakEvent event) { + return new EquipmentSlot[]{EquipmentSlot.HAND}; + } + + @Override + public boolean useEnchant(@NotNull BlockBreakEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, @NotNull BlockBreakEnchant enchant, int level) { + return enchant.onBreak(event, entity, item, level); + } + }; + + public static final DataGather BLOCK_DROP = new DataGather<>() { + + @Override + @NotNull + public LivingEntity getEntity(@NotNull BlockDropItemEvent event) { + return event.getPlayer(); + } + + @Override + public boolean checkPriority(@NotNull BlockDropEnchant enchant, @NotNull EventPriority priority) { + return enchant.getDropPriority() == priority; + } + + @NotNull + @Override + public EquipmentSlot[] getEnchantSlots(@NotNull BlockDropItemEvent event) { + return new EquipmentSlot[]{EquipmentSlot.HAND}; + } + + @Override + public boolean useEnchant(@NotNull BlockDropItemEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, @NotNull BlockDropEnchant enchant, int level) { + return enchant.onDrop(event, entity, item, level); + } + }; + + public static final DataGather BOW_SHOOT = new DataGather<>() { + + @Override + @NotNull + public LivingEntity getEntity(@NotNull EntityShootBowEvent event) { + return event.getEntity(); + } + + @Override + public boolean checkPriority(@NotNull BowEnchant enchant, @NotNull EventPriority priority) { + return enchant.getShootPriority() == priority; + } + + @NotNull + @Override + public EquipmentSlot[] getEnchantSlots(@NotNull EntityShootBowEvent event) { + return new EquipmentSlot[]{event.getHand()}; + } + + @Override + public boolean useEnchant(@NotNull EntityShootBowEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, @NotNull BowEnchant enchant, int level) { + if (enchant.onShoot(event, entity, item, level)) { + if (enchant instanceof Arrowed arrowed && event.getProjectile() instanceof Projectile projectile) { + arrowed.addData(projectile); + arrowed.addTrail(projectile); + } + return true; + } + return false; + } + }; + + public static final DataGather PROJECTILE_HIT = new DataGather<>() { + + @Override + @Nullable + public LivingEntity getEntity(@NotNull ProjectileHitEvent event) { + return event.getEntity().getShooter() instanceof LivingEntity entity ? entity : null; + } + + @Override + public boolean checkPriority(@NotNull BowEnchant enchant, @NotNull EventPriority priority) { + return enchant.getHitPriority() == priority; + } + + @NotNull + @Override + public EquipmentSlot[] getEnchantSlots(@NotNull ProjectileHitEvent event) { + return new EquipmentSlot[0]; + } + + @NotNull + @Override + public Map> getEnchants(@NotNull ProjectileHitEvent event, @NotNull Class enchantClass, @NotNull LivingEntity entity) { + Map> map = new HashMap<>(); + ItemStack bow = EnchantUtils.getSourceWeapon(event.getEntity()); + if (bow != null) { + map.put(bow, EnchantUtils.getExcellents(bow, enchantClass)); + } + return map; + } + + @Override + public boolean useEnchant(@NotNull ProjectileHitEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, @NotNull BowEnchant enchant, int level) { + return enchant.onHit(event, entity, event.getEntity(), item, level); + } + }; + + public static final DataGather ENTITY_DAMAGE_SHOOT = new DataGather<>() { + + @Override + @Nullable + public LivingEntity getEntity(@NotNull EntityDamageByEntityEvent event) { + if (event.getDamager() instanceof Projectile projectile && projectile.getShooter() instanceof LivingEntity shooter) { + return shooter; + } + return null; + } + + @Override + public boolean checkPriority(@NotNull BowEnchant enchant, @NotNull EventPriority priority) { + return enchant.getDamagePriority() == priority; + } + + @NotNull + @Override + public EquipmentSlot[] getEnchantSlots(@NotNull EntityDamageByEntityEvent event) { + return new EquipmentSlot[0]; + } + + @NotNull + @Override + public Map> getEnchants(@NotNull EntityDamageByEntityEvent event, @NotNull Class enchantClass, @NotNull LivingEntity entity) { + if (!(event.getDamager() instanceof Projectile projectile)) return Collections.emptyMap(); + + Map> map = new HashMap<>(); + ItemStack bow = EnchantUtils.getSourceWeapon(projectile); + if (bow != null) { + map.put(bow, EnchantUtils.getExcellents(bow, enchantClass)); + } + return map; + } + + @Override + public boolean useEnchant(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull ItemStack item, @NotNull BowEnchant enchant, int level) { + if (!(event.getDamager() instanceof Projectile projectile)) return false; + if (!(event.getEntity() instanceof LivingEntity victim)) return false; + + return enchant.onDamage(event, projectile, damager, victim, item, level); + } + }; + + public static final DataGather ENTITY_DAMAGE_ATTACK = new DataGather<>() { + + @Override + @Nullable + public LivingEntity getEntity(@NotNull EntityDamageByEntityEvent event) { + if (event.getDamager() instanceof LivingEntity entity) { + return entity; + } + return null; + } + + @Override + public boolean checkPriority(@NotNull CombatEnchant enchant, @NotNull EventPriority priority) { + return enchant.getAttackPriority() == priority; + } + + @NotNull + @Override + public EquipmentSlot[] getEnchantSlots(@NotNull EntityDamageByEntityEvent event) { + return new EquipmentSlot[]{EquipmentSlot.HAND}; + } + + @Override + public boolean useEnchant(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull ItemStack item, @NotNull CombatEnchant enchant, int level) { + if (event.getCause() == EntityDamageEvent.DamageCause.THORNS) return false; + if (!(event.getEntity() instanceof LivingEntity victim)) return false; + + return enchant.onAttack(event, damager, victim, item, level); + } + }; + + public static final DataGather ENTITY_DAMAGE_DEFENSE = new DataGather<>() { + + @Override + @Nullable + public LivingEntity getEntity(@NotNull EntityDamageByEntityEvent event) { + Entity entity = event.getEntity(); + return entity instanceof Player player ? player : null; + } + + @Override + public boolean checkPriority(@NotNull CombatEnchant enchant, @NotNull EventPriority priority) { + return enchant.getProtectPriority() == priority; + } + + @NotNull + @Override + public EquipmentSlot[] getEnchantSlots(@NotNull EntityDamageByEntityEvent event) { + return EquipmentSlot.values(); + } + + @Override + public boolean useEnchant(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity victim, @NotNull ItemStack item, @NotNull CombatEnchant enchant, int level) { + if (event.getCause() == EntityDamageEvent.DamageCause.THORNS) return false; + if (!(event.getDamager() instanceof LivingEntity damager)) return false; + + return enchant.onProtect(event, damager, victim, item, level); + } + }; + + public static final DataGather ENTITY_KILL = new DataGather<>() { + + @Override + @Nullable + public LivingEntity getEntity(@NotNull EntityDeathEvent event) { + return event.getEntity().getKiller(); + } + + @Override + public boolean checkPriority(@NotNull DeathEnchant enchant, @NotNull EventPriority priority) { + return enchant.getKillPriority() == priority; + } + + @NotNull + @Override + public EquipmentSlot[] getEnchantSlots(@NotNull EntityDeathEvent event) { + return new EquipmentSlot[] {EquipmentSlot.HAND}; + } + + @Override + public boolean useEnchant(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, @NotNull DeathEnchant enchant, int level) { + Player killer = entity.getKiller(); + if (killer == null) return false; + + return enchant.onKill(event, entity, killer, level); // TODO item? + } + }; + + public static final DataGather ENTITY_DEATH = new DataGather<>() { + + @Override + @NotNull + public LivingEntity getEntity(@NotNull EntityDeathEvent event) { + return event.getEntity(); + } + + @Override + public boolean checkPriority(@NotNull DeathEnchant enchant, @NotNull EventPriority priority) { + return enchant.getDeathPriority() == priority; + } + + @NotNull + @Override + public EquipmentSlot[] getEnchantSlots(@NotNull EntityDeathEvent event) { + return EquipmentSlot.values(); + } + + @Override + public boolean useEnchant(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, @NotNull DeathEnchant enchant, int level) { + return enchant.onDeath(event, entity, item, level); + } + }; + + public static final DataGather FISHING = new DataGather<>() { + + @Override + @NotNull + public LivingEntity getEntity(@NotNull PlayerFishEvent event) { + return event.getPlayer(); + } + + @Override + public boolean checkPriority(@NotNull FishingEnchant enchant, @NotNull EventPriority priority) { + return enchant.getFishingPriority() == priority; + } + + @NotNull + @Override + public EquipmentSlot[] getEnchantSlots(@NotNull PlayerFishEvent event) { + return new EquipmentSlot[] {event.getHand()}; + } + + @Override + public boolean useEnchant(@NotNull PlayerFishEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, @NotNull FishingEnchant enchant, int level) { + return enchant.onFishing(event, item, level); + } + }; + + public static final DataGather INTERACT = new DataGather<>() { + + @NotNull + @Override + public LivingEntity getEntity(@NotNull PlayerInteractEvent event) { + return event.getPlayer(); + } + + @Override + public boolean checkPriority(@NotNull InteractEnchant enchant, @NotNull EventPriority priority) { + return enchant.getInteractPriority() == priority; + } + + @NotNull + @Override + public EquipmentSlot[] getEnchantSlots(@NotNull PlayerInteractEvent event) { + return new EquipmentSlot[]{event.getHand()}; + } + + @Override + public boolean useEnchant(@NotNull PlayerInteractEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, @NotNull InteractEnchant enchant, int level) { + return enchant.onInteract(event, entity, item, level); + } + }; +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/WrappedEvent.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/WrappedEvent.java new file mode 100644 index 0000000..ec0b241 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/WrappedEvent.java @@ -0,0 +1,56 @@ +package su.nightexpress.excellentenchants.enchantment.registry.wrapper; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.Event; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.plugin.EventExecutor; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; +import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; + +public class WrappedEvent implements Listener, EventExecutor { + + //private final ExcellentEnchants plugin; + private final EventPriority priority; + private final Class eventClass; + private final Class enchantClass; + private final DataGather dataGather; + + public WrappedEvent(@NotNull ExcellentEnchants plugin, + @NotNull EventPriority priority, + @NotNull Class eventClass, + @NotNull Class enchantClass, + @NotNull DataGather dataGather) { + //this.plugin = plugin; + this.priority = priority; + this.eventClass = eventClass; + this.enchantClass = enchantClass; + this.dataGather = dataGather; + } + + @Override + public void execute(@NotNull Listener listener, @NotNull Event bukkitEvent) { + if (!this.eventClass.isAssignableFrom(bukkitEvent.getClass())) return; + + E event = this.eventClass.cast(bukkitEvent); + LivingEntity entity = this.dataGather.getEntity(event); + if (entity == null) return; + + this.dataGather.getEnchants(event, this.enchantClass, entity).forEach((item, enchants) -> { + enchants.forEach(((enchant, level) -> { + if (!this.dataGather.checkPriority(enchant, this.priority)) return; + if (!enchant.isAvailableToUse(entity)) return; + if (enchant.isOutOfCharges(item)) return; + if (this.dataGather.useEnchant(event, entity, item, enchant, level)) { + enchant.consumeChargesNoUpdate(item, level); + } + })); + if (Config.ENCHANTMENTS_CHARGES_ENABLED.get()) { + EnchantUtils.updateChargesDisplay(item); + } + }); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantPriority.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantPriority.java deleted file mode 100644 index 533ddc8..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantPriority.java +++ /dev/null @@ -1,6 +0,0 @@ -package su.nightexpress.excellentenchants.enchantment.util; - -public enum EnchantPriority { - - LOWEST, LOW, MEDIUM, HIGH, HIGHEST -} 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 index c039999..ce33cf3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -2,48 +2,41 @@ package su.nightexpress.excellentenchants.enchantment.util; import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.block.BlockDropItemEvent; 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.bukkit.metadata.FixedMetadataValue; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.lang.LangManager; -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 su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry; import java.util.*; -import java.util.concurrent.atomic.AtomicBoolean; -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"); + private static final String META_PROJECTILE_WEAPON = "sourceWeapon"; private static boolean busyBreak = false; @@ -101,107 +94,6 @@ public class EnchantUtils { return item.getType() == Material.ENCHANTED_BOOK || Stream.of(EnchantmentTarget.values()).anyMatch(target -> target.includes(item)); } - // TODO Move in populator class - - public static boolean populate(@NotNull ItemStack item, @NotNull ObtainType obtainType, @Nullable World world) { - AtomicBoolean status = new AtomicBoolean(false); - - var population = getPopulationCandidates(item, obtainType, world); - - if (obtainType == ObtainType.VILLAGER && item.getType() == Material.ENCHANTED_BOOK) { - if (Config.ENCHANTMENTS_SINGLE_ENCHANT_IN_VILLAGER_BOOKS.get() && !population.isEmpty()) { - getAll(item).keySet().forEach(enchantment -> remove(item, enchantment)); - } - } - - population.forEach((enchantment, level) -> { - if (add(item, enchantment, level, false)) { - status.set(true); - } - }); - - if (status.get()) { - updateDisplay(item); - } - - return status.get(); - } - - @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, - @Nullable World world) { - return getPopulationCandidates(item, obtainType, new HashMap<>(), (enchant) -> enchant.generateLevel(obtainType), world); - } - - @NotNull - public static Map getPopulationCandidates(@NotNull ItemStack item, @NotNull ObtainType obtainType, - @NotNull Map enchantsPrepared, - @NotNull Function levelFunc, - @Nullable World world) { - 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); - - // Try to populate as many as possible. - while (!populator.isEmpty() && enchRoll > 0) { - // Limit reached. - if (enchantsToAdd.size() >= enchMax) break; - - Tier tier = populator.getTierByChance(); - if (tier == null) break; // no tiers left. - - ExcellentEnchant enchant = populator.getEnchantByChance(tier); - // Remove entire tier if no enchants can be selected. - if (enchant == null) { - populator.purge(tier); - continue; - } - - // Remove disabled world enchants. - if (world != null && enchant.isDisabledInWorld(world)) { - populator.purge(tier, enchant); - continue; - } - - // Remove conflicting enchants. - if (enchantsToAdd.keySet().stream().anyMatch(has -> has.conflictsWith(enchant) || enchant.conflictsWith(has))) { - populator.purge(tier, enchant); - continue; - } - - // Level generation failed. - int level = levelFunc.apply(enchant); - if (level < enchant.getStartLevel()) { - populator.purge(tier, enchant); - continue; - } - - // All good! - populator.purge(tier, 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; @@ -417,12 +309,17 @@ public class EnchantUtils { map.put(clazz.cast(excellent), level); }); - return CollectionsUtil.sort(map, Comparator.comparing(p -> p.getKey().getPriority(), Comparator.reverseOrder())); + return map;//CollectionsUtil.sort(map, Comparator.comparing(p -> p.getKey().getPriority(), Comparator.reverseOrder())); } @NotNull public static Map getEnchantedEquipment(@NotNull LivingEntity entity) { - Map equipment = EntityUtil.getEquippedItems(entity); + return getEnchantedEquipment(entity, EquipmentSlot.values()); + } + + @NotNull + public static Map getEnchantedEquipment(@NotNull LivingEntity entity, @NotNull EquipmentSlot... slots) { + Map equipment = EntityUtil.getEquippedItems(entity, slots); equipment.entrySet().removeIf(entry -> { ItemStack item = entry.getValue(); EquipmentSlot slot = entry.getKey(); @@ -445,8 +342,15 @@ public class EnchantUtils { @NotNull public static Map> getEquipped(@NotNull LivingEntity entity, @NotNull Class clazz) { + return getEquipped(entity, clazz, EquipmentSlot.values()); + } + + @NotNull + public static Map> getEquipped(@NotNull LivingEntity entity, + @NotNull Class clazz, + @NotNull EquipmentSlot... slots) { Map> map = new HashMap<>(); - getEnchantedEquipment(entity).values().forEach(item -> { + getEnchantedEquipment(entity, slots).values().forEach(item -> { map.computeIfAbsent(item, k -> new LinkedHashMap<>()).putAll(getExcellents(item, clazz)); }); return map; @@ -455,6 +359,7 @@ public class EnchantUtils { public static void updateEquippedEffects(@NotNull LivingEntity entity) { getEquipped(entity, PassiveEnchant.class).forEach((item, enchants) -> { enchants.forEach((enchant, level) -> { + if (!enchant.isAvailableToUse(entity)) return; if (enchant instanceof Potioned potioned) { if (enchant.isOutOfCharges(item)) return; if (enchant.onTrigger(entity, item, level)) { @@ -465,4 +370,19 @@ public class EnchantUtils { EnchantUtils.updateChargesDisplay(item); }); } + + public static void setSourceWeapon(@NotNull Projectile projectile, @Nullable ItemStack item) { + if (item == null) return; + + projectile.setMetadata(META_PROJECTILE_WEAPON, new FixedMetadataValue(ExcellentEnchantsAPI.PLUGIN, item)); + } + + @Nullable + public static ItemStack getSourceWeapon(@NotNull Projectile projectile) { + return projectile.hasMetadata(META_PROJECTILE_WEAPON) ? (ItemStack) projectile.getMetadata(META_PROJECTILE_WEAPON).get(0).value() : null; + } + + public static void removeSourceWeapon(@NotNull Projectile projectile) { + projectile.removeMetadata(META_PROJECTILE_WEAPON, ExcellentEnchantsAPI.PLUGIN); + } } 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 c20da53..604c102 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 @@ -10,7 +10,7 @@ import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; -import su.nightexpress.excellentenchants.enchantment.EnchantRegistry; +import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry; public class PlaceholderHook { 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 de94899..a4f5ba5 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,8 +13,8 @@ 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.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.*; diff --git a/NMS/pom.xml b/NMS/pom.xml index 50c9ef7..730d361 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.8 + 3.5.9 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index e48bc89..73ed7ae 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.8 + 3.5.9 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.8 + 3.5.9 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 2a21e2c..5b2a71f 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.8 + 3.5.9 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.8 + 3.5.9 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 26bd766..4068d37 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.8 + 3.5.9 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.8 + 3.5.9 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index 5813cfc..28e0214 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.8 + 3.5.9 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.8 + 3.5.9 diff --git a/V1_20_R2/pom.xml b/V1_20_R2/pom.xml index a3ffdf1..84b4c86 100644 --- a/V1_20_R2/pom.xml +++ b/V1_20_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.8 + 3.5.9 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.8 + 3.5.9 diff --git a/pom.xml b/pom.xml index 965af82..284537e 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.5.8 + 3.5.9 Core NMS From 7e58a21e3245fd5c685c06ee2efc40aacfa383e7 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 3 Oct 2023 21:14:27 +0500 Subject: [PATCH 59/69] v3.6.0 --- Core/pom.xml | 14 +- .../api/enchantment/type/DeathEnchant.java | 2 +- .../impl/armor/KamikadzeEnchant.java | 2 +- .../impl/bow/DarknessArrowsEnchant.java | 2 +- .../impl/bow/EnchantConfusingArrows.java | 2 +- .../impl/bow/EnchantDragonfireArrows.java | 2 +- .../impl/bow/EnchantElectrifiedArrows.java | 2 +- .../enchantment/impl/bow/EnchantEnderBow.java | 2 +- .../impl/bow/EnchantExplosiveArrows.java | 2 +- .../enchantment/impl/bow/EnchantGhast.java | 2 +- .../enchantment/impl/bow/EnchantHover.java | 2 +- .../impl/bow/EnchantPoisonedArrows.java | 2 +- .../impl/bow/EnchantWitheredArrows.java | 2 +- .../impl/bow/VampiricArrowsEnchant.java | 125 ++++++++++++++++++ .../impl/tool/CurseOfMediocrityEnchant.java | 2 +- .../impl/tool/CurseOfMisfortuneEnchant.java | 2 +- .../impl/universal/RestoreEnchant.java | 97 ++++++++++++++ .../impl/weapon/CurseOfDeathEnchant.java | 66 +++++++++ .../impl/weapon/EnchantDecapitator.java | 2 +- .../impl/weapon/EnchantExpHunter.java | 2 +- .../impl/weapon/EnchantNimble.java | 2 +- .../impl/weapon/EnchantScavenger.java | 2 +- .../impl/weapon/EnchantThrifty.java | 2 +- .../impl/weapon/SwiperEnchant.java | 100 ++++++++++++++ .../listener/EnchantGenericListener.java | 6 +- .../enchantment/registry/EnchantRegistry.java | 5 + .../registry/wrapper/DataGathers.java | 5 +- .../registry/wrapper/WrappedEvent.java | 1 + .../enchantment/util/EnchantUtils.java | 2 +- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 4 +- V1_18_R2/pom.xml | 4 +- V1_19_R3/pom.xml | 4 +- V1_20_R1/pom.xml | 4 +- V1_20_R2/pom.xml | 4 +- pom.xml | 2 +- 36 files changed, 439 insertions(+), 44 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/VampiricArrowsEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/RestoreEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/CurseOfDeathEnchant.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/SwiperEnchant.java diff --git a/Core/pom.xml b/Core/pom.xml index 611fd6a..51460af 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.9 + 3.6.0 4.0.0 @@ -76,32 +76,32 @@ su.nightexpress.excellentenchants NMS - 3.5.9 + 3.6.0 su.nightexpress.excellentenchants V1_17_R1 - 3.5.9 + 3.6.0 su.nightexpress.excellentenchants V1_18_R2 - 3.5.9 + 3.6.0 su.nightexpress.excellentenchants V1_19_R3 - 3.5.9 + 3.6.0 su.nightexpress.excellentenchants V1_20_R1 - 3.5.9 + 3.6.0 su.nightexpress.excellentenchants V1_20_R2 - 3.5.9 + 3.6.0 diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java index e42468e..98f2371 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java @@ -12,7 +12,7 @@ public interface DeathEnchant extends IEnchantment { boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level); - boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level); + boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level); @NotNull default EventPriority getDeathPriority() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/KamikadzeEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/KamikadzeEnchant.java index 7bc9bbe..0f3b6bf 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/KamikadzeEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/KamikadzeEnchant.java @@ -77,7 +77,7 @@ public class KamikadzeEnchant extends ExcellentEnchant implements Chanced, Death } @Override - public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) { return false; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java index d2cc8d1..8297c01 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java @@ -37,7 +37,7 @@ public class DarknessArrowsEnchant extends ExcellentEnchant implements Chanced, 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, EnchantBomber.ID); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID); } @Override 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 d830c10..b092515 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 @@ -37,7 +37,7 @@ public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, 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, EnchantBomber.ID); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID); } @Override 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 15bfd31..d9e3960 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 @@ -50,7 +50,7 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced 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, EnchantBomber.ID); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID); } @Override 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 d86aab8..feb7a30 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 @@ -41,7 +41,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance 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, EnchantBomber.ID); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID); } @Override 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 de01b2f..cd0520e 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 @@ -33,7 +33,7 @@ public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Cha EnchantBomber.ID, EnchantGhast.ID, EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID, - DarknessArrowsEnchant.ID, + DarknessArrowsEnchant.ID, VampiricArrowsEnchant.ID, EnchantHover.ID, FlareEnchant.ID, Enchantment.ARROW_FIRE.getKey().getKey(), Enchantment.ARROW_KNOCKBACK.getKey().getKey(), 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 8cedd07..7cf8c1a 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 @@ -45,7 +45,7 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, 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, EnchantBomber.ID); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID); } @Override 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 9d54165..c81e114 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 @@ -40,7 +40,7 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance EnchantEnderBow.ID, EnchantBomber.ID, EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID, - DarknessArrowsEnchant.ID, + DarknessArrowsEnchant.ID, VampiricArrowsEnchant.ID, EnchantHover.ID, FlareEnchant.ID, Enchantment.ARROW_FIRE.getKey().getKey(), Enchantment.ARROW_KNOCKBACK.getKey().getKey(), 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 440fda4..e8acb10 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 @@ -37,7 +37,7 @@ public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, 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, EnchantBomber.ID); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID); } @Override 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 e56fd82..7e5aa90 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 @@ -37,7 +37,7 @@ public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, 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, EnchantBomber.ID); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID); } @Override 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 6f22ad3..260cbf1 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 @@ -37,7 +37,7 @@ public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, 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, EnchantBomber.ID); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/VampiricArrowsEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/VampiricArrowsEnchant.java new file mode 100644 index 0000000..c439858 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/VampiricArrowsEnchant.java @@ -0,0 +1,125 @@ +package su.nightexpress.excellentenchants.enchantment.impl.bow; + +import org.bukkit.Color; +import org.bukkit.Particle; +import org.bukkit.attribute.Attribute; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.utils.EntityUtil; +import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.values.UniParticle; +import su.nightexpress.excellentenchants.ExcellentEnchants; +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.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class VampiricArrowsEnchant extends ExcellentEnchant implements BowEnchant, Arrowed, Chanced { + + public static final String ID = "vampiric_arrows"; + + public static final String PLACEHOLDER_HEAL_AMOUNT = "%heal_amount%"; + + private ArrowImplementation arrowImplementation; + private ChanceImplementation chanceImplementation; + private EnchantScaler healAmount; + + public VampiricArrowsEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to restore " + PLACEHOLDER_HEAL_AMOUNT + "❤ on arrow hit."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.3); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID); + } + + @Override + public void loadSettings() { + super.loadSettings(); + + this.arrowImplementation = ArrowImplementation.create(this, UniParticle.redstone(Color.RED, 1f)); + + this.chanceImplementation = ChanceImplementation.create(this, "20.0 * " + Placeholders.ENCHANTMENT_LEVEL); + + this.healAmount = EnchantScaler.read(this, "Settings.Heal_Amount", + Placeholders.ENCHANTMENT_LEVEL, + "Amount of health to be restored on hit."); + + this.addPlaceholder(PLACEHOLDER_HEAL_AMOUNT, level -> NumberUtil.format(this.getHealAmount(level))); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @NotNull + @Override + public Arrowed getArrowImplementation() { + return this.arrowImplementation; + } + + @NotNull + @Override + public Chanced getChanceImplementation() { + return this.chanceImplementation; + } + + public double getHealAmount(int level) { + return this.healAmount.getValue(level); + } + + @NotNull + @Override + public EventPriority getDamagePriority() { + return EventPriority.HIGHEST; + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!(event.getProjectile() instanceof Arrow arrow)) return false; + if (!this.checkTriggerChance(level)) return false; + + this.addData(arrow); + return true; + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent event, LivingEntity user, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return false; + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + double healAmount = this.getHealAmount(level); + if (healAmount <= 0D) return false; + + double health = shooter.getHealth(); + double maxHealth = EntityUtil.getAttribute(shooter, Attribute.GENERIC_MAX_HEALTH); + if (health >= maxHealth) return false; + + EntityRegainHealthEvent healthEvent = new EntityRegainHealthEvent(shooter, healAmount, EntityRegainHealthEvent.RegainReason.CUSTOM); + plugin.getPluginManager().callEvent(healthEvent); + if (healthEvent.isCancelled()) return false; + + shooter.setHealth(Math.min(maxHealth, health + healAmount)); + + if (this.hasVisualEffects()) { + UniParticle.of(Particle.HEART).play(shooter.getEyeLocation(), 0.25f, 0.15f, 5); + } + return false; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java index d167001..13175d4 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java @@ -88,7 +88,7 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance } @Override - public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) { if (!this.checkTriggerChance(level)) return false; event.getDrops().forEach(stack -> { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMisfortuneEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMisfortuneEnchant.java index 683f37c..08d6624 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMisfortuneEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMisfortuneEnchant.java @@ -95,7 +95,7 @@ public class CurseOfMisfortuneEnchant extends ExcellentEnchant implements Chance } @Override - public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) { if (!this.checkTriggerChance(level)) return false; event.getDrops().clear(); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/RestoreEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/RestoreEnchant.java new file mode 100644 index 0000000..5c9399b --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/RestoreEnchant.java @@ -0,0 +1,97 @@ +package su.nightexpress.excellentenchants.enchantment.impl.universal; + +import org.bukkit.Sound; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerItemDamageEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.manager.EventListener; +import su.nexmedia.engine.utils.NumberUtil; +import su.nexmedia.engine.utils.values.UniSound; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; +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.EnchantUtils; + +public class RestoreEnchant extends ExcellentEnchant implements GenericEnchant, Chanced, EventListener { + + public static final String ID = "restore"; + public static final String PLACEHOLDER_DURABILITY_RESTORE = "%durability_restore%"; + + private ChanceImplementation chanceImplementation; + private EnchantScaler durabilityRestore; + + public RestoreEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to save item from breaking back to " + PLACEHOLDER_DURABILITY_RESTORE + "%"); + this.getDefaults().setLevelMax(5); + this.getDefaults().setTier(0.6); + } + + @Override + public void loadSettings() { + super.loadSettings(); + + this.chanceImplementation = ChanceImplementation.create(this, + "35.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 8"); + + this.durabilityRestore = EnchantScaler.read(this, "Settings.Durability_Restoration", + "25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5", + "Amount of durability (in percent of item max) to be restored."); + + this.addPlaceholder(PLACEHOLDER_DURABILITY_RESTORE, level -> NumberUtil.format(this.getDurabilityRestore(level))); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BREAKABLE; + } + + public double getDurabilityRestore(int level) { + return this.durabilityRestore.getValue(level); + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onItemDamage(PlayerItemDamageEvent event) { + ItemStack item = event.getItem(); + if (!(item.getItemMeta() instanceof Damageable damageable)) return; + + int damage = event.getDamage(); + int maxDurability = item.getType().getMaxDurability(); + if (damageable.getDamage() + damage < maxDurability) return; + + int level = EnchantUtils.getLevel(item, this); + if (level <= 0) return; + + if (this.isOutOfCharges(item)) return; + if (!this.checkTriggerChance(level)) return; + + event.setCancelled(true); + this.consumeChargesNoUpdate(item, level); + + double restorePercent = 100D - this.getDurabilityRestore(level); + int restored = (int) (maxDurability * (restorePercent / 100D)); + + damageable.setDamage(restored); + item.setItemMeta(damageable); + EnchantUtils.remove(item, this); + + if (this.hasVisualEffects()) { + UniSound.of(Sound.ITEM_TOTEM_USE).play(event.getPlayer()); + } + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/CurseOfDeathEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/CurseOfDeathEnchant.java new file mode 100644 index 0000000..53dc786 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/CurseOfDeathEnchant.java @@ -0,0 +1,66 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.ExcellentEnchants; +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.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class CurseOfDeathEnchant extends ExcellentEnchant implements DeathEnchant, Chanced { + + public static final String ID = "curse_of_death"; + + private ChanceImplementation chanceImplementation; + + public CurseOfDeathEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); + this.getDefaults().setDescription("When killing players, you have a chance of dying too."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0D); + } + + @Override + public void loadSettings() { + super.loadSettings(); + + this.chanceImplementation = ChanceImplementation.create(this, Placeholders.ENCHANTMENT_LEVEL + " * 0.1"); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @NotNull + @Override + public Chanced getChanceImplementation() { + return this.chanceImplementation; + } + + @Override + public boolean isCursed() { + return true; + } + + @Override + public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) { + return false; + } + + @Override + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) { + if (!(entity instanceof Player dead)) return false; + if (!this.checkTriggerChance(level)) return false; + + killer.setHealth(0D); + 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 8a90738..32bb370 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 @@ -183,7 +183,7 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea } @Override - public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) { EntityType entityType = entity.getType(); if (this.ignoredEntityTypes.contains(entityType)) return false; if (!this.checkTriggerChance(level)) return false; 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 0217c56..98fc483 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 @@ -48,7 +48,7 @@ public class EnchantExpHunter extends ExcellentEnchant implements DeathEnchant { } @Override - public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) { double expModifier = this.getExpModifier(level); double expFinal = Math.ceil((double) event.getDroppedExp() * expModifier); 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 f0b9c90..0a78c75 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 @@ -52,7 +52,7 @@ public class EnchantNimble extends ExcellentEnchant implements Chanced, DeathEnc } @Override - public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) { if (!this.checkTriggerChance(level)) return false; event.getDrops().forEach(item -> PlayerUtil.addItem(killer, item)); 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 19da38d..ffda6de 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 @@ -98,7 +98,7 @@ public class EnchantScavenger extends ExcellentEnchant implements Chanced, Death } @Override - public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) { Map> items = this.loot.get(entity.getType()); if (items == null) return false; 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 bde26a3..3f4949d 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 @@ -80,7 +80,7 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn } @Override - public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) { + public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) { if (this.ignoredEntityTypes.contains(entity.getType())) return false; if (PDCUtil.getBoolean(entity, this.keyEntityIgnored).orElse(false)) return false; if (!this.checkTriggerChance(level)) return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/SwiperEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/SwiperEnchant.java new file mode 100644 index 0000000..1b1746c --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/SwiperEnchant.java @@ -0,0 +1,100 @@ +package su.nightexpress.excellentenchants.enchantment.impl.weapon; + +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.inventory.ItemStack; +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.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; + +public class SwiperEnchant extends ExcellentEnchant implements CombatEnchant, Chanced { + + public static final String ID = "swiper"; + + public static final String PLACEHOLER_XP_AMOUNT = "%xp_amount%"; + + private ChanceImplementation chanceImplementation; + private EnchantScaler xpAmount; + + public SwiperEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to steal " + PLACEHOLER_XP_AMOUNT + " XP from players."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.7); + } + + @Override + public void loadSettings() { + super.loadSettings(); + + this.chanceImplementation = ChanceImplementation.create(this, + "5.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 2.5"); + + this.xpAmount = EnchantScaler.read(this, "Settings.XP_Amount", + Placeholders.ENCHANTMENT_LEVEL, + "Amount of XP to be stolen on hit."); + + this.addPlaceholder(PLACEHOLER_XP_AMOUNT, level -> NumberUtil.format(this.getXPAmount(level))); + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.WEAPON; + } + + @NotNull + @Override + public Chanced getChanceImplementation() { + return this.chanceImplementation; + } + + public int getXPAmount(int level) { + return (int) this.xpAmount.getValue(level); + } + + private int getExpRequired(int level) { + if (level <= 15) return 2 * level + 7; + if (level <= 30) return 5 * level - 38; + return 9 * level - 158; + } + + private void addXP(@NotNull Player player, int amount) { + int levelHas = player.getLevel(); + int xpHas = player.getTotalExperience(); + + xpHas = Math.max(0, xpHas - amount); + player.setExp(0F); + player.setTotalExperience(0); + player.setLevel(0); + player.giveExp(xpHas); + } + + @Override + public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!(damager instanceof Player attacker)) return false; + if (!(victim instanceof Player defender)) return false; + if (defender.getTotalExperience() == 0) return false; + if (!this.checkTriggerChance(level)) return false; + + int amount = this.getXPAmount(level); + if (defender.getTotalExperience() < amount) amount = defender.getTotalExperience(); + + this.addXP(defender, -amount); + this.addXP(attacker, amount); + return true; + } + + @Override + public boolean onProtect(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return false; + } +} 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 48a5ec2..ea1f043 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 @@ -44,9 +44,11 @@ public class EnchantGenericListener extends AbstractListener } } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.MONITOR) public void onEnchantProjectileLand(ProjectileHitEvent event) { - EnchantUtils.removeSourceWeapon(event.getEntity()); + this.plugin.runTask(task -> { + EnchantUtils.removeSourceWeapon(event.getEntity()); + }); } // --------------------------------------------------------------- diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java index a158045..ce33fb0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java @@ -27,6 +27,7 @@ import su.nightexpress.excellentenchants.enchantment.impl.bow.*; import su.nightexpress.excellentenchants.enchantment.impl.fishing.*; import su.nightexpress.excellentenchants.enchantment.impl.tool.*; import su.nightexpress.excellentenchants.enchantment.impl.universal.CurseOfFragilityEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.universal.RestoreEnchant; import su.nightexpress.excellentenchants.enchantment.impl.universal.SoulboundEnchant; import su.nightexpress.excellentenchants.enchantment.impl.weapon.*; import su.nightexpress.excellentenchants.enchantment.registry.wrapper.DataGather; @@ -106,6 +107,7 @@ public class EnchantRegistry extends AbstractManager { this.register(EnchantBlindness.ID, () -> new EnchantBlindness(plugin)); this.register(EnchantConfusion.ID, () -> new EnchantConfusion(plugin)); this.register(EnchantCutter.ID, () -> new EnchantCutter(plugin)); + this.register(CurseOfDeathEnchant.ID, () -> new CurseOfDeathEnchant(plugin)); this.register(EnchantDecapitator.ID, () -> new EnchantDecapitator(plugin)); this.register(EnchantDoubleStrike.ID, () -> new EnchantDoubleStrike(plugin)); this.register(EnchantExhaust.ID, () -> new EnchantExhaust(plugin)); @@ -119,6 +121,7 @@ public class EnchantRegistry extends AbstractManager { this.register(EnchantRocket.ID, () -> new EnchantRocket(plugin)); this.register(EnchantScavenger.ID, () -> new EnchantScavenger(plugin)); this.register(EnchantSurprise.ID, () -> new EnchantSurprise(plugin)); + this.register(SwiperEnchant.ID, () -> new SwiperEnchant(plugin)); this.register(EnchantTemper.ID, () -> new EnchantTemper(plugin)); this.register(EnchantThrifty.ID, () -> new EnchantThrifty(plugin)); this.register(EnchantThunder.ID, () -> new EnchantThunder(plugin)); @@ -155,6 +158,7 @@ public class EnchantRegistry extends AbstractManager { this.register(EnchantHover.ID, () -> new EnchantHover(plugin)); this.register(SniperEnchant.ID, () -> new SniperEnchant(plugin)); this.register(EnchantPoisonedArrows.ID, () -> new EnchantPoisonedArrows(plugin)); + this.register(VampiricArrowsEnchant.ID, () -> new VampiricArrowsEnchant(plugin)); this.register(EnchantWitheredArrows.ID, () -> new EnchantWitheredArrows(plugin)); if (Version.isAbove(Version.V1_18_R2)) { this.register(DarknessArrowsEnchant.ID, () -> new DarknessArrowsEnchant(plugin)); @@ -165,6 +169,7 @@ public class EnchantRegistry extends AbstractManager { this.register(CurseOfFragilityEnchant.ID, () -> new CurseOfFragilityEnchant(plugin)); this.register(CurseOfMediocrityEnchant.ID, () -> new CurseOfMediocrityEnchant(plugin)); this.register(SoulboundEnchant.ID, () -> new SoulboundEnchant(plugin)); + this.register(RestoreEnchant.ID, () -> new RestoreEnchant(plugin)); Enchantment.stopAcceptingRegistrations(); this.plugin.info("Enchantments Registered: " + EnchantRegistry.getRegistered().size()); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java index 0df6e3b..80a018f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java @@ -267,10 +267,9 @@ public class DataGathers { @Override public boolean useEnchant(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, @NotNull DeathEnchant enchant, int level) { - Player killer = entity.getKiller(); - if (killer == null) return false; + if (!(entity instanceof Player killer)) return false; - return enchant.onKill(event, entity, killer, level); // TODO item? + return enchant.onKill(event, event.getEntity(), killer, item, level); } }; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/WrappedEvent.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/WrappedEvent.java index ec0b241..9ce3b1b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/WrappedEvent.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/WrappedEvent.java @@ -1,5 +1,6 @@ package su.nightexpress.excellentenchants.enchantment.registry.wrapper; +import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Event; import org.bukkit.event.EventPriority; 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 index ce33cf3..ed2253a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -239,7 +239,7 @@ public class EnchantUtils { public static void consumeCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int level) { int has = getCharges(item, enchant); int use = enchant.getChargesConsumeAmount(level); - setCharges(item, enchant, level,has < use ? 0 : has - use); + setCharges(item, enchant, level, has < use ? 0 : has - use); } /*public static void restoreCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { diff --git a/NMS/pom.xml b/NMS/pom.xml index 730d361..b7fe1cb 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.9 + 3.6.0 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml index 73ed7ae..8c68f01 100644 --- a/V1_17_R1/pom.xml +++ b/V1_17_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.9 + 3.6.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.9 + 3.6.0 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 5b2a71f..2b0d013 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.9 + 3.6.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.9 + 3.6.0 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 4068d37..7716f3d 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.9 + 3.6.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.9 + 3.6.0 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index 28e0214..8b041ab 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.9 + 3.6.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.9 + 3.6.0 diff --git a/V1_20_R2/pom.xml b/V1_20_R2/pom.xml index 84b4c86..1830142 100644 --- a/V1_20_R2/pom.xml +++ b/V1_20_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.5.9 + 3.6.0 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.5.9 + 3.6.0 diff --git a/pom.xml b/pom.xml index 284537e..5e9c7f8 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.5.9 + 3.6.0 Core NMS From 0eed750aecd141b7a4e7f2657d667124abfb9b5a Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 4 Oct 2023 16:46:14 +0500 Subject: [PATCH 60/69] Null slot fix --- .../enchantment/registry/wrapper/DataGathers.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java index 80a018f..b7848f6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java @@ -234,7 +234,7 @@ public class DataGathers { @NotNull @Override public EquipmentSlot[] getEnchantSlots(@NotNull EntityDamageByEntityEvent event) { - return EquipmentSlot.values(); + return new EquipmentSlot[] {EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET}; } @Override @@ -314,7 +314,7 @@ public class DataGathers { @NotNull @Override public EquipmentSlot[] getEnchantSlots(@NotNull PlayerFishEvent event) { - return new EquipmentSlot[] {event.getHand()}; + return event.getHand() == null ? new EquipmentSlot[] {EquipmentSlot.HAND} : new EquipmentSlot[]{event.getHand()}; } @Override @@ -339,7 +339,7 @@ public class DataGathers { @NotNull @Override public EquipmentSlot[] getEnchantSlots(@NotNull PlayerInteractEvent event) { - return new EquipmentSlot[]{event.getHand()}; + return event.getHand() == null ? new EquipmentSlot[] {EquipmentSlot.HAND} : new EquipmentSlot[]{event.getHand()}; } @Override From d5537829eb2c0f6ca6a648b117d807a13518cff7 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 24 Oct 2023 17:25:21 +0500 Subject: [PATCH 61/69] v3.6.2 --- .gitignore | 2 - Core/pom.xml | 23 +- .../excellentenchants/ExcellentEnchants.java | 11 +- .../nightexpress/excellentenchants/Perms.java | 4 +- .../excellentenchants/Placeholders.java | 1 + .../api/enchantment/meta/Periodic.java | 24 ++ .../api/enchantment/type/PassiveEnchant.java | 3 +- .../excellentenchants/config/Config.java | 14 +- .../excellentenchants/config/Lang.java | 14 +- .../enchantment/EnchantManager.java | 17 +- .../enchantment/impl/ExcellentEnchant.java | 4 + .../impl/armor/AquamanEnchant.java | 9 + .../impl/armor/JumpingEnchant.java | 9 + .../impl/armor/NightVisionEnchant.java | 9 + .../impl/armor/RegrowthEnchant.java | 65 +---- .../impl/armor/SaturationEnchant.java | 58 +--- .../enchantment/impl/armor/SpeedyEnchant.java | 9 + .../impl/bow/VampiricArrowsEnchant.java | 2 + .../impl/meta/PeriodImplementation.java | 55 ++++ .../impl/meta/PotionImplementation.java | 2 +- .../enchantment/impl/tool/HasteEnchant.java | 9 + .../impl/universal/SoulboundEnchant.java | 2 +- .../impl/weapon/EnchantDecapitator.java | 2 +- .../impl/weapon/EnchantThrifty.java | 9 +- .../impl/weapon/SwiperEnchant.java | 2 +- .../listener/EnchantHandlerListener.java | 251 ------------------ .../registry/wrapper/DataGathers.java | 3 + .../registry/wrapper/WrappedEvent.java | 8 +- ...mentTask.java => PassiveEnchantsTask.java} | 18 +- .../enchantment/task/PotionEffectsTask.java | 21 -- .../enchantment/util/EnchantUtils.java | 19 +- .../hook/impl/PlaceholderHook.java | 5 + Core/src/main/resources/plugin.yml | 2 +- NMS/pom.xml | 2 +- V1_17_R1/pom.xml | 71 ----- .../nms/v1_17_R1/V1_17_R1.java | 116 -------- V1_18_R2/pom.xml | 4 +- V1_19_R3/pom.xml | 4 +- V1_20_R1/pom.xml | 4 +- V1_20_R2/pom.xml | 4 +- pom.xml | 3 +- 41 files changed, 253 insertions(+), 641 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Periodic.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PeriodImplementation.java delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java rename Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/{AbstractEnchantmentTask.java => PassiveEnchantsTask.java} (57%) delete mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PotionEffectsTask.java delete mode 100644 V1_17_R1/pom.xml delete mode 100644 V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java diff --git a/.gitignore b/.gitignore index 94be98e..cfcd694 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,6 @@ /Core/pom.xml.versionsBackup /NMS/target/ /NMS/pom.xml.versionsBackup -/V1_17_R1/target/ -/V1_17_R1/pom.xml.versionsBackup /V1_18_R2/target/ /V1_18_R2/pom.xml.versionsBackup /V1_19_R3/target/ diff --git a/Core/pom.xml b/Core/pom.xml index 51460af..7a22cea 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.0 + 3.6.2 4.0.0 @@ -24,22 +24,18 @@ dmulloy2-repo https://repo.dmulloy2.net/repository/public/ - placeholderapi https://repo.extendedclip.com/content/repositories/placeholderapi/ - lumine-repo https://mvn.lumine.io/repository/maven-public/ - lumine-snapshot http://mvn.lumine.io/repository/maven-snapshots/ - @@ -64,7 +60,7 @@ com.comphenix.protocol ProtocolLib - 5.0.0 + 5.1.0 provided @@ -76,32 +72,27 @@ su.nightexpress.excellentenchants NMS - 3.6.0 - - - su.nightexpress.excellentenchants - V1_17_R1 - 3.6.0 + 3.6.2 su.nightexpress.excellentenchants V1_18_R2 - 3.6.0 + 3.6.2 su.nightexpress.excellentenchants V1_19_R3 - 3.6.0 + 3.6.2 su.nightexpress.excellentenchants V1_20_R1 - 3.6.0 + 3.6.2 su.nightexpress.excellentenchants V1_20_R2 - 3.6.0 + 3.6.2 diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 6e733a0..3beadac 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -23,7 +23,6 @@ import su.nightexpress.excellentenchants.hook.impl.PlaceholderHook; import su.nightexpress.excellentenchants.hook.impl.ProtocolHook; import su.nightexpress.excellentenchants.nms.EnchantNMS; import su.nightexpress.excellentenchants.nms.V1_20_R2; -import su.nightexpress.excellentenchants.nms.v1_17_R1.V1_17_R1; import su.nightexpress.excellentenchants.nms.v1_18_R2.V1_18_R2; import su.nightexpress.excellentenchants.nms.v1_19_R3.V1_19_R3; import su.nightexpress.excellentenchants.nms.v1_20_R1.V1_20_R1; @@ -50,7 +49,11 @@ public class ExcellentEnchants extends NexPlugin { @Override public void enable() { - this.setNMS(); + if (!this.setNMS()) { + this.error("Unsupported server version!"); + this.getPluginManager().disablePlugin(this); + return; + } this.tierManager = new TierManager(this); this.tierManager.setup(); @@ -85,15 +88,15 @@ public class ExcellentEnchants extends NexPlugin { this.registry.shutdown(); } - private void setNMS() { + private boolean setNMS() { this.enchantNMS = switch (Version.getCurrent()) { - case V1_17_R1 -> new V1_17_R1(); case V1_18_R2 -> new V1_18_R2(); case V1_19_R3 -> new V1_19_R3(); case V1_20_R1 -> new V1_20_R1(); case V1_20_R2 -> new V1_20_R2(); default -> null; }; + return this.enchantManager != null; } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java b/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java index 0eea32d..88045d3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Perms.java @@ -8,14 +8,14 @@ public class Perms { private static final String PREFIX = "excellentenchants."; private static final String PREFIX_COMMAND = PREFIX + "command."; - public static final JPermission PLUGIN = new JPermission(PREFIX + Placeholders.WILDCARD, "Access to all the plugin functions."); + public static final JPermission PLUGIN = new JPermission(PREFIX + Placeholders.WILDCARD, "Access to all the plugin functions."); public static final JPermission COMMAND = new JPermission(PREFIX_COMMAND + Placeholders.WILDCARD, "Access to all the plugin commands."); public static final JPermission COMMAND_BOOK = new JPermission(PREFIX_COMMAND + "book", "Allows to use '/eenchants book' command."); public static final JPermission COMMAND_ENCHANT = new JPermission(PREFIX_COMMAND + "enchant", "Allows to use '/eenchants enchant' command."); public static final JPermission COMMAND_LIST = new JPermission(PREFIX_COMMAND + "list", "Allows to use '/eenchants list' command.", PermissionDefault.TRUE); public static final JPermission COMMAND_TIERBOOK = new JPermission(PREFIX_COMMAND + "tierbook", "Allows to use '/eenchants tierbook' command."); - public static final JPermission COMMAND_RELOAD = new JPermission(PREFIX_COMMAND + "reload", "Allows to use '/eenchants reload' command."); + public static final JPermission COMMAND_RELOAD = new JPermission(PREFIX_COMMAND + "reload", "Allows to use '/eenchants reload' command."); static { PLUGIN.addChildren(COMMAND); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java index 12bc277..087a5b5 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java @@ -13,6 +13,7 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders { public static final String GENERIC_ENCHANT = "%enchant%"; public static final String ENCHANTMENT_CHANCE = "%enchantment_trigger_chance%"; + public static final String ENCHANTMENT_INTERVAL = "%enchantment_trigger_interval%"; 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%"; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Periodic.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Periodic.java new file mode 100644 index 0000000..426a1b2 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Periodic.java @@ -0,0 +1,24 @@ +package su.nightexpress.excellentenchants.api.enchantment.meta; + +import org.jetbrains.annotations.NotNull; + +public interface Periodic { + + @NotNull Periodic getPeriodImplementation(); + + default long getInterval(int level) { + return this.getPeriodImplementation().getInterval(level); + } + + default long getNextTriggerTime() { + return this.getPeriodImplementation().getNextTriggerTime(); + } + + default boolean isTriggerTime() { + return this.getPeriodImplementation().isTriggerTime(); + } + + default void updateTriggerTime(int level) { + this.getPeriodImplementation().updateTriggerTime(level); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/PassiveEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/PassiveEnchant.java index 2426733..28c190d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/PassiveEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/PassiveEnchant.java @@ -4,8 +4,9 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; +import su.nightexpress.excellentenchants.api.enchantment.meta.Periodic; -public interface PassiveEnchant extends IEnchantment { +public interface PassiveEnchant extends IEnchantment, Periodic { boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level); } 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 4fe365c..d4df3c3 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,18 @@ import java.util.stream.Stream; public class Config { - public static final JOption TASKS_ARROW_TRAIL_TICKS_INTERVAL = JOption.create("Tasks.Arrow_Trail.Tick_Interval", + 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", + + public static final JOption TASKS_PASSIVE_ENCHANTS_TRIGGER_INTERVAL = JOption.create("Tasks.Passive_Enchants.Trigger_Interval", 100L, - "Sets how often (in ticks) the plugin will apply permanent potion effects from enchanted items to an entity who wear them." + "Sets how often (in ticks) the plugin will attempt to trigger passive enchantment effects on all alive entities.", + "For best results it's recommened to keep this value smaller, but at the same rate as enchantment 'Trigger_Interval' settings.", + "Examples:", + "--- Global: 100 ticks; Regrowth: 100 ticks; Saturation: 100 ticks;", + "--- Global: 50 ticks, Regrowth: 100 ticks; Saturation: 150 ticks;" ); public static final JOption ENCHANTMENTS_CHARGES_ENABLED = JOption.create("Enchantments.Charges.Enabled", @@ -86,7 +91,8 @@ public class Config { "To disable all enchantments for a world, use '" + Placeholders.WILDCARD + "' instead of enchantment names.") .setWriter((cfg, path, map) -> map.forEach((world, enchants) -> cfg.set(path + "." + world, enchants))); - public static final JOption ENCHANTMENTS_DISPLAY_MODE = JOption.create("Enchantments.Display.Mode", 1, + public static final JOption ENCHANTMENTS_DISPLAY_MODE = JOption.create("Enchantments.Display.Mode", + 1, "Sets how enchantment names and descriptions will be handled on items.", "1 = Plain modification of item's lore (lore changes are real and persistent).", "2 = Packet modification of item's lore (no real changes are made to the items). Requires ProtocolLib.", 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 eaff27a..8ec49c7 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java @@ -2,9 +2,9 @@ package su.nightexpress.excellentenchants.config; import su.nexmedia.engine.api.lang.LangKey; import su.nexmedia.engine.lang.EngineLang; -import su.nightexpress.excellentenchants.Placeholders; -import static su.nexmedia.engine.utils.Colors.RED; +import static su.nexmedia.engine.utils.Colors.*; +import static su.nightexpress.excellentenchants.Placeholders.*; public class Lang extends EngineLang { @@ -12,18 +12,18 @@ public class Lang extends EngineLang { 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_ENCHANT_DONE = LangKey.of("Command.Enchant.Done", LIGHT_YELLOW + "Successfully enchanted!"); public static final LangKey COMMAND_ENCHANT_ERROR_NO_ITEM = LangKey.of("Command.Enchant.Error.NoItem", RED + "You must hold an item to enchant it!"); 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_BOOK_DONE = LangKey.of("Command.Book.Done", LIGHT_YELLOW + "Given " + ORANGE + GENERIC_ENCHANT + LIGHT_YELLOW + " enchanted book to " + ORANGE + PLAYER_DISPLAY_NAME + LIGHT_YELLOW + "."); 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 COMMAND_TIER_BOOK_ERROR = LangKey.of("Command.TierBook.Error", RED + "Invalid tier!"); + public static final LangKey COMMAND_TIER_BOOK_DONE = LangKey.of("Command.TierBook.Done", LIGHT_YELLOW + "Given " + ORANGE + TIER_NAME + LIGHT_YELLOW + " enchanted book to " + ORANGE + PLAYER_DISPLAY_NAME + LIGHT_YELLOW + "."); - public static final LangKey ERROR_NO_ENCHANT = LangKey.of("Error.NoEnchant", "&cInvalid enchantment."); + public static final LangKey ERROR_NO_ENCHANT = LangKey.of("Error.NoEnchant", RED + "Invalid 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 3e3dabe..332672a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantManager.java @@ -7,7 +7,7 @@ import su.nightexpress.excellentenchants.enchantment.listener.EnchantAnvilListen import su.nightexpress.excellentenchants.enchantment.listener.EnchantGenericListener; 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.task.PassiveEnchantsTask; public class EnchantManager extends AbstractManager { @@ -15,8 +15,8 @@ public class EnchantManager extends AbstractManager { private EnchantmentsListMenu enchantmentsListMenu; - private ArrowTrailsTask arrowTrailsTask; - private PotionEffectsTask potionEffectsTask; + private ArrowTrailsTask arrowTrailsTask; + private PassiveEnchantsTask passiveEnchantsTask; public EnchantManager(@NotNull ExcellentEnchants plugin) { super(plugin); @@ -25,15 +25,14 @@ public class EnchantManager extends AbstractManager { @Override protected void onLoad() { this.enchantmentsListMenu = new EnchantmentsListMenu(this.plugin); - //this.addListener(new EnchantHandlerListener(this)); this.addListener(new EnchantGenericListener(this)); this.addListener(new EnchantAnvilListener(this.plugin)); this.arrowTrailsTask = new ArrowTrailsTask(this.plugin); this.arrowTrailsTask.start(); - this.potionEffectsTask = new PotionEffectsTask(this.plugin); - this.potionEffectsTask.start(); + this.passiveEnchantsTask = new PassiveEnchantsTask(this.plugin); + this.passiveEnchantsTask.start(); } @Override @@ -46,9 +45,9 @@ public class EnchantManager extends AbstractManager { this.arrowTrailsTask.stop(); this.arrowTrailsTask = null; } - if (this.potionEffectsTask != null) { - this.potionEffectsTask.stop(); - this.potionEffectsTask = null; + if (this.passiveEnchantsTask != null) { + this.passiveEnchantsTask.stop(); + this.passiveEnchantsTask = null; } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index bf95036..1ebdc34 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -19,6 +19,7 @@ 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.Periodic; import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.EnchantManager; @@ -83,6 +84,9 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme if (this instanceof Chanced chanced) { map.add(Placeholders.ENCHANTMENT_CHANCE, () -> NumberUtil.format(chanced.getTriggerChance(level))); } + if (this instanceof Periodic periodic) { + map.add(Placeholders.ENCHANTMENT_INTERVAL, () -> NumberUtil.format(periodic.getInterval(level) / 20D)); + } if (this instanceof Potioned potioned) { map.add(Placeholders.ENCHANTMENT_POTION_LEVEL, () -> NumberUtil.toRoman(potioned.getEffectAmplifier(level))); map.add(Placeholders.ENCHANTMENT_POTION_DURATION, () -> NumberUtil.format(potioned.getEffectDuration(level) / 20D)); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/AquamanEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/AquamanEnchant.java index c3f969a..5fd16c9 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/AquamanEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/AquamanEnchant.java @@ -10,6 +10,7 @@ import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PeriodImplementation; import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; public class AquamanEnchant extends ExcellentEnchant implements Potioned, PassiveEnchant { @@ -17,6 +18,7 @@ public class AquamanEnchant extends ExcellentEnchant implements Potioned, Passiv public static final String ID = "aquaman"; private PotionImplementation potionImplementation; + private PeriodImplementation periodImplementation; public AquamanEnchant(@NotNull ExcellentEnchants plugin) { super(plugin, ID); @@ -29,6 +31,7 @@ public class AquamanEnchant extends ExcellentEnchant implements Potioned, Passiv public void loadSettings() { super.loadSettings(); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.WATER_BREATHING, true); + this.periodImplementation = PeriodImplementation.create(this, "100"); } @NotNull @@ -37,6 +40,12 @@ public class AquamanEnchant extends ExcellentEnchant implements Potioned, Passiv return potionImplementation; } + @NotNull + @Override + public PeriodImplementation getPeriodImplementation() { + return periodImplementation; + } + @Override @NotNull public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/JumpingEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/JumpingEnchant.java index b7dc33a..5a83310 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/JumpingEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/JumpingEnchant.java @@ -10,6 +10,7 @@ import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PeriodImplementation; import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; public class JumpingEnchant extends ExcellentEnchant implements Potioned, PassiveEnchant { @@ -17,6 +18,7 @@ public class JumpingEnchant extends ExcellentEnchant implements Potioned, Passiv public static final String ID = "bunny_hop"; private PotionImplementation potionImplementation; + private PeriodImplementation periodImplementation; public JumpingEnchant(@NotNull ExcellentEnchants plugin) { super(plugin, ID); @@ -29,6 +31,7 @@ public class JumpingEnchant extends ExcellentEnchant implements Potioned, Passiv public void loadSettings() { super.loadSettings(); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.JUMP, true); + this.periodImplementation = PeriodImplementation.create(this, "100"); } @NotNull @@ -37,6 +40,12 @@ public class JumpingEnchant extends ExcellentEnchant implements Potioned, Passiv return potionImplementation; } + @NotNull + @Override + public PeriodImplementation getPeriodImplementation() { + return periodImplementation; + } + @Override @NotNull public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/NightVisionEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/NightVisionEnchant.java index 6589f35..74b606c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/NightVisionEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/NightVisionEnchant.java @@ -10,6 +10,7 @@ import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PeriodImplementation; import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; public class NightVisionEnchant extends ExcellentEnchant implements Potioned, PassiveEnchant { @@ -17,6 +18,7 @@ public class NightVisionEnchant extends ExcellentEnchant implements Potioned, Pa public static final String ID = "night_vision"; private PotionImplementation potionImplementation; + private PeriodImplementation periodImplementation; public NightVisionEnchant(@NotNull ExcellentEnchants plugin) { super(plugin, ID); @@ -29,6 +31,7 @@ public class NightVisionEnchant extends ExcellentEnchant implements Potioned, Pa public void loadSettings() { super.loadSettings(); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.NIGHT_VISION, true); + this.periodImplementation = PeriodImplementation.create(this, "100"); } @NotNull @@ -37,6 +40,12 @@ public class NightVisionEnchant extends ExcellentEnchant implements Potioned, Pa return potionImplementation; } + @NotNull + @Override + public PeriodImplementation getPeriodImplementation() { + return periodImplementation; + } + @Override @NotNull public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java index 0620744..87c9d38 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java @@ -6,41 +6,36 @@ import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.utils.EntityUtil; import su.nexmedia.engine.utils.NumberUtil; import su.nexmedia.engine.utils.values.UniParticle; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; -import su.nightexpress.excellentenchants.api.enchantment.Cleanable; import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; 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.EnchantUtils; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PeriodImplementation; -public class RegrowthEnchant extends ExcellentEnchant implements Chanced, PassiveEnchant, Cleanable { +public class RegrowthEnchant extends ExcellentEnchant implements Chanced, PassiveEnchant { public static final String ID = "regrowth"; private static final String PLACEHOLDER_HEAL_AMOUNT = "%enchantment_heal_amount%"; private static final String PLACEHOLDER_HEAL_MIN_HEALTH = "%enchantment_heal_min_health%"; private static final String PLACEHOLDER_HEAL_MAX_HEALTH = "%enchantment_heal_max_health%"; - private static final String PLACEHOLDER_HEAL_INTERVAL = "%enchantment_heal_interval%"; - private long healInterval; private EnchantScaler healMinHealth; private EnchantScaler healMaxHealth; private EnchantScaler healAmount; private ChanceImplementation chanceImplementation; - private Task task; + private PeriodImplementation periodImplementation; public RegrowthEnchant(@NotNull ExcellentEnchants plugin) { super(plugin, ID); - this.getDefaults().setDescription("Restores " + PLACEHOLDER_HEAL_AMOUNT + " hearts every " + PLACEHOLDER_HEAL_INTERVAL + "s."); + this.getDefaults().setDescription("Restores " + PLACEHOLDER_HEAL_AMOUNT + " hearts every " + Placeholders.ENCHANTMENT_INTERVAL + "s."); this.getDefaults().setLevelMax(5); this.getDefaults().setTier(0.7); } @@ -50,8 +45,9 @@ public class RegrowthEnchant extends ExcellentEnchant implements Chanced, Passiv super.loadSettings(); 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.periodImplementation = PeriodImplementation.create(this, "100"); + this.healMinHealth = EnchantScaler.read(this, "Settings.Heal.Min_Health", "0.5", "Minimal entity health for the enchantment to have effect."); this.healMaxHealth = EnchantScaler.read(this, "Settings.Heal.Max_Health", "20.0", @@ -62,22 +58,6 @@ public class RegrowthEnchant extends ExcellentEnchant implements Chanced, Passiv this.addPlaceholder(PLACEHOLDER_HEAL_AMOUNT, level -> NumberUtil.format(this.getHealAmount(level))); this.addPlaceholder(PLACEHOLDER_HEAL_MIN_HEALTH, level -> NumberUtil.format(this.getHealMaxHealth(level))); this.addPlaceholder(PLACEHOLDER_HEAL_MAX_HEALTH, level -> NumberUtil.format(this.getHealMaxHealth(level))); - this.addPlaceholder(PLACEHOLDER_HEAL_INTERVAL, level -> NumberUtil.format((double) this.healInterval / 20D)); - - this.task = new Task(plugin); - this.task.start(); - } - - @Override - public void clear() { - this.stopTask(); - } - - private void stopTask() { - if (this.task != null) { - this.task.stop(); - this.task = null; - } } @NotNull @@ -86,6 +66,12 @@ public class RegrowthEnchant extends ExcellentEnchant implements Chanced, Passiv return chanceImplementation; } + @NotNull + @Override + public PeriodImplementation getPeriodImplementation() { + return periodImplementation; + } + @NotNull @Override public EnchantmentTarget getItemTarget() { @@ -104,10 +90,6 @@ public class RegrowthEnchant extends ExcellentEnchant implements Chanced, Passiv return this.healMaxHealth.getValue(level); } - public long getHealInterval() { - return this.healInterval; - } - @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { if (!this.checkTriggerChance(level)) return false; @@ -125,25 +107,4 @@ public class RegrowthEnchant extends ExcellentEnchant implements Chanced, Passiv } return true; } - - class Task extends AbstractEnchantmentTask { - - public Task(@NotNull ExcellentEnchants plugin) { - super(plugin, healInterval, false); - } - - @Override - public void action() { - for (LivingEntity entity : this.getEntities()) { - EnchantUtils.getEquipped(entity, RegrowthEnchant.class).forEach((item, enchants) -> { - enchants.forEach((enchant, level) -> { - if (enchant.isOutOfCharges(item)) return; - if (enchant.onTrigger(entity, item, level)) { - enchant.consumeCharges(item, level); - } - }); - }); - } - } - } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java index 263a8b1..c9f42dd 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java @@ -5,34 +5,29 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -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.Cleanable; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; -import su.nightexpress.excellentenchants.enchantment.task.AbstractEnchantmentTask; -import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PeriodImplementation; -public class SaturationEnchant extends ExcellentEnchant implements PassiveEnchant, Cleanable { +public class SaturationEnchant extends ExcellentEnchant implements PassiveEnchant { public static final String ID = "saturation"; private static final String PLACEHOLDER_SATURATION_AMOUNT = "%enchantment_saturation_amount%"; - private static final String PLACEHOLDER_SATURATION_INTERVAL = "%enchantment_saturation_interval%"; private static final String PLACEHOLDER_SATURATION_MAX_FOOD_LEVEL = "%enchantment_saturation_max_food_level%"; - private long saturationInterval; private EnchantScaler saturationAmount; private EnchantScaler saturationMaxFoodLevel; - private Task task; + private PeriodImplementation periodImplementation; public SaturationEnchant(@NotNull ExcellentEnchants plugin) { super(plugin, ID); - this.getDefaults().setDescription("Restores " + PLACEHOLDER_SATURATION_AMOUNT + " food points every " + PLACEHOLDER_SATURATION_INTERVAL + "s."); + this.getDefaults().setDescription("Restores " + PLACEHOLDER_SATURATION_AMOUNT + " food points every " + Placeholders.ENCHANTMENT_INTERVAL + "s."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.5); } @@ -40,31 +35,21 @@ public class SaturationEnchant extends ExcellentEnchant implements PassiveEnchan @Override public void loadSettings() { super.loadSettings(); - this.saturationInterval = JOption.create("Settings.Saturation.Interval", 100, - "How often (in ticks) enchantment will have effect? 1 second = 20 ticks.").read(cfg); + this.periodImplementation = PeriodImplementation.create(this, "100"); + this.saturationAmount = EnchantScaler.read(this, "Settings.Saturation.Amount", Placeholders.ENCHANTMENT_LEVEL, "Amount of food points to restore."); this.saturationMaxFoodLevel = EnchantScaler.read(this, "Settings.Saturation.Max_Food_Level", "20", "Maximal player's food level for the enchantment to stop feeding them."); this.addPlaceholder(PLACEHOLDER_SATURATION_AMOUNT, level -> NumberUtil.format(this.getSaturationAmount(level))); - this.addPlaceholder(PLACEHOLDER_SATURATION_INTERVAL, level -> NumberUtil.format((double) this.saturationInterval / 20D)); this.addPlaceholder(PLACEHOLDER_SATURATION_MAX_FOOD_LEVEL, level -> NumberUtil.format(this.getMaxFoodLevel(level))); - - this.task = new Task(plugin); - this.task.start(); } + @NotNull @Override - public void clear() { - this.stopTask(); - } - - private void stopTask() { - if (this.task != null) { - this.task.stop(); - this.task = null; - } + public PeriodImplementation getPeriodImplementation() { + return periodImplementation; } @Override @@ -81,10 +66,6 @@ public class SaturationEnchant extends ExcellentEnchant implements PassiveEnchan return (int) this.saturationMaxFoodLevel.getValue(level); } - public long getSaturationInterval() { - return saturationInterval; - } - @Override public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { if (!(entity instanceof Player player)) return false; @@ -94,25 +75,4 @@ public class SaturationEnchant extends ExcellentEnchant implements PassiveEnchan player.setFoodLevel(Math.min(20, player.getFoodLevel() + amount)); return true; } - - class Task extends AbstractEnchantmentTask { - - public Task(@NotNull ExcellentEnchants plugin) { - super(plugin, saturationInterval, false); - } - - @Override - public void action() { - for (LivingEntity entity : this.getEntities()) { - EnchantUtils.getEquipped(entity, SaturationEnchant.class).forEach((item, enchants) -> { - enchants.forEach((enchant, level) -> { - if (enchant.isOutOfCharges(item)) return; - if (enchant.onTrigger(entity, item, level)) { - enchant.consumeCharges(item, level); - } - }); - }); - } - } - } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SpeedyEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SpeedyEnchant.java index 116c70d..e3dc556 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SpeedyEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SpeedyEnchant.java @@ -10,6 +10,7 @@ import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PeriodImplementation; import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; public class SpeedyEnchant extends ExcellentEnchant implements Potioned, PassiveEnchant { @@ -17,6 +18,7 @@ public class SpeedyEnchant extends ExcellentEnchant implements Potioned, Passive public static final String ID = "sonic"; private PotionImplementation potionImplementation; + private PeriodImplementation periodImplementation; public SpeedyEnchant(@NotNull ExcellentEnchants plugin) { super(plugin, ID); @@ -29,6 +31,7 @@ public class SpeedyEnchant extends ExcellentEnchant implements Potioned, Passive public void loadSettings() { super.loadSettings(); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.SPEED, true); + this.periodImplementation = PeriodImplementation.create(this, "100"); } @NotNull @@ -37,6 +40,12 @@ public class SpeedyEnchant extends ExcellentEnchant implements Potioned, Passive return potionImplementation; } + @NotNull + @Override + public PeriodImplementation getPeriodImplementation() { + return periodImplementation; + } + @Override @NotNull public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/VampiricArrowsEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/VampiricArrowsEnchant.java index c439858..58965d3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/VampiricArrowsEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/VampiricArrowsEnchant.java @@ -104,6 +104,8 @@ public class VampiricArrowsEnchant extends ExcellentEnchant implements BowEnchan @Override public boolean onDamage(@NotNull EntityDamageByEntityEvent event, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (shooter.isDead() || shooter.getHealth() <= 0D) return false; + double healAmount = this.getHealAmount(level); if (healAmount <= 0D) return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PeriodImplementation.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PeriodImplementation.java new file mode 100644 index 0000000..b0d0327 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PeriodImplementation.java @@ -0,0 +1,55 @@ +package su.nightexpress.excellentenchants.enchantment.impl.meta; + +import org.jetbrains.annotations.NotNull; +import su.nightexpress.excellentenchants.api.enchantment.meta.Periodic; +import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; + +public class PeriodImplementation implements Periodic { + + private final EnchantScaler triggerInterval; + + private long nextTriggerTime; + + public PeriodImplementation(@NotNull ExcellentEnchant enchant, @NotNull EnchantScaler triggerInterval) { + this.triggerInterval = triggerInterval; + } + + @NotNull + public static PeriodImplementation create(@NotNull ExcellentEnchant enchant) { + return create(enchant, "100"); + } + + @NotNull + public static PeriodImplementation create(@NotNull ExcellentEnchant enchant, @NotNull String def) { + return new PeriodImplementation(enchant, EnchantScaler.read(enchant, "Settings.Trigger_Interval", def, + "Sets how often (in ticks) this enchantment will be triggered.", + "20 ticks = 1 second.")); + } + + @NotNull + @Override + public Periodic getPeriodImplementation() { + return this; + } + + @Override + public long getInterval(int level) { + return (long) this.triggerInterval.getValue(level); + } + + @Override + public long getNextTriggerTime() { + return nextTriggerTime; + } + + @Override + public boolean isTriggerTime() { + return System.currentTimeMillis() >= this.getNextTriggerTime(); + } + + @Override + public void updateTriggerTime(int level) { + this.nextTriggerTime = System.currentTimeMillis() + this.getInterval(level) / 20L * 1000L; + } +} 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 9ec91f2..45db877 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 @@ -64,7 +64,7 @@ public final class PotionImplementation implements Potioned { public int getEffectDuration(int level) { if (this.isPermanent()) { - int duration = Config.TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL.get().intValue() + 30; + int duration = Config.TASKS_PASSIVE_ENCHANTS_TRIGGER_INTERVAL.get().intValue() + 30; if (this.getEffectType().getName().equalsIgnoreCase(PotionEffectType.NIGHT_VISION.getName())) { duration += 30 * 20; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/HasteEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/HasteEnchant.java index 4fd578b..112dd48 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/HasteEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/HasteEnchant.java @@ -10,6 +10,7 @@ import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PeriodImplementation; import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; public class HasteEnchant extends ExcellentEnchant implements Potioned, PassiveEnchant { @@ -17,6 +18,7 @@ public class HasteEnchant extends ExcellentEnchant implements Potioned, PassiveE public static final String ID = "haste"; private PotionImplementation potionImplementation; + private PeriodImplementation periodImplementation; public HasteEnchant(@NotNull ExcellentEnchants plugin) { super(plugin, ID); @@ -29,6 +31,7 @@ public class HasteEnchant extends ExcellentEnchant implements Potioned, PassiveE public void loadSettings() { super.loadSettings(); this.potionImplementation = PotionImplementation.create(this, PotionEffectType.FAST_DIGGING, true); + this.periodImplementation = PeriodImplementation.create(this, "100"); } @NotNull @@ -37,6 +40,12 @@ public class HasteEnchant extends ExcellentEnchant implements Potioned, PassiveE return potionImplementation; } + @NotNull + @Override + public PeriodImplementation getPeriodImplementation() { + return periodImplementation; + } + @Override @NotNull public EnchantmentTarget getItemTarget() { diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java index c68ebf2..9fd8704 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java @@ -64,7 +64,7 @@ public class SoulboundEnchant extends ExcellentEnchant implements GenericEnchant world.dropItemNaturally(location, save); } else { - this.consumeCharges(save, EnchantUtils.getLevel(save, this)); + this.consumeChargesNoUpdate(save, EnchantUtils.getLevel(save, this)); player.getInventory().addItem(save); } }); 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 32bb370..abdd334 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 @@ -218,7 +218,7 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea String texture = this.headTextures.get(entity.getType()); if (texture == null) return false; - entityName = this.headName.replace(Placeholders.GENERIC_TYPE, plugin.getLangManager().getEnum(entity.getType())); + entityName = this.headName.replace(Placeholders.GENERIC_TYPE, LangManager.getEntityType(entity.getType())); ItemUtil.setSkullTexture(item, texture); meta = (SkullMeta) item.getItemMeta(); } 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 3f4949d..247ba4c 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 @@ -12,6 +12,7 @@ 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.api.manager.EventListener; import su.nexmedia.engine.utils.PDCUtil; import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -25,7 +26,7 @@ import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; -public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEnchant { +public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEnchant, EventListener { public static final String ID = "thrifty"; @@ -98,9 +99,9 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onCreatureSpawn(CreatureSpawnEvent e) { - if (!this.ignoredSpawnReasons.contains(e.getSpawnReason())) return; + public void onCreatureSpawn(CreatureSpawnEvent event) { + if (!this.ignoredSpawnReasons.contains(event.getSpawnReason())) return; - PDCUtil.set(e.getEntity(), this.keyEntityIgnored, true); + PDCUtil.set(event.getEntity(), this.keyEntityIgnored, true); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/SwiperEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/SwiperEnchant.java index 1b1746c..39b966a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/SwiperEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/SwiperEnchant.java @@ -71,7 +71,7 @@ public class SwiperEnchant extends ExcellentEnchant implements CombatEnchant, Ch int levelHas = player.getLevel(); int xpHas = player.getTotalExperience(); - xpHas = Math.max(0, xpHas - amount); + xpHas = Math.max(0, xpHas + amount); player.setExp(0F); player.setTotalExperience(0); player.setLevel(0); 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 deleted file mode 100644 index 5a71e2c..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java +++ /dev/null @@ -1,251 +0,0 @@ -package su.nightexpress.excellentenchants.enchantment.listener; - -import org.jetbrains.annotations.NotNull; -import su.nexmedia.engine.api.manager.AbstractListener; -import su.nightexpress.excellentenchants.ExcellentEnchants; -import su.nightexpress.excellentenchants.enchantment.EnchantManager; - -public class EnchantHandlerListener extends AbstractListener { - - public EnchantHandlerListener(@NotNull EnchantManager enchantManager) { - super(enchantManager.plugin()); - } - - // --------------------------------------------------------------- - // Combat Attacking Enchants - // --------------------------------------------------------------- - /*@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantCombatMelee(EntityDamageEvent event) { - if (event.getCause() == DamageCause.THORNS) return; - if (!(event.getEntity() instanceof LivingEntity victim)) return; - - if (event instanceof EntityDamageByEntityEvent ede) { - if (ede.getDamager() instanceof Projectile projectile && this.getSourceWeapon(projectile) != null) { - this.handleCombatBowEnchants(ede, projectile, victim); - return; - } - - if (!(ede.getDamager() instanceof LivingEntity damager) || damager == victim) return; - - this.handleCombatWeaponEnchants(ede, damager, victim); - this.handleCombatArmorEnchants(ede, damager, victim); - } - else { - this.handleArmorEnchants(event, victim); - } - } - - private void handleCombatWeaponEnchants(@NotNull EntityDamageByEntityEvent e, - @NotNull LivingEntity damager, @NotNull LivingEntity victim) { - EntityEquipment equipment = damager.getEquipment(); - if (equipment == null) return; - - ItemStack weapon = equipment.getItemInMainHand(); - if (weapon.getType().isAir() || weapon.getType() == Material.ENCHANTED_BOOK) return; - - EnchantUtils.getExcellents(weapon, CombatEnchant.class).forEach((combatEnchant, level) -> { - if (combatEnchant.isOutOfCharges(weapon)) return; - if (combatEnchant.onAttack(e, damager, victim, weapon, level)) { - combatEnchant.consumeChargesNoUpdate(weapon, level); - } - }); - EnchantUtils.updateChargesDisplay(weapon); - } - - private void handleCombatArmorEnchants(@NotNull EntityDamageByEntityEvent e, - @NotNull LivingEntity damager, @NotNull LivingEntity victim) { - EntityEquipment equipDamager = damager.getEquipment(); - if (equipDamager == null) return; - - ItemStack weaponDamager = equipDamager.getItemInMainHand(); - - for (ItemStack armor : EntityUtil.getEquippedArmor(victim).values()) { - if (armor == null || armor.getType().isAir()) continue; - - EnchantUtils.getExcellents(armor, CombatEnchant.class).forEach((combatEnchant, level) -> { - if (combatEnchant.isOutOfCharges(armor)) return; - if (combatEnchant.onProtect(e, damager, victim, weaponDamager, level)) { - combatEnchant.consumeChargesNoUpdate(armor, level); - } - }); - EnchantUtils.updateChargesDisplay(armor); - } - } - - private void handleArmorEnchants(@NotNull EntityDamageEvent e, @NotNull LivingEntity entity) { - EnchantUtils.getEquipped(entity, DamageEnchant.class).forEach((item, enchants) -> { - enchants.forEach((enchant, level) -> { - if (enchant.isOutOfCharges(item)) return; - if (enchant.onDamage(e, entity, item, level)) { - enchant.consumeChargesNoUpdate(item, level); - } - }); - EnchantUtils.updateChargesDisplay(item); - }); - } - - private void handleCombatBowEnchants(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, - @NotNull LivingEntity victim) { - if (!(projectile.getShooter() instanceof LivingEntity shooter)) return; - - ItemStack bow = this.getSourceWeapon(projectile); - if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; - - EnchantUtils.getExcellents(bow, BowEnchant.class).forEach((bowEnchant, level) -> { - bowEnchant.onDamage(e, projectile, shooter, victim, bow, level); - }); - } - - // --------------------------------------------------------------- - // Bow Shooting Enchants - // --------------------------------------------------------------- - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantBowShoot(EntityShootBowEvent event) { - LivingEntity shooter = event.getEntity(); - if (shooter.getEquipment() == null) return; - - ItemStack bow = event.getBow(); - if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; - - EnchantUtils.getExcellents(bow, BowEnchant.class).forEach((bowEnchant, level) -> { - if (bowEnchant.isOutOfCharges(bow)) return; - if (bowEnchant.onShoot(event, shooter, bow, level)) { - if (bowEnchant instanceof Arrowed arrowed && event.getProjectile() instanceof Projectile projectile) { - arrowed.addData(projectile); - arrowed.addTrail(projectile); - } - bowEnchant.consumeChargesNoUpdate(bow, level); - } - }); - EnchantUtils.updateChargesDisplay(bow); - - if (event.getProjectile() instanceof Projectile projectile) { - this.setSourceWeapon(projectile, bow); - } - } - - // --------------------------------------------------------------- - // Bow Hit Land Enchants - // --------------------------------------------------------------- - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantBowHit(ProjectileHitEvent event) { - Projectile projectile = event.getEntity(); - - ItemStack bow = this.getSourceWeapon(projectile); - if (bow == null || bow.getType().isAir() || bow.getType() == Material.ENCHANTED_BOOK) return; - - EnchantUtils.getExcellents(bow, BowEnchant.class).forEach((bowEnchant, level) -> { - bowEnchant.onHit(event, null, projectile, bow, level); - }); - - // Prevent to apply enchants multiple times on hits. - this.plugin.runTask(task -> this.removeSourceWeapon(projectile)); - } - - // --------------------------------------------------------------- - // Interaction Related Enchants - // --------------------------------------------------------------- - @EventHandler(priority = EventPriority.HIGHEST) - public void onEnchantInteract(PlayerInteractEvent event) { - if (event.useInteractedBlock() == Result.DENY) return; - if (event.useItemInHand() == Result.DENY) return; - - ItemStack item = event.getItem(); - if (item == null || item.getType().isAir() || item.getType() == Material.ENCHANTED_BOOK) return; - - Player player = event.getPlayer(); - EnchantUtils.getExcellents(item, InteractEnchant.class).forEach((interEnchant, level) -> { - if (interEnchant.isOutOfCharges(item)) return; - if (interEnchant.onInteract(event, player, item, level)) { - interEnchant.consumeChargesNoUpdate(item, level); - } - }); - EnchantUtils.updateChargesDisplay(item); - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEnchantFishing(PlayerFishEvent event) { - Player player = event.getPlayer(); - - ItemStack item = EnchantUtils.getFishingRod(player); - if (item == null) return; - - EnchantUtils.getExcellents(item, FishingEnchant.class).forEach((enchant, level) -> { - if (event.isCancelled()) return; // Check if event was cancelled by some enchantment. - if (enchant.isOutOfCharges(item)) return; - if (enchant.onFishing(event, item, level)) { - enchant.consumeChargesNoUpdate(item, level); - } - }); - EnchantUtils.updateChargesDisplay(item); - } - - // --------------------------------------------------------------- - // Death Related Enchants - // --------------------------------------------------------------- - @EventHandler(priority = EventPriority.HIGHEST) - public void onEnchantDeath(EntityDeathEvent event) { - LivingEntity entity = event.getEntity(); - - EnchantUtils.getEquipped(entity, DeathEnchant.class).forEach((item, enchants) -> { - enchants.forEach(((deathEnchant, level) -> { - if (deathEnchant.isOutOfCharges(item)) return; - if (deathEnchant.onDeath(event, entity, item, level)) { - deathEnchant.consumeChargesNoUpdate(item, level); - } - })); - if (Config.ENCHANTMENTS_CHARGES_ENABLED.get()) { - EnchantUtils.updateChargesDisplay(item); - } - }); - - Player killer = entity.getKiller(); - if (killer == null) return; - - ItemStack weapon = killer.getInventory().getItemInMainHand(); - if (weapon.getType().isAir() || weapon.getType() == Material.ENCHANTED_BOOK) return; - - EnchantUtils.getExcellents(weapon, DeathEnchant.class).forEach((deathEnchant, level) -> { - if (deathEnchant.isOutOfCharges(weapon)) return; - if (deathEnchant.onKill(event, entity, killer, level)) { - deathEnchant.consumeChargesNoUpdate(weapon, level); - } - }); - EnchantUtils.updateChargesDisplay(weapon); - } - - // Handle BlockBreak enchantments. - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantBlockBreak(BlockBreakEvent event) { - Player player = event.getPlayer(); - if (player.getGameMode() == GameMode.CREATIVE) return; - - ItemStack tool = player.getInventory().getItemInMainHand(); - if (tool.getType().isAir() || tool.getType() == Material.ENCHANTED_BOOK) return; - - EnchantUtils.getExcellents(tool, BlockBreakEnchant.class).forEach((blockEnchant, level) -> { - if (blockEnchant.isOutOfCharges(tool)) return; - if (blockEnchant.onBreak(event, player, tool, level)) { - blockEnchant.consumeChargesNoUpdate(tool, level); - } - }); - EnchantUtils.updateChargesDisplay(tool); - } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onEnchantBlockDropItem(BlockDropItemEvent event) { - Player player = event.getPlayer(); - if (player.getGameMode() == GameMode.CREATIVE) return; - - ItemStack tool = player.getInventory().getItemInMainHand(); - if (tool.getType().isAir() || tool.getType() == Material.ENCHANTED_BOOK) return; - - EnchantUtils.getExcellents(tool, BlockDropEnchant.class).forEach((enchant, level) -> { - if (enchant.isOutOfCharges(tool)) return; - if (enchant.onDrop(event, player, tool, level)) { - enchant.consumeChargesNoUpdate(tool, level); - } - }); - EnchantUtils.updateChargesDisplay(tool); - }*/ -} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java index b7848f6..320835a 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/DataGathers.java @@ -14,6 +14,7 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.Version; import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; import su.nightexpress.excellentenchants.api.enchantment.type.*; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; @@ -314,6 +315,8 @@ public class DataGathers { @NotNull @Override public EquipmentSlot[] getEnchantSlots(@NotNull PlayerFishEvent event) { + if (Version.isBehind(Version.V1_19_R3)) return new EquipmentSlot[] {EquipmentSlot.HAND}; + return event.getHand() == null ? new EquipmentSlot[] {EquipmentSlot.HAND} : new EquipmentSlot[]{event.getHand()}; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/WrappedEvent.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/WrappedEvent.java index 9ce3b1b..c210447 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/WrappedEvent.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/wrapper/WrappedEvent.java @@ -1,7 +1,7 @@ package su.nightexpress.excellentenchants.enchantment.registry.wrapper; -import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -40,6 +40,8 @@ public class WrappedEvent implements Li LivingEntity entity = this.dataGather.getEntity(event); if (entity == null) return; + Player player = entity instanceof Player p1 ? p1 : null; + this.dataGather.getEnchants(event, this.enchantClass, entity).forEach((item, enchants) -> { enchants.forEach(((enchant, level) -> { if (!this.dataGather.checkPriority(enchant, this.priority)) return; @@ -49,8 +51,8 @@ public class WrappedEvent implements Li enchant.consumeChargesNoUpdate(item, level); } })); - if (Config.ENCHANTMENTS_CHARGES_ENABLED.get()) { - EnchantUtils.updateChargesDisplay(item); + if (this.priority == EventPriority.MONITOR && Config.ENCHANTMENTS_CHARGES_ENABLED.get() && player != null) { + EnchantUtils.updateDisplay(item); } }); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/AbstractEnchantmentTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PassiveEnchantsTask.java similarity index 57% rename from Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/AbstractEnchantmentTask.java rename to Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PassiveEnchantsTask.java index df7d292..b10289f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/AbstractEnchantmentTask.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PassiveEnchantsTask.java @@ -5,19 +5,27 @@ import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.server.AbstractTask; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.Collection; import java.util.HashSet; import java.util.Set; -public abstract class AbstractEnchantmentTask extends AbstractTask { +public class PassiveEnchantsTask extends AbstractTask { - public AbstractEnchantmentTask(@NotNull ExcellentEnchants plugin, long interval, boolean async) { - super(plugin, interval, async); + public PassiveEnchantsTask(@NotNull ExcellentEnchants plugin) { + super(plugin, Config.TASKS_PASSIVE_ENCHANTS_TRIGGER_INTERVAL.get(), false); + } + + @Override + public void action() { + for (LivingEntity entity : this.getEntities()) { + EnchantUtils.triggerPassiveEnchants(entity); + } } @NotNull - protected Collection getEntities() { + private Collection getEntities() { Set list = new HashSet<>(plugin.getServer().getOnlinePlayers()); if (Config.ENCHANTMENTS_ENTITY_PASSIVE_FOR_MOBS.get()) { @@ -25,7 +33,7 @@ public abstract class AbstractEnchantmentTask extends AbstractTask e.isDead() || !e.isValid()); + list.removeIf(entity -> entity.isDead() || !entity.isValid()); return list; } } 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 deleted file mode 100644 index 2d2a777..0000000 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PotionEffectsTask.java +++ /dev/null @@ -1,21 +0,0 @@ -package su.nightexpress.excellentenchants.enchantment.task; - -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.util.EnchantUtils; - -public class PotionEffectsTask extends AbstractEnchantmentTask { - - public PotionEffectsTask(@NotNull ExcellentEnchants plugin) { - super(plugin, Config.TASKS_PASSIVE_POTION_EFFECTS_APPLY_INTERVAL.get(), false); - } - - @Override - public void action() { - for (LivingEntity entity : this.getEntities()) { - EnchantUtils.updateEquippedEffects(entity); - } - } -} 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 index ed2253a..95072e8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -24,7 +24,6 @@ import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PDCUtil; 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.enchantment.impl.ExcellentEnchant; @@ -356,18 +355,22 @@ public class EnchantUtils { return map; } - public static void updateEquippedEffects(@NotNull LivingEntity entity) { + public static void triggerPassiveEnchants(@NotNull LivingEntity entity) { + Player player = entity instanceof Player p1 ? p1 : null; + getEquipped(entity, PassiveEnchant.class).forEach((item, enchants) -> { enchants.forEach((enchant, level) -> { if (!enchant.isAvailableToUse(entity)) return; - if (enchant instanceof Potioned potioned) { - if (enchant.isOutOfCharges(item)) return; - if (enchant.onTrigger(entity, item, level)) { - enchant.consumeChargesNoUpdate(item, level); - } + if (!enchant.isTriggerTime()) return; + if (enchant.isOutOfCharges(item)) return; + if (enchant.onTrigger(entity, item, level)) { + enchant.consumeChargesNoUpdate(item, level); + enchant.updateTriggerTime(level); } }); - EnchantUtils.updateChargesDisplay(item); + if (Config.ENCHANTMENTS_CHARGES_ENABLED.get() && player != null) { + EnchantUtils.updateDisplay(item); + } }); } 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 604c102..f2cde44 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 @@ -50,6 +50,11 @@ public class PlaceholderHook { return ExcellentEnchantsAPI.PLUGIN.getDescription().getVersion(); } + @Override + public boolean persist() { + return true; + } + @Override @Nullable public String onPlaceholderRequest(Player player, @NotNull String params) { diff --git a/Core/src/main/resources/plugin.yml b/Core/src/main/resources/plugin.yml index ae3c11b..f7eea7d 100644 --- a/Core/src/main/resources/plugin.yml +++ b/Core/src/main/resources/plugin.yml @@ -5,5 +5,5 @@ author: NightExpress desciption: Vanilla-like enchants for your server. depend: [ NexEngine ] softdepend: [ ProtocolLib, NoCheatPlus, PlaceholderAPI, MythicMobs ] -api-version: 1.17 +api-version: 1.18 load: STARTUP \ No newline at end of file diff --git a/NMS/pom.xml b/NMS/pom.xml index b7fe1cb..9bf13cf 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.0 + 3.6.2 4.0.0 diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml deleted file mode 100644 index 8c68f01..0000000 --- a/V1_17_R1/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - ExcellentEnchants - su.nightexpress.excellentenchants - 3.6.0 - - 4.0.0 - - V1_17_R1 - - - 16 - 16 - - - - - org.spigotmc - spigot - 1.17.1-R0.1-SNAPSHOT - remapped-mojang - - - su.nightexpress.excellentenchants - NMS - 3.6.0 - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.3 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:1.17.1-R0.1-SNAPSHOT:txt:maps-mojang - true - org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT:jar:remapped-mojang - true - remapped-obf - - - - package - - remap - - remap-spigot - - ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.17.1-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT:jar:remapped-obf - - - - - - - - \ No newline at end of file diff --git a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java b/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java deleted file mode 100644 index 2612742..0000000 --- a/V1_17_R1/src/main/java/su/nightexpress/excellentenchants/nms/v1_17_R1/V1_17_R1.java +++ /dev/null @@ -1,116 +0,0 @@ -package su.nightexpress.excellentenchants.nms.v1_17_R1; - -import net.minecraft.core.BlockPos; -import net.minecraft.network.protocol.game.ClientboundAnimatePacket; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.projectile.FishingHook; -import net.minecraft.world.item.SpawnEggItem; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.LiquidBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.shapes.CollisionContext; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftFishHook; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; -import org.bukkit.entity.FishHook; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import su.nightexpress.excellentenchants.nms.EnchantNMS; - -import java.util.HashSet; -import java.util.Set; - -public class V1_17_R1 implements EnchantNMS { - - @Override - public void sendAttackPacket(@NotNull Player player, int id) { - CraftPlayer craftPlayer = (CraftPlayer) player; - Entity entity = craftPlayer.getHandle(); - ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id); - craftPlayer.getHandle().connection.send(packet); - } - - @Override - public void retrieveHook(@NotNull FishHook hook, @NotNull ItemStack item) { - CraftFishHook craftFishHook = (CraftFishHook) hook; - FishingHook handle = craftFishHook.getHandle(); - handle.retrieve(CraftItemStack.asNMSCopy(item)); - } - - @Override - @Nullable - public ItemStack getSpawnEgg(@NotNull LivingEntity entity) { - CraftLivingEntity craftLivingEntity = (CraftLivingEntity) entity; - net.minecraft.world.entity.LivingEntity livingEntity = craftLivingEntity.getHandle(); - - SpawnEggItem eggItem = SpawnEggItem.byId(livingEntity.getType()); - if (eggItem == null) return null; - - return CraftItemStack.asBukkitCopy(eggItem.getDefaultInstance()); - } - - @Override - @NotNull - public Set handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) { - Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle(); - BlockPos pos = new BlockPos(location.getX(), location.getY(), location.getZ()); - ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle(); - - float radius = Math.min(16F, 2F + level); - BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState(); - BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos(); - - Set blocks = new HashSet<>(); - for (BlockPos posNear : BlockPos.betweenClosed(pos.b(-radius, -1.0, -radius), pos.b(radius, -1.0, radius))) { - if (!posNear.closerThan(entity.position(), radius)) continue; - - posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ()); - - BlockState bLavaAbove = world.getBlockState(posAbove); - BlockState bLava = world.getBlockState(posNear); - - if (!bLavaAbove.isAir()) continue; - if (!bLava.getBlock().equals(Blocks.LAVA)) continue; - if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue; - if (!bStone.canSurvive(world, posNear)) continue; - if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue; - if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue; - //world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120)); - - Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ()); - blocks.add(bukkitLoc.getBlock()); - } - return blocks; - } - - @NotNull - public Item popResource(@NotNull Block block, @NotNull ItemStack item) { - Level world = ((CraftWorld)block.getWorld()).getHandle(); - BlockPos pos = ((CraftBlock)block).getPosition(); - net.minecraft.world.item.ItemStack itemstack = CraftItemStack.asNMSCopy(item); - - float yMod = EntityType.ITEM.getHeight() / 2.0F; - double x = (pos.getX() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D); - double y = (pos.getY() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D) - yMod; - double z = (pos.getZ() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D); - - ItemEntity itemEntity = new ItemEntity(world, x, y, z, itemstack); - itemEntity.setDefaultPickUpDelay(); - return (Item) itemEntity.getBukkitEntity(); - } -} diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index 2b0d013..c94731d 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.0 + 3.6.2 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.0 + 3.6.2 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 7716f3d..bbc2704 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.0 + 3.6.2 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.0 + 3.6.2 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index 8b041ab..276ae4c 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.0 + 3.6.2 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.0 + 3.6.2 diff --git a/V1_20_R2/pom.xml b/V1_20_R2/pom.xml index 1830142..a6f89c4 100644 --- a/V1_20_R2/pom.xml +++ b/V1_20_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.0 + 3.6.2 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.0 + 3.6.2 diff --git a/pom.xml b/pom.xml index 5e9c7f8..576e24a 100644 --- a/pom.xml +++ b/pom.xml @@ -7,11 +7,10 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.6.0 + 3.6.2 Core NMS - V1_17_R1 V1_18_R2 V1_19_R3 V1_20_R1 From 938d15c2f4862e77be8591cba480f085c54e28ab Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 25 Oct 2023 00:37:49 +0500 Subject: [PATCH 62/69] PassiveEnchantsTask fix --- .../excellentenchants/ExcellentEnchants.java | 2 +- .../api/enchantment/meta/Periodic.java | 8 ++-- .../enchantment/impl/ExcellentEnchant.java | 2 +- .../impl/meta/PeriodImplementation.java | 8 ++-- .../impl/meta/PotionImplementation.java | 4 +- .../enchantment/task/PassiveEnchantsTask.java | 38 +++++++++++++++++-- .../enchantment/util/EnchantUtils.java | 24 ++++-------- 7 files changed, 55 insertions(+), 31 deletions(-) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index 3beadac..ad15f58 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -96,7 +96,7 @@ public class ExcellentEnchants extends NexPlugin { case V1_20_R2 -> new V1_20_R2(); default -> null; }; - return this.enchantManager != null; + return this.enchantNMS != null; } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Periodic.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Periodic.java index 426a1b2..f2194ce 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Periodic.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/meta/Periodic.java @@ -6,8 +6,8 @@ public interface Periodic { @NotNull Periodic getPeriodImplementation(); - default long getInterval(int level) { - return this.getPeriodImplementation().getInterval(level); + default long getInterval() { + return this.getPeriodImplementation().getInterval(); } default long getNextTriggerTime() { @@ -18,7 +18,7 @@ public interface Periodic { return this.getPeriodImplementation().isTriggerTime(); } - default void updateTriggerTime(int level) { - this.getPeriodImplementation().updateTriggerTime(level); + default void updateTriggerTime() { + this.getPeriodImplementation().updateTriggerTime(); } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index 1ebdc34..a879594 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -85,7 +85,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme map.add(Placeholders.ENCHANTMENT_CHANCE, () -> NumberUtil.format(chanced.getTriggerChance(level))); } if (this instanceof Periodic periodic) { - map.add(Placeholders.ENCHANTMENT_INTERVAL, () -> NumberUtil.format(periodic.getInterval(level) / 20D)); + map.add(Placeholders.ENCHANTMENT_INTERVAL, () -> NumberUtil.format(periodic.getInterval() / 20D)); } if (this instanceof Potioned potioned) { map.add(Placeholders.ENCHANTMENT_POTION_LEVEL, () -> NumberUtil.toRoman(potioned.getEffectAmplifier(level))); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PeriodImplementation.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PeriodImplementation.java index b0d0327..e9c449b 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PeriodImplementation.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PeriodImplementation.java @@ -34,8 +34,8 @@ public class PeriodImplementation implements Periodic { } @Override - public long getInterval(int level) { - return (long) this.triggerInterval.getValue(level); + public long getInterval() { + return (long) this.triggerInterval.getValue(1); } @Override @@ -49,7 +49,7 @@ public class PeriodImplementation implements Periodic { } @Override - public void updateTriggerTime(int level) { - this.nextTriggerTime = System.currentTimeMillis() + this.getInterval(level) / 20L * 1000L; + public void updateTriggerTime() { + this.nextTriggerTime = System.currentTimeMillis() + this.getInterval() * 50L - 100L; } } 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 45db877..d6ca37d 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 @@ -64,8 +64,8 @@ public final class PotionImplementation implements Potioned { public int getEffectDuration(int level) { if (this.isPermanent()) { - int duration = Config.TASKS_PASSIVE_ENCHANTS_TRIGGER_INTERVAL.get().intValue() + 30; - if (this.getEffectType().getName().equalsIgnoreCase(PotionEffectType.NIGHT_VISION.getName())) { + int duration = Config.TASKS_PASSIVE_ENCHANTS_TRIGGER_INTERVAL.get().intValue() * 2; + if (this.getEffectType().getName().equalsIgnoreCase(PotionEffectType.NIGHT_VISION.getName()) && duration < 600) { duration += 30 * 20; } return duration; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PassiveEnchantsTask.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PassiveEnchantsTask.java index b10289f..4ef6467 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PassiveEnchantsTask.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/task/PassiveEnchantsTask.java @@ -3,8 +3,12 @@ package su.nightexpress.excellentenchants.enchantment.task; import org.bukkit.entity.LivingEntity; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.server.AbstractTask; +import su.nexmedia.engine.utils.Pair; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.config.Config; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.Collection; @@ -13,15 +17,43 @@ import java.util.Set; public class PassiveEnchantsTask extends AbstractTask { + private final Set> enchants; + public PassiveEnchantsTask(@NotNull ExcellentEnchants plugin) { super(plugin, Config.TASKS_PASSIVE_ENCHANTS_TRIGGER_INTERVAL.get(), false); + this.enchants = new HashSet<>(); + + EnchantRegistry.getEnchantments(PassiveEnchant.class).forEach(enchant -> { + ExcellentEnchant excellent = EnchantRegistry.getByKey(enchant.getKey()); + if (excellent == null) return; + + this.enchants.add(Pair.of(enchant, excellent)); + }); } @Override public void action() { - for (LivingEntity entity : this.getEntities()) { - EnchantUtils.triggerPassiveEnchants(entity); - } + if (this.enchants.isEmpty()) return; + + var entities = this.getEntities(); + + this.enchants.forEach(pair -> { + PassiveEnchant enchant = pair.getFirst(); + ExcellentEnchant excellent = pair.getSecond(); + if (!enchant.isTriggerTime()) return; + + for (LivingEntity entity : entities) { + EnchantUtils.getEquipped(entity, excellent).forEach((item, level) -> { + if (!enchant.isAvailableToUse(entity)) return; + if (enchant.isOutOfCharges(item)) return; + if (enchant.onTrigger(entity, item, level)) { + enchant.consumeCharges(item, level); + } + }); + } + + enchant.updateTriggerTime(); + }); } @NotNull 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 index 95072e8..2cc39a1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/EnchantUtils.java @@ -24,7 +24,6 @@ import su.nexmedia.engine.utils.ItemUtil; import su.nexmedia.engine.utils.PDCUtil; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; -import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry; @@ -355,23 +354,16 @@ public class EnchantUtils { return map; } - public static void triggerPassiveEnchants(@NotNull LivingEntity entity) { - Player player = entity instanceof Player p1 ? p1 : null; - - getEquipped(entity, PassiveEnchant.class).forEach((item, enchants) -> { - enchants.forEach((enchant, level) -> { - if (!enchant.isAvailableToUse(entity)) return; - if (!enchant.isTriggerTime()) return; - if (enchant.isOutOfCharges(item)) return; - if (enchant.onTrigger(entity, item, level)) { - enchant.consumeChargesNoUpdate(item, level); - enchant.updateTriggerTime(level); - } - }); - if (Config.ENCHANTMENTS_CHARGES_ENABLED.get() && player != null) { - EnchantUtils.updateDisplay(item); + @NotNull + public static Map getEquipped(@NotNull LivingEntity entity, @NotNull ExcellentEnchant enchantment) { + Map map = new HashMap<>(); + getEnchantedEquipment(entity).values().forEach(item -> { + int level = getLevel(item, enchantment); + if (level > 0) { + map.put(item, level); } }); + return map; } public static void setSourceWeapon(@NotNull Projectile projectile, @Nullable ItemStack item) { From 962dc81becb4621a8217d3ed183f15586f3cd905 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 12 Nov 2023 21:34:10 +0500 Subject: [PATCH 63/69] EnchantRegistry fix --- .../enchantment/impl/meta/PeriodImplementation.java | 1 + .../enchantment/registry/EnchantRegistry.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PeriodImplementation.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PeriodImplementation.java index e9c449b..a7219f1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PeriodImplementation.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/meta/PeriodImplementation.java @@ -13,6 +13,7 @@ public class PeriodImplementation implements Periodic { public PeriodImplementation(@NotNull ExcellentEnchant enchant, @NotNull EnchantScaler triggerInterval) { this.triggerInterval = triggerInterval; + this.updateTriggerTime(); } @NotNull diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java index ce33fb0..787e3fb 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java @@ -178,7 +178,9 @@ public class EnchantRegistry extends AbstractManager { @Override protected void onShutdown() { - ENCHANTS_MAP.clear(); + if (!isLocked) { + ENCHANTS_MAP.clear(); + } } public void registerType(@NotNull Class enchantClass) { From fcf77ff4937a11892b41d34ec2842f134f74ff59 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 19 Nov 2023 11:34:49 +0700 Subject: [PATCH 64/69] Add internal placeholder color of tier %enchantment_tier_color% -> return color of Tier --- .../java/su/nightexpress/excellentenchants/Placeholders.java | 1 + .../excellentenchants/enchantment/impl/ExcellentEnchant.java | 1 + 2 files changed, 2 insertions(+) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java index 087a5b5..2d75a00 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java @@ -26,6 +26,7 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders { public static final String ENCHANTMENT_LEVEL_MIN = "%enchantment_level_min%"; public static final String ENCHANTMENT_LEVEL_MAX = "%enchantment_level_max%"; public static final String ENCHANTMENT_TIER = "%enchantment_tier%"; + public static final String ENCHANTMENT_TIER_COLOR = "%enchantment_tier_color%"; public static final String ENCHANTMENT_FIT_ITEM_TYPES = "%enchantment_fit_item_types%"; public static final String ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING = "%enchantment_obtain_chance_enchanting%"; public static final String ENCHANTMENT_OBTAIN_CHANCE_VILLAGER = "%enchantment_obtain_chance_villager%"; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index a879594..54d1ec8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -70,6 +70,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme .add(Placeholders.ENCHANTMENT_LEVEL_MIN, () -> String.valueOf(this.getStartLevel())) .add(Placeholders.ENCHANTMENT_LEVEL_MAX, () -> String.valueOf(this.getMaxLevel())) .add(Placeholders.ENCHANTMENT_TIER, () -> this.getTier().getName()) + .add(Placeholders.ENCHANTMENT_TIER_COLOR, () -> String.valueOf(this.getTier().getColor())) .add(Placeholders.ENCHANTMENT_FIT_ITEM_TYPES, () -> String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList())) .add(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING, () -> NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING))) .add(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_VILLAGER, () -> NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER))) From ce7ca983510ee30e4957fba86d14b852fde59367 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 28 Nov 2023 16:54:07 +0500 Subject: [PATCH 65/69] v3.6.4 --- Core/pom.xml | 12 ++-- .../excellentenchants/Placeholders.java | 2 + .../command/EnchantCommand.java | 41 ++++++++--- .../excellentenchants/config/Lang.java | 7 +- .../impl/weapon/EnchantThrifty.java | 20 ++++-- .../enchantment/util/Modifier.java | 69 +++++++++++++++++++ .../enchantment/util/ModifierAction.java | 21 ++++++ NMS/pom.xml | 2 +- V1_18_R2/pom.xml | 4 +- V1_19_R3/pom.xml | 4 +- V1_20_R1/pom.xml | 4 +- V1_20_R2/pom.xml | 4 +- pom.xml | 2 +- 13 files changed, 159 insertions(+), 33 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/Modifier.java create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/ModifierAction.java diff --git a/Core/pom.xml b/Core/pom.xml index 7a22cea..23e546e 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.2 + 3.6.3 4.0.0 @@ -72,27 +72,27 @@ su.nightexpress.excellentenchants NMS - 3.6.2 + 3.6.3 su.nightexpress.excellentenchants V1_18_R2 - 3.6.2 + 3.6.3 su.nightexpress.excellentenchants V1_19_R3 - 3.6.2 + 3.6.3 su.nightexpress.excellentenchants V1_20_R1 - 3.6.2 + 3.6.3 su.nightexpress.excellentenchants V1_20_R2 - 3.6.2 + 3.6.3 diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java index 087a5b5..63095d5 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java @@ -8,6 +8,8 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders { public static final String URL_ENGINE_ITEMS = "https://github.com/nulli0n/NexEngine-spigot/wiki/Configuration-Tips#item-sections"; public static final String GENERIC_TYPE = "%type%"; + public static final String GENERIC_ITEM = "%item%"; + public static final String GENERIC_LEVEL = "%level%"; public static final String GENERIC_AMOUNT = "%amount%"; public static final String GENERIC_DESCRIPTION = "%description%"; public static final String GENERIC_ENCHANT = "%enchant%"; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java index 94ff2fb..879d3aa 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java @@ -4,13 +4,17 @@ import org.bukkit.NamespacedKey; import org.bukkit.command.CommandSender; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; +import org.bukkit.inventory.EquipmentSlot; 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.*; 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.util.EnchantUtils; @@ -23,7 +27,6 @@ public class EnchantCommand extends AbstractCommand { super(plugin, new String[]{"enchant"}, Perms.COMMAND_ENCHANT); this.setDescription(plugin.getMessage(Lang.COMMAND_ENCHANT_DESC)); this.setUsage(plugin.getMessage(Lang.COMMAND_ENCHANT_USAGE)); - this.setPlayerOnly(true); } @Override @@ -35,6 +38,12 @@ public class EnchantCommand extends AbstractCommand { if (arg == 2) { return Arrays.asList("-1", "1", "5", "10"); } + if (arg == 3) { + return CollectionsUtil.playerNames(player); + } + if (arg == 4) { + return CollectionsUtil.getEnumsList(EquipmentSlot.class); + } return super.getTab(player, arg, args); } @@ -45,19 +54,26 @@ public class EnchantCommand extends AbstractCommand { return; } - Player player = (Player) sender; - ItemStack item = player.getInventory().getItemInMainHand(); - if (item.getType().isAir()) { - this.plugin.getMessage(Lang.COMMAND_ENCHANT_ERROR_NO_ITEM).send(sender); - return; - } - Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(result.getArg(1).toLowerCase())); if (enchantment == null) { plugin.getMessage(Lang.ERROR_NO_ENCHANT).send(sender); return; } + Player player = PlayerUtil.getPlayer(result.getArg(3, sender.getName())); + if (player == null) { + this.errorPlayer(sender); + return; + } + + EquipmentSlot slot = StringUtil.getEnum(result.getArg(4, ""), EquipmentSlot.class).orElse(EquipmentSlot.HAND); + + ItemStack item = player.getInventory().getItem(slot); + if (item == null || item.getType().isAir()) { + this.plugin.getMessage(Lang.COMMAND_ENCHANT_ERROR_NO_ITEM).send(sender); + return; + } + int level = result.getInt(2, -1); if (level < 0) { level = Rnd.get(enchantment.getStartLevel(), enchantment.getMaxLevel()); @@ -69,6 +85,13 @@ public class EnchantCommand extends AbstractCommand { else EnchantUtils.remove(item, enchantment); EnchantUtils.updateDisplay(item); - plugin.getMessage(Lang.COMMAND_ENCHANT_DONE).send(sender); + player.getInventory().setItem(slot, item); + + plugin.getMessage(sender == player ? Lang.COMMAND_ENCHANT_DONE_SELF : Lang.COMMAND_ENCHANT_DONE_OTHERS) + .replace(Placeholders.forPlayer(player)) + .replace(Placeholders.GENERIC_ITEM, ItemUtil.getItemName(item)) + .replace(Placeholders.GENERIC_ENCHANT, LangManager.getEnchantment(enchantment)) + .replace(Placeholders.GENERIC_LEVEL, NumberUtil.toRoman(level)) + .send(sender); } } 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 8ec49c7..f6e7dc8 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java @@ -10,10 +10,11 @@ public class Lang extends EngineLang { public static final LangKey COMMAND_LIST_DESC = LangKey.of("Command.List.Desc", "List of all custom enchantments."); - public static final LangKey COMMAND_ENCHANT_USAGE = LangKey.of("Command.Enchant.Usage", " "); + public static final LangKey COMMAND_ENCHANT_USAGE = LangKey.of("Command.Enchant.Usage", " [player] [slot]"); 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", LIGHT_YELLOW + "Successfully enchanted!"); - public static final LangKey COMMAND_ENCHANT_ERROR_NO_ITEM = LangKey.of("Command.Enchant.Error.NoItem", RED + "You must hold an item to enchant it!"); + public static final LangKey COMMAND_ENCHANT_DONE_SELF = LangKey.of("Command.Enchant.Done.Self", ORANGE + GENERIC_ITEM + LIGHT_YELLOW + " enchanted with " + GENERIC_ENCHANT + " " + GENERIC_LEVEL + LIGHT_YELLOW + "!"); + public static final LangKey COMMAND_ENCHANT_DONE_OTHERS = LangKey.of("Command.Enchant.Done.Others", ORANGE + PLAYER_NAME + LIGHT_YELLOW + "'s " + ORANGE + GENERIC_ITEM + LIGHT_YELLOW + " enchanted with " + GENERIC_ENCHANT + " " + GENERIC_LEVEL + LIGHT_YELLOW + "!"); + public static final LangKey COMMAND_ENCHANT_ERROR_NO_ITEM = LangKey.of("Command.Enchant.Error.NoItem", RED + "There is no item to enchant!"); 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."); 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 247ba4c..5db0914 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,6 +13,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.api.manager.EventListener; +import su.nexmedia.engine.utils.EngineUtils; import su.nexmedia.engine.utils.PDCUtil; import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -21,6 +22,8 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.hook.HookId; +import su.nightexpress.excellentenchants.hook.impl.MythicMobsHook; import java.util.Objects; import java.util.Set; @@ -30,9 +33,11 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn public static final String ID = "thrifty"; + private final NamespacedKey keyEntityIgnored; + private Set ignoredEntityTypes; private Set ignoredSpawnReasons; - private final NamespacedKey keyEntityIgnored; + private boolean ignoreMythicMobs; private ChanceImplementation chanceImplementation; @@ -54,8 +59,8 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn 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 -> StringUtil.getEnum(e, EntityType.class).orElse(null)) + "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html" + ).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", @@ -63,9 +68,13 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn CreatureSpawnEvent.SpawnReason.SPAWNER.name(), 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 -> StringUtil.getEnum(e, CreatureSpawnEvent.SpawnReason.class).orElse(null)) + "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/CreatureSpawnEvent.SpawnReason.html" + ).read(cfg).stream().map(e -> StringUtil.getEnum(e, CreatureSpawnEvent.SpawnReason.class).orElse(null)) .filter(Objects::nonNull).collect(Collectors.toSet()); + + this.ignoreMythicMobs = JOption.create("Settings.Ignore_MythicMobs", true, + "Sets whether or not MythicMobs should be immune to enchantment effect." + ).read(cfg); } @NotNull @@ -84,6 +93,7 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) { if (this.ignoredEntityTypes.contains(entity.getType())) return false; if (PDCUtil.getBoolean(entity, this.keyEntityIgnored).orElse(false)) return false; + if (this.ignoreMythicMobs && EngineUtils.hasPlugin(HookId.MYTHIC_MOBS) && MythicMobsHook.isMythicMob(entity)) return false; if (!this.checkTriggerChance(level)) return false; ItemStack eggItem = plugin.getEnchantNMS().getSpawnEgg(entity); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/Modifier.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/Modifier.java new file mode 100644 index 0000000..5353180 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/Modifier.java @@ -0,0 +1,69 @@ +package su.nightexpress.excellentenchants.enchantment.util; + +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JOption; +import su.nexmedia.engine.api.config.JYML; + +public class Modifier { + + private final double base; + private final double perLevel; + private final ModifierAction action; + + public Modifier(double base, double perLevel, @NotNull ModifierAction action) { + this.base = base; + this.perLevel = perLevel; + this.action = action; + } + + @NotNull + public static Modifier add(double base, double perLevel) { + return new Modifier(base, perLevel, ModifierAction.ADD); + } + + @NotNull + public static Modifier multiply(double base, double perLevel) { + return new Modifier(base, perLevel, ModifierAction.MULTIPLY); + } + + @NotNull + public static Modifier read(@NotNull JYML cfg, @NotNull String path, @NotNull Modifier def, @NotNull String... comments) { + return new JOption<>(path, + (cfg2, path2, def2) -> read(cfg2, path2), + def, + comments + ).setWriter((cfg2, path2, mod) -> mod.write(cfg2, path2)).read(cfg); + } + + @NotNull + public static Modifier read(@NotNull JYML cfg, @NotNull String path) { + double base = JOption.create(path + ".Base", 0D).read(cfg); + double perLevel = JOption.create(path + ".Per_Level", 0D).read(cfg); + ModifierAction action = JOption.create(path + ".Action", ModifierAction.class, ModifierAction.ADD).read(cfg); + + return new Modifier(base, perLevel, action); + } + + public void write(@NotNull JYML cfg, @NotNull String path) { + cfg.set(path + ".Base", this.getBase()); + cfg.set(path + ".Per_Level", this.getPerLevel()); + cfg.set(path + ".Action", this.getAction().name()); + } + + public double getValue(int level) { + return this.action.math(this.getBase(), this.getPerLevel() * level); + } + + public double getBase() { + return base; + } + + public double getPerLevel() { + return perLevel; + } + + @NotNull + public ModifierAction getAction() { + return action; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/ModifierAction.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/ModifierAction.java new file mode 100644 index 0000000..06b719d --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/ModifierAction.java @@ -0,0 +1,21 @@ +package su.nightexpress.excellentenchants.enchantment.util; + +import org.jetbrains.annotations.NotNull; + +import java.util.function.BiFunction; + +public enum ModifierAction { + + ADD(Double::sum), + MULTIPLY((origin, target) -> origin * target); + + private final BiFunction function; + + ModifierAction(@NotNull BiFunction function) { + this.function = function; + } + + public double math(double origin, double target) { + return this.function.apply(origin, target); + } +} diff --git a/NMS/pom.xml b/NMS/pom.xml index 9bf13cf..d4be4ab 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.2 + 3.6.3 4.0.0 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index c94731d..c3cf53a 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.2 + 3.6.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.2 + 3.6.3 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index bbc2704..6a56530 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.2 + 3.6.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.2 + 3.6.3 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index 276ae4c..b578b14 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.2 + 3.6.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.2 + 3.6.3 diff --git a/V1_20_R2/pom.xml b/V1_20_R2/pom.xml index a6f89c4..62dcce1 100644 --- a/V1_20_R2/pom.xml +++ b/V1_20_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.2 + 3.6.3 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.2 + 3.6.3 diff --git a/pom.xml b/pom.xml index 576e24a..f61087e 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.6.2 + 3.6.3 Core NMS From daa3e40c652d2fc2867e42ebd736e1edc336ba0e Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 28 Nov 2023 17:33:45 +0500 Subject: [PATCH 66/69] v3.6.4 --- Core/pom.xml | 12 +++++----- .../excellentenchants/Placeholders.java | 4 ++-- .../enchantment/config/EnchantDefaults.java | 20 ++++++++++++++++ .../enchantment/impl/ExcellentEnchant.java | 4 ++++ .../impl/armor/RegrowthEnchant.java | 2 +- .../impl/armor/SaturationEnchant.java | 2 +- .../impl/universal/SoulboundEnchant.java | 2 +- .../listener/EnchantAnvilListener.java | 2 +- .../listener/EnchantGenericListener.java | 24 +++++++++---------- .../menu/EnchantmentsListMenu.java | 2 +- .../enchantment/type/FitItemType.java | 2 +- NMS/pom.xml | 2 +- V1_18_R2/pom.xml | 4 ++-- V1_19_R3/pom.xml | 4 ++-- V1_20_R1/pom.xml | 4 ++-- V1_20_R2/pom.xml | 4 ++-- pom.xml | 2 +- 17 files changed, 60 insertions(+), 36 deletions(-) diff --git a/Core/pom.xml b/Core/pom.xml index 23e546e..8b8b0ca 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.3 + 3.6.4 4.0.0 @@ -72,27 +72,27 @@ su.nightexpress.excellentenchants NMS - 3.6.3 + 3.6.4 su.nightexpress.excellentenchants V1_18_R2 - 3.6.3 + 3.6.4 su.nightexpress.excellentenchants V1_19_R3 - 3.6.3 + 3.6.4 su.nightexpress.excellentenchants V1_20_R1 - 3.6.3 + 3.6.4 su.nightexpress.excellentenchants V1_20_R2 - 3.6.3 + 3.6.4 diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java index 6a45e4a..dcb3bc0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java @@ -8,8 +8,8 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders { public static final String URL_ENGINE_ITEMS = "https://github.com/nulli0n/NexEngine-spigot/wiki/Configuration-Tips#item-sections"; public static final String GENERIC_TYPE = "%type%"; - public static final String GENERIC_ITEM = "%item%"; - public static final String GENERIC_LEVEL = "%level%"; + public static final String GENERIC_ITEM = "%item%"; + public static final String GENERIC_LEVEL = "%level%"; public static final String GENERIC_AMOUNT = "%amount%"; public static final String GENERIC_DESCRIPTION = "%description%"; public static final String GENERIC_ENCHANT = "%enchant%"; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java index c7be3ac..fe4bcfb 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/config/EnchantDefaults.java @@ -31,6 +31,7 @@ public class EnchantDefaults { private boolean isTreasure; private int levelMin; private int levelMax; + private int maxMergeLevel; private EnchantScaler levelByEnchantCost; private EnchantScaler anvilMergeCost; private Set conflicts; @@ -51,6 +52,7 @@ public class EnchantDefaults { this.setTreasure(false); this.setLevelMin(1); this.setLevelMax(3); + this.setMaxMergeLevel(-1); this.setConflicts(new HashSet<>()); this.setVisualEffects(true); this.obtainChance = new HashMap<>(); @@ -89,6 +91,11 @@ public class EnchantDefaults { "Note: While you can 'bypass' this value by enchant commands, all level-dependant enchantment", "settings will have a limit up to this setting.").read(cfg)); + this.setMaxMergeLevel(JOption.create("Anvil.Max_Merge_Level", this.getMaxMergeLevel(), + "Sets max. enchantment level that can be obtained by combining 2 items with this enchantment.", + "Set this to '-1' to remove merge limit and just use 'Max Level' instead." + ).read(cfg)); + this.setLevelByEnchantCost(EnchantScaler.read(enchant, ObtainType.ENCHANTING.getPathName() + ".Level_By_Exp_Cost", (int)(30D / this.levelMax) + " * " + Placeholders.ENCHANTMENT_LEVEL, "Sets how much XP levels must be used in enchanting table to obtain this enchantment.", @@ -124,14 +131,19 @@ public class EnchantDefaults { this.setChargesEnabled(JOption.create("Settings.Charges.Enabled", this.isChargesEnabled(), "When 'true' enables the Charges system for this enchantment.", "When enchanted the first time on enchanting table, it will have maximum charges amount.").read(cfg)); + this.setChargesCustomFuel(JOption.create("Settings.Charges.Custom_Fuel", this.isChargesCustomFuel(), "When 'true' uses different (non-default) fuel item (from the 'Fuel_Item' setting) to recharge.").read(cfg)); + this.setChargesMax(EnchantScaler.read(enchant, "Settings.Charges.Maximum", "100", "Maximum amount of charges for the enchantment.")); + this.setChargesConsumeAmount(EnchantScaler.read(enchant, "Settings.Charges.Consume_Amount", "1", "How many charges will be consumed when enchantment is triggered?")); + this.setChargesRechargeAmount(EnchantScaler.read(enchant, "Settings.Charges.Recharge_Amount", "25", "How many charges will be restored when using 'Fuel Item' in anvil?")); + this.setChargesFuel(JOption.create("Settings.Charges.Fuel_Item", new ItemStack(Material.LAPIS_LAZULI), "An item, that will be used to restore enchantment charges on anvils.", "Item Options:" + Placeholders.URL_ENGINE_ITEMS) @@ -206,6 +218,14 @@ public class EnchantDefaults { return levelMax; } + public int getMaxMergeLevel() { + return this.maxMergeLevel; + } + + public void setMaxMergeLevel(int maxMergeLevel) { + this.maxMergeLevel = Math.min(this.getLevelMax(), maxMergeLevel); + } + @NotNull public EnchantScaler getLevelByEnchantCost() { return levelByEnchantCost; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index 54d1ec8..9db2208 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -222,6 +222,10 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme return this.getDefaults().getLevelMin(); } + public int getMaxMergeLevel() { + return this.getDefaults().getMaxMergeLevel() < 0 ? this.getMaxLevel() : this.getDefaults().getMaxMergeLevel(); + } + public int getLevelByEnchantCost(int expLevel) { int get = this.getDefaults().getLevelByEnchantCost().getValues().entrySet().stream() .filter(en -> expLevel >= en.getValue().intValue()).max(Comparator.comparingInt(Map.Entry::getKey)) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java index 87c9d38..de154b6 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/RegrowthEnchant.java @@ -35,7 +35,7 @@ public class RegrowthEnchant extends ExcellentEnchant implements Chanced, Passiv public RegrowthEnchant(@NotNull ExcellentEnchants plugin) { super(plugin, ID); - this.getDefaults().setDescription("Restores " + PLACEHOLDER_HEAL_AMOUNT + " hearts every " + Placeholders.ENCHANTMENT_INTERVAL + "s."); + this.getDefaults().setDescription("Restores " + PLACEHOLDER_HEAL_AMOUNT + " hearts every few seconds."); this.getDefaults().setLevelMax(5); this.getDefaults().setTier(0.7); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java index c9f42dd..b252295 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/SaturationEnchant.java @@ -27,7 +27,7 @@ public class SaturationEnchant extends ExcellentEnchant implements PassiveEnchan public SaturationEnchant(@NotNull ExcellentEnchants plugin) { super(plugin, ID); - this.getDefaults().setDescription("Restores " + PLACEHOLDER_SATURATION_AMOUNT + " food points every " + Placeholders.ENCHANTMENT_INTERVAL + "s."); + this.getDefaults().setDescription("Restores " + PLACEHOLDER_SATURATION_AMOUNT + " food points every few seconds."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.5); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java index 9fd8704..4f3dec1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java @@ -33,7 +33,7 @@ public class SoulboundEnchant extends ExcellentEnchant implements GenericEnchant @NotNull @Override public EnchantmentTarget getItemTarget() { - return EnchantmentTarget.BREAKABLE; + return EnchantmentTarget.WEARABLE; } @EventHandler diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantAnvilListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantAnvilListener.java index 997a83b..6e83676 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantAnvilListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantAnvilListener.java @@ -109,7 +109,7 @@ public class EnchantAnvilListener extends AbstractListener { // Merge only if it's Item + Item, Item + Enchanted book or Enchanted Book + Enchanted Book if (second.getType() == Material.ENCHANTED_BOOK || second.getType() == first.getType()) { EnchantUtils.getExcellents(second).forEach((enchant, level) -> { - enchantments.merge(enchant, level, (oldLvl, newLvl) -> (oldLvl.equals(newLvl)) ? (Math.min(enchant.getMaxLevel(), oldLvl + 1)) : (Math.max(oldLvl, newLvl))); + enchantments.merge(enchant, level, (oldLvl, newLvl) -> (oldLvl.equals(newLvl)) ? (Math.min(enchant.getMaxMergeLevel(), oldLvl + 1)) : (Math.max(oldLvl, newLvl))); charges.merge(enchant, enchant.getCharges(second), Integer::sum); }); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantGenericListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantGenericListener.java index ea1f043..4202091 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantGenericListener.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantGenericListener.java @@ -150,26 +150,26 @@ public class EnchantGenericListener extends AbstractListener // --------------------------------------------------------------- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEnchantPopulateVillagerAcquire(VillagerAcquireTradeEvent event) { - MerchantRecipe recipe = event.getRecipe(); - ItemStack result = recipe.getResult(); + MerchantRecipe origin = event.getRecipe(); + ItemStack result = origin.getResult(); if (!EnchantUtils.isEnchantable(result)) return; EnchantPopulator populator = this.plugin.createPopulator(result, ObtainType.VILLAGER) .withWorld(event.getEntity().getWorld()); if (!populator.populate()) return; - int uses = recipe.getUses(); - int maxUses = recipe.getMaxUses(); - boolean expReward = recipe.hasExperienceReward(); - int villagerExperience = recipe.getVillagerExperience(); - float priceMultiplier = recipe.getPriceMultiplier(); - int demand = recipe.getDemand(); - int specialPrice = recipe.getSpecialPrice(); + int uses = origin.getUses(); + int maxUses = origin.getMaxUses(); + boolean expReward = origin.hasExperienceReward(); + int villagerExperience = origin.getVillagerExperience(); + float priceMultiplier = origin.getPriceMultiplier(); + int demand = origin.getDemand(); + int specialPrice = origin.getSpecialPrice(); - MerchantRecipe recipe2 = new MerchantRecipe(result, uses, maxUses, expReward, villagerExperience, + MerchantRecipe recipe = new MerchantRecipe(result, uses, maxUses, expReward, villagerExperience, priceMultiplier, demand, specialPrice); - recipe2.setIngredients(recipe.getIngredients()); - event.setRecipe(recipe2); + recipe.setIngredients(origin.getIngredients()); + event.setRecipe(recipe); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/menu/EnchantmentsListMenu.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/menu/EnchantmentsListMenu.java index 7e9a649..f4a6aea 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/menu/EnchantmentsListMenu.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/menu/EnchantmentsListMenu.java @@ -83,7 +83,7 @@ public class EnchantmentsListMenu extends ConfigMenu implemen public List getObjects(@NotNull Player player) { return new ArrayList<>(EnchantRegistry.getRegistered().stream() .filter(Predicate.not(enchant -> enchant.getDefaults().isHiddenFromList())) - .sorted(Comparator.comparing(e -> Colorizer.strip(e.getDisplayName()))).toList()); + .sorted(Comparator.comparing(e -> Colorizer.restrip(e.getDisplayName()))).toList()); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java index ef32ade..392e94c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/type/FitItemType.java @@ -36,7 +36,7 @@ public enum FitItemType { public boolean isIncluded(@NotNull ItemStack item) { return switch (this) { - case UNIVERSAL -> ARMOR.isIncluded(item) || WEAPON.isIncluded(item) || TOOL.isIncluded(item); + case UNIVERSAL -> ARMOR.isIncluded(item) || WEAPON.isIncluded(item) || TOOL.isIncluded(item) || BOW.isIncluded(item) || FISHING_ROD.isIncluded(item) || ELYTRA.isIncluded(item); case HELMET -> ItemUtil.isHelmet(item); case CHESTPLATE -> ItemUtil.isChestplate(item) || (Config.ENCHANTMENTS_ITEM_CHESTPLATE_ENCHANTS_TO_ELYTRA.get() && ELYTRA.isIncluded(item)); case LEGGINGS -> ItemUtil.isLeggings(item); diff --git a/NMS/pom.xml b/NMS/pom.xml index d4be4ab..997ff63 100644 --- a/NMS/pom.xml +++ b/NMS/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.3 + 3.6.4 4.0.0 diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml index c3cf53a..4c5b33e 100644 --- a/V1_18_R2/pom.xml +++ b/V1_18_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.3 + 3.6.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.3 + 3.6.4 diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml index 6a56530..c3bf3c0 100644 --- a/V1_19_R3/pom.xml +++ b/V1_19_R3/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.3 + 3.6.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.3 + 3.6.4 diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml index b578b14..ba89518 100644 --- a/V1_20_R1/pom.xml +++ b/V1_20_R1/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.3 + 3.6.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.3 + 3.6.4 diff --git a/V1_20_R2/pom.xml b/V1_20_R2/pom.xml index 62dcce1..d889b3b 100644 --- a/V1_20_R2/pom.xml +++ b/V1_20_R2/pom.xml @@ -5,7 +5,7 @@ ExcellentEnchants su.nightexpress.excellentenchants - 3.6.3 + 3.6.4 4.0.0 @@ -26,7 +26,7 @@ su.nightexpress.excellentenchants NMS - 3.6.3 + 3.6.4 diff --git a/pom.xml b/pom.xml index f61087e..33d0148 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ su.nightexpress.excellentenchants ExcellentEnchants pom - 3.6.3 + 3.6.4 Core NMS From 9d7c98cddbcab38a347fce662d1cd8a88e1a9b2b Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 28 Nov 2023 18:49:21 +0500 Subject: [PATCH 67/69] v3.6.4 --- .../excellentenchants/ExcellentEnchants.java | 1 + .../excellentenchants/Placeholders.java | 1 + .../command/EnchantCommand.java | 3 +- .../excellentenchants/config/Config.java | 2 + .../enchantment/EnchantPopulator.java | 5 +- .../enchantment/impl/ExcellentEnchant.java | 17 ++ .../menu/EnchantmentsListMenu.java | 167 ++++++++++++++---- Core/src/main/resources/lang/messages_en.yml | 0 .../src/main/resources/menu/enchants_list.yml | 72 -------- 9 files changed, 156 insertions(+), 112 deletions(-) delete mode 100644 Core/src/main/resources/lang/messages_en.yml delete mode 100644 Core/src/main/resources/menu/enchants_list.yml diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index ad15f58..fd79fda 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -108,6 +108,7 @@ public class ExcellentEnchants extends NexPlugin { public void loadLang() { this.getLangManager().loadMissing(Lang.class); this.getLangManager().loadEnum(FitItemType.class); + this.getLangManager().loadEnum(ObtainType.class); this.getLang().saveChanges(); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java index dcb3bc0..78215ad 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/Placeholders.java @@ -8,6 +8,7 @@ public class Placeholders extends su.nexmedia.engine.utils.Placeholders { public static final String URL_ENGINE_ITEMS = "https://github.com/nulli0n/NexEngine-spigot/wiki/Configuration-Tips#item-sections"; public static final String GENERIC_TYPE = "%type%"; + public static final String GENERIC_NAME = "%name%"; public static final String GENERIC_ITEM = "%item%"; public static final String GENERIC_LEVEL = "%level%"; public static final String GENERIC_AMOUNT = "%amount%"; 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 879d3aa..9d59d76 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/EnchantCommand.java @@ -9,7 +9,6 @@ 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.*; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; @@ -90,7 +89,7 @@ public class EnchantCommand extends AbstractCommand { plugin.getMessage(sender == player ? Lang.COMMAND_ENCHANT_DONE_SELF : Lang.COMMAND_ENCHANT_DONE_OTHERS) .replace(Placeholders.forPlayer(player)) .replace(Placeholders.GENERIC_ITEM, ItemUtil.getItemName(item)) - .replace(Placeholders.GENERIC_ENCHANT, LangManager.getEnchantment(enchantment)) + .replace(Placeholders.GENERIC_ENCHANT, EnchantUtils.getLocalized(enchantment)) .replace(Placeholders.GENERIC_LEVEL, NumberUtil.toRoman(level)) .send(sender); } 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 d4df3c3..b8576f0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -19,6 +19,8 @@ import java.util.stream.Stream; public class Config { + public static final String DIR_MENU = "/menu/"; + 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." 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 d093c32..4147d61 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantPopulator.java @@ -69,10 +69,7 @@ public class EnchantPopulator { Set enchants = EnchantRegistry.getOfTier(tier); enchants.removeIf(enchant -> { - if (enchant.getObtainChance(this.getObtainType()) <= 0D) return true; - if (!enchant.canEnchantItem(this.getItem())) return true; - - return this.getObtainType() == ObtainType.ENCHANTING && (enchant.isTreasure() || enchant.isCursed()); + return !enchant.isObtainable(this.getObtainType()) || !enchant.canEnchantItem(this.getItem()); }); this.candidates.put(tier, enchants); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index 9db2208..fd21885 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -195,6 +195,13 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme return description; } + @NotNull + public List formatDescription() { + return new ArrayList<>(this.getDescription().stream() + .map(line -> Config.ENCHANTMENTS_DESCRIPTION_FORMAT.get().replace(Placeholders.GENERIC_DESCRIPTION, line)) + .toList()); + } + @NotNull public List formatDescription(int level) { return new ArrayList<>(this.getDescription(level).stream() @@ -202,6 +209,10 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme .toList()); } + public boolean hasConflicts() { + return !this.getConflicts().isEmpty(); + } + @NotNull public Set getConflicts() { return this.getDefaults().getConflicts(); @@ -234,6 +245,12 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme return get != 0 ? this.fineLevel(get, ObtainType.ENCHANTING) : 0; } + public boolean isObtainable(@NotNull ObtainType obtainType) { + if (obtainType == ObtainType.ENCHANTING && (this.isTreasure() || this.isCursed())) return false; + + return this.getObtainChance(obtainType) > 0D; + } + public double getObtainChance(@NotNull ObtainType obtainType) { return this.getDefaults().getObtainChance().getOrDefault(obtainType, 0D); } 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 f4a6aea..4042613 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 @@ -1,9 +1,12 @@ package su.nightexpress.excellentenchants.enchantment.menu; +import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JOption; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.menu.AutoPaged; import su.nexmedia.engine.api.menu.MenuItemType; @@ -12,49 +15,50 @@ 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.api.menu.item.MenuItem; import su.nexmedia.engine.utils.Colorizer; +import su.nexmedia.engine.utils.ItemReplacer; import su.nexmedia.engine.utils.ItemUtil; 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.config.Config; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry; +import su.nightexpress.excellentenchants.enchantment.type.ObtainType; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import java.util.*; import java.util.function.Predicate; +import java.util.stream.IntStream; + +import static su.nexmedia.engine.utils.Colors2.*; +import static su.nightexpress.excellentenchants.Placeholders.*; public class EnchantmentsListMenu extends ConfigMenu implements AutoPaged { - private static final String PATH = "/menu/enchants_list.yml"; + private static final String FILE = "enchants.yml"; private static final String PLACEHOLDER_CONFLICTS = "%conflicts%"; private static final String PLACEHOLDER_CHARGES = "%charges%"; private static final String PLACEHOLDER_OBTAINING = "%obtaining%"; - private final ItemStack enchantIcon; - private final List enchantLoreConflicts; - private final List enchantLoreCharges; - private final List enchantLoreObtaining; - private final int[] enchantSlots; - private final NamespacedKey keyLevel; private final Map> iconCache; + private String enchantName; + private List enchantLoreMain; + private List enchantLoreConflicts; + private List enchantLoreCharges; + private List enchantLoreObtaining; + private int[] enchantSlots; + public EnchantmentsListMenu(@NotNull ExcellentEnchants plugin) { - super(plugin, JYML.loadOrExtract(plugin, PATH)); + super(plugin, new JYML(plugin.getDataFolder() + Config.DIR_MENU, FILE)); this.keyLevel = new NamespacedKey(plugin, "list_display_level"); this.iconCache = new HashMap<>(); - this.enchantIcon = cfg.getItem("Enchantments.Icon"); - this.enchantLoreConflicts = Colorizer.apply(cfg.getStringList("Enchantments.Lore.Conflicts")); - this.enchantLoreCharges = Colorizer.apply(cfg.getStringList("Enchantments.Lore.Charges")); - this.enchantLoreObtaining = Colorizer.apply(cfg.getStringList("Enchantments.Lore.Obtaining")); - this.enchantSlots = cfg.getIntArray("Enchantments.Slots"); - this.registerHandler(MenuItemType.class) - .addClick(MenuItemType.CLOSE, (viewer, event) -> plugin.runTask(task -> viewer.getPlayer().closeInventory())) + .addClick(MenuItemType.CLOSE, ClickHandler.forClose(this)) .addClick(MenuItemType.PAGE_NEXT, ClickHandler.forNextPage(this)) .addClick(MenuItemType.PAGE_PREVIOUS, ClickHandler.forPreviousPage(this)); @@ -67,6 +71,85 @@ public class EnchantmentsListMenu extends ConfigMenu implemen this.iconCache.clear(); } + // ---------- + + @Override + public boolean isCodeCreation() { + return true; + } + + @Override + protected void loadAdditional() { + this.enchantName = JOption.create("Enchantment.Name", ENCHANTMENT_NAME_FORMATTED).read(cfg); + + this.enchantLoreMain = JOption.create("Enchantment.Lore.Main", + Arrays.asList( + ENCHANTMENT_DESCRIPTION, + DARK_GRAY + "(click to switch level)", + "", + LIGHT_YELLOW + BOLD + "Info:", + LIGHT_YELLOW + "▪ " + LIGHT_GRAY + "Tier: " + LIGHT_YELLOW + ENCHANTMENT_TIER, + LIGHT_YELLOW + "▪ " + LIGHT_GRAY + "Applies to: " + LIGHT_YELLOW + ENCHANTMENT_FIT_ITEM_TYPES, + LIGHT_YELLOW + "▪ " + LIGHT_GRAY + "Levels: " + LIGHT_YELLOW + ENCHANTMENT_LEVEL_MIN + GRAY + " - " + LIGHT_YELLOW + ENCHANTMENT_LEVEL_MAX, + PLACEHOLDER_CHARGES, + PLACEHOLDER_CONFLICTS, + PLACEHOLDER_OBTAINING + )).read(cfg); + + this.enchantLoreConflicts = JOption.create("Enchantment.Lore.Conflicts", + Arrays.asList( + "", + LIGHT_RED + BOLD + "Conflicts:", + LIGHT_RED + "✘ " + LIGHT_GRAY + GENERIC_NAME + )).read(cfg); + + this.enchantLoreCharges = JOption.create("Enchantment.Lore.Charges", + Arrays.asList( + LIGHT_YELLOW + "▪ " + LIGHT_GRAY + "Charges: " + LIGHT_YELLOW + ENCHANTMENT_CHARGES_MAX_AMOUNT + "⚡" + LIGHT_GRAY + " (" + WHITE + ENCHANTMENT_CHARGES_FUEL_ITEM + LIGHT_GRAY + ")" + )).read(cfg); + + this.enchantLoreObtaining = JOption.create("Enchantment.Lore.Obtaining", + Arrays.asList( + "", + LIGHT_GREEN + BOLD + "Obtaining:", + LIGHT_GREEN + "✔ " + LIGHT_GRAY + GENERIC_TYPE + )).read(cfg); + + this.enchantSlots = new JOption("Enchantment.Slots", + (cfg, path, def) -> cfg.getIntArray(path), + () -> IntStream.range(0, 27).toArray() + ).setWriter(JYML::setIntArray).read(cfg); + } + + @Override + @NotNull + protected MenuOptions createDefaultOptions() { + return new MenuOptions(DARK_GRAY + BOLD + "Custom Enchants", 36, InventoryType.CHEST); + } + + @Override + @NotNull + protected List createDefaultItems() { + List list = new ArrayList<>(); + + ItemStack nextPageStack = ItemUtil.createCustomHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjMyY2E2NjA1NmI3Mjg2M2U5OGY3ZjMyYmQ3ZDk0YzdhMGQ3OTZhZjY5MWM5YWMzYTkxMzYzMzEzNTIyODhmOSJ9fX0="); + ItemUtil.mapMeta(nextPageStack, meta -> { + meta.setDisplayName(WHITE + "Next Page" + LIGHT_GRAY + " (→)"); + }); + + ItemStack prevPageStack = ItemUtil.createCustomHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODY5NzFkZDg4MWRiYWY0ZmQ2YmNhYTkzNjE0NDkzYzYxMmY4Njk2NDFlZDU5ZDFjOTM2M2EzNjY2YTVmYTYifX19"); + ItemUtil.mapMeta(prevPageStack, meta -> { + meta.setDisplayName(LIGHT_GRAY + "(←) " + WHITE + "Previous Page"); + }); + + list.add(new MenuItem(nextPageStack).setSlots(35).setType(MenuItemType.PAGE_NEXT).setPriority(5)); + list.add(new MenuItem(prevPageStack).setSlots(27).setType(MenuItemType.PAGE_PREVIOUS).setPriority(5)); + + return list; + } + + // ----------- + @Override public void onPrepare(@NotNull MenuViewer viewer, @NotNull MenuOptions options) { super.onPrepare(viewer, options); @@ -118,26 +201,42 @@ public class EnchantmentsListMenu extends ConfigMenu implemen @NotNull private ItemStack buildEnchantIcon(@NotNull ExcellentEnchant enchant, int level) { - ItemStack icon = new ItemStack(this.enchantIcon); - ItemUtil.mapMeta(icon, meta -> { - List lore = meta.getLore(); - if (lore == null) lore = new ArrayList<>(); + ItemStack icon = new ItemStack(Material.ENCHANTED_BOOK); - List conflicts = enchant.getConflicts().isEmpty() ? Collections.emptyList() : new ArrayList<>(this.enchantLoreConflicts); - List conflictNames = enchant.getConflicts().stream().map(EnchantUtils::getLocalized).filter(Objects::nonNull).toList(); - conflicts = StringUtil.replace(conflicts, Placeholders.ENCHANTMENT_NAME, true, conflictNames); + List conflicts = new ArrayList<>(); + if (enchant.hasConflicts()) { + for (String line : this.enchantLoreConflicts) { + if (line.contains(GENERIC_NAME)) { + enchant.getConflicts().stream().map(EnchantUtils::getLocalized).filter(Objects::nonNull).forEach(conf -> { + conflicts.add(line.replace(GENERIC_NAME, conf)); + }); + } + else conflicts.add(line); + } + } - List charges = enchant.isChargesEnabled() ? new ArrayList<>(this.enchantLoreCharges) : Collections.emptyList(); - List obtaining = new ArrayList<>(this.enchantLoreObtaining); + List obtaining = new ArrayList<>(); + for (String line : this.enchantLoreObtaining) { + if (line.contains(GENERIC_TYPE)) { + for (ObtainType obtainType : ObtainType.values()) { + if (enchant.isObtainable(obtainType)) { + obtaining.add(line.replace(GENERIC_TYPE, plugin.getLangManager().getEnum(obtainType))); + } + } + } + else obtaining.add(line); + } - lore = StringUtil.replaceInList(lore, PLACEHOLDER_CONFLICTS, conflicts); - lore = StringUtil.replaceInList(lore, PLACEHOLDER_CHARGES, charges); - lore = StringUtil.replaceInList(lore, PLACEHOLDER_OBTAINING, obtaining); - lore = StringUtil.replace(lore, Placeholders.ENCHANTMENT_DESCRIPTION, true, enchant.getDescription()); - - meta.setLore(lore); - ItemUtil.replace(meta, enchant.getPlaceholders(level).replacer()); - }); + ItemReplacer.create(icon).hideFlags().trimmed() + .setDisplayName(this.enchantName) + .setLore(this.enchantLoreMain) + .replaceLoreExact(PLACEHOLDER_CHARGES, enchant.isChargesEnabled() ? new ArrayList<>(this.enchantLoreCharges) : Collections.emptyList()) + .replaceLoreExact(PLACEHOLDER_CONFLICTS, conflicts) + .replaceLoreExact(PLACEHOLDER_OBTAINING, obtaining) + .replaceLoreExact(ENCHANTMENT_DESCRIPTION, enchant.formatDescription()) + .replace(enchant.getPlaceholders(level)) + .replace(Colorizer::apply) + .writeMeta(); return icon; } diff --git a/Core/src/main/resources/lang/messages_en.yml b/Core/src/main/resources/lang/messages_en.yml deleted file mode 100644 index e69de29..0000000 diff --git a/Core/src/main/resources/menu/enchants_list.yml b/Core/src/main/resources/menu/enchants_list.yml deleted file mode 100644 index 3a5f635..0000000 --- a/Core/src/main/resources/menu/enchants_list.yml +++ /dev/null @@ -1,72 +0,0 @@ -Title: ' #a267f3&lCustom Enchants' -Size: 36 -Inventory_Type: CHEST -Use_Mini_Message: false - -Enchantments: - Icon: - Material: ENCHANTED_BOOK - Name: '%enchantment_name_formatted%' - Lore: - - '#aeb6bf%enchantment_description%' - - '' - - '#bcff9a&lInfo:' - - '#bcff9a▪ #ddeceeTier: #bcff9a%enchantment_tier%' - - '#bcff9a▪ #ddeceeApplies to: #bcff9a%enchantment_fit_item_types%' - - '#bcff9a▪ #ddeceeLevels: #bcff9a%enchantment_level_min% #ddecee- #bcff9a%enchantment_level_max%' - - '%conflicts%' - - '%charges%' - - '%obtaining%' - - '' - - '#a5ff9a&lActions:' - - '#a5ff9a▪ #ddeceeLeft-Click: #a5ff9aSwitch Level' - Lore: - Conflicts: - - '' - - '#ff9a9a[!] #ddeceeCan not be used together with:' - - '#ff9a9a▸ %enchantment_name%' - Charges: - - '' - - '#d39aff&lCharges:' - - '#d39aff◈ #ddeceeMaximum: #d39aff%enchantment_charges_max_amount%⚡' - - '#d39aff◈ #ddeceePer Use: #d39aff-%enchantment_charges_consume_amount%⚡' - - '#d39aff◈ #ddeceePer Recharge: #d39aff+%enchantment_charges_recharge_amount%⚡' - - '#d39aff◈ #ddeceeFuel Item: #d39aff%enchantment_charges_fuel_item%' - Obtaining: - - '' - - '#9af7ff&lObtain Chance:' - - '#9af7ff┃ #ddeceeEnchanting Table: #9af7ff%enchantment_obtain_chance_enchanting%%' - - '#9af7ff┃ #ddeceeVillager Trade: #9af7ff%enchantment_obtain_chance_villager%%' - - '#9af7ff┃ #ddeceeLoot Generation: #9af7ff%enchantment_obtain_chance_loot_generation%%' - - '#9af7ff┃ #ddeceeFishing: #9af7ff%enchantment_obtain_chance_fishing%%' - - '#9af7ff┃ #ddeceeMob Spawning: #9af7ff%enchantment_obtain_chance_mob_spawning%%' - Slots: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 - -Content: - return: - Priority: 5 - Item: - Material: PLAYER_HEAD - Head_Texture: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmU5YWU3YTRiZTY1ZmNiYWVlNjUxODEzODlhMmY3ZDQ3ZTJlMzI2ZGI1OWVhM2ViNzg5YTkyYzg1ZWE0NiJ9fX0= - Name: '#ffee9a(↓) &fClose Menu' - Lore: [] - Slots: 31 - Type: CLOSE - - page_next: - Slots: 35 - Type: PAGE_NEXT - Item: - Material: PLAYER_HEAD - Head_Texture: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjMyY2E2NjA1NmI3Mjg2M2U5OGY3ZjMyYmQ3ZDk0YzdhMGQ3OTZhZjY5MWM5YWMzYTkxMzYzMzEzNTIyODhmOSJ9fX0= - Name: '#ffee9a(→) &fNext Page' - Priority: 5 - - page_previous: - Slots: 27 - Type: PAGE_PREVIOUS - Item: - Material: PLAYER_HEAD - Head_Texture: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODY5NzFkZDg4MWRiYWY0ZmQ2YmNhYTkzNjE0NDkzYzYxMmY4Njk2NDFlZDU5ZDFjOTM2M2EzNjY2YTVmYTYifX19 - Name: '#ffee9a(←) &fPrevious Page' - Priority: 5 \ No newline at end of file From ce3877bd07443a0b2ac39b1b02303e9f7bab9a31 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 28 Nov 2023 19:45:48 +0500 Subject: [PATCH 68/69] v3.6.4 --- .../excellentenchants/ExcellentEnchants.java | 6 +- .../api/enchantment/IEnchantment.java | 1 - .../command/BookCommand.java | 2 +- .../command/TierbookCommand.java | 2 +- .../excellentenchants/config/Config.java | 27 +++++- .../excellentenchants/config/Lang.java | 10 +- .../enchantment/config/EnchantScaler.java | 62 ++++++++++-- .../enchantment/impl/ExcellentEnchant.java | 2 +- .../listener/EnchantAnvilListener.java | 12 +-- .../enchantment/registry/EnchantRegistry.java | 13 ++- .../enchantment/util/Evaluator.java | 94 +++++++++++++++++++ .../hook/impl/PlaceholderHook.java | 17 +++- .../excellentenchants/tier/Tier.java | 20 +++- .../excellentenchants/tier/TierManager.java | 49 +++++----- Core/src/main/resources/lang/messages_ru.yml | 3 +- Core/src/main/resources/tiers.yml | 50 ---------- 16 files changed, 253 insertions(+), 117 deletions(-) create mode 100644 Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/Evaluator.java delete mode 100644 Core/src/main/resources/tiers.yml diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java index fd79fda..a7ee3ca 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/ExcellentEnchants.java @@ -84,7 +84,9 @@ public class ExcellentEnchants extends NexPlugin { this.tierManager.shutdown(); this.tierManager = null; } - PlaceholderHook.shutdown(); + if (EngineUtils.hasPlaceholderAPI()) { + PlaceholderHook.shutdown(); + } this.registry.shutdown(); } @@ -124,7 +126,7 @@ public class ExcellentEnchants extends NexPlugin { @Override public void registerHooks() { if (EngineUtils.hasPlaceholderAPI()) { - PlaceholderHook.setup(); + PlaceholderHook.setup(this); } } 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 b5c3e8b..df57cb2 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 @@ -3,7 +3,6 @@ package su.nightexpress.excellentenchants.api.enchantment; import org.bukkit.Keyed; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; -import org.bukkit.event.EventPriority; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; 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 ba28383..a63f2f2 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/BookCommand.java @@ -51,7 +51,7 @@ public class BookCommand extends AbstractCommand { return; } - Player player = plugin.getServer().getPlayer(result.getArg(1)); + Player player = PlayerUtil.getPlayer(result.getArg(1)); if (player == null) { this.errorPlayer(sender); return; 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 a7bddce..0fbcb5d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/command/TierbookCommand.java @@ -53,7 +53,7 @@ public class TierbookCommand extends AbstractCommand { return; } - Player player = plugin.getServer().getPlayer(result.getArg(1)); + Player player = PlayerUtil.getPlayer(result.getArg(1)); if (player == null) { this.errorPlayer(sender); return; 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 b8576f0..76b0064 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Config.java @@ -6,14 +6,13 @@ import org.jetbrains.annotations.NotNull; 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.Colors2; import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; +import su.nightexpress.excellentenchants.tier.Tier; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.TreeMap; +import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -139,4 +138,24 @@ public class Config { ObtainSettings settings = OBTAIN_SETTINGS.get().get(obtainType); return settings == null || !settings.isEnabled() ? Optional.empty() : Optional.of(settings); } + + @NotNull + public static List getDefaultTiers() { + List list = new ArrayList<>(); + list.add(new Tier("common", 1, "Common", Colors2.WHITE, getObtainWeight(50D))); + list.add(new Tier("rare", 2, "Rare", Colors2.GREEN, getObtainWeight(25D))); + list.add(new Tier("unique", 3, "Unique", Colors2.YELLOW, getObtainWeight(15D))); + list.add(new Tier("legendary", 4, "Legendary", Colors2.ORANGE, getObtainWeight(5D))); + list.add(new Tier("cursed", 0, "Cursed", Colors2.RED, getObtainWeight(5D))); + return list; + } + + @NotNull + private static Map getObtainWeight(double weight) { + Map map = new HashMap<>(); + for (ObtainType obtainType : ObtainType.values()) { + map.put(obtainType, weight); + } + return map; + } } 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 f6e7dc8..1baeeba 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/config/Lang.java @@ -3,7 +3,7 @@ package su.nightexpress.excellentenchants.config; import su.nexmedia.engine.api.lang.LangKey; import su.nexmedia.engine.lang.EngineLang; -import static su.nexmedia.engine.utils.Colors.*; +import static su.nexmedia.engine.utils.Colors2.*; import static su.nightexpress.excellentenchants.Placeholders.*; public class Lang extends EngineLang { @@ -12,18 +12,18 @@ public class Lang extends EngineLang { public static final LangKey COMMAND_ENCHANT_USAGE = LangKey.of("Command.Enchant.Usage", " [player] [slot]"); 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_SELF = LangKey.of("Command.Enchant.Done.Self", ORANGE + GENERIC_ITEM + LIGHT_YELLOW + " enchanted with " + GENERIC_ENCHANT + " " + GENERIC_LEVEL + LIGHT_YELLOW + "!"); - public static final LangKey COMMAND_ENCHANT_DONE_OTHERS = LangKey.of("Command.Enchant.Done.Others", ORANGE + PLAYER_NAME + LIGHT_YELLOW + "'s " + ORANGE + GENERIC_ITEM + LIGHT_YELLOW + " enchanted with " + GENERIC_ENCHANT + " " + GENERIC_LEVEL + LIGHT_YELLOW + "!"); + public static final LangKey COMMAND_ENCHANT_DONE_SELF = LangKey.of("Command.Enchant.Done.Self", LIGHT_ORANGE + GENERIC_ITEM + LIGHT_YELLOW + " enchanted with " + GENERIC_ENCHANT + " " + GENERIC_LEVEL + LIGHT_YELLOW + "!"); + public static final LangKey COMMAND_ENCHANT_DONE_OTHERS = LangKey.of("Command.Enchant.Done.Others", LIGHT_ORANGE + PLAYER_DISPLAY_NAME + LIGHT_YELLOW + "'s " + LIGHT_ORANGE + GENERIC_ITEM + LIGHT_YELLOW + " enchanted with " + GENERIC_ENCHANT + " " + GENERIC_LEVEL + LIGHT_YELLOW + "!"); public static final LangKey COMMAND_ENCHANT_ERROR_NO_ITEM = LangKey.of("Command.Enchant.Error.NoItem", RED + "There is no item to enchant!"); 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", LIGHT_YELLOW + "Given " + ORANGE + GENERIC_ENCHANT + LIGHT_YELLOW + " enchanted book to " + ORANGE + PLAYER_DISPLAY_NAME + LIGHT_YELLOW + "."); + public static final LangKey COMMAND_BOOK_DONE = LangKey.of("Command.Book.Done", LIGHT_YELLOW + "Given " + LIGHT_ORANGE + GENERIC_ENCHANT + LIGHT_YELLOW + " enchanted book to " + LIGHT_ORANGE + PLAYER_DISPLAY_NAME + LIGHT_YELLOW + "."); 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", RED + "Invalid tier!"); - public static final LangKey COMMAND_TIER_BOOK_DONE = LangKey.of("Command.TierBook.Done", LIGHT_YELLOW + "Given " + ORANGE + TIER_NAME + LIGHT_YELLOW + " enchanted book to " + ORANGE + PLAYER_DISPLAY_NAME + LIGHT_YELLOW + "."); + public static final LangKey COMMAND_TIER_BOOK_DONE = LangKey.of("Command.TierBook.Done", LIGHT_YELLOW + "Given " + LIGHT_ORANGE + TIER_NAME + LIGHT_YELLOW + " enchanted book to " + LIGHT_ORANGE + PLAYER_DISPLAY_NAME + LIGHT_YELLOW + "."); public static final LangKey ERROR_NO_ENCHANT = LangKey.of("Error.NoEnchant", RED + "Invalid enchantment."); 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 811de83..c4041cf 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 @@ -2,18 +2,18 @@ package su.nightexpress.excellentenchants.enchantment.config; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import su.nexmedia.engine.utils.Scaler; +import su.nexmedia.engine.api.config.JYML; +import su.nexmedia.engine.utils.StringUtil; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.util.Evaluator; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.util.*; -public class EnchantScaler extends Scaler { +public class EnchantScaler { public EnchantScaler(@NotNull ExcellentEnchant enchant, @NotNull String path) { - super(enchant.getConfig(), path, Placeholders.ENCHANTMENT_LEVEL, enchant.getStartLevel(), enchant.getMaxLevel()); + this(enchant.getConfig(), path, Placeholders.ENCHANTMENT_LEVEL, enchant.getStartLevel(), enchant.getMaxLevel()); } @NotNull @@ -27,4 +27,54 @@ public class EnchantScaler extends Scaler { } return new EnchantScaler(enchant, path); } + + private final int levelMin; + private final int levelMax; + private final TreeMap values; + + public EnchantScaler(@NotNull JYML cfg, @NotNull String path, @NotNull String levelPlaceholder, int levelMin, int levelMax) { + this.levelMin = levelMin; + this.levelMax = levelMax; + this.values = new TreeMap<>(); + + // Load different values for each object level. + Set lvlKeys = cfg.getSection(path); + if (!lvlKeys.isEmpty()) { + for (String sLvl : lvlKeys) { + int eLvl = StringUtil.getInteger(sLvl, 0); + if (eLvl < this.getLevelMin() || eLvl > this.getLevelMax()) continue; + + String formula = cfg.getString(path + "." + sLvl, "0").replace(levelPlaceholder, sLvl); + values.put(eLvl, Evaluator.evaluate(formula)); + } + return; + } + + // Load the single formula for all object levels. + for (int lvl = this.getLevelMin(); lvl < (this.getLevelMax() + 1); lvl++) { + String sLvl = String.valueOf(lvl); + String exChance = cfg.getString(path, "").replace(levelPlaceholder, sLvl); + if (exChance.isEmpty()) continue; + + values.put(lvl, Evaluator.evaluate(exChance)); + } + } + + public int getLevelMin() { + return this.levelMin; + } + + public int getLevelMax() { + return this.levelMax; + } + + @NotNull + public TreeMap getValues() { + return this.values; + } + + public double getValue(int level) { + Map.Entry en = this.values.floorEntry(level); + return en != null ? en.getValue() : 0D; + } } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java index fd21885..5ddcaea 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/ExcellentEnchant.java @@ -70,7 +70,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme .add(Placeholders.ENCHANTMENT_LEVEL_MIN, () -> String.valueOf(this.getStartLevel())) .add(Placeholders.ENCHANTMENT_LEVEL_MAX, () -> String.valueOf(this.getMaxLevel())) .add(Placeholders.ENCHANTMENT_TIER, () -> this.getTier().getName()) - .add(Placeholders.ENCHANTMENT_TIER_COLOR, () -> String.valueOf(this.getTier().getColor())) + .add(Placeholders.ENCHANTMENT_TIER_COLOR, () -> this.getTier().getColor()) .add(Placeholders.ENCHANTMENT_FIT_ITEM_TYPES, () -> String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList())) .add(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING, () -> NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING))) .add(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_VILLAGER, () -> NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER))) 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 6e83676..f414428 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 @@ -33,12 +33,12 @@ public class EnchantAnvilListener extends AbstractListener { } @EventHandler(priority = EventPriority.HIGH) - public void onAnvilRename(PrepareAnvilEvent e) { - AnvilInventory inventory = e.getInventory(); + public void onAnvilRename(PrepareAnvilEvent event) { + AnvilInventory inventory = event.getInventory(); ItemStack first = inventory.getItem(0); ItemStack second = inventory.getItem(1); - ItemStack result = e.getResult(); + ItemStack result = event.getResult(); if (first == null) first = new ItemStack(Material.AIR); if (second == null) second = new ItemStack(Material.AIR); @@ -47,10 +47,10 @@ public class EnchantAnvilListener extends AbstractListener { // Check if source item is an enchantable single item. 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; + if (this.handleRename(event, first, second, result)) return; + if (this.handleRecharge(event, first, second, result)) return; - this.handleEnchantMerging(e, first, second, result); + this.handleEnchantMerging(event, first, second, result); } private boolean handleRename(@NotNull PrepareAnvilEvent event, diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java index 787e3fb..f9b3f29 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/registry/EnchantRegistry.java @@ -235,15 +235,20 @@ public class EnchantRegistry extends AbstractManager { } @NotNull - public static Set getPeriodicTalents() { + public static Set getPeriodicEnchants() { return getEnchantments(PassiveEnchant.class); } @NotNull - @SuppressWarnings("unchecked") public static Set getEnchantments(@NotNull Class clazz) { - Set set = new HashSet<>(ENCHANTS_MAP.getOrDefault(clazz, Collections.emptySet())); - return (Set) set; + Set enchants = new HashSet<>(); + + ENCHANTS_MAP.getOrDefault(clazz, Collections.emptySet()).forEach(talent -> { + enchants.add(clazz.cast(talent)); + }); + return enchants; + //Set set = new HashSet<>(ENCHANTS_MAP.getOrDefault(clazz, Collections.emptySet())); + //return (Set) set; } @Nullable diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/Evaluator.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/Evaluator.java new file mode 100644 index 0000000..00a4e18 --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/util/Evaluator.java @@ -0,0 +1,94 @@ +package su.nightexpress.excellentenchants.enchantment.util; + +import org.jetbrains.annotations.NotNull; + +public class Evaluator { + + public static double evaluate(@NotNull final String str) { + return new Object() { + int pos = -1, ch; + + void nextChar() { + ch = (++pos < str.length()) ? str.charAt(pos) : -1; + } + + boolean eat(int charToEat) { + while (ch == ' ') nextChar(); + if (ch == charToEat) { + nextChar(); + return true; + } + return false; + } + + double parse() { + nextChar(); + double x = parseExpression(); + if (pos < str.length()) throw new RuntimeException("Unexpected: " + (char)ch); + return x; + } + + // Grammar: + // expression = term | expression `+` term | expression `-` term + // term = factor | term `*` factor | term `/` factor + // factor = `+` factor | `-` factor | `(` expression `)` | number + // | functionName `(` expression `)` | functionName factor + // | factor `^` factor + + double parseExpression() { + double x = parseTerm(); + for (;;) { + if (eat('+')) x += parseTerm(); // addition + else if (eat('-')) x -= parseTerm(); // subtraction + else return x; + } + } + + double parseTerm() { + double x = parseFactor(); + for (;;) { + if (eat('*')) x *= parseFactor(); // multiplication + else if (eat('/')) x /= parseFactor(); // division + else return x; + } + } + + double parseFactor() { + if (eat('+')) return +parseFactor(); // unary plus + if (eat('-')) return -parseFactor(); // unary minus + + double x; + int startPos = this.pos; + if (eat('(')) { // parentheses + x = parseExpression(); + if (!eat(')')) throw new RuntimeException("Missing ')'"); + } else if ((ch >= '0' && ch <= '9') || ch == '.') { // numbers + while ((ch >= '0' && ch <= '9') || ch == '.') nextChar(); + x = Double.parseDouble(str.substring(startPos, this.pos)); + } else if (ch >= 'a' && ch <= 'z') { // functions + while (ch >= 'a' && ch <= 'z') nextChar(); + String func = str.substring(startPos, this.pos); + if (eat('(')) { + x = parseExpression(); + if (!eat(')')) throw new RuntimeException("Missing ')' after argument to " + func); + } else { + x = parseFactor(); + } + x = switch (func) { + case "sqrt" -> Math.sqrt(x); + case "sin" -> Math.sin(Math.toRadians(x)); + case "cos" -> Math.cos(Math.toRadians(x)); + case "tan" -> Math.tan(Math.toRadians(x)); + default -> throw new RuntimeException("Unknown function: " + func); + }; + } else { + throw new RuntimeException("Unexpected: " + (char)ch); + } + + if (eat('^')) x = Math.pow(x, parseFactor()); // exponentiation + + return x; + } + }.parse(); + } +} 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 f2cde44..739e839 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 @@ -8,6 +8,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.utils.StringUtil; +import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.ExcellentEnchantsAPI; import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry; @@ -16,9 +17,9 @@ public class PlaceholderHook { private static EnchantsExpansion expansion; - public static void setup() { + public static void setup(@NotNull ExcellentEnchants plugin) { if (expansion == null) { - expansion = new EnchantsExpansion(); + expansion = new EnchantsExpansion(plugin); expansion.register(); } } @@ -32,22 +33,28 @@ public class PlaceholderHook { static class EnchantsExpansion extends PlaceholderExpansion { + private final ExcellentEnchants plugin; + + public EnchantsExpansion(@NotNull ExcellentEnchants plugin) { + this.plugin = plugin; + } + @Override @NotNull public String getIdentifier() { - return "excellentenchants"; + return this.plugin.getName().toLowerCase(); } @Override @NotNull public String getAuthor() { - return ExcellentEnchantsAPI.PLUGIN.getDescription().getAuthors().get(0); + return this.plugin.getDescription().getAuthors().get(0); } @Override @NotNull public String getVersion() { - return ExcellentEnchantsAPI.PLUGIN.getDescription().getVersion(); + return this.plugin.getDescription().getVersion(); } @Override 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 49a9cdd..83cc2f1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/tier/Tier.java @@ -1,7 +1,7 @@ package su.nightexpress.excellentenchants.tier; -import net.md_5.bungee.api.ChatColor; import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.placeholder.Placeholder; import su.nexmedia.engine.api.placeholder.PlaceholderMap; import su.nexmedia.engine.utils.Colorizer; @@ -16,16 +16,16 @@ public class Tier implements Placeholder { private final String id; private final int priority; private final String name; - private final ChatColor color; + private final String color; private final Map chance; private final PlaceholderMap placeholderMap; - public Tier(@NotNull String id, int priority, @NotNull String name, @NotNull ChatColor color, + public Tier(@NotNull String id, int priority, @NotNull String name, @NotNull String color, @NotNull Map chance) { this.id = id.toLowerCase(); this.priority = priority; this.name = Colorizer.apply(name); - this.color = color; + this.color = Colorizer.apply(color); this.chance = chance; this.placeholderMap = new PlaceholderMap() .add(Placeholders.TIER_ID, this::getId) @@ -38,6 +38,16 @@ public class Tier implements Placeholder { ; } + public void write(@NotNull JYML cfg, @NotNull String path) { + cfg.set(path + ".Name", this.getName()); + cfg.set(path + ".Color", this.getColor()); + cfg.set(path + ".Priority", this.getPriority()); + cfg.remove(path + ".Obtain_Chance"); + this.getChance().forEach((type, chance) -> { + cfg.set(path + ".Obtain_Chance." + type.name(), chance); + }); + } + @Override @NotNull public PlaceholderMap getPlaceholders() { @@ -59,7 +69,7 @@ public class Tier implements Placeholder { } @NotNull - public ChatColor getColor() { + public String getColor() { return this.color; } 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 98d8b23..cd13c42 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/tier/TierManager.java @@ -1,48 +1,43 @@ package su.nightexpress.excellentenchants.tier; -import net.md_5.bungee.api.ChatColor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nexmedia.engine.api.config.JYML; import su.nexmedia.engine.api.manager.AbstractManager; +import su.nexmedia.engine.utils.Colors2; import su.nexmedia.engine.utils.random.Rnd; import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.config.Config; import su.nightexpress.excellentenchants.enchantment.type.ObtainType; import java.util.*; -import java.util.concurrent.ConcurrentHashMap; 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; + private final Map tierMap; public TierManager(@NotNull ExcellentEnchants plugin) { super(plugin); - this.tiers = new ConcurrentHashMap<>(); - + this.tierMap = new HashMap<>(); } @Override protected void onLoad() { - this.config = JYML.loadOrExtract(plugin, FILE_NAME); + JYML config = this.getConfig(); + + if (config.getSection("").isEmpty()) { + Config.getDefaultTiers().forEach(tier -> tier.write(config, tier.getId())); + } for (String sId : config.getSection("")) { String path = sId + "."; int priority = config.getInt(path + "Priority"); String name = config.getString(path + "Name", sId); - - ChatColor color; - try { - color = ChatColor.of(config.getString(path + "Color", ChatColor.WHITE.getName())); - } - catch (IllegalArgumentException e) { - color = ChatColor.WHITE; - } + String color = config.getString(path + "Color", Colors2.WHITE); Map chance = new HashMap<>(); for (ObtainType obtainType : ObtainType.values()) { @@ -53,35 +48,41 @@ public class TierManager extends AbstractManager { } Tier tier = new Tier(sId, priority, name, color, chance); - this.tiers.put(tier.getId(), tier); + this.tierMap.put(tier.getId(), tier); } + config.saveChanges(); - this.plugin.info("Tiers Loaded: " + this.tiers.size()); + this.plugin.info("Tiers Loaded: " + this.tierMap.size()); } @Override protected void onShutdown() { - this.tiers.clear(); + this.tierMap.clear(); } @NotNull public JYML getConfig() { - return config; + return JYML.loadOrExtract(plugin, FILE_NAME); } - @Nullable - public Tier getTierById(@NotNull String id) { - return this.tiers.get(id.toLowerCase()); + @NotNull + public Map getTierMap() { + return tierMap; } @NotNull public Collection getTiers() { - return this.tiers.values(); + return this.getTierMap().values(); + } + + @Nullable + public Tier getTierById(@NotNull String id) { + return this.getTierMap().get(id.toLowerCase()); } @NotNull public List getTierIds() { - return new ArrayList<>(this.tiers.keySet()); + return new ArrayList<>(this.getTierMap().keySet()); } @Nullable diff --git a/Core/src/main/resources/lang/messages_ru.yml b/Core/src/main/resources/lang/messages_ru.yml index e0f46f1..b216be8 100644 --- a/Core/src/main/resources/lang/messages_ru.yml +++ b/Core/src/main/resources/lang/messages_ru.yml @@ -2,9 +2,8 @@ Command: List: Desc: 'Меню дополнительных зачарований.' Enchant: - Usage: '<зачарование> <уровень>' + Usage: '<зачарование> <уровень> [игрок] [слот]' Desc: 'Зачарование предмета в руке.' - Done: '&aУспешно зачаровано!' Book: Usage: '<игрок> <зачарование> <уровень>' Desc: 'Выдача книги с указанным зачарованием.' diff --git a/Core/src/main/resources/tiers.yml b/Core/src/main/resources/tiers.yml deleted file mode 100644 index 0d928b4..0000000 --- a/Core/src/main/resources/tiers.yml +++ /dev/null @@ -1,50 +0,0 @@ -common: - Name: 'Common' - Color: 'WHITE' - Priority: 1 - Obtain_Chance: - ENCHANTING: 80.0 - VILLAGER: 80.0 - LOOT_GENERATION: 80.0 - FISHING: 80.0 - MOB_SPAWNING: 80.0 -rare: - Name: 'Rare' - Color: 'GREEN' - Priority: 2 - Obtain_Chance: - ENCHANTING: 50.0 - VILLAGER: 50.0 - LOOT_GENERATION: 50.0 - FISHING: 50.0 - MOB_SPAWNING: 50.0 -exotic: - Name: 'Exotic' - Color: 'YELLOW' - Priority: 3 - Obtain_Chance: - ENCHANTING: 25.0 - VILLAGER: 25.0 - LOOT_GENERATION: 25.0 - FISHING: 25.0 - MOB_SPAWNING: 25.0 -legendary: - Name: 'Legendary' - Color: 'GOLD' - Priority: 4 - Obtain_Chance: - ENCHANTING: 10.0 - VILLAGER: 10.0 - LOOT_GENERATION: 10.0 - FISHING: 10.0 - MOB_SPAWNING: 10.0 -cursed: - Name: 'Cursed' - Color: 'RED' - Priority: 0 - Obtain_Chance: - ENCHANTING: 0.0 - VILLAGER: 5.0 - LOOT_GENERATION: 7.0 - FISHING: 12.0 - MOB_SPAWNING: 0.0 \ No newline at end of file From de8dde553399e47c2cd048c7528a538c2be45c2d Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 28 Nov 2023 19:46:58 +0500 Subject: [PATCH 69/69] v3.6.4 --- .../enchantment/impl/meta/PotionImplementation.java | 5 ++--- .../enchantment/impl/tool/VeinminerEnchant.java | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) 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 d6ca37d..a15c83d 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 @@ -4,7 +4,6 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.potion.PotionEffect; 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.meta.Potioned; import su.nightexpress.excellentenchants.config.Config; @@ -15,8 +14,8 @@ public final class PotionImplementation implements Potioned { private final ExcellentEnchant enchant; private final PotionEffectType effectType; - private final Scaler duration; - private final Scaler amplifier; + private final EnchantScaler duration; + private final EnchantScaler amplifier; private final boolean isPermanent; private PotionImplementation(@NotNull ExcellentEnchant enchant, diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/VeinminerEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/VeinminerEnchant.java index 7c2bb15..8a651ac 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/VeinminerEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/VeinminerEnchant.java @@ -11,7 +11,6 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nexmedia.engine.api.config.JOption; -import su.nexmedia.engine.utils.Scaler; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; @@ -37,7 +36,7 @@ public class VeinminerEnchant extends ExcellentEnchant implements BlockBreakEnch private static final String PLACEHOLDER_BLOCK_LIMIT = "%enchantment_block_limit%"; - private Scaler blocksLimit; + private EnchantScaler blocksLimit; private Set blocksAffected; public VeinminerEnchant(@NotNull ExcellentEnchants plugin) {