From 8b5139a1b0996c6a8bbe331eaa76fb58a02d7681 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 16 Apr 2021 16:36:41 +0100 Subject: [PATCH] Revert "Started EcoSkills" This reverts commit dba5d455 --- eco-core/core-nms/build.gradle | 9 + eco-core/core-nms/v1_16_R1/build.gradle | 6 + .../proxy/v1_16_R1/FastGetEnchants.java | 53 ++ .../proxy/v1_16_R1/OpenInventory.java | 13 + .../proxy/v1_16_R1/RepairCost.java | 22 + eco-core/core-nms/v1_16_R2/build.gradle | 6 + .../proxy/v1_16_R2/FastGetEnchants.java | 53 ++ .../proxy/v1_16_R2/OpenInventory.java | 13 + .../proxy/v1_16_R2/RepairCost.java | 22 + eco-core/core-nms/v1_16_R3/build.gradle | 6 + .../proxy/v1_16_R3/FastGetEnchants.java | 53 ++ .../proxy/v1_16_R3/OpenInventory.java | 13 + .../proxy/v1_16_R3/RepairCost.java | 22 + .../willfp/ecoenchants/EcoEnchantsPlugin.java | 236 ++++++ .../command/commands/CommandEcodebug.java | 150 ++++ .../command/commands/CommandEcoreload.java} | 10 +- .../command/commands/CommandEnchantinfo.java | 139 ++++ .../commands/CommandGiverandombook.java | 68 ++ .../commands/CommandRandomenchant.java | 124 +++ .../TabCompleterEnchantinfo.java | 73 ++ .../TabCompleterRandomEnchant.java | 53 ++ .../willfp/ecoenchants/config/RarityYml.java | 27 + .../willfp/ecoenchants/config/TargetYml.java | 45 ++ .../config/configs/EnchantmentConfig.java | 103 +++ .../ecoenchants/display/EnchantDisplay.java | 253 ++++++ .../ecoenchants/display/EnchantmentCache.java | 211 +++++ .../display/options/DescriptionOptions.java | 45 ++ .../display/options/DisplayOptions.java | 145 ++++ .../display/options/NumbersOptions.java | 39 + .../display/options/ShrinkOptions.java | 44 ++ .../options/sorting/EnchantmentSorter.java | 24 + .../options/sorting/SortParameters.java | 18 + .../options/sorting/SorterManager.java | 52 ++ .../implementations/AlphabeticSorter.java | 32 + .../sorting/implementations/LengthSorter.java | 33 + .../RarityAlphabeticSorter.java | 53 ++ .../implementations/RarityLengthSorter.java | 53 ++ .../RarityTypeAlphabeticSorter.java | 62 ++ .../RarityTypeLengthSorter.java | 64 ++ .../implementations/TypeAlphabeticSorter.java | 53 ++ .../implementations/TypeLengthSorter.java | 52 ++ .../ecoenchants/enchantments/EcoEnchant.java | 367 +++++++++ .../ecoenchants/enchantments/EcoEnchants.java | 605 +++++++++++++++ .../ecoenchants/artifact/AngerArtifact.java | 18 + .../ecoenchants/artifact/AshArtifact.java | 18 + .../ecoenchants/artifact/BarrierArtifact.java | 18 + .../ecoenchants/artifact/CloudsArtifact.java | 24 + .../ecoenchants/artifact/CrimsonArtifact.java | 18 + .../ecoenchants/artifact/DamageArtifact.java | 18 + .../ecoenchants/artifact/DragonArtifact.java | 18 + .../ecoenchants/artifact/DustArtifact.java | 18 + .../ecoenchants/artifact/EmeraldArtifact.java | 18 + .../artifact/EnchantmentArtifact.java | 18 + .../ecoenchants/artifact/EndArtifact.java | 18 + .../ecoenchants/artifact/FireArtifact.java | 18 + .../ecoenchants/artifact/HeartArtifact.java | 18 + .../ecoenchants/artifact/HoneyArtifact.java | 18 + .../ecoenchants/artifact/InkArtifact.java | 18 + .../ecoenchants/artifact/LavaArtifact.java | 18 + .../ecoenchants/artifact/LimeArtifact.java | 24 + .../ecoenchants/artifact/MagicArtifact.java | 18 + .../ecoenchants/artifact/MagmaArtifact.java | 18 + .../ecoenchants/artifact/MusicArtifact.java | 18 + .../artifact/NautilusArtifact.java | 18 + .../ecoenchants/artifact/NetherArtifact.java | 18 + .../artifact/RedstoneArtifact.java | 24 + .../ecoenchants/artifact/SmokeArtifact.java | 18 + .../ecoenchants/artifact/SnowArtifact.java | 18 + .../ecoenchants/artifact/SoulArtifact.java | 18 + .../artifact/SoulFireArtifact.java | 18 + .../ecoenchants/artifact/SparkleArtifact.java | 18 + .../ecoenchants/artifact/SweepArtifact.java | 18 + .../ecoenchants/artifact/TearArtifact.java | 18 + .../ecoenchants/artifact/TotemArtifact.java | 18 + .../artifact/VillagerArtifact.java | 18 + .../ecoenchants/artifact/WarpedArtifact.java | 18 + .../ecoenchants/artifact/WaterArtifact.java | 18 + .../ecoenchants/artifact/WitchArtifact.java | 18 + .../ecoenchants/artifact/ZapArtifact.java | 24 + .../ecoenchants/curse/BreaklessnessCurse.java | 29 + .../ecoenchants/curse/CallingCurse.java | 90 +++ .../ecoenchants/curse/DecayCurse.java | 120 +++ .../ecoenchants/curse/FragilityCurse.java | 37 + .../ecoenchants/curse/HarmlessnessCurse.java | 29 + .../ecoenchants/curse/HungerCurse.java | 44 ++ .../ecoenchants/curse/InaccuracyCurse.java | 32 + .../ecoenchants/curse/MisfortuneCurse.java | 29 + .../ecoenchants/curse/PermanenceCurse.java | 13 + .../ecoenchants/normal/Abattoir.java | 39 + .../ecoenchants/normal/Abrasion.java | 61 ++ .../ecoenchants/normal/Aerial.java | 50 ++ .../ecoenchants/normal/Aquatic.java | 34 + .../ecoenchants/normal/Arachnid.java | 34 + .../ecoenchants/normal/Arborist.java | 71 ++ .../ecoenchants/normal/Arcanic.java | 31 + .../ecoenchants/normal/Atmospheric.java | 46 ++ .../ecoenchants/normal/Aversion.java | 49 ++ .../ecoenchants/normal/Backstab.java | 39 + .../ecoenchants/normal/Beheading.java | 79 ++ .../ecoenchants/normal/BlastMining.java | 85 ++ .../ecoenchants/normal/Bleed.java | 51 ++ .../ecoenchants/normal/Blind.java | 38 + .../ecoenchants/normal/BlockBreather.java | 32 + .../ecoenchants/normal/BossHunter.java | 39 + .../ecoenchants/normal/Buckshot.java | 57 ++ .../ecoenchants/normal/Butchering.java | 35 + .../ecoenchants/normal/Cerebral.java | 39 + .../ecoenchants/normal/Chopless.java | 35 + .../ecoenchants/normal/Cleave.java | 45 ++ .../ecoenchants/normal/Collateral.java | 24 + .../ecoenchants/normal/Conclude.java | 37 + .../ecoenchants/normal/Corrosive.java | 56 ++ .../ecoenchants/normal/Cranial.java | 34 + .../ecoenchants/normal/Criticals.java | 38 + .../ecoenchants/normal/Cubism.java | 33 + .../ecoenchants/normal/Defender.java | 39 + .../ecoenchants/normal/Deflection.java | 37 + .../ecoenchants/normal/Defusion.java | 30 + .../ecoenchants/normal/Dexterous.java | 39 + .../ecoenchants/normal/Disable.java | 34 + .../ecoenchants/normal/Disappear.java | 33 + .../ecoenchants/normal/Diurnal.java | 35 + .../ecoenchants/normal/Diverse.java | 34 + .../ecoenchants/normal/Drill.java | 63 ++ .../ecoenchants/normal/Dullness.java | 37 + .../ecoenchants/normal/Dweller.java | 32 + .../ecoenchants/normal/Economical.java | 33 + .../ecoenchants/normal/Electroshock.java | 33 + .../ecoenchants/normal/EndInfusion.java | 31 + .../ecoenchants/normal/EnderSlayer.java | 41 + .../ecoenchants/normal/Enderism.java | 66 ++ .../ecoenchants/normal/Evasion.java | 28 + .../ecoenchants/normal/Extinguishing.java | 31 + .../ecoenchants/normal/Extract.java | 33 + .../ecoenchants/normal/Famine.java | 36 + .../ecoenchants/normal/Farmhand.java | 101 +++ .../ecoenchants/normal/Fetching.java | 67 ++ .../ecoenchants/normal/Finality.java | 37 + .../ecoenchants/normal/Finishing.java | 35 + .../ecoenchants/normal/FireAffinity.java | 31 + .../ecoenchants/normal/FirstStrike.java | 32 + .../ecoenchants/normal/Flinch.java | 36 + .../ecoenchants/normal/Forcefield.java | 87 +++ .../ecoenchants/normal/Freerunner.java | 28 + .../ecoenchants/normal/Frozen.java | 57 ++ .../enchantments/ecoenchants/normal/Fury.java | 58 ++ .../ecoenchants/normal/Goliath.java | 37 + .../ecoenchants/normal/Graceful.java | 56 ++ .../ecoenchants/normal/Grapple.java | 31 + .../ecoenchants/normal/GreenThumb.java | 61 ++ .../enchantments/ecoenchants/normal/Grit.java | 58 ++ .../ecoenchants/normal/Hellish.java | 33 + .../enchantments/ecoenchants/normal/Hook.java | 32 + .../ecoenchants/normal/Horde.java | 31 + .../ecoenchants/normal/IceShot.java | 35 + .../ecoenchants/normal/Identify.java | 36 + .../ecoenchants/normal/Ignite.java | 53 ++ .../ecoenchants/normal/IllusionAspect.java | 36 + .../ecoenchants/normal/Impact.java | 32 + .../ecoenchants/normal/Incandescence.java | 58 ++ .../ecoenchants/normal/InfernalTouch.java | 131 ++++ .../ecoenchants/normal/Inferno.java | 38 + .../ecoenchants/normal/Infuriate.java | 54 ++ .../ecoenchants/normal/Insecticide.java | 34 + .../ecoenchants/normal/Instantaneous.java | 38 + .../ecoenchants/normal/Introversion.java | 30 + .../ecoenchants/normal/Invigoration.java | 72 ++ .../ecoenchants/normal/Kinetic.java | 29 + .../ecoenchants/normal/Launch.java | 56 ++ .../ecoenchants/normal/Leeching.java | 36 + .../ecoenchants/normal/Lesion.java | 49 ++ .../ecoenchants/normal/Levitate.java | 37 + .../ecoenchants/normal/LiquidShot.java | 37 + .../ecoenchants/normal/LuckyCatch.java | 55 ++ .../ecoenchants/normal/Lumberjack.java | 66 ++ .../ecoenchants/normal/MagmaWalker.java | 101 +++ .../ecoenchants/normal/Magnetic.java | 90 +++ .../ecoenchants/normal/Marking.java | 48 ++ .../ecoenchants/normal/Marksman.java | 48 ++ .../ecoenchants/normal/Necrotic.java | 58 ++ .../ecoenchants/normal/NetherInfusion.java | 31 + .../ecoenchants/normal/Netheric.java | 33 + .../ecoenchants/normal/Nocturnal.java | 35 + .../ecoenchants/normal/Optics.java | 36 + .../ecoenchants/normal/Oxygenate.java | 35 + .../ecoenchants/normal/Pacify.java | 34 + .../ecoenchants/normal/Paladin.java | 32 + .../ecoenchants/normal/Paralyze.java | 36 + .../ecoenchants/normal/Parasitic.java | 33 + .../ecoenchants/normal/Parry.java | 46 ++ .../ecoenchants/normal/Phantasm.java | 35 + .../ecoenchants/normal/Plasmic.java | 66 ++ .../ecoenchants/normal/Protector.java | 36 + .../ecoenchants/normal/Proximity.java | 35 + .../ecoenchants/normal/Puncture.java | 35 + .../ecoenchants/normal/Quadrilateralism.java | 35 + .../ecoenchants/normal/Radiance.java | 47 ++ .../enchantments/ecoenchants/normal/Rage.java | 55 ++ .../ecoenchants/normal/Rapid.java | 32 + .../ecoenchants/normal/Reaper.java | 14 + .../ecoenchants/normal/Rebounding.java | 63 ++ .../enchantments/ecoenchants/normal/Reel.java | 61 ++ .../ecoenchants/normal/Reinforcement.java | 29 + .../ecoenchants/normal/Rejuvenation.java | 46 ++ .../ecoenchants/normal/Replenish.java | 54 ++ .../ecoenchants/normal/Respirator.java | 31 + .../ecoenchants/normal/Revenant.java | 35 + .../ecoenchants/normal/Sating.java | 47 ++ .../ecoenchants/normal/Serrated.java | 29 + .../ecoenchants/normal/Settle.java | 34 + .../ecoenchants/normal/Shockwave.java | 75 ++ .../ecoenchants/normal/ShotAssist.java | 58 ++ .../ecoenchants/normal/Sickening.java | 37 + .../ecoenchants/normal/Slaughter.java | 39 + .../ecoenchants/normal/Slicing.java | 66 ++ .../ecoenchants/normal/Spearfishing.java | 91 +++ .../ecoenchants/normal/Spiked.java | 57 ++ .../ecoenchants/normal/Splash.java | 72 ++ .../enchantments/ecoenchants/normal/Stab.java | 28 + .../ecoenchants/normal/Stalwart.java | 37 + .../ecoenchants/normal/Stamina.java | 51 ++ .../ecoenchants/normal/StoneSwitcher.java | 62 ++ .../ecoenchants/normal/StrayAspect.java | 38 + .../ecoenchants/normal/Succession.java | 46 ++ .../ecoenchants/normal/Supercritical.java | 33 + .../ecoenchants/normal/Sycophant.java | 32 + .../ecoenchants/normal/Tectonic.java | 52 ++ .../ecoenchants/normal/Telekinesis.java | 199 +++++ .../enchantments/ecoenchants/normal/Thor.java | 36 + .../ecoenchants/normal/Thrive.java | 63 ++ .../ecoenchants/normal/Tornado.java | 30 + .../ecoenchants/normal/Toxic.java | 34 + .../ecoenchants/normal/Transfuse.java | 65 ++ .../ecoenchants/normal/Tripleshot.java | 40 + .../ecoenchants/normal/VampireAspect.java | 34 + .../enchantments/ecoenchants/normal/Vein.java | 66 ++ .../ecoenchants/normal/Venom.java | 32 + .../ecoenchants/normal/VoidAffinity.java | 33 + .../ecoenchants/normal/Voltage.java | 69 ++ .../ecoenchants/normal/WaterAffinity.java | 32 + .../ecoenchants/normal/WaterAspect.java | 35 + .../ecoenchants/normal/Weakening.java | 46 ++ .../ecoenchants/normal/Wisdom.java | 39 + .../ecoenchants/normal/WoodSwitcher.java | 63 ++ .../ecoenchants/normal/Wound.java | 49 ++ .../enchantments/ecoenchants/normal/Zeus.java | 34 + .../ecoenchants/special/Aiming.java | 125 +++ .../ecoenchants/special/Annihilate.java | 35 + .../ecoenchants/special/Bladed.java | 30 + .../ecoenchants/special/Bolt.java | 35 + .../ecoenchants/special/Carve.java | 45 ++ .../ecoenchants/special/Confusion.java | 52 ++ .../ecoenchants/special/Energizing.java | 30 + .../ecoenchants/special/Force.java | 29 + .../ecoenchants/special/Frenzy.java | 43 + .../ecoenchants/special/Harpoon.java | 57 ++ .../special/Indestructibility.java | 42 + .../ecoenchants/special/Instability.java | 65 ++ .../ecoenchants/special/Intellect.java | 39 + .../ecoenchants/special/LifeSteal.java | 36 + .../ecoenchants/special/Pentashot.java | 46 ++ .../ecoenchants/special/Preservation.java | 31 + .../ecoenchants/special/Prosperity.java | 63 ++ .../ecoenchants/special/Razor.java | 32 + .../ecoenchants/special/Repairing.java | 123 +++ .../ecoenchants/special/Soulbound.java | 139 ++++ .../ecoenchants/special/Spring.java | 34 + .../ecoenchants/special/Streamlining.java | 28 + .../ecoenchants/special/Volatile.java | 56 ++ .../ecoenchants/spell/Ascend.java | 44 ++ .../ecoenchants/spell/Charge.java | 27 + .../ecoenchants/spell/Dynamite.java | 90 +++ .../ecoenchants/spell/Missile.java | 64 ++ .../enchantments/ecoenchants/spell/Quake.java | 45 ++ .../ecoenchants/spell/Vitalize.java | 22 + .../enchantments/itemtypes/Artifact.java | 179 +++++ .../enchantments/itemtypes/Spell.java | 248 ++++++ .../enchantments/meta/EnchantmentRarity.java | 158 ++++ .../enchantments/meta/EnchantmentTarget.java | 95 +++ .../enchantments/meta/EnchantmentType.java | 242 ++++++ .../support/merging/anvil/AnvilListeners.java | 143 ++++ .../support/merging/anvil/AnvilMerge.java | 274 +++++++ .../grindstone/GrindstoneListeners.java | 80 ++ .../merging/grindstone/GrindstoneMerge.java | 75 ++ .../obtaining/EnchantingListeners.java | 295 +++++++ .../support/obtaining/LootPopulator.java | 163 ++++ .../support/obtaining/VillagerListeners.java | 225 ++++++ .../enchantments/util/EnchantChecks.java | 437 +++++++++++ .../enchantments/util/EnchantmentUtils.java | 71 ++ .../enchantments/util/ItemConversions.java | 228 ++++++ .../enchantments/util/SpellActivateEvent.java | 66 ++ .../enchantments/util/TimedRunnable.java | 10 + .../enchantments/util/Watcher.java | 238 ++++++ .../enchantments/util/WatcherTriggers.java | 733 ++++++++++++++++++ .../essentials/EssentialsManager.java | 31 + .../essentials/EssentialsWrapper.java | 11 + .../plugins/IntegrationEssentials.java | 30 + .../willfp/ecoenchants/util/ProxyUtils.java | 21 + .../com/willfp/ecoskills/EcoSkillsPlugin.java | 165 ---- .../willfp/ecoskills/classes/ClassesMenu.java | 36 - .../ecoskills/classes/SkillClasses.java | 49 -- .../ecoskills/command/CommandClasses.java | 25 - .../willfp/ecoskills/config/ClassConfig.java | 18 - .../enchants/artifact/angerartifact.yml | 47 ++ .../enchants/artifact/ashartifact.yml | 47 ++ .../enchants/artifact/barrierartifact.yml | 47 ++ .../enchants/artifact/cloudsartifact.yml | 47 ++ .../enchants/artifact/crimsonartifact.yml | 47 ++ .../enchants/artifact/damageartifact.yml | 47 ++ .../enchants/artifact/dragonartifact.yml | 47 ++ .../enchants/artifact/dustartifact.yml | 47 ++ .../enchants/artifact/emeraldartifact.yml | 47 ++ .../enchants/artifact/enchantmentartifact.yml | 47 ++ .../enchants/artifact/endartifact.yml | 47 ++ .../enchants/artifact/fireartifact.yml | 47 ++ .../enchants/artifact/heartartifact.yml | 47 ++ .../enchants/artifact/honeyartifact.yml | 47 ++ .../enchants/artifact/inkartifact.yml | 47 ++ .../enchants/artifact/lavaartifact.yml | 47 ++ .../enchants/artifact/limeartifact.yml | 47 ++ .../enchants/artifact/magicartifact.yml | 47 ++ .../enchants/artifact/magmaartifact.yml | 47 ++ .../enchants/artifact/musicartifact.yml | 47 ++ .../enchants/artifact/nautilusartifact.yml | 47 ++ .../enchants/artifact/netherartifact.yml | 47 ++ .../enchants/artifact/redstoneartifact.yml | 47 ++ .../enchants/artifact/smokeartifact.yml | 47 ++ .../enchants/artifact/snowartifact.yml | 47 ++ .../enchants/artifact/soulartifact.yml | 47 ++ .../enchants/artifact/soulfireartifact.yml | 47 ++ .../enchants/artifact/sparkleartifact.yml | 47 ++ .../enchants/artifact/sweepartifact.yml | 47 ++ .../enchants/artifact/tearartifact.yml | 47 ++ .../enchants/artifact/totemartifact.yml | 47 ++ .../enchants/artifact/villagerartifact.yml | 47 ++ .../enchants/artifact/warpedartifact.yml | 47 ++ .../enchants/artifact/waterartifact.yml | 47 ++ .../enchants/artifact/witchartifact.yml | 47 ++ .../enchants/artifact/zapartifact.yml | 47 ++ .../enchants/curse/breaklessnesscurse.yml | 26 + .../resources/enchants/curse/callingcurse.yml | 28 + .../resources/enchants/curse/decaycurse.yml | 26 + .../enchants/curse/fragilitycurse.yml | 25 + .../enchants/curse/harmlessnesscurse.yml | 24 + .../resources/enchants/curse/hungercurse.yml | 24 + .../enchants/curse/inaccuracycurse.yml | 23 + .../enchants/curse/misfortunecurse.yml | 27 + .../enchants/curse/permanencecurse.yml | 24 + .../resources/enchants/normal/abattoir.yml | 30 + .../resources/enchants/normal/abrasion.yml | 25 + .../main/resources/enchants/normal/aerial.yml | 25 + .../resources/enchants/normal/aquatic.yml | 24 + .../resources/enchants/normal/arachnid.yml | 30 + .../resources/enchants/normal/arborist.yml | 35 + .../resources/enchants/normal/arcanic.yml | 27 + .../resources/enchants/normal/atmospheric.yml | 24 + .../resources/enchants/normal/aversion.yml | 23 + .../resources/enchants/normal/backstab.yml | 25 + .../resources/enchants/normal/beheading.yml | 25 + .../resources/enchants/normal/blastmining.yml | 31 + .../main/resources/enchants/normal/bleed.yml | 27 + .../main/resources/enchants/normal/blind.yml | 26 + .../enchants/normal/blockbreather.yml | 24 + .../resources/enchants/normal/bosshunter.yml | 25 + .../resources/enchants/normal/buckshot.yml | 28 + .../resources/enchants/normal/butchering.yml | 31 + .../resources/enchants/normal/cerebral.yml | 25 + .../resources/enchants/normal/chopless.yml | 27 + .../main/resources/enchants/normal/cleave.yml | 26 + .../resources/enchants/normal/collateral.yml | 24 + .../resources/enchants/normal/conclude.yml | 25 + .../resources/enchants/normal/corrosive.yml | 25 + .../resources/enchants/normal/cranial.yml | 24 + .../resources/enchants/normal/criticals.yml | 26 + .../main/resources/enchants/normal/cubism.yml | 25 + .../resources/enchants/normal/defender.yml | 24 + .../resources/enchants/normal/deflection.yml | 24 + .../resources/enchants/normal/defusion.yml | 32 + .../resources/enchants/normal/dexterous.yml | 25 + .../resources/enchants/normal/disable.yml | 25 + .../resources/enchants/normal/disappear.yml | 28 + .../resources/enchants/normal/diurnal.yml | 25 + .../resources/enchants/normal/diverse.yml | 24 + .../main/resources/enchants/normal/drill.yml | 33 + .../resources/enchants/normal/dullness.yml | 26 + .../resources/enchants/normal/dweller.yml | 25 + .../resources/enchants/normal/economical.yml | 24 + .../enchants/normal/electroshock.yml | 25 + .../resources/enchants/normal/enderism.yml | 26 + .../resources/enchants/normal/enderslayer.yml | 32 + .../resources/enchants/normal/endinfusion.yml | 25 + .../resources/enchants/normal/evasion.yml | 28 + .../enchants/normal/extinguishing.yml | 27 + .../resources/enchants/normal/extract.yml | 24 + .../main/resources/enchants/normal/famine.yml | 25 + .../resources/enchants/normal/farmhand.yml | 27 + .../resources/enchants/normal/fetching.yml | 23 + .../resources/enchants/normal/finality.yml | 25 + .../resources/enchants/normal/finishing.yml | 25 + .../enchants/normal/fireaffinity.yml | 25 + .../resources/enchants/normal/firststrike.yml | 24 + .../main/resources/enchants/normal/flinch.yml | 25 + .../resources/enchants/normal/forcefield.yml | 30 + .../resources/enchants/normal/freerunner.yml | 24 + .../main/resources/enchants/normal/frozen.yml | 28 + .../main/resources/enchants/normal/fury.yml | 26 + .../resources/enchants/normal/goliath.yml | 25 + .../resources/enchants/normal/graceful.yml | 24 + .../resources/enchants/normal/grapple.yml | 28 + .../resources/enchants/normal/greenthumb.yml | 23 + .../main/resources/enchants/normal/grit.yml | 27 + .../resources/enchants/normal/hellish.yml | 25 + .../main/resources/enchants/normal/hook.yml | 25 + .../main/resources/enchants/normal/horde.yml | 25 + .../resources/enchants/normal/iceshot.yml | 25 + .../resources/enchants/normal/identify.yml | 25 + .../main/resources/enchants/normal/ignite.yml | 25 + .../enchants/normal/illusionaspect.yml | 25 + .../main/resources/enchants/normal/impact.yml | 25 + .../enchants/normal/incandescence.yml | 28 + .../enchants/normal/infernaltouch.yml | 25 + .../resources/enchants/normal/inferno.yml | 23 + .../resources/enchants/normal/infuriate.yml | 25 + .../resources/enchants/normal/insecticide.yml | 29 + .../enchants/normal/instantaneous.yml | 27 + .../enchants/normal/introversion.yml | 32 + .../enchants/normal/invigoration.yml | 30 + .../resources/enchants/normal/kinetic.yml | 24 + .../main/resources/enchants/normal/launch.yml | 24 + .../resources/enchants/normal/leeching.yml | 27 + .../main/resources/enchants/normal/lesion.yml | 26 + .../resources/enchants/normal/levitate.yml | 26 + .../resources/enchants/normal/liquidshot.yml | 25 + .../resources/enchants/normal/luckycatch.yml | 24 + .../resources/enchants/normal/lumberjack.yml | 41 + .../resources/enchants/normal/magmawalker.yml | 26 + .../resources/enchants/normal/magnetic.yml | 26 + .../resources/enchants/normal/marking.yml | 26 + .../resources/enchants/normal/marksman.yml | 24 + .../resources/enchants/normal/necrotic.yml | 25 + .../resources/enchants/normal/netheric.yml | 26 + .../enchants/normal/netherinfusion.yml | 25 + .../resources/enchants/normal/nocturnal.yml | 25 + .../main/resources/enchants/normal/optics.yml | 25 + .../resources/enchants/normal/oxygenate.yml | 27 + .../main/resources/enchants/normal/pacify.yml | 30 + .../resources/enchants/normal/paladin.yml | 24 + .../resources/enchants/normal/paralyze.yml | 25 + .../resources/enchants/normal/parasitic.yml | 25 + .../main/resources/enchants/normal/parry.yml | 24 + .../resources/enchants/normal/phantasm.yml | 30 + .../resources/enchants/normal/plasmic.yml | 25 + .../resources/enchants/normal/protector.yml | 24 + .../resources/enchants/normal/proximity.yml | 25 + .../resources/enchants/normal/puncture.yml | 24 + .../enchants/normal/quadrilateralism.yml | 25 + .../resources/enchants/normal/radiance.yml | 26 + .../main/resources/enchants/normal/rage.yml | 25 + .../main/resources/enchants/normal/rapid.yml | 24 + .../main/resources/enchants/normal/reaper.yml | 25 + .../resources/enchants/normal/rebounding.yml | 27 + .../main/resources/enchants/normal/reel.yml | 24 + .../enchants/normal/reinforcement.yml | 24 + .../enchants/normal/rejuvenation.yml | 27 + .../resources/enchants/normal/replenish.yml | 23 + .../resources/enchants/normal/respirator.yml | 24 + .../resources/enchants/normal/revenant.yml | 29 + .../main/resources/enchants/normal/sating.yml | 24 + .../resources/enchants/normal/serrated.yml | 30 + .../main/resources/enchants/normal/settle.yml | 29 + .../resources/enchants/normal/shockwave.yml | 24 + .../resources/enchants/normal/shotassist.yml | 27 + .../resources/enchants/normal/sickening.yml | 26 + .../resources/enchants/normal/slaughter.yml | 29 + .../resources/enchants/normal/slicing.yml | 26 + .../enchants/normal/spearfishing.yml | 29 + .../main/resources/enchants/normal/spiked.yml | 25 + .../main/resources/enchants/normal/splash.yml | 26 + .../main/resources/enchants/normal/stab.yml | 26 + .../resources/enchants/normal/stalwart.yml | 28 + .../resources/enchants/normal/stamina.yml | 24 + .../enchants/normal/stoneswitcher.yml | 30 + .../resources/enchants/normal/strayaspect.yml | 26 + .../resources/enchants/normal/succession.yml | 27 + .../enchants/normal/supercritical.yml | 26 + .../resources/enchants/normal/sycophant.yml | 24 + .../resources/enchants/normal/tectonic.yml | 28 + .../resources/enchants/normal/telekinesis.yml | 31 + .../main/resources/enchants/normal/thor.yml | 26 + .../main/resources/enchants/normal/thrive.yml | 28 + .../resources/enchants/normal/tornado.yml | 28 + .../main/resources/enchants/normal/toxic.yml | 25 + .../resources/enchants/normal/transfuse.yml | 34 + .../resources/enchants/normal/tripleshot.yml | 26 + .../enchants/normal/vampireaspect.yml | 25 + .../main/resources/enchants/normal/vein.yml | 39 + .../main/resources/enchants/normal/venom.yml | 25 + .../enchants/normal/voidaffinity.yml | 25 + .../resources/enchants/normal/voltage.yml | 25 + .../enchants/normal/wateraffinity.yml | 25 + .../resources/enchants/normal/wateraspect.yml | 26 + .../resources/enchants/normal/weakening.yml | 25 + .../main/resources/enchants/normal/wisdom.yml | 33 + .../enchants/normal/woodswitcher.yml | 32 + .../main/resources/enchants/normal/wound.yml | 27 + .../main/resources/enchants/normal/zeus.yml | 26 + .../resources/enchants/special/aiming.yml | 28 + .../resources/enchants/special/annihilate.yml | 28 + .../resources/enchants/special/bladed.yml | 33 + .../main/resources/enchants/special/bolt.yml | 26 + .../main/resources/enchants/special/carve.yml | 26 + .../resources/enchants/special/confusion.yml | 25 + .../resources/enchants/special/energizing.yml | 28 + .../main/resources/enchants/special/force.yml | 29 + .../resources/enchants/special/frenzy.yml | 24 + .../resources/enchants/special/harpoon.yml | 25 + .../enchants/special/indestructibility.yml | 25 + .../enchants/special/instability.yml | 26 + .../resources/enchants/special/intellect.yml | 33 + .../resources/enchants/special/lifesteal.yml | 27 + .../resources/enchants/special/pentashot.yml | 28 + .../enchants/special/preservation.yml | 31 + .../resources/enchants/special/prosperity.yml | 28 + .../main/resources/enchants/special/razor.yml | 33 + .../resources/enchants/special/repairing.yml | 27 + .../resources/enchants/special/soulbound.yml | 23 + .../resources/enchants/special/spring.yml | 24 + .../enchants/special/streamlining.yml | 24 + .../resources/enchants/special/volatile.yml | 27 + .../main/resources/enchants/spell/ascend.yml | 27 + .../main/resources/enchants/spell/charge.yml | 26 + .../resources/enchants/spell/dynamite.yml | 30 + .../main/resources/enchants/spell/missile.yml | 28 + .../main/resources/enchants/spell/quake.yml | 27 + .../resources/enchants/spell/vitalize.yml | 28 + .../core-plugin/src/main/resources/rarity.yml | 68 ++ .../core-plugin/src/main/resources/target.yml | 104 +++ eco-core/core-proxy/build.gradle | 6 + .../proxy/proxies/FastGetEnchantsProxy.java | 28 + .../proxy/proxies/OpenInventoryProxy.java | 15 + .../proxy/proxies/RepairCostProxy.java | 25 + .../ecoenchants/proxy/util/ProxyFactory.java | 75 ++ eco-extensions/alchemy/build.gradle | 7 + .../willfp/ecoenchants/alchemy/Alchemy.java | 79 ++ .../ecoenchants/alchemy/AlchemyMain.java | 27 + .../resources/enchants/normal/alchemy.yml | 27 + .../alchemy/src/main/resources/extension.yml | 3 + eco-extensions/biomes/build.gradle | 7 + .../ecoenchants/biomes/BiomesEnchantment.java | 84 ++ .../willfp/ecoenchants/biomes/BiomesMain.java | 43 + .../biomes/enchants/defensive/Elevation.java | 20 + .../biomes/enchants/defensive/Glacial.java | 20 + .../enchants/defensive/HeatTreated.java | 20 + .../biomes/enchants/defensive/Oceanic.java | 20 + .../biomes/enchants/defensive/Tropical.java | 20 + .../biomes/enchants/offensive/Altitude.java | 22 + .../biomes/enchants/offensive/Aquamarine.java | 22 + .../enchants/offensive/Dehydration.java | 19 + .../biomes/enchants/offensive/Icelord.java | 19 + .../biomes/enchants/offensive/Rainforest.java | 19 + .../resources/enchants/normal/altitude.yml | 32 + .../resources/enchants/normal/aquamarine.yml | 32 + .../resources/enchants/normal/dehydration.yml | 32 + .../resources/enchants/normal/elevation.yml | 31 + .../resources/enchants/normal/glacial.yml | 31 + .../resources/enchants/normal/heattreated.yml | 31 + .../resources/enchants/normal/icelord.yml | 32 + .../resources/enchants/normal/oceanic.yml | 31 + .../resources/enchants/normal/rainforest.yml | 32 + .../resources/enchants/normal/tropical.yml | 31 + .../biomes/src/main/resources/extension.yml | 3 + eco-extensions/build.gradle | 16 + eco-extensions/effects/build.gradle | 7 + .../effects/EffectsEnchantment.java | 41 + .../ecoenchants/effects/EffectsMain.java | 33 + .../effects/enchants/JumpBoost.java | 16 + .../effects/enchants/NightVision.java | 16 + .../effects/enchants/Regeneration.java | 16 + .../ecoenchants/effects/enchants/Speed.java | 16 + .../effects/enchants/WaterBreathing.java | 16 + .../resources/enchants/normal/jumpboost.yml | 25 + .../resources/enchants/normal/nightvision.yml | 24 + .../enchants/normal/regeneration.yml | 24 + .../main/resources/enchants/normal/speed.yml | 25 + .../enchants/normal/waterbreathing.yml | 24 + .../effects/src/main/resources/extension.yml | 3 + eco-extensions/endershot/build.gradle | 7 + .../ecoenchants/endershot/Endershot.java | 68 ++ .../ecoenchants/endershot/EndershotMain.java | 24 + .../resources/enchants/normal/endershot.yml | 25 + .../src/main/resources/extension.yml | 3 + eco-extensions/firewand/build.gradle | 7 + .../willfp/ecoenchants/firewand/Firewand.java | 60 ++ .../ecoenchants/firewand/FirewandMain.java | 24 + .../resources/enchants/spell/firewand.yml | 30 + .../firewand/src/main/resources/extension.yml | 3 + eco-extensions/mmo/build.gradle | 24 + .../com/willfp/ecoenchants/mmo/MMOMain.java | 52 ++ .../ecoenchants/mmo/MMOPrerequisites.java | 29 + .../mmo/enchants/abilities/Discounted.java | 34 + .../mmo/enchants/abilities/Recover.java | 35 + .../mmo/enchants/mana/Augment.java | 38 + .../ecoenchants/mmo/enchants/mana/Drain.java | 29 + .../ecoenchants/mmo/enchants/mana/Elixir.java | 38 + .../ecoenchants/mmo/enchants/mana/Siphon.java | 34 + .../mmo/enchants/mana/Spirituality.java | 30 + .../mmo/enchants/misc/Strengthening.java | 38 + .../mmo/enchants/stamina/Athletic.java | 38 + .../mmo/enchants/stamina/Endurance.java | 30 + .../mmo/enchants/stamina/Fortitude.java | 34 + .../mmo/enchants/stamina/Motivate.java | 38 + .../mmo/integrations/mmo/MMOIntegration.java | 23 + .../mmo/integrations/mmo/MMOManager.java | 58 ++ .../mmo/integrations/mmo/plugins/MMOCore.java | 53 ++ .../ecoenchants/mmo/structure/MMOEnchant.java | 8 + .../mmo/structure/MMOEnchantment.java | 14 + .../ecoenchants/mmo/structure/MMOSpell.java | 13 + .../resources/enchants/normal/athletic.yml | 26 + .../resources/enchants/normal/augment.yml | 26 + .../resources/enchants/normal/discounted.yml | 25 + .../main/resources/enchants/normal/elixir.yml | 25 + .../resources/enchants/normal/endurance.yml | 29 + .../resources/enchants/normal/fortitude.yml | 24 + .../resources/enchants/normal/motivate.yml | 25 + .../resources/enchants/normal/recover.yml | 25 + .../main/resources/enchants/normal/siphon.yml | 24 + .../enchants/normal/spirituality.yml | 29 + .../enchants/normal/strengthening.yml | 26 + .../main/resources/enchants/spell/drain.yml | 26 + .../mmo/src/main/resources/extension.yml | 3 + eco-extensions/precision/build.gradle | 7 + .../ecoenchants/precision/Precision.java | 108 +++ .../ecoenchants/precision/PrecisionMain.java | 24 + .../resources/enchants/special/precision.yml | 26 + .../src/main/resources/extension.yml | 3 + eco-extensions/rainbow/build.gradle | 7 + .../willfp/ecoenchants/rainbow/Rainbow.java | 71 ++ .../ecoenchants/rainbow/RainbowMain.java | 24 + .../resources/enchants/normal/rainbow.yml | 56 ++ .../rainbow/src/main/resources/extension.yml | 3 + eco-extensions/sprint-artifacts/build.gradle | 7 + .../SprintArtifactsListener.java | 62 ++ .../sprintartifacts/SprintArtifactsMain.java | 22 + .../src/main/resources/extension.yml | 3 + eco-extensions/summoning/build.gradle | 7 + .../summoning/SummoningEnchantment.java | 133 ++++ .../ecoenchants/summoning/SummoningMain.java | 33 + .../ecoenchants/summoning/SummoningType.java | 7 + .../summoning/enchants/Crawler.java | 17 + .../summoning/enchants/Firestorm.java | 17 + .../ecoenchants/summoning/enchants/Ghoul.java | 17 + .../summoning/enchants/Metallic.java | 17 + .../summoning/enchants/Mortality.java | 17 + .../summoning/enchants/Sniper.java | 17 + .../resources/enchants/normal/crawler.yml | 28 + .../resources/enchants/normal/firestorm.yml | 29 + .../main/resources/enchants/normal/ghoul.yml | 29 + .../resources/enchants/normal/mortality.yml | 29 + .../main/resources/enchants/normal/sniper.yml | 28 + .../resources/enchants/special/metallic.yml | 29 + .../src/main/resources/extension.yml | 3 + eco-extensions/xray/build.gradle | 7 + .../com/willfp/ecoenchants/xray/Xray.java | 134 ++++ .../com/willfp/ecoenchants/xray/XrayMain.java | 24 + .../main/resources/enchants/spell/xray.yml | 36 + .../xray/src/main/resources/extension.yml | 3 + gradle.properties | 4 +- 667 files changed, 28073 insertions(+), 300 deletions(-) create mode 100644 eco-core/core-nms/build.gradle create mode 100644 eco-core/core-nms/v1_16_R1/build.gradle create mode 100644 eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R1/FastGetEnchants.java create mode 100644 eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R1/OpenInventory.java create mode 100644 eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R1/RepairCost.java create mode 100644 eco-core/core-nms/v1_16_R2/build.gradle create mode 100644 eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R2/FastGetEnchants.java create mode 100644 eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R2/OpenInventory.java create mode 100644 eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R2/RepairCost.java create mode 100644 eco-core/core-nms/v1_16_R3/build.gradle create mode 100644 eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/FastGetEnchants.java create mode 100644 eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/OpenInventory.java create mode 100644 eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/RepairCost.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java rename eco-core/core-plugin/src/main/java/com/willfp/{ecoskills/command/CommandEsreload.java => ecoenchants/command/commands/CommandEcoreload.java} (66%) create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandGiverandombook.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandRandomenchant.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterEnchantinfo.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterRandomEnchant.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/RarityYml.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/TargetYml.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/DescriptionOptions.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/DisplayOptions.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/NumbersOptions.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/ShrinkOptions.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/EnchantmentSorter.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SortParameters.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SorterManager.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/AlphabeticSorter.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/LengthSorter.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityAlphabeticSorter.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityLengthSorter.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeAlphabeticSorter.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeLengthSorter.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeAlphabeticSorter.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeLengthSorter.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/AngerArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/AshArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/BarrierArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CloudsArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CrimsonArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DamageArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DragonArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DustArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EmeraldArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EnchantmentArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EndArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/FireArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HeartArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HoneyArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/InkArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LavaArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LimeArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagicArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagmaArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MusicArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/NautilusArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/NetherArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/RedstoneArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SmokeArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SnowArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulFireArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SparkleArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SweepArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TearArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TotemArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/VillagerArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WarpedArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WaterArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WitchArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/ZapArtifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/BreaklessnessCurse.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/FragilityCurse.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HarmlessnessCurse.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HungerCurse.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/MisfortuneCurse.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/PermanenceCurse.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abattoir.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abrasion.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aerial.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aquatic.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arachnid.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arborist.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arcanic.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Atmospheric.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aversion.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Backstab.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Beheading.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlastMining.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Bleed.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Blind.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlockBreather.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BossHunter.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Buckshot.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Butchering.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cerebral.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Chopless.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cleave.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Collateral.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Corrosive.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cranial.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Criticals.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cubism.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defender.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Deflection.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defusion.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dexterous.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disable.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disappear.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diurnal.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diverse.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Drill.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dullness.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dweller.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Economical.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Electroshock.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EndInfusion.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EnderSlayer.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Enderism.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Evasion.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extinguishing.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extract.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Famine.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Farmhand.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fetching.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FireAffinity.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FirstStrike.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Flinch.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Freerunner.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Frozen.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Goliath.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Graceful.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grapple.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/GreenThumb.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grit.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hellish.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hook.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Horde.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IceShot.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Identify.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Ignite.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IllusionAspect.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Incandescence.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/InfernalTouch.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Inferno.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Insecticide.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Introversion.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Invigoration.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Kinetic.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Launch.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Leeching.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lesion.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Levitate.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LiquidShot.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LuckyCatch.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lumberjack.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/MagmaWalker.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marking.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marksman.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/NetherInfusion.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Netheric.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Nocturnal.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Optics.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Oxygenate.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Pacify.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paladin.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paralyze.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parasitic.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parry.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Phantasm.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Plasmic.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Protector.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Proximity.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Puncture.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Quadrilateralism.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Radiance.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rapid.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reaper.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rebounding.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reel.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reinforcement.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rejuvenation.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Replenish.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Respirator.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Revenant.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sating.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Serrated.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Settle.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Shockwave.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/ShotAssist.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sickening.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slaughter.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slicing.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spearfishing.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spiked.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Splash.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stab.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stalwart.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stamina.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StoneSwitcher.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StrayAspect.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Succession.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sycophant.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tectonic.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thor.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thrive.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tornado.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Toxic.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Transfuse.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tripleshot.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VampireAspect.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Vein.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Venom.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VoidAffinity.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Voltage.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAffinity.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAspect.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Weakening.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wisdom.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WoodSwitcher.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wound.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Zeus.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Annihilate.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bolt.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Carve.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Energizing.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Frenzy.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Harpoon.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Indestructibility.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Instability.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Intellect.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/LifeSteal.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Pentashot.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Preservation.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Prosperity.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Spring.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Streamlining.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Volatile.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Ascend.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Charge.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Dynamite.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Missile.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Quake.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Vitalize.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentType.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneListeners.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneMerge.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantChecks.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/ItemConversions.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellActivateEvent.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/TimedRunnable.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/Watcher.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsManager.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsWrapper.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/plugins/IntegrationEssentials.java create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/util/ProxyUtils.java delete mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java delete mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoskills/classes/ClassesMenu.java delete mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoskills/classes/SkillClasses.java delete mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoskills/command/CommandClasses.java delete mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecoskills/config/ClassConfig.java create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/angerartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/ashartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/barrierartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/cloudsartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/crimsonartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/damageartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/dragonartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/dustartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/emeraldartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/enchantmentartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/endartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/fireartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/heartartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/honeyartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/inkartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/lavaartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/limeartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/magicartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/magmaartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/musicartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/nautilusartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/netherartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/redstoneartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/smokeartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/snowartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/soulartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/soulfireartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/sparkleartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/sweepartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/tearartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/totemartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/villagerartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/warpedartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/waterartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/witchartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/artifact/zapartifact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/curse/breaklessnesscurse.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/curse/callingcurse.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/curse/decaycurse.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/curse/fragilitycurse.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/curse/harmlessnesscurse.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/curse/hungercurse.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/curse/inaccuracycurse.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/curse/misfortunecurse.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/curse/permanencecurse.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/abattoir.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/abrasion.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/aerial.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/aquatic.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/arachnid.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/arborist.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/arcanic.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/atmospheric.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/aversion.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/backstab.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/beheading.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/blastmining.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/bleed.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/blind.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/blockbreather.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/bosshunter.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/buckshot.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/butchering.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/cerebral.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/chopless.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/cleave.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/collateral.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/conclude.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/corrosive.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/cranial.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/criticals.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/cubism.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/defender.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/deflection.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/defusion.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/dexterous.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/disable.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/disappear.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/diurnal.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/diverse.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/drill.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/dullness.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/dweller.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/economical.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/electroshock.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/enderism.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/enderslayer.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/endinfusion.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/evasion.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/extinguishing.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/extract.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/famine.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/farmhand.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/fetching.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/finality.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/finishing.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/fireaffinity.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/firststrike.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/flinch.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/forcefield.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/freerunner.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/frozen.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/fury.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/goliath.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/graceful.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/grapple.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/greenthumb.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/grit.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/hellish.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/hook.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/horde.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/iceshot.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/identify.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/ignite.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/illusionaspect.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/impact.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/incandescence.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/infernaltouch.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/inferno.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/infuriate.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/insecticide.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/instantaneous.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/introversion.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/invigoration.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/kinetic.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/launch.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/leeching.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/lesion.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/levitate.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/liquidshot.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/luckycatch.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/lumberjack.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/magmawalker.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/magnetic.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/marking.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/marksman.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/necrotic.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/netheric.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/netherinfusion.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/nocturnal.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/optics.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/oxygenate.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/pacify.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/paladin.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/paralyze.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/parasitic.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/parry.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/phantasm.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/plasmic.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/protector.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/proximity.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/puncture.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/quadrilateralism.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/radiance.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/rage.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/rapid.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/reaper.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/rebounding.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/reel.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/reinforcement.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/rejuvenation.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/replenish.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/respirator.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/revenant.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/sating.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/serrated.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/settle.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/shockwave.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/shotassist.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/sickening.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/slaughter.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/slicing.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/spearfishing.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/spiked.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/splash.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/stab.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/stalwart.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/stamina.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/stoneswitcher.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/strayaspect.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/succession.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/supercritical.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/sycophant.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/tectonic.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/telekinesis.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/thor.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/thrive.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/tornado.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/toxic.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/transfuse.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/tripleshot.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/vampireaspect.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/vein.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/venom.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/voidaffinity.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/voltage.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/wateraffinity.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/wateraspect.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/weakening.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/wisdom.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/woodswitcher.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/wound.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/normal/zeus.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/aiming.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/annihilate.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/bladed.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/bolt.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/carve.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/confusion.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/energizing.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/force.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/frenzy.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/harpoon.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/indestructibility.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/instability.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/intellect.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/lifesteal.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/pentashot.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/preservation.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/prosperity.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/razor.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/repairing.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/soulbound.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/spring.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/streamlining.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/special/volatile.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/spell/ascend.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/spell/charge.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/spell/dynamite.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/spell/missile.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/spell/quake.yml create mode 100644 eco-core/core-plugin/src/main/resources/enchants/spell/vitalize.yml create mode 100644 eco-core/core-plugin/src/main/resources/rarity.yml create mode 100644 eco-core/core-plugin/src/main/resources/target.yml create mode 100644 eco-core/core-proxy/build.gradle create mode 100644 eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/FastGetEnchantsProxy.java create mode 100644 eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/OpenInventoryProxy.java create mode 100644 eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/RepairCostProxy.java create mode 100644 eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/util/ProxyFactory.java create mode 100644 eco-extensions/alchemy/build.gradle create mode 100644 eco-extensions/alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java create mode 100644 eco-extensions/alchemy/src/main/java/com/willfp/ecoenchants/alchemy/AlchemyMain.java create mode 100644 eco-extensions/alchemy/src/main/resources/enchants/normal/alchemy.yml create mode 100644 eco-extensions/alchemy/src/main/resources/extension.yml create mode 100644 eco-extensions/biomes/build.gradle create mode 100644 eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/BiomesEnchantment.java create mode 100644 eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/BiomesMain.java create mode 100644 eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Elevation.java create mode 100644 eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Glacial.java create mode 100644 eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/HeatTreated.java create mode 100644 eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Oceanic.java create mode 100644 eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Tropical.java create mode 100644 eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Altitude.java create mode 100644 eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Aquamarine.java create mode 100644 eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Dehydration.java create mode 100644 eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Icelord.java create mode 100644 eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Rainforest.java create mode 100644 eco-extensions/biomes/src/main/resources/enchants/normal/altitude.yml create mode 100644 eco-extensions/biomes/src/main/resources/enchants/normal/aquamarine.yml create mode 100644 eco-extensions/biomes/src/main/resources/enchants/normal/dehydration.yml create mode 100644 eco-extensions/biomes/src/main/resources/enchants/normal/elevation.yml create mode 100644 eco-extensions/biomes/src/main/resources/enchants/normal/glacial.yml create mode 100644 eco-extensions/biomes/src/main/resources/enchants/normal/heattreated.yml create mode 100644 eco-extensions/biomes/src/main/resources/enchants/normal/icelord.yml create mode 100644 eco-extensions/biomes/src/main/resources/enchants/normal/oceanic.yml create mode 100644 eco-extensions/biomes/src/main/resources/enchants/normal/rainforest.yml create mode 100644 eco-extensions/biomes/src/main/resources/enchants/normal/tropical.yml create mode 100644 eco-extensions/biomes/src/main/resources/extension.yml create mode 100644 eco-extensions/build.gradle create mode 100644 eco-extensions/effects/build.gradle create mode 100644 eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/EffectsEnchantment.java create mode 100644 eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/EffectsMain.java create mode 100644 eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/JumpBoost.java create mode 100644 eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/NightVision.java create mode 100644 eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/Regeneration.java create mode 100644 eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/Speed.java create mode 100644 eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/WaterBreathing.java create mode 100644 eco-extensions/effects/src/main/resources/enchants/normal/jumpboost.yml create mode 100644 eco-extensions/effects/src/main/resources/enchants/normal/nightvision.yml create mode 100644 eco-extensions/effects/src/main/resources/enchants/normal/regeneration.yml create mode 100644 eco-extensions/effects/src/main/resources/enchants/normal/speed.yml create mode 100644 eco-extensions/effects/src/main/resources/enchants/normal/waterbreathing.yml create mode 100644 eco-extensions/effects/src/main/resources/extension.yml create mode 100644 eco-extensions/endershot/build.gradle create mode 100644 eco-extensions/endershot/src/main/java/com/willfp/ecoenchants/endershot/Endershot.java create mode 100644 eco-extensions/endershot/src/main/java/com/willfp/ecoenchants/endershot/EndershotMain.java create mode 100644 eco-extensions/endershot/src/main/resources/enchants/normal/endershot.yml create mode 100644 eco-extensions/endershot/src/main/resources/extension.yml create mode 100644 eco-extensions/firewand/build.gradle create mode 100644 eco-extensions/firewand/src/main/java/com/willfp/ecoenchants/firewand/Firewand.java create mode 100644 eco-extensions/firewand/src/main/java/com/willfp/ecoenchants/firewand/FirewandMain.java create mode 100644 eco-extensions/firewand/src/main/resources/enchants/spell/firewand.yml create mode 100644 eco-extensions/firewand/src/main/resources/extension.yml create mode 100644 eco-extensions/mmo/build.gradle create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/MMOMain.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/MMOPrerequisites.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/abilities/Discounted.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/abilities/Recover.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Augment.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Drain.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Elixir.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Siphon.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Spirituality.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/misc/Strengthening.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Athletic.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Endurance.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Fortitude.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Motivate.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/integrations/mmo/MMOIntegration.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/integrations/mmo/MMOManager.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/integrations/mmo/plugins/MMOCore.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOEnchant.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOEnchantment.java create mode 100644 eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOSpell.java create mode 100644 eco-extensions/mmo/src/main/resources/enchants/normal/athletic.yml create mode 100644 eco-extensions/mmo/src/main/resources/enchants/normal/augment.yml create mode 100644 eco-extensions/mmo/src/main/resources/enchants/normal/discounted.yml create mode 100644 eco-extensions/mmo/src/main/resources/enchants/normal/elixir.yml create mode 100644 eco-extensions/mmo/src/main/resources/enchants/normal/endurance.yml create mode 100644 eco-extensions/mmo/src/main/resources/enchants/normal/fortitude.yml create mode 100644 eco-extensions/mmo/src/main/resources/enchants/normal/motivate.yml create mode 100644 eco-extensions/mmo/src/main/resources/enchants/normal/recover.yml create mode 100644 eco-extensions/mmo/src/main/resources/enchants/normal/siphon.yml create mode 100644 eco-extensions/mmo/src/main/resources/enchants/normal/spirituality.yml create mode 100644 eco-extensions/mmo/src/main/resources/enchants/normal/strengthening.yml create mode 100644 eco-extensions/mmo/src/main/resources/enchants/spell/drain.yml create mode 100644 eco-extensions/mmo/src/main/resources/extension.yml create mode 100644 eco-extensions/precision/build.gradle create mode 100644 eco-extensions/precision/src/main/java/com/willfp/ecoenchants/precision/Precision.java create mode 100644 eco-extensions/precision/src/main/java/com/willfp/ecoenchants/precision/PrecisionMain.java create mode 100644 eco-extensions/precision/src/main/resources/enchants/special/precision.yml create mode 100644 eco-extensions/precision/src/main/resources/extension.yml create mode 100644 eco-extensions/rainbow/build.gradle create mode 100644 eco-extensions/rainbow/src/main/java/com/willfp/ecoenchants/rainbow/Rainbow.java create mode 100644 eco-extensions/rainbow/src/main/java/com/willfp/ecoenchants/rainbow/RainbowMain.java create mode 100644 eco-extensions/rainbow/src/main/resources/enchants/normal/rainbow.yml create mode 100644 eco-extensions/rainbow/src/main/resources/extension.yml create mode 100644 eco-extensions/sprint-artifacts/build.gradle create mode 100644 eco-extensions/sprint-artifacts/src/main/java/com/willfp/ecoenchants/sprintartifacts/SprintArtifactsListener.java create mode 100644 eco-extensions/sprint-artifacts/src/main/java/com/willfp/ecoenchants/sprintartifacts/SprintArtifactsMain.java create mode 100644 eco-extensions/sprint-artifacts/src/main/resources/extension.yml create mode 100644 eco-extensions/summoning/build.gradle create mode 100644 eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningEnchantment.java create mode 100644 eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningMain.java create mode 100644 eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningType.java create mode 100644 eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Crawler.java create mode 100644 eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Firestorm.java create mode 100644 eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Ghoul.java create mode 100644 eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Metallic.java create mode 100644 eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Mortality.java create mode 100644 eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Sniper.java create mode 100644 eco-extensions/summoning/src/main/resources/enchants/normal/crawler.yml create mode 100644 eco-extensions/summoning/src/main/resources/enchants/normal/firestorm.yml create mode 100644 eco-extensions/summoning/src/main/resources/enchants/normal/ghoul.yml create mode 100644 eco-extensions/summoning/src/main/resources/enchants/normal/mortality.yml create mode 100644 eco-extensions/summoning/src/main/resources/enchants/normal/sniper.yml create mode 100644 eco-extensions/summoning/src/main/resources/enchants/special/metallic.yml create mode 100644 eco-extensions/summoning/src/main/resources/extension.yml create mode 100644 eco-extensions/xray/build.gradle create mode 100644 eco-extensions/xray/src/main/java/com/willfp/ecoenchants/xray/Xray.java create mode 100644 eco-extensions/xray/src/main/java/com/willfp/ecoenchants/xray/XrayMain.java create mode 100644 eco-extensions/xray/src/main/resources/enchants/spell/xray.yml create mode 100644 eco-extensions/xray/src/main/resources/extension.yml diff --git a/eco-core/core-nms/build.gradle b/eco-core/core-nms/build.gradle new file mode 100644 index 00000000..4aa1efc1 --- /dev/null +++ b/eco-core/core-nms/build.gradle @@ -0,0 +1,9 @@ +group 'com.willfp' +version rootProject.version + +subprojects { + dependencies { + compileOnly project(':eco-core:core-proxy') + compileOnly project(':eco-core:core-plugin') + } +} \ No newline at end of file diff --git a/eco-core/core-nms/v1_16_R1/build.gradle b/eco-core/core-nms/v1_16_R1/build.gradle new file mode 100644 index 00000000..49623620 --- /dev/null +++ b/eco-core/core-nms/v1_16_R1/build.gradle @@ -0,0 +1,6 @@ +group 'com.willfp' +version rootProject.version + +dependencies { + compileOnly 'org.spigotmc:spigot:1.16.1-R0.1-SNAPSHOT' +} \ No newline at end of file diff --git a/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R1/FastGetEnchants.java b/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R1/FastGetEnchants.java new file mode 100644 index 00000000..f1ac15ed --- /dev/null +++ b/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R1/FastGetEnchants.java @@ -0,0 +1,53 @@ +package com.willfp.ecoenchants.proxy.v1_16_R1; + +import com.willfp.ecoenchants.proxy.proxies.FastGetEnchantsProxy; +import net.minecraft.server.v1_16_R1.NBTBase; +import net.minecraft.server.v1_16_R1.NBTTagCompound; +import net.minecraft.server.v1_16_R1.NBTTagList; +import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_16_R1.util.CraftNamespacedKey; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.HashMap; +import java.util.Map; + +public final class FastGetEnchants implements FastGetEnchantsProxy { + @Override + public Map getEnchantmentsOnItem(@NotNull final ItemStack itemStack) { + net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + NBTTagList enchantmentNBT = nmsStack.getEnchantments(); + HashMap foundEnchantments = new HashMap<>(); + + for (NBTBase base : enchantmentNBT) { + NBTTagCompound compound = (NBTTagCompound) base; + String key = compound.getString("id"); + int level = '\uffff' & compound.getShort("lvl"); + + Enchantment found = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(key)); + if (found != null) { + foundEnchantments.put(found, level); + } + } + return foundEnchantments; + } + + @Override + public int getLevelOnItem(@NotNull final ItemStack itemStack, + @NotNull final Enchantment enchantment) { + net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + NBTTagList enchantmentNBT = nmsStack.getEnchantments(); + + for (NBTBase base : enchantmentNBT) { + NBTTagCompound compound = (NBTTagCompound) base; + String key = compound.getString("id"); + if (!key.equals(enchantment.getKey().toString())) { + continue; + } + + return '\uffff' & compound.getShort("lvl"); + } + return 0; + } +} diff --git a/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R1/OpenInventory.java b/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R1/OpenInventory.java new file mode 100644 index 00000000..7ed7bc16 --- /dev/null +++ b/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R1/OpenInventory.java @@ -0,0 +1,13 @@ +package com.willfp.ecoenchants.proxy.v1_16_R1; + +import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy; +import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public final class OpenInventory implements OpenInventoryProxy { + @Override + public Object getOpenInventory(@NotNull final Player player) { + return ((CraftPlayer) player).getHandle().activeContainer; + } +} diff --git a/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R1/RepairCost.java b/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R1/RepairCost.java new file mode 100644 index 00000000..ffa9c164 --- /dev/null +++ b/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R1/RepairCost.java @@ -0,0 +1,22 @@ +package com.willfp.ecoenchants.proxy.v1_16_R1; + +import com.willfp.ecoenchants.proxy.proxies.RepairCostProxy; +import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public final class RepairCost implements RepairCostProxy { + @Override + public ItemStack setRepairCost(@NotNull final ItemStack itemStack, + final int cost) { + net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + nmsStack.setRepairCost(cost); + return CraftItemStack.asBukkitCopy(nmsStack); + } + + @Override + public int getRepairCost(@NotNull final ItemStack itemStack) { + net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + return nmsStack.getRepairCost(); + } +} diff --git a/eco-core/core-nms/v1_16_R2/build.gradle b/eco-core/core-nms/v1_16_R2/build.gradle new file mode 100644 index 00000000..3f4d50cf --- /dev/null +++ b/eco-core/core-nms/v1_16_R2/build.gradle @@ -0,0 +1,6 @@ +group 'com.willfp' +version rootProject.version + +dependencies { + compileOnly 'org.spigotmc:spigot:1.16.3-R0.1-SNAPSHOT' +} \ No newline at end of file diff --git a/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R2/FastGetEnchants.java b/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R2/FastGetEnchants.java new file mode 100644 index 00000000..a82894b4 --- /dev/null +++ b/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R2/FastGetEnchants.java @@ -0,0 +1,53 @@ +package com.willfp.ecoenchants.proxy.v1_16_R2; + +import com.willfp.ecoenchants.proxy.proxies.FastGetEnchantsProxy; +import net.minecraft.server.v1_16_R2.NBTBase; +import net.minecraft.server.v1_16_R2.NBTTagCompound; +import net.minecraft.server.v1_16_R2.NBTTagList; +import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_16_R2.util.CraftNamespacedKey; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.HashMap; +import java.util.Map; + +public final class FastGetEnchants implements FastGetEnchantsProxy { + @Override + public Map getEnchantmentsOnItem(@NotNull final ItemStack itemStack) { + net.minecraft.server.v1_16_R2.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + NBTTagList enchantmentNBT = nmsStack.getEnchantments(); + HashMap foundEnchantments = new HashMap<>(); + + for (NBTBase base : enchantmentNBT) { + NBTTagCompound compound = (NBTTagCompound) base; + String key = compound.getString("id"); + int level = '\uffff' & compound.getShort("lvl"); + + Enchantment found = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(key)); + if (found != null) { + foundEnchantments.put(found, level); + } + } + return foundEnchantments; + } + + @Override + public int getLevelOnItem(@NotNull final ItemStack itemStack, + @NotNull final Enchantment enchantment) { + net.minecraft.server.v1_16_R2.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + NBTTagList enchantmentNBT = nmsStack.getEnchantments(); + + for (NBTBase base : enchantmentNBT) { + NBTTagCompound compound = (NBTTagCompound) base; + String key = compound.getString("id"); + if (!key.equals(enchantment.getKey().toString())) { + continue; + } + + return '\uffff' & compound.getShort("lvl"); + } + return 0; + } +} diff --git a/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R2/OpenInventory.java b/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R2/OpenInventory.java new file mode 100644 index 00000000..ff876898 --- /dev/null +++ b/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R2/OpenInventory.java @@ -0,0 +1,13 @@ +package com.willfp.ecoenchants.proxy.v1_16_R2; + +import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy; +import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public final class OpenInventory implements OpenInventoryProxy { + @Override + public Object getOpenInventory(@NotNull final Player player) { + return ((CraftPlayer) player).getHandle().activeContainer; + } +} diff --git a/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R2/RepairCost.java b/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R2/RepairCost.java new file mode 100644 index 00000000..fd0cc8c5 --- /dev/null +++ b/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R2/RepairCost.java @@ -0,0 +1,22 @@ +package com.willfp.ecoenchants.proxy.v1_16_R2; + +import com.willfp.ecoenchants.proxy.proxies.RepairCostProxy; +import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public final class RepairCost implements RepairCostProxy { + @Override + public ItemStack setRepairCost(@NotNull final ItemStack itemStack, + final int cost) { + net.minecraft.server.v1_16_R2.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + nmsStack.setRepairCost(cost); + return CraftItemStack.asBukkitCopy(nmsStack); + } + + @Override + public int getRepairCost(@NotNull final ItemStack itemStack) { + net.minecraft.server.v1_16_R2.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + return nmsStack.getRepairCost(); + } +} diff --git a/eco-core/core-nms/v1_16_R3/build.gradle b/eco-core/core-nms/v1_16_R3/build.gradle new file mode 100644 index 00000000..5930f17d --- /dev/null +++ b/eco-core/core-nms/v1_16_R3/build.gradle @@ -0,0 +1,6 @@ +group 'com.willfp' +version rootProject.version + +dependencies { + compileOnly 'org.spigotmc:spigot:1.16.4-R0.1-SNAPSHOT' +} \ No newline at end of file diff --git a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/FastGetEnchants.java b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/FastGetEnchants.java new file mode 100644 index 00000000..af748a63 --- /dev/null +++ b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/FastGetEnchants.java @@ -0,0 +1,53 @@ +package com.willfp.ecoenchants.proxy.v1_16_R3; + +import com.willfp.ecoenchants.proxy.proxies.FastGetEnchantsProxy; +import net.minecraft.server.v1_16_R3.NBTBase; +import net.minecraft.server.v1_16_R3.NBTTagCompound; +import net.minecraft.server.v1_16_R3.NBTTagList; +import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_16_R3.util.CraftNamespacedKey; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.HashMap; +import java.util.Map; + +public final class FastGetEnchants implements FastGetEnchantsProxy { + @Override + public Map getEnchantmentsOnItem(@NotNull final ItemStack itemStack) { + net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + NBTTagList enchantmentNBT = nmsStack.getEnchantments(); + HashMap foundEnchantments = new HashMap<>(); + + for (NBTBase base : enchantmentNBT) { + NBTTagCompound compound = (NBTTagCompound) base; + String key = compound.getString("id"); + int level = '\uffff' & compound.getShort("lvl"); + + Enchantment found = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(key)); + if (found != null) { + foundEnchantments.put(found, level); + } + } + return foundEnchantments; + } + + @Override + public int getLevelOnItem(@NotNull final ItemStack itemStack, + @NotNull final Enchantment enchantment) { + net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + NBTTagList enchantmentNBT = nmsStack.getEnchantments(); + + for (NBTBase base : enchantmentNBT) { + NBTTagCompound compound = (NBTTagCompound) base; + String key = compound.getString("id"); + if (!key.equals(enchantment.getKey().toString())) { + continue; + } + + return '\uffff' & compound.getShort("lvl"); + } + return 0; + } +} diff --git a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/OpenInventory.java b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/OpenInventory.java new file mode 100644 index 00000000..c6549c6b --- /dev/null +++ b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/OpenInventory.java @@ -0,0 +1,13 @@ +package com.willfp.ecoenchants.proxy.v1_16_R3; + +import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy; +import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public final class OpenInventory implements OpenInventoryProxy { + @Override + public Object getOpenInventory(@NotNull final Player player) { + return ((CraftPlayer) player).getHandle().activeContainer; + } +} diff --git a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/RepairCost.java b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/RepairCost.java new file mode 100644 index 00000000..fc4e6868 --- /dev/null +++ b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/RepairCost.java @@ -0,0 +1,22 @@ +package com.willfp.ecoenchants.proxy.v1_16_R3; + +import com.willfp.ecoenchants.proxy.proxies.RepairCostProxy; +import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public final class RepairCost implements RepairCostProxy { + @Override + public ItemStack setRepairCost(@NotNull final ItemStack itemStack, + final int cost) { + net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + nmsStack.setRepairCost(cost); + return CraftItemStack.asBukkitCopy(nmsStack); + } + + @Override + public int getRepairCost(@NotNull final ItemStack itemStack) { + net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + return nmsStack.getRepairCost(); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java new file mode 100644 index 00000000..249493be --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java @@ -0,0 +1,236 @@ +package com.willfp.ecoenchants; + +import com.willfp.eco.core.AbstractPacketAdapter; +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.command.AbstractCommand; +import com.willfp.eco.core.display.DisplayModule; +import com.willfp.eco.core.integrations.IntegrationLoader; +import com.willfp.eco.util.TelekinesisUtils; +import com.willfp.ecoenchants.command.commands.CommandEcodebug; +import com.willfp.ecoenchants.command.commands.CommandEcoreload; +import com.willfp.ecoenchants.command.commands.CommandEnchantinfo; +import com.willfp.ecoenchants.command.commands.CommandGiverandombook; +import com.willfp.ecoenchants.command.commands.CommandRandomenchant; +import com.willfp.ecoenchants.command.tabcompleters.TabCompleterEnchantinfo; +import com.willfp.ecoenchants.config.RarityYml; +import com.willfp.ecoenchants.config.TargetYml; +import com.willfp.ecoenchants.display.EnchantDisplay; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.support.merging.anvil.AnvilListeners; +import com.willfp.ecoenchants.enchantments.support.merging.grindstone.GrindstoneListeners; +import com.willfp.ecoenchants.enchantments.support.obtaining.EnchantingListeners; +import com.willfp.ecoenchants.enchantments.support.obtaining.LootPopulator; +import com.willfp.ecoenchants.enchantments.support.obtaining.VillagerListeners; +import com.willfp.ecoenchants.enchantments.util.ItemConversions; +import com.willfp.ecoenchants.enchantments.util.TimedRunnable; +import com.willfp.ecoenchants.enchantments.util.WatcherTriggers; +import com.willfp.ecoenchants.integrations.essentials.EssentialsManager; +import com.willfp.ecoenchants.integrations.essentials.plugins.IntegrationEssentials; +import com.willfp.ecoenchants.proxy.proxies.FastGetEnchantsProxy; +import com.willfp.ecoenchants.util.ProxyUtils; +import lombok.Getter; +import org.bukkit.Bukkit; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.generator.BlockPopulator; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@SuppressWarnings("unused") +public class EcoEnchantsPlugin extends EcoPlugin { + /** + * Instance of the plugin. + */ + @Getter + private static EcoEnchantsPlugin instance; + + /** + * Rarity.yml. + */ + @Getter + private final RarityYml rarityYml; + + /** + * Target.yml. + */ + @Getter + private final TargetYml targetYml; + + /** + * Internal constructor called by bukkit on plugin load. + */ + public EcoEnchantsPlugin() { + super("EcoEnchants", 79573, 7666, "com.willfp.ecoenchants.proxy", "&a"); + instance = this; + + rarityYml = new RarityYml(this); + targetYml = new TargetYml(this); + } + + /** + * Code executed on plugin enable. + */ + @Override + public void enable() { + this.getExtensionLoader().loadExtensions(); + + if (this.getExtensionLoader().getLoadedExtensions().isEmpty()) { + this.getLogger().info("&cNo extensions found"); + } else { + this.getLogger().info("Extensions Loaded:"); + this.getExtensionLoader().getLoadedExtensions().forEach(extension -> this.getLogger().info("- " + extension.getName() + " v" + extension.getVersion())); + } + + this.getLogger().info(EcoEnchants.values().size() + " Enchantments Loaded"); + + TelekinesisUtils.registerTest(player -> ProxyUtils.getProxy(FastGetEnchantsProxy.class).getLevelOnItem(player.getInventory().getItemInMainHand(), EcoEnchants.TELEKINESIS) > 0); + } + + /** + * Code executed on plugin disable. + */ + @Override + public void disable() { + Bukkit.getServer().getWorlds().forEach(world -> { + List populators = new ArrayList<>(world.getPopulators()); + populators.forEach((blockPopulator -> { + if (blockPopulator instanceof LootPopulator) { + world.getPopulators().remove(blockPopulator); + } + })); + }); + + this.getExtensionLoader().unloadExtensions(); + } + + /** + * Nothing is called on plugin load. + */ + @Override + public void load() { + // Nothing needs to be called on load + } + + /** + * Code executed on /ecoreload. + */ + @Override + public void onReload() { + targetYml.update(); + rarityYml.update(); + ((EnchantDisplay) this.getDisplayModule()).update(); + EcoEnchants.values().forEach((ecoEnchant -> { + HandlerList.unregisterAll(ecoEnchant); + + this.getScheduler().runLater(() -> { + if (ecoEnchant.isEnabled()) { + this.getEventManager().registerListener(ecoEnchant); + + if (ecoEnchant instanceof TimedRunnable) { + this.getScheduler().syncRepeating((TimedRunnable) ecoEnchant, 5, ((TimedRunnable) ecoEnchant).getTime()); + } + } + }, 1); + })); + } + + /** + * Code executed after server is up. + */ + @Override + public void postLoad() { + if (this.getConfigYml().getBool("loot.enabled")) { + Bukkit.getServer().getWorlds().forEach(world -> { + List populators = new ArrayList<>(world.getPopulators()); + populators.forEach((blockPopulator -> { + if (blockPopulator instanceof LootPopulator) { + world.getPopulators().remove(blockPopulator); + } + })); + world.getPopulators().add(new LootPopulator(this)); + }); + } + EssentialsManager.registerEnchantments(); + } + + /** + * EcoEnchants-specific integrations. + * + * @return A list of all integrations. + */ + @Override + public List getIntegrationLoaders() { + return Arrays.asList( + new IntegrationLoader("Essentials", () -> EssentialsManager.register(new IntegrationEssentials())) + ); + } + + /** + * EcoEnchants-specific commands. + * + * @return A list of all commands. + */ + @Override + public List getCommands() { + return Arrays.asList( + new CommandEcodebug(this), + new CommandEcoreload(this), + new CommandEnchantinfo(this), + new CommandRandomenchant(this), + new CommandGiverandombook(this) + ); + } + + /** + * Packet Adapters for enchant display. + * + * @return A list of packet adapters. + */ + @Override + public List getPacketAdapters() { + return new ArrayList<>(); + } + + /** + * EcoEnchants-specific listeners. + * + * @return A list of all listeners. + */ + @Override + public List getListeners() { + return Arrays.asList( + new EnchantingListeners(this), + new GrindstoneListeners(this), + new AnvilListeners(this), + new WatcherTriggers(this), + new VillagerListeners(this), + new ItemConversions(this) + ); + } + + @Override + public List> getUpdatableClasses() { + return Arrays.asList( + EnchantmentCache.class, + EnchantmentRarity.class, + EnchantmentTarget.class, + EcoEnchants.class, + TabCompleterEnchantinfo.class, + EnchantmentType.class, + WatcherTriggers.class + ); + } + + @Override + @Nullable + protected DisplayModule createDisplayModule() { + return new EnchantDisplay(this); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java new file mode 100644 index 00000000..98d407e0 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java @@ -0,0 +1,150 @@ +package com.willfp.ecoenchants.command.commands; + +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.ListenerPriority; +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.command.AbstractCommand; +import com.willfp.eco.core.proxy.ProxyConstants; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +@SuppressWarnings("unchecked") +public class CommandEcodebug extends AbstractCommand { + /** + * Instantiate a new /ecodebug command handler. + * + * @param plugin The plugin for the commands to listen for. + */ + public CommandEcodebug(@NotNull final EcoPlugin plugin) { + super(plugin, "ecodebug", "ecoenchants.ecodebug", false); + } + + @Override + public void onExecute(@NotNull final CommandSender sender, + @NotNull final List args) { + if (!args.isEmpty() && args.get(0).equalsIgnoreCase("full")) { + Bukkit.getLogger().info("--------------- BEGIN DEBUG ----------------"); + if (sender instanceof Player) { + Player player = (Player) sender; + player.sendMessage("Held Item: " + player.getInventory().getItemInMainHand().toString()); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Held Item: " + player.getInventory().getItemInMainHand().toString()); + Bukkit.getLogger().info(""); + } + + Bukkit.getLogger().info("Running Version: " + this.getPlugin().getDescription().getVersion()); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Loaded Extensions: " + this.getPlugin().getExtensionLoader().getLoadedExtensions().stream() + .map(extension -> extension.getName() + " v" + extension.getVersion()) + .collect(Collectors.joining())); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("EcoEnchants.getAll(): " + EcoEnchants.values().toString()); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Enchantment.values(): " + Arrays.toString(Enchantment.values())); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Enchantment Cache: " + EnchantmentCache.getCache().toString()); + Bukkit.getLogger().info(""); + + try { + Field byNameField = Enchantment.class.getDeclaredField("byName"); + byNameField.setAccessible(true); + Map byName = (Map) byNameField.get(null); + Bukkit.getLogger().info("Enchantment.byName: " + byName.toString()); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + Bukkit.getLogger().info(""); + + + List extern = Arrays.stream(Enchantment.values()).collect(Collectors.toList()); + extern.removeAll(EcoEnchants.values().stream().map(EcoEnchant::getEnchantment).collect(Collectors.toList())); + extern.removeIf(enchantment -> enchantment.getClass().toString().toLowerCase().contains("craftbukkit")); + String external = extern.stream().map(enchantment -> "{" + enchantment.toString() + ", Provider: " + enchantment.getClass().toString() + "}").collect(Collectors.joining(", ")); + Bukkit.getLogger().info("External Enchantments: " + external); + Bukkit.getLogger().info(""); + + List uncached = Arrays.stream(Enchantment.values()).collect(Collectors.toList()); + uncached.removeAll(EnchantmentCache.getCache().values().stream().map(EnchantmentCache.CacheEntry::getEnchantment).collect(Collectors.toList())); + Bukkit.getLogger().info("Uncached Enchantments: " + uncached.toString()); + Bukkit.getLogger().info(""); + + List brokenCache = Arrays.stream(Enchantment.values()).collect(Collectors.toList()); + brokenCache.removeIf(enchantment -> !( + EnchantmentCache.getEntry(enchantment).getName().equalsIgnoreCase("null") + || EnchantmentCache.getEntry(enchantment).getRawName().equalsIgnoreCase("null") + || EnchantmentCache.getEntry(enchantment).getStringDescription().equalsIgnoreCase("null"))); + Bukkit.getLogger().info("Enchantments with broken cache: " + brokenCache.toString()); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Installed Plugins: " + Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList()).toString()); + Bukkit.getLogger().info(""); + + Set withIssues = new HashSet<>(); + EcoEnchants.values().forEach(enchant -> { + if (enchant.getRarity() == null) { + withIssues.add(enchant); + } + if (enchant.getTargets().isEmpty()) { + withIssues.add(enchant); + } + }); + Bukkit.getLogger().info("Enchantments with evident issues: " + withIssues.toString()); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Packets: " + ProtocolLibrary.getProtocolManager().getPacketListeners().stream() + .filter(packetListener -> packetListener.getSendingWhitelist().getPriority().equals(ListenerPriority.MONITOR)) + .collect(Collectors.toList()).toString()); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Server Information: "); + Bukkit.getLogger().info("Players Online: " + Bukkit.getServer().getOnlinePlayers().size()); + Bukkit.getLogger().info("Bukkit IP: " + Bukkit.getIp()); + Bukkit.getLogger().info("Running Version: " + Bukkit.getVersion() + + ", Bukkit Version: " + Bukkit.getBukkitVersion() + + ", Alt Version: " + Bukkit.getServer().getVersion() + + ", NMS: " + ProxyConstants.NMS_VERSION); + Bukkit.getLogger().info("Motd: " + Bukkit.getServer().getMotd()); + Bukkit.getLogger().info("--------------- END DEBUG ----------------"); + } else { + if (sender instanceof Player) { + Player player = (Player) sender; + player.sendMessage("Held Item: " + player.getInventory().getItemInMainHand().toString()); + player.sendMessage("Lore: "); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Held Item: " + player.getInventory().getItemInMainHand().toString()); + Bukkit.getLogger().info("Lore: "); + ItemMeta meta = player.getInventory().getItemInMainHand().getItemMeta(); + if (meta != null) { + for (String s : new ArrayList<>(meta.hasLore() ? meta.getLore() : new ArrayList<>())) { + Bukkit.getLogger().info(s); + player.sendMessage(s); + } + } + Bukkit.getLogger().info(""); + } + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/command/CommandEsreload.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcoreload.java similarity index 66% rename from eco-core/core-plugin/src/main/java/com/willfp/ecoskills/command/CommandEsreload.java rename to eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcoreload.java index 6ef005e0..42705f5a 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/command/CommandEsreload.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcoreload.java @@ -1,4 +1,4 @@ -package com.willfp.ecoskills.command; +package com.willfp.ecoenchants.command.commands; import com.willfp.eco.core.EcoPlugin; import com.willfp.eco.core.command.AbstractCommand; @@ -7,14 +7,14 @@ import org.jetbrains.annotations.NotNull; import java.util.List; -public class CommandEsreload extends AbstractCommand { +public class CommandEcoreload extends AbstractCommand { /** - * Instantiate a new /esreload command handler. + * Instantiate a new /ecoreload command handler. * * @param plugin The plugin for the commands to listen for. */ - public CommandEsreload(@NotNull final EcoPlugin plugin) { - super(plugin, "esreload", "ecoskills.reload", false); + public CommandEcoreload(@NotNull final EcoPlugin plugin) { + super(plugin, "ecoreload", "ecoenchants.reload", false); } @Override diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java new file mode 100644 index 00000000..05f7545c --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java @@ -0,0 +1,139 @@ +package com.willfp.ecoenchants.command.commands; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.command.AbstractCommand; +import com.willfp.eco.core.command.AbstractTabCompleter; +import com.willfp.eco.util.StringUtils; +import com.willfp.ecoenchants.command.tabcompleters.TabCompleterEnchantinfo; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import org.apache.commons.lang.WordUtils; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.CommandSender; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class CommandEnchantinfo extends AbstractCommand { + /** + * Instantiate a new /enchantinfo command handler. + * + * @param plugin The plugin for the commands to listen for. + */ + public CommandEnchantinfo(@NotNull final EcoPlugin plugin) { + super(plugin, "enchantinfo", "ecoenchants.enchantinfo", false); + } + + @Override + public AbstractTabCompleter getTab() { + return new TabCompleterEnchantinfo(this); + } + + @Override + public void onExecute(@NotNull final CommandSender sender, + @NotNull final List args) { + if (args.isEmpty()) { + sender.sendMessage(this.getPlugin().getLangYml().getMessage("missing-enchant")); + return; + } + StringBuilder nameBuilder = new StringBuilder(); + + args.forEach(arg -> nameBuilder.append(arg).append(" ")); + String searchName = nameBuilder.toString(); + searchName = searchName.substring(0, searchName.length() - 1); + + EcoEnchant enchantment = EcoEnchants.getByName(searchName); + + if (enchantment == null) { + String finalSearchName = searchName; + enchantment = EcoEnchants.values().stream().filter(ecoEnchant -> ChatColor.stripColor(ecoEnchant.getName()).equalsIgnoreCase(finalSearchName)).findFirst().orElse(null); + } + + if (enchantment == null || !enchantment.isEnabled()) { + String message = this.getPlugin().getLangYml().getMessage("not-found").replace("%name%", searchName); + sender.sendMessage(message); + return; + } + + Set conflictNames = new HashSet<>(); + + Set conflicts = enchantment.getConflicts(); + + new HashSet<>(conflicts).forEach(enchantment1 -> { + EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchantment1); + if (ecoEnchant != null && !ecoEnchant.isEnabled()) { + conflicts.remove(enchantment1); + } + }); + + conflicts.forEach((enchantment1 -> { + if (EcoEnchants.getFromEnchantment(enchantment1) != null) { + conflictNames.add(EcoEnchants.getFromEnchantment(enchantment1).getName()); + } else { + conflictNames.add(this.getPlugin().getLangYml().getString("enchantments." + enchantment1.getKey().getKey() + ".name")); + } + })); + + StringBuilder conflictNamesBuilder = new StringBuilder(); + conflictNames.forEach(name1 -> conflictNamesBuilder.append(name1).append(", ")); + String allConflicts = conflictNamesBuilder.toString(); + if (allConflicts.length() >= 2) { + allConflicts = allConflicts.substring(0, allConflicts.length() - 2); + } else { + allConflicts = StringUtils.translate(this.getPlugin().getLangYml().getString("no-conflicts")); + } + + Set targets = enchantment.getTargetMaterials(); + + Set applicableItemsSet = new HashSet<>(); + + if (this.getPlugin().getConfigYml().getBool("commands.enchantinfo.show-target-group")) { + enchantment.getTargets().forEach(target -> { + String targetName = target.getName(); + targetName = targetName.toLowerCase(); + targetName = targetName.replace("_", " "); + targetName = WordUtils.capitalize(targetName); + applicableItemsSet.add(targetName); + }); + } else { + targets.forEach(material -> { + String matName = material.toString(); + matName = matName.toLowerCase(); + matName = matName.replace("_", " "); + matName = WordUtils.capitalize(matName); + applicableItemsSet.add(matName); + }); + } + + StringBuilder targetNamesBuilder = new StringBuilder(); + applicableItemsSet.forEach(name1 -> targetNamesBuilder.append(name1).append(", ")); + String allTargets = targetNamesBuilder.toString(); + if (allTargets.length() >= 2) { + allTargets = allTargets.substring(0, allTargets.length() - 2); + } else { + allTargets = StringUtils.translate(this.getPlugin().getLangYml().getString("no-targets")); + } + + String maxLevel = String.valueOf(enchantment.getMaxLevel()); + + final String finalName = EnchantmentCache.getEntry(enchantment).getName(); + final String finalDescription = EnchantmentCache.getEntry(enchantment).getStringDescription(); + final String finalTargets = allTargets; + final String finalConflicts = allConflicts; + final String finalMaxLevel = maxLevel; + Arrays.asList(this.getPlugin().getLangYml().getMessage("enchantinfo").split("\\r?\\n")).forEach((string -> { + string = string.replace("%name%", finalName) + .replace("%description%", finalDescription) + .replace("%target%", finalTargets) + .replace("%conflicts%", finalConflicts) + .replace("%maxlevel%", finalMaxLevel); + sender.sendMessage(string); + })); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandGiverandombook.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandGiverandombook.java new file mode 100644 index 00000000..e982eb93 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandGiverandombook.java @@ -0,0 +1,68 @@ +package com.willfp.ecoenchants.command.commands; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.command.AbstractCommand; +import com.willfp.eco.core.command.AbstractTabCompleter; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.command.tabcompleters.TabCompleterRandomEnchant; +import com.willfp.ecoenchants.display.EnchantmentCache; +import org.bukkit.Bukkit; +import org.bukkit.Material; +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 java.util.List; + +public class CommandGiverandombook extends AbstractCommand { + /** + * Instantiate a new /ecoreload command handler. + * + * @param plugin The plugin for the commands to listen for. + */ + public CommandGiverandombook(@NotNull final EcoPlugin plugin) { + super(plugin, "giverandombook", "ecoenchants.randombook", false); + } + + @Override + public AbstractTabCompleter getTab() { + return new TabCompleterRandomEnchant(this); + } + + @Override + public void onExecute(@NotNull final CommandSender sender, + @NotNull final List args) { + if (args.isEmpty()) { + sender.sendMessage(this.getPlugin().getLangYml().getMessage("requires-player")); + return; + } + Player player = Bukkit.getServer().getPlayer(args.get(0)); + + if (player == null) { + sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-player")); + return; + } + + ItemStack itemStack = new ItemStack(Material.ENCHANTED_BOOK); + EnchantmentStorageMeta meta = (EnchantmentStorageMeta) itemStack.getItemMeta(); + Enchantment enchantment = Enchantment.values()[NumberUtils.randInt(0, Enchantment.values().length - 1)]; + int level = NumberUtils.randInt(1, enchantment.getMaxLevel()); + meta.addStoredEnchant(enchantment, level, true); + itemStack.setItemMeta(meta); + + for (ItemStack stack : player.getInventory().addItem(itemStack).values()) { + player.getWorld().dropItem(player.getLocation(), stack); + } + + String message = this.getPlugin().getLangYml().getMessage("gave-random-book"); + message = message.replace("%enchantment%", EnchantmentCache.getEntry(enchantment).getName() + " " + NumberUtils.toNumeral(level) + "§r"); + sender.sendMessage(message); + + String message2 = this.getPlugin().getLangYml().getMessage("received-random-book"); + message2 = message2.replace("%enchantment%", EnchantmentCache.getEntry(enchantment).getName() + " " + NumberUtils.toNumeral(level) + "§r"); + player.sendMessage(message2); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandRandomenchant.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandRandomenchant.java new file mode 100644 index 00000000..3371010d --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandRandomenchant.java @@ -0,0 +1,124 @@ +package com.willfp.ecoenchants.command.commands; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.command.AbstractCommand; +import com.willfp.eco.core.command.AbstractTabCompleter; +import com.willfp.ecoenchants.command.tabcompleters.TabCompleterRandomEnchant; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; +import org.bukkit.Bukkit; +import org.bukkit.Material; +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 java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class CommandRandomenchant extends AbstractCommand { + /** + * Instantiate a new /ecoreload command handler. + * + * @param plugin The plugin for the commands to listen for. + */ + public CommandRandomenchant(@NotNull final EcoPlugin plugin) { + super(plugin, "randomenchant", "ecoenchants.randomenchant", false); + } + + @Override + public AbstractTabCompleter getTab() { + return new TabCompleterRandomEnchant(this); + } + + @Override + public void onExecute(@NotNull final CommandSender sender, + @NotNull final List args) { + Player player; + + if ((args.isEmpty() && sender instanceof Player) || !sender.hasPermission("ecoenchants.randomenchant.others")) { + player = (Player) sender; + } else { + player = Bukkit.getServer().getPlayer(args.get(0)); + } + + if (player == null) { + sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-player")); + return; + } + + ItemStack itemStack = player.getInventory().getItemInMainHand(); + ItemMeta meta = itemStack.getItemMeta(); + + if (itemStack.getType() == Material.AIR || meta == null || !EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) { + if (player.equals(sender)) { + player.sendMessage(this.getPlugin().getLangYml().getMessage("must-hold-item")); + } else { + sender.sendMessage(this.getPlugin().getLangYml().getMessage("must-hold-item-other")); + } + return; + } + + List ecoEnchants = new ArrayList<>(EcoEnchants.values()); + Collections.shuffle(ecoEnchants); + EcoEnchant enchant = null; + + List onItem = new ArrayList<>(); + + if (meta instanceof EnchantmentStorageMeta) { + onItem.addAll(((EnchantmentStorageMeta) meta).getStoredEnchants().keySet()); + } else { + onItem.addAll(meta.getEnchants().keySet()); + } + + for (EcoEnchant ecoEnchant : ecoEnchants) { + if (ecoEnchant.canEnchantItem(itemStack)) { + if (!ecoEnchant.conflictsWithAny(onItem)) { + if (onItem.stream().noneMatch(enchantment -> enchantment.conflictsWith(ecoEnchant))) { + if (!onItem.contains(ecoEnchant)) { + boolean conflicts = false; + for (Enchantment enchantment : onItem) { + if (EcoEnchants.getFromEnchantment(enchantment) != null) { + EcoEnchant ecoEnchantOnItem = EcoEnchants.getFromEnchantment(enchantment); + if (ecoEnchantOnItem.getType().equals(ecoEnchant.getType()) && ecoEnchantOnItem.getType().isSingular()) { + conflicts = true; + } + } + } + if (this.getPlugin().getConfigYml().getBool("anvil.hard-cap.enabled") + && !player.hasPermission("ecoenchants.randomenchant.bypasshardcap") + && onItem.size() >= this.getPlugin().getConfigYml().getInt("anvil.hard-cap.cap")) { + conflicts = true; + } + if (!conflicts) { + enchant = ecoEnchant; + } + } + } + } + } + } + + if (enchant == null) { + player.sendMessage(this.getPlugin().getLangYml().getMessage("no-enchants-available")); + return; + } + + if (meta instanceof EnchantmentStorageMeta) { + ((EnchantmentStorageMeta) meta).addStoredEnchant(enchant, enchant.getMaxLevel(), true); + } else { + meta.addEnchant(enchant, enchant.getMaxLevel(), true); + } + + itemStack.setItemMeta(meta); + String message = this.getPlugin().getLangYml().getMessage("applied-random-enchant"); + message = message.replace("%enchantment%", EnchantmentCache.getEntry(enchant).getName() + "§r"); + player.sendMessage(message); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterEnchantinfo.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterEnchantinfo.java new file mode 100644 index 00000000..fc4bb9a2 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterEnchantinfo.java @@ -0,0 +1,73 @@ +package com.willfp.ecoenchants.command.tabcompleters; + +import com.willfp.eco.core.command.AbstractCommand; +import com.willfp.eco.core.command.AbstractTabCompleter; +import com.willfp.eco.core.config.ConfigUpdater; +import com.willfp.eco.util.StringUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class TabCompleterEnchantinfo extends AbstractTabCompleter { + /** + * The cached enchantment names. + */ + private static final List ENCHANT_NAMES = EcoEnchants.values().stream().filter(EcoEnchant::isEnabled).map(EcoEnchant::getName).map(ChatColor::stripColor).collect(Collectors.toList()); + + /** + * Instantiate a new tab-completer for /enchantinfo. + * + * @param command /enchantinfo. + */ + public TabCompleterEnchantinfo(@NotNull final AbstractCommand command) { + super(command); + } + + /** + * Called on /ecoreload. + */ + @ConfigUpdater + public static void reload() { + ENCHANT_NAMES.clear(); + ENCHANT_NAMES.addAll(EcoEnchants.values().stream().filter(EcoEnchant::isEnabled).map(EcoEnchant::getName).map(ChatColor::stripColor).collect(Collectors.toList())); + } + + /** + * The execution of the tabcompleter. + * + * @param sender The sender of the command. + * @param args The arguments of the command. + * @return A list of tab-completions. + */ + @Override + public List onTab(@NotNull final CommandSender sender, + @NotNull final List args) { + List completions = new ArrayList<>(); + + if (args.isEmpty()) { + // Currently, this case is not ever reached + return ENCHANT_NAMES; + } + + StringUtil.copyPartialMatches(String.join(" ", args), ENCHANT_NAMES, completions); + + if (args.size() > 1) { // Remove all previous words from the candidate of completions + ArrayList finishedArgs = new ArrayList<>(args); + finishedArgs.remove(args.size() - 1); + + String prefix = String.join(" ", finishedArgs); + completions = completions.stream().map(enchantName -> StringUtils.removePrefix(enchantName, prefix).trim()).collect(Collectors.toList()); + } + + Collections.sort(completions); + return completions; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterRandomEnchant.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterRandomEnchant.java new file mode 100644 index 00000000..4f32c00b --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterRandomEnchant.java @@ -0,0 +1,53 @@ +package com.willfp.ecoenchants.command.tabcompleters; + +import com.willfp.eco.core.command.AbstractCommand; +import com.willfp.eco.core.command.AbstractTabCompleter; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class TabCompleterRandomEnchant extends AbstractTabCompleter { + /** + * Instantiate a new tab-completer for /randomenchant. + * + * @param command /randomenchant. + */ + public TabCompleterRandomEnchant(@NotNull final AbstractCommand command) { + super(command); + } + + /** + * The execution of the tabcompleter. + * + * @param sender The sender of the command. + * @param args The arguments of the command. + * @return A list of tab-completions. + */ + @Override + public List onTab(@NotNull final CommandSender sender, + @NotNull final List args) { + List completions = new ArrayList<>(); + + List playerNames = Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList()); + + if (args.isEmpty() || !sender.hasPermission("ecoenchants.randomenchant.others")) { + // Currently, this case is not ever reached + return playerNames; + } + + if (args.size() == 1) { + StringUtil.copyPartialMatches(String.join(" ", args), playerNames, completions); + Collections.sort(completions); + return completions; + } + + return new ArrayList<>(); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/RarityYml.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/RarityYml.java new file mode 100644 index 00000000..86a63bac --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/RarityYml.java @@ -0,0 +1,27 @@ +package com.willfp.ecoenchants.config; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.config.BaseConfig; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class RarityYml extends BaseConfig { + /** + * Instantiate rarity.yml. + * + * @param plugin Instance of EcoEnchants. + */ + public RarityYml(@NotNull final EcoPlugin plugin) { + super("rarity", false, plugin); + } + + /** + * Get all rarity names. + * + * @return Set of all rarity names. + */ + public List getRarities() { + return this.getSubsection("rarities").getKeys(false); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/TargetYml.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/TargetYml.java new file mode 100644 index 00000000..b32e51eb --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/TargetYml.java @@ -0,0 +1,45 @@ +package com.willfp.ecoenchants.config; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.config.BaseConfig; +import org.bukkit.Material; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TargetYml extends BaseConfig { + /** + * Instantiate target.yml. + * + * @param plugin Instance of EcoEnchants. + */ + public TargetYml(@NotNull final EcoPlugin plugin) { + super("target", false, plugin); + } + + /** + * Get all target names. + * + * @return Set of all names. + */ + public List getTargets() { + return this.getSubsection("targets").getKeys(false); + } + + /** + * Get all materials from a target name. + * + * @param target The name of the target. + * @return All materials. + */ + public Set getTargetMaterials(@NotNull final String target) { + Set materials = new HashSet<>(); + this.getStrings("targets." + target).forEach(materialName -> { + materials.add(Material.getMaterial(materialName.toUpperCase())); + }); + + return materials; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java new file mode 100644 index 00000000..8246705a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java @@ -0,0 +1,103 @@ +package com.willfp.ecoenchants.config.configs; + +import com.willfp.eco.core.config.ExtendableConfig; +import com.willfp.ecoenchants.EcoEnchantsPlugin; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import lombok.Getter; +import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class EnchantmentConfig extends ExtendableConfig { + /** + * The name of the config. + */ + @Getter + private final String name; + + /** + * Instantiate a new config for an enchantment. + * + * @param name The name of the config. + * @param plugin The provider of the enchantment. + * @param type The {@link EnchantmentType} of the enchantment. + */ + public EnchantmentConfig(@NotNull final String name, + @NotNull final Class plugin, + @NotNull final EnchantmentType type) { + super(name, true, EcoEnchantsPlugin.getInstance(), plugin, "enchants/" + type.getName() + "/"); + this.name = name; + } + + /** + * Get a set of enchantments stored by key. + * + * @param path The location of the enchantments in the config. + * @return A set of all enchantments. + */ + public Set getEnchantments(@NotNull final String path) { + Set enchantments = new HashSet<>(); + List enchantmentKeys = this.getStrings(path); + enchantmentKeys.forEach((key -> enchantments.add(Enchantment.getByKey(NamespacedKey.minecraft(key))))); + return enchantments; + } + + /** + * Get the rarity of the enchantment. + * + * @return The rarity, or null if invalid. + */ + public EnchantmentRarity getRarity() { + String rarityName = this.getString("obtaining.rarity"); + return EnchantmentRarity.getByName(rarityName); + } + + /** + * Get all applicable targets. + * + * @return The targets. + */ + public Set getTargets() { + List targetNames = this.getStrings(EcoEnchants.GENERAL_LOCATION + "targets"); + if (targetNames.isEmpty()) { + return new HashSet<>(); + } + Set targets = new HashSet<>(); + + targetNames.forEach((s -> { + if (EnchantmentTarget.getByName(s) == null) { + Bukkit.getLogger().warning("Target specified in " + name + " is invalid!"); + return; + } + targets.add(EnchantmentTarget.getByName(s)); + })); + + return targets; + } + + /** + * Load config values from lang.yml. + */ + public void loadFromLang() { + if (!this.getPlugin().getLangYml().has("enchantments." + this.getName())) { + return; + } + + this.set("name", this.getPlugin().getLangYml().getString("enchantments." + this.getName() + ".name")); + this.set("description", this.getPlugin().getLangYml().getString("enchantments." + this.getName() + ".description")); + try { + this.save(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java new file mode 100644 index 00000000..c816c6bc --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java @@ -0,0 +1,253 @@ +package com.willfp.ecoenchants.display; + +import com.google.common.collect.Lists; +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.display.Display; +import com.willfp.eco.core.display.DisplayModule; +import com.willfp.eco.core.display.DisplayPriority; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.display.options.DisplayOptions; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; +import com.willfp.ecoenchants.proxy.proxies.FastGetEnchantsProxy; +import com.willfp.ecoenchants.util.ProxyUtils; +import lombok.Getter; +import org.bukkit.NamespacedKey; +import org.bukkit.enchantments.Enchantment; +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.persistence.PersistentDataType; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; + +/** + * All methods and fields pertaining to showing players the enchantments on their items. + */ +@SuppressWarnings("DeprecatedIsStillUsed") +public class EnchantDisplay extends DisplayModule { + /** + * The meta key to hide enchantments in lore. + *

+ * EcoEnchants packet lore implementation of HideEnchants. + */ + @Getter + private final NamespacedKey keySkip; + + /** + * The legacy V key. + *

+ * Exists for backwards compatibility. + */ + @Getter + @Deprecated + private final NamespacedKey legacyV; + + /** + * The configurable options for displaying enchantments. + */ + @Getter + private final DisplayOptions options; + + /** + * Create EcoEnchants display module. + * + * @param plugin Instance of EcoEnchants. + */ + public EnchantDisplay(@NotNull final EcoPlugin plugin) { + super(plugin, DisplayPriority.HIGH); + keySkip = this.getPlugin().getNamespacedKeyFactory().create("ecoenchantlore-skip"); + legacyV = this.getPlugin().getNamespacedKeyFactory().create("ecoenchantlore-v"); + options = new DisplayOptions(this.getPlugin()); + } + + /** + * Update config values. + */ + public void update() { + options.update(); + EnchantmentCache.update(); + } + + @Override + protected void display(@NotNull final ItemStack itemStack, + @NotNull final Object... args) { + if (options.isRequireTarget()) { + if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) { + return; + } + } + + ItemMeta meta = itemStack.getItemMeta(); + + assert meta != null; + + boolean hide = (boolean) args[0]; + + List itemLore = null; + + if (hide || meta.getPersistentDataContainer().has(keySkip, PersistentDataType.INTEGER)) { + meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); + if (meta instanceof EnchantmentStorageMeta) { + meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + } + meta.getPersistentDataContainer().set(keySkip, PersistentDataType.INTEGER, 1); + itemStack.setItemMeta(meta); + return; + } + + if (meta.hasLore()) { + itemLore = meta.getLore(); + } + + if (itemLore == null) { + itemLore = new ArrayList<>(); + } + + List lore = new ArrayList<>(); + + LinkedHashMap enchantments = new LinkedHashMap<>(); + List forRemoval = new ArrayList<>(); + + if (meta instanceof EnchantmentStorageMeta) { + enchantments.putAll(((EnchantmentStorageMeta) meta).getStoredEnchants()); + } else { + enchantments.putAll(meta.getEnchants()); + } + + enchantments.entrySet().removeIf(enchantmentIntegerEntry -> enchantmentIntegerEntry.getValue().equals(0)); + + List unsorted = new ArrayList<>(); + enchantments.forEach((enchantment, integer) -> unsorted.add(enchantment)); + + HashMap tempEnchantments = new HashMap<>(enchantments); + + options.getSorter().sortEnchantments(unsorted); + + enchantments.clear(); + unsorted.forEach(enchantment -> enchantments.put(enchantment, tempEnchantments.get(enchantment))); + + enchantments.forEach((enchantment, level) -> { + if (EcoEnchants.getFromEnchantment(enchantment) == null) { + return; + } + + EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchantment); + + if (!ecoEnchant.isEnabled()) { + forRemoval.add(enchantment); + } + }); + + forRemoval.forEach(enchantment -> { + enchantments.remove(enchantment); + if (meta instanceof EnchantmentStorageMeta) { + ((EnchantmentStorageMeta) meta).removeStoredEnchant(enchantment); + } else { + meta.removeEnchant(enchantment); + } + }); + + enchantments.forEach((enchantment, level) -> { + String name = EnchantmentCache.getEntry(enchantment).getName(); + + if (!(enchantment.getMaxLevel() == 1 && level == 1)) { + if (options.getNumbersOptions().isUseNumerals() && ProxyUtils.getProxy(FastGetEnchantsProxy.class).getLevelOnItem(itemStack, enchantment) < options.getNumbersOptions().getThreshold()) { + name += " " + NumberUtils.toNumeral(level); + } else { + name += " " + level; + } + } + + lore.add(Display.PREFIX + name); + if (enchantments.size() <= options.getDescriptionOptions().getThreshold() && options.getDescriptionOptions().isEnabled()) { + lore.addAll(EnchantmentCache.getEntry(enchantment).getDescription()); + } + }); + + if (options.getShrinkOptions().isEnabled() && (enchantments.size() > options.getShrinkOptions().getThreshold())) { + List> partitionedCombinedLoreList = Lists.partition(lore, options.getShrinkOptions().getShrinkPerLine()); + List newLore = new ArrayList<>(); + partitionedCombinedLoreList.forEach(list -> { + StringBuilder builder = new StringBuilder(); + for (String s : list) { + builder.append(s); + builder.append(", "); + } + String line = builder.toString(); + line = line.substring(0, line.length() - 2); + newLore.add(line); + }); + lore.clear(); + lore.addAll(newLore); + } + + if (meta instanceof EnchantmentStorageMeta) { + meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + } + + meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); + lore.addAll(itemLore); + meta.setLore(lore); + itemStack.setItemMeta(meta); + } + + @Override + protected void revert(@NotNull final ItemStack itemStack) { + ItemMeta meta = itemStack.getItemMeta(); + + assert meta != null; + + List lore = meta.getLore() == null ? new ArrayList<>() : new ArrayList<>(meta.getLore()); + + lore.removeIf(s -> s.startsWith("§w")); + meta.setLore(lore); + + meta.getPersistentDataContainer().remove(legacyV); + + if (!meta.getPersistentDataContainer().has(keySkip, PersistentDataType.INTEGER)) { + meta.removeItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + meta.removeItemFlags(ItemFlag.HIDE_ENCHANTS); + } + + meta.getPersistentDataContainer().remove(keySkip); + itemStack.setItemMeta(meta); + } + + @Override + protected Object[] generateVarArgs(@NotNull final ItemStack itemStack) { + ItemMeta meta = itemStack.getItemMeta(); + if (meta == null) { + return new Object[]{false}; + } + boolean hideEnchants = false; + + if (meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS) || meta.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) { + hideEnchants = true; + } + + if (meta.getPersistentDataContainer().has(legacyV, PersistentDataType.INTEGER)) { + hideEnchants = false; + } + + if (Display.isFinalized(itemStack)) { + hideEnchants = false; + } + + if (options.isUsingExperimentalHideFixer() && options.isUsingForceHideFixer()) { + hideEnchants = false; + } + + if (options.isUsingExperimentalHideFixer() && meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS) && meta.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) { + hideEnchants = false; + } + + return new Object[]{hideEnchants}; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java new file mode 100644 index 00000000..6e882e34 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java @@ -0,0 +1,211 @@ +package com.willfp.ecoenchants.display; + +import com.google.common.collect.ImmutableMap; +import com.willfp.eco.core.config.ConfigUpdater; +import com.willfp.eco.core.display.Display; +import com.willfp.ecoenchants.EcoEnchantsPlugin; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import lombok.Getter; +import lombok.ToString; +import lombok.experimental.UtilityClass; +import org.apache.commons.lang.WordUtils; +import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentWrapper; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@UtilityClass +@SuppressWarnings("deprecation") +public class EnchantmentCache { + /** + * Instance of EcoEnchants. + */ + public static final EcoEnchantsPlugin PLUGIN = EcoEnchantsPlugin.getInstance(); + + /** + * The physical cache. + */ + private static final Map CACHE = new HashMap<>(); + + /** + * Get the {@link CacheEntry} for a specific enchantment. + *

+ * Returns a default "broken" cache entry if not cached. + * + * @param enchantment The enchantment to query. + * @return The found cache entry. + */ + public static CacheEntry getEntry(@NotNull final Enchantment enchantment) { + CacheEntry matching = CACHE.get(enchantment.getKey()); + if (matching != null) { + return matching; + } else { + updateEnchantment(enchantment); + Bukkit.getLogger().warning(enchantment.getKey() + " (from class " + enchantment.getClass() + ") was not cached! Trying to fix..."); + return getEntry(enchantment); + } + } + + /** + * Get the entire cache. + * + * @return An immutable map of the cache. + */ + public static Map getCache() { + return ImmutableMap.copyOf(CACHE); + } + + /** + * Update the cache. + */ + @ConfigUpdater + public static void update() { + CACHE.clear(); + Arrays.asList(Enchantment.values()).forEach(EnchantmentCache::updateEnchantment); + } + + private static void updateEnchantment(@NotNull final Enchantment enchantment) { + CACHE.remove(enchantment.getKey()); + + if (enchantment instanceof EnchantmentWrapper) { + Bukkit.getLogger().severe("Found erroneous enchantment registration!"); + Bukkit.getLogger().severe("Enchantment " + enchantment.getKey() + + " (Found in class " + enchantment.getClass().getName() + ", Path: " + enchantment.getClass().getProtectionDomain().getCodeSource().getLocation().getPath() + ")" + ); + Bukkit.getLogger().severe("Tell the author to lean how enchantments are stored internally."); + Bukkit.getLogger().severe("Hint: Extend Enchantment instead of EnchantmentWrapper."); + CACHE.put(enchantment.getKey(), new CacheEntry( + enchantment, + "&4INVALID ENCHANTMENT", + "INVALID", + Collections.singletonList(Display.PREFIX + "INVALID ENCHANTMENT: " + enchantment.getClass().getName()), + EnchantmentType.NORMAL, + EnchantmentRarity.getByName(PLUGIN.getConfigYml().getString("rarity.vanilla-rarity")) + )); + return; + } + + String name; + String color; + EnchantmentType type; + EnchantmentRarity rarity; + List description; + if (EcoEnchants.getFromEnchantment(enchantment) != null) { + EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchantment); + description = ecoEnchant.getWrappedDescription(); + name = ecoEnchant.getName(); + type = ecoEnchant.getType(); + rarity = ecoEnchant.getRarity(); + } else { + description = Arrays.asList( + WordUtils.wrap( + String.valueOf(PLUGIN.getLangYml().getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".description")), + PLUGIN.getConfigYml().getInt("lore.describe.wrap"), + "\n", false + ).split("\\r?\\n") + ); + name = String.valueOf(PLUGIN.getLangYml().getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".name")); + type = enchantment.isCursed() ? EnchantmentType.CURSE : EnchantmentType.NORMAL; + if (enchantment.isTreasure()) { + rarity = EnchantmentRarity.getByName(PLUGIN.getConfigYml().getString("rarity.vanilla-treasure-rarity")); + } else { + rarity = EnchantmentRarity.getByName(PLUGIN.getConfigYml().getString("rarity.vanilla-rarity")); + } + } + + color = type.getColor(); + + if (rarity != null && rarity.hasCustomColor() && type != EnchantmentType.CURSE) { + color = rarity.getCustomColor(); + } + + if (rarity == null) { + rarity = EnchantmentRarity.getByName(PLUGIN.getConfigYml().getString("rarity.vanilla-rarity")); + } + + String rawName = name; + name = color + name; + description.replaceAll(line -> Display.PREFIX + ((EnchantDisplay) PLUGIN.getDisplayModule()).getOptions().getDescriptionOptions().getColor() + line); + CACHE.put(enchantment.getKey(), new CacheEntry(enchantment, name, rawName, description, type, rarity)); + } + + @ToString + public static final class CacheEntry { + /** + * The enchantment that this cache is for. + */ + @Getter + private final Enchantment enchantment; + + /** + * The formatted name of the enchantment. + */ + @Getter + private final String name; + + /** + * The raw (unformatted) name of the enchantment. + */ + @Getter + private final String rawName; + + /** + * The description, line-wrapped. + */ + @Getter + private final List description; + + /** + * The description, not line-wrapped or colorized. + */ + @Getter + private final String stringDescription; + + /** + * The type of the enchantment. + */ + @Getter + private final EnchantmentType type; + + /** + * The rarity of the enchantment. + */ + @Getter + private final EnchantmentRarity rarity; + + private CacheEntry(@NotNull final Enchantment enchantment, + @NotNull final String name, + @NotNull final String rawName, + @NotNull final List description, + @NotNull final EnchantmentType type, + @NotNull final EnchantmentRarity rarity) { + this.enchantment = enchantment; + this.name = name; + this.rawName = rawName; + this.description = description; + this.type = type; + this.rarity = rarity; + + StringBuilder descriptionBuilder = new StringBuilder(); + + description.forEach(s -> { + descriptionBuilder.append(s); + descriptionBuilder.append(" "); + }); + + String processedStringDescription = descriptionBuilder.toString(); + processedStringDescription = processedStringDescription.replace(Display.PREFIX, ""); + this.stringDescription = processedStringDescription.replaceAll(((EnchantDisplay) PLUGIN.getDisplayModule()).getOptions().getDescriptionOptions().getColor(), ""); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/DescriptionOptions.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/DescriptionOptions.java new file mode 100644 index 00000000..48d20cfd --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/DescriptionOptions.java @@ -0,0 +1,45 @@ +package com.willfp.ecoenchants.display.options; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.eco.util.StringUtils; +import lombok.Getter; +import org.jetbrains.annotations.NotNull; + +public class DescriptionOptions extends PluginDependent { + /** + * The threshold below which to describe enchantments. + */ + @Getter + private int threshold; + + /** + * If the options are enabled. + */ + @Getter + private boolean enabled; + + /** + * The description lines color. + */ + @Getter + private String color; + + /** + * Create new description options. + * + * @param plugin EcoEnchants. + */ + public DescriptionOptions(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + /** + * Update the options. + */ + public void update() { + threshold = this.getPlugin().getConfigYml().getInt("lore.describe.before-lines"); + enabled = this.getPlugin().getConfigYml().getBool("lore.describe.enabled"); + color = StringUtils.translate(this.getPlugin().getLangYml().getString("description-color")); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/DisplayOptions.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/DisplayOptions.java new file mode 100644 index 00000000..7574a820 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/DisplayOptions.java @@ -0,0 +1,145 @@ +package com.willfp.ecoenchants.display.options; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter; +import com.willfp.ecoenchants.display.options.sorting.SortParameters; +import com.willfp.ecoenchants.display.options.sorting.SorterManager; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import lombok.Getter; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +public class DisplayOptions extends PluginDependent { + /** + * The description options being used. + */ + @Getter + private final DescriptionOptions descriptionOptions = new DescriptionOptions(this.getPlugin()); + /** + * The enchantment level options being used. + */ + @Getter + private final NumbersOptions numbersOptions = new NumbersOptions(this.getPlugin()); + /** + * The shrink options being used. + */ + @Getter + private final ShrinkOptions shrinkOptions = new ShrinkOptions(this.getPlugin()); + /** + * The enchantment types, sorted according to config. + */ + @Getter + private final List sortedTypes = new ArrayList<>(); + /** + * The enchantment rarities, sorted according to config. + */ + @Getter + private final List sortedRarities = new ArrayList<>(); + /** + * The enchantment sorter being used. + */ + @Getter + private EnchantmentSorter sorter; + /** + * Allow reading enchantments from lore-based plugins. + */ + @Getter + private boolean usingLoreGetter = false; + + /** + * Allow reading enchantments from lore-based plugins aggressively. + */ + @Getter + private boolean usingAggressiveLoreGetter = false; + + /** + * If the experimental hide fixer is being used. + */ + @Getter + private boolean usingExperimentalHideFixer = false; + + /** + * If the aggressive experimental hide fixer is being used. + */ + @Getter + private boolean usingAggressiveExperimentalHideFixer = false; + + /** + * If all items should have hide enchants removed. + */ + @Getter + private boolean usingForceHideFixer = false; + + /** + * If item must be a target. + */ + @Getter + private boolean requireTarget = true; + + /** + * Instantiate new display options. + * + * @param plugin EcoEnchants. + */ + @ApiStatus.Internal + public DisplayOptions(@NotNull final EcoPlugin plugin) { + super(plugin); + update(); + } + + /** + * Update all options. + */ + public void update() { + descriptionOptions.update(); + numbersOptions.update(); + shrinkOptions.update(); + + sortedTypes.clear(); + sortedTypes.addAll(this.getPlugin().getConfigYml().getStrings("lore.type-ordering").stream() + .map(typeName -> EnchantmentType.values().stream().filter(type -> type.getName().equalsIgnoreCase(typeName)).findFirst().orElse(null)) + .filter(Objects::nonNull) + .collect(Collectors.toList())); + sortedTypes.addAll(EnchantmentType.values().stream().filter(enchantmentType -> !sortedTypes.contains(enchantmentType)).collect(Collectors.toList())); + + sortedRarities.clear(); + sortedRarities.addAll(this.getPlugin().getConfigYml().getStrings("lore.rarity-ordering").stream() + .map(rarityName -> EnchantmentRarity.values().stream().filter(rarity -> rarity.getName().equalsIgnoreCase(rarityName)).findFirst().orElse(null)) + .filter(Objects::nonNull) + .collect(Collectors.toList())); + sortedRarities.addAll(EnchantmentRarity.values().stream().filter(enchantmentRarity -> !sortedRarities.contains(enchantmentRarity)).collect(Collectors.toList())); + + usingLoreGetter = this.getPlugin().getConfigYml().getBool("advanced.lore-getter.enabled"); + usingAggressiveLoreGetter = this.getPlugin().getConfigYml().getBool("advanced.lore-getter.aggressive"); + usingExperimentalHideFixer = this.getPlugin().getConfigYml().getBool("advanced.hide-fixer.enabled"); + usingAggressiveExperimentalHideFixer = this.getPlugin().getConfigYml().getBool("advanced.hide-fixer.aggressive"); + usingForceHideFixer = this.getPlugin().getConfigYml().getBool("advanced.hide-fixer.force"); + + requireTarget = this.getPlugin().getConfigYml().getBool("lore.require-target"); + + boolean byType = this.getPlugin().getConfigYml().getBool("lore.sort-by-type"); + boolean byLength = this.getPlugin().getConfigYml().getBool("lore.sort-by-length"); + boolean byRarity = this.getPlugin().getConfigYml().getBool("lore.sort-by-rarity"); + Set params = new HashSet<>(); + if (byType) { + params.add(SortParameters.TYPE); + } + if (byLength) { + params.add(SortParameters.LENGTH); + } + if (byRarity) { + params.add(SortParameters.RARITY); + } + + sorter = SorterManager.getSorter(params.toArray(new SortParameters[]{})); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/NumbersOptions.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/NumbersOptions.java new file mode 100644 index 00000000..227681f1 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/NumbersOptions.java @@ -0,0 +1,39 @@ +package com.willfp.ecoenchants.display.options; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import lombok.Getter; +import org.jetbrains.annotations.NotNull; + +public class NumbersOptions extends PluginDependent { + /** + * If numerals should be used. + *

+ * If false then numbers will be used instead. + */ + @Getter + private boolean useNumerals; + + /** + * The threshold above which numbers will be used instead. + */ + @Getter + private int threshold; + + /** + * Create new numbers options. + * + * @param plugin EcoEnchants. + */ + public NumbersOptions(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + /** + * Update the options. + */ + public void update() { + useNumerals = this.getPlugin().getConfigYml().getBool("lore.use-numerals"); + threshold = this.getPlugin().getConfigYml().getInt("lore.use-numbers-above-threshold"); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/ShrinkOptions.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/ShrinkOptions.java new file mode 100644 index 00000000..879b9e83 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/ShrinkOptions.java @@ -0,0 +1,44 @@ +package com.willfp.ecoenchants.display.options; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import lombok.Getter; +import org.jetbrains.annotations.NotNull; + +public class ShrinkOptions extends PluginDependent { + /** + * The threshold above which enchantments will be shrunk. + */ + @Getter + private int threshold; + + /** + * If shrinking is enabled. + */ + @Getter + private boolean enabled; + + /** + * The amount of enchantments to have per-line. + */ + @Getter + private int shrinkPerLine; + + /** + * Create new shrink options. + * + * @param plugin EcoEnchants. + */ + public ShrinkOptions(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + /** + * Update the options. + */ + public void update() { + threshold = this.getPlugin().getConfigYml().getInt("lore.shrink.after-lines"); + enabled = this.getPlugin().getConfigYml().getBool("lore.shrink.enabled"); + shrinkPerLine = this.getPlugin().getConfigYml().getInt("lore.shrink.maximum-per-line"); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/EnchantmentSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/EnchantmentSorter.java new file mode 100644 index 00000000..7a0a3a01 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/EnchantmentSorter.java @@ -0,0 +1,24 @@ +package com.willfp.ecoenchants.display.options.sorting; + +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public interface EnchantmentSorter { + /** + * Sort list of enchantments. + *

+ * All implementations must treat enchantments as final or effectively final. + * + * @param toSort The enchantments to sort. + */ + void sortEnchantments(@NotNull List toSort); + + /** + * Get the parameters that the sorter fulfills. + * + * @return Array of all parameters. + */ + SortParameters[] getParameters(); +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SortParameters.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SortParameters.java new file mode 100644 index 00000000..cd357891 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SortParameters.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.display.options.sorting; + +public enum SortParameters { + /** + * If the sorter should sort by type or if type should be ignored. + */ + TYPE, + + /** + * If the sorter should sort by rarity or if rarity should be ignored. + */ + RARITY, + + /** + * If the sorter should sort by length or alphabetically. + */ + LENGTH +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SorterManager.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SorterManager.java new file mode 100644 index 00000000..6b2478a3 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SorterManager.java @@ -0,0 +1,52 @@ +package com.willfp.ecoenchants.display.options.sorting; + +import com.willfp.ecoenchants.EcoEnchantsPlugin; +import com.willfp.ecoenchants.display.options.sorting.implementations.AlphabeticSorter; +import com.willfp.ecoenchants.display.options.sorting.implementations.LengthSorter; +import com.willfp.ecoenchants.display.options.sorting.implementations.RarityAlphabeticSorter; +import com.willfp.ecoenchants.display.options.sorting.implementations.RarityLengthSorter; +import com.willfp.ecoenchants.display.options.sorting.implementations.RarityTypeAlphabeticSorter; +import com.willfp.ecoenchants.display.options.sorting.implementations.RarityTypeLengthSorter; +import com.willfp.ecoenchants.display.options.sorting.implementations.TypeAlphabeticSorter; +import com.willfp.ecoenchants.display.options.sorting.implementations.TypeLengthSorter; +import lombok.experimental.UtilityClass; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +@UtilityClass +public class SorterManager { + /** + * All registered enchantment sorters. + */ + private static final Set REGISTERED = new HashSet<>(); + + static { + EcoEnchantsPlugin instance = EcoEnchantsPlugin.getInstance(); // Really dirty and janky. + REGISTERED.add(new AlphabeticSorter(instance)); + REGISTERED.add(new LengthSorter(instance)); + REGISTERED.add(new TypeAlphabeticSorter(instance)); + REGISTERED.add(new TypeLengthSorter(instance)); + REGISTERED.add(new RarityAlphabeticSorter(instance)); + REGISTERED.add(new RarityLengthSorter(instance)); + REGISTERED.add(new RarityTypeAlphabeticSorter(instance)); + REGISTERED.add(new RarityTypeLengthSorter(instance)); + } + + /** + * Get a sorter based off of parameters. + *

+ * Any combination of parameters is valid. + * + * @param parameters The parameters to find a sorter from. + * @return The matching sorter. + */ + public static EnchantmentSorter getSorter(@NotNull final SortParameters... parameters) { + return REGISTERED.stream() + .filter(enchantmentSorter -> Arrays.asList(enchantmentSorter.getParameters()).containsAll(Arrays.asList(parameters)) && enchantmentSorter.getParameters().length == parameters.length) + .findFirst() + .orElse(new AlphabeticSorter(EcoEnchantsPlugin.getInstance())); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/AlphabeticSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/AlphabeticSorter.java new file mode 100644 index 00000000..7e912849 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/AlphabeticSorter.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.display.options.sorting.implementations; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter; +import com.willfp.ecoenchants.display.options.sorting.SortParameters; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class AlphabeticSorter extends PluginDependent implements EnchantmentSorter { + /** + * Instantiate sorter. + * + * @param plugin Instance of EcoEnchants. + */ + public AlphabeticSorter(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void sortEnchantments(@NotNull final List toSort) { + toSort.sort(((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName()))); + } + + @Override + public SortParameters[] getParameters() { + return new SortParameters[0]; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/LengthSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/LengthSorter.java new file mode 100644 index 00000000..16578b3d --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/LengthSorter.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.display.options.sorting.implementations; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter; +import com.willfp.ecoenchants.display.options.sorting.SortParameters; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; + +import java.util.Comparator; +import java.util.List; + +public class LengthSorter extends PluginDependent implements EnchantmentSorter { + /** + * Instantiate sorter. + * + * @param plugin Instance of EcoEnchants. + */ + public LengthSorter(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void sortEnchantments(@NotNull final List toSort) { + toSort.sort(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length())); + } + + @Override + public SortParameters[] getParameters() { + return new SortParameters[]{SortParameters.LENGTH}; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityAlphabeticSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityAlphabeticSorter.java new file mode 100644 index 00000000..2d42e66a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityAlphabeticSorter.java @@ -0,0 +1,53 @@ +package com.willfp.ecoenchants.display.options.sorting.implementations; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.ecoenchants.display.EnchantDisplay; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter; +import com.willfp.ecoenchants.display.options.sorting.SortParameters; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +public class RarityAlphabeticSorter extends PluginDependent implements EnchantmentSorter { + /** + * Instantiate sorter. + * + * @param plugin Instance of EcoEnchants. + */ + public RarityAlphabeticSorter(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void sortEnchantments(@NotNull final List toSort) { + if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().isEmpty() + || ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().isEmpty()) { + ((EnchantDisplay) this.getPlugin().getDisplayModule()).update(); + } + + List sorted = new ArrayList<>(); + + ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().forEach(enchantmentRarity -> { + List rarityEnchants = new ArrayList<>(); + for (Enchantment enchantment : toSort) { + if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) { + rarityEnchants.add(enchantment); + } + } + rarityEnchants.sort((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName())); + sorted.addAll(rarityEnchants); + }); + + toSort.clear(); + toSort.addAll(sorted); + } + + @Override + public SortParameters[] getParameters() { + return new SortParameters[]{SortParameters.RARITY}; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityLengthSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityLengthSorter.java new file mode 100644 index 00000000..91d411fd --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityLengthSorter.java @@ -0,0 +1,53 @@ +package com.willfp.ecoenchants.display.options.sorting.implementations; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.ecoenchants.display.EnchantDisplay; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter; +import com.willfp.ecoenchants.display.options.sorting.SortParameters; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +public class RarityLengthSorter extends PluginDependent implements EnchantmentSorter { + /** + * Instantiate sorter. + * + * @param plugin Instance of EcoEnchants. + */ + public RarityLengthSorter(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void sortEnchantments(@NotNull final List toSort) { + if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().isEmpty() + || ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().isEmpty()) { + ((EnchantDisplay) this.getPlugin().getDisplayModule()).update(); + } + + List sorted = new ArrayList<>(); + ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().forEach(enchantmentRarity -> { + List rarityEnchants = new ArrayList<>(); + for (Enchantment enchantment : toSort) { + if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) { + rarityEnchants.add(enchantment); + } + } + rarityEnchants.sort(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length())); + sorted.addAll(rarityEnchants); + }); + + toSort.clear(); + toSort.addAll(sorted); + } + + @Override + public SortParameters[] getParameters() { + return new SortParameters[]{SortParameters.RARITY, SortParameters.LENGTH}; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeAlphabeticSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeAlphabeticSorter.java new file mode 100644 index 00000000..0fcd6f98 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeAlphabeticSorter.java @@ -0,0 +1,62 @@ +package com.willfp.ecoenchants.display.options.sorting.implementations; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.ecoenchants.display.EnchantDisplay; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter; +import com.willfp.ecoenchants.display.options.sorting.SortParameters; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +public class RarityTypeAlphabeticSorter extends PluginDependent implements EnchantmentSorter { + /** + * Instantiate sorter. + * + * @param plugin Instance of EcoEnchants. + */ + public RarityTypeAlphabeticSorter(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void sortEnchantments(@NotNull final List toSort) { + if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().isEmpty() + || ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().isEmpty()) { + ((EnchantDisplay) this.getPlugin().getDisplayModule()).update(); + } + + List sorted = new ArrayList<>(); + ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().forEach(enchantmentType -> { + List typeEnchants = new ArrayList<>(); + for (Enchantment enchantment : toSort) { + if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) { + typeEnchants.add(enchantment); + } + } + typeEnchants.sort((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName())); + + ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().forEach(enchantmentRarity -> { + List rarityEnchants = new ArrayList<>(); + for (Enchantment enchantment : typeEnchants) { + if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) { + rarityEnchants.add(enchantment); + } + } + rarityEnchants.sort((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName())); + sorted.addAll(rarityEnchants); + }); + }); + + toSort.clear(); + toSort.addAll(sorted); + } + + @Override + public SortParameters[] getParameters() { + return new SortParameters[]{SortParameters.RARITY, SortParameters.TYPE}; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeLengthSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeLengthSorter.java new file mode 100644 index 00000000..256e1562 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeLengthSorter.java @@ -0,0 +1,64 @@ +package com.willfp.ecoenchants.display.options.sorting.implementations; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.ecoenchants.display.EnchantDisplay; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter; +import com.willfp.ecoenchants.display.options.sorting.SortParameters; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +public class RarityTypeLengthSorter extends PluginDependent implements EnchantmentSorter { + /** + * Instantiate sorter. + * + * @param plugin Instance of EcoEnchants. + */ + public RarityTypeLengthSorter(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void sortEnchantments(@NotNull final List toSort) { + if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().isEmpty() + || ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().isEmpty()) { + ((EnchantDisplay) this.getPlugin().getDisplayModule()).update(); + } + + List sorted = new ArrayList<>(); + ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().forEach(enchantmentType -> { + List typeEnchants = new ArrayList<>(); + for (Enchantment enchantment : toSort) { + if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) { + typeEnchants.add(enchantment); + } + } + + typeEnchants.sort(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length())); + + ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().forEach(enchantmentRarity -> { + List rarityEnchants = new ArrayList<>(); + for (Enchantment enchantment : typeEnchants) { + if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) { + rarityEnchants.add(enchantment); + } + } + rarityEnchants.sort(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length())); + sorted.addAll(rarityEnchants); + }); + }); + + toSort.clear(); + toSort.addAll(sorted); + } + + @Override + public SortParameters[] getParameters() { + return new SortParameters[]{SortParameters.RARITY, SortParameters.TYPE, SortParameters.LENGTH}; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeAlphabeticSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeAlphabeticSorter.java new file mode 100644 index 00000000..08d9ba21 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeAlphabeticSorter.java @@ -0,0 +1,53 @@ +package com.willfp.ecoenchants.display.options.sorting.implementations; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.ecoenchants.display.EnchantDisplay; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter; +import com.willfp.ecoenchants.display.options.sorting.SortParameters; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +public class TypeAlphabeticSorter extends PluginDependent implements EnchantmentSorter { + /** + * Instantiate sorter. + * + * @param plugin Instance of EcoEnchants. + */ + public TypeAlphabeticSorter(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void sortEnchantments(@NotNull final List toSort) { + if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().isEmpty() + || ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().isEmpty()) { + ((EnchantDisplay) this.getPlugin().getDisplayModule()).update(); + } + + List sorted = new ArrayList<>(); + ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().forEach(enchantmentType -> { + List typeEnchants = new ArrayList<>(); + for (Enchantment enchantment : toSort) { + if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) { + typeEnchants.add(enchantment); + } + } + + typeEnchants.sort((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName())); + sorted.addAll(typeEnchants); + }); + + toSort.clear(); + toSort.addAll(sorted); + } + + @Override + public SortParameters[] getParameters() { + return new SortParameters[]{SortParameters.TYPE}; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeLengthSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeLengthSorter.java new file mode 100644 index 00000000..126c87e2 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeLengthSorter.java @@ -0,0 +1,52 @@ +package com.willfp.ecoenchants.display.options.sorting.implementations; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.ecoenchants.display.EnchantDisplay; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter; +import com.willfp.ecoenchants.display.options.sorting.SortParameters; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +public class TypeLengthSorter extends PluginDependent implements EnchantmentSorter { + /** + * Instantiate sorter. + * + * @param plugin Instance of EcoEnchants. + */ + public TypeLengthSorter(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void sortEnchantments(@NotNull final List toSort) { + if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().isEmpty() + || ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().isEmpty()) { + ((EnchantDisplay) this.getPlugin().getDisplayModule()).update(); + } + + List sorted = new ArrayList<>(); + ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().forEach(enchantmentType -> { + List typeEnchants = new ArrayList<>(); + for (Enchantment enchantment : toSort) { + if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) { + typeEnchants.add(enchantment); + } + } + + sorted.addAll(typeEnchants); + }); + + toSort.clear(); + toSort.addAll(sorted); + } + + @Override + public SortParameters[] getParameters() { + return new SortParameters[]{SortParameters.TYPE, SortParameters.LENGTH}; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java new file mode 100644 index 00000000..e545369a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java @@ -0,0 +1,367 @@ +package com.willfp.ecoenchants.enchantments; + +import com.willfp.eco.core.Prerequisite; +import com.willfp.eco.util.StringUtils; +import com.willfp.ecoenchants.EcoEnchantsPlugin; +import com.willfp.ecoenchants.config.configs.EnchantmentConfig; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import com.willfp.ecoenchants.enchantments.util.Watcher; +import lombok.AccessLevel; +import lombok.Getter; +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.WordUtils; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.World; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; +import org.jetbrains.annotations.NotNull; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +@SuppressWarnings({"unchecked", "deprecation", "RedundantSuppression"}) +public abstract class EcoEnchant extends Enchantment implements Listener, Watcher { + /** + * Instance of EcoEnchants for enchantments to be able to access. + */ + @Getter(AccessLevel.PROTECTED) + private final EcoEnchantsPlugin plugin = EcoEnchantsPlugin.getInstance(); + /** + * The permission/config name of the enchantment. + */ + @Getter + private final String permissionName; + /** + * The type of the enchantment. + */ + @Getter + private final EnchantmentType type; + /** + * The enchantment's config. + */ + @Getter + private final EnchantmentConfig config; + /** + * The targets of the enchantment. + */ + @Getter + private final Set targets = new HashSet<>(); + /** + * The materials of the targets. + */ + @Getter + private final Set targetMaterials = new HashSet<>(); + /** + * The names of the worlds that this enchantment is disabled in. + */ + @Getter + private final Set disabledWorldNames = new HashSet<>(); + /** + * The worlds that this enchantment is disabled in. + */ + @Getter + private final List disabledWorlds = new ArrayList<>(); + /** + * The display name of the enchantment. + */ + private String name; + /** + * The description of the enchantment. + */ + @Getter + private String description; + /** + * If the enchantment can be removed in a grindstone. + */ + @Getter + private boolean grindstoneable; + /** + * If the enchantment can be obtained from an enchanting table. + */ + @Getter + private boolean availableFromTable; + /** + * If the enchantment can be obtained from a villager. + */ + @Getter + private boolean availableFromVillager; + /** + * If the enchantment can be obtained from a loot chest. + */ + @Getter + private boolean availableFromLoot; + /** + * The maximum level for the enchantment to be obtained naturally. + */ + private int maxLevel; + /** + * The enchantments that conflict with this enchantment. + */ + @Getter + private Set conflicts; + /** + * The rarity of the enchantment. + */ + @Getter + private EnchantmentRarity rarity; + /** + * If the enchantment is enabled. + */ + @Getter + private boolean enabled; + + /** + * Create a new EcoEnchant. + * + * @param key The key name of the enchantment + * @param type The type of the enchantment + * @param prerequisites Optional {@link Prerequisite}s that must be met + */ + protected EcoEnchant(@NotNull final String key, + @NotNull final EnchantmentType type, + @NotNull final Prerequisite... prerequisites) { + super(NamespacedKey.minecraft(key)); + + this.type = type; + this.permissionName = key.replace("_", ""); + this.config = new EnchantmentConfig(this.permissionName, this.getClass(), this.type); + + if (Bukkit.getPluginManager().getPermission("ecoenchants.fromtable." + permissionName) == null) { + Permission permission = new Permission( + "ecoenchants.fromtable." + permissionName, + "Allows getting " + permissionName + " from an Enchanting Table", + PermissionDefault.TRUE + ); + permission.addParent(Objects.requireNonNull(Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.*")), true); + Bukkit.getPluginManager().addPermission(permission); + } + + if (type.getRequiredToExtend() != null && !type.getRequiredToExtend().isInstance(this)) { + return; + } + + if (!Prerequisite.areMet(prerequisites)) { + return; + } + + enabled = config.getBool("enabled"); + + if (!this.isEnabled() && this.getPlugin().getConfigYml().getBool("advanced.hard-disable.enabled")) { + return; + } + + this.update(); + + EcoEnchants.addNewEcoEnchant(this); + } + + /** + * Update the enchantment based off config values. + * This can be overridden but may lead to unexpected behavior. + */ + public void update() { + config.update(); + config.loadFromLang(); + rarity = config.getRarity(); + Validate.notNull(rarity, "Rarity specified in " + this.permissionName + " is invalid!"); + conflicts = config.getEnchantments(EcoEnchants.GENERAL_LOCATION + "conflicts"); + grindstoneable = config.getBool(EcoEnchants.GENERAL_LOCATION + "grindstoneable"); + availableFromTable = config.getBool(EcoEnchants.OBTAINING_LOCATION + "table"); + availableFromVillager = config.getBool(EcoEnchants.OBTAINING_LOCATION + "villager"); + availableFromLoot = config.getBool(EcoEnchants.OBTAINING_LOCATION + "loot"); + maxLevel = config.getInt(EcoEnchants.GENERAL_LOCATION + "maximum-level", 1); + name = StringUtils.translate(config.getString("name")); + description = StringUtils.translate(config.getString("description")); + disabledWorldNames.clear(); + disabledWorldNames.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "disabled-in-worlds")); + disabledWorlds.clear(); + List worldNames = Bukkit.getWorlds().stream().map(World::getName).map(String::toLowerCase).collect(Collectors.toList()); + List disabledExistingWorldNames = disabledWorldNames.stream().filter(s -> worldNames.contains(s.toLowerCase())).collect(Collectors.toList()); + disabledWorlds.addAll(Bukkit.getWorlds().stream().filter(world -> disabledExistingWorldNames.contains(world.getName().toLowerCase())).collect(Collectors.toList())); + targets.clear(); + targetMaterials.clear(); + targets.addAll(config.getTargets()); + targets.forEach(enchantmentTarget -> targetMaterials.addAll(enchantmentTarget.getMaterials())); + enabled = config.getBool("enabled"); + EnchantmentUtils.registerPlaceholders(this); + + postUpdate(); + this.register(); + } + + protected void postUpdate() { + // Unused as some enchantments may have postUpdate tasks, however most won't. + } + + /** + * Register the enchantment with spigot. + * Only used internally. + */ + public void register() { + try { + Field byIdField = Enchantment.class.getDeclaredField("byKey"); + Field byNameField = Enchantment.class.getDeclaredField("byName"); + byIdField.setAccessible(true); + byNameField.setAccessible(true); + Map byKey = (Map) byIdField.get(null); + Map byName = (Map) byNameField.get(null); + byKey.remove(this.getKey()); + byName.remove(this.getName()); + + Map byNameClone = new HashMap<>(byName); + for (Map.Entry entry : byNameClone.entrySet()) { + if (entry.getValue().getKey().equals(this.getKey())) { + byName.remove(entry.getKey()); + } + } + + Field f = Enchantment.class.getDeclaredField("acceptingNew"); + f.setAccessible(true); + f.set(null, true); + f.setAccessible(false); + + Enchantment.registerEnchantment(this); + } catch (NoSuchFieldException | IllegalAccessException ignored) { + } + } + + /** + * Get description of enchantment line-wrapped. + * + * @return The description. + */ + public List getWrappedDescription() { + return Arrays.asList(WordUtils.wrap(description, this.getPlugin().getConfigYml().getInt("lore.describe.wrap"), "\n", false).split("\\r?\\n")); + } + + /** + * If enchantment conflicts with any enchantment in collection. + * + * @param enchantments The collection to test against. + * @return If there are any conflicts. + */ + public boolean conflictsWithAny(@NotNull final Collection enchantments) { + return conflicts.stream().anyMatch(enchantments::contains); + } + + /** + * Get enchantment cast to {@link Enchantment}. + * + * @return The enchantment. + */ + public Enchantment getEnchantment() { + return this; + } + + /** + * Get the display name of the enchantment. + *

+ * Not deprecated, unlike superclass. + * + * @return The name. + */ + @Override + @NotNull + public String getName() { + return name; + } + + /** + * Get max level of enchantment. + * + * @return The max level. + */ + @Override + public int getMaxLevel() { + return maxLevel; + } + + /** + * @return 1 + */ + @Override + public int getStartLevel() { + return 1; + } + + /** + * Do not use this method. + * Only here for compatibility with {@link Enchantment}. + * + * @return Returns {@link EnchantmentTarget#ALL}. Do not use. + * @deprecated {@link EnchantmentTarget} is not supported due to its lack of flexibility. Use {@link EcoEnchant#getTargets()} instead. + */ + @Override + @Deprecated + public @NotNull org.bukkit.enchantments.EnchantmentTarget getItemTarget() { + return org.bukkit.enchantments.EnchantmentTarget.ALL; + } + + /** + * Treasure enchantments do not exist in EcoEnchants. + * + * @return false. + * @see EnchantmentType#SPECIAL + * @deprecated Treasure enchantments do not exist. Use {@link EcoEnchant#getType()} instead. + */ + @Override + @Deprecated + public boolean isTreasure() { + return false; + } + + /** + * While this method works, it is not recommended to use it. + * + * @return Returns if enchantment is cursed. + * @see EnchantmentType#CURSE + * @deprecated Use {@link EcoEnchant#getType()} instead. + */ + @Override + @Deprecated + public boolean isCursed() { + return this.type.equals(EnchantmentType.CURSE); + } + + /** + * Get if enchantment conflicts with specified enchantment. + * + * @param enchantment The enchantment to test against. + * @return If conflicts. + */ + @Override + public boolean conflictsWith(@NotNull final Enchantment enchantment) { + if (enchantment instanceof EcoEnchant) { + return conflicts.contains(enchantment) || ((EcoEnchant) enchantment).conflicts.contains(this); + } + return conflicts.contains(enchantment); + } + + /** + * If enchantment can be applied to item. + * + * @param itemStack The {@link ItemStack} to test against. + * @return If can be applied. + */ + @Override + public boolean canEnchantItem(@NotNull final ItemStack itemStack) { + return targetMaterials.contains(itemStack.getType()) || itemStack.getType().equals(Material.BOOK) || itemStack.getType().equals(Material.ENCHANTED_BOOK); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java new file mode 100644 index 00000000..1f3ca5e2 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java @@ -0,0 +1,605 @@ +package com.willfp.ecoenchants.enchantments; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.ImmutableList; +import com.willfp.eco.core.config.ConfigUpdater; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.AngerArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.AshArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.BarrierArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.CloudsArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.CrimsonArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.DamageArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.DragonArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.DustArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.EmeraldArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.EnchantmentArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.EndArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.FireArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.HeartArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.HoneyArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.InkArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.LavaArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.LimeArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.MagicArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.MagmaArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.MusicArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.NautilusArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.NetherArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.RedstoneArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SmokeArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SnowArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SoulArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SoulFireArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SparkleArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SweepArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.TearArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.TotemArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.VillagerArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.WarpedArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.WaterArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.WitchArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.ZapArtifact; +import com.willfp.ecoenchants.enchantments.ecoenchants.curse.BreaklessnessCurse; +import com.willfp.ecoenchants.enchantments.ecoenchants.curse.CallingCurse; +import com.willfp.ecoenchants.enchantments.ecoenchants.curse.DecayCurse; +import com.willfp.ecoenchants.enchantments.ecoenchants.curse.FragilityCurse; +import com.willfp.ecoenchants.enchantments.ecoenchants.curse.HarmlessnessCurse; +import com.willfp.ecoenchants.enchantments.ecoenchants.curse.HungerCurse; +import com.willfp.ecoenchants.enchantments.ecoenchants.curse.InaccuracyCurse; +import com.willfp.ecoenchants.enchantments.ecoenchants.curse.MisfortuneCurse; +import com.willfp.ecoenchants.enchantments.ecoenchants.curse.PermanenceCurse; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Abattoir; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Abrasion; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Aerial; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Aquatic; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Arachnid; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Arborist; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Arcanic; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Atmospheric; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Aversion; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Backstab; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Beheading; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.BlastMining; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Bleed; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Blind; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.BlockBreather; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.BossHunter; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Buckshot; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Butchering; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Cerebral; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Chopless; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Cleave; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Collateral; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Conclude; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Corrosive; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Cranial; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Criticals; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Cubism; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Defender; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Deflection; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Defusion; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Dexterous; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Disable; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Disappear; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Diurnal; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Diverse; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Drill; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Dullness; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Dweller; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Economical; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Electroshock; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.EndInfusion; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.EnderSlayer; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Enderism; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Evasion; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Extinguishing; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Extract; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Famine; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Farmhand; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Fetching; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Finality; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Finishing; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.FireAffinity; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.FirstStrike; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Flinch; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Forcefield; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Freerunner; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Frozen; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Fury; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Goliath; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Graceful; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Grapple; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.GreenThumb; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Grit; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Hellish; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Hook; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Horde; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.IceShot; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Identify; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Ignite; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.IllusionAspect; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Impact; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Incandescence; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.InfernalTouch; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Inferno; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Infuriate; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Insecticide; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Instantaneous; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Introversion; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Invigoration; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Kinetic; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Launch; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Leeching; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Lesion; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Levitate; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.LiquidShot; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.LuckyCatch; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Lumberjack; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.MagmaWalker; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Magnetic; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Marking; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Marksman; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Necrotic; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.NetherInfusion; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Netheric; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Nocturnal; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Optics; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Oxygenate; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Pacify; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Paladin; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Paralyze; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Parasitic; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Parry; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Phantasm; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Plasmic; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Protector; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Proximity; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Puncture; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Quadrilateralism; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Radiance; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Rage; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Rapid; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Reaper; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Rebounding; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Reel; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Reinforcement; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Rejuvenation; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Replenish; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Respirator; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Revenant; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Sating; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Serrated; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Settle; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Shockwave; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.ShotAssist; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Sickening; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Slaughter; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Slicing; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Spearfishing; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Spiked; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Splash; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Stab; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Stalwart; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Stamina; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.StoneSwitcher; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.StrayAspect; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Succession; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Supercritical; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Sycophant; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Tectonic; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Telekinesis; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Thor; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Thrive; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Tornado; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Toxic; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Transfuse; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Tripleshot; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.VampireAspect; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Vein; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Venom; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.VoidAffinity; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Voltage; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.WaterAffinity; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.WaterAspect; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Weakening; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Wisdom; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.WoodSwitcher; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Wound; +import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Zeus; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Aiming; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Annihilate; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Bladed; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Bolt; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Carve; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Confusion; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Energizing; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Force; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Frenzy; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Harpoon; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Indestructibility; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Instability; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Intellect; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.LifeSteal; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Pentashot; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Preservation; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Prosperity; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Razor; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Repairing; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Soulbound; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Spring; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Streamlining; +import com.willfp.ecoenchants.enchantments.ecoenchants.special.Volatile; +import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Ascend; +import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Charge; +import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Dynamite; +import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Missile; +import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Quake; +import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Vitalize; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import lombok.experimental.UtilityClass; +import org.bukkit.NamespacedKey; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicBoolean; + +@UtilityClass +@SuppressWarnings({"unused", "checkstyle:JavadocVariable"}) +public class EcoEnchants { + public static final String CONFIG_LOCATION = "config."; + public static final String OBTAINING_LOCATION = "obtaining."; + public static final String GENERAL_LOCATION = "general-config."; + + private static final BiMap BY_KEY = HashBiMap.create(); + private static final BiMap BY_NAME = HashBiMap.create(); + + public static final EcoEnchant TELEKINESIS = new Telekinesis(); + public static final EcoEnchant MARKSMAN = new Marksman(); + public static final EcoEnchant INFERNAL_TOUCH = new InfernalTouch(); + public static final EcoEnchant SPRING = new Spring(); + public static final EcoEnchant STRAY_ASPECT = new StrayAspect(); + public static final EcoEnchant ILLUSION_ASPECT = new IllusionAspect(); + public static final EcoEnchant SLICING = new Slicing(); + public static final EcoEnchant DEXTEROUS = new Dexterous(); + public static final EcoEnchant BEHEADING = new Beheading(); + public static final EcoEnchant NECROTIC = new Necrotic(); + public static final EcoEnchant MAGMA_WALKER = new MagmaWalker(); + public static final EcoEnchant TECTONIC = new Tectonic(); + public static final EcoEnchant EVASION = new Evasion(); + public static final EcoEnchant SUCCESSION = new Succession(); + public static final EcoEnchant FARMHAND = new Farmhand(); + public static final EcoEnchant WISDOM = new Wisdom(); + public static final EcoEnchant LEECHING = new Leeching(); + public static final EcoEnchant VAMPIRE_ASPECT = new VampireAspect(); + public static final EcoEnchant INSTABILITY = new Instability(); + public static final EcoEnchant THRIVE = new Thrive(); + public static final EcoEnchant DRILL = new Drill(); + public static final EcoEnchant THOR = new Thor(); + public static final EcoEnchant STREAMLINING = new Streamlining(); + public static final EcoEnchant FIRST_STRIKE = new FirstStrike(); + public static final EcoEnchant FINISHING = new Finishing(); + public static final EcoEnchant CRITICALS = new Criticals(); + public static final EcoEnchant INCANDESCENCE = new Incandescence(); + public static final EcoEnchant SUPERCRITICAL = new Supercritical(); + public static final EcoEnchant ABRASION = new Abrasion(); + public static final EcoEnchant SPLASH = new Splash(); + public static final EcoEnchant EXTINGUISHING = new Extinguishing(); + public static final EcoEnchant GOLIATH = new Goliath(); + public static final EcoEnchant OPTICS = new Optics(); + public static final EcoEnchant DEFUSION = new Defusion(); + public static final EcoEnchant CEREBRAL = new Cerebral(); + public static final EcoEnchant GRIT = new Grit(); + public static final EcoEnchant BOSS_HUNTER = new BossHunter(); + public static final EcoEnchant INVIGORATION = new Invigoration(); + public static final EcoEnchant REJUVENATION = new Rejuvenation(); + public static final EcoEnchant FRAGILITY_CURSE = new FragilityCurse(); + public static final EcoEnchant TRIPLESHOT = new Tripleshot(); + public static final EcoEnchant RAPID = new Rapid(); + public static final EcoEnchant SATING = new Sating(); + public static final EcoEnchant REINFORCEMENT = new Reinforcement(); + public static final EcoEnchant SOULBOUND = new Soulbound(); + public static final EcoEnchant RAZOR = new Razor(); + public static final EcoEnchant PROSPERITY = new Prosperity(); + public static final EcoEnchant PRESERVATION = new Preservation(); + public static final EcoEnchant FRENZY = new Frenzy(); + public static final EcoEnchant BUTCHERING = new Butchering(); + public static final EcoEnchant PROXIMITY = new Proximity(); + public static final EcoEnchant ENDER_SLAYER = new EnderSlayer(); + public static final EcoEnchant PROTECTOR = new Protector(); + public static final EcoEnchant INDESTRUCTIBILITY = new Indestructibility(); + public static final EcoEnchant ENERGIZING = new Energizing(); + public static final EcoEnchant INTELLECT = new Intellect(); + public static final EcoEnchant DEFLECTION = new Deflection(); + public static final EcoEnchant LAUNCH = new Launch(); + public static final EcoEnchant PERMANENCE_CURSE = new PermanenceCurse(); + public static final EcoEnchant SPEARFISHING = new Spearfishing(); + public static final EcoEnchant NETHER_INFUSION = new NetherInfusion(); + public static final EcoEnchant REPLENISH = new Replenish(); + public static final EcoEnchant FLINCH = new Flinch(); + public static final EcoEnchant ELECTROSHOCK = new Electroshock(); + public static final EcoEnchant NOCTURNAL = new Nocturnal(); + public static final EcoEnchant CONFUSION = new Confusion(); + public static final EcoEnchant ARCANIC = new Arcanic(); + public static final EcoEnchant PENTASHOT = new Pentashot(); + public static final EcoEnchant LUMBERJACK = new Lumberjack(); + public static final EcoEnchant STONE_SWITCHER = new StoneSwitcher(); + public static final EcoEnchant MAGNETIC = new Magnetic(); + public static final EcoEnchant REPAIRING = new Repairing(); + public static final EcoEnchant CALLING_CURSE = new CallingCurse(); + public static final EcoEnchant BLAST_MINING = new BlastMining(); + public static final EcoEnchant LIQUID_SHOT = new LiquidShot(); + public static final EcoEnchant GRAPPLE = new Grapple(); + public static final EcoEnchant HEART_ARTIFACT = new HeartArtifact(); + public static final EcoEnchant SPARKLE_ARTIFACT = new SparkleArtifact(); + public static final EcoEnchant LAVA_ARTIFACT = new LavaArtifact(); + public static final EcoEnchant DRAGON_ARTIFACT = new DragonArtifact(); + public static final EcoEnchant ENCHANTMENT_ARTIFACT = new EnchantmentArtifact(); + public static final EcoEnchant SMOKE_ARTIFACT = new SmokeArtifact(); + public static final EcoEnchant FIRE_ARTIFACT = new FireArtifact(); + public static final EcoEnchant EMERALD_ARTIFACT = new EmeraldArtifact(); + public static final EcoEnchant NETHER_ARTIFACT = new NetherArtifact(); + public static final EcoEnchant END_ARTIFACT = new EndArtifact(); + public static final EcoEnchant WATER_ARTIFACT = new WaterArtifact(); + public static final EcoEnchant TOTEM_ARTIFACT = new TotemArtifact(); + public static final EcoEnchant REDSTONE_ARTIFACT = new RedstoneArtifact(); + public static final EcoEnchant ZAP_ARTIFACT = new ZapArtifact(); + public static final EcoEnchant MUSIC_ARTIFACT = new MusicArtifact(); + public static final EcoEnchant SNOW_ARTIFACT = new SnowArtifact(); + public static final EcoEnchant WITCH_ARTIFACT = new WitchArtifact(); + public static final EcoEnchant HONEY_ARTIFACT = new HoneyArtifact(); + public static final EcoEnchant DAMAGE_ARTIFACT = new DamageArtifact(); + public static final EcoEnchant CLOUDS_ARTIFACT = new CloudsArtifact(); + public static final EcoEnchant MAGIC_ARTIFACT = new MagicArtifact(); + public static final EcoEnchant DUST_ARTIFACT = new DustArtifact(); + public static final EcoEnchant MAGMA_ARTIFACT = new MagmaArtifact(); + public static final EcoEnchant INK_ARTIFACT = new InkArtifact(); + public static final EcoEnchant ZEUS = new Zeus(); + public static final EcoEnchant KINETIC = new Kinetic(); + public static final EcoEnchant FIRE_AFFINITY = new FireAffinity(); + public static final EcoEnchant PARASITIC = new Parasitic(); + public static final EcoEnchant PARRY = new Parry(); + public static final EcoEnchant AIMING = new Aiming(); + public static final EcoEnchant HOOK = new Hook(); + public static final EcoEnchant BLEED = new Bleed(); + public static final EcoEnchant WEAKENING = new Weakening(); + public static final EcoEnchant OXYGENATE = new Oxygenate(); + public static final EcoEnchant WATER_ASPECT = new WaterAspect(); + public static final EcoEnchant STAMINA = new Stamina(); + public static final EcoEnchant COLLATERAL = new Collateral(); + public static final EcoEnchant HUNGER_CURSE = new HungerCurse(); + public static final EcoEnchant PALADIN = new Paladin(); + public static final EcoEnchant SERRATED = new Serrated(); + public static final EcoEnchant BLADED = new Bladed(); + public static final EcoEnchant INFERNO = new Inferno(); + public static final EcoEnchant STAB = new Stab(); + public static final EcoEnchant TORNADO = new Tornado(); + public static final EcoEnchant EXTRACT = new Extract(); + public static final EcoEnchant AERIAL = new Aerial(); + public static final EcoEnchant FAMINE = new Famine(); + public static final EcoEnchant ANNIHILATE = new Annihilate(); + public static final EcoEnchant RADIANCE = new Radiance(); + public static final EcoEnchant HORDE = new Horde(); + public static final EcoEnchant VEIN = new Vein(); + public static final EcoEnchant ICE_SHOT = new IceShot(); + public static final EcoEnchant PUNCTURE = new Puncture(); + public static final EcoEnchant SHOCKWAVE = new Shockwave(); + public static final EcoEnchant VOLATILE = new Volatile(); + public static final EcoEnchant INSTANTANEOUS = new Instantaneous(); + public static final EcoEnchant FREERUNNER = new Freerunner(); + public static final EcoEnchant BOLT = new Bolt(); + public static final EcoEnchant DULLNESS = new Dullness(); + public static final EcoEnchant IGNITE = new Ignite(); + public static final EcoEnchant CLEAVE = new Cleave(); + public static final EcoEnchant CARVE = new Carve(); + public static final EcoEnchant TOXIC = new Toxic(); + public static final EcoEnchant WATER_AFFINITY = new WaterAffinity(); + public static final EcoEnchant FORCEFIELD = new Forcefield(); + public static final EcoEnchant SYCOPHANT = new Sycophant(); + public static final EcoEnchant CHOPLESS = new Chopless(); + public static final EcoEnchant GREEN_THUMB = new GreenThumb(); + public static final EcoEnchant SPIKED = new Spiked(); + public static final EcoEnchant HARPOON = new Harpoon(); + public static final EcoEnchant REEL = new Reel(); + public static final EcoEnchant SHOT_ASSIST = new ShotAssist(); + public static final EcoEnchant FROZEN = new Frozen(); + public static final EcoEnchant DISAPPEAR = new Disappear(); + public static final EcoEnchant HARMLESSNESS_CURSE = new HarmlessnessCurse(); + public static final EcoEnchant FURY = new Fury(); + public static final EcoEnchant LEVITATE = new Levitate(); + public static final EcoEnchant BREAKLESSNESS_CURSE = new BreaklessnessCurse(); + public static final EcoEnchant DECAY_CURSE = new DecayCurse(); + public static final EcoEnchant MISFORTUNE_CURSE = new MisfortuneCurse(); + public static final EcoEnchant VENOM = new Venom(); + public static final EcoEnchant CRANIAL = new Cranial(); + public static final EcoEnchant AQUATIC = new Aquatic(); + public static final EcoEnchant BUCKSHOT = new Buckshot(); + public static final EcoEnchant DIVERSE = new Diverse(); + public static final EcoEnchant LIFE_STEAL = new LifeSteal(); + public static final EcoEnchant LIME_ARTIFACT = new LimeArtifact(); + public static final EcoEnchant FORCE = new Force(); + public static final EcoEnchant END_INFUSION = new EndInfusion(); + public static final EcoEnchant DIURNAL = new Diurnal(); + public static final EcoEnchant MARKING = new Marking(); + public static final EcoEnchant CORROSIVE = new Corrosive(); + public static final EcoEnchant WOUND = new Wound(); + public static final EcoEnchant FINALITY = new Finality(); + public static final EcoEnchant BLIND = new Blind(); + public static final EcoEnchant SICKENING = new Sickening(); + public static final EcoEnchant DEFENDER = new Defender(); + public static final EcoEnchant NETHERIC = new Netheric(); + public static final EcoEnchant ENDERISM = new Enderism(); + public static final EcoEnchant RAGE = new Rage(); + public static final EcoEnchant IMPACT = new Impact(); + public static final EcoEnchant PARALYZE = new Paralyze(); + public static final EcoEnchant IDENTIFY = new Identify(); + public static final EcoEnchant INFURIATE = new Infuriate(); + public static final EcoEnchant ATMOSPHERIC = new Atmospheric(); + public static final EcoEnchant REVENANT = new Revenant(); + public static final EcoEnchant INSECTICIDE = new Insecticide(); + public static final EcoEnchant SLAUGHTER = new Slaughter(); + public static final EcoEnchant SETTLE = new Settle(); + public static final EcoEnchant PHANTASM = new Phantasm(); + public static final EcoEnchant ARACHNID = new Arachnid(); + public static final EcoEnchant PACIFY = new Pacify(); + public static final EcoEnchant ABATTOIR = new Abattoir(); + public static final EcoEnchant DISABLE = new Disable(); + public static final EcoEnchant HELLISH = new Hellish(); + public static final EcoEnchant VOID_AFFINITY = new VoidAffinity(); + public static final EcoEnchant CUBISM = new Cubism(); + public static final EcoEnchant QUADRILATERALISM = new Quadrilateralism(); + public static final EcoEnchant LESION = new Lesion(); + public static final EcoEnchant CONCLUDE = new Conclude(); + public static final EcoEnchant GRACEFUL = new Graceful(); + public static final EcoEnchant BLOCK_BREATHER = new BlockBreather(); + public static final EcoEnchant VOLTAGE = new Voltage(); + public static final EcoEnchant TRANSFUSE = new Transfuse(); + public static final EcoEnchant INACCURACY_CURSE = new InaccuracyCurse(); + public static final EcoEnchant RESPIRATOR = new Respirator(); + public static final EcoEnchant FETCHING = new Fetching(); + public static final EcoEnchant ECONOMICAL = new Economical(); + public static final EcoEnchant SOUL_ARTIFACT = new SoulArtifact(); + public static final EcoEnchant SOUL_FIRE_ARTIFACT = new SoulFireArtifact(); + public static final EcoEnchant CRIMSON_ARTIFACT = new CrimsonArtifact(); + public static final EcoEnchant ASH_ARTIFACT = new AshArtifact(); + public static final EcoEnchant WARPED_ARTIFACT = new WarpedArtifact(); + public static final EcoEnchant TEAR_ARTIFACT = new TearArtifact(); + public static final EcoEnchant BACKSTAB = new Backstab(); + public static final EcoEnchant DWELLER = new Dweller(); + public static final EcoEnchant STALWART = new Stalwart(); + public static final EcoEnchant PLASMIC = new Plasmic(); + public static final EcoEnchant MISSILE = new Missile(); + public static final EcoEnchant QUAKE = new Quake(); + public static final EcoEnchant VITALIZE = new Vitalize(); + public static final EcoEnchant DYNAMITE = new Dynamite(); + public static final EcoEnchant CHARGE = new Charge(); + public static final EcoEnchant ASCEND = new Ascend(); + public static final EcoEnchant ARBORIST = new Arborist(); + public static final EcoEnchant LUCKY_CATCH = new LuckyCatch(); + public static final EcoEnchant AVERSION = new Aversion(); + public static final EcoEnchant INTROVERSION = new Introversion(); + public static final EcoEnchant BARRIER_ARTIFACT = new BarrierArtifact(); + public static final EcoEnchant VILLAGER_ARTIFACT = new VillagerArtifact(); + public static final EcoEnchant ANGER_ARTIFACT = new AngerArtifact(); + public static final EcoEnchant NAUTILUS_ARTIFACT = new NautilusArtifact(); + public static final EcoEnchant SWEEP_ARTIFACT = new SweepArtifact(); + public static final EcoEnchant REAPER = new Reaper(); + public static final EcoEnchant WOOD_SWITCHER = new WoodSwitcher(); + public static final EcoEnchant REBOUNDING = new Rebounding(); + + /** + * Get all registered {@link EcoEnchant}s. + * + * @return A list of all {@link EcoEnchant}s. + */ + public static List values() { + return ImmutableList.copyOf(BY_KEY.values()); + } + + /** + * Gets {@link EcoEnchant} from {@link Enchantment}. + * + * @param enchantment The enchantment. + * @return The matching {@link EcoEnchant}, or null if not found. + */ + public static EcoEnchant getFromEnchantment(@NotNull final Enchantment enchantment) { + return getByKey(enchantment.getKey()); + } + + /** + * Get {@link EcoEnchant} matching display name. + * + * @param name The display name to search for. + * @return The matching {@link EcoEnchant}, or null if not found. + */ + public static EcoEnchant getByName(@NotNull final String name) { + return BY_NAME.get(name); + } + + /** + * Get {@link EcoEnchant} matching permission name. + * + * @param permissionName The permission name to search for. + * @return The matching {@link EcoEnchant}, or null if not found. + */ + public static EcoEnchant getByPermission(@NotNull final String permissionName) { + Optional matching = values().stream().filter(enchant -> enchant.getPermissionName().equalsIgnoreCase(permissionName)).findFirst(); + return matching.orElse(null); + } + + /** + * Get {@link EcoEnchant} matching key. + * + * @param key The NamespacedKey to search for. + * @return The matching {@link EcoEnchant}, or null if not found. + */ + public static EcoEnchant getByKey(@NotNull final NamespacedKey key) { + return BY_KEY.get(key); + } + + /** + * Get if {@link ItemStack} has any {@link EcoEnchant} matching specified {@link EnchantmentType}. + * + * @param item The {@link ItemStack} to check. + * @param type The {@link EnchantmentType} to match. + * @return True if has, false if doesn't have. + */ + public static boolean hasAnyOfType(@NotNull final ItemStack item, + @NotNull final EnchantmentType type) { + AtomicBoolean hasOfType = new AtomicBoolean(false); + + if (item.getItemMeta() instanceof EnchantmentStorageMeta) { + ((EnchantmentStorageMeta) item.getItemMeta()).getStoredEnchants().forEach(((enchantment, integer) -> { + if (getFromEnchantment(enchantment) != null && getFromEnchantment(enchantment).getType().equals(type)) { + hasOfType.set(true); + } + })); + } else { + item.getEnchantments().forEach((enchantment, integer) -> { + if (getFromEnchantment(enchantment) != null && (getFromEnchantment(enchantment).getType().equals(type))) { + hasOfType.set(true); + } + }); + } + return hasOfType.get(); + } + + /** + * Update all {@link EcoEnchant}s. + */ + @ConfigUpdater + public static void update() { + for (EcoEnchant ecoEnchant : new HashSet<>(values())) { + ecoEnchant.update(); + } + } + + /** + * Add new {@link EcoEnchant} to EcoEnchants. + *

+ * Only for internal use, enchantments are automatically added in the constructor. + * + * @param enchant The {@link EcoEnchant} to add. + */ + public static void addNewEcoEnchant(@NotNull final EcoEnchant enchant) { + BY_KEY.remove(enchant.getKey()); + BY_NAME.inverse().remove(enchant); + BY_KEY.put(enchant.getKey(), enchant); + BY_NAME.put(enchant.getName(), enchant); + } + + /** + * Remove {@link EcoEnchant} from EcoEnchants. + * + * @param enchant The {@link EcoEnchant} to remove. + */ + public static void removeEcoEnchant(@NotNull final EcoEnchant enchant) { + BY_KEY.remove(enchant.getKey()); + BY_NAME.inverse().remove(enchant); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/AngerArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/AngerArtifact.java new file mode 100644 index 00000000..d60ed683 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/AngerArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class AngerArtifact extends Artifact { + public AngerArtifact() { + super( + "anger_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.VILLAGER_ANGRY; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/AshArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/AshArtifact.java new file mode 100644 index 00000000..40dfa27a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/AshArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class AshArtifact extends Artifact { + public AshArtifact() { + super( + "ash_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.WHITE_ASH; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/BarrierArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/BarrierArtifact.java new file mode 100644 index 00000000..5b15416e --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/BarrierArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class BarrierArtifact extends Artifact { + public BarrierArtifact() { + super( + "barrier_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.BARRIER; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CloudsArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CloudsArtifact.java new file mode 100644 index 00000000..1811d272 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CloudsArtifact.java @@ -0,0 +1,24 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Color; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class CloudsArtifact extends Artifact { + public CloudsArtifact() { + super( + "clouds_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.REDSTONE; + } + + @Override + public Particle.DustOptions getDustOptions() { + return new Particle.DustOptions(Color.AQUA, 1.0f); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CrimsonArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CrimsonArtifact.java new file mode 100644 index 00000000..269a528a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CrimsonArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class CrimsonArtifact extends Artifact { + public CrimsonArtifact() { + super( + "crimson_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.CRIMSON_SPORE; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DamageArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DamageArtifact.java new file mode 100644 index 00000000..dbc80da2 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DamageArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class DamageArtifact extends Artifact { + public DamageArtifact() { + super( + "damage_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.DAMAGE_INDICATOR; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DragonArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DragonArtifact.java new file mode 100644 index 00000000..fa9e0cdd --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DragonArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class DragonArtifact extends Artifact { + public DragonArtifact() { + super( + "dragon_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.DRAGON_BREATH; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DustArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DustArtifact.java new file mode 100644 index 00000000..ab491a79 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DustArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class DustArtifact extends Artifact { + public DustArtifact() { + super( + "dust_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.CRIT; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EmeraldArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EmeraldArtifact.java new file mode 100644 index 00000000..15299ee9 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EmeraldArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class EmeraldArtifact extends Artifact { + public EmeraldArtifact() { + super( + "emerald_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.COMPOSTER; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EnchantmentArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EnchantmentArtifact.java new file mode 100644 index 00000000..57695a44 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EnchantmentArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class EnchantmentArtifact extends Artifact { + public EnchantmentArtifact() { + super( + "enchantment_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.ENCHANTMENT_TABLE; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EndArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EndArtifact.java new file mode 100644 index 00000000..7f279b4c --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EndArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class EndArtifact extends Artifact { + public EndArtifact() { + super( + "end_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.END_ROD; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/FireArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/FireArtifact.java new file mode 100644 index 00000000..13fb98c5 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/FireArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class FireArtifact extends Artifact { + public FireArtifact() { + super( + "fire_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.FLAME; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HeartArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HeartArtifact.java new file mode 100644 index 00000000..105575c9 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HeartArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class HeartArtifact extends Artifact { + public HeartArtifact() { + super( + "heart_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.HEART; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HoneyArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HoneyArtifact.java new file mode 100644 index 00000000..227d2e3b --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HoneyArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class HoneyArtifact extends Artifact { + public HoneyArtifact() { + super( + "honey_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.FALLING_HONEY; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/InkArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/InkArtifact.java new file mode 100644 index 00000000..6fea17dc --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/InkArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class InkArtifact extends Artifact { + public InkArtifact() { + super( + "ink_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.SQUID_INK; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LavaArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LavaArtifact.java new file mode 100644 index 00000000..89bb94c6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LavaArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class LavaArtifact extends Artifact { + public LavaArtifact() { + super( + "lava_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.DRIP_LAVA; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LimeArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LimeArtifact.java new file mode 100644 index 00000000..452f9819 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LimeArtifact.java @@ -0,0 +1,24 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Color; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class LimeArtifact extends Artifact { + public LimeArtifact() { + super( + "lime_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.REDSTONE; + } + + @Override + public Particle.DustOptions getDustOptions() { + return new Particle.DustOptions(Color.fromRGB(3, 252, 140), 1.0f); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagicArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagicArtifact.java new file mode 100644 index 00000000..0de89a98 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagicArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class MagicArtifact extends Artifact { + public MagicArtifact() { + super( + "magic_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.CRIT_MAGIC; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagmaArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagmaArtifact.java new file mode 100644 index 00000000..520c1cba --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagmaArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class MagmaArtifact extends Artifact { + public MagmaArtifact() { + super( + "magma_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.LAVA; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MusicArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MusicArtifact.java new file mode 100644 index 00000000..4e1984ca --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MusicArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class MusicArtifact extends Artifact { + public MusicArtifact() { + super( + "music_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.NOTE; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/NautilusArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/NautilusArtifact.java new file mode 100644 index 00000000..3a8b2ce4 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/NautilusArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class NautilusArtifact extends Artifact { + public NautilusArtifact() { + super( + "nautilus_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.NAUTILUS; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/NetherArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/NetherArtifact.java new file mode 100644 index 00000000..b7e6a836 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/NetherArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class NetherArtifact extends Artifact { + public NetherArtifact() { + super( + "nether_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.PORTAL; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/RedstoneArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/RedstoneArtifact.java new file mode 100644 index 00000000..75f143b4 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/RedstoneArtifact.java @@ -0,0 +1,24 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Color; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class RedstoneArtifact extends Artifact { + public RedstoneArtifact() { + super( + "redstone_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.REDSTONE; + } + + @Override + public Particle.DustOptions getDustOptions() { + return new Particle.DustOptions(Color.RED, 1.0f); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SmokeArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SmokeArtifact.java new file mode 100644 index 00000000..1bb67824 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SmokeArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class SmokeArtifact extends Artifact { + public SmokeArtifact() { + super( + "smoke_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.CAMPFIRE_COSY_SMOKE; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SnowArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SnowArtifact.java new file mode 100644 index 00000000..009f400f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SnowArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class SnowArtifact extends Artifact { + public SnowArtifact() { + super( + "snow_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.SNOWBALL; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulArtifact.java new file mode 100644 index 00000000..df2f4bae --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class SoulArtifact extends Artifact { + public SoulArtifact() { + super( + "soul_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.SOUL; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulFireArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulFireArtifact.java new file mode 100644 index 00000000..4604a6ec --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulFireArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class SoulFireArtifact extends Artifact { + public SoulFireArtifact() { + super( + "soul_fire_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.SOUL_FIRE_FLAME; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SparkleArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SparkleArtifact.java new file mode 100644 index 00000000..917f04da --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SparkleArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class SparkleArtifact extends Artifact { + public SparkleArtifact() { + super( + "sparkle_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.FIREWORKS_SPARK; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SweepArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SweepArtifact.java new file mode 100644 index 00000000..c3cbc353 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SweepArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class SweepArtifact extends Artifact { + public SweepArtifact() { + super( + "sweep_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.SWEEP_ATTACK; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TearArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TearArtifact.java new file mode 100644 index 00000000..64ed9ac3 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TearArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class TearArtifact extends Artifact { + public TearArtifact() { + super( + "tear_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.DRIPPING_OBSIDIAN_TEAR; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TotemArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TotemArtifact.java new file mode 100644 index 00000000..f0a656b6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TotemArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class TotemArtifact extends Artifact { + public TotemArtifact() { + super( + "totem_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.TOTEM; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/VillagerArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/VillagerArtifact.java new file mode 100644 index 00000000..f6d76fd6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/VillagerArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class VillagerArtifact extends Artifact { + public VillagerArtifact() { + super( + "villager_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.VILLAGER_HAPPY; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WarpedArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WarpedArtifact.java new file mode 100644 index 00000000..2a746ca5 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WarpedArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class WarpedArtifact extends Artifact { + public WarpedArtifact() { + super( + "warped_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.WARPED_SPORE; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WaterArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WaterArtifact.java new file mode 100644 index 00000000..770e34a0 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WaterArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class WaterArtifact extends Artifact { + public WaterArtifact() { + super( + "water_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.DRIP_WATER; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WitchArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WitchArtifact.java new file mode 100644 index 00000000..6095fae5 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WitchArtifact.java @@ -0,0 +1,18 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class WitchArtifact extends Artifact { + public WitchArtifact() { + super( + "witch_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.SPELL_WITCH; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/ZapArtifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/ZapArtifact.java new file mode 100644 index 00000000..81d8654e --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/ZapArtifact.java @@ -0,0 +1,24 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; + +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import org.bukkit.Color; +import org.bukkit.Particle; +import org.jetbrains.annotations.NotNull; + +public class ZapArtifact extends Artifact { + public ZapArtifact() { + super( + "zap_artifact" + ); + } + + @Override + public @NotNull Particle getParticle() { + return Particle.REDSTONE; + } + + @Override + public Particle.DustOptions getDustOptions() { + return new Particle.DustOptions(Color.YELLOW, 1.0f); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/BreaklessnessCurse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/BreaklessnessCurse.java new file mode 100644 index 00000000..9548dd70 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/BreaklessnessCurse.java @@ -0,0 +1,29 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.curse; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class BreaklessnessCurse extends EcoEnchant { + public BreaklessnessCurse() { + super( + "breaklessness_curse", EnchantmentType.CURSE + ); + } + + @Override + public void onDamageBlock(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockDamageEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java new file mode 100644 index 00000000..dc0843e0 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java @@ -0,0 +1,90 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.curse; + +import com.willfp.eco.core.events.ArmorEquipEvent; +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.TimedRunnable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.PigZombie; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +import java.util.HashMap; + +public class CallingCurse extends EcoEnchant implements TimedRunnable { + private final HashMap players = new HashMap<>(); + private double distance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance"); + + public CallingCurse() { + super( + "calling_curse", EnchantmentType.CURSE + ); + } + + @EventHandler + public void onArmorEquip(@NotNull final ArmorEquipEvent event) { + refresh(); + } + + @EventHandler + public void onPlayerJoin(@NotNull final PlayerJoinEvent event) { + refresh(); + } + + @EventHandler + public void onPlayerLeave(@NotNull final PlayerQuitEvent event) { + refresh(); + } + + private void refresh() { + players.clear(); + this.getPlugin().getScheduler().runLater(() -> this.getPlugin().getServer().getOnlinePlayers().forEach(player -> { + int level = EnchantChecks.getArmorPoints(player, this, 0); + if (level > 0) { + players.put(player, level); + } + }), 1); + + distance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance"); + } + + @Override + public void run() { + players.forEach((player, level) -> { + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + for (Entity e : player.getWorld().getNearbyEntities(player.getLocation(), distance, distance, distance)) { + if (!(e instanceof Monster)) { + continue; + } + + if (e instanceof PigZombie) { + ((PigZombie) e).setAngry(true); + } + + ((Monster) e).setTarget(player); + + Vector vector = player.getLocation().toVector().clone().subtract(e.getLocation().toVector()).normalize().multiply(0.23d); + + if (VectorUtils.isFinite(vector)) { + e.setVelocity(vector); + } + } + }); + } + + @Override + public long getTime() { + return this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "repeat-ticks"); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java new file mode 100644 index 00000000..c3669ff5 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java @@ -0,0 +1,120 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.curse; + +import com.willfp.eco.util.DurabilityUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.TimedRunnable; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDropItemEvent; +import org.bukkit.event.entity.EntityPickupItemEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Repairable; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public class DecayCurse extends EcoEnchant implements TimedRunnable { + private final Set players = new HashSet<>(); + private int amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + public DecayCurse() { + super( + "decay_curse", EnchantmentType.CURSE + ); + } + + @EventHandler + public void onItemPickup(@NotNull final EntityPickupItemEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + refreshPlayer((Player) event.getEntity()); + } + + @EventHandler + public void onPlayerJoin(@NotNull final PlayerJoinEvent event) { + refresh(); + } + + @EventHandler + public void onPlayerLeave(@NotNull final PlayerQuitEvent event) { + refresh(); + } + + @EventHandler + public void onInventoryDrop(@NotNull final EntityDropItemEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + refreshPlayer((Player) event.getEntity()); + } + + @EventHandler + public void onInventoryClick(@NotNull final InventoryClickEvent event) { + if (!(event.getWhoClicked() instanceof Player)) { + return; + } + refreshPlayer((Player) event.getWhoClicked()); + } + + private void refresh() { + players.clear(); + this.getPlugin().getScheduler().runLater(() -> this.getPlugin().getServer().getOnlinePlayers().forEach(player -> { + if (Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, this))) { + players.add(player); + } + }), 1); + amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier"); + } + + private void refreshPlayer(@NotNull final Player player) { + players.remove(player); + if (Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, this))) { + players.add(player); + } + } + + @Override + public void run() { + players.forEach((player -> { + for (ItemStack item : player.getInventory().getContents()) { + int level = EnchantChecks.getItemLevel(item, this); + if (level == 0) { + continue; + } + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (!(item.getItemMeta() instanceof Repairable)) { + continue; + } + + if (player.getInventory().getItemInMainHand().equals(item)) { + continue; + } + if (player.getInventory().getItemInOffHand().equals(item)) { + continue; + } + if (player.getItemOnCursor().equals(item)) { + continue; + } + + DurabilityUtils.damageItemNoBreak(item, amount, player); + } + })); + } + + @Override + public long getTime() { + return this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "repeat-ticks"); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/FragilityCurse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/FragilityCurse.java new file mode 100644 index 00000000..b3d71b37 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/FragilityCurse.java @@ -0,0 +1,37 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.curse; + +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerItemDamageEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public class FragilityCurse extends EcoEnchant { + public FragilityCurse() { + super( + "fragility_curse", EnchantmentType.CURSE + ); + } + + @EventHandler + public void onItemDamage(@NotNull final PlayerItemDamageEvent event) { + ItemStack item = event.getItem(); + + if (!EnchantChecks.item(item, this)) { + return; + } + + if (this.getDisabledWorlds().contains(event.getPlayer().getWorld())) { + return; + } + + int min = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "minimum-extra-durability"); + int max = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "maximum-extra-durability"); + + event.setDamage(event.getDamage() * NumberUtils.randInt(min, max)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HarmlessnessCurse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HarmlessnessCurse.java new file mode 100644 index 00000000..2521ff04 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HarmlessnessCurse.java @@ -0,0 +1,29 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.curse; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class HarmlessnessCurse extends EcoEnchant { + public HarmlessnessCurse() { + super( + "harmlessness_curse", EnchantmentType.CURSE + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setDamage(0); + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HungerCurse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HungerCurse.java new file mode 100644 index 00000000..afeba0de --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HungerCurse.java @@ -0,0 +1,44 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.curse; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.jetbrains.annotations.NotNull; + +public class HungerCurse extends EcoEnchant { + public HungerCurse() { + super( + "hunger_curse", EnchantmentType.CURSE + ); + } + + @EventHandler + public void onHunger(@NotNull final FoodLevelChangeEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + + Player player = (Player) event.getEntity(); + + if (!EnchantChecks.helmet(player, this)) { + return; + } + + if (event.getFoodLevel() > player.getFoodLevel()) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int delta = player.getFoodLevel() - event.getFoodLevel(); + delta *= this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "times-more-hunger"); + + event.setFoodLevel(player.getFoodLevel() - delta); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java new file mode 100644 index 00000000..597d1d58 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.curse; + +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class InaccuracyCurse extends EcoEnchant { + public InaccuracyCurse() { + super( + "inaccuracy_curse", EnchantmentType.CURSE + ); + } + + @Override + public void onBowShoot(@NotNull final LivingEntity shooter, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityShootBowEvent event) { + double spread = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "spread"); + + Vector velocity = event.getProjectile().getVelocity().clone(); + + velocity.add(new Vector(NumberUtils.randFloat(-spread, spread), NumberUtils.randFloat(-spread, spread), NumberUtils.randFloat(-spread, spread))); + event.getProjectile().setVelocity(velocity); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/MisfortuneCurse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/MisfortuneCurse.java new file mode 100644 index 00000000..cf423826 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/MisfortuneCurse.java @@ -0,0 +1,29 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.curse; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.jetbrains.annotations.NotNull; + +public class MisfortuneCurse extends EcoEnchant { + public MisfortuneCurse() { + super( + "misfortune_curse", EnchantmentType.CURSE + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setDropItems(false); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/PermanenceCurse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/PermanenceCurse.java new file mode 100644 index 00000000..d3f354aa --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/PermanenceCurse.java @@ -0,0 +1,13 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.curse; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; + +public class PermanenceCurse extends EcoEnchant { + public PermanenceCurse() { + super( + "permanence_curse", EnchantmentType.CURSE + ); + } + // Listeners are in anvil listeners +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abattoir.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abattoir.java new file mode 100644 index 00000000..1b42ab32 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abattoir.java @@ -0,0 +1,39 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.Player; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Abattoir extends EcoEnchant { + public Abattoir() { + super( + "abattoir", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (victim instanceof Monster) { + return; + } + + if (victim instanceof Player) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = (multiplier * (level + 1)) + 1; + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abrasion.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abrasion.java new file mode 100644 index 00000000..a579c0e5 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abrasion.java @@ -0,0 +1,61 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.DurabilityUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +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 java.util.ArrayList; +import java.util.Arrays; + +public class Abrasion extends EcoEnchant { + public Abrasion() { + super( + "abrasion", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity uncastVictim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(uncastVictim instanceof Player)) { + return; + } + Player victim = (Player) uncastVictim; + + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + ArrayList armor = new ArrayList<>(Arrays.asList(victim.getInventory().getArmorContents())); + if (armor.isEmpty()) { + return; + } + + for (ItemStack armorPiece : armor) { + if (armorPiece == null) { + continue; + } + + if (armorPiece.equals(victim.getInventory().getHelmet())) { + DurabilityUtils.damageItem(victim, victim.getInventory().getHelmet(), level, 39); + } + if (armorPiece.equals(victim.getInventory().getChestplate())) { + DurabilityUtils.damageItem(victim, victim.getInventory().getChestplate(), level, 38); + } + if (armorPiece.equals(victim.getInventory().getLeggings())) { + DurabilityUtils.damageItem(victim, victim.getInventory().getLeggings(), level, 37); + } + if (armorPiece.equals(victim.getInventory().getBoots())) { + DurabilityUtils.damageItem(victim, victim.getInventory().getBoots(), level, 36); + } + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aerial.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aerial.java new file mode 100644 index 00000000..503a7855 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aerial.java @@ -0,0 +1,50 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.jetbrains.annotations.NotNull; + +public class Aerial extends EcoEnchant { + public Aerial() { + super( + "aerial", EnchantmentType.NORMAL + ); + } + + @Override + public void onBowShoot(@NotNull final LivingEntity shooter, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityShootBowEvent event) { + if (!(event.getProjectile() instanceof Arrow)) { + return; + } + + if (shooter.isOnGround()) { + return; + } + + event.getProjectile().setMetadata("shot-in-air", this.getPlugin().getMetadataValueFactory().create(true)); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!arrow.hasMetadata("shot-in-air")) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level); + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aquatic.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aquatic.java new file mode 100644 index 00000000..07691ea0 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aquatic.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Aquatic extends EcoEnchant { + public Aquatic() { + super( + "aquatic", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!attacker.getLocation().getBlock().getType().equals(Material.WATER)) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double reduction = 1 + (multiplier * level); + event.setDamage(damage * reduction); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arachnid.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arachnid.java new file mode 100644 index 00000000..a427d5f1 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arachnid.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Spider; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Arachnid extends EcoEnchant { + public Arachnid() { + super( + "arachnid", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Spider)) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = (multiplier * (level + 1)) + 1; + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arborist.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arborist.java new file mode 100644 index 00000000..3cb557f8 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arborist.java @@ -0,0 +1,71 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.drops.DropQueue; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class Arborist extends EcoEnchant { + public Arborist() { + super( + "arborist", EnchantmentType.NORMAL + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + if (!Tag.LEAVES.isTagged(block.getType())) { + return; + } + + event.setDropItems(false); + + Material toDrop; + + List materials = new ArrayList<>(); + + for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "items")) { + Material material = Material.getMaterial(materialName.toUpperCase()); + if (material != null) { + materials.add(material); + } + } + + toDrop = materials.get(new Random().nextInt(materials.size())); + + if (toDrop == null) { + toDrop = block.getType(); + } + + ItemStack item = new ItemStack(toDrop, 1); + + new DropQueue(player) + .setLocation(block.getLocation()) + .addItem(item) + .push(); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arcanic.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arcanic.java new file mode 100644 index 00000000..3d60c3f1 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arcanic.java @@ -0,0 +1,31 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Arcanic extends EcoEnchant { + public Arcanic() { + super( + "arcanic", EnchantmentType.NORMAL + ); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + if (!(event.getCause().equals(EntityDamageEvent.DamageCause.POISON) || event.getCause().equals(EntityDamageEvent.DamageCause.WITHER))) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Atmospheric.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Atmospheric.java new file mode 100644 index 00000000..3fc94e47 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Atmospheric.java @@ -0,0 +1,46 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.jetbrains.annotations.NotNull; + +public class Atmospheric extends EcoEnchant { + public Atmospheric() { + super( + "atmospheric", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentLaunch(@NotNull final LivingEntity shooter, + @NotNull final Trident trident, + final int level, + @NotNull final ProjectileLaunchEvent event) { + if (shooter.isOnGround()) { + return; + } + + trident.setMetadata("shot-in-air", this.getPlugin().getMetadataValueFactory().create(true)); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!trident.hasMetadata("shot-in-air")) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level); + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aversion.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aversion.java new file mode 100644 index 00000000..47a8c397 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aversion.java @@ -0,0 +1,49 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Enderman; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Aversion extends EcoEnchant { + public Aversion() { + super( + "aversion", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onEndermanTarget(@NotNull final EntityTargetLivingEntityEvent event) { + if (!(event.getEntity() instanceof Enderman)) { + return; + } + + Enderman enderman = (Enderman) event.getEntity(); + LivingEntity target = event.getTarget(); + + if (event.getReason() != EntityTargetEvent.TargetReason.CLOSEST_PLAYER) { + return; + } + + if (target == null) { + return; + } + + int level = EnchantChecks.getHelmetLevel(target, this); + + if (level == 0) { + return; + } + + if (this.getDisabledWorlds().contains(target.getWorld())) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Backstab.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Backstab.java new file mode 100644 index 00000000..638557a0 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Backstab.java @@ -0,0 +1,39 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Backstab extends EcoEnchant { + public Backstab() { + super( + "backstab", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + Vector pDir = attacker.getLocation().getDirection(); + Vector eDir = victim.getLocation().getDirection(); + double xv = pDir.getX() * eDir.getZ() - pDir.getZ() * eDir.getX(); + double zv = pDir.getX() * eDir.getX() + pDir.getZ() * eDir.getZ(); + double angle = Math.atan2(xv, zv); // Value between -Ï€ and +Ï€ + double angleInDegrees = (angle * 180) / Math.PI; + + if (angleInDegrees > 60 || angleInDegrees < -32) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level); + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Beheading.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Beheading.java new file mode 100644 index 00000000..dea660af --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Beheading.java @@ -0,0 +1,79 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.drops.DropQueue; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; +import org.jetbrains.annotations.NotNull; + +public class Beheading extends EcoEnchant { + public Beheading() { + super( + "beheading", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onDeath(@NotNull final EntityDeathEvent event) { + if (event.getEntity().getKiller() == null) { + return; + } + + Player player = event.getEntity().getKiller(); + + LivingEntity victim = event.getEntity(); + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + ItemStack item; + + if (victim instanceof Player) { + item = new ItemStack(Material.PLAYER_HEAD, 1); + SkullMeta meta = (SkullMeta) item.getItemMeta(); + assert meta != null; + meta.setOwningPlayer((Player) victim); + item.setItemMeta(meta); + } else { + if (event.getEntityType().equals(EntityType.ZOMBIE)) { + item = new ItemStack(Material.ZOMBIE_HEAD, 1); + } else if (event.getEntityType().equals(EntityType.SKELETON)) { + item = new ItemStack(Material.SKELETON_SKULL, 1); + } else if (event.getEntityType().equals(EntityType.CREEPER)) { + item = new ItemStack(Material.CREEPER_HEAD, 1); + } else if (event.getEntityType().equals(EntityType.ENDER_DRAGON)) { + item = new ItemStack(Material.DRAGON_HEAD, 1); + } else { + return; + } + } + + new DropQueue(player) + .addItem(item) + .addXP(event.getDroppedExp()) + .setLocation(victim.getLocation()) + .push(); + + event.setDroppedExp(0); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlastMining.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlastMining.java new file mode 100644 index 00000000..7390693f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlastMining.java @@ -0,0 +1,85 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.anticheat.AnticheatManager; +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.util.BlockUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.Particle; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.Set; + +public class BlastMining extends EcoEnchant { + public BlastMining() { + super( + "blast_mining", EnchantmentType.NORMAL + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + if (block.hasMetadata("block-ignore")) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + if (player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) { + return; + } + + AnticheatManager.exemptPlayer(player); + + Set toBreak = new HashSet<>(); + + for (int x = -1; x <= 1; x++) { + for (int y = -1; y <= 1; y++) { + for (int z = -1; z <= 1; z++) { + if (x == 0 && y == 0 && z == 0) { + if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "enable-sound")) { + block.getWorld().createExplosion(block.getLocation().clone().add(0.5, 0.5, 0.5), 0, false); + } else { + block.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, block.getLocation().clone().add(0.5, 0.5, 0.5), 1); + } + continue; + } + Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(x, y, z)); + + if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks").contains(block1.getType().name().toLowerCase())) { + continue; + } + + if (block1.getType().getHardness() > block.getType().getHardness() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "hardness-check")) { + continue; + } + + if (!AntigriefManager.canBreakBlock(player, block1)) { + continue; + } + + toBreak.add(block1); + } + } + } + + toBreak.forEach((block1 -> { + block1.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true)); + BlockUtils.breakBlock(player, block1); + block1.removeMetadata("block-ignore", this.getPlugin()); + })); + + AnticheatManager.unexemptPlayer(player); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Bleed.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Bleed.java new file mode 100644 index 00000000..5360adcf --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Bleed.java @@ -0,0 +1,51 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.atomic.AtomicInteger; + +public class Bleed extends EcoEnchant { + public Bleed() { + super( + "bleed", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + double bleedDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bleed-damage"); + + int bleedCount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "amount-per-level"); + bleedCount *= level; + final int finalBleedCount = bleedCount; + + AtomicInteger currentBleedCount = new AtomicInteger(0); + + this.getPlugin().getRunnableFactory().create(bukkitRunnable -> { + currentBleedCount.addAndGet(1); + + victim.damage(bleedDamage); + + if (currentBleedCount.get() >= finalBleedCount) { + bukkitRunnable.cancel(); + } + }).runTaskTimer(0, 10); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Blind.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Blind.java new file mode 100644 index 00000000..765ab4f9 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Blind.java @@ -0,0 +1,38 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Blind extends EcoEnchant { + public Blind() { + super( + "blind", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level"); + + victim.setVelocity(new Vector(0, 0, 0)); + victim.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, duration * level, level)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlockBreather.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlockBreather.java new file mode 100644 index 00000000..6d7c256a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlockBreather.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class BlockBreather extends EcoEnchant { + public BlockBreather() { + super( + "block_breather", EnchantmentType.NORMAL + ); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + if (!event.getCause().equals(EntityDamageEvent.DamageCause.SUFFOCATION)) { + return; + } + + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BossHunter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BossHunter.java new file mode 100644 index 00000000..a22f6e86 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BossHunter.java @@ -0,0 +1,39 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Boss; +import org.bukkit.entity.ElderGuardian; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.persistence.PersistentDataType; +import org.jetbrains.annotations.NotNull; + +@SuppressWarnings("deprecation") +public class BossHunter extends EcoEnchant { + public BossHunter() { + super( + "boss_hunter", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Boss || victim instanceof ElderGuardian) && !victim.getPersistentDataContainer().has(new NamespacedKey("ecobosses", "boss"), PersistentDataType.STRING)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + double damageMultiplier = (level * multiplier) + 1; + + event.setDamage(event.getDamage() * damageMultiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Buckshot.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Buckshot.java new file mode 100644 index 00000000..50bd8a96 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Buckshot.java @@ -0,0 +1,57 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.Sound; +import org.bukkit.SoundCategory; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.AbstractArrow; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Buckshot extends EcoEnchant { + public Buckshot() { + super( + "buckshot", EnchantmentType.NORMAL + ); + } + + @Override + public void onBowShoot(@NotNull final LivingEntity shooter, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityShootBowEvent event) { + event.getProjectile().remove(); + if (shooter instanceof Player) { + ((Player) shooter).playSound(shooter.getLocation(), Sound.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0f, 1.0f); + } + + int numberPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "amount-per-level"); + int number = numberPerLevel * level; + double spread = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "spread-per-level"); + spread *= level; + + for (int i = 0; i < number; i += 1) { + + Vector velocity = event.getProjectile().getVelocity().clone(); + + velocity.add(new Vector(NumberUtils.randFloat(-spread, spread), NumberUtils.randFloat(-spread, spread), NumberUtils.randFloat(-spread, spread))); + + Arrow arrow1 = shooter.launchProjectile(Arrow.class, velocity); + if (EnchantChecks.mainhand(shooter, Enchantment.ARROW_FIRE)) { + arrow1.setFireTicks(Integer.MAX_VALUE); + } + if (EnchantChecks.mainhand(shooter, EcoEnchants.MARKSMAN)) { + arrow1.setGravity(false); + } + arrow1.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Butchering.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Butchering.java new file mode 100644 index 00000000..b24a2081 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Butchering.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Butchering extends EcoEnchant { + public Butchering() { + super( + "butchering", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (victim instanceof Monster) { + return; + } + + if (victim instanceof Player) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level"); + event.setDamage(event.getDamage() + (level * multiplier)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cerebral.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cerebral.java new file mode 100644 index 00000000..0fe58864 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cerebral.java @@ -0,0 +1,39 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Cerebral extends EcoEnchant { + public Cerebral() { + super( + "cerebral", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (arrow.getLocation().getY() < victim.getLocation().getY() + victim.getEyeHeight() - 0.22) { + return; + } + + if (!EnchantChecks.arrow(arrow, this)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + double damageMultiplier = (level * multiplier) + 1; + + event.setDamage(event.getDamage() * damageMultiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Chopless.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Chopless.java new file mode 100644 index 00000000..2d0f84a6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Chopless.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Chopless extends EcoEnchant { + public Chopless() { + super( + "chopless", EnchantmentType.NORMAL + ); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + if (victim.getEquipment() == null) { + return; + } + + if (!victim.getEquipment().getItemInMainHand().getType().toString().endsWith("_AXE")) { + return; + } + + double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-less-per-level"); + + double multiplier = 1 - ((reduction / 100) * level); + + event.setDamage(event.getDamage() * multiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cleave.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cleave.java new file mode 100644 index 00000000..b9f5471f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cleave.java @@ -0,0 +1,45 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Cleave extends EcoEnchant { + public Cleave() { + super( + "cleave", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (victim.hasMetadata("cleaved")) { + return; + } + + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + double damagePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-percentage-per-level") * 0.01; + double radiusPerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-per-level"); + final double damage = damagePerLevel * level * event.getDamage(); + final double radius = radiusPerLevel * level; + + victim.getNearbyEntities(radius, radius, radius).stream() + .filter(entity -> entity instanceof LivingEntity) + .filter(entity -> !entity.equals(attacker)) + .forEach(entity -> { + entity.setMetadata("cleaved", this.getPlugin().getMetadataValueFactory().create(true)); + ((LivingEntity) entity).damage(damage, attacker); + this.getPlugin().getScheduler().runLater(() -> entity.removeMetadata("cleaved", this.getPlugin()), 5); + }); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Collateral.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Collateral.java new file mode 100644 index 00000000..4b456406 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Collateral.java @@ -0,0 +1,24 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.jetbrains.annotations.NotNull; + +public class Collateral extends EcoEnchant { + public Collateral() { + super( + "collateral", EnchantmentType.NORMAL + ); + } + + @Override + public void onBowShoot(@NotNull final LivingEntity shooter, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityShootBowEvent event) { + arrow.setPierceLevel(level); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java new file mode 100644 index 00000000..6396856f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java @@ -0,0 +1,37 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Conclude extends EcoEnchant { + public Conclude() { + super( + "conclude", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level"); + if (victim.getHealth() > level * minhealth) { + return; + } + + event.setDamage(30); // cba to do this properly + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Corrosive.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Corrosive.java new file mode 100644 index 00000000..98ec9a7c --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Corrosive.java @@ -0,0 +1,56 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.DurabilityUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +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 java.util.ArrayList; +import java.util.Arrays; + +public class Corrosive extends EcoEnchant { + public Corrosive() { + super( + "corrosive", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity uncastVictim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(uncastVictim instanceof Player)) { + return; + } + Player victim = (Player) uncastVictim; + + ArrayList armor = new ArrayList<>(Arrays.asList(victim.getInventory().getArmorContents())); + if (armor.isEmpty()) { + return; + } + + for (ItemStack armorPiece : armor) { + if (armorPiece == null) { + continue; + } + + + if (armorPiece.equals(victim.getInventory().getHelmet())) { + DurabilityUtils.damageItem(victim, victim.getInventory().getHelmet(), level, 39); + } else if (armorPiece.equals(victim.getInventory().getChestplate())) { + DurabilityUtils.damageItem(victim, victim.getInventory().getChestplate(), level, 38); + } else if (armorPiece.equals(victim.getInventory().getLeggings())) { + DurabilityUtils.damageItem(victim, victim.getInventory().getLeggings(), level, 37); + } else if (armorPiece.equals(victim.getInventory().getBoots())) { + DurabilityUtils.damageItem(victim, victim.getInventory().getBoots(), level, 36); + } + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cranial.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cranial.java new file mode 100644 index 00000000..f6f43ee9 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cranial.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Cranial extends EcoEnchant { + public Cranial() { + super( + "cranial", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (trident.getLocation().getY() < victim.getLocation().getY() + victim.getEyeHeight() - 0.22) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + double damageMultiplier = (level * multiplier) + 1; + + event.setDamage(event.getDamage() * damageMultiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Criticals.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Criticals.java new file mode 100644 index 00000000..04784a39 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Criticals.java @@ -0,0 +1,38 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Criticals extends EcoEnchant { + public Criticals() { + super( + "criticals", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(attacker.getFallDistance() > 0 && !attacker.isOnGround())) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "use-additive")) { + damage = damage / 1.5; + double bonus = damage * (multiplier * level); + damage = damage + bonus + damage / 2; + event.setDamage(damage); + } else { + double bonus = 1 + (multiplier * level); + event.setDamage(damage * bonus); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cubism.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cubism.java new file mode 100644 index 00000000..7b1c8bdf --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cubism.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Slime; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Cubism extends EcoEnchant { + public Cubism() { + super( + "cubism", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Slime)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + double damageMultiplier = (level * multiplier) + 1; + + event.setDamage(event.getDamage() * damageMultiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defender.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defender.java new file mode 100644 index 00000000..50b3f771 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defender.java @@ -0,0 +1,39 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Tameable; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Defender extends EcoEnchant { + public Defender() { + super( + "defender", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Tameable)) { + return; + } + + Tameable pet = (Tameable) victim; + + if (pet.getOwner() == null) { + return; + } + if (!pet.getOwner().equals(attacker)) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Deflection.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Deflection.java new file mode 100644 index 00000000..617db5f0 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Deflection.java @@ -0,0 +1,37 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Deflection extends EcoEnchant { + public Deflection() { + super( + "deflection", EnchantmentType.NORMAL + ); + } + + @Override + public void onDeflect(@NotNull final Player blocker, + @NotNull final LivingEntity attacker, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (blocker.hasMetadata("cleaved") || blocker.hasMetadata("carved")) { + return; + } + + if (attacker.hasMetadata("cleaved") || attacker.hasMetadata("carved")) { + return; + } + + double perlevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-deflected-per-level"); + double damagePercent = (perlevel / 100) * level; + double damage = event.getDamage() * damagePercent; + + attacker.damage(damage, attacker); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defusion.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defusion.java new file mode 100644 index 00000000..5b0344cd --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defusion.java @@ -0,0 +1,30 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Defusion extends EcoEnchant { + public Defusion() { + super( + "defusion", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Creeper)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level"); + event.setDamage(event.getDamage() + (level * multiplier)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dexterous.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dexterous.java new file mode 100644 index 00000000..ce6510ea --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dexterous.java @@ -0,0 +1,39 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public class Dexterous extends EcoEnchant { + public Dexterous() { + super( + "dexterous", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onDextHold(@NotNull final PlayerItemHeldEvent event) { + Player player = event.getPlayer(); + ItemStack item = player.getInventory().getItem(event.getNewSlot()); + + if (!EnchantChecks.item(item, this)) { + player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0); + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int level = EnchantChecks.getItemLevel(item, this); + double bonus = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "add-speed-per-level"); + player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0 + (level * bonus)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disable.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disable.java new file mode 100644 index 00000000..7bd38647 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disable.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Disable extends EcoEnchant { + public Disable() { + super( + "disable", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, level * 10, 5)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disappear.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disappear.java new file mode 100644 index 00000000..b7538ee6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disappear.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Disappear extends EcoEnchant { + public Disappear() { + super( + "disappear", EnchantmentType.NORMAL + ); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + this.getPlugin().getScheduler().runLater(() -> { + if (victim.getHealth() > EcoEnchants.DISAPPEAR.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "threshold")) { + return; + } + + int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); + final int ticks = ticksPerLevel * level; + victim.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, ticks, 1, false, false, true)); + }, 1); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diurnal.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diurnal.java new file mode 100644 index 00000000..14cf3c6a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diurnal.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.World; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Diurnal extends EcoEnchant { + public Diurnal() { + super( + "diurnal", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!attacker.getWorld().getEnvironment().equals(World.Environment.NORMAL)) { + return; + } + + if (!(attacker.getWorld().getTime() < 12300 && attacker.getWorld().getTime() > 23850)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diverse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diverse.java new file mode 100644 index 00000000..02fcd986 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diverse.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Diverse extends EcoEnchant { + public Diverse() { + super( + "diverse", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (victim.getEquipment() == null) { + return; + } + + if (!victim.getEquipment().getItemInMainHand().getType().toString().endsWith("_SWORD")) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Drill.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Drill.java new file mode 100644 index 00000000..66d4cff4 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Drill.java @@ -0,0 +1,63 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.anticheat.AnticheatManager; +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.util.BlockUtils; +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Drill extends EcoEnchant { + public Drill() { + super( + "drill", EnchantmentType.NORMAL + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + if (block.hasMetadata("block-ignore")) { + return; + } + + if (player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) { + return; + } + + int blocks = level * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "blocks-per-level"); + + AnticheatManager.exemptPlayer(player); + + for (int i = 1; i <= blocks; i++) { + Vector simplified = VectorUtils.simplifyVector(player.getLocation().getDirection().normalize()).multiply(i); + Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(simplified)); + block1.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true)); + + if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks").contains(block1.getType().name().toLowerCase())) { + continue; + } + + if (block1.getType().getHardness() > block.getType().getHardness() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "hardness-check")) { + continue; + } + + if (!AntigriefManager.canBreakBlock(player, block1)) { + continue; + } + + BlockUtils.breakBlock(player, block1); + block1.removeMetadata("block-ignore", this.getPlugin()); + } + + AnticheatManager.unexemptPlayer(player); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dullness.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dullness.java new file mode 100644 index 00000000..664ebdca --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dullness.java @@ -0,0 +1,37 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Dullness extends EcoEnchant { + public Dullness() { + super( + "dullness", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + int durationPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level"); + + victim.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, level * durationPerLevel, level)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dweller.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dweller.java new file mode 100644 index 00000000..94e01f1f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dweller.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Illager; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Dweller extends EcoEnchant { + public Dweller() { + super( + "dweller", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Illager)) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level); + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Economical.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Economical.java new file mode 100644 index 00000000..b6ca77a6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Economical.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent; +import com.willfp.eco.core.Prerequisite; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.event.EventHandler; +import org.jetbrains.annotations.NotNull; + +public class Economical extends EcoEnchant { + public Economical() { + super( + "economical", EnchantmentType.NORMAL, + Prerequisite.HAS_PAPER + ); + } + + @EventHandler + public void onElytraBoost(@NotNull final PlayerElytraBoostEvent event) { + if (!EnchantChecks.chestplate(event.getPlayer(), this)) { + return; + } + if (!EnchantmentUtils.passedChance(this, EnchantChecks.getArmorPoints(event.getPlayer(), this))) { + return; + } + if (this.getDisabledWorlds().contains(event.getPlayer().getWorld())) { + return; + } + event.setShouldConsume(false); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Electroshock.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Electroshock.java new file mode 100644 index 00000000..77521e8e --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Electroshock.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.LightningUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Electroshock extends EcoEnchant { + public Electroshock() { + super( + "electroshock", EnchantmentType.NORMAL + ); + } + + @Override + public void onDeflect(@NotNull final Player blocker, + @NotNull final LivingEntity attacker, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage"); + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + LightningUtils.strike(attacker, damage); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EndInfusion.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EndInfusion.java new file mode 100644 index 00000000..8ab7bc46 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EndInfusion.java @@ -0,0 +1,31 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.World; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class EndInfusion extends EcoEnchant { + public EndInfusion() { + super( + "end_infusion", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!attacker.getWorld().getEnvironment().equals(World.Environment.THE_END)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EnderSlayer.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EnderSlayer.java new file mode 100644 index 00000000..b414eff4 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EnderSlayer.java @@ -0,0 +1,41 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.google.common.collect.ImmutableSet; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +public class EnderSlayer extends EcoEnchant { + private static final Set END_MOBS = new ImmutableSet.Builder() + .add(EntityType.ENDERMITE) + .add(EntityType.ENDERMAN) + .add(EntityType.ENDER_DRAGON) + .add(EntityType.SHULKER) + .build(); + + public EnderSlayer() { + super( + "ender_slayer", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!END_MOBS.contains(victim.getType())) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level"); + + event.setDamage(event.getDamage() + (level * multiplier)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Enderism.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Enderism.java new file mode 100644 index 00000000..c9904cdc --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Enderism.java @@ -0,0 +1,66 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.World; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Enderism extends EcoEnchant { + public Enderism() { + super( + "enderism", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!attacker.getWorld().getEnvironment().equals(World.Environment.THE_END)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } + + @EventHandler + public void onHit(@NotNull final EntityDamageByEntityEvent event) { + if (!(event.getDamager() instanceof Arrow)) { + return; + } + if (!(((Arrow) event.getDamager()).getShooter() instanceof Player)) { + return; + } + + Player player = (Player) ((Arrow) event.getDamager()).getShooter(); + Arrow arrow = (Arrow) event.getDamager(); + + assert player != null; + if (!player.getWorld().getEnvironment().equals(World.Environment.THE_END)) { + return; + } + + if (!EnchantChecks.arrow(arrow, this)) { + return; + } + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int level = EnchantChecks.getArrowLevel(arrow, this); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Evasion.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Evasion.java new file mode 100644 index 00000000..bb95fb06 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Evasion.java @@ -0,0 +1,28 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Evasion extends EcoEnchant { + public Evasion() { + super( + "evasion", EnchantmentType.NORMAL + ); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extinguishing.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extinguishing.java new file mode 100644 index 00000000..5546f11a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extinguishing.java @@ -0,0 +1,31 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Extinguishing extends EcoEnchant { + public Extinguishing() { + super( + "extinguishing", EnchantmentType.NORMAL + ); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + if (!event.getCause().equals(EntityDamageEvent.DamageCause.FIRE_TICK)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + victim.setFireTicks(0); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extract.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extract.java new file mode 100644 index 00000000..4cdb6dcc --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extract.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Extract extends EcoEnchant { + public Extract() { + super( + "extract", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level"); + double amountToHeal = level * multiplier; + double newHealth = attacker.getHealth() + amountToHeal; + if (newHealth > attacker.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { + newHealth = attacker.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); + } + attacker.setHealth(newHealth); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Famine.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Famine.java new file mode 100644 index 00000000..039ff92a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Famine.java @@ -0,0 +1,36 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Famine extends EcoEnchant { + public Famine() { + super( + "famine", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + victim.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, level * 40, level)); + victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, level * 40, level)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Farmhand.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Farmhand.java new file mode 100644 index 00000000..a73755d6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Farmhand.java @@ -0,0 +1,101 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.util.DurabilityUtils; +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Farmhand extends EcoEnchant { + public Farmhand() { + super( + "farmhand", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onTill(@NotNull final PlayerInteractEvent event) { + Player player = event.getPlayer(); + + if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { + return; + } + + if (event.getClickedBlock() == null) { + return; + } + + if (!(event.getClickedBlock().getType().equals(Material.DIRT) || event.getClickedBlock().getType().equals(Material.GRASS_BLOCK))) { + return; + } + + ItemStack item = event.getItem(); + + if (!EnchantChecks.item(item, this)) { + return; + } + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (!item.getType().toString().endsWith("_HOE")) { + return; + } + + if (!AntigriefManager.canBreakBlock(player, event.getClickedBlock())) { + return; + } + + event.getClickedBlock().setType(Material.FARMLAND); + int initial = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "initial-radius"); + int levelrad = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "per-level-radius"); + int radius = initial + (EnchantChecks.getItemLevel(item, this) - 1) * levelrad; + Vector[] vecs; + + if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "use-cube")) { + vecs = VectorUtils.getCube(radius); + } else { + vecs = VectorUtils.getSquare(radius); + } + + if (!this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "per-block-damage")) { + + DurabilityUtils.damageItem(player, player.getInventory().getItemInMainHand(), 1, player.getInventory().getHeldItemSlot()); + } + + for (Vector vec : vecs) { + Location loc = event.getClickedBlock().getLocation().add(vec); + Block block = event.getClickedBlock().getWorld().getBlockAt(loc); + + if (!AntigriefManager.canBreakBlock(player, block)) { + continue; + } + + if (!(block.getType().equals(Material.DIRT) || block.getType().equals(Material.GRASS_BLOCK))) { + continue; + } + + if (!block.getWorld().getBlockAt(loc.add(0, 1, 0)).getType().equals(Material.AIR)) { + continue; + } + + block.setType(Material.FARMLAND); + if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "per-block-damage")) { + + DurabilityUtils.damageItem(player, player.getInventory().getItemInMainHand(), 1, player.getInventory().getHeldItemSlot()); + } + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fetching.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fetching.java new file mode 100644 index 00000000..911988e5 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fetching.java @@ -0,0 +1,67 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.drops.DropQueue; +import com.willfp.eco.core.events.EntityDeathByEntityEvent; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; + +public class Fetching extends EcoEnchant { + public Fetching() { + super( + "fetching", EnchantmentType.NORMAL + ); + } + + @EventHandler(priority = EventPriority.HIGH) + public void onWolfKill(@NotNull final EntityDeathByEntityEvent event) { + LivingEntity entity = event.getVictim(); + + if (entity instanceof Player && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "not-on-players")) { + return; + } + + if (!(event.getKiller() instanceof Wolf)) { + return; + } + + Wolf wolf = (Wolf) event.getKiller(); + + if (!wolf.isTamed() || wolf.getOwner() == null) { + return; + } + + if (!(wolf.getOwner() instanceof Player)) { + return; + } + + Player player = (Player) wolf.getOwner(); + + if (!(EnchantChecks.helmet(player, this))) { + return; + } + + int xp = event.getXp(); + Collection drops = event.getDrops(); + + new DropQueue(player) + .addItems(drops) + .setLocation(entity.getLocation()) + .addXP(xp) + .forceTelekinesis() + .push(); + + event.getDeathEvent().setDroppedExp(0); + event.getDeathEvent().getDrops().clear(); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java new file mode 100644 index 00000000..80d284b7 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java @@ -0,0 +1,37 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Finality extends EcoEnchant { + public Finality() { + super( + "finality", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level"); + if (victim.getHealth() > level * minhealth) { + return; + } + + event.setDamage(30); // cba to do this properly + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java new file mode 100644 index 00000000..23df4797 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Finishing extends EcoEnchant { + public Finishing() { + super( + "finishing", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level"); + if (victim.getHealth() > level * minhealth) { + return; + } + + event.setDamage(30); // cba to do this properly + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FireAffinity.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FireAffinity.java new file mode 100644 index 00000000..c391a209 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FireAffinity.java @@ -0,0 +1,31 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class FireAffinity extends EcoEnchant { + public FireAffinity() { + super( + "fire_affinity", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (attacker.getFireTicks() == 0) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level); + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FirstStrike.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FirstStrike.java new file mode 100644 index 00000000..8f2d1671 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FirstStrike.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class FirstStrike extends EcoEnchant { + public FirstStrike() { + super( + "first_strike", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (victim.getHealth() != victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level); + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Flinch.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Flinch.java new file mode 100644 index 00000000..1afedef7 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Flinch.java @@ -0,0 +1,36 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Flinch extends EcoEnchant { + public Flinch() { + super( + "flinch", EnchantmentType.NORMAL + ); + } + + @Override + public void onDeflect(@NotNull final Player blocker, + @NotNull final LivingEntity attacker, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + int finalDuration = duration * level; + + attacker.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, finalDuration, 1, false, false, false)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java new file mode 100644 index 00000000..c016b8e1 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java @@ -0,0 +1,87 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.events.ArmorEquipEvent; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.TimedRunnable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.HashMap; + +public class Forcefield extends EcoEnchant implements TimedRunnable { + private final HashMap players = new HashMap<>(); + private double initialDistance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance"); + private double bonus = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level"); + private double damagePerPoint = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level"); + + public Forcefield() { + super( + "forcefield", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onArmorEquip(@NotNull final ArmorEquipEvent event) { + refresh(); + } + + @EventHandler + public void onPlayerJoin(@NotNull final PlayerJoinEvent event) { + refresh(); + } + + @EventHandler + public void onPlayerLeave(@NotNull final PlayerQuitEvent event) { + refresh(); + } + + private void refresh() { + players.clear(); + this.getPlugin().getScheduler().runLater(() -> this.getPlugin().getServer().getOnlinePlayers().forEach(player -> { + int level = EnchantChecks.getArmorPoints(player, this, 0); + if (level > 0) { + players.put(player, level); + } + }), 1); + initialDistance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance"); + bonus = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level"); + damagePerPoint = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level"); + } + + @Override + public void run() { + players.forEach((player, level) -> { + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + double distance = initialDistance + (level * bonus); + final double damage = damagePerPoint * level; + + for (Entity e : player.getWorld().getNearbyEntities(player.getLocation(), distance, 2.0d, distance)) { + if (!(e instanceof Monster)) { + continue; + } + + ((Monster) e).damage(damage); + + if (NumberUtils.randFloat(0, 1) < 0.2) { + EnchantChecks.getArmorPoints(player, this, 1); + } + } + }); + } + + @Override + public long getTime() { + return this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "repeat-ticks"); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Freerunner.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Freerunner.java new file mode 100644 index 00000000..c6db7e1b --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Freerunner.java @@ -0,0 +1,28 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Freerunner extends EcoEnchant { + public Freerunner() { + super( + "freerunner", EnchantmentType.NORMAL + ); + } + + @Override + public void onFallDamage(@NotNull final LivingEntity faller, + final int level, + @NotNull final EntityDamageEvent event) { + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Frozen.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Frozen.java new file mode 100644 index 00000000..990a17d6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Frozen.java @@ -0,0 +1,57 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Frozen extends EcoEnchant { + public Frozen() { + super( + "frozen", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onHurt(@NotNull final EntityDamageByEntityEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + + if (!(event.getDamager() instanceof LivingEntity)) { + return; + } + + Player player = (Player) event.getEntity(); + LivingEntity victim = (LivingEntity) event.getDamager(); + + final int points = EnchantChecks.getArmorPoints(player, this, 0); + + if (points == 0) { + return; + } + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (!EnchantmentUtils.passedChance(this, points)) { + return; + } + + int divisor = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "points-per-level"); + final int level = (int) Math.ceil((double) points / divisor); + + this.getPlugin().getScheduler().runLater(() -> { + victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, points * 5, level)); + victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, points * 5, level)); + }, 1); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java new file mode 100644 index 00000000..08123a21 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java @@ -0,0 +1,58 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.PigZombie; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Fury extends EcoEnchant { + public Fury() { + super( + "fury", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + double distancePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level"); + final double distance = distancePerLevel * level; + + for (Entity e : victim.getWorld().getNearbyEntities(victim.getLocation(), distance, distance, distance)) { + if (!(e instanceof Monster)) { + continue; + } + + if (e instanceof PigZombie) { + ((PigZombie) e).setAngry(true); + } + + ((Monster) e).setTarget(victim); + + Vector vector = attacker.getLocation().toVector().clone().subtract(e.getLocation().toVector()).normalize().multiply(0.23d); + + if (VectorUtils.isFinite(vector)) { + e.setVelocity(vector); + } + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Goliath.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Goliath.java new file mode 100644 index 00000000..e7779f6f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Goliath.java @@ -0,0 +1,37 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Goliath extends EcoEnchant { + public Goliath() { + super( + "goliath", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (victim.getHealth() <= attacker.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { + return; + } + + double timesMoreHealth = victim.getHealth() / attacker.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level * timesMoreHealth); + if (bonus - 1 > this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier-cap")) { + bonus = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier-cap") + 1; + } + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Graceful.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Graceful.java new file mode 100644 index 00000000..c724bee7 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Graceful.java @@ -0,0 +1,56 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +@SuppressWarnings("deprecation") +public class Graceful extends EcoEnchant { + public Graceful() { + super( + "graceful", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onFall(@NotNull final PlayerMoveEvent event) { + Player player = event.getPlayer(); + + if (player.isOnGround()) { + return; + } + + if (player.getVelocity().getY() > -1) { + return; + } + + if (player.getLocation().clone().add(0, -3, 0).getBlock().getType().equals(Material.AIR)) { + return; + } + + if (!EnchantChecks.boots(player, this)) { + return; + } + + int level = EnchantChecks.getBootsLevel(player, this); + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20, 5, false, false, true)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grapple.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grapple.java new file mode 100644 index 00000000..8e0da516 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grapple.java @@ -0,0 +1,31 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Grapple extends EcoEnchant { + public Grapple() { + super( + "grapple", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier"); + Vector vector = attacker.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier); + + if (VectorUtils.isFinite(vector)) { + victim.setVelocity(vector); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/GreenThumb.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/GreenThumb.java new file mode 100644 index 00000000..e1f1008a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/GreenThumb.java @@ -0,0 +1,61 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.util.DurabilityUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.jetbrains.annotations.NotNull; + +public class GreenThumb extends EcoEnchant { + public GreenThumb() { + super( + "green_thumb", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onInteract(@NotNull final PlayerInteractEvent event) { + Player player = event.getPlayer(); + + if (!event.getAction().equals(Action.LEFT_CLICK_BLOCK)) { + return; + } + + if (event.getClickedBlock() == null) { + return; + } + + if (!event.getClickedBlock().getType().equals(Material.DIRT)) { + return; + } + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (!AntigriefManager.canBreakBlock(player, event.getClickedBlock())) { + return; + } + + if (!AntigriefManager.canPlaceBlock(player, event.getClickedBlock())) { + return; + } + + if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "damage")) { + DurabilityUtils.damageItem(player, player.getInventory().getItemInMainHand(), 1, player.getInventory().getHeldItemSlot()); + } + + event.getClickedBlock().setType(Material.GRASS_BLOCK); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grit.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grit.java new file mode 100644 index 00000000..247205a9 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grit.java @@ -0,0 +1,58 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.util.DurabilityUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.inventory.meta.Damageable; +import org.jetbrains.annotations.NotNull; + +public class Grit extends EcoEnchant { + public Grit() { + super( + "grit", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onGritHurt(@NotNull final EntityDamageByEntityEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + + if (!(event.getDamager() instanceof Player)) { + return; + } + + Player player = (Player) event.getEntity(); + Player attacker = (Player) event.getDamager(); + + if (!AntigriefManager.canInjure(attacker, player)) { + return; + } + + int totalGritPoints = EnchantChecks.getArmorPoints(player, this, 0); + + if (totalGritPoints == 0) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (!(attacker.getInventory().getItemInMainHand() instanceof Damageable)) { + return; + } + + int damage = (int) Math.ceil(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * totalGritPoints); + + DurabilityUtils.damageItem(attacker, attacker.getInventory().getItemInMainHand(), damage, attacker.getInventory().getHeldItemSlot()); + } + +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hellish.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hellish.java new file mode 100644 index 00000000..b02b339b --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hellish.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.World; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Hellish extends EcoEnchant { + public Hellish() { + super( + "hellish", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!attacker.getWorld().getEnvironment().equals(World.Environment.NETHER)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hook.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hook.java new file mode 100644 index 00000000..f6209400 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hook.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Hook extends EcoEnchant { + public Hook() { + super( + "hook", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier"); + Vector vector = attacker.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier); + if (VectorUtils.isFinite(vector)) { + victim.setVelocity(vector); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Horde.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Horde.java new file mode 100644 index 00000000..9164aefe --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Horde.java @@ -0,0 +1,31 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Horde extends EcoEnchant { + public Horde() { + super( + "horde", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double distance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level") * level; + + int entitiesNearby = (int) attacker.getNearbyEntities(distance, distance, distance).stream().filter(entity -> entity instanceof LivingEntity).count(); + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier-per-level"); + multiplier = (1 + (level * multiplier * entitiesNearby)); + + event.setDamage(event.getDamage() * multiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IceShot.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IceShot.java new file mode 100644 index 00000000..0324ea6e --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IceShot.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class IceShot extends EcoEnchant { + public IceShot() { + super( + "ice_shot", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + victim.setVelocity(new Vector(0, 0, 0)); + victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 30, level)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Identify.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Identify.java new file mode 100644 index 00000000..95684921 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Identify.java @@ -0,0 +1,36 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Identify extends EcoEnchant { + public Identify() { + super( + "identify", EnchantmentType.NORMAL + ); + } + + @Override + public void onDeflect(@NotNull final Player blocker, + @NotNull final LivingEntity attacker, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + int finalDuration = duration * level; + + attacker.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, finalDuration, 1, false, false, false)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Ignite.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Ignite.java new file mode 100644 index 00000000..3ea0194e --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Ignite.java @@ -0,0 +1,53 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.jetbrains.annotations.NotNull; + +public class Ignite extends EcoEnchant { + public Ignite() { + super( + "ignite", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowHit(@NotNull final LivingEntity uncastShooter, + final int level, + @NotNull final ProjectileHitEvent event) { + if (!(uncastShooter instanceof Player)) { + return; + } + + if (event.getHitBlock() == null) { + return; + } + + Player shooter = (Player) uncastShooter; + if (!AntigriefManager.canBreakBlock(shooter, event.getHitBlock())) { + return; + } + + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + BlockFace face = event.getHitBlockFace(); + + assert face != null; + + Block toIgnite = event.getHitBlock().getRelative(face); + if (toIgnite.getType().equals(Material.AIR)) { + toIgnite.setType(Material.FIRE); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IllusionAspect.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IllusionAspect.java new file mode 100644 index 00000000..ead91aa4 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IllusionAspect.java @@ -0,0 +1,36 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class IllusionAspect extends EcoEnchant { + public IllusionAspect() { + super( + "illusion_aspect", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + victim.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, level * 10 + 15, level)); + victim.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, level * 10 + 15, level)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java new file mode 100644 index 00000000..cd8deb48 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Impact extends EcoEnchant { + public Impact() { + super( + "impact", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier")); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Incandescence.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Incandescence.java new file mode 100644 index 00000000..3a1c64f1 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Incandescence.java @@ -0,0 +1,58 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Incandescence extends EcoEnchant { + public Incandescence() { + super( + "incandescence", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onIncandescenceHurt(@NotNull final EntityDamageByEntityEvent event) { + if (event.getCause() == EntityDamageEvent.DamageCause.THORNS) { + return; + } + + if (!(event.getEntity() instanceof Player)) { + return; + } + + if (!(event.getDamager() instanceof LivingEntity)) { + return; + } + + Player player = (Player) event.getEntity(); + LivingEntity victim = (LivingEntity) event.getDamager(); + + int totalIncandescencePoints = EnchantChecks.getArmorPoints(player, this); + + if (totalIncandescencePoints == 0) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (!AntigriefManager.canInjure(player, victim)) { + return; + } + + this.getPlugin().getScheduler().runLater(() -> victim.setFireTicks(totalIncandescencePoints + * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-point") + + this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "initial-ticks")), + 1); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/InfernalTouch.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/InfernalTouch.java new file mode 100644 index 00000000..1a3e135e --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/InfernalTouch.java @@ -0,0 +1,131 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.drops.DropQueue; +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.core.tuples.Pair; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Container; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockDropItemEvent; +import org.bukkit.inventory.FurnaceRecipe; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class InfernalTouch extends EcoEnchant { + private static final HashMap> RECIPES = new HashMap<>(); + private static final Set FORTUNE_MATERIALS = new HashSet<>( + Arrays.asList( + Material.GOLD_INGOT, + Material.IRON_INGOT + ) + ); + + static { + Iterator iterator = Bukkit.recipeIterator(); + while (iterator.hasNext()) { + Recipe recipe = iterator.next(); + if (!(recipe instanceof FurnaceRecipe)) { + continue; + } + FurnaceRecipe furnaceRecipe = (FurnaceRecipe) recipe; + int xp = (int) Math.ceil(furnaceRecipe.getExperience()); + RECIPES.put(furnaceRecipe.getInput().getType(), new Pair<>(furnaceRecipe.getResult().getType(), xp)); + } + } + + public InfernalTouch() { + super( + "infernal_touch", EnchantmentType.NORMAL + ); + } + + @NotNull + private static Pair getOutput(@NotNull final Material input) { + Pair toReturn = RECIPES.get(input); + if (toReturn == null) { + return new Pair<>(input, 0); + } + return toReturn; + } + + @EventHandler + public void infernalTouchBreak(@NotNull final BlockDropItemEvent event) { + Player player = event.getPlayer(); + Block block = event.getBlock(); + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) { + return; + } + + if (event.getBlockState() instanceof Container) { + return; + } + + if (event.isCancelled()) { + return; + } + + if (!AntigriefManager.canBreakBlock(player, block)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + Collection drops = new ArrayList<>(); + + for (Item item : event.getItems()) { + drops.add(item.getItemStack()); + } + + int experience = 0; + int fortune = EnchantChecks.getMainhandLevel(player, Enchantment.LOOT_BONUS_BLOCKS); + + for (ItemStack itemStack : drops) { + Pair out = getOutput(itemStack.getType()); + itemStack.setType(out.getFirst()); + experience += out.getSecond(); + + if (fortune > 0 && FORTUNE_MATERIALS.contains(itemStack.getType())) { + itemStack.setAmount((int) Math.round((Math.random() * ((double) fortune - 1)) + 1.1)); + experience++; + } + } + + event.getItems().clear(); + + if (!this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "drop-xp")) { + experience = 0; + } + + new DropQueue(player) + .setLocation(block.getLocation()) + .addItems(drops) + .addXP(experience) + .push(); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Inferno.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Inferno.java new file mode 100644 index 00000000..22353798 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Inferno.java @@ -0,0 +1,38 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.jetbrains.annotations.NotNull; + +public class Inferno extends EcoEnchant { + public Inferno() { + super( + "inferno", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentLaunch(@NotNull final LivingEntity shooter, + @NotNull final Trident trident, + final int level, + final @NotNull ProjectileLaunchEvent event) { + trident.setFireTicks(Integer.MAX_VALUE); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (trident.getFireTicks() <= 0) { + return; + } + + victim.setFireTicks(100); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java new file mode 100644 index 00000000..19979274 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java @@ -0,0 +1,54 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.PigZombie; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Infuriate extends EcoEnchant { + public Infuriate() { + super( + "infuriate", EnchantmentType.NORMAL + ); + } + + @Override + public void onDeflect(@NotNull final Player blocker, + @NotNull final LivingEntity attacker, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + double distancePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level"); + final double distance = distancePerLevel * level; + + for (Entity e : attacker.getWorld().getNearbyEntities(attacker.getLocation(), distance, distance, distance)) { + if (!(e instanceof Monster)) { + continue; + } + + if (e instanceof PigZombie) { + ((PigZombie) e).setAngry(true); + } + + ((Monster) e).setTarget(attacker); + + Vector vector = attacker.getLocation().toVector().clone().subtract(e.getLocation().toVector()).normalize().multiply(0.23d); + + if (VectorUtils.isFinite(vector)) { + e.setVelocity(vector); + } + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Insecticide.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Insecticide.java new file mode 100644 index 00000000..83457511 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Insecticide.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Spider; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Insecticide extends EcoEnchant { + public Insecticide() { + super( + "insecticide", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Spider)) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = (multiplier * (level + 1)) + 1; + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java new file mode 100644 index 00000000..c509bc4c --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java @@ -0,0 +1,38 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.anticheat.AnticheatManager; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Instantaneous extends EcoEnchant { + public Instantaneous() { + super( + "instantaneous", EnchantmentType.NORMAL + ); + } + + @Override + public void onDamageBlock(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockDamageEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + if (block.getDrops(player.getInventory().getItemInMainHand()).isEmpty()) { + return; + } + + AnticheatManager.exemptPlayer(player); + + event.setInstaBreak(true); + + AnticheatManager.unexemptPlayer(player); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Introversion.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Introversion.java new file mode 100644 index 00000000..7e7bee50 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Introversion.java @@ -0,0 +1,30 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Introversion extends EcoEnchant { + public Introversion() { + super( + "introversion", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Player)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level"); + event.setDamage(event.getDamage() + (level * multiplier)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Invigoration.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Invigoration.java new file mode 100644 index 00000000..6c7c72f0 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Invigoration.java @@ -0,0 +1,72 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Invigoration extends EcoEnchant { + public Invigoration() { + super( + "invigoration", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onInvigorationHurt(@NotNull final EntityDamageEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + + Player player = (Player) event.getEntity(); + + if (player.getHealth() > this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "below-health")) { + return; + } + + int totalInvigorationPoints = EnchantChecks.getArmorPoints(player, this, 0); + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (totalInvigorationPoints == 0) { + return; + } + + double damageReduction = totalInvigorationPoints * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "reduction-multiplier") * 0.01; + damageReduction += 1; + event.setDamage(event.getDamage() * damageReduction); + } + + @EventHandler + public void onInvigorationDamage(@NotNull final EntityDamageByEntityEvent event) { + if (!(event.getDamager() instanceof Player)) { + return; + } + + Player player = (Player) event.getDamager(); + + if (player.getHealth() > this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "below-health")) { + return; + } + + int totalInvigorationPoints = EnchantChecks.getArmorPoints(player, this, 0); + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (totalInvigorationPoints == 0) { + return; + } + + double damageBonus = totalInvigorationPoints * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier") * 0.01; + damageBonus += 1; + event.setDamage(event.getDamage() * damageBonus); + } + +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Kinetic.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Kinetic.java new file mode 100644 index 00000000..033f3818 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Kinetic.java @@ -0,0 +1,29 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Kinetic extends EcoEnchant { + public Kinetic() { + super( + "kinetic", EnchantmentType.NORMAL + ); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + if (!event.getCause().equals(EntityDamageEvent.DamageCause.FLY_INTO_WALL)) { + return; + } + + double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "reduction-per-level"); + double multiplier = 1 - ((reduction / 100) * level); + event.setDamage(event.getDamage() * multiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Launch.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Launch.java new file mode 100644 index 00000000..83402c7e --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Launch.java @@ -0,0 +1,56 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.jetbrains.annotations.NotNull; + +public class Launch extends EcoEnchant { + public Launch() { + super( + "launch", EnchantmentType.NORMAL + ); + } + + // START OF LISTENERS + @EventHandler + public void onFireworkUse(@NotNull final PlayerInteractEvent event) { + if (event.getItem() == null) { + return; + } + + if (!event.getItem().getType().equals(Material.FIREWORK_ROCKET)) { + return; + } + + if (!event.getAction().equals(Action.RIGHT_CLICK_AIR)) { + return; + } + + Player player = event.getPlayer(); + + if (!player.isGliding()) { + return; + } + + if (!EnchantChecks.chestplate(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int level = EnchantChecks.getChestplateLevel(player, this); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double boost = 1 + (multiplier * level); + + this.getPlugin().getScheduler().run(() -> player.setVelocity(player.getVelocity().multiply(boost))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Leeching.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Leeching.java new file mode 100644 index 00000000..36572d15 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Leeching.java @@ -0,0 +1,36 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Leeching extends EcoEnchant { + public Leeching() { + super( + "leeching", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level"); + double amountToHeal = level * multiplier; + double newHealth = attacker.getHealth() + amountToHeal; + if (newHealth > attacker.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { + newHealth = attacker.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); + } + attacker.setHealth(newHealth); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lesion.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lesion.java new file mode 100644 index 00000000..b0410c9f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lesion.java @@ -0,0 +1,49 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.atomic.AtomicInteger; + +public class Lesion extends EcoEnchant { + public Lesion() { + super( + "lesion", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + double bleedDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bleed-damage"); + + int bleedCount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "amount-per-level"); + bleedCount *= level; + final int finalBleedCount = bleedCount; + + AtomicInteger currentBleedCount = new AtomicInteger(0); + + this.getPlugin().getRunnableFactory().create(bukkitRunnable -> { + currentBleedCount.addAndGet(1); + + victim.damage(bleedDamage); + + if (currentBleedCount.get() >= finalBleedCount) { + bukkitRunnable.cancel(); + } + }).runTaskTimer(0, 10); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Levitate.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Levitate.java new file mode 100644 index 00000000..2f6f3ab1 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Levitate.java @@ -0,0 +1,37 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Levitate extends EcoEnchant { + public Levitate() { + super( + "levitate", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level"); + + victim.setVelocity(new Vector(0, 0, 0)); + victim.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, duration * level, 0)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LiquidShot.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LiquidShot.java new file mode 100644 index 00000000..07065e2d --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LiquidShot.java @@ -0,0 +1,37 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Blaze; +import org.bukkit.entity.Enderman; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.MagmaCube; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class LiquidShot extends EcoEnchant { + public LiquidShot() { + super( + "liquid_shot", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Blaze || victim instanceof MagmaCube || victim instanceof Enderman)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + double damageMultiplier = (level * multiplier) + 1; + + event.setDamage(event.getDamage() * damageMultiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LuckyCatch.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LuckyCatch.java new file mode 100644 index 00000000..422cf375 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LuckyCatch.java @@ -0,0 +1,55 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public class LuckyCatch extends EcoEnchant { + public LuckyCatch() { + super( + "lucky_catch", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onFish(@NotNull final PlayerFishEvent event) { + Player player = event.getPlayer(); + ItemStack item = player.getInventory().getItemInMainHand(); + + if (!EnchantChecks.item(item, this)) { + return; + } + + if (event.getState() == PlayerFishEvent.State.CAUGHT_ENTITY) { + return; + } + + int level = EnchantChecks.getItemLevel(item, this); + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + Entity caught = event.getCaught(); + + if (!(caught instanceof Item)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + Item caughtItem = (Item) caught; + + caughtItem.getItemStack().setAmount(caughtItem.getItemStack().getAmount() * 2); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lumberjack.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lumberjack.java new file mode 100644 index 00000000..e5991c36 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lumberjack.java @@ -0,0 +1,66 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.anticheat.AnticheatManager; +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.util.BlockUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +public class Lumberjack extends EcoEnchant { + public Lumberjack() { + super( + "lumberjack", EnchantmentType.NORMAL + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + if (block.hasMetadata("block-ignore")) { + return; + } + + if (player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) { + return; + } + + List materials = new ArrayList<>(); + this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "whitelisted-blocks").forEach(name -> materials.add(Material.getMaterial(name.toUpperCase()))); + + if (!materials.contains(block.getType())) { + return; + } + + int blocksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "blocks-per-level"); + int limit = level * blocksPerLevel; + + Set treeBlocks = BlockUtils.getVein(block, materials, limit); + + AnticheatManager.exemptPlayer(player); + + for (Block treeBlock : treeBlocks) { + treeBlock.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true)); + if (!AntigriefManager.canBreakBlock(player, treeBlock)) { + continue; + } + + BlockUtils.breakBlock(player, treeBlock); + + this.getPlugin().getScheduler().runLater(() -> treeBlock.removeMetadata("block-ignore", this.getPlugin()), 1); + } + + AnticheatManager.unexemptPlayer(player); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/MagmaWalker.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/MagmaWalker.java new file mode 100644 index 00000000..a99f19ce --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/MagmaWalker.java @@ -0,0 +1,101 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.anticheat.AnticheatManager; +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.core.scheduling.RunnableTask; +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.data.Levelled; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class MagmaWalker extends EcoEnchant { + public MagmaWalker() { + super( + "magma_walker", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onLavaWalk(@NotNull final PlayerMoveEvent event) { + Player player = event.getPlayer(); + + if (event.getTo() == null) { + return; + } + + if (event.getFrom().getBlock().equals(event.getTo().getBlock())) { + return; + } + + if (!EnchantChecks.boots(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + Vector[] circle = VectorUtils.getCircle(this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "initial-radius") + + (this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "per-level-radius") * EnchantChecks.getBootsLevel(player, this) - 1)); + + AnticheatManager.exemptPlayer(player); + + for (Vector vector : circle) { + Location loc = player.getLocation().add(vector).add(0, -1, 0); + + Block block = player.getWorld().getBlockAt(loc); + + if (!AntigriefManager.canPlaceBlock(player, player.getWorld().getBlockAt(loc))) { + continue; + } + + if (!block.getType().equals(Material.LAVA)) { + continue; + } + + Levelled data = (Levelled) block.getBlockData(); + + if (data.getLevel() != 0) { + continue; + } + + block.setType(Material.OBSIDIAN); + + block.setMetadata("byMagmaWalker", this.getPlugin().getMetadataValueFactory().create(true)); + + long afterTicks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "remove-after-ticks"); + + RunnableTask replace = this.getPlugin().getRunnableFactory().create(bukkitRunnable -> { + if (block.getType().equals(Material.OBSIDIAN) && !player.getWorld().getBlockAt(player.getLocation().add(0, -1, 0)).equals(block)) { + block.setType(Material.LAVA); + block.removeMetadata("byMagmaWalker", this.getPlugin()); + bukkitRunnable.cancel(); + } + }); + + this.getPlugin().getScheduler().runLater(() -> { + if (block.getType().equals(Material.OBSIDIAN)) { + if (!player.getWorld().getBlockAt(player.getLocation().add(0, -1, 0)).equals(block)) { + block.setType(Material.LAVA); + block.removeMetadata("byMagmaWalker", this.getPlugin()); + } else { + replace.runTaskTimer(afterTicks, afterTicks); + } + } + }, afterTicks); + } + + AnticheatManager.unexemptPlayer(player); + } + +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java new file mode 100644 index 00000000..33f16750 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java @@ -0,0 +1,90 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.events.ArmorEquipEvent; +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.TimedRunnable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.ExperienceOrb; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +import java.util.HashMap; + +public class Magnetic extends EcoEnchant implements TimedRunnable { + private final HashMap players = new HashMap<>(); + private double initialDistance = 1; + private double bonus = 1; + + public Magnetic() { + super( + "magnetic", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onArmorEquip(@NotNull final ArmorEquipEvent event) { + refresh(); + } + + @EventHandler + public void onPlayerJoin(@NotNull final PlayerJoinEvent event) { + refresh(); + } + + @EventHandler + public void onPlayerLeave(@NotNull final PlayerQuitEvent event) { + refresh(); + } + + private void refresh() { + players.clear(); + this.getPlugin().getScheduler().runLater(() -> this.getPlugin().getServer().getOnlinePlayers().forEach(player -> { + int level = EnchantChecks.getArmorPoints(player, this, 0); + if (level > 0) { + players.put(player, level); + } + }), 1); + initialDistance = EcoEnchants.MAGNETIC.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance"); + bonus = EcoEnchants.MAGNETIC.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level"); + } + + @Override + public void run() { + players.forEach((player, level) -> { + double distance = initialDistance + (level * bonus); + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + for (Entity e : player.getWorld().getNearbyEntities(player.getLocation(), distance, 2.0d, distance)) { + if (!(e instanceof Item || e instanceof ExperienceOrb)) { + continue; + } + + if (e instanceof Item && ((Item) e).getPickupDelay() > 0) { + continue; + } + + Vector vector = player.getLocation().toVector().subtract(e.getLocation().toVector()).normalize().multiply(0.1 * level); + + if (VectorUtils.isFinite(vector)) { + e.setVelocity(vector); + } + } + }); + } + + @Override + public long getTime() { + return this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "repeat-ticks"); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marking.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marking.java new file mode 100644 index 00000000..b56d0f41 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marking.java @@ -0,0 +1,48 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Marking extends EcoEnchant { + public Marking() { + super( + "marking", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); + int ticks = ticksPerLevel * level; + + victim.setMetadata("marked", this.getPlugin().getMetadataValueFactory().create(true)); + + this.getPlugin().getScheduler().runLater(() -> victim.removeMetadata("marked", this.getPlugin()), ticks); + } + + @EventHandler + public void onHitWhileMarked(@NotNull final EntityDamageEvent event) { + if (!(event.getEntity() instanceof LivingEntity)) { + return; + } + + LivingEntity victim = (LivingEntity) event.getEntity(); + + if (!victim.hasMetadata("marked")) { + return; + } + + event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier-while-weak")); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marksman.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marksman.java new file mode 100644 index 00000000..619506a9 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marksman.java @@ -0,0 +1,48 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.jetbrains.annotations.NotNull; + +public class Marksman extends EcoEnchant { + public Marksman() { + super( + "marksman", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onMarksmanShoot(@NotNull final ProjectileLaunchEvent event) { + + if (!(event.getEntity().getShooter() instanceof Player)) { + return; + } + + Player player = (Player) event.getEntity().getShooter(); + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + Projectile a = event.getEntity(); + a.setGravity(false); + + int ticks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "remove-arrow-after-ticks"); + + this.getPlugin().getScheduler().runLater(() -> { + if (!a.isOnGround()) { + a.remove(); + } + }, ticks); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java new file mode 100644 index 00000000..57d26ce0 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java @@ -0,0 +1,58 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.drops.DropQueue; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.entity.WitherSkeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public class Necrotic extends EcoEnchant { + public Necrotic() { + super( + "necrotic", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void necroticKill(@NotNull final EntityDeathEvent event) { + if (event.getEntity().getKiller() == null) { + return; + } + + if (!(event.getEntity() instanceof WitherSkeleton)) { + return; + } + + Player player = event.getEntity().getKiller(); + WitherSkeleton victim = (WitherSkeleton) event.getEntity(); + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + ItemStack item = new ItemStack(Material.WITHER_SKELETON_SKULL, 1); + + new DropQueue(player) + .addItem(item) + .setLocation(victim.getLocation()) + .addXP(event.getDroppedExp()) + .push(); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/NetherInfusion.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/NetherInfusion.java new file mode 100644 index 00000000..5b3e737b --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/NetherInfusion.java @@ -0,0 +1,31 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.World; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class NetherInfusion extends EcoEnchant { + public NetherInfusion() { + super( + "nether_infusion", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!attacker.getWorld().getEnvironment().equals(World.Environment.NETHER)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Netheric.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Netheric.java new file mode 100644 index 00000000..106d5718 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Netheric.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.World; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Netheric extends EcoEnchant { + public Netheric() { + super( + "netheric", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!attacker.getWorld().getEnvironment().equals(World.Environment.NETHER)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Nocturnal.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Nocturnal.java new file mode 100644 index 00000000..0d3818f4 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Nocturnal.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.World; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Nocturnal extends EcoEnchant { + public Nocturnal() { + super( + "nocturnal", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!attacker.getWorld().getEnvironment().equals(World.Environment.NORMAL)) { + return; + } + + if (!(attacker.getWorld().getTime() > 12300 && attacker.getWorld().getTime() < 23850)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Optics.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Optics.java new file mode 100644 index 00000000..cbbd8210 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Optics.java @@ -0,0 +1,36 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.Location; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Optics extends EcoEnchant { + public Optics() { + super( + "optics", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + Location land = arrow.getLocation(); + Location source = attacker.getLocation(); + + double distance = land.distance(source); + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "block-multiplier"); + + double damageMultiplier = (distance * level * multiplier) + 1; + + event.setDamage(event.getDamage() * damageMultiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Oxygenate.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Oxygenate.java new file mode 100644 index 00000000..3a0bc066 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Oxygenate.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.jetbrains.annotations.NotNull; + +public class Oxygenate extends EcoEnchant { + public Oxygenate() { + super( + "oxygenate", EnchantmentType.NORMAL + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + if (player.getRemainingAir() == player.getMaximumAir()) { + return; + } + + int oxygenLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "oxygen-per-level"); + int oxygen = level * oxygenLevel; + int newOxygen = player.getRemainingAir() + oxygen; + newOxygen = NumberUtils.equalIfOver(newOxygen, player.getMaximumAir()); + + player.setRemainingAir(newOxygen); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Pacify.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Pacify.java new file mode 100644 index 00000000..57ffccc7 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Pacify.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Pacify extends EcoEnchant { + public Pacify() { + super( + "pacify", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Creeper)) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = (multiplier * (level + 1)) + 1; + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paladin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paladin.java new file mode 100644 index 00000000..971b4bb7 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paladin.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Horse; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Paladin extends EcoEnchant { + public Paladin() { + super( + "paladin", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(attacker.getVehicle() instanceof Horse)) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level); + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paralyze.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paralyze.java new file mode 100644 index 00000000..f711475f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paralyze.java @@ -0,0 +1,36 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Paralyze extends EcoEnchant { + public Paralyze() { + super( + "paralyze", EnchantmentType.NORMAL + ); + } + + @Override + public void onDeflect(@NotNull final Player blocker, + @NotNull final LivingEntity attacker, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + int finalDuration = duration * level; + + attacker.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, finalDuration, 10, false, false, false)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parasitic.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parasitic.java new file mode 100644 index 00000000..2b6f30ae --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parasitic.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Parasitic extends EcoEnchant { + public Parasitic() { + super( + "parasitic", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level"); + double amountToHeal = level * multiplier; + double newHealth = attacker.getHealth() + amountToHeal; + if (newHealth > attacker.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { + newHealth = attacker.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); + } + attacker.setHealth(newHealth); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parry.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parry.java new file mode 100644 index 00000000..cece6cd3 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parry.java @@ -0,0 +1,46 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Parry extends EcoEnchant { + public Parry() { + super( + "parry", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void parryHit(@NotNull final EntityDamageByEntityEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + + if (event.isCancelled()) { + return; + } + + Player player = (Player) event.getEntity(); + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 - (multiplier * level); + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Phantasm.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Phantasm.java new file mode 100644 index 00000000..7e4253cc --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Phantasm.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Trident; +import org.bukkit.entity.Zombie; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Phantasm extends EcoEnchant { + public Phantasm() { + super( + "phantasm", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Zombie || victim instanceof Skeleton)) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = (multiplier * (level + 1)) + 1; + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Plasmic.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Plasmic.java new file mode 100644 index 00000000..707cfc8a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Plasmic.java @@ -0,0 +1,66 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; + +public class Plasmic extends EcoEnchant { + private static final Material[] ITEMS; + + static { + ITEMS = new Material[]{ + Material.DIAMOND_HELMET, + Material.DIAMOND_CHESTPLATE, + Material.DIAMOND_LEGGINGS, + Material.DIAMOND_BOOTS, + + Material.NETHERITE_HELMET, + Material.NETHERITE_CHESTPLATE, + Material.NETHERITE_LEGGINGS, + Material.NETHERITE_BOOTS + }; + } + + public Plasmic() { + super( + "plasmic", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + EntityEquipment equipment = victim.getEquipment(); + if (equipment == null) { + return; + } + + int pieces = 0; + for (ItemStack armorPiece : equipment.getArmorContents()) { + if (armorPiece == null) { + continue; + } + if (Arrays.asList(ITEMS).contains(armorPiece.getType())) { + pieces++; + } + } + + if (pieces == 0) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + event.setDamage(event.getDamage() * (1 + (level * multiplier * pieces))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Protector.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Protector.java new file mode 100644 index 00000000..df067057 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Protector.java @@ -0,0 +1,36 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Tameable; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Protector extends EcoEnchant { + public Protector() { + super( + "protector", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity uncastVictim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(uncastVictim instanceof Tameable)) { + return; + } + + Tameable victim = (Tameable) uncastVictim; + if (victim.getOwner() == null) { + return; + } + if (!victim.getOwner().equals(attacker)) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Proximity.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Proximity.java new file mode 100644 index 00000000..c966275f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Proximity.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Proximity extends EcoEnchant { + public Proximity() { + super( + "proximity", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double distance = attacker.getLocation().distance(victim.getLocation()); + + double decreaseAfter = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "when-closer-than-blocks"); + + if (distance > decreaseAfter) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level); + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Puncture.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Puncture.java new file mode 100644 index 00000000..4384c74e --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Puncture.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Shulker; +import org.bukkit.entity.Trident; +import org.bukkit.entity.Turtle; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Puncture extends EcoEnchant { + public Puncture() { + super( + "puncture", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Turtle || victim instanceof Shulker)) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level); + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Quadrilateralism.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Quadrilateralism.java new file mode 100644 index 00000000..414691ec --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Quadrilateralism.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Slime; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Quadrilateralism extends EcoEnchant { + public Quadrilateralism() { + super( + "quadrilateralism", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Slime)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + double damageMultiplier = (level * multiplier) + 1; + + event.setDamage(event.getDamage() * damageMultiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Radiance.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Radiance.java new file mode 100644 index 00000000..f2f969df --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Radiance.java @@ -0,0 +1,47 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Radiance extends EcoEnchant { + public Radiance() { + super( + "radiance", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double radius = level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-multiplier"); + int duration = level * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level"); + + for (Entity e : arrow.getNearbyEntities(radius, radius, radius)) { + if (e.hasMetadata("NPC")) { + continue; + } + + if (!(e instanceof LivingEntity)) { + continue; + } + LivingEntity entity = (LivingEntity) e; + + if (e.equals(attacker)) { + continue; + } + + entity.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, duration, 0, false, false, false)); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java new file mode 100644 index 00000000..c1782869 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java @@ -0,0 +1,55 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.PigZombie; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Rage extends EcoEnchant { + public Rage() { + super( + "rage", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + double distancePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level"); + final double distance = distancePerLevel * level; + + for (Entity e : victim.getWorld().getNearbyEntities(victim.getLocation(), distance, distance, distance)) { + if (!(e instanceof Monster)) { + continue; + } + + if (e instanceof PigZombie) { + ((PigZombie) e).setAngry(true); + } + + ((Monster) e).setTarget(victim); + + Vector vector = attacker.getLocation().toVector().clone().subtract(e.getLocation().toVector()).normalize().multiply(0.23d); + + if (VectorUtils.isFinite(vector)) { + e.setVelocity(vector); + } + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rapid.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rapid.java new file mode 100644 index 00000000..9841544e --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rapid.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.jetbrains.annotations.NotNull; + +public class Rapid extends EcoEnchant { + public Rapid() { + super( + "rapid", EnchantmentType.NORMAL + ); + } + + @Override + public void onBowShoot(@NotNull final LivingEntity shooter, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityShootBowEvent event) { + double multiplier = 1 - ((this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-faster-per-level") / 100) * level); + + if (event.getForce() < multiplier) { + return; + } + + double force = 1 / event.getForce(); + event.getProjectile().setVelocity(event.getProjectile().getVelocity().multiply(force)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reaper.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reaper.java new file mode 100644 index 00000000..52abe244 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reaper.java @@ -0,0 +1,14 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; + +public class Reaper extends EcoEnchant { + public Reaper() { + super( + "reaper", EnchantmentType.NORMAL + ); + } + + // Actual code is in soulbound. +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rebounding.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rebounding.java new file mode 100644 index 00000000..1da6bd04 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rebounding.java @@ -0,0 +1,63 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Rebounding extends EcoEnchant { + public Rebounding() { + super( + "rebounding", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onDamage(@NotNull final EntityDamageByEntityEvent event) { + if (!(event.getEntity() instanceof LivingEntity)) { + return; + } + + if (!(event.getDamager() instanceof LivingEntity)) { + return; + } + + if (event.isCancelled()) { + return; + } + + LivingEntity victim = (LivingEntity) event.getEntity(); + LivingEntity attacker = (LivingEntity) event.getDamager(); + + int level = EnchantChecks.getArmorPoints(victim, this); + + if (level == 0) { + return; + } + + if (this.getDisabledWorlds().contains(attacker.getWorld())) { + return; + } + + Vector vector = attacker.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize() + .multiply((level * (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier") - 1)) + 1); + + if (!VectorUtils.isFinite(vector)) { + return; + } + + vector.setY(0.2); + + if (!VectorUtils.isFinite(vector)) { + return; + } + + attacker.setVelocity(vector); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reel.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reel.java new file mode 100644 index 00000000..dff5d409 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reel.java @@ -0,0 +1,61 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Reel extends EcoEnchant { + public Reel() { + super( + "reel", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onFish(@NotNull final PlayerFishEvent event) { + if (!event.getState().equals(PlayerFishEvent.State.CAUGHT_ENTITY)) { + return; + } + + if (!(event.getCaught() instanceof LivingEntity)) { + return; + } + + Player player = event.getPlayer(); + + LivingEntity victim = (LivingEntity) event.getCaught(); + + if (victim.hasMetadata("NPC")) { + return; + } + + if (!AntigriefManager.canInjure(player, victim)) { + return; + } + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + + double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier"); + Vector vector = player.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier); + if (VectorUtils.isFinite(vector)) { + victim.setVelocity(vector); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reinforcement.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reinforcement.java new file mode 100644 index 00000000..ad4bc6d8 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reinforcement.java @@ -0,0 +1,29 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Reinforcement extends EcoEnchant { + public Reinforcement() { + super( + "reinforcement", EnchantmentType.NORMAL + ); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + if (event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) { + return; + } + + double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "reduction-per-level"); + double multiplier = 1 - ((reduction / 100) * level); + event.setDamage(event.getDamage() * multiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rejuvenation.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rejuvenation.java new file mode 100644 index 00000000..8b679236 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rejuvenation.java @@ -0,0 +1,46 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.jetbrains.annotations.NotNull; + +public class Rejuvenation extends EcoEnchant { + public Rejuvenation() { + super( + "rejuvenation", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onRejuvenationHeal(@NotNull final EntityRegainHealthEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + + if (!event.getRegainReason().equals(EntityRegainHealthEvent.RegainReason.SATIATED) && !event.getRegainReason().equals(EntityRegainHealthEvent.RegainReason.REGEN)) { + return; + } + + Player player = (Player) event.getEntity(); + + int totalRejuvenationPoints = EnchantChecks.getArmorPoints(player, this, 0); + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (totalRejuvenationPoints == 0) { + return; + } + + double amount = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "per-point-multiplier"); + amount = amount * totalRejuvenationPoints; + amount += 1; + + event.setAmount(event.getAmount() * amount); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Replenish.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Replenish.java new file mode 100644 index 00000000..b7f107f6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Replenish.java @@ -0,0 +1,54 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.data.Ageable; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.jetbrains.annotations.NotNull; + +public class Replenish extends EcoEnchant { + public Replenish() { + super( + "replenish", EnchantmentType.NORMAL + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + Material type = block.getType(); + + if (!(block.getBlockData() instanceof Ageable)) { + return; + } + + if (block.getType().equals(Material.SUGAR_CANE) || block.getType().equals(Material.SWEET_BERRY_BUSH)) { + return; + } + + Ageable data = (Ageable) block.getBlockData(); + if (data.getAge() != data.getMaximumAge()) { + event.setDropItems(false); + event.setExpToDrop(0); + + data.setAge(0); + + this.getPlugin().getScheduler().runLater(() -> { + block.setType(type); + block.setBlockData(data); + }, 1); + } + + data.setAge(0); + + this.getPlugin().getScheduler().runLater(() -> { + block.setType(type); + block.setBlockData(data); + }, 1); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Respirator.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Respirator.java new file mode 100644 index 00000000..48b0c627 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Respirator.java @@ -0,0 +1,31 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Respirator extends EcoEnchant { + public Respirator() { + super( + "respirator", EnchantmentType.NORMAL + ); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + final @NotNull EntityDamageEvent event) { + if (!event.getCause().equals(EntityDamageEvent.DamageCause.DRAGON_BREATH)) { + return; + } + + double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-less-per-level"); + + double multiplier = 1 - ((reduction / 100) * level); + + event.setDamage(event.getDamage() * multiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Revenant.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Revenant.java new file mode 100644 index 00000000..a214959f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Revenant.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Zombie; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Revenant extends EcoEnchant { + public Revenant() { + super( + "revenant", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Zombie || victim instanceof Skeleton)) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = (multiplier * (level + 1)) + 1; + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sating.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sating.java new file mode 100644 index 00000000..61b0cb7f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sating.java @@ -0,0 +1,47 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.jetbrains.annotations.NotNull; + +public class Sating extends EcoEnchant { + public Sating() { + super( + "sating", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onSatingHunger(@NotNull final FoodLevelChangeEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + + Player player = (Player) event.getEntity(); + + if (!EnchantChecks.helmet(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (event.getFoodLevel() > player.getFoodLevel()) { + return; + } + + int level = EnchantChecks.getHelmetLevel(player, this); + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Serrated.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Serrated.java new file mode 100644 index 00000000..ef3ec479 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Serrated.java @@ -0,0 +1,29 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Serrated extends EcoEnchant { + public Serrated() { + super( + "serrated", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level); + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Settle.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Settle.java new file mode 100644 index 00000000..c744f4fb --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Settle.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Settle extends EcoEnchant { + public Settle() { + super( + "settle", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Creeper)) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = (multiplier * (level + 1)) + 1; + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Shockwave.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Shockwave.java new file mode 100644 index 00000000..425f0b71 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Shockwave.java @@ -0,0 +1,75 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.util.TridentUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.AbstractArrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Trident; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public class Shockwave extends EcoEnchant { + public Shockwave() { + super( + "shockwave", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onShoot(@NotNull final ProjectileLaunchEvent event) { + if (!(event.getEntity() instanceof AbstractArrow)) { + return; + } + + if (!(event.getEntity().getShooter() instanceof Player)) { + return; + } + + Player player = (Player) event.getEntity().getShooter(); + + AbstractArrow entity = (AbstractArrow) event.getEntity(); + ItemStack item = player.getInventory().getItemInMainHand(); + if (entity instanceof Trident) { + item = TridentUtils.getItemStack((Trident) entity); + } + + if (!EnchantChecks.item(item, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int ticks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "particle-tick-delay"); + + int level = EnchantChecks.getMainhandLevel(player, this); + double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level"); + damage *= level; + final double finalDamage = damage; + + this.getPlugin().getRunnableFactory().create(runnable -> { + if (entity.isOnGround() || entity.isInBlock() || entity.isDead()) { + runnable.cancel(); + } + entity.getNearbyEntities(1.5, 1.5, 1.5).stream() + .filter(entity1 -> entity1 instanceof LivingEntity) + .filter(entity1 -> entity1 != player) + .filter(entity1 -> !entity1.hasMetadata("shockwaved")) + .filter(entity1 -> AntigriefManager.canInjure(player, (LivingEntity) entity1)) + .forEach((mob -> { + ((LivingEntity) mob).damage(finalDamage, entity); + mob.setMetadata("shockwaved", this.getPlugin().getMetadataValueFactory().create(true)); + this.getPlugin().getScheduler().runLater(() -> mob.removeMetadata("shockwaved", this.getPlugin()), 10); + } + )); + }).runTaskTimer(4, ticks); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/ShotAssist.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/ShotAssist.java new file mode 100644 index 00000000..40fbb1ee --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/ShotAssist.java @@ -0,0 +1,58 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class ShotAssist extends EcoEnchant { + public ShotAssist() { + super( + "shot_assist", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onHit(@NotNull final EntityDamageByEntityEvent event) { + if (!(event.getDamager() instanceof Arrow)) { + return; + } + + if (!(((Arrow) event.getDamager()).getShooter() instanceof Player)) { + return; + } + + if (!(event.getEntity() instanceof LivingEntity)) { + return; + } + + if (event.isCancelled()) { + return; + } + + Player player = (Player) ((Arrow) event.getDamager()).getShooter(); + + assert player != null; + + int points = EnchantChecks.getArmorPoints(player, this, 0); + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (points == 0) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double reduction = 1 + (multiplier * points); + event.setDamage(damage * reduction); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sickening.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sickening.java new file mode 100644 index 00000000..85d3b246 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sickening.java @@ -0,0 +1,37 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Sickening extends EcoEnchant { + public Sickening() { + super( + "sickening", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level"); + + victim.setVelocity(new Vector(0, 0, 0)); + victim.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, duration * level, level)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slaughter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slaughter.java new file mode 100644 index 00000000..22f9ac78 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slaughter.java @@ -0,0 +1,39 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Slaughter extends EcoEnchant { + public Slaughter() { + super( + "slaughter", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (victim instanceof Monster) { + return; + } + + if (victim instanceof Player) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = (multiplier * (level + 1)) + 1; + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slicing.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slicing.java new file mode 100644 index 00000000..eac25ea6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slicing.java @@ -0,0 +1,66 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.DurabilityUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.Bukkit; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerMoveEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; + +public class Slicing extends EcoEnchant { + private final ArrayList entities = new ArrayList<>(); + + public Slicing() { + super( + "slicing", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onPlayerCollide(@NotNull final PlayerMoveEvent event) { + Player player = event.getPlayer(); + + if (!player.isGliding()) { + return; + } + + if (!EnchantChecks.chestplate(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + for (Entity entity : player.getNearbyEntities(1, 1, 1)) { + LivingEntity victim; + if (entity instanceof LivingEntity) { + victim = (LivingEntity) entity; + } else { + continue; + } + + if (entities.contains(victim)) { + continue; + } + + double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level"); + int level = EnchantChecks.getMainhandLevel(player, this); + victim.damage(level * damage, player); + entities.add(victim); + + Bukkit.getServer().getScheduler().runTaskLater(this.getPlugin(), () -> entities.remove(victim), this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "cooldown")); + if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "damage-elytra")) { + DurabilityUtils.damageItem(player, player.getInventory().getChestplate(), 1, 38); + } + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spearfishing.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spearfishing.java new file mode 100644 index 00000000..3c5d6b71 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spearfishing.java @@ -0,0 +1,91 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.drops.DropQueue; +import com.willfp.eco.util.NumberUtils; +import com.willfp.eco.util.TridentUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Trident; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Random; + +public class Spearfishing extends EcoEnchant { + public Spearfishing() { + super( + "spearfishing", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onSpearfishingLand(@NotNull final ProjectileHitEvent event) { + if (event.getEntityType() != EntityType.TRIDENT) { + return; + } + + if (!(event.getEntity().getShooter() instanceof Player)) { + return; + } + + if (!(event.getEntity() instanceof Trident)) { + return; + } + + Trident trident = (Trident) event.getEntity(); + + if (!trident.getWorld().getBlockAt(trident.getLocation().add(0, 0.2, 0)).getType().equals(Material.WATER)) { + return; + } + + Player player = (Player) event.getEntity().getShooter(); + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + ItemStack item = TridentUtils.getItemStack(trident); + + if (!EnchantChecks.item(item, this)) { + return; + } + + int level = EnchantChecks.getItemLevel(item, this); + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + List potentialDrops = new ArrayList<>(); + this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "drops").forEach(material -> { + potentialDrops.add(Material.getMaterial(material.toUpperCase())); + }); + + Collections.shuffle(potentialDrops, new Random(NumberUtils.randInt(0, 100000))); + ItemStack drop = new ItemStack(potentialDrops.get(0), 1); + + if (EnchantChecks.item(item, EcoEnchants.TELEKINESIS)) { + new DropQueue(player) + .addItem(drop) + .setLocation(trident.getLocation()) + .forceTelekinesis() + .push(); + } else { + new DropQueue(player) + .addItem(drop) + .setLocation(trident.getLocation()) + .push(); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spiked.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spiked.java new file mode 100644 index 00000000..ea56b70f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spiked.java @@ -0,0 +1,57 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerFishEvent; +import org.jetbrains.annotations.NotNull; + +public class Spiked extends EcoEnchant { + public Spiked() { + super( + "spiked", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onFish(@NotNull final PlayerFishEvent event) { + if (!event.getState().equals(PlayerFishEvent.State.CAUGHT_ENTITY)) { + return; + } + + if (!(event.getCaught() instanceof LivingEntity)) { + return; + } + + Player player = event.getPlayer(); + + LivingEntity victim = (LivingEntity) event.getCaught(); + + if (victim.hasMetadata("NPC")) { + return; + } + + if (!AntigriefManager.canInjure(player, victim)) { + return; + } + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + + double damagePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level"); + double damage = damagePerLevel * level; + victim.damage(damage, player); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Splash.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Splash.java new file mode 100644 index 00000000..b49e63b4 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Splash.java @@ -0,0 +1,72 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.util.TridentUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.Bukkit; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Trident; +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.jetbrains.annotations.NotNull; + +public class Splash extends EcoEnchant { + public Splash() { + super( + "splash", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentHit(@NotNull final LivingEntity shooter, + final int level, + @NotNull final ProjectileHitEvent event) { + Trident trident = (Trident) event.getEntity(); + + ItemStack item = TridentUtils.getItemStack(trident); + + if (!EnchantChecks.item(item, this)) { + return; + } + + if (this.getDisabledWorlds().contains(shooter.getWorld())) { + return; + } + + double radius = level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-multiplier"); + double damage = level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level"); + + for (Entity victim : trident.getNearbyEntities(radius, radius, radius)) { + if (victim.hasMetadata("NPC")) { + continue; + } + + if (!(victim instanceof LivingEntity)) { + continue; + } + + LivingEntity entity = (LivingEntity) victim; + + if (victim.equals(shooter)) { + continue; + } + + Bukkit.getPluginManager().callEvent(new EntityDamageByEntityEvent(trident, entity, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); + + if (shooter instanceof Player) { + if (!AntigriefManager.canInjure((Player) shooter, entity)) { + continue; + } + } + + entity.damage(damage, trident); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stab.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stab.java new file mode 100644 index 00000000..d1a15d96 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stab.java @@ -0,0 +1,28 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Stab extends EcoEnchant { + public Stab() { + super( + "stab", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-base"); + double perLevelDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level"); + double damage = baseDamage + (level * perLevelDamage); + + event.setDamage(event.getDamage() + damage); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stalwart.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stalwart.java new file mode 100644 index 00000000..d99a0e96 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stalwart.java @@ -0,0 +1,37 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Stalwart extends EcoEnchant { + public Stalwart() { + super( + "stalwart", EnchantmentType.NORMAL + ); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level"); + duration *= level; + + int amplifier = (int) Math.ceil((double) level / 4) - 1; + + victim.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, duration, amplifier, false, false, true)); + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stamina.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stamina.java new file mode 100644 index 00000000..082669b5 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stamina.java @@ -0,0 +1,51 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.jetbrains.annotations.NotNull; + +public class Stamina extends EcoEnchant { + public Stamina() { + super( + "stamina", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onStaminaHunger(@NotNull final FoodLevelChangeEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + + Player player = (Player) event.getEntity(); + + if (!player.isSprinting()) { + return; + } + + if (!EnchantChecks.boots(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (event.getFoodLevel() > player.getFoodLevel()) { + return; + } + + int level = EnchantChecks.getBootsLevel(player, this); + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StoneSwitcher.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StoneSwitcher.java new file mode 100644 index 00000000..4e94d0e6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StoneSwitcher.java @@ -0,0 +1,62 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.drops.DropQueue; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public class StoneSwitcher extends EcoEnchant { + public StoneSwitcher() { + super( + "stone_switcher", EnchantmentType.NORMAL + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) { + return; + } + + if (!block.getType().equals(Material.STONE)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setDropItems(false); + + Material material; + double random = NumberUtils.randFloat(0, 1); + double band = 1 / (double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size(); + int selectedIndex = (int) Math.floor(random / band); + selectedIndex = NumberUtils.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size() - 1); + String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").get(selectedIndex); + material = Material.getMaterial(materialName.toUpperCase()); + + if (material == null) { + material = Material.COBBLESTONE; + } + + ItemStack item = new ItemStack(material, 1); + + new DropQueue(player) + .setLocation(block.getLocation()) + .addItem(item) + .push(); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StrayAspect.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StrayAspect.java new file mode 100644 index 00000000..a064e3fc --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StrayAspect.java @@ -0,0 +1,38 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class StrayAspect extends EcoEnchant { + public StrayAspect() { + super( + "stray_aspect", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); + + victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, level * ticksPerLevel, level)); + victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, level * ticksPerLevel, level)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Succession.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Succession.java new file mode 100644 index 00000000..ccca20b3 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Succession.java @@ -0,0 +1,46 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.DurabilityUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.AbstractArrow; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.jetbrains.annotations.NotNull; + +public class Succession extends EcoEnchant { + public Succession() { + super( + "succession", EnchantmentType.NORMAL + ); + } + + @Override + public void onBowShoot(@NotNull final LivingEntity shooter, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityShootBowEvent event) { + int amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "extra-arrows-per-level") * level; + + boolean fire = EnchantChecks.mainhand(shooter, Enchantment.ARROW_FIRE); + + for (int i = 1; i <= amount; i++) { + this.getPlugin().getScheduler().runLater(() -> { + Arrow arrow1 = shooter.launchProjectile(Arrow.class, event.getProjectile().getVelocity()); + arrow1.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); + if (fire) { + arrow1.setFireTicks(Integer.MAX_VALUE); + } + + if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "per-arrow-damage") && shooter instanceof Player) { + DurabilityUtils.damageItem((Player) shooter, ((Player) shooter).getInventory().getItemInMainHand(), 1, ((Player) shooter).getInventory().getHeldItemSlot()); + } + }, i * 2L); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java new file mode 100644 index 00000000..e6911baf --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Supercritical extends EcoEnchant { + public Supercritical() { + super( + "supercritical", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier")); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sycophant.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sycophant.java new file mode 100644 index 00000000..af5fb9e3 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sycophant.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Sycophant extends EcoEnchant { + public Sycophant() { + super( + "sycophant", EnchantmentType.NORMAL + ); + } + + @Override + public void onDeflect(@NotNull final Player blocker, + @NotNull final LivingEntity attacker, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level"); + double amountToHeal = level * multiplier; + double newHealth = attacker.getHealth() + amountToHeal; + if (newHealth > attacker.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { + newHealth = attacker.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); + } + attacker.setHealth(newHealth); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tectonic.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tectonic.java new file mode 100644 index 00000000..25968078 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tectonic.java @@ -0,0 +1,52 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; + +public class Tectonic extends EcoEnchant { + public Tectonic() { + super( + "tectonic", EnchantmentType.NORMAL + ); + } + + @Override + public void onFallDamage(@NotNull final LivingEntity faller, + final int level, + @NotNull final EntityDamageEvent event) { + + if (!event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) { + return; + } + + int radius = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "initial-radius") + (this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "per-level-radius") * level - 1); + int damage = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "initial-damage") + (this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "per-level-damage") * level - 1); + + + Collection entities = faller.getWorld().getNearbyEntities(faller.getLocation(), radius, 2, radius); + + for (Entity entity : entities) { + if (entity.equals(faller)) { + continue; + } + if (!(entity instanceof LivingEntity)) { + continue; + } + entity.teleport(entity.getLocation().add(0, 0.3, 0)); + if (faller instanceof Player && !AntigriefManager.canInjure((Player) faller, (LivingEntity) entity)) { + return; + } + ((LivingEntity) entity).damage(damage); + } + } + +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java new file mode 100644 index 00000000..7aa3f641 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java @@ -0,0 +1,199 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.drops.DropQueue; +import com.willfp.eco.core.events.EntityDeathByEntityEvent; +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.core.integrations.mcmmo.McmmoManager; +import com.willfp.eco.util.TridentUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Trident; +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.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataType; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class Telekinesis extends EcoEnchant { + private static boolean always = false; + + public Telekinesis() { + super( + "telekinesis", EnchantmentType.NORMAL + ); + } + + @Override + protected void postUpdate() { + always = this.getPlugin().getConfigYml().getBool("advanced.force-dropqueue"); + } + + // For block drops + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void telekinesisDropItem(@NotNull final BlockDropItemEvent event) { + Player player = event.getPlayer(); + + if (!always && !EnchantChecks.mainhand(player, this)) { + return; + } + + if (this.getDisabledWorldNames().contains(player.getWorld().getName())) { + return; + } + + if (event.isCancelled()) { + return; + } + + Block block = event.getBlock(); + + if (!AntigriefManager.canBreakBlock(player, block)) { + return; + } + + List drops = new ArrayList<>(); + + for (Item item : event.getItems()) { + drops.add(item.getItemStack()); + for (int i = 0; i < McmmoManager.getBonusDropCount(block); i++) { + drops.add(item.getItemStack()); + } + } + + event.getItems().clear(); + + DropQueue queue = new DropQueue(player) + .setLocation(block.getLocation()) + .addItems(drops); + + if (!always) { + queue.forceTelekinesis(); + } + + queue.push(); + } + + // For exp drops, blockdropitemevent doesn't cover xp + @EventHandler(priority = EventPriority.HIGH) + public void telekinesisBreak(@NotNull final BlockBreakEvent event) { + Player player = event.getPlayer(); + Block block = event.getBlock(); + + if (!always && !EnchantChecks.mainhand(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) { + return; + } + + if (event.isCancelled()) { + return; + } + + if (!AntigriefManager.canBreakBlock(player, block)) { + return; + } + + if (block.getType().equals(Material.SPAWNER)) { + event.setExpToDrop(0); + } + + DropQueue queue = new DropQueue(player) + .setLocation(block.getLocation()) + .addXP(event.getExpToDrop()); + + if (!always) { + queue.forceTelekinesis(); + } + + queue.push(); + + event.setExpToDrop(0); + } + + @EventHandler(priority = EventPriority.HIGH) + public void telekinesisKill(@NotNull final EntityDeathByEntityEvent event) { + Player player = null; + LivingEntity entity = event.getVictim(); + ItemStack item = null; + + if (entity instanceof Player && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "not-on-players")) { + return; + } + + if (event.getKiller() instanceof Player) { + player = (Player) event.getKiller(); + item = player.getInventory().getItemInMainHand(); + } else if (event.getKiller() instanceof Arrow) { + if (((Arrow) event.getKiller()).getShooter() instanceof Player) { + player = (Player) ((Arrow) event.getKiller()).getShooter(); + item = player.getInventory().getItemInMainHand(); + } + } else if (event.getKiller() instanceof Trident) { + if (((Trident) event.getKiller()).getShooter() instanceof Player) { + player = (Player) ((Trident) event.getKiller()).getShooter(); + item = TridentUtils.getItemStack((Trident) event.getKiller()); + } + } + + if (player == null || item == null) { + return; + } + + if (!EnchantChecks.item(item, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int xp = event.getXp(); + Collection drops = event.getDrops(); + + drops.removeIf(itemStack -> { + if (itemStack == null) { + return true; + } + ItemMeta meta = itemStack.getItemMeta(); + if (meta == null) { + return false; + } + if (meta.getPersistentDataContainer() == null) { + return false; + } + return meta.getPersistentDataContainer().has(this.getPlugin().getNamespacedKeyFactory().create("soulbound"), PersistentDataType.INTEGER); + }); + + new DropQueue(player) + .addItems(drops) + .setLocation(entity.getLocation()) + .addXP(xp) + .forceTelekinesis() + .push(); + + event.getDeathEvent().setDroppedExp(0); + event.getDeathEvent().getDrops().clear(); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thor.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thor.java new file mode 100644 index 00000000..beb37eaa --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thor.java @@ -0,0 +1,36 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.LightningUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Thor extends EcoEnchant { + public Thor() { + super( + "thor", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "lightning-damage"); + + LightningUtils.strike(victim, damage); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thrive.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thrive.java new file mode 100644 index 00000000..b264003d --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thrive.java @@ -0,0 +1,63 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.events.ArmorEquipEvent; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeInstance; +import org.bukkit.attribute.AttributeModifier; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +public class Thrive extends EcoEnchant { + private final AttributeModifier modifier = new AttributeModifier(UUID.nameUUIDFromBytes("thrive".getBytes()), this.getKey().getKey(), 1, AttributeModifier.Operation.ADD_NUMBER); + + public Thrive() { + super( + "thrive", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onArmorEquip(@NotNull final ArmorEquipEvent event) { + Player player = event.getPlayer(); + + this.getPlugin().getScheduler().runLater(() -> { + int points = EnchantChecks.getArmorPoints(player, this); + + AttributeInstance inst = player.getAttribute(Attribute.GENERIC_MAX_HEALTH); + + assert inst != null; + + inst.setBaseValue(inst.getDefaultValue()); + + if (this.getDisabledWorlds().contains(player.getWorld())) { + points = 0; + } + + inst.removeModifier(modifier); + + if (player.getHealth() >= inst.getValue()) { + this.getPlugin().getScheduler().runLater(() -> { + player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); + }, 1); + } + + if (points > 0) { + inst.addModifier( + new AttributeModifier( + UUID.nameUUIDFromBytes("thrive".getBytes()), + this.getKey().getKey(), + this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "health-per-point") * points, + AttributeModifier.Operation.ADD_NUMBER + ) + ); + } + }, 1); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tornado.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tornado.java new file mode 100644 index 00000000..a038668b --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tornado.java @@ -0,0 +1,30 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Tornado extends EcoEnchant { + public Tornado() { + super( + "tornado", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double baseVelocity = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-per-level"); + double yVelocity = baseVelocity * level; + + Vector toAdd = new Vector(0, yVelocity, 0); + + this.getPlugin().getScheduler().runLater(() -> victim.setVelocity(victim.getVelocity().clone().add(toAdd)), 1); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Toxic.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Toxic.java new file mode 100644 index 00000000..cb57fcc3 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Toxic.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Toxic extends EcoEnchant { + public Toxic() { + super( + "toxic", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + victim.addPotionEffect(new PotionEffect(PotionEffectType.POISON, level * 10 + 20, level)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Transfuse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Transfuse.java new file mode 100644 index 00000000..d95e8e59 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Transfuse.java @@ -0,0 +1,65 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.drops.DropQueue; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.stream.Collectors; + +public class Transfuse extends EcoEnchant { + public Transfuse() { + super( + "transfuse", EnchantmentType.NORMAL + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setDropItems(false); + + if (!this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "works-on").stream() + .map(string -> Material.getMaterial(string.toUpperCase())) + .collect(Collectors.toList()).contains(block.getType())) { + return; + } + + Material material; + double random = NumberUtils.randFloat(0, 1); + double band = 1 / (double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size(); + int selectedIndex = (int) Math.floor(random / band); + selectedIndex = NumberUtils.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size() - 1); + String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").get(selectedIndex); + material = Material.getMaterial(materialName.toUpperCase()); + if (material == null) { + material = Material.COBBLESTONE; + } + + ItemStack item = new ItemStack(material, 1); + + new DropQueue(player) + .setLocation(block.getLocation()) + .addItem(item) + .push(); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tripleshot.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tripleshot.java new file mode 100644 index 00000000..2e86cf94 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tripleshot.java @@ -0,0 +1,40 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.AbstractArrow; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Tripleshot extends EcoEnchant { + public Tripleshot() { + super( + "tripleshot", EnchantmentType.NORMAL + ); + } + + @Override + public void onBowShoot(@NotNull final LivingEntity shooter, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityShootBowEvent event) { + for (int i = -1; i < 2; i += 2) { + Vector velocity = event.getProjectile().getVelocity(); + + float radians = (float) ((float) i * Math.toRadians(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "angle"))); + velocity.rotateAroundY(radians); + + Arrow arrow1 = shooter.launchProjectile(Arrow.class, velocity); + if (EnchantChecks.mainhand(shooter, Enchantment.ARROW_FIRE)) { + arrow1.setFireTicks(Integer.MAX_VALUE); + } + arrow1.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VampireAspect.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VampireAspect.java new file mode 100644 index 00000000..41a873b5 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VampireAspect.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class VampireAspect extends EcoEnchant { + public VampireAspect() { + super( + "vampire_aspect", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + victim.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, level * 10 + 20, level)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Vein.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Vein.java new file mode 100644 index 00000000..5c0f2295 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Vein.java @@ -0,0 +1,66 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.integrations.anticheat.AnticheatManager; +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.util.BlockUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +public class Vein extends EcoEnchant { + public Vein() { + super( + "vein", EnchantmentType.NORMAL + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + if (block.hasMetadata("block-ignore")) { + return; + } + + if (player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) { + return; + } + + List materials = new ArrayList<>(); + this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "whitelisted-blocks").forEach(name -> materials.add(Material.getMaterial(name.toUpperCase()))); + + if (!materials.contains(block.getType())) { + return; + } + + int blocksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "blocks-per-level"); + int limit = level * blocksPerLevel; + + Set blockSet = BlockUtils.getVein(block, materials, limit); + + AnticheatManager.exemptPlayer(player); + + for (Block veinBlock : blockSet) { + veinBlock.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true)); + if (!AntigriefManager.canBreakBlock(player, veinBlock)) { + continue; + } + + BlockUtils.breakBlock(player, veinBlock); + + this.getPlugin().getScheduler().runLater(() -> veinBlock.removeMetadata("block-ignore", this.getPlugin()), 1); + } + + AnticheatManager.unexemptPlayer(player); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Venom.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Venom.java new file mode 100644 index 00000000..db5c73d4 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Venom.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Venom extends EcoEnchant { + public Venom() { + super( + "venom", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + victim.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, level * 10 + 20, level)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VoidAffinity.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VoidAffinity.java new file mode 100644 index 00000000..3c275127 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VoidAffinity.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.World; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class VoidAffinity extends EcoEnchant { + public VoidAffinity() { + super( + "void_affinity", EnchantmentType.NORMAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!attacker.getWorld().getEnvironment().equals(World.Environment.THE_END)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Voltage.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Voltage.java new file mode 100644 index 00000000..5d3d9465 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Voltage.java @@ -0,0 +1,69 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; + +public class Voltage extends EcoEnchant { + private static final Material[] ITEMS = { + Material.IRON_HELMET, + Material.IRON_CHESTPLATE, + Material.IRON_LEGGINGS, + Material.IRON_BOOTS, + + Material.GOLDEN_HELMET, + Material.GOLDEN_CHESTPLATE, + Material.GOLDEN_LEGGINGS, + Material.GOLDEN_BOOTS, + + Material.CHAINMAIL_HELMET, + Material.CHAINMAIL_CHESTPLATE, + Material.CHAINMAIL_LEGGINGS, + Material.CHAINMAIL_BOOTS, + }; + + public Voltage() { + super( + "voltage", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + EntityEquipment equipment = victim.getEquipment(); + if (equipment == null) { + return; + } + + int pieces = 0; + + for (ItemStack armorPiece : equipment.getArmorContents()) { + if (armorPiece == null) { + continue; + } + + if (Arrays.asList(ITEMS).contains(armorPiece.getType())) { + pieces++; + } + } + + if (pieces == 0) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + event.setDamage(event.getDamage() * (1 + (level * multiplier * pieces))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAffinity.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAffinity.java new file mode 100644 index 00000000..6fd7fbb6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAffinity.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class WaterAffinity extends EcoEnchant { + public WaterAffinity() { + super( + "water_affinity", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!attacker.getLocation().getBlock().getType().equals(Material.WATER)) { + return; + } + + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level); + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAspect.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAspect.java new file mode 100644 index 00000000..465811a3 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAspect.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Blaze; +import org.bukkit.entity.Enderman; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.MagmaCube; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class WaterAspect extends EcoEnchant { + public WaterAspect() { + super( + "water_aspect", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(victim instanceof Blaze || victim instanceof MagmaCube || victim instanceof Enderman)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + double damageMultiplier = (level * multiplier) + 1; + + event.setDamage(event.getDamage() * damageMultiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Weakening.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Weakening.java new file mode 100644 index 00000000..99e44249 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Weakening.java @@ -0,0 +1,46 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Weakening extends EcoEnchant { + public Weakening() { + super( + "weakening", EnchantmentType.NORMAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); + int ticks = ticksPerLevel * level; + + victim.setMetadata("weak", this.getPlugin().getMetadataValueFactory().create(true)); + + this.getPlugin().getScheduler().runLater(() -> victim.removeMetadata("weak", this.getPlugin()), ticks); + } + + @EventHandler + public void onDamage(@NotNull final EntityDamageEvent event) { + if (!(event.getEntity() instanceof LivingEntity)) { + return; + } + + LivingEntity victim = (LivingEntity) event.getEntity(); + + if (!victim.hasMetadata("weak")) { + return; + } + + event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier-while-weak")); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wisdom.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wisdom.java new file mode 100644 index 00000000..b41a0ed0 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wisdom.java @@ -0,0 +1,39 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.events.NaturalExpGainEvent; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.jetbrains.annotations.NotNull; + +public class Wisdom extends EcoEnchant { + public Wisdom() { + super( + "wisdom", EnchantmentType.NORMAL + ); + } + + @EventHandler + public void onExpChange(@NotNull final NaturalExpGainEvent event) { + Player player = event.getExpChangeEvent().getPlayer(); + + if (event.getExpChangeEvent().getAmount() < 0) { + return; + } + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + + event.getExpChangeEvent().setAmount((int) Math.ceil(event.getExpChangeEvent().getAmount() * (1 + (level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-point"))))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WoodSwitcher.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WoodSwitcher.java new file mode 100644 index 00000000..34c3f6f1 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WoodSwitcher.java @@ -0,0 +1,63 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.core.drops.DropQueue; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public class WoodSwitcher extends EcoEnchant { + public WoodSwitcher() { + super( + "wood_switcher", EnchantmentType.NORMAL + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) { + return; + } + + if (!Tag.LOGS.isTagged(block.getType())) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + event.setDropItems(false); + + Material material; + double random = NumberUtils.randFloat(0, 1); + double band = 1 / (double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size(); + int selectedIndex = (int) Math.floor(random / band); + selectedIndex = NumberUtils.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size() - 1); + String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").get(selectedIndex); + material = Material.getMaterial(materialName.toUpperCase()); + + if (material == null) { + material = block.getType(); + } + + ItemStack item = new ItemStack(material, 1); + + new DropQueue(player) + .setLocation(block.getLocation()) + .addItem(item) + .push(); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wound.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wound.java new file mode 100644 index 00000000..3bc20a94 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wound.java @@ -0,0 +1,49 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.atomic.AtomicInteger; + +public class Wound extends EcoEnchant { + public Wound() { + super( + "wound", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + double bleedDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bleed-damage"); + + int bleedCount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "amount-per-level"); + bleedCount *= level; + final int finalBleedCount = bleedCount; + + AtomicInteger currentBleedCount = new AtomicInteger(0); + + this.getPlugin().getRunnableFactory().create(bukkitRunnable -> { + currentBleedCount.addAndGet(1); + + victim.damage(bleedDamage); + + if (currentBleedCount.get() >= finalBleedCount) { + bukkitRunnable.cancel(); + } + }).runTaskTimer(0, 10); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Zeus.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Zeus.java new file mode 100644 index 00000000..fdc9cd5b --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Zeus.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.eco.util.LightningUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Zeus extends EcoEnchant { + public Zeus() { + super( + "zeus", EnchantmentType.NORMAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "lightning-damage"); + + LightningUtils.strike(victim, damage); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java new file mode 100644 index 00000000..782e092e --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java @@ -0,0 +1,125 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.GameMode; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Enderman; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +@SuppressWarnings({"unchecked", "unused"}) +public class Aiming extends EcoEnchant { + public Aiming() { + super( + "aiming", EnchantmentType.SPECIAL + ); + } + + @EventHandler + public void aimingLaunch(@NotNull final ProjectileLaunchEvent event) { + if (!(event.getEntity().getShooter() instanceof Player)) { + return; + } + + if (!(event.getEntity() instanceof Arrow)) { + return; + } + + if (event.isCancelled()) { + return; + } + + Player player = (Player) event.getEntity().getShooter(); + Arrow arrow = (Arrow) event.getEntity(); + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level"); + + double distance = level * multiplier; + double force = arrow.getVelocity().clone().length() / 3; + force = NumberUtils.equalIfOver(force, 1); + + if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "require-full-force") && force < 0.9) { + return; + } + + if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "scale-on-force")) { + distance *= force; + } + + final double finalDistance = distance; + + Runnable runnable = this.getPlugin().getRunnableFactory().create(bukkitRunnable -> { + List nearbyEntities = (List) (List) Arrays.asList(arrow.getNearbyEntities(finalDistance, finalDistance, finalDistance).stream() + .filter(entity -> entity instanceof LivingEntity) + .map(entity -> (LivingEntity) entity) + .filter(entity -> !entity.equals(player)) + .filter(entity -> !(entity instanceof Enderman)) + .filter(entity -> AntigriefManager.canInjure(player, entity)) + .filter(entity -> { + if (entity instanceof Player) { + return ((Player) entity).getGameMode().equals(GameMode.SURVIVAL) || ((Player) entity).getGameMode().equals(GameMode.ADVENTURE); + } + return true; + }).toArray()); + + if (nearbyEntities.isEmpty()) { + return; + } + + LivingEntity entity = nearbyEntities.get(0); + double dist = Double.MAX_VALUE; + + for (LivingEntity livingEntity : nearbyEntities) { + double currentDistance = livingEntity.getLocation().distance(arrow.getLocation()); + if (currentDistance >= dist) { + continue; + } + + dist = currentDistance; + entity = livingEntity; + } + if (entity != null) { + Vector vector = entity.getEyeLocation().toVector().clone().subtract(arrow.getLocation().toVector()).normalize(); + arrow.setVelocity(vector); + } + }); + + final int period = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "check-ticks"); + final int checks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "checks-per-level") * level; + AtomicInteger checksPerformed = new AtomicInteger(0); + + this.getPlugin().getRunnableFactory().create(bukkitRunnable -> { + checksPerformed.addAndGet(1); + if (checksPerformed.get() > checks) { + bukkitRunnable.cancel(); + } + if (arrow.isDead() || arrow.isInBlock() || arrow.isOnGround()) { + bukkitRunnable.cancel(); + } + this.getPlugin().getScheduler().run(runnable); + }).runTaskTimer(3, period); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Annihilate.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Annihilate.java new file mode 100644 index 00000000..e2e3e8f9 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Annihilate.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.eco.util.VectorUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Annihilate extends EcoEnchant { + public Annihilate() { + super( + "annihilate", EnchantmentType.SPECIAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier"); + Vector vector = attacker.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier).multiply(-1); + if (!VectorUtils.isFinite(vector)) { + return; + } + vector.setY(0.2); + if (!VectorUtils.isFinite(vector)) { + return; + } + victim.setVelocity(vector); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java new file mode 100644 index 00000000..4ad1a095 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java @@ -0,0 +1,30 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Bladed extends EcoEnchant { + public Bladed() { + super( + "bladed", EnchantmentType.SPECIAL + ); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "base-multiplier"); + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = 1 + (multiplier * level) + baseDamage; + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bolt.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bolt.java new file mode 100644 index 00000000..7ca827f2 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bolt.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.eco.util.LightningUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Bolt extends EcoEnchant { + public Bolt() { + super( + "bolt", EnchantmentType.SPECIAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "lightning-damage"); + + LightningUtils.strike(victim, damage); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Carve.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Carve.java new file mode 100644 index 00000000..66e97350 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Carve.java @@ -0,0 +1,45 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Carve extends EcoEnchant { + public Carve() { + super( + "carve", EnchantmentType.SPECIAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (victim.hasMetadata("carved")) { + return; + } + + double damagePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-percentage-per-level") * 0.01; + double radiusPerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-per-level"); + final double damage = damagePerLevel * level * event.getDamage(); + final double radius = radiusPerLevel * level; + + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + victim.getNearbyEntities(radius, radius, radius).stream() + .filter(entity -> entity instanceof LivingEntity) + .filter(entity -> !entity.equals(attacker)) + .forEach(entity -> { + entity.setMetadata("carved", this.getPlugin().getMetadataValueFactory().create(true)); + ((LivingEntity) entity).damage(damage, attacker); + this.getPlugin().getScheduler().runLater(() -> entity.removeMetadata("carved", this.getPlugin()), 20); + }); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java new file mode 100644 index 00000000..3db9d3f9 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java @@ -0,0 +1,52 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +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 java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class Confusion extends EcoEnchant { + public Confusion() { + super( + "confusion", EnchantmentType.SPECIAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity uncastVictim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(uncastVictim instanceof Player)) { + return; + } + Player victim = (Player) uncastVictim; + + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + List hotbar = new ArrayList<>(); + for (int i = 0; i < 9; i++) { + hotbar.add(victim.getInventory().getItem(i)); + } + Collections.shuffle(hotbar); + int i2 = 0; + for (ItemStack item : hotbar) { + victim.getInventory().setItem(i2, item); + i2++; + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Energizing.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Energizing.java new file mode 100644 index 00000000..37d1aacc --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Energizing.java @@ -0,0 +1,30 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Energizing extends EcoEnchant { + public Energizing() { + super( + "energizing", EnchantmentType.SPECIAL + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level") * level; + int amplifier = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "initial-level") + (level - 2); + + player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, duration, amplifier, true, true, true)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java new file mode 100644 index 00000000..e92ee028 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java @@ -0,0 +1,29 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Force extends EcoEnchant { + public Force() { + super( + "force", EnchantmentType.SPECIAL + ); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double damage = event.getDamage(); + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double bonus = (multiplier * (level + 6)) + 1; + event.setDamage(damage * bonus); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Frenzy.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Frenzy.java new file mode 100644 index 00000000..a00af005 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Frenzy.java @@ -0,0 +1,43 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Frenzy extends EcoEnchant { + public Frenzy() { + super( + "frenzy", EnchantmentType.SPECIAL + ); + } + + @EventHandler + public void onFrenzyKill(@NotNull final EntityDeathEvent event) { + if (event.getEntity().getKiller() == null) { + return; + } + + Player player = event.getEntity().getKiller(); + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + + int duration = (int) (level * 20 * this.getConfig().getDouble((EcoEnchants.CONFIG_LOCATION + "seconds-per-level"))); + + player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, duration, level, true, true, true)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Harpoon.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Harpoon.java new file mode 100644 index 00000000..c463bef6 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Harpoon.java @@ -0,0 +1,57 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerFishEvent; +import org.jetbrains.annotations.NotNull; + +public class Harpoon extends EcoEnchant { + public Harpoon() { + super( + "harpoon", EnchantmentType.SPECIAL + ); + } + + @EventHandler + public void onFish(@NotNull final PlayerFishEvent event) { + if (!event.getState().equals(PlayerFishEvent.State.CAUGHT_ENTITY)) { + return; + } + + if (!(event.getCaught() instanceof LivingEntity)) { + return; + } + + Player player = event.getPlayer(); + + LivingEntity victim = (LivingEntity) event.getCaught(); + + if (victim.hasMetadata("NPC")) { + return; + } + + if (!AntigriefManager.canInjure(player, victim)) { + return; + } + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + + double damagePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level"); + double damage = damagePerLevel * level; + victim.damage(damage, player); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Indestructibility.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Indestructibility.java new file mode 100644 index 00000000..30615882 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Indestructibility.java @@ -0,0 +1,42 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerItemDamageEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public class Indestructibility extends EcoEnchant { + public Indestructibility() { + super( + "indestructibility", EnchantmentType.SPECIAL + ); + } + + @EventHandler + public void onItemDamage(@NotNull final PlayerItemDamageEvent event) { + ItemStack item = event.getItem(); + + if (!EnchantChecks.item(item, this)) { + return; + } + + if (this.getDisabledWorlds().contains(event.getPlayer().getWorld())) { + return; + } + + double level = EnchantChecks.getItemLevel(item, this); + double levelBonus = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "level-bonus"); + + if (NumberUtils.randFloat(0, 1) < (100 / (level + (1 + levelBonus)) / 100)) { + return; + } + + event.setCancelled(true); + event.setDamage(0); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Instability.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Instability.java new file mode 100644 index 00000000..d5dd3465 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Instability.java @@ -0,0 +1,65 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.jetbrains.annotations.NotNull; + +public class Instability extends EcoEnchant { + public Instability() { + super( + "instability", EnchantmentType.SPECIAL + ); + } + + @EventHandler + public void onInstabilityLand(@NotNull final ProjectileHitEvent event) { + if (event.getEntityType() != EntityType.ARROW) { + return; + } + + if (!(event.getEntity().getShooter() instanceof Player)) { + return; + } + + Player player = (Player) event.getEntity().getShooter(); + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (!(event.getEntity() instanceof Arrow)) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + + boolean fire = this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "fire"); + boolean breakblocks = this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "break-blocks"); + + float power = (float) (0.5 + (level * 0.5)); + + if (!AntigriefManager.canCreateExplosion(player, event.getEntity().getLocation())) { + return; + } + + if (breakblocks) { + breakblocks = AntigriefManager.canBreakBlock(player, event.getEntity().getLocation().getWorld().getBlockAt(event.getEntity().getLocation())); + } + + event.getEntity().getWorld().createExplosion(event.getEntity().getLocation().getX(), event.getEntity().getLocation().getY(), event.getEntity().getLocation().getZ(), power, fire, breakblocks); + + event.getEntity().remove(); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Intellect.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Intellect.java new file mode 100644 index 00000000..4e1d8855 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Intellect.java @@ -0,0 +1,39 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.eco.core.events.NaturalExpGainEvent; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.jetbrains.annotations.NotNull; + +public class Intellect extends EcoEnchant { + public Intellect() { + super( + "intellect", EnchantmentType.SPECIAL + ); + } + + @EventHandler + public void onExpChange(@NotNull final NaturalExpGainEvent event) { + Player player = event.getExpChangeEvent().getPlayer(); + + if (event.getExpChangeEvent().getAmount() < 0) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + + if (level == 0) { + return; + } + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + event.getExpChangeEvent().setAmount((int) Math.ceil(event.getExpChangeEvent().getAmount() * (1 + (level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-point"))))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/LifeSteal.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/LifeSteal.java new file mode 100644 index 00000000..38a054c2 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/LifeSteal.java @@ -0,0 +1,36 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class LifeSteal extends EcoEnchant { + public LifeSteal() { + super( + "life_steal", EnchantmentType.SPECIAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level"); + double amountToHeal = level * multiplier; + double newHealth = attacker.getHealth() + amountToHeal; + if (newHealth > attacker.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { + newHealth = attacker.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); + } + attacker.setHealth(newHealth); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Pentashot.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Pentashot.java new file mode 100644 index 00000000..b290960a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Pentashot.java @@ -0,0 +1,46 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.AbstractArrow; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Pentashot extends EcoEnchant { + public Pentashot() { + super( + "pentashot", EnchantmentType.SPECIAL + ); + } + + @Override + public void onBowShoot(@NotNull final LivingEntity shooter, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityShootBowEvent event) { + int bonusPerSide = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "side-arrows-per-level") * level; + + for (int i = -bonusPerSide; i <= bonusPerSide; i += 1) { + if (i == 0) { + continue; + } + + Vector velocity = event.getProjectile().getVelocity(); + + float radians = (float) ((float) i * Math.toRadians(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "angle"))); + velocity.rotateAroundY(radians); + + Arrow arrow1 = shooter.launchProjectile(Arrow.class, velocity); + if (EnchantChecks.mainhand(shooter, Enchantment.ARROW_FIRE)) { + arrow1.setFireTicks(Integer.MAX_VALUE); + } + arrow1.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Preservation.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Preservation.java new file mode 100644 index 00000000..07fe41ad --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Preservation.java @@ -0,0 +1,31 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public class Preservation extends EcoEnchant { + public Preservation() { + super( + "preservation", EnchantmentType.SPECIAL + ); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + if (event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) { + return; + } + + double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-less-per-level"); + + double multiplier = 1 - ((reduction / 100) * level); + + event.setDamage(event.getDamage() * multiplier); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Prosperity.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Prosperity.java new file mode 100644 index 00000000..9a6fc25d --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Prosperity.java @@ -0,0 +1,63 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.eco.core.events.ArmorEquipEvent; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeInstance; +import org.bukkit.attribute.AttributeModifier; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +public class Prosperity extends EcoEnchant { + private final AttributeModifier modifier = new AttributeModifier(UUID.nameUUIDFromBytes("prosperity".getBytes()), this.getKey().getKey(), 1, AttributeModifier.Operation.ADD_NUMBER); + + public Prosperity() { + super( + "prosperity", EnchantmentType.SPECIAL + ); + } + + @EventHandler + public void onArmorEquip(@NotNull final ArmorEquipEvent event) { + Player player = event.getPlayer(); + + this.getPlugin().getScheduler().runLater(() -> { + int points = EnchantChecks.getArmorPoints(player, this); + + AttributeInstance inst = player.getAttribute(Attribute.GENERIC_MAX_HEALTH); + + assert inst != null; + + inst.setBaseValue(inst.getDefaultValue()); + + if (this.getDisabledWorlds().contains(player.getWorld())) { + points = 0; + } + + inst.removeModifier(modifier); + + if (player.getHealth() >= inst.getValue()) { + this.getPlugin().getScheduler().runLater(() -> { + player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); + }, 1); + } + + if (points > 0) { + inst.addModifier( + new AttributeModifier( + UUID.nameUUIDFromBytes("prosperity".getBytes()), + this.getKey().getKey(), + this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "health-per-point") * points, + AttributeModifier.Operation.ADD_NUMBER + ) + ); + } + }, 1); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java new file mode 100644 index 00000000..bef73e33 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java @@ -0,0 +1,32 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Razor extends EcoEnchant { + public Razor() { + super( + "razor", EnchantmentType.SPECIAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double perLevelMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "base-damage"); + double extra = (level * perLevelMultiplier) + baseDamage; + if (this.getConfig().getBool((EcoEnchants.CONFIG_LOCATION) + "decrease-if-cooldown") && attacker instanceof Player) { + extra *= ((Player) attacker).getAttackCooldown(); + } + + event.setDamage(event.getDamage() + extra); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java new file mode 100644 index 00000000..edbbd7b9 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java @@ -0,0 +1,123 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.eco.util.DurabilityUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.TimedRunnable; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDropItemEvent; +import org.bukkit.event.entity.EntityPickupItemEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Repairable; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public class Repairing extends EcoEnchant implements TimedRunnable { + private final Set players = new HashSet<>(); + private int amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + public Repairing() { + super( + "repairing", EnchantmentType.SPECIAL + ); + } + + @EventHandler + public void onItemPickup(@NotNull final EntityPickupItemEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + refreshPlayer((Player) event.getEntity()); + } + + @EventHandler + public void onPlayerJoin(@NotNull final PlayerJoinEvent event) { + refresh(); + } + + @EventHandler + public void onPlayerLeave(@NotNull final PlayerQuitEvent event) { + refresh(); + } + + @EventHandler + public void onInventoryDrop(@NotNull final EntityDropItemEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + + refreshPlayer((Player) event.getEntity()); + } + + @EventHandler + public void onInventoryClick(@NotNull final InventoryClickEvent event) { + if (!(event.getWhoClicked() instanceof Player)) { + return; + } + refreshPlayer((Player) event.getWhoClicked()); + } + + private void refresh() { + players.clear(); + this.getPlugin().getScheduler().runLater(() -> this.getPlugin().getServer().getOnlinePlayers().forEach(player -> { + if (Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, this))) { + players.add(player); + } + }), 1); + amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier"); + } + + private void refreshPlayer(@NotNull final Player player) { + players.remove(player); + if (Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, this))) { + players.add(player); + } + } + + @Override + public void run() { + players.forEach((player -> { + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + for (ItemStack item : player.getInventory().getContents()) { + int level = EnchantChecks.getItemLevel(item, this); + if (level == 0) { + continue; + } + + if (!(item.getItemMeta() instanceof Repairable)) { + continue; + } + + if (player.getInventory().getItemInMainHand().equals(item)) { + continue; + } + + if (player.getInventory().getItemInOffHand().equals(item)) { + continue; + } + + if (player.getItemOnCursor().equals(item)) { + continue; + } + + DurabilityUtils.repairItem(item, amount * level); + } + })); + } + + @Override + public long getTime() { + return this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "repeat-ticks"); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java new file mode 100644 index 00000000..a29fc2c8 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java @@ -0,0 +1,139 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +@SuppressWarnings("unchecked") +public class Soulbound extends EcoEnchant { + public Soulbound() { + super( + "soulbound", EnchantmentType.SPECIAL + ); + } + + @EventHandler(priority = EventPriority.LOW) + public void onSoulboundDeath(@NotNull final PlayerDeathEvent event) { + if (event.getKeepInventory()) { + return; + } + + Player player = event.getEntity(); + List soulboundItems = new ArrayList<>(); // Stored as list to preserve duplicates + + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (player.getKiller() != null) { + Player killer = player.getKiller(); + int reaperLevel = EnchantChecks.getMainhandLevel(killer, EcoEnchants.REAPER); + if (reaperLevel > 0) { + if (!(EcoEnchants.REAPER.getDisabledWorlds().contains(killer.getWorld()))) { + if (EnchantmentUtils.passedChance(EcoEnchants.REAPER, reaperLevel)) { + return; + } + } + } + } + + for (ItemStack itemStack : player.getInventory().getContents()) { + if (itemStack == null) { + continue; + } + + if (itemStack.containsEnchantment(this)) { + soulboundItems.add(itemStack); + } + + if (itemStack.getItemMeta() instanceof EnchantmentStorageMeta && (((EnchantmentStorageMeta) itemStack.getItemMeta()).getStoredEnchants().containsKey(this.getEnchantment()))) { + soulboundItems.add(itemStack); + } + } + + event.getDrops().removeAll(soulboundItems); + + for (ItemStack itemStack : soulboundItems) { + ItemMeta meta = itemStack.getItemMeta(); + assert meta != null; + PersistentDataContainer container = meta.getPersistentDataContainer(); + container.set(this.getPlugin().getNamespacedKeyFactory().create("soulbound"), PersistentDataType.INTEGER, 1); + + if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "remove-after")) { + if (meta instanceof EnchantmentStorageMeta) { + ((EnchantmentStorageMeta) meta).removeStoredEnchant(this); + } + meta.removeEnchant(this); + } + + itemStack.setItemMeta(meta); + } + + player.setMetadata("soulbound-items", this.getPlugin().getMetadataValueFactory().create(soulboundItems)); + } + + public boolean hasEmptyInventory(@NotNull final Player player) { + for (ItemStack itemStack : player.getInventory().getContents()) { + if (itemStack != null && itemStack.getType() != Material.AIR) { + return false; + } + } + return true; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onSoulboundRespawn(@NotNull final PlayerRespawnEvent event) { + Player player = event.getPlayer(); + + this.getPlugin().getScheduler().runLater(() -> { + if (!hasEmptyInventory(player)) { + return; + } + + if (!player.hasMetadata("soulbound-items")) { + return; + } + + List soulboundItems = (List) player.getMetadata("soulbound-items").get(0).value(); + + if (soulboundItems == null) { + player.removeMetadata("soulbound-items", this.getPlugin()); + return; + } + + for (ItemStack soulboundItem : soulboundItems) { + player.getInventory().remove(soulboundItem); + + ItemMeta meta = soulboundItem.getItemMeta(); + assert meta != null; + meta.getPersistentDataContainer().remove(this.getPlugin().getNamespacedKeyFactory().create("soulbound")); + soulboundItem.setItemMeta(meta); + player.getInventory().addItem(soulboundItem); + } + + player.removeMetadata("soulbound-items", this.getPlugin()); + }, 1); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onDeath(@NotNull final PlayerDeathEvent event) { + event.getDrops().removeIf(itemStack -> itemStack.getItemMeta().getPersistentDataContainer().has(this.getPlugin().getNamespacedKeyFactory().create("soulbound"), PersistentDataType.INTEGER)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Spring.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Spring.java new file mode 100644 index 00000000..d9a4f657 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Spring.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.jetbrains.annotations.NotNull; + +public class Spring extends EcoEnchant { + public Spring() { + super( + "spring", EnchantmentType.SPECIAL + ); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + if (event.getCause() == EntityDamageEvent.DamageCause.FALL) { + event.setCancelled(true); + } + } + + @Override + public void onJump(@NotNull final Player player, + final int level, + @NotNull final PlayerMoveEvent event) { + double multiplier = 0.5 + ((double) (level * level) / 4 - 0.2) / 3; + player.setVelocity(player.getLocation().getDirection().multiply(multiplier).setY(multiplier)); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Streamlining.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Streamlining.java new file mode 100644 index 00000000..2e2c92da --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Streamlining.java @@ -0,0 +1,28 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; + +import com.willfp.eco.core.events.ArmorEquipEvent; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class Streamlining extends EcoEnchant { + public Streamlining() { + super( + "streamlining", EnchantmentType.SPECIAL + ); + } + + @Override + public void onArmorEquip(@NotNull final Player player, + final int level, + @NotNull final ArmorEquipEvent event) { + if (level == 0) { + player.setWalkSpeed(0.2f); + return; + } + + player.setWalkSpeed((float) (0.2 + (level * EcoEnchants.STREAMLINING.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "speed-per-level")))); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Volatile.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Volatile.java new file mode 100644 index 00000000..69afafde --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Volatile.java @@ -0,0 +1,56 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.special; +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Volatile extends EcoEnchant { + public Volatile() { + super( + "volatile", EnchantmentType.SPECIAL + ); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity uncastAttacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!(uncastAttacker instanceof Player)) { + return; + } + + Player attacker = (Player) uncastAttacker; + + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + boolean fire = this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "fire"); + boolean breakblocks = this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "break-blocks"); + + float power = (float) (0.5 + (level * 0.5)); + + if (!AntigriefManager.canCreateExplosion(attacker, event.getEntity().getLocation())) { + return; + } + + if (breakblocks && !AntigriefManager.canBreakBlock(attacker, event.getEntity().getLocation().getWorld().getBlockAt(event.getEntity().getLocation()))) { + return; + } + + Location explosionLoc = victim.getEyeLocation(); + + victim.getWorld().createExplosion(explosionLoc, power, fire, breakblocks); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Ascend.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Ascend.java new file mode 100644 index 00000000..680d7a7f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Ascend.java @@ -0,0 +1,44 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.spell; + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.itemtypes.Spell; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public class Ascend extends Spell { + private static final String IGNORE_FALL_KEY = "ignore-fall-damage"; + + public Ascend() { + super("ascend"); + } + + @Override + public boolean onUse(@NotNull final Player player, + final int level, + @NotNull final PlayerInteractEvent event) { + int ticks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level") * level; + player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, ticks, this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "power") - 1, false, false)); + player.setMetadata(IGNORE_FALL_KEY, this.getPlugin().getMetadataValueFactory().create(true)); + this.getPlugin().getScheduler().runLater(() -> player.removeMetadata(IGNORE_FALL_KEY, this.getPlugin()), ticks * 4L); + + return true; + } + + @EventHandler + public void onFallDamage(@NotNull final EntityDamageEvent event) { + if (!event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) { + return; + } + + if (!event.getEntity().hasMetadata(IGNORE_FALL_KEY)) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Charge.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Charge.java new file mode 100644 index 00000000..334ebeda --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Charge.java @@ -0,0 +1,27 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.spell; + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.itemtypes.Spell; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +public class Charge extends Spell { + public Charge() { + super("charge"); + } + + @Override + public boolean onUse(@NotNull final Player player, + final int level, + @NotNull final PlayerInteractEvent event) { + Vector velocity = player.getEyeLocation().getDirection().clone(); + velocity.normalize(); + velocity.multiply(level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-per-level")); + velocity.setY(player.getEyeLocation().getDirection().clone().getY() + 0.2); + player.setVelocity(velocity); + + return true; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Dynamite.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Dynamite.java new file mode 100644 index 00000000..2732a851 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Dynamite.java @@ -0,0 +1,90 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.spell; + +import com.willfp.eco.core.integrations.anticheat.AnticheatManager; +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.util.BlockUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.itemtypes.Spell; +import org.bukkit.Particle; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.Set; + +public class Dynamite extends Spell { + public Dynamite() { + super("dynamite"); + } + + @Override + public boolean onUse(@NotNull final Player player, + final int level, + @NotNull final PlayerInteractEvent event) { + Block block = event.getClickedBlock(); + + if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { + return false; + } + + if (block == null) { + return false; + } + + if (block.hasMetadata("block-ignore")) { + return false; + } + + AnticheatManager.exemptPlayer(player); + + Set toBreak = new HashSet<>(); + + int baseDiff = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "base-bonus"); + int bonusPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "per-level-bonus"); + final int size = baseDiff + (bonusPerLevel * (level - 1)); + + + for (int x = -size; x <= size; x++) { + for (int y = -size; y <= size; y++) { + for (int z = -size; z <= size; z++) { + if (x == 0 && y == 0 && z == 0) { + block.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, block.getLocation().clone().add(0.5, 0.5, 0.5), 1); + } + Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(x, y, z)); + + if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks").contains(block1.getType().name().toLowerCase())) { + continue; + } + + if (block1.getType().getHardness() > block.getType().getHardness() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "hardness-check")) { + continue; + } + + if (!AntigriefManager.canBreakBlock(player, block1)) { + continue; + } + + toBreak.add(block1); + } + } + } + + toBreak.forEach((block1 -> { + block1.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true)); + BlockUtils.breakBlock(player, block1); + block1.removeMetadata("block-ignore", this.getPlugin()); + })); + + AnticheatManager.unexemptPlayer(player); + + return true; + } + + @Override + protected boolean requiresBlockClick() { + return true; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Missile.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Missile.java new file mode 100644 index 00000000..7a5aa3d9 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Missile.java @@ -0,0 +1,64 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.spell; + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.itemtypes.Spell; +import org.bukkit.entity.Player; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.jetbrains.annotations.NotNull; + +public class Missile extends Spell { + public Missile() { + super("missile"); + } + + @Override + public boolean onUse(@NotNull final Player player, + final int level, + @NotNull final PlayerInteractEvent event) { + WitherSkull skull = player.launchProjectile(WitherSkull.class, player.getEyeLocation().getDirection().multiply(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity"))); + skull.setCharged(true); + skull.setIsIncendiary(false); + skull.setMetadata("eco-damage", this.getPlugin().getMetadataValueFactory().create(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * level)); + skull.setMetadata("nobreak", this.getPlugin().getMetadataValueFactory().create(true)); + skull.setShooter(player); + + return true; + } + + @EventHandler(priority = EventPriority.LOW) + public void onWitherSkullDamage(@NotNull final EntityDamageByEntityEvent event) { + if (!(event.getDamager() instanceof WitherSkull)) { + return; + } + + if (event.getDamager().getMetadata("eco-damage").isEmpty()) { + return; + } + + double multiplier = event.getDamager().getMetadata("eco-damage").get(0).asDouble(); + + if (((WitherSkull) event.getDamager()).getShooter().equals(event.getEntity())) { + event.setCancelled(true); + } + + event.setDamage(multiplier); + } + + @EventHandler + public void onWitherSkullExplode(@NotNull final EntityExplodeEvent event) { + if (!(event.getEntity() instanceof WitherSkull)) { + return; + } + + if (event.getEntity().getMetadata("nobreak").isEmpty()) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Quake.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Quake.java new file mode 100644 index 00000000..382f3d2d --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Quake.java @@ -0,0 +1,45 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.spell; + +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.itemtypes.Spell; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerInteractEvent; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; + +public class Quake extends Spell { + public Quake() { + super("quake"); + } + + @Override + public boolean onUse(@NotNull final Player player, + final int level, + @NotNull final PlayerInteractEvent event) { + int radius = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "radius-per-level") * level; + int damage = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * level; + + + Collection entities = player.getWorld().getNearbyEntities(player.getLocation(), radius, 3, radius); + + for (Entity entity : entities) { + if (entity.equals(player)) { + continue; + } + if (!(entity instanceof LivingEntity)) { + continue; + } + if (!AntigriefManager.canInjure(player, (LivingEntity) entity)) { + continue; + } + + ((LivingEntity) entity).damage(damage); + } + + return true; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Vitalize.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Vitalize.java new file mode 100644 index 00000000..ef9754a2 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Vitalize.java @@ -0,0 +1,22 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.spell; + +import com.willfp.ecoenchants.enchantments.itemtypes.Spell; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerInteractEvent; +import org.jetbrains.annotations.NotNull; + +public class Vitalize extends Spell { + public Vitalize() { + super("vitalize"); + } + + @Override + public boolean onUse(@NotNull final Player player, + final int level, + @NotNull final PlayerInteractEvent event) { + player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); + + return true; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java new file mode 100644 index 00000000..9da5ea63 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java @@ -0,0 +1,179 @@ +package com.willfp.ecoenchants.enchantments.itemtypes; + +import com.google.common.util.concurrent.AtomicDouble; +import com.willfp.eco.core.Prerequisite; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.Location; +import org.bukkit.Particle; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public abstract class Artifact extends EcoEnchant { + /** + * The artifact particle. + */ + private Particle particle; + + /** + * The extra particle dust options. + *

+ * Used for redstone particles. + */ + @Nullable + private Particle.DustOptions extra; + + /** + * Create a new artifact enchantment. + * + * @param key The key name of the enchantment + * @param prerequisites Optional {@link Prerequisite}s that must be met + */ + protected Artifact(@NotNull final String key, + @NotNull final Prerequisite... prerequisites) { + super(key, EnchantmentType.ARTIFACT, prerequisites); + + if (!Prerequisite.areMet(prerequisites)) { + HandlerList.unregisterAll(this); // Prevent events firing + return; + } + + this.particle = this.getParticle(); + this.extra = this.getDustOptions(); + } + + /** + * Get the artifact particle. + * + * @return The artifact particle. + */ + @NotNull + public abstract Particle getParticle(); + + /** + * The extra particle dust options. + * + * @return The dust options. + */ + @Nullable + public Particle.DustOptions getDustOptions() { + return null; + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + if (!this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "on-blocks").contains(block.getType().name().toLowerCase())) { + return; + } + + int amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "amount"); + block.getWorld().spawnParticle(particle, block.getLocation().add(0.5, 0.5, 0.5), amount, 0.4, 0.4, 0.4, 0, extra, false); + } + + /** + * Called on player fly while wearing an elytra. + * + * @param event The event to listen for. + */ + @EventHandler + public void onElytra(@NotNull final PlayerMoveEvent event) { + Player player = event.getPlayer(); + + if (!player.isGliding()) { + return; + } + + if (!EnchantChecks.chestplate(player, this)) { + return; + } + + Vector point1 = player.getLocation().getDirection().clone(); + point1.rotateAroundY(Math.toRadians(90)); + point1.multiply(1.2); + Location location1 = player.getLocation().clone().add(point1); + + Vector point2 = player.getLocation().getDirection().clone(); + point2.rotateAroundY(Math.toRadians(-90)); + point2.multiply(1.2); + Location location2 = player.getLocation().clone().add(point2); + + player.getWorld().spawnParticle(particle, location1, 1, 0, 0, 0, 0, extra, true); + player.getWorld().spawnParticle(particle, location2, 1, 0, 0, 0, 0, extra, true); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + double radius = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius"); + + AtomicDouble yAtomic = new AtomicDouble(0); + + double yDelta = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "y-delta"); + double radiusMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-multiplier"); + double offset = NumberUtils.randFloat(0, 0.75); + + boolean doubleHelix = this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "use-double-helix"); + + this.getPlugin().getRunnableFactory().create(bukkitRunnable -> { + for (int i = 0; i < 3; i++) { + if (yAtomic.get() > victim.getHeight()) { + bukkitRunnable.cancel(); + } + yAtomic.addAndGet(yDelta); + double y = yAtomic.get(); + double x = radius * NumberUtils.fastCos((y + offset) * radiusMultiplier); + double z = radius * NumberUtils.fastSin((y + offset) * radiusMultiplier); + Location particleLocation = victim.getLocation(); + particleLocation.add(x, y, z); + victim.getWorld().spawnParticle(particle, particleLocation, 1, 0, 0, 0, 0, extra, false); + if (doubleHelix) { + Location particleLocation2 = victim.getLocation(); + particleLocation2.add(-x, y, -z); + victim.getWorld().spawnParticle(particle, particleLocation2, 1, 0, 0, 0, 0, extra, false); + } + } + }).runTaskTimer(0, 1); + } + + @Override + public void onProjectileLaunch(@NotNull final LivingEntity shooter, + @NotNull final Projectile projectile, + final int level, + @NotNull final ProjectileLaunchEvent event) { + int ticks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "particle-tick-delay"); + + int noteColor; + AtomicDouble color = new AtomicDouble(0); + if (particle.equals(Particle.NOTE)) { + noteColor = NumberUtils.randInt(0, 24); + color.set((double) noteColor / 24); + } + final double finalColor = color.get(); + + this.getPlugin().getRunnableFactory().create(bukkitRunnable -> { + if (projectile.isOnGround() || projectile.isDead()) { + bukkitRunnable.cancel(); + } + projectile.getLocation().getWorld().spawnParticle(particle, projectile.getLocation(), 1, 0, 0, 0, finalColor, extra, true); + }).runTaskTimer(4, ticks); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java new file mode 100644 index 00000000..96470d45 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java @@ -0,0 +1,248 @@ +package com.willfp.ecoenchants.enchantments.itemtypes; + +import com.willfp.eco.core.Prerequisite; +import com.willfp.eco.core.integrations.placeholder.PlaceholderEntry; +import com.willfp.eco.core.integrations.placeholder.PlaceholderManager; +import com.willfp.eco.util.StringUtils; +import com.willfp.ecoenchants.display.EnchantmentCache; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.SpellActivateEvent; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.SoundCategory; +import org.bukkit.block.Container; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.BlockInventoryHolder; +import org.bukkit.permissions.PermissionAttachmentInfo; +import org.bukkit.util.NumberConversions; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +public abstract class Spell extends EcoEnchant { + /** + * Items that must be left-clicked to activate spells for. + */ + private static final List LEFT_CLICK_ITEMS = Arrays.asList( + Material.FISHING_ROD, + Material.BOW + ); + /** + * The cooldown end times linked to players. + */ + private final Map tracker = new HashMap<>(); + /** + * Players currently running spells - prevents listener firing twice. + */ + private final Set preventDuplicateList = new HashSet<>(); + + /** + * Create a new spell enchantment. + * + * @param key The key name of the enchantment + * @param prerequisites Optional {@link Prerequisite}s that must be met + */ + protected Spell(@NotNull final String key, + @NotNull final Prerequisite... prerequisites) { + super(key, EnchantmentType.SPELL, prerequisites); + + PlaceholderManager.registerPlaceholder( + new PlaceholderEntry( + this.getPermissionName() + "_" + "cooldown", + player -> StringUtils.internalToString(getCooldown(this, player)) + ) + ); + } + + /** + * Utility method to get a player's cooldown time of a specific spell. + * + * @param spell The spell to query. + * @param player The player to query. + * @return The time left in seconds before next use. + */ + public static int getCooldown(@NotNull final Spell spell, + @NotNull final Player player) { + if (!spell.tracker.containsKey(player.getUniqueId())) { + return 0; + } + + long msLeft = spell.tracker.get(player.getUniqueId()) - System.currentTimeMillis(); + + long secondsLeft = (long) Math.ceil((double) msLeft / 1000); + + return NumberConversions.toInt(secondsLeft); + } + + /** + * Get a multiplier for a spell cooldown. + *

+ * Used for perks.. + * + * @param player The player to query. + * @return The multiplier. + */ + public static double getCooldownMultiplier(@NotNull final Player player) { + if (player.hasPermission("ecoenchants.cooldowntime.quarter")) { + return 0.25; + } + + if (player.hasPermission("ecoenchants.cooldowntime.third")) { + return 0.33; + } + + if (player.hasPermission("ecoenchants.cooldowntime.half")) { + return 0.5; + } + + if (player.hasPermission("ecoenchants.cooldowntime.75")) { + return 0.75; + } + + String prefix = "ecoenchants.cooldowntime."; + for (PermissionAttachmentInfo permissionAttachmentInfo : player.getEffectivePermissions()) { + String permission = permissionAttachmentInfo.getPermission(); + if (permission.startsWith(prefix)) { + try { + return Double.parseDouble(permission.substring(permission.lastIndexOf(".") + 1)) / 100; + } catch (NumberFormatException e) { + return 1; + } + } + } + + return 1; + } + + /** + * Get the cooldown time of the spell (in seconds). + * + * @return The time, in seconds. + */ + public int getCooldownTime() { + return this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "cooldown"); + } + + /** + * Get the sound to be played on activation. + * + * @return The sound. + */ + public final Sound getActivationSound() { + return Sound.valueOf(this.getConfig().getString(EcoEnchants.CONFIG_LOCATION + "activation-sound").toUpperCase()); + } + + /** + * Listener called on spell activation. + * + * @param event The event to listen for. + */ + @EventHandler + public void onUseEventHandler(@NotNull final PlayerInteractEvent event) { + Player player = event.getPlayer(); + + if (preventDuplicateList.contains(player.getUniqueId())) { + return; + } + preventDuplicateList.add(player.getUniqueId()); + this.getPlugin().getScheduler().runLater(() -> preventDuplicateList.remove(player.getUniqueId()), 2); + + if (player.getGameMode() == GameMode.SPECTATOR) { + return; + } + + if (LEFT_CLICK_ITEMS.contains(player.getInventory().getItemInMainHand().getType())) { + if (!(event.getAction().equals(Action.LEFT_CLICK_AIR) || event.getAction().equals(Action.LEFT_CLICK_BLOCK))) { + return; + } + if (requiresBlockClick() && !event.getAction().equals(Action.LEFT_CLICK_BLOCK)) { + return; + } + } else { + if (!(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) { + return; + } + if (requiresBlockClick() && !event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { + return; + } + } + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int cooldown = getCooldown(this, player); + + if (event.getClickedBlock() != null) { + if (event.getClickedBlock().getState() instanceof Container + || event.getClickedBlock().getState() instanceof BlockInventoryHolder + || event.getClickedBlock().getType() == Material.CRAFTING_TABLE + || event.getClickedBlock().getType() == Material.GRINDSTONE + || event.getClickedBlock().getType() == Material.ENCHANTING_TABLE + || event.getClickedBlock().getType() == Material.ANVIL + || event.getClickedBlock().getType() == Material.FURNACE + || event.getClickedBlock().getType() == Material.SMITHING_TABLE) { + return; + } + } + + if (cooldown > 0) { + String message = this.getPlugin().getLangYml().getMessage("on-cooldown").replace("%seconds%", String.valueOf(cooldown)).replace("%name%", EnchantmentCache.getEntry(this).getRawName()); + player.sendMessage(message); + player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 0.5f); + } else { + SpellActivateEvent spellActivateEvent = new SpellActivateEvent(player, this); + Bukkit.getPluginManager().callEvent(spellActivateEvent); + + if (!spellActivateEvent.isCancelled()) { + if (onUse(player, level, event)) { + String message = this.getPlugin().getLangYml().getMessage("used-spell").replace("%name%", EnchantmentCache.getEntry(this).getRawName()); + player.sendMessage(message); + player.playSound(player.getLocation(), this.getActivationSound(), SoundCategory.PLAYERS, 1, 1); + + tracker.remove(player.getUniqueId()); + tracker.put(player.getUniqueId(), System.currentTimeMillis() + (long) ((this.getCooldownTime() * 1000L) * Spell.getCooldownMultiplier(player))); + } + } + } + } + + /** + * Get if the spell requires a block to be clicked to trigger the spell. + * + * @return If the spell requires a block to be clicked. + */ + protected boolean requiresBlockClick() { + return false; + } + + /** + * Actual spell-specific implementations; the functionality. + * + * @param player The player who triggered the spell. + * @param level The level of the spell on the item. + * @param event The event that activated the spell. + */ + public abstract boolean onUse(@NotNull Player player, + int level, + @NotNull PlayerInteractEvent event); +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java new file mode 100644 index 00000000..df8fa597 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java @@ -0,0 +1,158 @@ +package com.willfp.ecoenchants.enchantments.meta; + +import com.willfp.eco.core.config.ConfigUpdater; +import com.willfp.eco.util.StringUtils; +import com.willfp.ecoenchants.EcoEnchantsPlugin; +import com.willfp.ecoenchants.config.RarityYml; +import lombok.Getter; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; + +public class EnchantmentRarity { + /** + * All registered rarities. + */ + private static final Set REGISTERED = new HashSet<>(); + + static { + update(); + } + + /** + * The name of the rarity. + */ + @Getter + private final String name; + /** + * The probability of getting an enchantment with this rarity from an enchanting table. + */ + @Getter + private final double tableProbability; + /** + * The minimum xp level to get an enchantment of this rarity from an enchanting table. + */ + @Getter + private final int minimumLevel; + /** + * The probability of a villager obtaining an enchantment with this rarity. + */ + @Getter + private final double villagerProbability; + /** + * The probability of an item in a loot chest having an enchantment with this rarity. + */ + @Getter + private final double lootProbability; + /** + * The custom display color, or null if not enabled. + */ + @Getter + private final String customColor; + + /** + * Create new EnchantmentRarity. + * + * @param name The name of the rarity + * @param tableProbability The probability of getting an enchantment with this rarity from an enchanting table. + * @param minimumLevel The minimum xp level + * @param villagerProbability The probability of a villager obtaining an enchantment with this rarity + * @param lootProbability The probability of an item in a loot chest having an enchantment with this rarity + * @param customColor The custom display color, or null if not enabled + */ + public EnchantmentRarity(@NotNull final String name, + final double tableProbability, + final int minimumLevel, + final double villagerProbability, + final double lootProbability, + @Nullable final String customColor) { + this.name = name; + this.tableProbability = tableProbability; + this.minimumLevel = minimumLevel; + this.villagerProbability = villagerProbability; + this.lootProbability = lootProbability; + this.customColor = customColor; + } + + /** + * Get EnchantmentRarity matching name. + * + * @param name The name to search for. + * @return The matching EnchantmentRarity, or null if not found. + */ + public static EnchantmentRarity getByName(@NotNull final String name) { + Optional matching = REGISTERED.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst(); + return matching.orElse(null); + } + + /** + * Update all rarities. + */ + @ConfigUpdater + public static void update() { + RarityYml rarityYml = EcoEnchantsPlugin.getInstance().getRarityYml(); + List raritiesNames = rarityYml.getRarities(); + raritiesNames.forEach(rarity -> { + double probability = rarityYml.getDouble("rarities." + rarity + ".table-probability"); + int minimumLevel = rarityYml.getInt("rarities." + rarity + ".minimum-level"); + double villagerProbability = rarityYml.getDouble("rarities." + rarity + ".villager-probability"); + double lootProbability = rarityYml.getDouble("rarities." + rarity + ".loot-probability"); + String customColor = null; + if (rarityYml.getBool("rarities." + rarity + ".custom-color.enabled")) { + customColor = StringUtils.translate(rarityYml.getString("rarities." + rarity + ".custom-color.color")); + } + + new EnchantmentRarity(rarity, probability, minimumLevel, villagerProbability, lootProbability, customColor).register(); + }); + } + + /** + * Get all rarities. + * + * @return A set of all rarities. + */ + public static Set values() { + return REGISTERED; + } + + /** + * Register rarity. + */ + private void register() { + Optional matching = REGISTERED.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst(); + matching.ifPresent(REGISTERED::remove); + + REGISTERED.add(this); + } + + /** + * Is custom color enabled. + * + * @return If has enabled custom color. + */ + public boolean hasCustomColor() { + return this.customColor != null; + } + + @Override + public boolean equals(@NotNull final Object o) { + if (this == o) { + return true; + } + if (!(o instanceof EnchantmentRarity)) { + return false; + } + EnchantmentRarity that = (EnchantmentRarity) o; + return Objects.equals(getName(), that.getName()); + } + + @Override + public int hashCode() { + return Objects.hash(getName()); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java new file mode 100644 index 00000000..92280e0c --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java @@ -0,0 +1,95 @@ +package com.willfp.ecoenchants.enchantments.meta; + +import com.google.common.collect.ImmutableSet; +import com.willfp.eco.core.config.ConfigUpdater; +import com.willfp.ecoenchants.EcoEnchantsPlugin; +import lombok.Getter; +import org.bukkit.Material; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; + +public class EnchantmentTarget { + /** + * Target containing the materials from all other targets. + */ + public static final EnchantmentTarget ALL = new EnchantmentTarget("all", new HashSet<>()); + /** + * All registered targets. + */ + private static final Set REGISTERED = new HashSet<>(); + + static { + REGISTERED.add(ALL); + update(); + } + + /** + * The name of the target. + */ + @Getter + private final String name; + /** + * The materials of the target. + */ + @Getter + private final Set materials; + + /** + * Create new rarity. + * + * @param name The name of the rarity + * @param materials The items for the target + */ + public EnchantmentTarget(@NotNull final String name, + @NotNull final Set materials) { + this.name = name; + materials.removeIf(Objects::isNull); + this.materials = materials; + } + + /** + * Get EnchantmentTarget matching name. + * + * @param name The name to search for. + * @return The matching EnchantmentTarget, or null if not found. + */ + public static EnchantmentTarget getByName(@NotNull final String name) { + Optional matching = REGISTERED.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst(); + return matching.orElse(null); + } + + /** + * Update all targets. + */ + @ConfigUpdater + public static void update() { + List targetNames = EcoEnchantsPlugin.getInstance().getTargetYml().getTargets(); + ALL.materials.clear(); + targetNames.forEach(name -> { + Set materials = EcoEnchantsPlugin.getInstance().getTargetYml().getTargetMaterials(name); + new EnchantmentTarget(name, materials).register(); + }); + } + + /** + * Get all rarities. + * + * @return A set of all rarities. + */ + public static Set values() { + return ImmutableSet.copyOf(REGISTERED); + } + + private void register() { + Optional matching = REGISTERED.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst(); + matching.ifPresent(REGISTERED::remove); + matching.ifPresent(enchantmentTarget -> ALL.getMaterials().removeAll(enchantmentTarget.getMaterials())); + REGISTERED.add(this); + ALL.getMaterials().addAll(this.getMaterials()); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentType.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentType.java new file mode 100644 index 00000000..4582ffe0 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentType.java @@ -0,0 +1,242 @@ +package com.willfp.ecoenchants.enchantments.meta; + +import com.google.common.collect.ImmutableList; +import com.willfp.eco.core.config.ConfigUpdater; +import com.willfp.ecoenchants.EcoEnchantsPlugin; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import com.willfp.ecoenchants.enchantments.itemtypes.Spell; +import lombok.Getter; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.function.Supplier; + +public class EnchantmentType { + /** + * Instance of EcoEnchants. + */ + private static final EcoEnchantsPlugin PLUGIN = EcoEnchantsPlugin.getInstance(); + + /** + * All registered types. + */ + private static final List REGISTERED = new ArrayList<>(); + + /** + * Most enchantments are like this. + *

+ * eg: Arachnid, Telekinesis, Sharpness. + */ + public static final EnchantmentType NORMAL = new EnchantmentType( + "normal", + false, + () -> PLUGIN.getLangYml().getString("not-curse-color") + ); + + /** + * Negative enchantments. + *

+ * eg: Curse of Decay, Curse of Vanishing. + */ + public static final EnchantmentType CURSE = new EnchantmentType( + "curse", + false, + () -> PLUGIN.getLangYml().getString("curse-color") + ); + + /** + * Extremely powerful enchantments. + *

+ * eg: Razor, Force. + */ + public static final EnchantmentType SPECIAL = new EnchantmentType( + "special", + () -> !PLUGIN.getConfigYml().getBool("types.special.allow-multiple"), + () -> PLUGIN.getLangYml().getString("special-color") + ); + + /** + * Cosmetic enchantments. + *

+ * eg: Ash Artifact, Totem Artifact. + */ + public static final EnchantmentType ARTIFACT = new EnchantmentType( + "artifact", + () -> !PLUGIN.getConfigYml().getBool("types.artifact.allow-multiple"), + () -> PLUGIN.getLangYml().getString("artifact-color"), + Artifact.class + ); + + /** + * Ability enchantments. + *

+ * eg: Missile, Quake. + */ + public static final EnchantmentType SPELL = new EnchantmentType( + "spell", + true, + () -> PLUGIN.getLangYml().getString("spell-color"), + Spell.class + ); + + /** + * Lambda to fetch the color of the type. + */ + private final Supplier colorSupplier; + + /** + * Lambda to fetch the singularity of the type. + */ + private final Supplier singularSupplier; + + /** + * The name of the type. + */ + @Getter + private final String name; + + /** + * The class that all enchantments of this type must extend. + *

+ * Null if not required. + */ + @Getter + @Nullable + private final Class requiredToExtend; + + /** + * If only one enchantment of this type is allowed on an item. + */ + @Getter + private boolean singular; + + /** + * The color of enchantments of this type to have in lore. + */ + @Getter + private String color; + + /** + * Create simple EnchantmentType. + *

+ * Singularity and Color will not be updated using this constructor. + * + * @param name The name of the type. + * @param singular Whether an item can have several enchantments of this type. + * @param color The color for enchantments with this type in lore to have. + */ + public EnchantmentType(@NotNull final String name, + final boolean singular, + @NotNull final String color) { + this(name, () -> singular, () -> color); + } + + /** + * Create EnchantmentType with updatable color. + *

+ * Singularity will not be updated using this constructor. + * + * @param name The name of the type. + * @param singular Whether an item can have several enchantments of this type. + * @param colorSupplier Lambda to fetch the color of enchantments with this type to have. Updates on /ecoreload. + */ + public EnchantmentType(@NotNull final String name, + final boolean singular, + @NotNull final Supplier colorSupplier) { + this(name, () -> singular, colorSupplier); + } + + /** + * Create EnchantmentType with updatable color that must extend a specified class. + *

+ * Singularity will not be updated using this constructor. + * + * @param name The name of the type. + * @param singular Whether an item can have several enchantments of this type. + * @param colorSupplier Lambda to fetch the color of enchantments with this type to have. Updates on /ecoreload. + * @param requiredToExtend Class that all enchantments of this type must extend - or null if not required. + */ + public EnchantmentType(@NotNull final String name, + final boolean singular, + @NotNull final Supplier colorSupplier, + @Nullable final Class requiredToExtend) { + this(name, () -> singular, colorSupplier, requiredToExtend); + } + + /** + * Create EnchantmentType with updatable color and singularity. + * + * @param name The name of the type. + * @param singularSupplier Lambda to fetch whether an item can have several enchantments of this type. Updates on /ecoreload. + * @param colorSupplier Lambda to fetch the color of enchantments with this type to have. Updates on /ecoreload. + */ + public EnchantmentType(@NotNull final String name, + @NotNull final Supplier singularSupplier, + @NotNull final Supplier colorSupplier) { + this(name, singularSupplier, colorSupplier, null); + } + + /** + * Create EnchantmentType with updatable color and singularity that must extend a specified class. + * + * @param name The name of the type. + * @param singularSupplier Lambda to fetch whether an item can have several enchantments of this type. Updates on /ecoreload. + * @param colorSupplier Lambda to fetch the color of enchantments with this type to have. Updates on /ecoreload. + * @param requiredToExtend Class that all enchantments of this type must extend - or null if not required. + */ + public EnchantmentType(@NotNull final String name, + @NotNull final Supplier singularSupplier, + @NotNull final Supplier colorSupplier, + @Nullable final Class requiredToExtend) { + this.name = name; + this.singularSupplier = singularSupplier; + this.colorSupplier = colorSupplier; + this.requiredToExtend = requiredToExtend; + color = colorSupplier.get(); + singular = singularSupplier.get(); + REGISTERED.add(this); + } + + /** + * Update suppliers of all types. + */ + @ConfigUpdater + public static void update() { + REGISTERED.forEach(EnchantmentType::refresh); + } + + /** + * All registered enchantment types. + * + * @return All registered types. + */ + public static List values() { + return ImmutableList.copyOf(REGISTERED); + } + + private void refresh() { + this.color = colorSupplier.get(); + this.singular = singularSupplier.get(); + } + + @Override + public boolean equals(@NotNull final Object o) { + if (this == o) { + return true; + } + if (!(o instanceof EnchantmentType)) { + return false; + } + EnchantmentType that = (EnchantmentType) o; + return Objects.equals(getName(), that.getName()); + } + + @Override + public int hashCode() { + return Objects.hash(getName()); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java new file mode 100644 index 00000000..4e6afb0e --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java @@ -0,0 +1,143 @@ +package com.willfp.ecoenchants.enchantments.support.merging.anvil; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.eco.core.proxy.ProxyConstants; +import com.willfp.eco.core.tuples.Pair; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy; +import com.willfp.ecoenchants.proxy.proxies.RepairCostProxy; +import com.willfp.ecoenchants.util.ProxyUtils; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.PrepareAnvilEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.HashMap; +import java.util.Objects; +import java.util.UUID; + +public class AnvilListeners extends PluginDependent implements Listener { + /** + * Map to prevent incrementing cost several times as inventory events are fired 3 times. + */ + private static final HashMap ANTI_REPEAT = new HashMap<>(); + + /** + * Class for AnvilGUI wrappers to ignore them. + */ + private static final String ANVIL_GUI_CLASS = "net.wesjd.anvilgui.version.Wrapper" + ProxyConstants.NMS_VERSION.substring(1) + "$AnvilContainer"; + + /** + * Instantiate anvil listeners and link them to a specific plugin. + * + * @param plugin The plugin to link to. + */ + public AnvilListeners(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + /** + * Called when items are placed into an anvil. + * + * @param event The event to listen to. + */ + @EventHandler(priority = EventPriority.HIGHEST) + public void onAnvilPrepare(@NotNull final PrepareAnvilEvent event) { + ItemStack left = event.getInventory().getItem(0); + ItemStack right = event.getInventory().getItem(1); + ItemStack out = event.getResult(); + String name = event.getInventory().getRenameText(); + + if (event.getViewers().isEmpty()) { + return; // Prevent ArrayIndexOutOfBoundsException when using AnvilGUI + } + + event.setResult(null); + event.getInventory().setItem(2, null); + + Player player = (Player) event.getViewers().get(0); + if (ProxyUtils.getProxy(OpenInventoryProxy.class).getOpenInventory(player).getClass().toString().equals(ANVIL_GUI_CLASS)) { + return; + } + + if (name == null) { + name = ""; + } + + Pair newOut = AnvilMerge.doMerge(left, right, out, name, player); + + if (newOut.getFirst() == null) { + newOut.setFirst(new ItemStack(Material.AIR, 0)); + } + + int modCost; + if (newOut.getSecond() == null) { + modCost = 0; + } else { + modCost = newOut.getSecond(); + } + + this.getPlugin().getScheduler().run(() -> { + + // This is a disgusting bodge + if (!ANTI_REPEAT.containsKey(player.getUniqueId())) { + ANTI_REPEAT.put(player.getUniqueId(), 0); + } + + Integer num = ANTI_REPEAT.get(player.getUniqueId()); + num += 1; + ANTI_REPEAT.put(player.getUniqueId(), num); + + this.getPlugin().getScheduler().runLater(() -> ANTI_REPEAT.remove(player.getUniqueId()), 1); + + // End pain + + int preCost = event.getInventory().getRepairCost(); + ItemStack item = newOut.getFirst(); + + if (event.getInventory().getItem(0) == null) { + return; + } + + if (!Objects.requireNonNull(event.getInventory().getItem(0)).getType().equals(item.getType())) { + return; + } + + if (this.getPlugin().getConfigYml().getBool("anvil.rework-cost")) { + int repairCost = ProxyUtils.getProxy(RepairCostProxy.class).getRepairCost(item); + int reworkCount = NumberUtils.log2(repairCost + 1); + if (repairCost == 0) { + reworkCount = 0; + } + reworkCount++; + repairCost = (int) Math.pow(2, reworkCount) - 1; + item = ProxyUtils.getProxy(RepairCostProxy.class).setRepairCost(item, repairCost); + } + + int cost; + + if (ANTI_REPEAT.get(player.getUniqueId()) == 1) { + cost = preCost + modCost; + } else { + cost = preCost; + } + + if (!Objects.equals(left, player.getOpenInventory().getItem(0))) { + return; + } + if (cost == 0) { + return; + } + + event.getInventory().setRepairCost(cost); + event.setResult(item); + event.getInventory().setItem(2, item); + player.updateInventory(); + }); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java new file mode 100644 index 00000000..f8f2be83 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java @@ -0,0 +1,274 @@ +package com.willfp.ecoenchants.enchantments.support.merging.anvil; + +import com.willfp.eco.core.tuples.Pair; +import com.willfp.eco.util.StringUtils; +import com.willfp.ecoenchants.EcoEnchantsPlugin; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import lombok.experimental.UtilityClass; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +@UtilityClass +public class AnvilMerge { + /** + * Instance of EcoEnchants. + */ + private static final EcoEnchantsPlugin PLUGIN = EcoEnchantsPlugin.getInstance(); + + /** + * Config key for allowing unsafe levels. + */ + private static final String ALLOW_UNSAFE_KEY = "anvil.allow-unsafe-levels"; + + /** + * Merge items in anvil. + * + * @param left The {@link ItemStack} on the left of the anvil. + * @param right The {@link ItemStack} in the middle of the anvil. + * @param old The previous {@link ItemStack} result. + * @param itemName The anvil display name. + * @param player The player merging (for permissions). + * @return The result, stored as a {@link Pair} of {@link ItemStack} and {@link Integer}. + */ + public Pair doMerge(@Nullable final ItemStack left, + @Nullable final ItemStack right, + @Nullable final ItemStack old, + @NotNull final String itemName, + @NotNull final Player player) { + // Here so it can be accessed later (scope) + + // Copied to non-final string. + String name = itemName; + + int outDamage = -1; + if (old != null && old.getItemMeta() instanceof Damageable) { + outDamage = ((Damageable) old.getItemMeta()).getDamage(); + } + + if (left == null) { + return new Pair<>(null, null); + } + + if (left.getEnchantments().containsKey(EcoEnchants.PERMANENCE_CURSE)) { + return new Pair<>(null, null); + } + + name = name.replace("§", "&"); + + if (player.hasPermission("ecoenchants.anvil.color")) { + name = StringUtils.translate(name); + } + + if (!EnchantmentTarget.ALL.getMaterials().contains(left.getType()) || right == null || !EnchantmentTarget.ALL.getMaterials().contains(right.getType())) { + ItemStack out = left.clone(); + ItemMeta outMeta = out.getItemMeta(); + assert outMeta != null; + ItemMeta meta = left.getItemMeta(); + assert meta != null; + + outMeta.setDisplayName(name); + + if (meta.getDisplayName().equals(name)) { + + if (meta instanceof Damageable) { + int leftDamage = ((Damageable) meta).getDamage(); + + if (outDamage >= leftDamage || outDamage == -1) { + return new Pair<>(null, null); + } else { + ((Damageable) outMeta).setDamage(outDamage); + } + } else { + return new Pair<>(null, null); + } + if (right == null) { + return new Pair<>(null, null); + } + } + + out.setItemMeta(outMeta); + + if (out.equals(left)) { + return new Pair<>(null, null); + } + return new Pair<>(out, 0); + } + + if (left.getItemMeta() instanceof Damageable && right.getItemMeta() instanceof EnchantmentStorageMeta) { + outDamage = ((Damageable) left.getItemMeta()).getDamage(); + } + + if (!left.getType().equals(right.getType()) && !(right.getItemMeta() instanceof EnchantmentStorageMeta)) { + return new Pair<>(null, null); + } + + if (left.getAmount() != right.getAmount()) { + return new Pair<>(null, null); + } + + HashMap leftEnchants = new HashMap<>(); + HashMap rightEnchants = new HashMap<>(); + + Map outEnchants = new HashMap<>(); + + if (left.getItemMeta() instanceof EnchantmentStorageMeta) { + leftEnchants.putAll(((EnchantmentStorageMeta) left.getItemMeta()).getStoredEnchants()); + } else { + leftEnchants.putAll(left.getItemMeta().getEnchants()); + } + + if (right.getItemMeta() instanceof EnchantmentStorageMeta) { + rightEnchants.putAll(((EnchantmentStorageMeta) right.getItemMeta()).getStoredEnchants()); + } else { + rightEnchants.putAll(right.getItemMeta().getEnchants()); + } + + leftEnchants.forEach(((enchantment, integer) -> { + int level = integer; + + if (rightEnchants.containsKey(enchantment)) { + int rightLevel = rightEnchants.get(enchantment); + if (rightLevel > level) { + level = rightLevel; + } else if (rightLevel == level + && ((rightLevel > enchantment.getMaxLevel() && PLUGIN.getConfigYml().getBool("anvil.allow-combining-unsafe")) + || ((rightLevel + 1) <= enchantment.getMaxLevel() || PLUGIN.getConfigYml().getBool(ALLOW_UNSAFE_KEY)))) { + level++; + } + rightEnchants.remove(enchantment); + } + + outEnchants.put(enchantment, level); + })); + + rightEnchants.forEach(((enchantment, integer) -> { + AtomicBoolean doesConflict = new AtomicBoolean(false); + + EnchantmentType.values().forEach(enchantmentType -> { + EcoEnchant enchant = EcoEnchants.getFromEnchantment(enchantment); + if (enchant == null) { + return; + } + if (enchant.getType().equals(enchantmentType) && EcoEnchants.hasAnyOfType(left, enchantmentType) && enchantmentType.isSingular()) { + doesConflict.set(true); + } + }); + + leftEnchants.forEach((enchantment1, integer1) -> { + if (enchantment.conflictsWith(enchantment1)) { + doesConflict.set(true); + } + if (enchantment1.conflictsWith(enchantment)) { + doesConflict.set(true); + } + }); + + boolean canEnchantItem = enchantment.canEnchantItem(left); + if (left.getItemMeta() instanceof EnchantmentStorageMeta) { + canEnchantItem = true; + } + + if (canEnchantItem && !doesConflict.get()) { + if (PLUGIN.getConfigYml().getBool("anvil.hard-cap.enabled") && !player.hasPermission("ecoenchants.anvil.bypasshardcap") && outEnchants.size() >= PLUGIN.getConfigYml().getInt("anvil.hard-cap.cap")) { + return; + } + outEnchants.put(enchantment, integer); + } + })); + + // Test if the output is the same as left + if (outEnchants.equals(leftEnchants) && left.getItemMeta().getDisplayName().equals(name) && left.getItemMeta() instanceof Damageable) { + int leftDamage = ((Damageable) left.getItemMeta()).getDamage(); + + if (outDamage == leftDamage) { + return new Pair<>(null, null); + } + } + + ItemStack output = left.clone(); + + if (output.getItemMeta() instanceof EnchantmentStorageMeta) { + EnchantmentStorageMeta meta = (EnchantmentStorageMeta) output.getItemMeta(); + meta.getStoredEnchants().forEach(((enchantment, integer) -> { + meta.removeStoredEnchant(enchantment); + })); + + outEnchants.forEach(((enchantment, integer) -> { + meta.addStoredEnchant(enchantment, integer, PLUGIN.getConfigYml().getBool("anvil.allow-existing-unsafe-levels") || PLUGIN.getConfigYml().getBool(ALLOW_UNSAFE_KEY)); + })); + + meta.setDisplayName(name); + + output.setItemMeta(meta); + } else { + ItemMeta meta = output.getItemMeta(); + meta.getEnchants().forEach(((enchantment, integer) -> { + meta.removeEnchant(enchantment); + })); + + outEnchants.forEach(((enchantment, integer) -> { + meta.addEnchant(enchantment, integer, PLUGIN.getConfigYml().getBool("anvil.allow-existing-unsafe-levels") || PLUGIN.getConfigYml().getBool(ALLOW_UNSAFE_KEY)); + })); + + if (output.getItemMeta() instanceof Damageable) { + ((Damageable) meta).setDamage(outDamage); + } + + meta.setDisplayName(name); + + output.setItemMeta(meta); + } + + + // Calculate difference in enchant levels + int totalEnchantLevelDelta; + AtomicInteger outEnchantLevels = new AtomicInteger(); + AtomicInteger inEnchantLevels = new AtomicInteger(); + + outEnchants.forEach(((enchantment, integer) -> { + if (EcoEnchants.getFromEnchantment(enchantment) != null) { + outEnchantLevels.addAndGet(integer); + } + })); + leftEnchants.forEach(((enchantment, integer) -> { + if (EcoEnchants.getFromEnchantment(enchantment) != null) { + outEnchantLevels.addAndGet(integer); + } + })); + + totalEnchantLevelDelta = Math.abs(outEnchantLevels.intValue() - inEnchantLevels.intValue()); + + if (output.equals(left)) { + return new Pair<>(null, null); + } + + if (PLUGIN.getConfigYml().getBool("anvil.cost-exponent.enabled")) { + double exponent = PLUGIN.getConfigYml().getDouble("anvil.cost-exponent.exponent"); + int prevDelta = totalEnchantLevelDelta; + + double costMultiplier = Math.pow(exponent, totalEnchantLevelDelta); + double modifiedCost = Math.ceil((double) totalEnchantLevelDelta * costMultiplier); + totalEnchantLevelDelta = (int) modifiedCost; + + if (prevDelta > 0 && totalEnchantLevelDelta == 0) { + totalEnchantLevelDelta = prevDelta; + } + } + + return new Pair<>(output, totalEnchantLevelDelta); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneListeners.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneListeners.java new file mode 100644 index 00000000..a05fb91a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneListeners.java @@ -0,0 +1,80 @@ +package com.willfp.ecoenchants.enchantments.support.merging.grindstone; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.GrindstoneInventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; + +public class GrindstoneListeners extends PluginDependent implements Listener { + /** + * Instantiate grindstone listeners and link them to a specific plugin. + * + * @param plugin The plugin to link to. + */ + public GrindstoneListeners(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + /** + * Called when items are grindstoned. + * + * @param event The event to listen to. + */ + @EventHandler + public void onGrindstone(@NotNull final InventoryClickEvent event) { + Player player = (Player) event.getWhoClicked(); + + if (player.getOpenInventory().getTopInventory().getType() != InventoryType.GRINDSTONE) { + return; + } + + GrindstoneInventory inventory = (GrindstoneInventory) player.getOpenInventory().getTopInventory(); + + this.getPlugin().getScheduler().runLater(() -> { + ItemStack top = inventory.getItem(0); + ItemStack bottom = inventory.getItem(1); + ItemStack out = inventory.getItem(2); + + Map toKeep = GrindstoneMerge.doMerge(top, bottom); + + if (toKeep.isEmpty()) { + inventory.setItem(2, out); + } + if (out == null) { + return; + } + + ItemStack newOut = out.clone(); + if (newOut.getItemMeta() instanceof EnchantmentStorageMeta) { + EnchantmentStorageMeta meta = (EnchantmentStorageMeta) newOut.getItemMeta(); + toKeep.forEach(((enchantment, integer) -> { + meta.addStoredEnchant(enchantment, integer, true); + })); + newOut.setItemMeta(meta); + } else { + ItemMeta meta = newOut.getItemMeta(); + toKeep.forEach(((enchantment, integer) -> { + meta.addEnchant(enchantment, integer, true); + })); + newOut.setItemMeta(meta); + } + + final ItemStack finalOut = newOut; + + this.getPlugin().getScheduler().run(() -> { + inventory.setItem(2, finalOut); + }); + }, 1); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneMerge.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneMerge.java new file mode 100644 index 00000000..66ade936 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneMerge.java @@ -0,0 +1,75 @@ +package com.willfp.ecoenchants.enchantments.support.merging.grindstone; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import lombok.experimental.UtilityClass; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + +@SuppressWarnings("deprecation") +@UtilityClass +public class GrindstoneMerge { + + /** + * Merge items in a grindstone. + * + * @param top The item at the top of the GUI. + * @param bottom The item at the bottom of the GUI. + * @return All enchantments for the output item to have. + */ + public static Map doMerge(@Nullable final ItemStack top, + @Nullable final ItemStack bottom) { + Map bottomEnchants = new HashMap<>(); + Map topEnchants = new HashMap<>(); + + Map toKeep = new HashMap<>(); + + if (top != null) { + if (top.getItemMeta() instanceof EnchantmentStorageMeta) { + topEnchants = new HashMap<>(((EnchantmentStorageMeta) top.getItemMeta()).getStoredEnchants()); + } else { + topEnchants = new HashMap<>(top.getEnchantments()); + } + } + + if (bottom != null) { + if (bottom.getItemMeta() instanceof EnchantmentStorageMeta) { + bottomEnchants = new HashMap<>(((EnchantmentStorageMeta) bottom.getItemMeta()).getStoredEnchants()); + } else { + bottomEnchants = new HashMap<>(bottom.getEnchantments()); + } + } + + bottomEnchants.forEach(((enchantment, integer) -> { + if (EcoEnchants.getFromEnchantment(enchantment) != null) { + EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchantment); + if (!ecoEnchant.isGrindstoneable()) { + toKeep.putIfAbsent(enchantment, integer); + } + } else { + if (enchantment.isCursed()) { + toKeep.putIfAbsent(enchantment, integer); + } + } + })); + topEnchants.forEach(((enchantment, integer) -> { + if (EcoEnchants.getFromEnchantment(enchantment) != null) { + EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchantment); + if (!ecoEnchant.isGrindstoneable()) { + toKeep.putIfAbsent(enchantment, integer); + } + } else { + if (enchantment.isCursed()) { + toKeep.putIfAbsent(enchantment, integer); + } + } + })); + + return toKeep; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java new file mode 100644 index 00000000..6df726c7 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java @@ -0,0 +1,295 @@ +package com.willfp.ecoenchants.enchantments.support.obtaining; + +import com.google.common.collect.ImmutableSet; +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.enchantments.EnchantmentOffer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.enchantment.EnchantItemEvent; +import org.bukkit.event.enchantment.PrepareItemEnchantEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + +public class EnchantingListeners extends PluginDependent implements Listener { + /** + * All players currently enchanting a secondary item. + */ + public static final Map CURRENTLY_ENCHANTING_SECONDARY = new HashMap<>(); + /** + * All enchantments that by default cannot be enchanted in a table but are in EcoEnchants. + */ + private static final Set SECONDARY_ENCHANTABLE = new ImmutableSet.Builder() + .add(Material.ELYTRA) + .add(Material.SHIELD) + .add(Material.FLINT_AND_STEEL) + .add(Material.SHEARS) + .add(Material.CARROT_ON_A_STICK).build(); + + /** + * Instantiate enchanting listeners and link them to a specific plugin. + * + * @param plugin The plugin to link to. + */ + public EnchantingListeners(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + /** + * Called on player leave. + * + * @param event The event to listen to. + */ + @EventHandler + public void onPlayerLeave(@NotNull final PlayerQuitEvent event) { + CURRENTLY_ENCHANTING_SECONDARY.remove(event.getPlayer()); + } + + /** + * Called on player enchant item. + * + * @param event The event to listen to. + */ + @EventHandler + public void enchantItem(@NotNull final EnchantItemEvent event) { + Player player = event.getEnchanter(); + ItemStack item = event.getItem(); + int cost = event.getExpLevelCost(); + + Map toAdd = event.getEnchantsToAdd(); + if (!this.getPlugin().getConfigYml().getBool("enchanting-table.enabled")) { + this.getPlugin().getScheduler().runLater(() -> { + ItemStack item0 = event.getInventory().getItem(0); + event.getInventory().setItem(0, item0); + }, 1); + return; + } + + if (SECONDARY_ENCHANTABLE.contains(event.getItem().getType())) { + ItemStack lapis = event.getInventory().getItem(1); + if (!player.getGameMode().equals(GameMode.CREATIVE)) { + if (lapis == null) { + event.setCancelled(true); + return; + } + + if (lapis.getAmount() < event.whichButton() + 1) { + event.setCancelled(true); + return; + } + + lapis.setAmount(lapis.getAmount() - (event.whichButton() + 1)); + + event.getInventory().setItem(1, lapis); + } + } + + double multiplier = 0.01; + if (item.getType().equals(Material.BOOK) || item.getType().equals(Material.ENCHANTED_BOOK)) { + multiplier /= this.getPlugin().getConfigYml().getInt("enchanting-table.book-times-less-likely"); + } + + if (this.getPlugin().getConfigYml().getBool("enchanting-table.reduce-probability.enabled")) { + multiplier /= this.getPlugin().getConfigYml().getDouble("enchanting-table.reduce-probability.factor"); + } + + ArrayList enchantments = new ArrayList<>(EcoEnchants.values()); + Collections.shuffle(enchantments); // Prevent list bias towards early enchantments like telekinesis + + boolean gotSpecial = false; + + for (EcoEnchant enchantment : enchantments) { + if (!enchantment.canEnchantItem(item)) { + continue; + } + if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getTableProbability() * multiplier) { + continue; + } + if (enchantment.getRarity().getMinimumLevel() > cost) { + continue; + } + if (!enchantment.isEnabled()) { + continue; + } + if (!enchantment.isAvailableFromTable()) { + continue; + } + if (!player.hasPermission("ecoenchants.fromtable." + enchantment.getPermissionName())) { + continue; + } + + AtomicBoolean anyConflicts = new AtomicBoolean(false); + + toAdd.forEach((enchant, integer) -> { + if (enchantment.conflictsWithAny(toAdd.keySet())) { + anyConflicts.set(true); + } + if (enchant.conflictsWith(enchantment)) { + anyConflicts.set(true); + } + + if (EcoEnchants.getFromEnchantment(enchant) != null) { + EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchant); + if (enchantment.getType().equals(ecoEnchant.getType()) && ecoEnchant.getType().isSingular()) { + anyConflicts.set(true); + } + } + }); + if (anyConflicts.get()) { + continue; + } + + int level; + + double maxLevelDouble = enchantment.getMaxLevel(); + + if (enchantment.getType().equals(EnchantmentType.SPECIAL)) { + double enchantlevel1 = NumberUtils.randFloat(0, 1); + double enchantlevel2 = NumberUtils.bias(enchantlevel1, this.getPlugin().getConfigYml().getDouble("enchanting-table.special-bias")); + double enchantlevel3 = 1 / maxLevelDouble; + level = (int) Math.ceil(enchantlevel2 / enchantlevel3); + } else { + int maxLevel = this.getPlugin().getConfigYml().getInt("enchanting-table.maximum-obtainable-level"); + double enchantlevel1 = (cost / (double) enchantment.getRarity().getMinimumLevel()) / (maxLevel / (double) enchantment.getRarity().getMinimumLevel()); + double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, enchantlevel1); + double enchantlevel3 = 1 / maxLevelDouble; + level = (int) Math.ceil(enchantlevel2 / enchantlevel3); + } + + level = NumberUtils.equalIfOver(level, enchantment.getMaxLevel()); + toAdd.put(enchantment, level); + + if (this.getPlugin().getConfigYml().getBool("enchanting-table.cap-amount.enabled") && toAdd.size() >= this.getPlugin().getConfigYml().getInt("enchanting-table.cap-amount.limit")) { + break; + } + + if (enchantment.getType().equals(EnchantmentType.SPECIAL)) { + gotSpecial = true; + } + + if (this.getPlugin().getConfigYml().getBool("enchanting-table.reduce-probability.enabled")) { + multiplier /= this.getPlugin().getConfigYml().getDouble("enchanting-table.reduce-probability.factor"); + } + } + toAdd.forEach(event.getEnchantsToAdd()::putIfAbsent); + + if (SECONDARY_ENCHANTABLE.contains(event.getItem().getType()) && !toAdd.containsKey(EcoEnchants.INDESTRUCTIBILITY)) { + event.getEnchantsToAdd().put(Enchantment.DURABILITY, CURRENTLY_ENCHANTING_SECONDARY.get(player)[event.whichButton()]); + CURRENTLY_ENCHANTING_SECONDARY.remove(player); + } + + if (gotSpecial && this.getPlugin().getConfigYml().getBool("enchanting-table.notify-on-special")) { + player.sendMessage(this.getPlugin().getLangYml().getMessage("got-special")); + } + + // Ew + this.getPlugin().getScheduler().runLater(() -> { + ItemStack item0 = event.getInventory().getItem(0); + assert item0 != null; + if (item0.getItemMeta() instanceof EnchantmentStorageMeta) { + EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item0.getItemMeta(); + for (Enchantment enchantment : meta.getStoredEnchants().keySet()) { + meta.removeStoredEnchant(enchantment); + } + event.getEnchantsToAdd().forEach(((enchantment, integer) -> { + meta.addStoredEnchant(enchantment, integer, false); + })); + item0.setItemMeta(meta); + } + event.getInventory().setItem(0, item0); + }, 1); + } + + /** + * Called on prepare enchant. + * For secondary enchantments, generates unbreaking tooltips. + * + * @param event The event to listen to. + */ + @EventHandler + public void secondaryEnchant(@NotNull final PrepareItemEnchantEvent event) { + int maxLevel = this.getPlugin().getConfigYml().getInt("enchanting-table.maximum-obtainable-level"); + + try { + event.getOffers()[2].setCost(NumberUtils.equalIfOver(event.getOffers()[2].getCost(), maxLevel)); + } catch (ArrayIndexOutOfBoundsException | NullPointerException ignored) { + } + + if (!SECONDARY_ENCHANTABLE.contains(event.getItem().getType())) { + return; + } + + int bonus = event.getEnchantmentBonus(); + if (bonus > 15) { + bonus = 15; + } + if (bonus == 0) { + bonus = 1; + } + + double baseLevel = NumberUtils.randInt(1, 8) + Math.floor((double) bonus / 2) + NumberUtils.randInt(0, bonus); + + int bottomEnchantLevel = (int) Math.ceil(Math.max(baseLevel / 3, 1)); + int midEnchantLevel = (int) ((baseLevel * 2) / 3) + 1; + int topEnchantLevel = (int) Math.max(baseLevel, bonus * 2); + + bottomEnchantLevel *= (int) Math.ceil((double) maxLevel / 30); + midEnchantLevel *= (int) Math.ceil((double) maxLevel / 30); + topEnchantLevel *= (int) Math.ceil((double) maxLevel / 30); + + bottomEnchantLevel = NumberUtils.equalIfOver(bottomEnchantLevel, maxLevel); + + int midUnbreakingLevel = NumberUtils.randInt(1, 3); + if (midUnbreakingLevel < 2) { + midUnbreakingLevel = 2; + } + if (midEnchantLevel < 15) { + midUnbreakingLevel = 1; + } + + int topUnbreakingLevel = 3; + if (topEnchantLevel < 20) { + topUnbreakingLevel = 2; + } + if (topEnchantLevel < 10) { + topUnbreakingLevel = 1; + } + + EnchantmentOffer[] offers = { + new EnchantmentOffer(Enchantment.DURABILITY, 1, bottomEnchantLevel), + new EnchantmentOffer(Enchantment.DURABILITY, midUnbreakingLevel, midEnchantLevel), + new EnchantmentOffer(Enchantment.DURABILITY, topUnbreakingLevel, topEnchantLevel), + }; + + for (int i = 0; i < offers.length; i++) { + event.getOffers()[i] = offers[i]; + } + + CURRENTLY_ENCHANTING_SECONDARY.remove(event.getEnchanter()); + + int[] unbLevels = { + event.getOffers()[0].getEnchantmentLevel(), + event.getOffers()[1].getEnchantmentLevel(), + event.getOffers()[2].getEnchantmentLevel() + }; + + CURRENTLY_ENCHANTING_SECONDARY.put(event.getEnchanter(), unbLevels); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java new file mode 100644 index 00000000..96206f93 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java @@ -0,0 +1,163 @@ +package com.willfp.ecoenchants.enchantments.support.obtaining; + +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.EcoEnchantsPlugin; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.Chunk; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.block.Chest; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.generator.BlockPopulator; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Random; +import java.util.concurrent.atomic.AtomicBoolean; + +public class LootPopulator extends BlockPopulator { + /** + * Instance of ecoenchants. + */ + private final EcoEnchantsPlugin plugin; + + /** + * Create a new loot populator. + * + * @param plugin The plugin. + */ + public LootPopulator(@NotNull final EcoEnchantsPlugin plugin) { + this.plugin = plugin; + } + + /** + * Populate a chunk's loot chests. + * + * @param world The world to populate. + * @param random Bukkit parity. + * @param chunk The chunk to populate. + */ + public void populate(@NotNull final World world, + @NotNull final Random random, + @NotNull final Chunk chunk) { + if (!plugin.getConfigYml().getBool("loot.enabled")) { + return; + } + + for (BlockState state : chunk.getTileEntities()) { + Block block = state.getBlock(); + if (!(block.getState() instanceof Chest)) { + continue; + } + + Chest chestState = (Chest) block.getState(); + Inventory inventory = chestState.getBlockInventory(); + + for (ItemStack item : inventory) { + if (item == null) { + continue; + } + if (!EnchantmentTarget.ALL.getMaterials().contains(item.getType())) { + continue; + } + if (item.getType().equals(Material.BOOK)) { + continue; + } + + HashMap toAdd = new HashMap<>(); + + ArrayList enchantments = new ArrayList<>(EcoEnchants.values()); + Collections.shuffle(enchantments); // Prevent list bias towards early enchantments like telekinesis + + double multiplier = 0.01; + if (item.getType().equals(Material.BOOK) || item.getType().equals(Material.ENCHANTED_BOOK)) { + multiplier /= plugin.getConfigYml().getInt("loot.book-times-less-likely"); + } + + if (plugin.getConfigYml().getBool("loot.reduce-probability.enabled")) { + multiplier /= plugin.getConfigYml().getDouble("loot.reduce-probability.factor"); + } + + for (EcoEnchant enchantment : enchantments) { + if (enchantment == null || enchantment.getRarity() == null) { + continue; + } + + if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getLootProbability() * multiplier) { + continue; + } + + if (!enchantment.isAvailableFromLoot()) { + continue; + } + + if (!enchantment.canEnchantItem(item)) { + continue; + } + + if (!enchantment.isEnabled()) { + continue; + } + + AtomicBoolean anyConflicts = new AtomicBoolean(false); + toAdd.forEach((enchant, integer) -> { + if (enchantment.conflictsWithAny(toAdd.keySet())) { + anyConflicts.set(true); + } + if (enchant.conflictsWith(enchantment)) { + anyConflicts.set(true); + } + + EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchant); + if (enchantment.getType().equals(ecoEnchant.getType()) && ecoEnchant.getType().isSingular()) { + anyConflicts.set(true); + } + }); + if (anyConflicts.get()) { + continue; + } + + int level; + + if (enchantment.getType().equals(EnchantmentType.SPECIAL)) { + double enchantlevel1 = NumberUtils.randFloat(0, 1); + double enchantlevel2 = NumberUtils.bias(enchantlevel1, plugin.getConfigYml().getDouble("enchanting-table.special-bias")); + double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); + level = (int) Math.ceil(enchantlevel2 / enchantlevel3); + } else { + double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, 1); + double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); + level = (int) Math.ceil(enchantlevel2 / enchantlevel3); + } + + toAdd.put(enchantment, level); + + if (plugin.getConfigYml().getBool("loot.reduce-probability.enabled")) { + multiplier /= plugin.getConfigYml().getDouble("loot.reduce-probability.factor"); + } + } + + if (item.getItemMeta() instanceof EnchantmentStorageMeta) { + EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta(); + toAdd.forEach(((enchantment, integer) -> meta.addStoredEnchant(enchantment, integer, false))); + item.setItemMeta(meta); + } else { + ItemMeta meta = item.getItemMeta(); + toAdd.forEach(((enchantment, integer) -> meta.addEnchant(enchantment, integer, false))); + item.setItemMeta(meta); + } + } + } + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java new file mode 100644 index 00000000..001d433a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java @@ -0,0 +1,225 @@ +package com.willfp.ecoenchants.enchantments.support.obtaining; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.VillagerAcquireTradeEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.MerchantRecipe; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; + +public class VillagerListeners extends PluginDependent implements Listener { + /** + * Create new villager listeners. + * + * @param plugin The plugin. + */ + public VillagerListeners(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + /** + * Called on villager gain trade. + * + * @param event The event to listen for. + */ + @EventHandler + public void onVillagerGainBookTrade(@NotNull final VillagerAcquireTradeEvent event) { + if (!event.getRecipe().getResult().getType().equals(Material.ENCHANTED_BOOK)) { + return; + } + + if (!this.getPlugin().getConfigYml().getBool("villager.enabled")) { + return; + } + + ItemStack result = event.getRecipe().getResult().clone(); + int uses = event.getRecipe().getUses(); + int maxUses = event.getRecipe().getMaxUses(); + boolean experienceReward = event.getRecipe().hasExperienceReward(); + int villagerExperience = event.getRecipe().getVillagerExperience(); + float priceMultiplier = event.getRecipe().getPriceMultiplier(); + List ingredients = event.getRecipe().getIngredients(); + + if (!(result.getItemMeta() instanceof EnchantmentStorageMeta)) { + return; + } + + EnchantmentStorageMeta meta = (EnchantmentStorageMeta) result.getItemMeta(); + + ArrayList enchantments = new ArrayList<>(EcoEnchants.values()); + Collections.shuffle(enchantments); // Prevent list bias towards early enchantments like telekinesis + + double multiplier = 0.01 / this.getPlugin().getConfigYml().getDouble("villager.book-times-less-likely"); + + for (EcoEnchant enchantment : enchantments) { + if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getVillagerProbability() * multiplier) { + continue; + } + + if (!enchantment.isAvailableFromVillager()) { + continue; + } + + if (!enchantment.isEnabled()) { + continue; + } + + int level; + + if (enchantment.getType().equals(EnchantmentType.SPECIAL)) { + double enchantlevel1 = NumberUtils.randFloat(0, 1); + double enchantlevel2 = NumberUtils.bias(enchantlevel1, this.getPlugin().getConfigYml().getDouble("enchanting-table.special-bias")); + double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); + level = (int) Math.ceil(enchantlevel2 / enchantlevel3); + } else { + int cost = event.getRecipe().getIngredients().get(0).getAmount(); + double enchantlevel1 = (double) cost / 64; + double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, enchantlevel1); + double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); + level = (int) Math.ceil(enchantlevel2 / enchantlevel3); + } + + meta.getStoredEnchants().forEach(((enchantment1, integer) -> meta.removeStoredEnchant(enchantment1))); + + meta.addStoredEnchant(enchantment, level, false); + break; + } + + result.setItemMeta(meta); + + MerchantRecipe recipe = new MerchantRecipe(result, uses, maxUses, experienceReward, villagerExperience, priceMultiplier); + recipe.setIngredients(ingredients); + event.setRecipe(recipe); + } + + /** + * Called on villager gain trade. + * + * @param event The event to listen for. + */ + @EventHandler + public void onVillagerGainItemTrade(@NotNull final VillagerAcquireTradeEvent event) { + + if (!EnchantmentTarget.ALL.getMaterials().contains(event.getRecipe().getResult().getType())) { + return; + } + + if (event.getRecipe().getResult().getType().equals(Material.BOOK)) { + return; + } + + if (!this.getPlugin().getConfigYml().getBool("villager.enabled")) { + return; + } + + ItemStack result = event.getRecipe().getResult().clone(); + int uses = event.getRecipe().getUses(); + int maxUses = event.getRecipe().getMaxUses(); + boolean experienceReward = event.getRecipe().hasExperienceReward(); + int villagerExperience = event.getRecipe().getVillagerExperience(); + float priceMultiplier = event.getRecipe().getPriceMultiplier(); + List ingredients = event.getRecipe().getIngredients(); + + if (result.getItemMeta() instanceof EnchantmentStorageMeta) { + return; + } + + ItemMeta meta = result.getItemMeta(); + + ArrayList enchantments = new ArrayList<>(EcoEnchants.values()); + Collections.shuffle(enchantments); // Prevent list bias towards early enchantments like telekinesis + + Map toAdd = new HashMap<>(); + + double multiplier = 0.01; + + for (EcoEnchant enchantment : enchantments) { + if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getVillagerProbability() * multiplier) { + continue; + } + + if (!enchantment.isAvailableFromVillager()) { + continue; + } + + if (!enchantment.canEnchantItem(result)) { + continue; + } + + if (!enchantment.isEnabled()) { + continue; + } + + AtomicBoolean anyConflicts = new AtomicBoolean(false); + toAdd.forEach((enchant, integer) -> { + if (enchantment.conflictsWithAny(toAdd.keySet())) { + anyConflicts.set(true); + } + + if (enchant.conflictsWith(enchantment)) { + anyConflicts.set(true); + } + + if (enchantment.conflictsWith(enchant)) { + anyConflicts.set(true); + } + + EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchant); + + if (enchantment.getType().equals(ecoEnchant.getType()) && ecoEnchant.getType().isSingular()) { + anyConflicts.set(true); + } + }); + + if (anyConflicts.get()) { + continue; + } + + int level; + + if (enchantment.getType().equals(EnchantmentType.SPECIAL)) { + double enchantlevel1 = NumberUtils.randFloat(0, 1); + double enchantlevel2 = NumberUtils.bias(enchantlevel1, this.getPlugin().getConfigYml().getDouble("enchanting-table.special-bias")); + double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); + level = (int) Math.ceil(enchantlevel2 / enchantlevel3); + } else { + int cost = event.getRecipe().getIngredients().get(0).getAmount(); + double enchantlevel1 = (double) cost / 64; + double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, enchantlevel1); + double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); + level = (int) Math.ceil(enchantlevel2 / enchantlevel3); + } + + toAdd.put(enchantment, level); + + if (this.getPlugin().getConfigYml().getBool("villager.reduce-probability.enabled")) { + multiplier /= this.getPlugin().getConfigYml().getDouble("villager.reduce-probability.factor"); + } + } + + toAdd.forEach(((enchantment, integer) -> meta.addEnchant(enchantment, integer, false))); + + result.setItemMeta(meta); + + MerchantRecipe recipe = new MerchantRecipe(result, uses, maxUses, experienceReward, villagerExperience, priceMultiplier); + recipe.setIngredients(ingredients); + event.setRecipe(recipe); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantChecks.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantChecks.java new file mode 100644 index 00000000..e3fc575e --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantChecks.java @@ -0,0 +1,437 @@ +package com.willfp.ecoenchants.enchantments.util; + + +import com.willfp.eco.util.DurabilityUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.proxy.proxies.FastGetEnchantsProxy; +import com.willfp.ecoenchants.util.ProxyUtils; +import lombok.experimental.UtilityClass; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.MetadataValue; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + +@SuppressWarnings("unchecked") +@UtilityClass +public class EnchantChecks { + /** + * Proxy instance of FastGetEnchants. + */ + private static final FastGetEnchantsProxy PROXY = ProxyUtils.getProxy(FastGetEnchantsProxy.class); + + /** + * Does the specified ItemStack have a certain Enchantment present? + * + * @param item The {@link ItemStack} to check + * @param enchantment The enchantment to query + * @return If the item has the queried enchantment + */ + public static boolean item(@Nullable final ItemStack item, + @NotNull final Enchantment enchantment) { + return getItemLevel(item, enchantment) != 0; + } + + /** + * What level of the specified enchantment does the specified ItemStack have? + * + * @param item The {@link ItemStack} to check + * @param enchantment The enchantment to query + * @return The level of the enchantment, or 0 if not found + */ + public static int getItemLevel(@Nullable final ItemStack item, + @NotNull final Enchantment enchantment) { + if (item == null) { + return 0; + } + if (item.getType().equals(Material.AIR)) { + return 0; + } + + return PROXY.getLevelOnItem(item, enchantment); + } + + /** + * Get all {@link EcoEnchant}s on a specified ItemStack. + * + * @param item The ItemStack to query. + * @return A {@link HashMap} of all EcoEnchants, where the key represents the level. + */ + public static Map getEnchantsOnItem(@Nullable final ItemStack item) { + if (item == null) { + return new HashMap<>(); + } + if (item.getType().equals(Material.AIR)) { + return new HashMap<>(); + } + + Map ecoEnchants = new HashMap<>(); + for (Map.Entry enchantmentIntegerEntry : PROXY.getEnchantmentsOnItem(item).entrySet()) { + EcoEnchant enchant = EcoEnchants.getFromEnchantment(enchantmentIntegerEntry.getKey()); + if (enchant != null) { + ecoEnchants.put(enchant, enchantmentIntegerEntry.getValue()); + } + } + + return ecoEnchants; + } + + /** + * Does the specified Arrow have a certain Enchantment present? + *

+ * EcoEnchants automatically gives an arrow NBT data consisting of the enchantments present to avoid switching errors. + * + * @param arrow The {@link Arrow} to check. + * @param enchantment The enchantment to query. + * @return If the arrow has the queried enchantment. + */ + public static boolean arrow(@NotNull final Arrow arrow, + @NotNull final Enchantment enchantment) { + return getArrowLevel(arrow, enchantment) != 0; + } + + /** + * What level specified Arrow has of a certain Enchantment present? + *

+ * EcoEnchants automatically gives an arrow NBT data consisting of the enchantments present to avoid switching errors. + * + * @param arrow The {@link Arrow} to check. + * @param enchantment The enchantment to query. + * @return The level found on the arrow, or 0 if not found. + */ + public static int getArrowLevel(@NotNull final Arrow arrow, + @NotNull final Enchantment enchantment) { + if (arrow.getMetadata("shot-from").isEmpty()) { + return 0; + } + + MetadataValue enchantmentsMetaValue = arrow.getMetadata("shot-from").get(0); + if (!(enchantmentsMetaValue.value() instanceof ItemStack)) { + return 0; + } + + ItemStack shotFrom = (ItemStack) enchantmentsMetaValue.value(); + return getItemLevel(shotFrom, enchantment); + } + + /** + * Get all {@link EcoEnchant}s on a specified Arrow. + * + * @param arrow The Arrow to query. + * @return A {@link HashMap} of all EcoEnchants, where the key represents the level. + */ + public static Map getEnchantsOnArrow(@NotNull final Arrow arrow) { + if (arrow.getMetadata("shot-from").isEmpty()) { + return new HashMap<>(); + } + + MetadataValue enchantmentsMetaValue = arrow.getMetadata("shot-from").get(0); + if (!(enchantmentsMetaValue.value() instanceof ItemStack)) { + return new HashMap<>(); + } + + ItemStack shotFrom = (ItemStack) enchantmentsMetaValue.value(); + return getEnchantsOnItem(shotFrom); + } + + /** + * Does the specified {@link LivingEntity} have a certain Enchantment present on the item in their main hand? + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return If the LivingEntity has the enchantment. + */ + public static boolean mainhand(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + return getMainhandLevel(entity, enchantment) != 0; + } + + /** + * What level of the specified enchantment does the queried {@link LivingEntity} have on their main hand item? + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return The level found on the mainhand item, or 0 if not found. + */ + public static int getMainhandLevel(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + if (entity.getEquipment() == null) { + return 0; + } + + ItemStack item = entity.getEquipment().getItemInMainHand(); + + return getItemLevel(item, enchantment); + } + + /** + * Get all {@link EcoEnchant}s on a queried {@link LivingEntity}s main hand item. + * + * @param entity The entity to query. + * @return A {@link HashMap} of all EcoEnchants, where the key represents the level. + */ + public static Map getEnchantsOnMainhand(@NotNull final LivingEntity entity) { + if (entity.getEquipment() == null) { + return new HashMap<>(); + } + + ItemStack item = entity.getEquipment().getItemInMainHand(); + + return getEnchantsOnItem(item); + } + + /** + * Does the specified {@link LivingEntity} have a certain Enchantment present on the item in their offhand? + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return If the LivingEntity has the enchantment. + */ + public static boolean offhand(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + return getOffhandLevel(entity, enchantment) != 0; + } + + /** + * What level of the specified enchantment does the queried {@link LivingEntity} have on their offhand item? + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return The level found on the offhand item, or 0 if not found. + */ + public static int getOffhandLevel(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + if (entity.getEquipment() == null) { + return 0; + } + + ItemStack item = entity.getEquipment().getItemInOffHand(); + + return getItemLevel(item, enchantment); + } + + /** + * Get all {@link EcoEnchant}s on a queried {@link LivingEntity}s offhand item. + * + * @param entity The entity to query. + * @return A {@link HashMap} of all EcoEnchants, where the key represents the level. + */ + public static Map getEnchantsOnOffhand(@NotNull final LivingEntity entity) { + if (entity.getEquipment() == null) { + return new HashMap<>(); + } + + ItemStack item = entity.getEquipment().getItemInOffHand(); + + return getEnchantsOnItem(item); + } + + /** + * Get a cumulative total of all levels on a {@link LivingEntity}s armor of a certain enchantment. + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return The cumulative total of all levels, ie 4 pieces all with level 3 returns 12 + */ + public static int getArmorPoints(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + return getArmorPoints(entity, enchantment, 0); + } + + /** + * Get a cumulative total of all levels on a {@link LivingEntity}s armor of a certain enchantment. + *

+ * Then, apply a specified amount of damage to all items with said enchantment. + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @param damage The amount of damage to deal to all armor pieces. + * @return The cumulative total of all levels, ie 4 pieces all with level 3 returns 12. + */ + public static int getArmorPoints(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment, + final int damage) { + if (entity.getEquipment() == null) { + return 0; + } + + boolean isPlayer = entity instanceof Player; + + AtomicInteger armorPoints = new AtomicInteger(0); + List armor = Arrays.asList(entity.getEquipment().getArmorContents()); + armor.forEach((itemStack -> { + int level = getItemLevel(itemStack, enchantment); + if (level != 0) { + armorPoints.addAndGet(getItemLevel(itemStack, enchantment)); + if (damage > 0 && isPlayer) { + Player player = (Player) entity; + if (itemStack.equals(entity.getEquipment().getHelmet())) { + DurabilityUtils.damageItem(player, player.getInventory().getHelmet(), level, 39); + } + if (itemStack.equals(entity.getEquipment().getChestplate())) { + DurabilityUtils.damageItem(player, player.getInventory().getChestplate(), level, 38); + } + if (itemStack.equals(entity.getEquipment().getLeggings())) { + DurabilityUtils.damageItem(player, player.getInventory().getLeggings(), level, 37); + } + if (itemStack.equals(entity.getEquipment().getBoots())) { + DurabilityUtils.damageItem(player, player.getInventory().getBoots(), level, 36); + } + } + } + })); + + return armorPoints.get(); + } + + /** + * Get all {@link EcoEnchant}s on a queried {@link LivingEntity}s armor. + * + * @param entity The entity to query. + * @return A {@link HashMap} of all EcoEnchants, where the key represents the cumulative total levels. + */ + public static Map getEnchantsOnArmor(@NotNull final LivingEntity entity) { + if (entity.getEquipment() == null) { + return new HashMap<>(); + } + + Map ecoEnchants = new HashMap<>(); + + for (ItemStack itemStack : entity.getEquipment().getArmorContents()) { + ecoEnchants.putAll(EnchantChecks.getEnchantsOnItem(itemStack)); + } + + return ecoEnchants; + } + + /** + * Does the specified {@link LivingEntity} have a certain Enchantment present on their helmet? + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return If the LivingEntity has the enchantment. + */ + public static boolean helmet(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + return getHelmetLevel(entity, enchantment) != 0; + } + + /** + * What level of the specified enchantment does the queried {@link LivingEntity} have on their helmet? + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return The level found, or 0 if not found. + */ + public static int getHelmetLevel(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + if (entity.getEquipment() == null) { + return 0; + } + + ItemStack item = entity.getEquipment().getHelmet(); + + return getItemLevel(item, enchantment); + } + + /** + * Does the specified {@link LivingEntity} have a certain Enchantment present on their chestplate? + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return If the LivingEntity has the enchantment. + */ + public static boolean chestplate(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + return getChestplateLevel(entity, enchantment) != 0; + } + + /** + * What level of the specified enchantment does the queried {@link LivingEntity} have on their chestplate? + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return The level found, or 0 if not found. + */ + public static int getChestplateLevel(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + if (entity.getEquipment() == null) { + return 0; + } + + ItemStack item = entity.getEquipment().getChestplate(); + + return getItemLevel(item, enchantment); + } + + /** + * Does the specified {@link LivingEntity} have a certain Enchantment present on their leggings? + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return If the LivingEntity has the enchantment. + */ + public static boolean leggings(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + return getLeggingsLevel(entity, enchantment) != 0; + } + + /** + * What level of the specified enchantment does the queried {@link LivingEntity} have on their leggings? + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return The level found, or 0 if not found. + */ + public static int getLeggingsLevel(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + if (entity.getEquipment() == null) { + return 0; + } + + ItemStack item = entity.getEquipment().getLeggings(); + + return getItemLevel(item, enchantment); + } + + /** + * Does the specified {@link LivingEntity} have a certain Enchantment present on their boots? + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return If the LivingEntity has the enchantment. + */ + public static boolean boots(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + return getBootsLevel(entity, enchantment) != 0; + } + + /** + * What level of the specified enchantment does the queried {@link LivingEntity} have on their boots? + * + * @param entity The entity to query. + * @param enchantment The enchantment to check. + * @return The level found, or 0 if not found. + */ + public static int getBootsLevel(@NotNull final LivingEntity entity, + @NotNull final Enchantment enchantment) { + if (entity.getEquipment() == null) { + return 0; + } + + ItemStack item = entity.getEquipment().getBoots(); + + return getItemLevel(item, enchantment); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java new file mode 100644 index 00000000..43100c3d --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java @@ -0,0 +1,71 @@ +package com.willfp.ecoenchants.enchantments.util; + +import com.willfp.eco.core.integrations.placeholder.PlaceholderEntry; +import com.willfp.eco.core.integrations.placeholder.PlaceholderManager; +import com.willfp.eco.util.NumberUtils; +import com.willfp.eco.util.StringUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import lombok.experimental.UtilityClass; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +@UtilityClass +public class EnchantmentUtils { + /** + * If the enchantment has successfully passed its specified chance. + * + * @param enchantment The enchantment to query. + * @param level The level to base the chance off of. + * @return If the enchantment should then be executed. + */ + public static boolean passedChance(@NotNull final EcoEnchant enchantment, + final int level) { + return NumberUtils.randFloat(0, 1) < ((enchantment.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level") * level) / 100); + } + + /** + * If attack was fully charged if required. + * + * @param enchantment The enchantment. + * @param entity The attacker. + * @return If was fully charged. + */ + public static boolean isFullyChargeIfRequired(@NotNull final EcoEnchant enchantment, + @NotNull final LivingEntity entity) { + if (entity instanceof Player) { + if (((Player) entity).getAttackCooldown() != 1.0f) { + return enchantment.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"); + } + } + + return true; + } + + /** + * Register the placeholders for an enchantment. + * + * @param enchantment The enchantment to register placeholders for. + */ + public static void registerPlaceholders(@NotNull final EcoEnchant enchantment) { + PlaceholderManager.registerPlaceholder( + new PlaceholderEntry( + enchantment.getPermissionName() + "_" + "enabled", + player -> String.valueOf(enchantment.isEnabled()) + ) + ); + + enchantment.getConfig().getKeys(true).forEach(string -> { + String key = string.replace("\\.", "_").replace("-", "_"); + Object object = enchantment.getConfig().get(string); + + PlaceholderManager.registerPlaceholder( + new PlaceholderEntry( + enchantment.getPermissionName() + "_" + key, + player -> StringUtils.internalToString(object) + ) + ); + }); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/ItemConversions.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/ItemConversions.java new file mode 100644 index 00000000..78d779fa --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/ItemConversions.java @@ -0,0 +1,228 @@ +package com.willfp.ecoenchants.enchantments.util; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.display.EnchantDisplay; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; +import org.bukkit.ChatColor; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.inventory.BlockInventoryHolder; +import org.bukkit.inventory.Inventory; +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 java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class ItemConversions extends PluginDependent implements Listener { + /** + * Instantiate item conversions. + * + * @param plugin Instance of EcoEnchants. + */ + public ItemConversions(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + /** + * On player hold item. + *

+ * Listener for lore conversion. + * + * @param event The event to listen for. + */ + @EventHandler + public void loreConverter(@NotNull final PlayerItemHeldEvent event) { + if (!((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().isUsingLoreGetter()) { + return; + } + + ItemStack itemStack = event.getPlayer().getInventory().getItem(event.getNewSlot()); + + convertLore(itemStack); + } + + /** + * On player open inventory. + *

+ * Listener for lore conversion. + * + * @param event The event to listen for. + */ + @EventHandler + public void aggressiveLoreConverter(@NotNull final InventoryOpenEvent event) { + if (!((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().isUsingAggressiveLoreGetter()) { + return; + } + + Inventory inventory = event.getInventory(); + + if (inventory.getHolder() == null) { + return; + } + + if (!(inventory.getHolder() instanceof BlockInventoryHolder)) { + return; + } + + for (ItemStack itemStack : inventory.getContents()) { + convertLore(itemStack); + } + } + + private void convertLore(@Nullable final ItemStack itemStack) { + if (itemStack == null) { + return; + } + + ItemMeta meta = itemStack.getItemMeta(); + if (meta == null) { + return; + } + + Map toAdd = new HashMap<>(); + + List lore = meta.getLore(); + + if (lore == null) { + return; + } + + for (String line : new ArrayList<>(lore)) { + String rawLine = line; + line = ChatColor.stripColor(line); + + EcoEnchant enchant; + int level; + List lineSplit = new ArrayList<>(Arrays.asList(line.split(" "))); + if (lineSplit.size() == 0) { + continue; + } + if (lineSplit.size() == 1) { + enchant = EcoEnchants.getByName(lineSplit.get(0)); + level = 1; + } else { + EcoEnchant attemptFullLine = EcoEnchants.getByName(line); + + if (attemptFullLine != null) { + enchant = attemptFullLine; + level = 1; + } else { + String levelString = lineSplit.get(lineSplit.size() - 1); + lineSplit.remove(levelString); + levelString = levelString.trim(); + + try { + level = NumberUtils.fromNumeral(levelString); + } catch (IllegalArgumentException e) { + continue; + } + + String enchantName = lineSplit.stream().collect(Collectors.joining(" ")); + enchant = EcoEnchants.getByName(enchantName); + } + } + + if (enchant != null) { + lore.remove(rawLine); + toAdd.put(enchant, level); + } + } + + if (meta instanceof EnchantmentStorageMeta) { + lore.clear(); + toAdd.forEach((enchantment, integer) -> ((EnchantmentStorageMeta) meta).addStoredEnchant(enchantment, integer, true)); + } else { + toAdd.forEach((enchantment, integer) -> meta.addEnchant(enchantment, integer, true)); + } + meta.setLore(lore); + itemStack.setItemMeta(meta); + } + + /** + * On player hold item. + *

+ * Listener for hide fixer. + * + * @param event The event to listen for. + */ + @EventHandler + public void hideFixer(@NotNull final PlayerItemHeldEvent event) { + if (!((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().isUsingExperimentalHideFixer()) { + return; + } + + ItemStack itemStack = event.getPlayer().getInventory().getItem(event.getNewSlot()); + + hideFixItem(itemStack); + } + + /** + * On player open inventory. + *

+ * Listener for hide fixer. + * + * @param event The event to listen for. + */ + @EventHandler + public void aggressiveHideFixer(@NotNull final InventoryOpenEvent event) { + if (!((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().isUsingAggressiveExperimentalHideFixer()) { + return; + } + + Inventory inventory = event.getInventory(); + + if (inventory.getHolder() == null) { + return; + } + + if (!(inventory.getHolder() instanceof BlockInventoryHolder)) { + return; + } + + for (ItemStack itemStack : inventory.getContents()) { + hideFixItem(itemStack); + } + } + + private void hideFixItem(@Nullable final ItemStack itemStack) { + if (itemStack == null) { + return; + } + + if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) { + return; + } + + ItemMeta meta = itemStack.getItemMeta(); + if (meta == null) { + return; + } + + if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().isUsingForceHideFixer()) { + meta.removeItemFlags(ItemFlag.HIDE_ENCHANTS); + meta.removeItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + } else { + if (meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS) && meta.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) { + meta.removeItemFlags(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_POTION_EFFECTS); + } + } + + itemStack.setItemMeta(meta); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellActivateEvent.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellActivateEvent.java new file mode 100644 index 00000000..d67a4d6a --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellActivateEvent.java @@ -0,0 +1,66 @@ +package com.willfp.ecoenchants.enchantments.util; + +import com.willfp.ecoenchants.enchantments.itemtypes.Spell; +import lombok.Getter; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.jetbrains.annotations.NotNull; + +public class SpellActivateEvent extends PlayerEvent implements Cancellable { + /** + * Internal, for bukkit. + */ + private static final HandlerList HANDLERS = new HandlerList(); + + /** + * The spell that was activated. + */ + @Getter + private final Spell spell; + + /** + * If the spell activation was cancelled. + */ + private boolean cancelled; + + /** + * Create new SpellActivateEvent. + * + * @param player The player. + * @param spell The spell. + */ + public SpellActivateEvent(@NotNull final Player player, + @NotNull final Spell spell) { + super(player); + + this.spell = spell; + this.cancelled = false; + } + + /** + * Bukkit parity. + * + * @return The handler list. + */ + public static HandlerList getHandlerList() { + return HANDLERS; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(final boolean cancel) { + this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLERS; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/TimedRunnable.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/TimedRunnable.java new file mode 100644 index 00000000..e6f399f3 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/TimedRunnable.java @@ -0,0 +1,10 @@ +package com.willfp.ecoenchants.enchantments.util; + +public interface TimedRunnable extends Runnable { + /** + * Get the time between repetitions. + * + * @return The time. + */ + long getTime(); +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/Watcher.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/Watcher.java new file mode 100644 index 00000000..6abf2869 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/Watcher.java @@ -0,0 +1,238 @@ +package com.willfp.ecoenchants.enchantments.util; + +import com.willfp.eco.core.events.ArmorEquipEvent; +import org.bukkit.block.Block; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Trident; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDamageEvent; +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.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.jetbrains.annotations.NotNull; + +public interface Watcher { + + /** + * Called when an entity shoots another entity with an arrow. + * + * @param attacker The shooter. + * @param victim The victim. + * @param arrow The arrow entity. + * @param level The level of the enchantment on the arrow. + * @param event The event that called this watcher. + */ + default void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when an entity damages another entity with a trident throw. + * + * @param attacker The shooter. + * @param victim The victim. + * @param trident The trident entity. + * @param level The level of the enchantment on the trident. + * @param event The event that called this watcher. + */ + default void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when a player jumps. + * + * @param player The player. + * @param level The level of the enchantment found on the player's armor. + * @param event The event that called this watcher. + */ + default void onJump(@NotNull final Player player, + final int level, + @NotNull final PlayerMoveEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when an entity attacks another entity with a melee attack. + * + * @param attacker The attacker. + * @param victim The victim. + * @param level The level of the enchantment found on the attacker's weapon. + * @param event The event that called this watcher. + */ + default void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when an entity shoots a bow. + * + * @param shooter The entity that shot the bow. + * @param arrow The arrow that was shot. + * @param level The level of the enchantment found on the bow. + * @param event The event that called this watcher. + */ + default void onBowShoot(@NotNull final LivingEntity shooter, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityShootBowEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when an entity shoots a projectile. + * + * @param shooter The entity that shot the bow. + * @param projectile The projectile that was shot. + * @param level The level of the enchantment found on the projectile. + * @param event The event that called this watcher. + */ + default void onProjectileLaunch(@NotNull final LivingEntity shooter, + @NotNull final Projectile projectile, + final int level, + @NotNull final ProjectileLaunchEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when an entity takes fall damage. + * + * @param faller The entity that took the fall damage. + * @param level The level of the enchantment found on the entity's armor. + * @param event The event that called this watcher. + */ + default void onFallDamage(@NotNull final LivingEntity faller, + final int level, + @NotNull final EntityDamageEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when an arrow hits a block or entity. + * + * @param shooter The entity that shot the arrow. + * @param level The level of the enchantment found on the arrow. + * @param event The event that called this watcher. + */ + default void onArrowHit(@NotNull final LivingEntity shooter, + final int level, + @NotNull final ProjectileHitEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when a trident hits a block or entity. + * + * @param shooter The entity that threw the trident. + * @param level The level of the enchantment found on the trident. + * @param event The event that called this watcher. + */ + default void onTridentHit(@NotNull final LivingEntity shooter, + final int level, + @NotNull final ProjectileHitEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when a player breaks a block. + * + * @param player The player. + * @param block The block that was broken. + * @param level The level of the enchantment found on the player's main hand item. + * @param event The event that called this watcher. + */ + default void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when an entity takes damage wearing armor. + * + * @param victim The entity that took damage. + * @param level The level of the enchantment found on the entity's armor. + * @param event The event that called this watcher. + */ + default void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when an entity puts on or takes off armor with an enchantment. + * + * @param player The player that equipped the armor. + * @param level The level of the enchantment found on the player's armor. + * @param event The event that called this watcher. + */ + default void onArmorEquip(@NotNull final Player player, + final int level, + @NotNull final ArmorEquipEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when a player damages a block. + * + * @param player The player that damaged the block. + * @param block The damaged block. + * @param level The level of the enchantment found on the player's main hand. + * @param event The event that called this watcher. + */ + default void onDamageBlock(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockDamageEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when an entity throws a trident. + * + * @param shooter The entity that threw the trident. + * @param trident The trident that was thrown. + * @param level The level of the enchantment found on the trident. + * @param event The event that called this watcher. + */ + default void onTridentLaunch(@NotNull final LivingEntity shooter, + @NotNull final Trident trident, + final int level, + @NotNull final ProjectileLaunchEvent event) { + // Empty default as enchantments only override required watchers. + } + + /** + * Called when a player blocks an attack with a shield. + * + * @param blocker The player that blocked the attack. + * @param attacker The attacker. + * @param level The level of the enchantment found on the shield. + * @param event The event that called this watcher. + */ + default void onDeflect(@NotNull final Player blocker, + @NotNull final LivingEntity attacker, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + // Empty default as enchantments only override required watchers. + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java new file mode 100644 index 00000000..23fb981d --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java @@ -0,0 +1,733 @@ +package com.willfp.ecoenchants.enchantments.util; + +import com.google.common.collect.Sets; +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.eco.core.config.ConfigUpdater; +import com.willfp.eco.core.events.ArmorEquipEvent; +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.core.integrations.mcmmo.McmmoManager; +import com.willfp.eco.util.TridentUtils; +import com.willfp.ecoenchants.EcoEnchantsPlugin; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.AbstractArrow; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Trident; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDamageEvent; +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.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +import java.text.DecimalFormat; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +@SuppressWarnings("deprecation") +public class WatcherTriggers extends PluginDependent implements Listener { + /** + * For jump listeners. + */ + private static final Set PREVIOUS_PLAYERS_ON_GROUND = Sets.newHashSet(); + + /** + * For jump listeners. + */ + private static final DecimalFormat FORMAT = new DecimalFormat("0.00"); + + /** + * If watchers should be triggered against npcs. + */ + private static boolean allowOnNPC = false; + + /** + * Create new listener for watcher events. + * + * @param plugin The plugin to link the events to. + */ + public WatcherTriggers(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + /** + * Update if allowed on npc. + */ + @ConfigUpdater + public static void update() { + allowOnNPC = EcoEnchantsPlugin.getInstance().getConfig().getBoolean("allow-on-npc"); + } + + /** + * Called when an entity shoots another entity with an arrow. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onArrowDamage(@NotNull final EntityDamageByEntityEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + if (!(event.getDamager() instanceof Arrow)) { + return; + } + + if (!(event.getEntity() instanceof LivingEntity)) { + return; + } + + if (((Arrow) event.getDamager()).getShooter() == null) { + return; + } + + if (!(((Arrow) event.getDamager()).getShooter() instanceof LivingEntity)) { + return; + } + + LivingEntity attacker = (LivingEntity) ((Arrow) event.getDamager()).getShooter(); + Arrow arrow = (Arrow) event.getDamager(); + LivingEntity victim = (LivingEntity) event.getEntity(); + + if (!allowOnNPC) { + if (victim.hasMetadata("NPC")) { + return; + } + } + + if (attacker instanceof Player && !AntigriefManager.canInjure((Player) attacker, victim)) { + return; + } + + if (event.isCancelled()) { + return; + } + + EnchantChecks.getEnchantsOnArrow(arrow).forEach(((enchant, level) -> { + if (event.isCancelled()) { + return; + } + + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(attacker.getWorld())) { + return; + } + + enchant.onArrowDamage(attacker, victim, arrow, level, event); + })); + } + + /** + * Called when an entity damages another entity with a trident throw. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onTridentDamage(@NotNull final EntityDamageByEntityEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + if (!(event.getDamager() instanceof Trident)) { + return; + } + + if (!(((Trident) event.getDamager()).getShooter() instanceof LivingEntity)) { + return; + } + + if (((Trident) event.getDamager()).getShooter() == null) { + return; + } + + if (!(event.getEntity() instanceof LivingEntity)) { + return; + } + + if (event.isCancelled()) { + return; + } + + LivingEntity attacker = (LivingEntity) ((Trident) event.getDamager()).getShooter(); + Trident trident = (Trident) event.getDamager(); + ItemStack item = TridentUtils.getItemStack(trident); + + LivingEntity victim = (LivingEntity) event.getEntity(); + + if (!allowOnNPC) { + if (victim.hasMetadata("NPC")) { + return; + } + } + + if (attacker instanceof Player && !AntigriefManager.canInjure((Player) attacker, victim)) { + return; + } + + EnchantChecks.getEnchantsOnItem(item).forEach(((enchant, level) -> { + if (event.isCancelled()) { + return; + } + + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(attacker.getWorld())) { + return; + } + + enchant.onTridentDamage(attacker, victim, trident, level, event); + })); + } + + /** + * Called when a player jumps. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onJump(@NotNull final PlayerMoveEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + Player player = event.getPlayer(); + if (player.getVelocity().getY() > 0) { + float jumpVelocity = 0.42f; + if (player.hasPotionEffect(PotionEffectType.JUMP)) { + jumpVelocity += ((float) player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() + 1) * 0.1F; + } + jumpVelocity = Float.parseFloat(FORMAT.format(jumpVelocity).replace(',', '.')); + if (event.getPlayer().getLocation().getBlock().getType() != Material.LADDER + && PREVIOUS_PLAYERS_ON_GROUND.contains(player.getUniqueId()) + && !player.isOnGround() + && Float.compare((float) player.getVelocity().getY(), jumpVelocity) == 0) { + EnchantChecks.getEnchantsOnArmor(player).forEach((enchant, level) -> { + if (event.isCancelled()) { + return; + } + + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + enchant.onJump(player, level, event); + }); + } + } + if (player.isOnGround()) { + PREVIOUS_PLAYERS_ON_GROUND.add(player.getUniqueId()); + } else { + PREVIOUS_PLAYERS_ON_GROUND.remove(player.getUniqueId()); + } + } + + /** + * Called when an entity attacks another entity with a melee attack. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onMeleeAttack(@NotNull final EntityDamageByEntityEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + if (!(event.getDamager() instanceof LivingEntity)) { + return; + } + + if (!(event.getEntity() instanceof LivingEntity)) { + return; + } + + if (event.isCancelled()) { + return; + } + + if (event.getCause() == EntityDamageEvent.DamageCause.THORNS) { + return; + } + + LivingEntity attacker = (LivingEntity) event.getDamager(); + LivingEntity victim = (LivingEntity) event.getEntity(); + + if (!allowOnNPC) { + if (victim.hasMetadata("NPC")) { + return; + } + } + + if (attacker instanceof Player && !AntigriefManager.canInjure((Player) attacker, victim)) { + return; + } + + EnchantChecks.getEnchantsOnMainhand(attacker).forEach((enchant, level) -> { + if (event.isCancelled()) { + return; + } + + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(attacker.getWorld())) { + return; + } + + enchant.onMeleeAttack(attacker, victim, level, event); + }); + } + + /** + * Called when an entity shoots a bow. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onBowShoot(@NotNull final EntityShootBowEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + if (event.getProjectile().getType() != EntityType.ARROW) { + return; + } + + LivingEntity shooter = event.getEntity(); + Arrow arrow = (Arrow) event.getProjectile(); + + EnchantChecks.getEnchantsOnMainhand(shooter).forEach((enchant, level) -> { + if (event.isCancelled()) { + return; + } + + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(shooter.getWorld())) { + return; + } + + enchant.onBowShoot(shooter, arrow, level, event); + }); + } + + /** + * Called when an entity launches a projectile. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onProjectileLaunch(@NotNull final ProjectileLaunchEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + if (!(event.getEntity() instanceof AbstractArrow)) { + return; + } + + if (!(event.getEntity().getShooter() instanceof Player)) { + return; + } + + LivingEntity shooter = (LivingEntity) event.getEntity().getShooter(); + + Projectile projectile = event.getEntity(); + + if (shooter.getEquipment() == null) { + return; + } + + ItemStack item = shooter.getEquipment().getItemInMainHand(); + + if (projectile instanceof Trident) { + item = TridentUtils.getItemStack((Trident) projectile); + } + + EnchantChecks.getEnchantsOnItem(item).forEach((enchant, level) -> { + if (event.isCancelled()) { + return; + } + + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(shooter.getWorld())) { + return; + } + + enchant.onProjectileLaunch(shooter, projectile, level, event); + }); + } + + /** + * Called when an entity takes fall damage. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onFallDamage(@NotNull final EntityDamageEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + if (!event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) { + return; + } + + if (!(event.getEntity() instanceof LivingEntity)) { + return; + } + + LivingEntity victim = (LivingEntity) event.getEntity(); + + EnchantChecks.getEnchantsOnArmor(victim).forEach((enchant, level) -> { + if (event.isCancelled()) { + return; + } + + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(victim.getWorld())) { + return; + } + + enchant.onFallDamage(victim, level, event); + }); + } + + /** + * Called when an arrow hits a block or entity. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onArrowHit(@NotNull final ProjectileHitEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + if (!(event.getEntity().getShooter() instanceof LivingEntity)) { + return; + } + + if (!(event.getEntity() instanceof Arrow)) { + return; + } + + if (event.getEntity().getShooter() == null) { + return; + } + + Arrow arrow = (Arrow) event.getEntity(); + LivingEntity shooter = (LivingEntity) event.getEntity().getShooter(); + + EnchantChecks.getEnchantsOnArrow(arrow).forEach(((enchant, level) -> { + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(shooter.getWorld())) { + return; + } + + enchant.onArrowHit(shooter, level, event); + })); + } + + /** + * Called when a trident hits a block or entity. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onTridentHit(@NotNull final ProjectileHitEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + if (!(event.getEntity().getShooter() instanceof LivingEntity)) { + return; + } + + if (event.getEntity().getShooter() == null) { + return; + } + + if (!(event.getEntity() instanceof Trident)) { + return; + } + + Trident trident = (Trident) event.getEntity(); + ItemStack item = TridentUtils.getItemStack(trident); + LivingEntity shooter = (LivingEntity) event.getEntity().getShooter(); + + EnchantChecks.getEnchantsOnItem(item).forEach((enchant, level) -> { + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(shooter.getWorld())) { + return; + } + + enchant.onTridentHit(shooter, level, event); + }); + } + + /** + * Called when a player breaks a block. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onBlockBreak(@NotNull final BlockBreakEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + Player player = event.getPlayer(); + Block block = event.getBlock(); + + if (!AntigriefManager.canBreakBlock(player, block)) { + return; + } + + if (event.isCancelled()) { + return; + } + + EnchantChecks.getEnchantsOnMainhand(player).forEach((enchant, level) -> { + if (event.isCancelled()) { + return; + } + + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + enchant.onBlockBreak(player, block, level, event); + }); + } + + /** + * Called when an entity takes damage wearing armor. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onDamageWearingArmor(@NotNull final EntityDamageEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + if (!(event.getEntity() instanceof LivingEntity)) { + return; + } + + LivingEntity victim = (LivingEntity) event.getEntity(); + + EnchantChecks.getEnchantsOnArmor(victim).forEach((enchant, level) -> { + if (event.isCancelled()) { + return; + } + + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(victim.getWorld())) { + return; + } + + enchant.onDamageWearingArmor(victim, level, event); + }); + } + + /** + * Called when an entity puts on or takes off armor with an enchantment. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onArmorEquip(@NotNull final ArmorEquipEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + Player player = event.getPlayer(); + + this.getPlugin().getScheduler().runLater(() -> EcoEnchants.values().forEach(enchant -> { + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int level = EnchantChecks.getArmorPoints(player, enchant); + enchant.onArmorEquip(player, level, event); + }), 1); + } + + /** + * Called when a player damages a block. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onDamageBlock(@NotNull final BlockDamageEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + Player player = event.getPlayer(); + Block block = event.getBlock(); + + if (event.getBlock().getDrops(player.getInventory().getItemInMainHand()).isEmpty()) { + return; + } + + EnchantChecks.getEnchantsOnMainhand(player).forEach((enchant, level) -> { + if (event.isCancelled()) { + return; + } + + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + enchant.onDamageBlock(player, block, level, event); + }); + } + + /** + * Called when an entity throws a trident. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onTridentLaunch(@NotNull final ProjectileLaunchEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + if (!(event.getEntity() instanceof Trident)) { + return; + } + + if (!(event.getEntity().getShooter() instanceof LivingEntity)) { + return; + } + + Trident trident = (Trident) event.getEntity(); + LivingEntity shooter = (LivingEntity) trident.getShooter(); + ItemStack item = TridentUtils.getItemStack(trident); + + EnchantChecks.getEnchantsOnItem(item).forEach((enchant, level) -> { + if (event.isCancelled()) { + return; + } + + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(shooter.getWorld())) { + return; + } + + enchant.onTridentLaunch(shooter, trident, level, event); + }); + } + + /** + * Called when a player blocks an attack with a shield. + * + * @param event The event to listen for. + */ + @EventHandler(ignoreCancelled = true) + public void onDeflect(@NotNull final EntityDamageByEntityEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + + if (!(event.getEntity() instanceof Player)) { + return; + } + + if (!(event.getDamager() instanceof LivingEntity)) { + return; + } + + Player blocker = (Player) event.getEntity(); + + LivingEntity attacker = (LivingEntity) event.getDamager(); + + if (!blocker.isBlocking()) { + return; + } + + if (!AntigriefManager.canInjure(blocker, attacker)) { + return; + } + + Map enchants = blocker.getInventory().getItemInMainHand().getType() == Material.SHIELD + ? EnchantChecks.getEnchantsOnMainhand(blocker) + : EnchantChecks.getEnchantsOnOffhand(blocker); + + enchants.forEach((enchant, level) -> { + if (event.isCancelled()) { + return; + } + + if (!enchant.isEnabled()) { + return; + } + + if (enchant.getDisabledWorlds().contains(blocker.getWorld())) { + return; + } + + enchant.onDeflect(blocker, attacker, level, event); + }); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsManager.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsManager.java new file mode 100644 index 00000000..86d0c76c --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsManager.java @@ -0,0 +1,31 @@ +package com.willfp.ecoenchants.integrations.essentials; + +import lombok.experimental.UtilityClass; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.Set; + +@UtilityClass +public class EssentialsManager { + /** + * All registered essentials integrations. + */ + private static final Set REGISTERED = new HashSet<>(); + + /** + * Register a new essentials integration. + * + * @param essentials The integration to register. + */ + public static void register(@NotNull final EssentialsWrapper essentials) { + REGISTERED.add(essentials); + } + + /** + * Register all {@link com.willfp.ecoenchants.enchantments.EcoEnchant}s with Essentials. + */ + public static void registerEnchantments() { + REGISTERED.forEach(EssentialsWrapper::registerAllEnchantments); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsWrapper.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsWrapper.java new file mode 100644 index 00000000..408f416f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsWrapper.java @@ -0,0 +1,11 @@ +package com.willfp.ecoenchants.integrations.essentials; + +import com.willfp.eco.core.integrations.Integration; + +public interface EssentialsWrapper extends Integration { + /** + * @see EssentialsManager#registerEnchantments(); + */ + void registerAllEnchantments(); +} + diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/plugins/IntegrationEssentials.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/plugins/IntegrationEssentials.java new file mode 100644 index 00000000..743dfb24 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/plugins/IntegrationEssentials.java @@ -0,0 +1,30 @@ +package com.willfp.ecoenchants.integrations.essentials.plugins; + +import com.earth2me.essentials.Enchantments; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.integrations.essentials.EssentialsWrapper; +import org.apache.commons.lang.reflect.FieldUtils; +import org.bukkit.enchantments.Enchantment; + +import java.util.Map; + +@SuppressWarnings("unchecked") +public class IntegrationEssentials implements EssentialsWrapper { + @Override + public void registerAllEnchantments() { + try { + for (EcoEnchant enchantment : EcoEnchants.values()) { + ((Map) FieldUtils.readDeclaredStaticField(Enchantments.class, "ENCHANTMENTS", true)).put(enchantment.getKey().getKey(), enchantment); + ((Map) FieldUtils.readDeclaredStaticField(Enchantments.class, "ENCHANTMENTS", true)).put(enchantment.getPermissionName(), enchantment); + } + } catch (IllegalAccessException ignored) { + // Ignore reflective errors that won't happen. + } + } + + @Override + public String getPluginName() { + return "Essentials"; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/util/ProxyUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/util/ProxyUtils.java new file mode 100644 index 00000000..9a75d687 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/util/ProxyUtils.java @@ -0,0 +1,21 @@ +package com.willfp.ecoenchants.util; + +import com.willfp.eco.core.proxy.AbstractProxy; +import com.willfp.ecoenchants.EcoEnchantsPlugin; +import com.willfp.ecoenchants.proxy.util.ProxyFactory; +import lombok.experimental.UtilityClass; +import org.jetbrains.annotations.NotNull; + +@UtilityClass +public class ProxyUtils { + /** + * Get the implementation of a specified proxy. + * + * @param proxyClass The proxy interface. + * @param The type of the proxy. + * @return The proxy implementation. + */ + public @NotNull T getProxy(@NotNull final Class proxyClass) { + return new ProxyFactory<>(EcoEnchantsPlugin.getInstance(), proxyClass).getProxy(); + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java deleted file mode 100644 index 73e444bc..00000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java +++ /dev/null @@ -1,165 +0,0 @@ -package com.willfp.ecoskills; - -import com.willfp.eco.core.AbstractPacketAdapter; -import com.willfp.eco.core.EcoPlugin; -import com.willfp.eco.core.command.AbstractCommand; -import com.willfp.eco.core.integrations.IntegrationLoader; -import com.willfp.ecoskills.command.CommandClasses; -import com.willfp.ecoskills.command.CommandEsreload; -import com.willfp.ecoskills.enchantments.EcoEnchants; -import com.willfp.ecoskills.enchantments.meta.EnchantmentRarity; -import com.willfp.ecoskills.enchantments.meta.EnchantmentTarget; -import com.willfp.ecoskills.enchantments.meta.EnchantmentType; -import com.willfp.ecoskills.enchantments.support.merging.anvil.AnvilListeners; -import com.willfp.ecoskills.enchantments.support.merging.grindstone.GrindstoneListeners; -import com.willfp.ecoskills.enchantments.support.obtaining.EnchantingListeners; -import com.willfp.ecoskills.enchantments.support.obtaining.LootPopulator; -import com.willfp.ecoskills.enchantments.support.obtaining.VillagerListeners; -import com.willfp.ecoskills.enchantments.util.ItemConversions; -import com.willfp.ecoskills.enchantments.util.WatcherTriggers; -import lombok.Getter; -import org.bukkit.Bukkit; -import org.bukkit.event.Listener; -import org.bukkit.generator.BlockPopulator; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -@SuppressWarnings("unused") -public class EcoSkillsPlugin extends EcoPlugin { - /** - * Instance of the plugin. - */ - @Getter - private static EcoSkillsPlugin instance; - - /** - * Internal constructor called by bukkit on plugin load. - */ - public EcoSkillsPlugin() { - super("EcoSkills", 79573, 7666, "com.willfp.ecoskills.proxy", "&3"); - instance = this; - } - - /** - * Code executed on plugin enable. - */ - @Override - public void enable() { - this.getExtensionLoader().loadExtensions(); - - if (this.getExtensionLoader().getLoadedExtensions().isEmpty()) { - this.getLogger().info("&cNo extensions found"); - } else { - this.getLogger().info("Extensions Loaded:"); - this.getExtensionLoader().getLoadedExtensions().forEach(extension -> this.getLogger().info("- " + extension.getName() + " v" + extension.getVersion())); - } - - this.getLogger().info(EcoEnchants.values().size() + " Enchantments Loaded"); - } - - /** - * Code executed on plugin disable. - */ - @Override - public void disable() { - Bukkit.getServer().getWorlds().forEach(world -> { - List populators = new ArrayList<>(world.getPopulators()); - populators.forEach((blockPopulator -> { - if (blockPopulator instanceof LootPopulator) { - world.getPopulators().remove(blockPopulator); - } - })); - }); - - this.getExtensionLoader().unloadExtensions(); - } - - /** - * Nothing is called on plugin load. - */ - @Override - public void load() { - // Nothing needs to be called on load - } - - /** - * Code executed on /ecoreload. - */ - @Override - public void onReload() { - // Nothing needs to be called on reload - } - - /** - * Code executed after server is up. - */ - @Override - public void postLoad() { - // Nothing needs to be called post-loads - } - - /** - * EcoEnchants-specific integrations. - * - * @return A list of all integrations. - */ - @Override - public List getIntegrationLoaders() { - return Arrays.asList( - - ); - } - - /** - * EcoEnchants-specific commands. - * - * @return A list of all commands. - */ - @Override - public List getCommands() { - return Arrays.asList( - new CommandClasses(this), - new CommandEsreload(this) - ); - } - - /** - * Packet Adapters for enchant display. - * - * @return A list of packet adapters. - */ - @Override - public List getPacketAdapters() { - return new ArrayList<>(); - } - - /** - * EcoEnchants-specific listeners. - * - * @return A list of all listeners. - */ - @Override - public List getListeners() { - return Arrays.asList( - new EnchantingListeners(this), - new GrindstoneListeners(this), - new AnvilListeners(this), - new WatcherTriggers(this), - new VillagerListeners(this), - new ItemConversions(this) - ); - } - - @Override - public List> getUpdatableClasses() { - return Arrays.asList( - EnchantmentRarity.class, - EnchantmentTarget.class, - EcoEnchants.class, - EnchantmentType.class, - WatcherTriggers.class - ); - } -} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/classes/ClassesMenu.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/classes/ClassesMenu.java deleted file mode 100644 index 8ea774ba..00000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/classes/ClassesMenu.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoskills.classes; - -import com.willfp.eco.core.gui.menu.Menu; -import lombok.Getter; -import lombok.experimental.UtilityClass; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.jetbrains.annotations.NotNull; - -@UtilityClass -public class ClassesMenu { - /** - * The classes menu. - */ - @Getter - private static Menu menu; - - /** - * Set the menu for /classes. - * - * @param menu The menu. - */ - public void setMenu(@NotNull final Menu menu) { - ClassesMenu.menu = menu; - } - - /** - * Show the menu to a player. - * - * @param player The player. - * @return The inventory. - */ - public Inventory showMenu(@NotNull final Player player) { - return menu.open(player); - } -} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/classes/SkillClasses.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/classes/SkillClasses.java deleted file mode 100644 index 23570766..00000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/classes/SkillClasses.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.willfp.ecoskills.classes; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import com.google.common.collect.ImmutableList; -import com.willfp.eco.core.config.ConfigUpdater; -import lombok.experimental.UtilityClass; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -@UtilityClass -public class SkillClasses { - /** - * All registered skill classes. - */ - private static final BiMap BY_NAME = HashBiMap.create(); - - /** - * Get all registered {@link SkillClass}es. - * - * @return A list of all {@link SkillClass}es. - */ - public static List values() { - return ImmutableList.copyOf(BY_NAME.values()); - } - - /** - * Update the skill classes. - */ - @ConfigUpdater - public static void update() { - for (SkillClass skillClass : values()) { - skillClass.update(); - } - } - - /** - * Add new {@link SkillClass} to EcoSkills. - *

- * Only for internal use, skill classes are automatically added in the constructor. - * - * @param skillClass The {@link SkillClass} to add. - */ - public static void addNewSkillClass(@NotNull final SkillClass skillClass) { - BY_NAME.inverse().remove(skillClass); - BY_NAME.put(skillClass.getName(), skillClass); - } -} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/command/CommandClasses.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/command/CommandClasses.java deleted file mode 100644 index 218ceabb..00000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/command/CommandClasses.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.willfp.ecoskills.command; - -import com.willfp.eco.core.EcoPlugin; -import com.willfp.eco.core.command.AbstractCommand; -import org.bukkit.command.CommandSender; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public class CommandClasses extends AbstractCommand { - /** - * Instantiate a new /ecodebug command handler. - * - * @param plugin The plugin for the commands to listen for. - */ - public CommandClasses(@NotNull final EcoPlugin plugin) { - super(plugin, "classes", "ecoskills.classes", true); - } - - @Override - public void onExecute(@NotNull final CommandSender sender, - @NotNull final List args) { - - } -} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/config/ClassConfig.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/config/ClassConfig.java deleted file mode 100644 index d0e63efc..00000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/config/ClassConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.willfp.ecoskills.config; - -import com.willfp.eco.core.config.ExtendableConfig; -import com.willfp.ecoskills.EcoSkillsPlugin; -import org.jetbrains.annotations.NotNull; - -public class ClassConfig extends ExtendableConfig { - /** - * Instantiate a new config for a skill class. - * - * @param name The name of the config. - * @param plugin The provider of the skill class. - */ - public ClassConfig(@NotNull final String name, - @NotNull final Class plugin) { - super(name, true, EcoSkillsPlugin.getInstance(), plugin, "classes/"); - } -} diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/angerartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/angerartifact.yml new file mode 100644 index 00000000..f68c0f30 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/angerartifact.yml @@ -0,0 +1,47 @@ +# +# Anger Artifact EcoEnchant +# + +name: "Anger Artifact" +description: Creates angry villager particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/ashartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/ashartifact.yml new file mode 100644 index 00000000..d3251e3c --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/ashartifact.yml @@ -0,0 +1,47 @@ +# +# Ash Artifact EcoEnchant +# + +name: "Ash Artifact" +description: Creates basalt deltas particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/barrierartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/barrierartifact.yml new file mode 100644 index 00000000..da4458d8 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/barrierartifact.yml @@ -0,0 +1,47 @@ +# +# Barrier Artifact EcoEnchant +# + +name: "Barrier Artifact" +description: Creates barrier particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/cloudsartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/cloudsartifact.yml new file mode 100644 index 00000000..332d2ed9 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/cloudsartifact.yml @@ -0,0 +1,47 @@ +# +# Clouds Artifact EcoEnchant +# + +name: "Clouds Artifact" +description: Creates cloud particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/crimsonartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/crimsonartifact.yml new file mode 100644 index 00000000..cac281d0 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/crimsonartifact.yml @@ -0,0 +1,47 @@ +# +# Crimson Artifact EcoEnchant +# + +name: "Crimson Artifact" +description: Creates crimson forest particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/damageartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/damageartifact.yml new file mode 100644 index 00000000..c5d40bcc --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/damageartifact.yml @@ -0,0 +1,47 @@ +# +# Damage Artifact EcoEnchant +# + +name: "Damage Artifact" +description: Creates damage particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/dragonartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/dragonartifact.yml new file mode 100644 index 00000000..e31eb21d --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/dragonartifact.yml @@ -0,0 +1,47 @@ +# +# Dragon Artifact EcoEnchant +# + +name: "Dragon Artifact" +description: Creates dragon breath particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/dustartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/dustartifact.yml new file mode 100644 index 00000000..b2360be4 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/dustartifact.yml @@ -0,0 +1,47 @@ +# +# Dust Artifact EcoEnchant +# + +name: "Dust Artifact" +description: Creates dust particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/emeraldartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/emeraldartifact.yml new file mode 100644 index 00000000..1697c0da --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/emeraldartifact.yml @@ -0,0 +1,47 @@ +# +# Emerald Artifact EcoEnchant +# + +name: "Emerald Artifact" +description: Creates emerald particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/enchantmentartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/enchantmentartifact.yml new file mode 100644 index 00000000..471ccc38 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/enchantmentartifact.yml @@ -0,0 +1,47 @@ +# +# Enchantment Artifact EcoEnchant +# + +name: "Enchantment Artifact" +description: Creates enchantment particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/endartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/endartifact.yml new file mode 100644 index 00000000..c90841cb --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/endartifact.yml @@ -0,0 +1,47 @@ +# +# End Artifact EcoEnchant +# + +name: "End Artifact" +description: Creates end rod particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/fireartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/fireartifact.yml new file mode 100644 index 00000000..d3abef5e --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/fireartifact.yml @@ -0,0 +1,47 @@ +# +# Fire Artifact EcoEnchant +# + +name: "Fire Artifact" +description: Creates fire particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/heartartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/heartartifact.yml new file mode 100644 index 00000000..90c7c890 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/heartartifact.yml @@ -0,0 +1,47 @@ +# +# Heart Artifact EcoEnchant +# + +name: "Heart Artifact" +description: Creates heart particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/honeyartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/honeyartifact.yml new file mode 100644 index 00000000..553ae409 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/honeyartifact.yml @@ -0,0 +1,47 @@ +# +# Honey Artifact EcoEnchant +# + +name: "Honey Artifact" +description: Creates dripping honey particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false| + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/inkartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/inkartifact.yml new file mode 100644 index 00000000..db710d00 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/inkartifact.yml @@ -0,0 +1,47 @@ +# +# Ink Artifact EcoEnchant +# + +name: "Ink Artifact" +description: Creates ink particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/lavaartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/lavaartifact.yml new file mode 100644 index 00000000..fcc191ab --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/lavaartifact.yml @@ -0,0 +1,47 @@ +# +# Lava Artifact EcoEnchant +# + +name: "Lava Artifact" +description: Creates dripping lava particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/limeartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/limeartifact.yml new file mode 100644 index 00000000..f89bba07 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/limeartifact.yml @@ -0,0 +1,47 @@ +# +# Lime Artifact EcoEnchant +# + +name: "Lime Artifact" +description: Creates lime particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/magicartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/magicartifact.yml new file mode 100644 index 00000000..a485d8ad --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/magicartifact.yml @@ -0,0 +1,47 @@ +# +# Magic Artifact EcoEnchant +# + +name: "Magic Artifact" +description: Creates magic particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/magmaartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/magmaartifact.yml new file mode 100644 index 00000000..271f3f10 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/magmaartifact.yml @@ -0,0 +1,47 @@ +# +# Magma Artifact EcoEnchant +# + +name: "Magma Artifact" +description: Creates lava pop particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/musicartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/musicartifact.yml new file mode 100644 index 00000000..0a40c4a3 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/musicartifact.yml @@ -0,0 +1,47 @@ +# +# Music Artifact EcoEnchant +# + +name: "Music Artifact" +description: Creates note particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/nautilusartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/nautilusartifact.yml new file mode 100644 index 00000000..fff37780 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/nautilusartifact.yml @@ -0,0 +1,47 @@ +# +# Nautilus Artifact EcoEnchant +# + +name: "Nautilus Artifact" +description: Creates nautilus particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/netherartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/netherartifact.yml new file mode 100644 index 00000000..1fd83497 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/netherartifact.yml @@ -0,0 +1,47 @@ +# +# Nether Artifact EcoEnchant +# + +name: "Nether Artifact" +description: Creates nether portal particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/redstoneartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/redstoneartifact.yml new file mode 100644 index 00000000..b291f23d --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/redstoneartifact.yml @@ -0,0 +1,47 @@ +# +# Redstone Artifact EcoEnchant +# + +name: "Redstone Artifact" +description: Creates redstone particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/smokeartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/smokeartifact.yml new file mode 100644 index 00000000..72311870 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/smokeartifact.yml @@ -0,0 +1,47 @@ +# +# Smoke Artifact EcoEnchant +# + +name: "Smoke Artifact" +description: Creates smoke particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/snowartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/snowartifact.yml new file mode 100644 index 00000000..80ea3749 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/snowartifact.yml @@ -0,0 +1,47 @@ +# +# Snow Artifact EcoEnchant +# + +name: "Snow Artifact" +description: Creates snow particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/soulartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/soulartifact.yml new file mode 100644 index 00000000..59c0249a --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/soulartifact.yml @@ -0,0 +1,47 @@ +# +# Soul Artifact EcoEnchant +# + +name: "Soul Artifact" +description: Creates soul particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/soulfireartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/soulfireartifact.yml new file mode 100644 index 00000000..686548ef --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/soulfireartifact.yml @@ -0,0 +1,47 @@ +# +# Soul Fire Artifact EcoEnchant +# + +name: "Soul Fire Artifact" +description: Creates soul flame particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/sparkleartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/sparkleartifact.yml new file mode 100644 index 00000000..714331cc --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/sparkleartifact.yml @@ -0,0 +1,47 @@ +# +# Sparkle Artifact EcoEnchant +# + +name: "Sparkle Artifact" +description: Creates firework particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/sweepartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/sweepartifact.yml new file mode 100644 index 00000000..83bb4377 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/sweepartifact.yml @@ -0,0 +1,47 @@ +# +# Sweep Artifact EcoEnchant +# + +name: "Sweep Artifact" +description: Creates sweep attack particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/tearartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/tearartifact.yml new file mode 100644 index 00000000..f3e768eb --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/tearartifact.yml @@ -0,0 +1,47 @@ +# +# Tear Artifact EcoEnchant +# + +name: "Tear Artifact" +description: Creates crying obsidian particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/totemartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/totemartifact.yml new file mode 100644 index 00000000..5c345b5b --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/totemartifact.yml @@ -0,0 +1,47 @@ +# +# Totem Artifact EcoEnchant +# + +name: "Totem Artifact" +description: Creates totem particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/villagerartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/villagerartifact.yml new file mode 100644 index 00000000..1acbbaee --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/villagerartifact.yml @@ -0,0 +1,47 @@ +# +# Villager Artifact EcoEnchant +# + +name: "Villager Artifact" +description: Creates happy villager particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/warpedartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/warpedartifact.yml new file mode 100644 index 00000000..5e0ccc02 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/warpedartifact.yml @@ -0,0 +1,47 @@ +# +# Warped Artifact EcoEnchant +# + +name: "Warped Artifact" +description: Creates warped forest particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/waterartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/waterartifact.yml new file mode 100644 index 00000000..5189ac95 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/waterartifact.yml @@ -0,0 +1,47 @@ +# +# Water Artifact EcoEnchant +# + +name: "Water Artifact" +description: Creates dripping water particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/witchartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/witchartifact.yml new file mode 100644 index 00000000..281075d2 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/witchartifact.yml @@ -0,0 +1,47 @@ +# +# Witch Artifact EcoEnchant +# + +name: "Witch Artifact" +description: Creates witch particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/artifact/zapartifact.yml b/eco-core/core-plugin/src/main/resources/enchants/artifact/zapartifact.yml new file mode 100644 index 00000000..0d615399 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/artifact/zapartifact.yml @@ -0,0 +1,47 @@ +# +# Zap Artifact EcoEnchant +# + +name: "Zap Artifact" +description: Creates electric particles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + - sword + - axe + - elytra + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + # For Attack + radius: 1 + y-delta: 0.07 + radius-multiplier: 5 + use-double-helix: false + + # For Arrows + Tridents + particle-tick-delay: 2 + + # For Pickaxes + amount: 10 + on-blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + - obsidian + - ancient_debris \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/curse/breaklessnesscurse.yml b/eco-core/core-plugin/src/main/resources/enchants/curse/breaklessnesscurse.yml new file mode 100644 index 00000000..6c4d1e25 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/curse/breaklessnesscurse.yml @@ -0,0 +1,26 @@ +# +# Curse of Breaklessness EcoEnchant +# + +name: "Curse of Breaklessness" +description: Chance to prevent block breaking. +enabled: true + +obtaining: + table: false + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - pickaxe + - axe + - hoe + - shovel + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + chance-per-level: 15 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/curse/callingcurse.yml b/eco-core/core-plugin/src/main/resources/enchants/curse/callingcurse.yml new file mode 100644 index 00000000..7fe81ebe --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/curse/callingcurse.yml @@ -0,0 +1,28 @@ +# +# Curse of Calling EcoEnchant +# + +name: "Curse of Calling" +description: Angers all nearby mobs. +enabled: true + +obtaining: + table: false + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: false + disabled-in-worlds: [ ] + conflicts: + - mending + +config: + repeat-ticks: 20 # How often (in ticks) to call entities + distance: 20 # Entity Range \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/curse/decaycurse.yml b/eco-core/core-plugin/src/main/resources/enchants/curse/decaycurse.yml new file mode 100644 index 00000000..5104268f --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/curse/decaycurse.yml @@ -0,0 +1,26 @@ +# +# Curse of Decay EcoEnchant +# + +name: "Curse of Decay" +description: Automatically damages items when not held. +enabled: true + +obtaining: + table: false + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - all + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - mending + - repairing + +config: + repeat-ticks: 100 # How often (in ticks) to repair items + multiplier: 1 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/curse/fragilitycurse.yml b/eco-core/core-plugin/src/main/resources/enchants/curse/fragilitycurse.yml new file mode 100644 index 00000000..e0620d42 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/curse/fragilitycurse.yml @@ -0,0 +1,25 @@ +# +# Curse of Fragility EcoEnchant +# + +name: "Curse of Fragility" +description: Decreases item durability. +enabled: true + +obtaining: + table: false + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - all + grindstoneable: false + disabled-in-worlds: [ ] + conflicts: + - unbreaking + +config: + minimum-extra-durability: 2 #minimum extra durability lost on each usage + maximum-extra-durability: 8 #maximum extra durability lost on each usage \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/curse/harmlessnesscurse.yml b/eco-core/core-plugin/src/main/resources/enchants/curse/harmlessnesscurse.yml new file mode 100644 index 00000000..a36ba689 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/curse/harmlessnesscurse.yml @@ -0,0 +1,24 @@ +# +# Curse of Harmlessness EcoEnchant +# + +name: "Curse of Harmlessness" +description: Chance for attacks to do nothing. +enabled: true + +obtaining: + table: false + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - sword + - axe + grindstoneable: false + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + chance-per-level: 15 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/curse/hungercurse.yml b/eco-core/core-plugin/src/main/resources/enchants/curse/hungercurse.yml new file mode 100644 index 00000000..29367678 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/curse/hungercurse.yml @@ -0,0 +1,24 @@ +# +# Curse of Hunger EcoEnchant +# + +name: "Curse of Hunger" +description: Increases hunger loss. +enabled: true + +obtaining: + table: false + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - helmet + grindstoneable: false + disabled-in-worlds: [ ] + conflicts: + - sating + +config: +# No config is available for this enchantment \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/curse/inaccuracycurse.yml b/eco-core/core-plugin/src/main/resources/enchants/curse/inaccuracycurse.yml new file mode 100644 index 00000000..83970eef --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/curse/inaccuracycurse.yml @@ -0,0 +1,23 @@ +# +# Curse of Inaccuracy EcoEnchant +# + +name: "Curse of Inaccuracy" +description: Arrows fire incorrectly. +enabled: true + +obtaining: + table: false + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + spread: 0.2 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/curse/misfortunecurse.yml b/eco-core/core-plugin/src/main/resources/enchants/curse/misfortunecurse.yml new file mode 100644 index 00000000..bb318b5b --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/curse/misfortunecurse.yml @@ -0,0 +1,27 @@ +# +# Curse of Misfortune EcoEnchant +# + +name: "Curse of Misfortune" +description: Chance for blocks to not drop items. +enabled: true + +obtaining: + table: false + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - pickaxe + - axe + - hoe + - shovel + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - fortune + +config: + chance-per-level: 15 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/curse/permanencecurse.yml b/eco-core/core-plugin/src/main/resources/enchants/curse/permanencecurse.yml new file mode 100644 index 00000000..7037820c --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/curse/permanencecurse.yml @@ -0,0 +1,24 @@ +# +# Curse of Permanence EcoEnchant +# + +name: "Curse of Permanence" +description: Prevents item from being modified in an anvil. +enabled: true + +obtaining: + table: false + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - all + grindstoneable: false + disabled-in-worlds: [ ] + conflicts: + - mending + +config: +# No config is available for this enchantment \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/abattoir.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/abattoir.yml new file mode 100644 index 00000000..27731089 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/abattoir.yml @@ -0,0 +1,30 @@ +# +# Abattoir EcoEnchant +# + +name: "Abattoir" +description: Increases damage against passive mobs. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - trident + grindstoneable: true + conflicts: + - serrated + - bladed + - phantasm + - pacify + - arachnid + - impaling + maximum-level: 5 + disabled-in-worlds: [ ] + +config: + multiplier: 0.4 # Formula is (multiplier * (level + 1) + 1)*damage | Power is 0.25 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/abrasion.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/abrasion.yml new file mode 100644 index 00000000..0c365c9b --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/abrasion.yml @@ -0,0 +1,25 @@ +# +# Abrasion EcoEnchant +# + +name: "Abrasion" +description: Damages your opponents armor. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + allow-not-fully-charged: false \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/aerial.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/aerial.yml new file mode 100644 index 00000000..8f41807a --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/aerial.yml @@ -0,0 +1,25 @@ +# +# Aerial EcoEnchant +# + +name: "Aerial" +description: Increases arrow damage when shot while in air. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + multiplier: 0.06 # 1 + (Level * Multiplier) is multiplied with the damage diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/aquatic.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/aquatic.yml new file mode 100644 index 00000000..3a150662 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/aquatic.yml @@ -0,0 +1,24 @@ +# +# Aquatic EcoEnchant +# + +name: "Aquatic" +description: Trident deals additional damage when shot from water. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 8 + +config: + multiplier: 0.05 # 1 + (Level * Multiplier) is multiplied with the damage diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/arachnid.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/arachnid.yml new file mode 100644 index 00000000..53abe9b5 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/arachnid.yml @@ -0,0 +1,30 @@ +# +# Arachnid EcoEnchant +# + +name: "Arachnid" +description: Increases damage against spiders. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - serrated + - bladed + - phantasm + - pacify + - abattoir + - impaling + maximum-level: 5 + +config: + multiplier: 0.4 # Formula is (multiplier * (level + 1) + 1)*damage | Power is 0.25 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/arborist.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/arborist.yml new file mode 100644 index 00000000..abfb1806 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/arborist.yml @@ -0,0 +1,35 @@ +# +# Arborist EcoEnchant +# + +name: "Arborist" +description: Get more sticks, apples, and saplings from leaves. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - axe + - shears + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - silk_touch + maximum-level: 4 + +config: + items: + - stick + - apple + - acacia_sapling + - birch_sapling + - dark_oak_sapling + - jungle_sapling + - oak_sapling + - spruce_sapling + chance-per-level: 3 # Chance to drop item. \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/arcanic.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/arcanic.yml new file mode 100644 index 00000000..1d017ffa --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/arcanic.yml @@ -0,0 +1,27 @@ +# +# Arcanic EcoEnchant +# + +name: "Arcanic" +description: Chance to ignore potion damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 2 #Chance of ignoring potion damage = Total points (16 points * 3 chance = 48% chance) \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/atmospheric.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/atmospheric.yml new file mode 100644 index 00000000..9d510829 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/atmospheric.yml @@ -0,0 +1,24 @@ +# +# Atmospheric EcoEnchant +# + +name: "Atmospheric" +description: Increases trident damage when you are in air. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + multiplier: 0.06 # 1 + (Level * Multiplier) is multiplied with the damage diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/aversion.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/aversion.yml new file mode 100644 index 00000000..8e27083d --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/aversion.yml @@ -0,0 +1,23 @@ +# +# Aversion EcoEnchant +# + +name: "Aversion" +description: Prevents angering endermen by looking at them. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: +# No config is available for this enchantment. diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/backstab.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/backstab.yml new file mode 100644 index 00000000..582fad9c --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/backstab.yml @@ -0,0 +1,25 @@ +# +# Backstab EcoEnchant +# + +name: "Backstab" +description: Increases damage when behind opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + multiplier: 0.1 # 1 + (Level * Multiplier) is multiplied with the damage \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/beheading.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/beheading.yml new file mode 100644 index 00000000..e23250fb --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/beheading.yml @@ -0,0 +1,25 @@ +# +# Beheading EcoEnchant +# + +name: "Beheading" +description: Chance of getting player or mob head. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: uncommon + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + chance-per-level: 10 #chance of dropping skull per level \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/blastmining.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/blastmining.yml new file mode 100644 index 00000000..088efcad --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/blastmining.yml @@ -0,0 +1,31 @@ +# +# Blast Mining EcoEnchant +# + +name: "Blast Mining" +description: Mines blocks in a 3x3 area. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - pickaxe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - drill + - vein + maximum-level: 1 + +config: + chance-per-level: 100 + disable-on-sneak: true + enable-sound: true # Play explosion sound + hardness-check: true # Only break blocks with hardness less than or equal to first block + blacklisted-blocks: + - bedrock \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/bleed.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/bleed.yml new file mode 100644 index 00000000..e0172999 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/bleed.yml @@ -0,0 +1,27 @@ +# +# Bleed EcoEnchant +# + +name: "Bleed" +description: Causes your opponent to bleed, damaging them repeatedly. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 7 + +config: + chance-per-level: 1.5 #chance of bleeding per level + allow-not-fully-charged: false #dont require sword attack to be at full charge + bleed-damage: 1 + amount-per-level: 1 # Bleed number per level diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/blind.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/blind.yml new file mode 100644 index 00000000..9bdf47ea --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/blind.yml @@ -0,0 +1,26 @@ +# +# Blind EcoEnchant +# + +name: "Blind" +description: Chance of blinding your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 1 #as percentage + duration-per-level: 15 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/blockbreather.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/blockbreather.yml new file mode 100644 index 00000000..8b2b023f --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/blockbreather.yml @@ -0,0 +1,24 @@ +# +# Block Breather EcoEnchant +# + +name: "Block Breather" +description: Chance to ignore suffocation damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - helmet + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + chance-per-level: 15 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/bosshunter.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/bosshunter.yml new file mode 100644 index 00000000..59c7fa31 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/bosshunter.yml @@ -0,0 +1,25 @@ +# +# Boss Hunter EcoEnchant +# + +name: "Boss Hunter" +description: Increases damage against bosses. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 8 + +config: + multiplier: 0.1 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/buckshot.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/buckshot.yml new file mode 100644 index 00000000..0047b9e3 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/buckshot.yml @@ -0,0 +1,28 @@ +# +# Buckshot EcoEnchant +# + +name: "Buckshot" +description: Shoots multiple arrows spread out. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - succession + - pentashot + - tripleshot + maximum-level: 2 + +config: + amount-per-level: 3 # Arrows to shoot per level + spread-per-level: 0.2 # Spread randomness per level \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/butchering.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/butchering.yml new file mode 100644 index 00000000..65a5e780 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/butchering.yml @@ -0,0 +1,31 @@ +# +# Butchering EcoEnchant +# + +name: "Butchering" +description: Increases damage against passive mobs. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - sharpness + - bane_of_arthropods + - smite + - defusion + - razor + - ender_slayer + maximum-level: 5 + +config: + bonus-per-level: 2.5 # Damage to creepers = base damage + (level * bonus), eg Defusion 5 will do 12.5 more damage to creepers \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/cerebral.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/cerebral.yml new file mode 100644 index 00000000..283646d3 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/cerebral.yml @@ -0,0 +1,25 @@ +# +# Cerebral EcoEnchant +# + +name: "Cerebral" +description: Increases damage on headshots. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 8 + +config: + multiplier: 0.03 # Damage = level * multiplier + 1. Headshot with Cerebral 5 = 5 * 0.05 + 1 = 1.25x damage \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/chopless.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/chopless.yml new file mode 100644 index 00000000..39201c2c --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/chopless.yml @@ -0,0 +1,27 @@ +# +# Chopless EcoEnchant +# + +name: "Chopless" +description: Reduces damage dealt by axes. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + percent-less-per-level: 0.8 # Points * Percent less / 100 * damage = damage taken \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/cleave.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/cleave.yml new file mode 100644 index 00000000..a32ab524 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/cleave.yml @@ -0,0 +1,26 @@ +# +# Cleave EcoEnchant +# + +name: "Cleave" +description: Damage all entities around attacked entity. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - carve + maximum-level: 8 + +config: + damage-percentage-per-level: 2.5 + radius-per-level: 0.5 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/collateral.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/collateral.yml new file mode 100644 index 00000000..15a6639e --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/collateral.yml @@ -0,0 +1,24 @@ +# +# Collateral EcoEnchant +# + +name: "Collateral" +description: Arrows can go through entities. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 4 + +config: +# No config is available for this enchantment diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/conclude.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/conclude.yml new file mode 100644 index 00000000..0c5a2908 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/conclude.yml @@ -0,0 +1,25 @@ +# +# Conclude EcoEnchant +# + +name: "Conclude" +description: Chance to instantly kill entities on low health. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 5 + +config: + minimum-health-per-level: 1 # Multiplied by level, eg: if 1, then Conclude 5 kills any mobs below 2.5 hearts + chance-per-level: 10 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/corrosive.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/corrosive.yml new file mode 100644 index 00000000..b1dedb0c --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/corrosive.yml @@ -0,0 +1,25 @@ +# +# Corrosive EcoEnchant +# + +name: "Corrosive" +description: Damages your opponents armor. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: +# No config is available for this enchantment \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/cranial.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/cranial.yml new file mode 100644 index 00000000..a5c346a1 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/cranial.yml @@ -0,0 +1,24 @@ +# +# Cranial EcoEnchant +# + +name: "Cranial" +description: Increases damage on headshots. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 8 + +config: + multiplier: 0.03 # Damage = level * multiplier + 1. Headshot with Cranial 5 = 5 * 0.05 + 1 = 1.25x damage \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/criticals.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/criticals.yml new file mode 100644 index 00000000..02285036 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/criticals.yml @@ -0,0 +1,26 @@ +# +# Criticals EcoEnchant +# + +name: "Criticals" +description: Increases critical damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + multiplier: 0.1 # 1 + (Level * Multiplier) is multiplied with the damage + use-additive: false # Multiply base damage rather than vanilla critical damage \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/cubism.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/cubism.yml new file mode 100644 index 00000000..44b8b6a7 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/cubism.yml @@ -0,0 +1,25 @@ +# +# Cubism EcoEnchant +# + +name: "Cubism" +description: Increases damage dealt against slimes and magma cubes. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 7 + +config: + multiplier: 0.035 # Damage = level * multiplier + 1 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/defender.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/defender.yml new file mode 100644 index 00000000..301d549e --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/defender.yml @@ -0,0 +1,24 @@ +# +# Defender EcoEnchant +# + +name: "Defender" +description: Prevents damaging your own pets. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: uncommon + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: +# No config available for this enchantment \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/deflection.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/deflection.yml new file mode 100644 index 00000000..3e8b0be7 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/deflection.yml @@ -0,0 +1,24 @@ +# +# Deflection EcoEnchant +# + +name: "Deflection" +description: Rebounds some incoming damage back to your attacker. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: uncommon + +general-config: + targets: + - shield + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + percent-deflected-per-level: 5 # Percent of damage to deal to attacker per level (can go above 100) \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/defusion.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/defusion.yml new file mode 100644 index 00000000..84b83730 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/defusion.yml @@ -0,0 +1,32 @@ +# +# Defusion EcoEnchant +# + +name: "Defusion" +description: Increases damage against creepers. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - sharpness + - bane_of_arthropods + - smite + - butchering + - razor + - ender_slayer + - introversion + maximum-level: 5 + +config: + bonus-per-level: 2.5 # Damage to creepers = base damage + (level * bonus), eg Defusion 5 will do 12.5 more damage to creepers \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/dexterous.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/dexterous.yml new file mode 100644 index 00000000..866c951c --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/dexterous.yml @@ -0,0 +1,25 @@ +# +# Dexterous EcoEnchant +# + +name: "Dexterous" +description: Increases attack speed. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + add-speed-per-level: 0.2 #Bonus to attack speed, default 4.0 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/disable.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/disable.yml new file mode 100644 index 00000000..46ddaee6 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/disable.yml @@ -0,0 +1,25 @@ +# +# Disable EcoEnchant +# + +name: "Disable" +description: Chance of giving your opponent extreme mining fatigue. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + allow-not-fully-charged: false + chance-per-level: 2 #as percentage \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/disappear.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/disappear.yml new file mode 100644 index 00000000..a4132b2f --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/disappear.yml @@ -0,0 +1,28 @@ +# +# Disappear EcoEnchant +# + +name: "Disappear" +description: Go invisble if damaged on low health. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + ticks-per-level: 2 + threshold: 5 # If health is below threshold after being damaged, go invisble diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/diurnal.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/diurnal.yml new file mode 100644 index 00000000..a0e1bf37 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/diurnal.yml @@ -0,0 +1,25 @@ +# +# Diurnal EcoEnchant +# + +name: "Diurnal" +description: Increases damage dealt at daytime. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - nocturnal + maximum-level: 6 + +config: + multiplier: 0.02 # Multiplier per level for damage. Calculated as damage * (1 + level * multiplier) diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/diverse.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/diverse.yml new file mode 100644 index 00000000..90daec21 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/diverse.yml @@ -0,0 +1,24 @@ +# +# Diverse EcoEnchant +# + +name: "Diverse" +description: Increases damage dealt against players holding swords. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + multiplier: 0.05 # Multiplier per level for damage. Calculated as damage * (1 + level * multiplier) diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/drill.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/drill.yml new file mode 100644 index 00000000..ac97562d --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/drill.yml @@ -0,0 +1,33 @@ +# +# Drill EcoEnchant +# + +name: "Drill" +description: Mines blocks behind other blocks. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - pickaxe + - axe + - shovel + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - lumberjack + - blast_mining + - vein + maximum-level: 5 + +config: + blocks-per-level: 1 + disable-on-sneak: true + hardness-check: true # Only break blocks with hardness less than or equal to first block + blacklisted-blocks: + - bedrock \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/dullness.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/dullness.yml new file mode 100644 index 00000000..f2161e5a --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/dullness.yml @@ -0,0 +1,26 @@ +# +# Dullness EcoEnchant +# + +name: "Dullness" +description: Chance of giving your opponent weakness. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + allow-not-fully-charged: false #require sword attack to be at full charge + chance-per-level: 2 + duration-per-level: 10 # 20 ticks is one second \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/dweller.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/dweller.yml new file mode 100644 index 00000000..9919b3ed --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/dweller.yml @@ -0,0 +1,25 @@ +# +# Dweller EcoEnchant +# + +name: "Dweller" +description: Increases damage against illagers. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + multiplier: 0.2 # 1 + (Level * Multiplier) is multiplied with the damage \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/economical.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/economical.yml new file mode 100644 index 00000000..37639633 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/economical.yml @@ -0,0 +1,24 @@ +# +# Economical EcoEnchant +# + +name: "Economical" +description: Chance to not consume fireworks while boosting. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - elytra + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 4 + +config: + chance-per-level: 20 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/electroshock.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/electroshock.yml new file mode 100644 index 00000000..d8db781a --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/electroshock.yml @@ -0,0 +1,25 @@ +# +# Electroshock EcoEnchant +# + +name: "Electroshock" +description: Chance to strike lightning on your attacker. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - shield + grindstoneable: true + + conflicts: [ ] + maximum-level: 3 + +config: + chance-per-level: 5 + damage: 4 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/enderism.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/enderism.yml new file mode 100644 index 00000000..4ff452cb --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/enderism.yml @@ -0,0 +1,26 @@ +# +# Enderism EcoEnchant +# + +name: "Enderism" +description: Increases damage dealt in the end. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - netheric + maximum-level: 6 + +config: + multiplier: 0.02 # Multiplier per level for damage. Calculated as damage * (1 + level * multiplier) diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/enderslayer.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/enderslayer.yml new file mode 100644 index 00000000..250b15b7 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/enderslayer.yml @@ -0,0 +1,32 @@ +# +# Ender Slayer EcoEnchant +# + +name: "Ender Slayer" +description: Increases damage against end mobs. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - sharpness + - bane_of_arthropods + - smite + - defusion + - razor + - butchering + - introversion + maximum-level: 5 + +config: + bonus-per-level: 2.5 # Damage to creepers = base damage + (level * bonus), eg Defusion 5 will do 12.5 more damage to creepers \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/endinfusion.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/endinfusion.yml new file mode 100644 index 00000000..bb1ef03f --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/endinfusion.yml @@ -0,0 +1,25 @@ +# +# End Infusion EcoEnchant +# + +name: "End Infusion" +description: Increases damage dealt in the end. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - nether_infusion + maximum-level: 6 + +config: + multiplier: 0.02 # Multiplier per level for damage. Calculated as damage * (1 + level * multiplier) diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/evasion.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/evasion.yml new file mode 100644 index 00000000..7c63fba8 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/evasion.yml @@ -0,0 +1,28 @@ +# +# Evasion EcoEnchant +# + +name: "Evasion" +description: Chance to ignore incoming damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + # Each level of evasion on each piece of armor counts as a point, so if a player is wearing 4 pieces of armor all with Evasion 3, then that would be 12 points + chance-per-level: 0.5 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/extinguishing.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/extinguishing.yml new file mode 100644 index 00000000..2593d280 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/extinguishing.yml @@ -0,0 +1,27 @@ +# +# Extinguishing EcoEnchant +# + +name: "Extinguishing" +description: Chance to remove fire when taking fire damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + chance-per-level: 4 #Chance of being extinguished = Total points (12 points * 4 chance = 48% chance) \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/extract.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/extract.yml new file mode 100644 index 00000000..c66464dc --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/extract.yml @@ -0,0 +1,24 @@ +# +# Extract EcoEnchant +# + +name: "Extract" +description: Heals a portion of damage dealt. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + health-per-level: 1 # Level * Health = Amount of health to heal diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/famine.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/famine.yml new file mode 100644 index 00000000..3a182d9e --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/famine.yml @@ -0,0 +1,25 @@ +# +# Famine EcoEnchant +# + +name: "Famine" +description: Chance of giving your opponent hunger. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 8 + +config: + allow-not-fully-charged: false + chance-per-level: 1.5 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/farmhand.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/farmhand.yml new file mode 100644 index 00000000..2f33f1ce --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/farmhand.yml @@ -0,0 +1,27 @@ +# +# Farmhand EcoEnchant +# + +name: "Farmhand" +description: Till blocks around initial block. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - hoe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + initial-radius: 1 + per-level-radius: 1 + use-cube: true #If set to false, then it will use a square, and so will not go up/down edges + per-block-damage: true #If set to false, then it will only take 1 durability \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/fetching.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/fetching.yml new file mode 100644 index 00000000..1dd24189 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/fetching.yml @@ -0,0 +1,23 @@ +# +# Fetching EcoEnchant +# + +name: "Fetching" +description: Drops and xp from wolf kills go directly into your inventory. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - helmet + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + not-on-players: false \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/finality.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/finality.yml new file mode 100644 index 00000000..5963d31a --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/finality.yml @@ -0,0 +1,25 @@ +# +# Finality EcoEnchant +# + +name: "Finality" +description: Chance to instantly kill entities on low health. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 5 + +config: + minimum-health-per-level: 1 # Multiplied by level, eg: if 1, then Finality 5 kills any mobs below 2.5 hearts + chance-per-level: 10 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/finishing.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/finishing.yml new file mode 100644 index 00000000..822ec502 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/finishing.yml @@ -0,0 +1,25 @@ +# +# Finishing EcoEnchant +# + +name: "Finishing" +description: Chance to instantly kill entities on low health. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 5 + +config: + minimum-health-per-level: 1 # Multiplied by level, eg: if 1, then Finishing 5 kills any mobs below 2.5 hearts + chance-per-level: 10 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/fireaffinity.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/fireaffinity.yml new file mode 100644 index 00000000..b809bcc8 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/fireaffinity.yml @@ -0,0 +1,25 @@ +# +# Fire Affinity EcoEnchant +# + +name: "Fire Affinity" +description: Increases damage dealt when on fire. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - water_affinity + maximum-level: 7 + +config: + multiplier: 0.05 # 1 + (Level * Multiplier) is multiplied with the damage diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/firststrike.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/firststrike.yml new file mode 100644 index 00000000..363709a3 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/firststrike.yml @@ -0,0 +1,24 @@ +# +# First Strike EcoEnchant +# + +name: "First Strike" +description: Increases damage dealt when entity is on max health. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 5 + +config: + multiplier: 0.15 # 1 + (Level * Multiplier) is multiplied with the damage \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/flinch.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/flinch.yml new file mode 100644 index 00000000..d85a5f3f --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/flinch.yml @@ -0,0 +1,25 @@ +# +# Flinch EcoEnchant +# + +name: "Flinch" +description: Chance to blind your attacker. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - shield + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 2.5 + ticks-per-level: 10 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/forcefield.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/forcefield.yml new file mode 100644 index 00000000..fc6b7e91 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/forcefield.yml @@ -0,0 +1,30 @@ +# +# Forcefield EcoEnchant +# + +name: "Forcefield" +description: Damages all nearby monsters. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + initial-distance: 1.5 # Initial range + bonus-per-level: 0.3 # Bonus range per level (Level 1 also includes bonus) + damage-per-level: 0.5 + repeat-ticks: 20 # Damage nearby mobs every few ticks. Lower values lead to more damage and may cause lag \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/freerunner.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/freerunner.yml new file mode 100644 index 00000000..d5c6d3ba --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/freerunner.yml @@ -0,0 +1,24 @@ +# +# Freerunner EcoEnchant +# + +name: "Freerunner" +description: Chance to ignore fall damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 10 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/frozen.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/frozen.yml new file mode 100644 index 00000000..2f68a5b6 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/frozen.yml @@ -0,0 +1,28 @@ +# +# Frozen EcoEnchant +# + +name: "Frozen" +description: Chance to give your attacker slowness. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 0.6 + points-per-level: 6 # Points of frozen required to increment slowness level by 1 diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/fury.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/fury.yml new file mode 100644 index 00000000..25e2ba66 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/fury.yml @@ -0,0 +1,26 @@ +# +# Fury EcoEnchant +# + +name: "Fury" +description: Chance of angering nearby monsters towards your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 7 + +config: + allow-not-fully-charged: false #require sword attack to be at full charge + chance-per-level: 2 + distance-per-level: 3 # Distance for mobs to check \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/goliath.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/goliath.yml new file mode 100644 index 00000000..6383cdc0 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/goliath.yml @@ -0,0 +1,25 @@ +# +# Goliath EcoEnchant +# + +name: "Goliath" +description: Increases damage against entities with more health than you. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 8 + +config: + multiplier: 0.01 # If enemy has 200 health, and you have 20 w/ goliath 8 then your damage is multiplied by: ((200/10)*8*0.01) + 1 = 2.6 + multiplier-cap: 2.5 # Never deal more than x times more damage \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/graceful.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/graceful.yml new file mode 100644 index 00000000..1073de8d --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/graceful.yml @@ -0,0 +1,24 @@ +# +# Graceful EcoEnchant +# + +name: "Graceful" +description: Chance of getting slow falling just above hitting the ground. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 4 #chance of slow falling per level \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/grapple.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/grapple.yml new file mode 100644 index 00000000..24f5d02d --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/grapple.yml @@ -0,0 +1,28 @@ +# +# Grapple EcoEnchant +# + +name: "Grapple" +description: Pulls entities towards you. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - knockback + - tornado + - annihilate + maximum-level: 2 + +config: + velocity-multiplier: 0.75 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/greenthumb.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/greenthumb.yml new file mode 100644 index 00000000..2724bd4e --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/greenthumb.yml @@ -0,0 +1,23 @@ +# +# Green Thumb EcoEnchant +# + +name: "Green Thumb" +description: Left clicking dirt turns it to grass. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - hoe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + damage: true # Damage hoe on use \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/grit.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/grit.yml new file mode 100644 index 00000000..76cbedb3 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/grit.yml @@ -0,0 +1,27 @@ +# +# Grit EcoEnchant +# + +name: "Grit" +description: Damages your opponents weapon. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + damage-per-level: 0.3 # Damage * points (0.3 * 12 points = 3.6) Rounded up. diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/hellish.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/hellish.yml new file mode 100644 index 00000000..e9ee63d7 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/hellish.yml @@ -0,0 +1,25 @@ +# +# Hellish EcoEnchant +# + +name: "Hellish" +description: Increases damage dealt in the nether. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - void_affinity + maximum-level: 6 + +config: + multiplier: 0.02 # Multiplier per level for damage. Calculated as damage * (1 + level * multiplier) diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/hook.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/hook.yml new file mode 100644 index 00000000..34b4af18 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/hook.yml @@ -0,0 +1,25 @@ +# +# Hook EcoEnchant +# + +name: "Hook" +description: Pulls entities towards you. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - punch + maximum-level: 2 + +config: + velocity-multiplier: 0.75 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/horde.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/horde.yml new file mode 100644 index 00000000..f314e356 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/horde.yml @@ -0,0 +1,25 @@ +# +# Horde EcoEnchant +# + +name: "Horde" +description: Increases damage dealt the more mobs are nearby. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 4 + +config: + multiplier-per-level: 0.005 # Multiplier per mob per level (ie 10 mobs at level 4 will be 1.2x more powerful) + distance-per-level: 2.5 diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/iceshot.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/iceshot.yml new file mode 100644 index 00000000..d9ad852b --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/iceshot.yml @@ -0,0 +1,25 @@ +# +# Ice Shot EcoEnchant +# + +name: "Ice Shot" +description: Chance of freezing your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + chance-per-level: 3 #chance of slowness per level \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/identify.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/identify.yml new file mode 100644 index 00000000..f534a6d8 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/identify.yml @@ -0,0 +1,25 @@ +# +# Identify EcoEnchant +# + +name: "Identify" +description: Chance to give your attacker glowing. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - shield + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + chance-per-level: 10 + ticks-per-level: 10 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/ignite.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/ignite.yml new file mode 100644 index 00000000..c436bdef --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/ignite.yml @@ -0,0 +1,25 @@ +# +# Ignite EcoEnchant +# + +name: "Ignite" +description: Chance to light hit block on fire. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 8 + +config: + chance-per-level: 12.5 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/illusionaspect.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/illusionaspect.yml new file mode 100644 index 00000000..9fd40969 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/illusionaspect.yml @@ -0,0 +1,25 @@ +# +# Illusion Aspect EcoEnchant +# + +name: "Illusion Aspect" +description: Chance to blind and nauseate opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + chance-per-level: 3 #chance of illusioning opponent per level + allow-not-fully-charged: false #dont require sword attack to be at full charge \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/impact.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/impact.yml new file mode 100644 index 00000000..9dfbfab8 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/impact.yml @@ -0,0 +1,25 @@ +# +# Impact EcoEnchant +# + +name: "Impact" +description: Small chance to deal extreme damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + damage-multiplier: 3 + chance-per-level: 0.5 # Chance to deal more (as percentage) \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/incandescence.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/incandescence.yml new file mode 100644 index 00000000..faeac893 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/incandescence.yml @@ -0,0 +1,28 @@ +# +# Incandescence EcoEnchant +# + +name: "Incandescence" +description: Light your attacker on fire. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + initial-ticks: 20 + ticks-per-point: 2 # Ticks victim will be alight for multiplied by each enchantment point, eg: All armor with incandescence 3 = 4*3 = 12 points. diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/infernaltouch.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/infernaltouch.yml new file mode 100644 index 00000000..180b023f --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/infernaltouch.yml @@ -0,0 +1,25 @@ +# +# Infernal Touch EcoEnchant +# + +name: "Infernal Touch" +description: Automatically smelt mined blocks. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - pickaxe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - silk_touch + - stone_switcher + +config: + drop-xp: true # If experience should be given \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/inferno.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/inferno.yml new file mode 100644 index 00000000..4954e079 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/inferno.yml @@ -0,0 +1,23 @@ +# +# Infernal EcoEnchant +# + +name: "Inferno" +description: Flaming tridents. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: uncommon + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: +# No config available for this enchantment \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/infuriate.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/infuriate.yml new file mode 100644 index 00000000..82cab5f8 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/infuriate.yml @@ -0,0 +1,25 @@ +# +# Infuriate EcoEnchant +# + +name: "Infuriate" +description: Chance to cause nearby mobs to attack your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - shield + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 7 + +config: + chance-per-level: 2 + distance-per-level: 2 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/insecticide.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/insecticide.yml new file mode 100644 index 00000000..508fa4a5 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/insecticide.yml @@ -0,0 +1,29 @@ +# +# Insecticide EcoEnchant +# + +name: "Insecticide" +description: Increases damage against spiders. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - power + - force + - revenant + - slaughter + - settle + maximum-level: 5 + +config: + multiplier: 0.4 # Formula is (multiplier * (level + 1) + 1)*damage | Power is 0.25 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/instantaneous.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/instantaneous.yml new file mode 100644 index 00000000..a93d2af7 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/instantaneous.yml @@ -0,0 +1,27 @@ +# +# Instantaneous EcoEnchant +# + +name: "Instantaneous" +description: Chance of instantly breaking blocks. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - pickaxe + - axe + - shovel + - hoe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 7 + +config: + chance-per-level: 3 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/introversion.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/introversion.yml new file mode 100644 index 00000000..d278438c --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/introversion.yml @@ -0,0 +1,32 @@ +# +# Introversion EcoEnchant +# + +name: "Introversion" +description: Increases damage against players. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: uncommon + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - sharpness + - bane_of_arthropods + - smite + - defusion + - razor + - ender_slayer + - butchering + maximum-level: 5 + +config: + bonus-per-level: 2.5 # Damage to players = base damage + (level * bonus), eg Introversion 5 will do 12.5 more damage to players \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/invigoration.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/invigoration.yml new file mode 100644 index 00000000..a3c0fef5 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/invigoration.yml @@ -0,0 +1,30 @@ +# +# Invigoration EcoEnchant +# + +name: "Invigoration" +description: Increases outgoing damage and reduces incoming damage when low on health. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + # Each level of invigoration on each piece of armor counts as a point, so if a player is wearing 4 pieces of armor all with Invigoration 3, then that would be 12 points + reduction-multiplier: 5 # In percent, so default is take 5% less damage per point + damage-multiplier: 2.5 # In percent, so default is deal 5% more damage per point + below-health: 5 # Activates below specified health \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/kinetic.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/kinetic.yml new file mode 100644 index 00000000..781f42ec --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/kinetic.yml @@ -0,0 +1,24 @@ +# +# Kinetic EcoEnchant +# + +name: "Kinetic" +description: Reduces damage taken when flying into a wall. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - elytra + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + reduction-per-level: 15 #Percent less damage taken per level \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/launch.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/launch.yml new file mode 100644 index 00000000..db2cc3ef --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/launch.yml @@ -0,0 +1,24 @@ +# +# Launch EcoEnchant +# + +name: "Launch" +description: Fireworks give a short burst of extreme speed. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - elytra + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 8 + +config: + multiplier: 0.3 # Velocity multiplier per level \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/leeching.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/leeching.yml new file mode 100644 index 00000000..e18a25c9 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/leeching.yml @@ -0,0 +1,27 @@ +# +# Leeching EcoEnchant +# + +name: "Leeching" +description: Heals a portion of damage dealt. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - life_steal + maximum-level: 3 + +config: + health-per-level: 1 # Level * Health = Amount of health to heal + allow-not-fully-charged: false diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/lesion.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/lesion.yml new file mode 100644 index 00000000..269eeabd --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/lesion.yml @@ -0,0 +1,26 @@ +# +# Lesion EcoEnchant +# + +name: "Lesion" +description: Causes your opponent to bleed, damaging them repeatedly. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 7 + +config: + chance-per-level: 3 #chance of bleeding per level + bleed-damage: 1 + amount-per-level: 1 # Bleed number per level diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/levitate.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/levitate.yml new file mode 100644 index 00000000..44c48b6e --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/levitate.yml @@ -0,0 +1,26 @@ +# +# Levitate EcoEnchant +# + +name: "Levitate" +description: Chance of applying levitation to your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + chance-per-level: 3 #chance of levitation per level + duration-per-level: 30 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/liquidshot.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/liquidshot.yml new file mode 100644 index 00000000..424a1d3e --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/liquidshot.yml @@ -0,0 +1,25 @@ +# +# Liquid Shot EcoEnchant +# + +name: "Liquid Shot" +description: Increases damage against fiery mobs. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 5 + +config: + multiplier: 0.05 # Damage = level * multiplier + 1. Damage on blaze/magma cube with Liquid Shot 5 = 5 * 0.05 + 1 = 1.25x damage \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/luckycatch.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/luckycatch.yml new file mode 100644 index 00000000..042dd946 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/luckycatch.yml @@ -0,0 +1,24 @@ +# +# Lucky Catch EcoEnchant +# + +name: "Lucky Catch" +description: Chance to double fishing drops. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - rod + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + chance-per-level: 15 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/lumberjack.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/lumberjack.yml new file mode 100644 index 00000000..6b8e2157 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/lumberjack.yml @@ -0,0 +1,41 @@ +# +# Lumberjack EcoEnchant +# + +name: "Lumberjack" +description: Instantly cut down entire trees. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - axe + grindstoneable: true + disabled-in-worlds: [ ] + maximum-level: 6 + conflicts: + - drill + +config: + disable-on-sneak: true + blocks-per-level: 32 + whitelisted-blocks: + - oak_wood + - dark_oak_wood + - acacia_wood + - jungle_wood + - birch_wood + - crimson_stem + - spruce_wood + - warped_stem + - oak_log + - dark_oak_log + - acacia_log + - jungle_log + - birch_log + - spruce_log \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/magmawalker.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/magmawalker.yml new file mode 100644 index 00000000..f2bdc598 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/magmawalker.yml @@ -0,0 +1,26 @@ +# +# Magma Walker EcoEnchant +# + +name: "Magma Walker" +description: Turns lava beneath the player into obsidian. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + remove-after-ticks: 40 + initial-radius: 2 + per-level-radius: 1 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/magnetic.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/magnetic.yml new file mode 100644 index 00000000..c20c0638 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/magnetic.yml @@ -0,0 +1,26 @@ +# +# Magnetic EcoEnchant +# + +name: "Magnetic" +description: Items and XP go towards you. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 4 + +config: + initial-distance: 2.5 # Initial item pickup range + bonus-per-level: 0.6 # Bonus range per level (Level 1 also includes bonus) + repeat-ticks: 3 # Check magnetic every few ticks. Lower values give smoother animations and feels better to the end user, however may cause lag on lower-end hardware. \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/marking.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/marking.yml new file mode 100644 index 00000000..f9ebb3b9 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/marking.yml @@ -0,0 +1,26 @@ +# +# Marking EcoEnchant +# + +name: "Marking" +description: Increases subsequent damage dealt to opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 4 + +config: + ticks-per-level: 15 # Ticks to weaken player for per level + multiplier-while-weak: 1.25 # Times more damage to deal while weakened diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/marksman.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/marksman.yml new file mode 100644 index 00000000..19da870a --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/marksman.yml @@ -0,0 +1,24 @@ +# +# Marksman EcoEnchant +# + +name: "Marksman" +description: Removes arrow drop. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + remove-arrow-after-ticks: 120 #to prevent server lag, as arrows shot into the sky will not land. there are 20 ticks in a second. diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/necrotic.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/necrotic.yml new file mode 100644 index 00000000..81370321 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/necrotic.yml @@ -0,0 +1,25 @@ +# +# Necrotic EcoEnchant +# + +name: "Necrotic" +description: Wither skeletons have a higher chance to drop skulls. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - looting + maximum-level: 4 + +config: + chance-per-level: 5 #Chance of dropping a wither skull per level \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/netheric.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/netheric.yml new file mode 100644 index 00000000..8938537a --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/netheric.yml @@ -0,0 +1,26 @@ +# +# Netheric EcoEnchant +# + +name: "Netheric" +description: Increases damage dealt in the nether. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - enderism + maximum-level: 6 + +config: + multiplier: 0.02 # Multiplier per level for damage. Calculated as damage * (1 + level * multiplier) diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/netherinfusion.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/netherinfusion.yml new file mode 100644 index 00000000..666bd0a6 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/netherinfusion.yml @@ -0,0 +1,25 @@ +# +# Nether Infusion EcoEnchant +# + +name: "Nether Infusion" +description: Increases damage dealt in the nether. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - end_infusion + maximum-level: 6 + +config: + multiplier: 0.02 # Multiplier per level for damage. Calculated as damage * (1 + level * multiplier) diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/nocturnal.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/nocturnal.yml new file mode 100644 index 00000000..2ed50518 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/nocturnal.yml @@ -0,0 +1,25 @@ +# +# Nocturnal EcoEnchant +# + +name: "Nocturnal" +description: Increases damage dealt at night. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - diurnal + maximum-level: 6 + +config: + multiplier: 0.02 # Multiplier per level for damage. Calculated as damage * (1 + level * multiplier) diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/optics.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/optics.yml new file mode 100644 index 00000000..5681be55 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/optics.yml @@ -0,0 +1,25 @@ +# +# Optics EcoEnchant +# + +name: "Optics" +description: Increases damage when further from target. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: uncommon + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 5 + +config: + block-multiplier: 0.002 # Damage multiplier is distance * level * multiplier + 1 eg: 50 blocks with optics 5 and multiplier 0.002 = 50*5*0.002+1 = 1.5x damage diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/oxygenate.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/oxygenate.yml new file mode 100644 index 00000000..9384b040 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/oxygenate.yml @@ -0,0 +1,27 @@ +# +# Oxygenate EcoEnchant +# + +name: "Oxygenate" +description: Gain oxygen when breaking blocks underwater. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - pickaxe + - axe + - shovel + - hoe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 8 + +config: + oxygen-per-level: 8 # Oxygen ticks to give per level diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/pacify.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/pacify.yml new file mode 100644 index 00000000..290702f4 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/pacify.yml @@ -0,0 +1,30 @@ +# +# Pacify EcoEnchant +# + +name: "Pacify" +description: Increases damage against creepers. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - serrated + - bladed + - phantasm + - arachnid + - abattoir + - impaling + maximum-level: 5 + +config: + multiplier: 0.4 # Formula is (multiplier * (level + 1) + 1)*damage | Power is 0.25 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/paladin.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/paladin.yml new file mode 100644 index 00000000..78ff703f --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/paladin.yml @@ -0,0 +1,24 @@ +# +# Paladin EcoEnchant +# + +name: "Paladin" +description: Increases damage dealt when riding a horse. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + multiplier: 0.2 # 1 + (Level * Multiplier) is multiplied with the damage \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/paralyze.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/paralyze.yml new file mode 100644 index 00000000..283493fe --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/paralyze.yml @@ -0,0 +1,25 @@ +# +# Paralyze EcoEnchant +# + +name: "Paralyze" +description: Chance to give your attacker mining fatigue. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - shield + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 1.5 + ticks-per-level: 5 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/parasitic.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/parasitic.yml new file mode 100644 index 00000000..bb2fc8ff --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/parasitic.yml @@ -0,0 +1,25 @@ +# +# Parasitic EcoEnchant +# + +name: "Parasitic" +description: Heals a portion of damage dealt. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + health-per-level: 1 # Level * Health = Amount of health to heal diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/parry.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/parry.yml new file mode 100644 index 00000000..0a437834 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/parry.yml @@ -0,0 +1,24 @@ +# +# Parry EcoEnchant +# + +name: "Parry" +description: Reduces incoming damage when holding item. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 4 + +config: + multiplier: 0.05 # 1 - (Level * Multiplier) is multiplied with the damage diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/phantasm.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/phantasm.yml new file mode 100644 index 00000000..8f44722f --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/phantasm.yml @@ -0,0 +1,30 @@ +# +# Phantasm EcoEnchant +# + +name: "Phantasm" +description: Increases damage against undead mobs. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - serrated + - bladed + - arachnid + - pacify + - abattoir + - impaling + maximum-level: 5 + +config: + multiplier: 0.4 # Formula is (multiplier * (level + 1) + 1)*damage | Power is 0.25 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/plasmic.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/plasmic.yml new file mode 100644 index 00000000..86f6c51f --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/plasmic.yml @@ -0,0 +1,25 @@ +# +# Plasmic EcoEnchant +# + +name: "Plasmic" +description: Increases damage dealt against opponents with diamond or netherite armor. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - voltage + maximum-level: 5 + +config: + multiplier: 0.015 # bonus damage multiplier = multiplier * level * pieces diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/protector.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/protector.yml new file mode 100644 index 00000000..c2937c8f --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/protector.yml @@ -0,0 +1,24 @@ +# +# Protector EcoEnchant +# + +name: "Protector" +description: Prevents damaging your own pets. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: uncommon + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: +# No config available for this enchantment \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/proximity.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/proximity.yml new file mode 100644 index 00000000..8e7cc0aa --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/proximity.yml @@ -0,0 +1,25 @@ +# +# Proximity EcoEnchant +# + +name: "Proximity" +description: Increases damage when closer to opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 5 + +config: + when-closer-than-blocks: 1.5 + multiplier: 0.05 # 1 + (Level * Multiplier) is multiplied with the damage diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/puncture.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/puncture.yml new file mode 100644 index 00000000..442b4229 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/puncture.yml @@ -0,0 +1,24 @@ +# +# Puncture EcoEnchant +# + +name: "Puncture" +description: Trident deals additional damage to shelled mobs. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + multiplier: 0.12 # 1 + (Level * Multiplier) is multiplied with the damage diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/quadrilateralism.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/quadrilateralism.yml new file mode 100644 index 00000000..eca4f2d6 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/quadrilateralism.yml @@ -0,0 +1,25 @@ +# +# Quadrilateralism EcoEnchant +# + +name: "Quadrilateralism" +description: Increases damage dealt against slimes and magma cubes. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 7 + +config: + multiplier: 0.035 # Damage = level * multiplier + 1 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/radiance.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/radiance.yml new file mode 100644 index 00000000..e609f533 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/radiance.yml @@ -0,0 +1,26 @@ +# +# Radiance EcoEnchant +# + +name: "Radiance" +description: Causes entities to glow near where arrow lands. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 4 + +config: + radius-multiplier: 3 # Radius Multiplier * level = Radius of which to damage entities + duration-per-level: 10 # Duration (in ticks) to make entity glow for \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/rage.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/rage.yml new file mode 100644 index 00000000..906720fa --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/rage.yml @@ -0,0 +1,25 @@ +# +# Rage EcoEnchant +# + +name: "Rage" +description: Chance of angering nearby monsters towards your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 5 + +config: + chance-per-level: 3 + distance-per-level: 4 # Distance for mobs to check \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/rapid.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/rapid.yml new file mode 100644 index 00000000..28510c29 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/rapid.yml @@ -0,0 +1,24 @@ +# +# Rapid EcoEnchant +# + +name: "Rapid" +description: Increases bow pull speed. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: uncommon + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + percent-faster-per-level: 16 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/reaper.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/reaper.yml new file mode 100644 index 00000000..9689ea62 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/reaper.yml @@ -0,0 +1,25 @@ +# +# Reaper EcoEnchant +# + +name: "Reaper" +description: Chance to prevent your opponents soulbound from working. +enabled: true + +obtaining: + table: true + villager: false + loot: false + rarity: legendary + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + chance-per-level: 2 diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/rebounding.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/rebounding.yml new file mode 100644 index 00000000..ad99e3a8 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/rebounding.yml @@ -0,0 +1,27 @@ +# +# Rebounding EcoEnchant +# + +name: "Rebounding" +description: Deal knockback to entities that attack you. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + velocity-multiplier: 1.07 diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/reel.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/reel.yml new file mode 100644 index 00000000..90569893 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/reel.yml @@ -0,0 +1,24 @@ +# +# Reel EcoEnchant +# + +name: "Reel" +description: Pulls entities towards you. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - rod + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + velocity-multiplier: 0.75 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/reinforcement.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/reinforcement.yml new file mode 100644 index 00000000..9263626b --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/reinforcement.yml @@ -0,0 +1,24 @@ +# +# Reinforcement EcoEnchant +# + +name: "Reinforcement" +description: Reduces incoming damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - elytra + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 4 + +config: + reduction-per-level: 2 #Percent less damage taken per level (Protection is 4%) \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/rejuvenation.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/rejuvenation.yml new file mode 100644 index 00000000..82813e54 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/rejuvenation.yml @@ -0,0 +1,27 @@ +# +# Rejuvenation EcoEnchant +# + +name: "Rejuvenation" +description: Increases natural regeneration speed. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + per-point-multiplier: 0.1 # 8 points * multiplier +1 = 1.8x natural regen \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/replenish.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/replenish.yml new file mode 100644 index 00000000..758d5ede --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/replenish.yml @@ -0,0 +1,23 @@ +# +# Replenish EcoEnchant +# + +name: "Replenish" +description: Automatically replants crops. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - hoe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: +# No config is available for this enchantment \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/respirator.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/respirator.yml new file mode 100644 index 00000000..7124274c --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/respirator.yml @@ -0,0 +1,24 @@ +# +# Respirator EcoEnchant +# + +name: "Respirator" +description: Reduces dragon breath damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - helmet + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + percent-less-per-level: 15 # Points * Percent less / 100 * damage = damage taken \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/revenant.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/revenant.yml new file mode 100644 index 00000000..135247f4 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/revenant.yml @@ -0,0 +1,29 @@ +# +# Revenant EcoEnchant +# + +name: "Revenant" +description: Increases damage against undead mobs. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - power + - force + - insecticide + - slaughter + - settle + maximum-level: 5 + +config: + multiplier: 0.4 # Formula is (multiplier * (level + 1) + 1)*damage | Power is 0.25 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/sating.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/sating.yml new file mode 100644 index 00000000..4991ef01 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/sating.yml @@ -0,0 +1,24 @@ +# +# Sating EcoEnchant +# + +name: "Sating" +description: Reduces hunger loss. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 10 # Chance to "ignore" food loss (in percent) every time you lose food \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/serrated.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/serrated.yml new file mode 100644 index 00000000..3d7481fd --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/serrated.yml @@ -0,0 +1,30 @@ +# +# Serrated EcoEnchant +# + +name: "Serrated" +description: Trident deals additional damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - bladed + - phantasm + - arachnid + - pacify + - abattoir + - impaling + maximum-level: 5 + +config: + multiplier: 0.25 # 1 + (Level * Multiplier) is multiplied with the damage diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/settle.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/settle.yml new file mode 100644 index 00000000..fea790f1 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/settle.yml @@ -0,0 +1,29 @@ +# +# Settle EcoEnchant +# + +name: "Settle" +description: Increases damage against creepers. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - power + - force + - revenant + - slaughter + - insecticide + maximum-level: 5 + +config: + multiplier: 0.4 # Formula is (multiplier * (level + 1) + 1)*damage | Power is 0.25 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/shockwave.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/shockwave.yml new file mode 100644 index 00000000..0009a2c9 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/shockwave.yml @@ -0,0 +1,24 @@ +# +# Shockwave EcoEnchant +# + +name: "Shockwave" +description: Damages entities that arrows fly near. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + damage-per-level: 1 diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/shotassist.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/shotassist.yml new file mode 100644 index 00000000..335fe17c --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/shotassist.yml @@ -0,0 +1,27 @@ +# +# Shot Assist EcoEnchant +# + +name: "Shot Assist" +description: Deal more damage with arrows while wearing. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + multiplier: 0.015 # 1 + (Level * Multiplier) is multiplied with the damage diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/sickening.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/sickening.yml new file mode 100644 index 00000000..f7222d4d --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/sickening.yml @@ -0,0 +1,26 @@ +# +# Sickening EcoEnchant +# + +name: "Sickening" +description: Chance of nauseating your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + chance-per-level: 3 #as percentage + duration-per-level: 30 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/slaughter.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/slaughter.yml new file mode 100644 index 00000000..bd75ed54 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/slaughter.yml @@ -0,0 +1,29 @@ +# +# Slaughter EcoEnchant +# + +name: "Slaughter" +description: Increases damage against passive mobs. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - power + - force + - revenant + - insecticide + - settle + maximum-level: 5 + +config: + multiplier: 0.4 # Formula is (multiplier * (level + 1) + 1)*damage | Power is 0.25 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/slicing.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/slicing.yml new file mode 100644 index 00000000..f4b9f5b3 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/slicing.yml @@ -0,0 +1,26 @@ +# +# Slicing EcoEnchant +# + +name: "Slicing" +description: Damages entities when flown through. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - elytra + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 8 + +config: + damage-per-level: 0.7 #Damage given to opponent per level + cooldown: 20 #Cooldown in ticks until player can attack another entity with slicing + damage-elytra: true \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/spearfishing.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/spearfishing.yml new file mode 100644 index 00000000..812aee46 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/spearfishing.yml @@ -0,0 +1,29 @@ +# +# Spearfishing EcoEnchant +# + +name: "Spearfishing" +description: Chance of dropping fish when tridenting water. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 4 + drops: + - cod + - salmon + - pufferfish + - tropical_fish \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/spiked.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/spiked.yml new file mode 100644 index 00000000..c015ae3d --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/spiked.yml @@ -0,0 +1,25 @@ +# +# Spiked EcoEnchant +# + +name: "Spiked" +description: Hooking onto an entity will damage it. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: common + +general-config: + targets: + - rod + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - harpoon + maximum-level: 3 + +config: + damage-per-level: 1 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/splash.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/splash.yml new file mode 100644 index 00000000..5aa3a372 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/splash.yml @@ -0,0 +1,26 @@ +# +# Splash EcoEnchant +# + +name: "Splash" +description: Damages entities near where trident lands but does not drop experience. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - wisdom + maximum-level: 4 + +config: + radius-multiplier: 2 # Radius Multiplier * level = Radius of which to damage entities + damage-per-level: 1 # Damage to give to nearby entities \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/stab.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/stab.yml new file mode 100644 index 00000000..4fec62f6 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/stab.yml @@ -0,0 +1,26 @@ +# +# Stab EcoEnchant +# + +name: "Stab" +description: Increases melee trident damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 5 + +config: + damage-base: 0.5 # More damage to do as base + damage-per-level: 0.5 # More damage to do per level + # Default values are taken from sharpness diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/stalwart.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/stalwart.yml new file mode 100644 index 00000000..1fc7c68a --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/stalwart.yml @@ -0,0 +1,28 @@ +# +# Stalwart EcoEnchant +# + +name: "Stalwart" +description: Chance to get resistance for a short time when taking damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + chance-per-level: 2 + duration-per-level: 5 # Ticks to get resistance for \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/stamina.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/stamina.yml new file mode 100644 index 00000000..e7adf594 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/stamina.yml @@ -0,0 +1,24 @@ +# +# Stamina EcoEnchant +# + +name: "Stamina" +description: Decreases hunger loss while sprinting. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 4 + +config: + chance-per-level: 10 # Chance to "ignore" food loss (in percent) every time you lose food while sprinting \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/stoneswitcher.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/stoneswitcher.yml new file mode 100644 index 00000000..0f567330 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/stoneswitcher.yml @@ -0,0 +1,30 @@ +# +# Stone Switcher EcoEnchant +# + +name: "Stone Switcher" +description: Breaking stone can drop as variants. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - pickaxe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - transfuse + - silk_touch + maximum-level: 6 + +config: + blocks: + - andesite + - granite + - diorite + chance-per-level: 10 # Chance for drop to be switched diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/strayaspect.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/strayaspect.yml new file mode 100644 index 00000000..aed7db37 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/strayaspect.yml @@ -0,0 +1,26 @@ +# +# Stray Aspect EcoEnchant +# + +name: "Stray Aspect" +description: Chance of slowing your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + allow-not-fully-charged: false + chance-per-level: 1 #chance of slowness per level + ticks-per-level: 10 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/succession.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/succession.yml new file mode 100644 index 00000000..c57cd0e1 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/succession.yml @@ -0,0 +1,27 @@ +# +# Succession EcoEnchant +# + +name: "Succession" +description: Shoots multiple arrows in a burst. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - tripleshot + - pentashot + - buckshot + +config: + extra-arrows-per-level: 1 + per-arrow-damage: true #If set to false, then it will only take 1 durability \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/supercritical.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/supercritical.yml new file mode 100644 index 00000000..144a5f04 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/supercritical.yml @@ -0,0 +1,26 @@ +# +# Supercritical EcoEnchant +# + +name: "Supercritical" +description: Small chance to deal extreme damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + damage-multiplier: 3 + allow-not-fully-charged: false + chance-per-level: 0.5 # Chance to deal supercrit per hit \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/sycophant.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/sycophant.yml new file mode 100644 index 00000000..8daaa16a --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/sycophant.yml @@ -0,0 +1,24 @@ +# +# Sycophant EcoEnchant +# + +name: "Sycophant" +description: Heals a portion of damage blocked. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - shield + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + health-per-level: 1 # Level * Health = Amount of health to heal diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/tectonic.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/tectonic.yml new file mode 100644 index 00000000..36fc8433 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/tectonic.yml @@ -0,0 +1,28 @@ +# +# Tectonic EcoEnchant +# + +name: "Tectonic" +description: Damages nearby entities when taking fall damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - feather_falling + maximum-level: 2 + +config: + initial-radius: 3 + per-level-radius: 2 + initial-damage: 1 + per-level-damage: 1 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/telekinesis.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/telekinesis.yml new file mode 100644 index 00000000..332c4cc7 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/telekinesis.yml @@ -0,0 +1,31 @@ +# +# Telekinesis EcoEnchant +# + +name: "Telekinesis" +description: Drops and xp go directly into your inventory. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: uncommon + +general-config: + targets: + - pickaxe + - axe + - shovel + - hoe + - sword + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + use-orb: true # Use experience orb above player to give xp. Use if you need mending interaction. + not-on-players: false # Disallow getting drops from players \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/thor.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/thor.yml new file mode 100644 index 00000000..00e03c21 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/thor.yml @@ -0,0 +1,26 @@ +# +# Thor EcoEnchant +# + +name: "Thor" +description: Chance of striking lightning on your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 2 + allow-not-fully-charged: false # dont require sword attack to be at full charge + lightning-damage: 2.5 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/thrive.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/thrive.yml new file mode 100644 index 00000000..81112a1d --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/thrive.yml @@ -0,0 +1,28 @@ +# +# Thrive EcoEnchant +# + +name: "Thrive" +description: Increases maximum health. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - prosperity + maximum-level: 2 + +config: + health-per-point: 1 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/tornado.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/tornado.yml new file mode 100644 index 00000000..3dc695bd --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/tornado.yml @@ -0,0 +1,28 @@ +# +# Tornado EcoEnchant +# + +name: "Tornado" +description: Knocks your opponent into the air. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - knockback + - grapple + - annihilate + maximum-level: 2 + +config: + velocity-per-level: 0.25 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/toxic.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/toxic.yml new file mode 100644 index 00000000..94757c9d --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/toxic.yml @@ -0,0 +1,25 @@ +# +# Toxic EcoEnchant +# + +name: "Toxic" +description: Chance to apply poison to your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + chance-per-level: 3 #chance of poisoning opponent per level + allow-not-fully-charged: false \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/transfuse.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/transfuse.yml new file mode 100644 index 00000000..8ada646b --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/transfuse.yml @@ -0,0 +1,34 @@ +# +# Transfuse EcoEnchant +# + +name: "Transfuse" +description: Breaking stone can drop as random ore. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - pickaxe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - stone_switcher + - silk_touch + maximum-level: 7 + +config: + blocks: + - diamond_ore + - gold_ore + - lapis_ore + - redstone_ore + - iron_ore + chance-per-level: 0.03 # Chance for drop to be switched + works-on: + - stone diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/tripleshot.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/tripleshot.yml new file mode 100644 index 00000000..1b4a5e7c --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/tripleshot.yml @@ -0,0 +1,26 @@ +# +# Tripleshot EcoEnchant +# + +name: "Tripleshot" +description: Shoots 3 arrows. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - succession + - pentashot + - buckshot + +config: + angle: 11 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/vampireaspect.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/vampireaspect.yml new file mode 100644 index 00000000..6d9b3ba3 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/vampireaspect.yml @@ -0,0 +1,25 @@ +# +# Vampire Aspect EcoEnchant +# + +name: "Vampire Aspect" +description: Chance to apply wither to your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + chance-per-level: 3 #chance of withering opponent per level + allow-not-fully-charged: false #dont require sword attack to be at full charge \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/vein.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/vein.yml new file mode 100644 index 00000000..3323ba2b --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/vein.yml @@ -0,0 +1,39 @@ +# +# Vein EcoEnchant +# + +name: "Vein" +description: Mine blocks in a vein. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - pickaxe + grindstoneable: true + disabled-in-worlds: [ ] + maximum-level: 5 + conflicts: + - drill + - blast_mining + +config: + disable-on-sneak: true + blocks-per-level: 8 + whitelisted-blocks: + - coal_ore + - iron_ore + - gold_ore + - ancient_debris + - lapis_ore + - diamond_ore + - redstone_ore + - nether_quartz_ore + - gilded_blackstone + - nether_gold_ore + - glowstone \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/venom.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/venom.yml new file mode 100644 index 00000000..4bfe4dcd --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/venom.yml @@ -0,0 +1,25 @@ +# +# Venom EcoEnchant +# + +name: "Venom" +description: Chance of withering your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 1 #chance of wither per level \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/voidaffinity.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/voidaffinity.yml new file mode 100644 index 00000000..7fa75229 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/voidaffinity.yml @@ -0,0 +1,25 @@ +# +# Void Affinity EcoEnchant +# + +name: "Void Affinity" +description: Increases damage dealt in the end. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - netheric + maximum-level: 5 + +config: + multiplier: 0.02 # Multiplier per level for damage. Calculated as damage * (1 + level * multiplier) diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/voltage.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/voltage.yml new file mode 100644 index 00000000..b32ed621 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/voltage.yml @@ -0,0 +1,25 @@ +# +# Voltage EcoEnchant +# + +name: "Voltage" +description: Increases damage dealt against opponents with iron, gold, or chain armor. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - plasmic + maximum-level: 5 + +config: + multiplier: 0.015 # bonus damage multiplier = multiplier * level * pieces diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/wateraffinity.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/wateraffinity.yml new file mode 100644 index 00000000..93a65fb5 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/wateraffinity.yml @@ -0,0 +1,25 @@ +# +# Water Affinity EcoEnchant +# + +name: "Water Affinity" +description: Increases damage dealt when in water. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - fire_affinity + maximum-level: 7 + +config: + multiplier: 0.02 # 1 + (Level * Multiplier) is multiplied with the damage diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/wateraspect.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/wateraspect.yml new file mode 100644 index 00000000..228c7e2e --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/wateraspect.yml @@ -0,0 +1,26 @@ +# +# Water Aspect EcoEnchant +# + +name: "Water Aspect" +description: Increases damage dealt against fiery mobs. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - fire_aspect + maximum-level: 2 + +config: + multiplier: 0.2 # Damage = level * multiplier + 1. Damage on blaze/magma cube with Water Aspect 2 = 2 * 0.2 + 1 = 1.4x damage \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/weakening.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/weakening.yml new file mode 100644 index 00000000..a96b9220 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/weakening.yml @@ -0,0 +1,25 @@ +# +# Weakening EcoEnchant +# + +name: "Weakening" +description: Increases subsequent damage dealt to opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 4 + +config: + ticks-per-level: 1.5 # Ticks to weaken player for per level + multiplier-while-weak: 1.25 # Times more damage to deal while weakened diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/wisdom.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/wisdom.yml new file mode 100644 index 00000000..e2b8b49a --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/wisdom.yml @@ -0,0 +1,33 @@ +# +# Wisdom EcoEnchant +# + +name: "Wisdom" +description: Increases dropped experience. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: uncommon + +general-config: + targets: + - sword + - axe + - pickaxe + - shovel + - hoe + - bow + - crossbow + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - splash + - intellect + maximum-level: 3 + +config: + bonus-per-point: 0.2 #Increase per level relative to base \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/woodswitcher.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/woodswitcher.yml new file mode 100644 index 00000000..d6e5fc72 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/woodswitcher.yml @@ -0,0 +1,32 @@ +# +# Wood Switcher EcoEnchant +# + +name: "Wood Switcher" +description: Breaking logs can drop as other logs. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - silk_touch + maximum-level: 6 + +config: + blocks: + - oak_log + - birch_log + - spruce_log + - jungle_log + - acacia_log + - dark_oak_log + chance-per-level: 10 # Chance for drop to be switched diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/wound.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/wound.yml new file mode 100644 index 00000000..2c45c977 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/wound.yml @@ -0,0 +1,27 @@ +# +# Wound EcoEnchant +# + +name: "Wound" +description: Causes your opponent to bleed, damaging them repeatedly. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 7 + +config: + chance-per-level: 3 #chance of bleeding per level + bleed-damage: 1 + amount-per-level: 1 # Bleed number per level diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/zeus.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/zeus.yml new file mode 100644 index 00000000..6f161795 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/zeus.yml @@ -0,0 +1,26 @@ +# +# Zeus EcoEnchant +# + +name: "Zeus" +description: Chance to strike lightning on your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 1 + lightning-damage: 2.5 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/aiming.yml b/eco-core/core-plugin/src/main/resources/enchants/special/aiming.yml new file mode 100644 index 00000000..6eac30c0 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/aiming.yml @@ -0,0 +1,28 @@ +# +# Aiming EcoEnchant +# + +name: "Aiming" +description: Arrows hone in on your target. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 5 + +config: + distance-per-level: 4 # Distance to scan per aiming level + scale-on-force: true # Scale distance based on bow pull + require-full-force: true # Require full bow pull (works with rapid) If true, then scale-on-force is irrelevant. + check-ticks: 10 # Ticks between rotations + checks-per-level: 2 # Amount of times to rotate arrow per level (prevents "floating") \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/annihilate.yml b/eco-core/core-plugin/src/main/resources/enchants/special/annihilate.yml new file mode 100644 index 00000000..0f726b99 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/annihilate.yml @@ -0,0 +1,28 @@ +# +# Annihilate EcoEnchant +# + +name: "Annihilate" +description: Extreme Knockback. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - knockback + - tornado + - grapple + maximum-level: 2 + +config: + velocity-multiplier: 2.5 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/bladed.yml b/eco-core/core-plugin/src/main/resources/enchants/special/bladed.yml new file mode 100644 index 00000000..fcb3c75e --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/bladed.yml @@ -0,0 +1,33 @@ +# +# Bladed EcoEnchant +# + +name: "Bladed" +description: Trident deals extreme additional damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: veryspecial + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - impaling + - serrated + - phantasm + - arachnid + - pacify + - abattoir + maximum-level: 5 + +config: + base-multiplier: 1.25 # Percent more damage to do as base + multiplier: 0.25 # 1 + (Level * Multiplier) is multiplied with the damage + # To explain, Bladed V would be 2.5x more damage: 1.25 + (5*0.25) + # By default, Bladed I acts like Serrated VI diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/bolt.yml b/eco-core/core-plugin/src/main/resources/enchants/special/bolt.yml new file mode 100644 index 00000000..aa10c171 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/bolt.yml @@ -0,0 +1,26 @@ +# +# Bolt EcoEnchant +# + +name: "Bolt" +description: Chance of striking powerful lightning on your opponent. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 4 + +config: + chance-per-level: 5 + allow-not-fully-charged: false # dont require sword attack to be at full charge + lightning-damage: 8 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/carve.yml b/eco-core/core-plugin/src/main/resources/enchants/special/carve.yml new file mode 100644 index 00000000..34b5e398 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/carve.yml @@ -0,0 +1,26 @@ +# +# Carve EcoEnchant +# + +name: "Carve" +description: Heavily damage all entities around attacked entity. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - cleave + maximum-level: 8 + +config: + damage-percentage-per-level: 10 + radius-per-level: 0.5 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/confusion.yml b/eco-core/core-plugin/src/main/resources/enchants/special/confusion.yml new file mode 100644 index 00000000..e3b4452a --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/confusion.yml @@ -0,0 +1,25 @@ +# +# Confusion EcoEnchant +# + +name: "Confusion" +description: Chance to shuffle your opponents hotbar. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 4 + +config: + chance-per-level: 2 #chance of shuffling opponents hotbar per level + allow-not-fully-charged: false #dont require sword attack to be at full charge \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/energizing.yml b/eco-core/core-plugin/src/main/resources/enchants/special/energizing.yml new file mode 100644 index 00000000..770d505a --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/energizing.yml @@ -0,0 +1,28 @@ +# +# Energizing EcoEnchant +# + +name: "Energizing" +description: Receive a short burst of haste after breaking a block. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - pickaxe + - axe + - shovel + - hoe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + ticks-per-level: 8 + initial-level: 2 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/force.yml b/eco-core/core-plugin/src/main/resources/enchants/special/force.yml new file mode 100644 index 00000000..60e83d98 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/force.yml @@ -0,0 +1,29 @@ +# +# Force EcoEnchant +# + +name: "Force" +description: Massively increases arrow damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: veryspecial + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - power + - revenant + - insecticide + - slaughter + - settle + maximum-level: 8 + +config: + multiplier: 0.25 # Formula is (multiplier * (level + 6) + 1)*damage | Default functions as power 5 + level, eg force 2 = power 7 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/frenzy.yml b/eco-core/core-plugin/src/main/resources/enchants/special/frenzy.yml new file mode 100644 index 00000000..f5909ba2 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/frenzy.yml @@ -0,0 +1,24 @@ +# +# Frenzy EcoEnchant +# + +name: "Frenzy" +description: Gives strength after killing an entity. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + seconds-per-level: 1.5 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/harpoon.yml b/eco-core/core-plugin/src/main/resources/enchants/special/harpoon.yml new file mode 100644 index 00000000..65951316 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/harpoon.yml @@ -0,0 +1,25 @@ +# +# Harpoon EcoEnchant +# + +name: "Harpoon" +description: Hooking onto an entity will heavily damage it. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - rod + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - spiked + maximum-level: 3 + +config: + damage-per-level: 2 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/indestructibility.yml b/eco-core/core-plugin/src/main/resources/enchants/special/indestructibility.yml new file mode 100644 index 00000000..982c4545 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/indestructibility.yml @@ -0,0 +1,25 @@ +# +# Indestructibility EcoEnchant +# + +name: "Indestructibility" +description: Massively increases item durability. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - all + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - unbreaking + maximum-level: 3 + +config: + level-bonus: 4 # Indestructiblity 1 is the same as unbreaking +level, ie: indestructibility 3 with bonus 4 is the same as unbreaking 7 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/instability.yml b/eco-core/core-plugin/src/main/resources/enchants/special/instability.yml new file mode 100644 index 00000000..ca53fac5 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/instability.yml @@ -0,0 +1,26 @@ +# +# Instability EcoEnchant +# + +name: "Instability" +description: Explosive arrows. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + fire: false + break-blocks: false \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/intellect.yml b/eco-core/core-plugin/src/main/resources/enchants/special/intellect.yml new file mode 100644 index 00000000..2d316fdc --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/intellect.yml @@ -0,0 +1,33 @@ +# +# Intellect EcoEnchant +# + +name: "Intellect" +description: Massively increases dropped experience. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - bow + - crossbow + - trident + - pickaxe + - axe + - shovel + - hoe + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - splash + - wisdom + maximum-level: 3 + +config: + bonus-per-point: 1.2 #Increase per level relative to base \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/lifesteal.yml b/eco-core/core-plugin/src/main/resources/enchants/special/lifesteal.yml new file mode 100644 index 00000000..cb757ad3 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/lifesteal.yml @@ -0,0 +1,27 @@ +# +# Life Steal EcoEnchant +# + +name: "Life Steal" +description: Heals a large portion of damage dealt. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - leeching + maximum-level: 3 + +config: + health-per-level: 2 # Level * Health = Amount of health to heal + allow-not-fully-charged: false diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/pentashot.yml b/eco-core/core-plugin/src/main/resources/enchants/special/pentashot.yml new file mode 100644 index 00000000..3982b1e1 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/pentashot.yml @@ -0,0 +1,28 @@ +# +# Pentashot EcoEnchant +# + +name: "Pentashot" +description: Shoots 5 arrows. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - bow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - succession + - tripleshot + - buckshot + maximum-level: 1 + +config: + side-arrows-per-level: 2 # If you want to have more levels + angle: 11 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/preservation.yml b/eco-core/core-plugin/src/main/resources/enchants/special/preservation.yml new file mode 100644 index 00000000..f6f9e640 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/preservation.yml @@ -0,0 +1,31 @@ +# +# Preservation EcoEnchant +# + +name: "Preservation" +description: Massively reduces incoming damage. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - protection + - fire_protection + - projectile_protection + - blast_protection + maximum-level: 4 + +config: + percent-less-per-level: 5 # Points * Percent less / 100 * damage = damage taken \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/prosperity.yml b/eco-core/core-plugin/src/main/resources/enchants/special/prosperity.yml new file mode 100644 index 00000000..ff8080c2 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/prosperity.yml @@ -0,0 +1,28 @@ +# +# Prosperity EcoEnchant +# + +name: "Prosperity" +description: Massively increases maximum health. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: veryspecial + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - thrive + maximum-level: 3 + +config: + health-per-point: 2 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/razor.yml b/eco-core/core-plugin/src/main/resources/enchants/special/razor.yml new file mode 100644 index 00000000..5106a7bc --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/razor.yml @@ -0,0 +1,33 @@ +# +# Razor EcoEnchant +# + +name: "Razor" +description: Massively increases damage dealt. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: veryspecial + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - sharpness + - smite + - bane_of_arthropods + - defusion + - butchering + - ender_slayer + - introversion + maximum-level: 8 + +config: + multiplier: 0.5 # Vanilla sharpness is 0.5*level + 0.5 extra damage. Razor formula is multiplier*level + base extra damage. + base-damage: 10 # Vanilla Smite 5/BOA 5 extra damage is 12.5 + decrease-if-cooldown: true \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/repairing.yml b/eco-core/core-plugin/src/main/resources/enchants/special/repairing.yml new file mode 100644 index 00000000..338a6356 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/repairing.yml @@ -0,0 +1,27 @@ +# +# Repairing EcoEnchant +# + +name: "Repairing" +description: Automatically repairs items when not held. +enabled: true + +obtaining: + table: false + villager: true + loot: true + rarity: veryspecial + +general-config: + targets: + - all + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - mending + - decay_curse + maximum-level: 3 + +config: + repeat-ticks: 100 # How often (in ticks) to repair items + multiplier: 1 # Amount to repair = multiplier * level. Does not accept decimals \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/soulbound.yml b/eco-core/core-plugin/src/main/resources/enchants/special/soulbound.yml new file mode 100644 index 00000000..bf38f4c2 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/soulbound.yml @@ -0,0 +1,23 @@ +# +# Soulbound EcoEnchant +# + +name: "Soulbound" +description: Keep this item on death. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - all + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + +config: + remove-after: false # If soulbound should be 1-time use \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/spring.yml b/eco-core/core-plugin/src/main/resources/enchants/special/spring.yml new file mode 100644 index 00000000..9058f5d6 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/spring.yml @@ -0,0 +1,24 @@ +# +# Spring EcoEnchant +# + +name: "Spring" +description: Increases jump height and distance. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: +# No config is available for this enchantment \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/streamlining.yml b/eco-core/core-plugin/src/main/resources/enchants/special/streamlining.yml new file mode 100644 index 00000000..8041ee40 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/streamlining.yml @@ -0,0 +1,24 @@ +# +# Streamlining EcoEnchant +# + +name: "Streamlining" +description: Increases movement speed. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 8 + +config: + speed-per-level: 0.02 # Base is 0.2 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/volatile.yml b/eco-core/core-plugin/src/main/resources/enchants/special/volatile.yml new file mode 100644 index 00000000..c2aff0b5 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/special/volatile.yml @@ -0,0 +1,27 @@ +# +# Volatile EcoEnchant +# + +name: "Volatile" +description: Explosive sword attacks. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + fire: false + break-blocks: false + allow-not-fully-charged: false + chance-per-level: 5 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/spell/ascend.yml b/eco-core/core-plugin/src/main/resources/enchants/spell/ascend.yml new file mode 100644 index 00000000..8f48c5b5 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/spell/ascend.yml @@ -0,0 +1,27 @@ +# +# Ascend EcoEnchant +# + +name: "Ascend" +description: Levitates you into the air +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + activation-sound: ENTITY_FIREWORK_ROCKET_LARGE_BLAST + cooldown: 90 # In seconds + power: 25 # Level of levitation to give + ticks-per-level: 6 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/spell/charge.yml b/eco-core/core-plugin/src/main/resources/enchants/spell/charge.yml new file mode 100644 index 00000000..4d348186 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/spell/charge.yml @@ -0,0 +1,26 @@ +# +# Charge EcoEnchant +# + +name: "Charge" +description: Launches you in the direction you're looking. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + activation-sound: ENTITY_FIREWORK_ROCKET_LAUNCH + cooldown: 40 # In seconds + velocity-per-level: 1.5 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/spell/dynamite.yml b/eco-core/core-plugin/src/main/resources/enchants/spell/dynamite.yml new file mode 100644 index 00000000..cfcdea22 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/spell/dynamite.yml @@ -0,0 +1,30 @@ +# +# Dynamite EcoEnchant +# + +name: "Dynamite" +description: Mines blocks in a large area. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - pickaxe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: + activation-sound: ENTITY_DRAGON_FIREBALL_EXPLODE + cooldown: 60 # In seconds + hardness-check: true # Only break blocks with hardness less than or equal to first block + blacklisted-blocks: + - bedrock + base-bonus: 2 # Base extra blocks on all sides to break (1 = 3x3x3, 2 = 5x5x5, 3 = 7x7x7) + per-level-bonus: 1 # Extra blocks on all sides per level \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/spell/missile.yml b/eco-core/core-plugin/src/main/resources/enchants/spell/missile.yml new file mode 100644 index 00000000..c1a2d630 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/spell/missile.yml @@ -0,0 +1,28 @@ +# +# Missile EcoEnchant +# + +name: "Missile" +description: Shoots a wither skull +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + - axe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + activation-sound: ENTITY_WITHER_SHOOT + cooldown: 40 # In seconds + velocity: 3 + damage-per-level: 8 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/spell/quake.yml b/eco-core/core-plugin/src/main/resources/enchants/spell/quake.yml new file mode 100644 index 00000000..50182bb1 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/spell/quake.yml @@ -0,0 +1,27 @@ +# +# Quake EcoEnchant +# + +name: "Quake" +description: Damages all nearby entities +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + activation-sound: ENTITY_ENDER_DRAGON_GROWL + cooldown: 40 # In seconds + damage-per-level: 3 + radius-per-level: 2 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/spell/vitalize.yml b/eco-core/core-plugin/src/main/resources/enchants/spell/vitalize.yml new file mode 100644 index 00000000..b779035f --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/enchants/spell/vitalize.yml @@ -0,0 +1,28 @@ +# +# Vitalize EcoEnchant +# + +name: "Vitalize" +description: Puts you back on max health +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - sword + - axe + - pickaxe + - shovel + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 1 + +config: + activation-sound: ENTITY_PLAYER_LEVELUP + cooldown: 450 # In seconds \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/rarity.yml b/eco-core/core-plugin/src/main/resources/rarity.yml new file mode 100644 index 00000000..a43a739f --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/rarity.yml @@ -0,0 +1,68 @@ +rarities: + # Table Probability is the chance of getting enchantment as a percentage from an enchanting table + # Minimum Level is the minimum xp level you have to be to get the enchantment + # You can add more rarities by following the pattern. + # Remember, enchantments are more likely to be high-level the closer they are to maximum-obtainable-level + # Villager probability is the chance of a villager having this trade as a percentage. Vanilla default for all enchantments is 2.7%, however you can choose this per-rarity. + # Loot probability is the chance of an item in a loot chest having this enchantment as a percentage + + # Custom Color is a custom name color for all enchantments of rarity to have + # This is disabled by default. + # Curses override this, and always display in their specified color. + + common: + table-probability: 30 + minimum-level: 1 + villager-probability: 10.5 + loot-probability: 12 + custom-color: + enabled: false + color: "&7" + uncommon: + table-probability: 20 + minimum-level: 5 + villager-probability: 9 + loot-probability: 16 + custom-color: + enabled: false + color: "&a" + rare: + table-probability: 20 + minimum-level: 15 + villager-probability: 7.5 + loot-probability: 18 + custom-color: + enabled: false + color: "&9" + epic: + table-probability: 10 + minimum-level: 16 + villager-probability: 6 + loot-probability: 20 + custom-color: + enabled: false + color: "&5" + legendary: + table-probability: 8 + minimum-level: 20 + villager-probability: 4.5 + loot-probability: 15 + custom-color: + enabled: false + color: "&6" + special: + table-probability: 2 + minimum-level: 30 + villager-probability: 3 + loot-probability: 5 + custom-color: + enabled: false + color: "&d" + veryspecial: + table-probability: 1 + minimum-level: 30 + villager-probability: 1.5 + loot-probability: 2 + custom-color: + enabled: false + color: "&4" \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/target.yml b/eco-core/core-plugin/src/main/resources/target.yml new file mode 100644 index 00000000..e016b622 --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/target.yml @@ -0,0 +1,104 @@ +targets: + axe: + - wooden_axe + - stone_axe + - iron_axe + - golden_axe + - diamond_axe + - netherite_axe + + book: + - book + - enchanted_book + + pickaxe: + - wooden_pickaxe + - stone_pickaxe + - iron_pickaxe + - golden_pickaxe + - diamond_pickaxe + - netherite_pickaxe + + hoe: + - wooden_hoe + - stone_hoe + - iron_hoe + - golden_hoe + - diamond_hoe + - netherite_hoe + + shovel: + - wooden_shovel + - stone_shovel + - iron_shovel + - golden_shovel + - diamond_shovel + - netherite_shovel + + sword: + - wooden_sword + - stone_sword + - iron_sword + - golden_sword + - diamond_sword + - netherite_sword + + helmet: + - turtle_helmet + - leather_helmet + - chainmail_helmet + - iron_helmet + - golden_helmet + - diamond_helmet + - netherite_helmet + + chestplate: + - leather_chestplate + - chainmail_chestplate + - iron_chestplate + - golden_chestplate + - diamond_chestplate + - netherite_chestplate + + leggings: + - leather_leggings + - chainmail_leggings + - iron_leggings + - golden_leggings + - diamond_leggings + - netherite_leggings + + boots: + - leather_boots + - chainmail_boots + - iron_boots + - golden_boots + - diamond_boots + - netherite_boots + + elytra: + - elytra + + bow: + - bow + + crossbow: + - crossbow + + shears: + - shears + + trident: + - trident + + shield: + - shield + + rod: + - fishing_rod + + flintandsteel: + - flint_and_steel + + carrot_stick: + - carrot_on_a_stick diff --git a/eco-core/core-proxy/build.gradle b/eco-core/core-proxy/build.gradle new file mode 100644 index 00000000..3f90b631 --- /dev/null +++ b/eco-core/core-proxy/build.gradle @@ -0,0 +1,6 @@ +group 'com.willfp' +version rootProject.version + +dependencies { + compileOnly 'org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT' +} \ No newline at end of file diff --git a/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/FastGetEnchantsProxy.java b/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/FastGetEnchantsProxy.java new file mode 100644 index 00000000..2963cb10 --- /dev/null +++ b/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/FastGetEnchantsProxy.java @@ -0,0 +1,28 @@ +package com.willfp.ecoenchants.proxy.proxies; + +import com.willfp.eco.core.proxy.AbstractProxy; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; + +public interface FastGetEnchantsProxy extends AbstractProxy { + /** + * Get all enchantments on an {@link ItemStack}. + * + * @param itemStack The item to query. + * @return A map of all enchantments, where the value represents the level present. + */ + Map getEnchantmentsOnItem(@NotNull ItemStack itemStack); + + /** + * Get the level of a specified enchantment on an item. + * + * @param itemStack The item to query. + * @param enchantment The enchantment to query. + * @return The level found, or 0 if not present. + */ + int getLevelOnItem(@NotNull ItemStack itemStack, + @NotNull Enchantment enchantment); +} diff --git a/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/OpenInventoryProxy.java b/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/OpenInventoryProxy.java new file mode 100644 index 00000000..bfbe404a --- /dev/null +++ b/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/OpenInventoryProxy.java @@ -0,0 +1,15 @@ +package com.willfp.ecoenchants.proxy.proxies; + +import com.willfp.eco.core.proxy.AbstractProxy; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public interface OpenInventoryProxy extends AbstractProxy { + /** + * Get the NMS inventory container for a player's inventory view. + * + * @param player The player to query. + * @return The NMS inventory container. + */ + Object getOpenInventory(@NotNull Player player); +} diff --git a/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/RepairCostProxy.java b/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/RepairCostProxy.java new file mode 100644 index 00000000..98821b08 --- /dev/null +++ b/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/RepairCostProxy.java @@ -0,0 +1,25 @@ +package com.willfp.ecoenchants.proxy.proxies; + +import com.willfp.eco.core.proxy.AbstractProxy; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public interface RepairCostProxy extends AbstractProxy { + /** + * Set the rework penalty of an item. + * + * @param itemStack The item to query. + * @param cost The rework penalty to set. + * @return The item, with the rework penalty applied. + */ + ItemStack setRepairCost(@NotNull ItemStack itemStack, + int cost); + + /** + * Get the rework penalty of an item. + * + * @param itemStack The item to query. + * @return The rework penalty found on the item. + */ + int getRepairCost(@NotNull ItemStack itemStack); +} diff --git a/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/util/ProxyFactory.java b/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/util/ProxyFactory.java new file mode 100644 index 00000000..d8434e99 --- /dev/null +++ b/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/util/ProxyFactory.java @@ -0,0 +1,75 @@ +package com.willfp.ecoenchants.proxy.util; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.eco.core.proxy.AbstractProxy; +import com.willfp.eco.core.proxy.ProxyConstants; +import com.willfp.eco.core.proxy.UnsupportedVersionException; +import org.jetbrains.annotations.NotNull; + +import java.util.IdentityHashMap; +import java.util.Map; + +public class ProxyFactory extends PluginDependent { + /** + * Cached proxy implementations in order to not perform expensive reflective class-finding. + */ + private static final Map, AbstractProxy> CACHE = new IdentityHashMap<>(); + + /** + * The class of the proxy interface. + */ + private final Class proxyClass; + + /** + * Create a new Proxy Factory for a specific type. + * + * @param plugin The plugin to create proxies for. + * @param proxyClass The class of the proxy interface. + */ + public ProxyFactory(@NotNull final EcoPlugin plugin, + @NotNull final Class proxyClass) { + super(plugin); + this.proxyClass = proxyClass; + } + + /** + * Get the implementation of a proxy. + * + * @return The proxy implementation. + */ + public @NotNull T getProxy() { + try { + T cachedProxy = attemptCache(); + if (cachedProxy != null) { + return cachedProxy; + } + + String className = this.getPlugin().getProxyPackage() + "." + ProxyConstants.NMS_VERSION + "." + proxyClass.getSimpleName().replace("Proxy", ""); + final Class class2 = Class.forName(className); + Object instance = class2.getConstructor().newInstance(); + if (proxyClass.isAssignableFrom(class2) && proxyClass.isInstance(instance)) { + T proxy = proxyClass.cast(instance); + CACHE.put(proxyClass, proxy); + return proxy; + } + } catch (Exception e) { + // If not returned, then throw error + } + + throw new UnsupportedVersionException("You're running an unsupported server version: " + ProxyConstants.NMS_VERSION); + } + + private T attemptCache() { + Object proxy = CACHE.get(proxyClass); + if (proxy == null) { + return null; + } + + if (proxyClass.isInstance(proxy)) { + return proxyClass.cast(proxy); + } + + return null; + } +} diff --git a/eco-extensions/alchemy/build.gradle b/eco-extensions/alchemy/build.gradle new file mode 100644 index 00000000..68da73c8 --- /dev/null +++ b/eco-extensions/alchemy/build.gradle @@ -0,0 +1,7 @@ +group 'com.willfp' +version '5.0.0' +description = 'Alchemy Extension' + +shadowJar { + archiveFileName = project.getDescription() + " v" + project.version + ".jar" +} \ No newline at end of file diff --git a/eco-extensions/alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java b/eco-extensions/alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java new file mode 100644 index 00000000..814587cc --- /dev/null +++ b/eco-extensions/alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java @@ -0,0 +1,79 @@ +package com.willfp.ecoenchants.alchemy; + + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityPotionEffectEvent; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.PotionEffect; +import org.jetbrains.annotations.NotNull; + +public class Alchemy extends EcoEnchant { + /** + * true Metadata key. + */ + private final FixedMetadataValue metaKeyTrue = this.getPlugin().getMetadataValueFactory().create(true); + + /** + * Instantiate Alchemy Enchantment. + */ + public Alchemy() { + super("alchemy", EnchantmentType.NORMAL); + } + + /** + * Enchantment functionality. + * + * @param event The event to listen for. + */ + @EventHandler + public void onPotionEffect(@NotNull final EntityPotionEffectEvent event) { + if (event.getNewEffect() == null) { + return; + } + if (!(event.getEntity() instanceof LivingEntity)) { + return; + } + + LivingEntity entity = (LivingEntity) event.getEntity(); + + if (entity.hasMetadata(event.getNewEffect().toString())) { + return; + } + + int level = EnchantChecks.getArmorPoints(entity, this); + if (level == 0) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + if (this.getDisabledWorlds().contains(entity.getWorld())) { + return; + } + + PotionEffect effect = event.getNewEffect(); + + PotionEffect newEffect = new PotionEffect( + effect.getType(), + effect.getDuration(), + ((effect.getAmplifier() + 1) * 2) - 1, + effect.isAmbient(), + effect.hasParticles(), + effect.hasIcon() + ); + + entity.setMetadata(newEffect.toString(), metaKeyTrue); + + entity.removePotionEffect(effect.getType()); + + this.getPlugin().getScheduler().run(() -> newEffect.apply(entity)); + + this.getPlugin().getScheduler().runLater(() -> entity.removeMetadata(newEffect.toString(), this.getPlugin()), 1); + } +} diff --git a/eco-extensions/alchemy/src/main/java/com/willfp/ecoenchants/alchemy/AlchemyMain.java b/eco-extensions/alchemy/src/main/java/com/willfp/ecoenchants/alchemy/AlchemyMain.java new file mode 100644 index 00000000..618131d1 --- /dev/null +++ b/eco-extensions/alchemy/src/main/java/com/willfp/ecoenchants/alchemy/AlchemyMain.java @@ -0,0 +1,27 @@ +package com.willfp.ecoenchants.alchemy; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.extensions.Extension; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import org.jetbrains.annotations.NotNull; + +public class AlchemyMain extends Extension { + /** + * Alchemy enchantment. + */ + public static final EcoEnchant ALCHEMY = new Alchemy(); + + public AlchemyMain(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void onEnable() { + // Handled by super + } + + @Override + public void onDisable() { + // Handled by super + } +} diff --git a/eco-extensions/alchemy/src/main/resources/enchants/normal/alchemy.yml b/eco-extensions/alchemy/src/main/resources/enchants/normal/alchemy.yml new file mode 100644 index 00000000..9897e632 --- /dev/null +++ b/eco-extensions/alchemy/src/main/resources/enchants/normal/alchemy.yml @@ -0,0 +1,27 @@ +# +# Alchemy EcoEnchant +# + +name: "Alchemy" +description: Chance to double the strength of potions +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 6 + +config: + chance-per-level: 4 \ No newline at end of file diff --git a/eco-extensions/alchemy/src/main/resources/extension.yml b/eco-extensions/alchemy/src/main/resources/extension.yml new file mode 100644 index 00000000..1841ccf3 --- /dev/null +++ b/eco-extensions/alchemy/src/main/resources/extension.yml @@ -0,0 +1,3 @@ +name: Alchemy +main: com.willfp.ecoenchants.alchemy.AlchemyMain +version: ${projectVersion} \ No newline at end of file diff --git a/eco-extensions/biomes/build.gradle b/eco-extensions/biomes/build.gradle new file mode 100644 index 00000000..92604536 --- /dev/null +++ b/eco-extensions/biomes/build.gradle @@ -0,0 +1,7 @@ +group 'com.willfp' +version '5.0.0' +description = 'Biomes Extension' + +shadowJar { + archiveFileName = project.getDescription() + " v" + project.version + ".jar" +} \ No newline at end of file diff --git a/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/BiomesEnchantment.java b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/BiomesEnchantment.java new file mode 100644 index 00000000..66b239ee --- /dev/null +++ b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/BiomesEnchantment.java @@ -0,0 +1,84 @@ +package com.willfp.ecoenchants.biomes; + +import com.willfp.eco.core.Prerequisite; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Biome; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Trident; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.jetbrains.annotations.NotNull; + +public abstract class BiomesEnchantment extends EcoEnchant { + private static final String MULTIPLIER_KEY = "multiplier"; + + protected BiomesEnchantment(@NotNull final String key, + @NotNull final EnchantmentType type, + @NotNull final Prerequisite... prerequisites) { + super(key, type, prerequisites); + } + + public abstract boolean isValid(@NotNull Biome biome); + + private boolean isInBiome(@NotNull final LivingEntity entity) { + Biome entityBiome = entity.getLocation().getBlock().getBiome(); + return isValid(entityBiome); + } + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!isInBiome(attacker)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + MULTIPLIER_KEY); + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } + + @Override + public void onDamageWearingArmor(@NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageEvent event) { + if (!isInBiome(victim)) { + return; + } + + double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "reduction-per-level"); + double multiplier = 1 - ((reduction / 100) * level); + event.setDamage(event.getDamage() * multiplier); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!isInBiome(attacker)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + MULTIPLIER_KEY); + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!isInBiome(attacker)) { + return; + } + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + MULTIPLIER_KEY); + event.setDamage(event.getDamage() * (1 + (level * multiplier))); + } +} diff --git a/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/BiomesMain.java b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/BiomesMain.java new file mode 100644 index 00000000..2449800d --- /dev/null +++ b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/BiomesMain.java @@ -0,0 +1,43 @@ +package com.willfp.ecoenchants.biomes; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.extensions.Extension; +import com.willfp.ecoenchants.biomes.enchants.defensive.Elevation; +import com.willfp.ecoenchants.biomes.enchants.defensive.Glacial; +import com.willfp.ecoenchants.biomes.enchants.defensive.HeatTreated; +import com.willfp.ecoenchants.biomes.enchants.defensive.Oceanic; +import com.willfp.ecoenchants.biomes.enchants.defensive.Tropical; +import com.willfp.ecoenchants.biomes.enchants.offensive.Altitude; +import com.willfp.ecoenchants.biomes.enchants.offensive.Aquamarine; +import com.willfp.ecoenchants.biomes.enchants.offensive.Dehydration; +import com.willfp.ecoenchants.biomes.enchants.offensive.Icelord; +import com.willfp.ecoenchants.biomes.enchants.offensive.Rainforest; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import org.jetbrains.annotations.NotNull; + +public class BiomesMain extends Extension { + public static final EcoEnchant ELEVATION = new Elevation(); + public static final EcoEnchant GLACIAL = new Glacial(); + public static final EcoEnchant HEAT_TREATED = new HeatTreated(); + public static final EcoEnchant OCEANIC = new Oceanic(); + public static final EcoEnchant TROPICAL = new Tropical(); + public static final EcoEnchant ALTITUDE = new Altitude(); + public static final EcoEnchant AQUAMARINE = new Aquamarine(); + public static final EcoEnchant DEHYDRATION = new Dehydration(); + public static final EcoEnchant ICELORD = new Icelord(); + public static final EcoEnchant RAINFOREST = new Rainforest(); + + public BiomesMain(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void onEnable() { + // Handled by super + } + + @Override + public void onDisable() { + // Handled by super + } +} diff --git a/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Elevation.java b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Elevation.java new file mode 100644 index 00000000..93a19546 --- /dev/null +++ b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Elevation.java @@ -0,0 +1,20 @@ +package com.willfp.ecoenchants.biomes.enchants.defensive; + + +import com.willfp.ecoenchants.biomes.BiomesEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Biome; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; + +public class Elevation extends BiomesEnchantment { + public Elevation() { + super("elevation", EnchantmentType.NORMAL); + } + + @Override + public boolean isValid(@NotNull final Biome biome) { + return Arrays.stream(new String[]{"mountain", "hill"}).anyMatch(biome.name().toLowerCase()::contains); + } +} diff --git a/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Glacial.java b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Glacial.java new file mode 100644 index 00000000..e098c54a --- /dev/null +++ b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Glacial.java @@ -0,0 +1,20 @@ +package com.willfp.ecoenchants.biomes.enchants.defensive; + + +import com.willfp.ecoenchants.biomes.BiomesEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Biome; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; + +public class Glacial extends BiomesEnchantment { + public Glacial() { + super("glacial", EnchantmentType.NORMAL); + } + + @Override + public boolean isValid(@NotNull final Biome biome) { + return Arrays.stream(new String[]{"snowy", "ice", "frozen"}).anyMatch(biome.name().toLowerCase()::contains); + } +} diff --git a/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/HeatTreated.java b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/HeatTreated.java new file mode 100644 index 00000000..d5124e9b --- /dev/null +++ b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/HeatTreated.java @@ -0,0 +1,20 @@ +package com.willfp.ecoenchants.biomes.enchants.defensive; + + +import com.willfp.ecoenchants.biomes.BiomesEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Biome; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; + +public class HeatTreated extends BiomesEnchantment { + public HeatTreated() { + super("heat_treated", EnchantmentType.NORMAL); + } + + @Override + public boolean isValid(@NotNull final Biome biome) { + return Arrays.stream(new String[]{"desert", "badlands", "savanna"}).anyMatch(biome.name().toLowerCase()::contains); + } +} diff --git a/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Oceanic.java b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Oceanic.java new file mode 100644 index 00000000..5e7dd109 --- /dev/null +++ b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Oceanic.java @@ -0,0 +1,20 @@ +package com.willfp.ecoenchants.biomes.enchants.defensive; + + +import com.willfp.ecoenchants.biomes.BiomesEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Biome; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; + +public class Oceanic extends BiomesEnchantment { + public Oceanic() { + super("oceanic", EnchantmentType.NORMAL); + } + + @Override + public boolean isValid(@NotNull final Biome biome) { + return Arrays.stream(new String[]{"ocean"}).anyMatch(biome.name().toLowerCase()::contains); + } +} diff --git a/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Tropical.java b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Tropical.java new file mode 100644 index 00000000..09772f6c --- /dev/null +++ b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/defensive/Tropical.java @@ -0,0 +1,20 @@ +package com.willfp.ecoenchants.biomes.enchants.defensive; + + +import com.willfp.ecoenchants.biomes.BiomesEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Biome; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; + +public class Tropical extends BiomesEnchantment { + public Tropical() { + super("tropical", EnchantmentType.NORMAL); + } + + @Override + public boolean isValid(@NotNull final Biome biome) { + return Arrays.stream(new String[]{"jungle"}).anyMatch(biome.name().toLowerCase()::contains); + } +} diff --git a/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Altitude.java b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Altitude.java new file mode 100644 index 00000000..6f7e5de1 --- /dev/null +++ b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Altitude.java @@ -0,0 +1,22 @@ +package com.willfp.ecoenchants.biomes.enchants.offensive; + +import com.willfp.ecoenchants.biomes.BiomesEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Biome; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; + +public class Altitude extends BiomesEnchantment { + /** + * Instantiate enchantment. + */ + public Altitude() { + super("altitude", EnchantmentType.NORMAL); + } + + @Override + public boolean isValid(@NotNull final Biome biome) { + return Arrays.stream(new String[]{"mountain", "hill"}).anyMatch(biome.name().toLowerCase()::contains); + } +} diff --git a/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Aquamarine.java b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Aquamarine.java new file mode 100644 index 00000000..c70ac50f --- /dev/null +++ b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Aquamarine.java @@ -0,0 +1,22 @@ +package com.willfp.ecoenchants.biomes.enchants.offensive; + +import com.willfp.ecoenchants.biomes.BiomesEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Biome; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; + +public class Aquamarine extends BiomesEnchantment { + /** + * Instantiate enchantment. + */ + public Aquamarine() { + super("aquamarine", EnchantmentType.NORMAL); + } + + @Override + public boolean isValid(@NotNull final Biome biome) { + return Arrays.stream(new String[]{"ocean"}).anyMatch(biome.name().toLowerCase()::contains); + } +} diff --git a/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Dehydration.java b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Dehydration.java new file mode 100644 index 00000000..3a788e38 --- /dev/null +++ b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Dehydration.java @@ -0,0 +1,19 @@ +package com.willfp.ecoenchants.biomes.enchants.offensive; + +import com.willfp.ecoenchants.biomes.BiomesEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Biome; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; + +public class Dehydration extends BiomesEnchantment { + public Dehydration() { + super("dehydration", EnchantmentType.NORMAL); + } + + @Override + public boolean isValid(@NotNull final Biome biome) { + return Arrays.stream(new String[]{"desert", "badlands", "savanna"}).anyMatch(biome.name().toLowerCase()::contains); + } +} diff --git a/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Icelord.java b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Icelord.java new file mode 100644 index 00000000..ae29de91 --- /dev/null +++ b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Icelord.java @@ -0,0 +1,19 @@ +package com.willfp.ecoenchants.biomes.enchants.offensive; + +import com.willfp.ecoenchants.biomes.BiomesEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Biome; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; + +public class Icelord extends BiomesEnchantment { + public Icelord() { + super("icelord", EnchantmentType.NORMAL); + } + + @Override + public boolean isValid(@NotNull final Biome biome) { + return Arrays.stream(new String[]{"snowy", "ice", "frozen"}).anyMatch(biome.name().toLowerCase()::contains); + } +} diff --git a/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Rainforest.java b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Rainforest.java new file mode 100644 index 00000000..12439d1c --- /dev/null +++ b/eco-extensions/biomes/src/main/java/com/willfp/ecoenchants/biomes/enchants/offensive/Rainforest.java @@ -0,0 +1,19 @@ +package com.willfp.ecoenchants.biomes.enchants.offensive; + +import com.willfp.ecoenchants.biomes.BiomesEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.block.Biome; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; + +public class Rainforest extends BiomesEnchantment { + public Rainforest() { + super("rainforest", EnchantmentType.NORMAL); + } + + @Override + public boolean isValid(@NotNull final Biome biome) { + return Arrays.stream(new String[]{"jungle"}).anyMatch(biome.name().toLowerCase()::contains); + } +} diff --git a/eco-extensions/biomes/src/main/resources/enchants/normal/altitude.yml b/eco-extensions/biomes/src/main/resources/enchants/normal/altitude.yml new file mode 100644 index 00000000..ea38af7c --- /dev/null +++ b/eco-extensions/biomes/src/main/resources/enchants/normal/altitude.yml @@ -0,0 +1,32 @@ +# +# Altitude EcoEnchant +# + +name: "Altitude" +description: Deal more damage in hilly biomes. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - bow + - crossbow + - sword + - axe + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - aquamarine + - dehydration + - icelord + - rainforest + maximum-level: 6 + +config: + multiplier: 0.03 \ No newline at end of file diff --git a/eco-extensions/biomes/src/main/resources/enchants/normal/aquamarine.yml b/eco-extensions/biomes/src/main/resources/enchants/normal/aquamarine.yml new file mode 100644 index 00000000..1617e71f --- /dev/null +++ b/eco-extensions/biomes/src/main/resources/enchants/normal/aquamarine.yml @@ -0,0 +1,32 @@ +# +# Aquamarine EcoEnchant +# + +name: "Aquamarine" +description: Deal more damage in oceans. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - bow + - crossbow + - sword + - axe + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - altitude + - dehydration + - icelord + - rainforest + maximum-level: 6 + +config: + multiplier: 0.03 \ No newline at end of file diff --git a/eco-extensions/biomes/src/main/resources/enchants/normal/dehydration.yml b/eco-extensions/biomes/src/main/resources/enchants/normal/dehydration.yml new file mode 100644 index 00000000..1d9ccbbd --- /dev/null +++ b/eco-extensions/biomes/src/main/resources/enchants/normal/dehydration.yml @@ -0,0 +1,32 @@ +# +# Dehydration EcoEnchant +# + +name: "Dehydration" +description: Deal more damage in hot biomes. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - bow + - crossbow + - sword + - axe + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - altitude + - aquamarine + - icelord + - rainforest + maximum-level: 6 + +config: + multiplier: 0.03 \ No newline at end of file diff --git a/eco-extensions/biomes/src/main/resources/enchants/normal/elevation.yml b/eco-extensions/biomes/src/main/resources/enchants/normal/elevation.yml new file mode 100644 index 00000000..6ec6c030 --- /dev/null +++ b/eco-extensions/biomes/src/main/resources/enchants/normal/elevation.yml @@ -0,0 +1,31 @@ +# +# Elevation EcoEnchant +# + +name: "Elevation" +description: Take less damage in hilly biomes. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - glacial + - heat_treated + - oceanic + - tropical + maximum-level: 3 + +config: + reduction-per-level: 2 # As percentage \ No newline at end of file diff --git a/eco-extensions/biomes/src/main/resources/enchants/normal/glacial.yml b/eco-extensions/biomes/src/main/resources/enchants/normal/glacial.yml new file mode 100644 index 00000000..b036d84f --- /dev/null +++ b/eco-extensions/biomes/src/main/resources/enchants/normal/glacial.yml @@ -0,0 +1,31 @@ +# +# Glacial EcoEnchant +# + +name: "Glacial" +description: Take less damage in cold biomes. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - elevation + - heat_treated + - oceanic + - tropical + maximum-level: 3 + +config: + reduction-per-level: 2 # As percentage \ No newline at end of file diff --git a/eco-extensions/biomes/src/main/resources/enchants/normal/heattreated.yml b/eco-extensions/biomes/src/main/resources/enchants/normal/heattreated.yml new file mode 100644 index 00000000..8b0cc4c2 --- /dev/null +++ b/eco-extensions/biomes/src/main/resources/enchants/normal/heattreated.yml @@ -0,0 +1,31 @@ +# +# Heat Treated EcoEnchant +# + +name: "Heat Treated" +description: Take less damage in hot biomes. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - elevation + - glacial + - oceanic + - tropical + maximum-level: 3 + +config: + reduction-per-level: 2 # As percentage \ No newline at end of file diff --git a/eco-extensions/biomes/src/main/resources/enchants/normal/icelord.yml b/eco-extensions/biomes/src/main/resources/enchants/normal/icelord.yml new file mode 100644 index 00000000..669ab4c3 --- /dev/null +++ b/eco-extensions/biomes/src/main/resources/enchants/normal/icelord.yml @@ -0,0 +1,32 @@ +# +# Icelord EcoEnchant +# + +name: "Icelord" +description: Deal more damage in cold biomes. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - bow + - crossbow + - sword + - axe + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - altitide + - aquamarine + - dehydration + - rainforest + maximum-level: 6 + +config: + multiplier: 0.03 \ No newline at end of file diff --git a/eco-extensions/biomes/src/main/resources/enchants/normal/oceanic.yml b/eco-extensions/biomes/src/main/resources/enchants/normal/oceanic.yml new file mode 100644 index 00000000..ffba2b9f --- /dev/null +++ b/eco-extensions/biomes/src/main/resources/enchants/normal/oceanic.yml @@ -0,0 +1,31 @@ +# +# Oceanic EcoEnchant +# + +name: "Oceanic" +description: Take less damage in oceans. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - elevation + - glacial + - heat_treated + - tropical + maximum-level: 3 + +config: + reduction-per-level: 2 # As percentage \ No newline at end of file diff --git a/eco-extensions/biomes/src/main/resources/enchants/normal/rainforest.yml b/eco-extensions/biomes/src/main/resources/enchants/normal/rainforest.yml new file mode 100644 index 00000000..8e299bbb --- /dev/null +++ b/eco-extensions/biomes/src/main/resources/enchants/normal/rainforest.yml @@ -0,0 +1,32 @@ +# +# Rainforest EcoEnchant +# + +name: "Rainforest" +description: Deal more damage in jungles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - bow + - crossbow + - sword + - axe + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - altitude + - aquamarine + - dehydration + - icelord + maximum-level: 6 + +config: + multiplier: 0.03 \ No newline at end of file diff --git a/eco-extensions/biomes/src/main/resources/enchants/normal/tropical.yml b/eco-extensions/biomes/src/main/resources/enchants/normal/tropical.yml new file mode 100644 index 00000000..71431756 --- /dev/null +++ b/eco-extensions/biomes/src/main/resources/enchants/normal/tropical.yml @@ -0,0 +1,31 @@ +# +# Tropical EcoEnchant +# + +name: "Tropical" +description: Take less damage in jungles. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - elevation + - glacial + - heat_treated + - oceanic + maximum-level: 3 + +config: + reduction-per-level: 2 # As percentage \ No newline at end of file diff --git a/eco-extensions/biomes/src/main/resources/extension.yml b/eco-extensions/biomes/src/main/resources/extension.yml new file mode 100644 index 00000000..2bc26774 --- /dev/null +++ b/eco-extensions/biomes/src/main/resources/extension.yml @@ -0,0 +1,3 @@ +name: Biomes +main: com.willfp.ecoenchants.biomes.BiomesMain +version: ${projectVersion} \ No newline at end of file diff --git a/eco-extensions/build.gradle b/eco-extensions/build.gradle new file mode 100644 index 00000000..8437aeaf --- /dev/null +++ b/eco-extensions/build.gradle @@ -0,0 +1,16 @@ +group 'com.willfp' +description = 'Extension Parent' + +subprojects { + dependencies { + compileOnly project(":eco-core:core-plugin") + compileOnly project(":eco-core:core-proxy") + compileOnly 'org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT' + } + + tasks.withType(Jar) { + destinationDirectory = file("$rootDir/bin/") + } + + tasks.jar.enabled = false +} \ No newline at end of file diff --git a/eco-extensions/effects/build.gradle b/eco-extensions/effects/build.gradle new file mode 100644 index 00000000..b5891acc --- /dev/null +++ b/eco-extensions/effects/build.gradle @@ -0,0 +1,7 @@ +group 'com.willfp' +version '5.0.0' +description = 'Effects Extension' + +shadowJar { + archiveFileName = project.getDescription() + " v" + project.version + ".jar" +} \ No newline at end of file diff --git a/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/EffectsEnchantment.java b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/EffectsEnchantment.java new file mode 100644 index 00000000..4e55d6d0 --- /dev/null +++ b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/EffectsEnchantment.java @@ -0,0 +1,41 @@ +package com.willfp.ecoenchants.effects; + +import com.willfp.eco.core.Prerequisite; +import com.willfp.eco.core.events.ArmorEquipEvent; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +public abstract class EffectsEnchantment extends EcoEnchant { + protected EffectsEnchantment(@NotNull final String key, + @NotNull final EnchantmentType type, + @NotNull final Prerequisite... prerequisites) { + super(key, type, prerequisites); + } + + public abstract PotionEffectType getPotionEffect(); + + @EventHandler + public void onEquip(@NotNull final ArmorEquipEvent event) { + final Player player = event.getPlayer(); + + this.getPlugin().getScheduler().runLater(() -> { + if (player.hasPotionEffect(this.getPotionEffect()) && player.getPotionEffect(this.getPotionEffect()).getDuration() >= 1639) { + player.removePotionEffect(this.getPotionEffect()); + } + + int level = EnchantChecks.getArmorPoints(player, this); + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + if (level > 0) { + player.addPotionEffect(new PotionEffect(this.getPotionEffect(), 0x6fffffff, level - 1, false, false, true)); + } + }, 1); + } +} diff --git a/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/EffectsMain.java b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/EffectsMain.java new file mode 100644 index 00000000..9c8a5a52 --- /dev/null +++ b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/EffectsMain.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.effects; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.extensions.Extension; +import com.willfp.ecoenchants.effects.enchants.JumpBoost; +import com.willfp.ecoenchants.effects.enchants.NightVision; +import com.willfp.ecoenchants.effects.enchants.Regeneration; +import com.willfp.ecoenchants.effects.enchants.Speed; +import com.willfp.ecoenchants.effects.enchants.WaterBreathing; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import org.jetbrains.annotations.NotNull; + +public class EffectsMain extends Extension { + public static final EcoEnchant JUMP_BOOST = new JumpBoost(); + public static final EcoEnchant NIGHT_VISION = new NightVision(); + public static final EcoEnchant REGENERATION = new Regeneration(); + public static final EcoEnchant SPEED = new Speed(); + public static final EcoEnchant WATER_BREATHING = new WaterBreathing(); + + public EffectsMain(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void onEnable() { + // Handled by super + } + + @Override + public void onDisable() { + // Handled by super + } +} diff --git a/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/JumpBoost.java b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/JumpBoost.java new file mode 100644 index 00000000..03091f03 --- /dev/null +++ b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/JumpBoost.java @@ -0,0 +1,16 @@ +package com.willfp.ecoenchants.effects.enchants; + +import com.willfp.ecoenchants.effects.EffectsEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.potion.PotionEffectType; + +public class JumpBoost extends EffectsEnchantment { + public JumpBoost() { + super("jump_boost", EnchantmentType.NORMAL); + } + + @Override + public PotionEffectType getPotionEffect() { + return PotionEffectType.JUMP; + } +} diff --git a/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/NightVision.java b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/NightVision.java new file mode 100644 index 00000000..5a554089 --- /dev/null +++ b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/NightVision.java @@ -0,0 +1,16 @@ +package com.willfp.ecoenchants.effects.enchants; + +import com.willfp.ecoenchants.effects.EffectsEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.potion.PotionEffectType; + +public class NightVision extends EffectsEnchantment { + public NightVision() { + super("night_vision", EnchantmentType.NORMAL); + } + + @Override + public PotionEffectType getPotionEffect() { + return PotionEffectType.NIGHT_VISION; + } +} diff --git a/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/Regeneration.java b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/Regeneration.java new file mode 100644 index 00000000..f3e218e0 --- /dev/null +++ b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/Regeneration.java @@ -0,0 +1,16 @@ +package com.willfp.ecoenchants.effects.enchants; + +import com.willfp.ecoenchants.effects.EffectsEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.potion.PotionEffectType; + +public class Regeneration extends EffectsEnchantment { + public Regeneration() { + super("regeneration", EnchantmentType.NORMAL); + } + + @Override + public PotionEffectType getPotionEffect() { + return PotionEffectType.REGENERATION; + } +} diff --git a/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/Speed.java b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/Speed.java new file mode 100644 index 00000000..53e2a3ea --- /dev/null +++ b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/Speed.java @@ -0,0 +1,16 @@ +package com.willfp.ecoenchants.effects.enchants; + +import com.willfp.ecoenchants.effects.EffectsEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.potion.PotionEffectType; + +public class Speed extends EffectsEnchantment { + public Speed() { + super("speed", EnchantmentType.NORMAL); + } + + @Override + public PotionEffectType getPotionEffect() { + return PotionEffectType.SPEED; + } +} diff --git a/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/WaterBreathing.java b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/WaterBreathing.java new file mode 100644 index 00000000..02637995 --- /dev/null +++ b/eco-extensions/effects/src/main/java/com/willfp/ecoenchants/effects/enchants/WaterBreathing.java @@ -0,0 +1,16 @@ +package com.willfp.ecoenchants.effects.enchants; + +import com.willfp.ecoenchants.effects.EffectsEnchantment; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.potion.PotionEffectType; + +public class WaterBreathing extends EffectsEnchantment { + public WaterBreathing() { + super("water_breathing", EnchantmentType.NORMAL); + } + + @Override + public PotionEffectType getPotionEffect() { + return PotionEffectType.WATER_BREATHING; + } +} diff --git a/eco-extensions/effects/src/main/resources/enchants/normal/jumpboost.yml b/eco-extensions/effects/src/main/resources/enchants/normal/jumpboost.yml new file mode 100644 index 00000000..abc42f1c --- /dev/null +++ b/eco-extensions/effects/src/main/resources/enchants/normal/jumpboost.yml @@ -0,0 +1,25 @@ +# +# Jump Boost EcoEnchant +# + +name: "Jump Boost" +description: Gives you permanent jump boost. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - spring + maximum-level: 3 + +config: +# No config is available for this enchantment \ No newline at end of file diff --git a/eco-extensions/effects/src/main/resources/enchants/normal/nightvision.yml b/eco-extensions/effects/src/main/resources/enchants/normal/nightvision.yml new file mode 100644 index 00000000..4fe5cdb5 --- /dev/null +++ b/eco-extensions/effects/src/main/resources/enchants/normal/nightvision.yml @@ -0,0 +1,24 @@ +# +# Night Vision EcoEnchant +# + +name: "Night Vision" +description: Gives you permanent night vision. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - helmet + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 1 + +config: +# No config is available for this enchantment \ No newline at end of file diff --git a/eco-extensions/effects/src/main/resources/enchants/normal/regeneration.yml b/eco-extensions/effects/src/main/resources/enchants/normal/regeneration.yml new file mode 100644 index 00000000..a676e695 --- /dev/null +++ b/eco-extensions/effects/src/main/resources/enchants/normal/regeneration.yml @@ -0,0 +1,24 @@ +# +# Regeneration EcoEnchant +# + +name: "Regeneration" +description: Gives you permanent regeneration. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - helmet + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 2 + +config: +# No config is available for this enchantment \ No newline at end of file diff --git a/eco-extensions/effects/src/main/resources/enchants/normal/speed.yml b/eco-extensions/effects/src/main/resources/enchants/normal/speed.yml new file mode 100644 index 00000000..714042ff --- /dev/null +++ b/eco-extensions/effects/src/main/resources/enchants/normal/speed.yml @@ -0,0 +1,25 @@ +# +# Speed EcoEnchant +# + +name: "Speed" +description: Gives you permanent speed. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - boots + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - streamlining + maximum-level: 3 + +config: +# No config is available for this enchantment \ No newline at end of file diff --git a/eco-extensions/effects/src/main/resources/enchants/normal/waterbreathing.yml b/eco-extensions/effects/src/main/resources/enchants/normal/waterbreathing.yml new file mode 100644 index 00000000..122233e9 --- /dev/null +++ b/eco-extensions/effects/src/main/resources/enchants/normal/waterbreathing.yml @@ -0,0 +1,24 @@ +# +# Water Breathing EcoEnchant +# + +name: "Water Breathing" +description: Gives you permanent water breathing. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - helmet + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 1 + +config: +# No config is available for this enchantment \ No newline at end of file diff --git a/eco-extensions/effects/src/main/resources/extension.yml b/eco-extensions/effects/src/main/resources/extension.yml new file mode 100644 index 00000000..ad894c60 --- /dev/null +++ b/eco-extensions/effects/src/main/resources/extension.yml @@ -0,0 +1,3 @@ +name: Effects +main: com.willfp.ecoenchants.effects.EffectsMain +version: ${projectVersion} \ No newline at end of file diff --git a/eco-extensions/endershot/build.gradle b/eco-extensions/endershot/build.gradle new file mode 100644 index 00000000..c052b8eb --- /dev/null +++ b/eco-extensions/endershot/build.gradle @@ -0,0 +1,7 @@ +group 'com.willfp' +version '5.0.0' +description = 'Endershot Extension' + +shadowJar { + archiveFileName = project.getDescription() + " v" + project.version + ".jar" +} \ No newline at end of file diff --git a/eco-extensions/endershot/src/main/java/com/willfp/ecoenchants/endershot/Endershot.java b/eco-extensions/endershot/src/main/java/com/willfp/ecoenchants/endershot/Endershot.java new file mode 100644 index 00000000..54dedc51 --- /dev/null +++ b/eco-extensions/endershot/src/main/java/com/willfp/ecoenchants/endershot/Endershot.java @@ -0,0 +1,68 @@ +package com.willfp.ecoenchants.endershot; + +import com.willfp.eco.core.integrations.mcmmo.McmmoManager; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.SoundCategory; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public class Endershot extends EcoEnchant { + public Endershot() { + super("endershot", EnchantmentType.NORMAL); + } + + @EventHandler(priority = EventPriority.LOW) + public void onBowShoot(@NotNull final EntityShootBowEvent event) { + if (McmmoManager.isFake(event)) { + return; + } + if (event.getProjectile().getType() != EntityType.ARROW) { + return; + } + if (!(event.getEntity() instanceof Player)) { + return; + } + + Player player = (Player) event.getEntity(); + + if (!player.isSneaking()) { + return; + } + + event.setCancelled(true); + + if (!EnchantChecks.mainhand(player, this)) { + return; + } + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + if (!player.getInventory().contains(Material.ENDER_PEARL, 1) && !player.getGameMode().equals(GameMode.CREATIVE)) { + return; + } + + boolean hasInfinity = EnchantChecks.mainhand(player, ARROW_INFINITE) && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "work-with-infinity"); + if (!hasInfinity) { + ItemStack pearl = new ItemStack(Material.ENDER_PEARL, 1); + player.getInventory().remove(pearl); + } + + EnderPearl pearl = player.launchProjectile(EnderPearl.class); + pearl.setShooter(player); + pearl.setVelocity(event.getProjectile().getVelocity()); + player.playSound(player.getLocation(), Sound.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1f, 1f); + } +} diff --git a/eco-extensions/endershot/src/main/java/com/willfp/ecoenchants/endershot/EndershotMain.java b/eco-extensions/endershot/src/main/java/com/willfp/ecoenchants/endershot/EndershotMain.java new file mode 100644 index 00000000..94e578a8 --- /dev/null +++ b/eco-extensions/endershot/src/main/java/com/willfp/ecoenchants/endershot/EndershotMain.java @@ -0,0 +1,24 @@ +package com.willfp.ecoenchants.endershot; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.extensions.Extension; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import org.jetbrains.annotations.NotNull; + +public class EndershotMain extends Extension { + public static final EcoEnchant ENDERSHOT = new Endershot(); + + public EndershotMain(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void onEnable() { + // Handled by super + } + + @Override + public void onDisable() { + // Handled by super + } +} diff --git a/eco-extensions/endershot/src/main/resources/enchants/normal/endershot.yml b/eco-extensions/endershot/src/main/resources/enchants/normal/endershot.yml new file mode 100644 index 00000000..bf9c02ff --- /dev/null +++ b/eco-extensions/endershot/src/main/resources/enchants/normal/endershot.yml @@ -0,0 +1,25 @@ +# +# Endershot EcoEnchant +# + +name: "Endershot" +description: Shoot ender pearls out of your bow while crouching +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 1 + +config: + work-with-infinity: true # Don't consume ender pearls when enchanted with infinity \ No newline at end of file diff --git a/eco-extensions/endershot/src/main/resources/extension.yml b/eco-extensions/endershot/src/main/resources/extension.yml new file mode 100644 index 00000000..97574753 --- /dev/null +++ b/eco-extensions/endershot/src/main/resources/extension.yml @@ -0,0 +1,3 @@ +name: Endershot +main: com.willfp.ecoenchants.endershot.EndershotMain +version: ${projectVersion} diff --git a/eco-extensions/firewand/build.gradle b/eco-extensions/firewand/build.gradle new file mode 100644 index 00000000..177e290f --- /dev/null +++ b/eco-extensions/firewand/build.gradle @@ -0,0 +1,7 @@ +group 'com.willfp' +version '5.0.0' +description = 'Firewand Extension' + +shadowJar { + archiveFileName = project.getDescription() + " v" + project.version + ".jar" +} \ No newline at end of file diff --git a/eco-extensions/firewand/src/main/java/com/willfp/ecoenchants/firewand/Firewand.java b/eco-extensions/firewand/src/main/java/com/willfp/ecoenchants/firewand/Firewand.java new file mode 100644 index 00000000..3243550a --- /dev/null +++ b/eco-extensions/firewand/src/main/java/com/willfp/ecoenchants/firewand/Firewand.java @@ -0,0 +1,60 @@ +package com.willfp.ecoenchants.firewand; + + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.itemtypes.Spell; +import org.bukkit.entity.Player; +import org.bukkit.entity.SmallFireball; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.jetbrains.annotations.NotNull; + +public class Firewand extends Spell { + public Firewand() { + super("firewand"); + } + + @Override + public boolean onUse(@NotNull final Player player, + final int level, + @NotNull final PlayerInteractEvent event) { + SmallFireball fireball = player.launchProjectile(SmallFireball.class, player.getEyeLocation().getDirection().multiply(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity"))); + fireball.setIsIncendiary(this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "fire")); + fireball.setMetadata("eco-damage", this.getPlugin().getMetadataValueFactory().create(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * level)); + if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "no-explode")) { + fireball.setMetadata("nobreak", this.getPlugin().getMetadataValueFactory().create(true)); + } + fireball.setShooter(player); + + return true; + } + + @EventHandler(priority = EventPriority.LOW) + public void onFireballDamage(@NotNull final EntityDamageByEntityEvent event) { + if (!(event.getDamager() instanceof SmallFireball)) { + return; + } + if (event.getDamager().getMetadata("eco-damage").isEmpty()) { + return; + } + + double multiplier = event.getDamager().getMetadata("eco-damage").get(0).asDouble(); + + event.setDamage(multiplier); + } + + @EventHandler + public void onFireballExplode(@NotNull final EntityExplodeEvent event) { + if (!(event.getEntity() instanceof SmallFireball)) { + return; + } + if (event.getEntity().getMetadata("nobreak").isEmpty()) { + return; + } + + event.setCancelled(true); + } +} diff --git a/eco-extensions/firewand/src/main/java/com/willfp/ecoenchants/firewand/FirewandMain.java b/eco-extensions/firewand/src/main/java/com/willfp/ecoenchants/firewand/FirewandMain.java new file mode 100644 index 00000000..25792316 --- /dev/null +++ b/eco-extensions/firewand/src/main/java/com/willfp/ecoenchants/firewand/FirewandMain.java @@ -0,0 +1,24 @@ +package com.willfp.ecoenchants.firewand; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.extensions.Extension; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import org.jetbrains.annotations.NotNull; + +public class FirewandMain extends Extension { + public static final EcoEnchant FIREWAND = new Firewand(); + + public FirewandMain(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void onEnable() { + // Handled by super + } + + @Override + public void onDisable() { + // Handled by super + } +} diff --git a/eco-extensions/firewand/src/main/resources/enchants/spell/firewand.yml b/eco-extensions/firewand/src/main/resources/enchants/spell/firewand.yml new file mode 100644 index 00000000..028b1a5c --- /dev/null +++ b/eco-extensions/firewand/src/main/resources/enchants/spell/firewand.yml @@ -0,0 +1,30 @@ +# +# Firewand EcoEnchant +# + +name: "Firewand" +description: Shoots a fireball +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - rod + - carrot_stick + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + activation-sound: ENTITY_GHAST_SHOOT + cooldown: 60 # In seconds + velocity: 3 + fire: true + damage-per-level: 8 + no-explode: false # Don't explode \ No newline at end of file diff --git a/eco-extensions/firewand/src/main/resources/extension.yml b/eco-extensions/firewand/src/main/resources/extension.yml new file mode 100644 index 00000000..55f69765 --- /dev/null +++ b/eco-extensions/firewand/src/main/resources/extension.yml @@ -0,0 +1,3 @@ +name: Firewand +main: com.willfp.ecoenchants.firewand.FirewandMain +version: ${projectVersion} \ No newline at end of file diff --git a/eco-extensions/mmo/build.gradle b/eco-extensions/mmo/build.gradle new file mode 100644 index 00000000..a09a8ddd --- /dev/null +++ b/eco-extensions/mmo/build.gradle @@ -0,0 +1,24 @@ +group 'com.willfp' +version '5.0.0' +description = 'MMO Extension' + +repositories { + maven { + url 'https://mvn.lumine.io/repository/maven-public/' + } +} + +dependencies { + compileOnly 'net.Indyuce:MMOCore:1.7.0' + compileOnly 'net.Indyuce:MMOItems:6.5.4' + compileOnly 'net.Indyuce:MMOLib:1.7.3' +} + +configurations.all { + exclude group: 'com.mojang', module: 'authlib' + exclude group: 'org.kitteh.pastegg' +} + +shadowJar { + archiveFileName = project.getDescription() + " v" + project.version + ".jar" +} \ No newline at end of file diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/MMOMain.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/MMOMain.java new file mode 100644 index 00000000..f8720be1 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/MMOMain.java @@ -0,0 +1,52 @@ +package com.willfp.ecoenchants.mmo; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.extensions.Extension; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.mmo.enchants.abilities.Discounted; +import com.willfp.ecoenchants.mmo.enchants.abilities.Recover; +import com.willfp.ecoenchants.mmo.enchants.mana.Augment; +import com.willfp.ecoenchants.mmo.enchants.mana.Drain; +import com.willfp.ecoenchants.mmo.enchants.mana.Elixir; +import com.willfp.ecoenchants.mmo.enchants.mana.Siphon; +import com.willfp.ecoenchants.mmo.enchants.mana.Spirituality; +import com.willfp.ecoenchants.mmo.enchants.misc.Strengthening; +import com.willfp.ecoenchants.mmo.enchants.stamina.Athletic; +import com.willfp.ecoenchants.mmo.enchants.stamina.Endurance; +import com.willfp.ecoenchants.mmo.enchants.stamina.Fortitude; +import com.willfp.ecoenchants.mmo.enchants.stamina.Motivate; +import org.bukkit.Bukkit; +import org.jetbrains.annotations.NotNull; + +public class MMOMain extends Extension { + public static final EcoEnchant ELIXIR = new Elixir(); + public static final EcoEnchant SIPHON = new Siphon(); + public static final EcoEnchant DRAIN = new Drain(); + public static final EcoEnchant SPIRITUALITY = new Spirituality(); + public static final EcoEnchant AUGMENT = new Augment(); + public static final EcoEnchant DISCOUNTED = new Discounted(); + public static final EcoEnchant RECOVER = new Recover(); + public static final EcoEnchant ENDURANCE = new Endurance(); + public static final EcoEnchant FORTITUDE = new Fortitude(); + public static final EcoEnchant MOTIVATE = new Motivate(); + public static final EcoEnchant ATHLETIC = new Athletic(); + public static final EcoEnchant STRENGTHENING = new Strengthening(); + + public MMOMain(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + protected void onEnable() { + if (!MMOPrerequisites.HAS_MMOCORE.isMet()) { + Bukkit.getLogger().severe("MMO Extension requires MMOCore to be installed!"); + Bukkit.getLogger().severe("Disabling..."); + this.disable(); + } + } + + @Override + protected void onDisable() { + // Handled by super + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/MMOPrerequisites.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/MMOPrerequisites.java new file mode 100644 index 00000000..934a88c8 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/MMOPrerequisites.java @@ -0,0 +1,29 @@ +package com.willfp.ecoenchants.mmo; + +import com.willfp.eco.core.Prerequisite; +import org.bukkit.Bukkit; +import org.bukkit.plugin.Plugin; + +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; + +public class MMOPrerequisites { + private static final Set enabledPlugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toSet()); + + public static final Prerequisite HAS_MMOCORE = new Prerequisite( + () -> enabledPlugins.contains("MMOCore"), + "Has mmocore installed" + ); + public static final Prerequisite HAS_MMOITEMS = new Prerequisite( + () -> enabledPlugins.contains("MMOItems"), + "Has mmoitems installed" + ); + + public static Prerequisite[] append(Prerequisite[] array, Prerequisite newElement) { + Prerequisite[] copy = new Prerequisite[array.length + 1]; + System.arraycopy(array, 0, copy, 0, array.length); + copy[array.length] = newElement; + return copy; + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/abilities/Discounted.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/abilities/Discounted.java new file mode 100644 index 00000000..adeedab3 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/abilities/Discounted.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.mmo.enchants.abilities; + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.mmo.MMOPrerequisites; +import com.willfp.ecoenchants.mmo.structure.MMOEnchantment; +import net.Indyuce.mmoitems.api.event.AbilityUseEvent; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class Discounted extends MMOEnchantment { + public Discounted() { + super("discounted", EnchantmentType.NORMAL, MMOPrerequisites.HAS_MMOITEMS); + } + + @EventHandler + public void onAbility(AbilityUseEvent event) { + Player player = event.getPlayer(); + + if (!EnchantChecks.mainhand(player, this)) + return; + + int level = EnchantChecks.getMainhandLevel(player, this); + + double cost = event.getAbility().getModifier("mana"); + if (cost == 0.0D) return; + + double multiplier = 1 - (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier") * level); + cost *= multiplier; + + event.getAbility().setModifier("mana", cost); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/abilities/Recover.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/abilities/Recover.java new file mode 100644 index 00000000..40488adf --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/abilities/Recover.java @@ -0,0 +1,35 @@ +package com.willfp.ecoenchants.mmo.enchants.abilities; + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.mmo.MMOPrerequisites; +import com.willfp.ecoenchants.mmo.structure.MMOEnchantment; +import net.Indyuce.mmoitems.api.event.AbilityUseEvent; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class Recover extends MMOEnchantment { + public Recover() { + super("recover", EnchantmentType.NORMAL, MMOPrerequisites.HAS_MMOITEMS); + } + + @EventHandler + public void onAbility(AbilityUseEvent event) { + Player player = event.getPlayer(); + + if (!EnchantChecks.mainhand(player, this)) + return; + + int level = EnchantChecks.getMainhandLevel(player, this); + + double cooldown = event.getAbility().getModifier("cooldown"); + + if (cooldown == 0.0D) return; + + double multiplier = 1 - (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier") * level); + cooldown *= multiplier; + + event.getAbility().setModifier("cooldown", cooldown); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Augment.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Augment.java new file mode 100644 index 00000000..58b45105 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Augment.java @@ -0,0 +1,38 @@ +package com.willfp.ecoenchants.mmo.enchants.mana; + +import com.willfp.eco.core.events.ArmorEquipEvent; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.mmo.structure.MMOEnchantment; +import net.mmogroup.mmolib.MMOLib; +import net.mmogroup.mmolib.api.player.MMOPlayerData; +import net.mmogroup.mmolib.api.stat.SharedStat; +import net.mmogroup.mmolib.api.stat.modifier.StatModifier; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class Augment extends MMOEnchantment { + private static final String KEY = "ecoenchants_bonus_mana"; + + public Augment() { + super("augment", EnchantmentType.NORMAL); + } + + @Override + public void onArmorEquip(@NotNull Player player, int level, @NotNull ArmorEquipEvent event) { + MMOPlayerData data = MMOPlayerData.get(player); + + data.getStatMap().getInstance(SharedStat.MAX_MANA).remove(KEY); + + if (level == 0) { + MMOLib.plugin.getStats().runUpdates(data.getStatMap()); + return; + } + + int mana = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "mana-per-level") * level; + + data.getStatMap().getInstance(SharedStat.MAX_MANA).addModifier(KEY, new StatModifier(mana)); + + MMOLib.plugin.getStats().runUpdates(data.getStatMap()); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Drain.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Drain.java new file mode 100644 index 00000000..8a1405ea --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Drain.java @@ -0,0 +1,29 @@ +package com.willfp.ecoenchants.mmo.enchants.mana; + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager; +import com.willfp.ecoenchants.mmo.structure.MMOSpell; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerInteractEvent; + +public class Drain extends MMOSpell { + public Drain() { + super("drain"); + } + + @Override + public boolean onUse(Player player, int level, PlayerInteractEvent event) { + double radius = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-per-level") * level; + double amount = 1 - ((this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percentage-per-level") / 100) * level); + + player.getNearbyEntities(radius, radius, radius).forEach(entity -> { + if (!(entity instanceof Player)) + return; + + Player victim = (Player) entity; + MMOManager.setMana(victim, MMOManager.getMana(player) * amount); + }); + + return true; + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Elixir.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Elixir.java new file mode 100644 index 00000000..ff2a1c15 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Elixir.java @@ -0,0 +1,38 @@ +package com.willfp.ecoenchants.mmo.enchants.mana; + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager; +import com.willfp.ecoenchants.mmo.structure.MMOEnchantment; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Elixir extends MMOEnchantment { + public Elixir() { + super("elixir", EnchantmentType.NORMAL); + } + + @Override + public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) { + if (!(attacker instanceof Player && victim instanceof Player)) + return; + Player pAttacker = (Player) attacker; + Player pVictim = (Player) victim; + + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + double victimMana = MMOManager.getMana(pVictim); + + double quantity = (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percentage-per-level") / 100) * level; + + double toSteal = victimMana * quantity; + + MMOManager.setMana(pVictim, victimMana - toSteal); + MMOManager.giveMana(pAttacker, toSteal); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Siphon.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Siphon.java new file mode 100644 index 00000000..2805ebfd --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Siphon.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.mmo.enchants.mana; + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager; +import com.willfp.ecoenchants.mmo.structure.MMOEnchantment; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Siphon extends MMOEnchantment { + public Siphon() { + super("siphon", EnchantmentType.NORMAL); + } + + @Override + public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) { + if (!(attacker instanceof Player && victim instanceof Player)) + return; + Player pAttacker = (Player) attacker; + Player pVictim = (Player) victim; + + double victimMana = MMOManager.getMana(pVictim); + + double quantity = (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percentage-per-level") / 100) * level; + + double toSteal = victimMana * quantity; + + MMOManager.setMana(pVictim, victimMana - toSteal); + MMOManager.giveMana(pAttacker, toSteal); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Spirituality.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Spirituality.java new file mode 100644 index 00000000..34a99cec --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/mana/Spirituality.java @@ -0,0 +1,30 @@ +package com.willfp.ecoenchants.mmo.enchants.mana; + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.mmo.structure.MMOEnchantment; +import net.Indyuce.mmocore.api.event.PlayerRegenResourceEvent; +import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class Spirituality extends MMOEnchantment { + public Spirituality() { + super("spirituality", EnchantmentType.NORMAL); + } + + @EventHandler + public void onRegainMana(PlayerRegenResourceEvent event) { + if (!event.getResource().equals(PlayerResource.MANA)) + return; + + Player player = event.getPlayer(); + + int levels = EnchantChecks.getArmorPoints(player, this); + if (levels == 0) return; + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier") * levels; + event.setAmount(event.getAmount() * (multiplier + 1)); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/misc/Strengthening.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/misc/Strengthening.java new file mode 100644 index 00000000..0e46365e --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/misc/Strengthening.java @@ -0,0 +1,38 @@ +package com.willfp.ecoenchants.mmo.enchants.misc; + +import com.willfp.eco.core.events.ArmorEquipEvent; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.mmo.structure.MMOEnchantment; +import net.mmogroup.mmolib.MMOLib; +import net.mmogroup.mmolib.api.player.MMOPlayerData; +import net.mmogroup.mmolib.api.stat.SharedStat; +import net.mmogroup.mmolib.api.stat.modifier.StatModifier; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class Strengthening extends MMOEnchantment { + private static final String KEY = "ecoenchants_bonus_strength"; + + public Strengthening() { + super("strengthening", EnchantmentType.NORMAL); + } + + @Override + public void onArmorEquip(@NotNull Player player, int level, @NotNull ArmorEquipEvent event) { + MMOPlayerData data = MMOPlayerData.get(player); + + data.getStatMap().getInstance(SharedStat.ATTACK_DAMAGE).remove(KEY); + + if (level == 0) { + MMOLib.plugin.getStats().runUpdates(data.getStatMap()); + return; + } + + double multiplier = (this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier") * level) * data.getStatMap().getInstance(SharedStat.ATTACK_DAMAGE).getBase(); + + data.getStatMap().getInstance(SharedStat.ATTACK_DAMAGE).addModifier(KEY, new StatModifier(multiplier)); + + MMOLib.plugin.getStats().runUpdates(data.getStatMap()); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Athletic.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Athletic.java new file mode 100644 index 00000000..e45e1279 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Athletic.java @@ -0,0 +1,38 @@ +package com.willfp.ecoenchants.mmo.enchants.stamina; + +import com.willfp.eco.core.events.ArmorEquipEvent; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.mmo.structure.MMOEnchantment; +import net.mmogroup.mmolib.MMOLib; +import net.mmogroup.mmolib.api.player.MMOPlayerData; +import net.mmogroup.mmolib.api.stat.SharedStat; +import net.mmogroup.mmolib.api.stat.modifier.StatModifier; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class Athletic extends MMOEnchantment { + private static final String KEY = "ecoenchants_bonus_stamina"; + + public Athletic() { + super("athletic", EnchantmentType.NORMAL); + } + + @Override + public void onArmorEquip(@NotNull Player player, int level, @NotNull ArmorEquipEvent event) { + MMOPlayerData data = MMOPlayerData.get(player); + + data.getStatMap().getInstance(SharedStat.MAX_STAMINA).remove(KEY); + + if (level == 0) { + MMOLib.plugin.getStats().runUpdates(data.getStatMap()); + return; + } + + int stamina = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "stamina-per-level") * level; + + data.getStatMap().getInstance(SharedStat.MAX_STAMINA).addModifier(KEY, new StatModifier(stamina)); + + MMOLib.plugin.getStats().runUpdates(data.getStatMap()); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Endurance.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Endurance.java new file mode 100644 index 00000000..bb2dfd06 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Endurance.java @@ -0,0 +1,30 @@ +package com.willfp.ecoenchants.mmo.enchants.stamina; + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import com.willfp.ecoenchants.mmo.structure.MMOEnchantment; +import net.Indyuce.mmocore.api.event.PlayerRegenResourceEvent; +import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class Endurance extends MMOEnchantment { + public Endurance() { + super("endurance", EnchantmentType.NORMAL); + } + + @EventHandler + public void onRegainMana(PlayerRegenResourceEvent event) { + if (!event.getResource().equals(PlayerResource.STAMINA)) + return; + + Player player = event.getPlayer(); + + int levels = EnchantChecks.getArmorPoints(player, this); + if (levels == 0) return; + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier") * levels; + event.setAmount(event.getAmount() * (multiplier + 1)); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Fortitude.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Fortitude.java new file mode 100644 index 00000000..bee3bab9 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Fortitude.java @@ -0,0 +1,34 @@ +package com.willfp.ecoenchants.mmo.enchants.stamina; + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager; +import com.willfp.ecoenchants.mmo.structure.MMOEnchantment; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Fortitude extends MMOEnchantment { + public Fortitude() { + super("fortitude", EnchantmentType.NORMAL); + } + + @Override + public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) { + if (!(attacker instanceof Player && victim instanceof Player)) + return; + Player pAttacker = (Player) attacker; + Player pVictim = (Player) victim; + + double victimStamina = MMOManager.getStamina(pVictim); + + double quantity = (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percentage-per-level") / 100) * level; + + double toSteal = victimStamina * quantity; + + MMOManager.setStamina(pVictim, victimStamina - toSteal); + MMOManager.giveStamina(pAttacker, toSteal); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Motivate.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Motivate.java new file mode 100644 index 00000000..5cad4241 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/enchants/stamina/Motivate.java @@ -0,0 +1,38 @@ +package com.willfp.ecoenchants.mmo.enchants.stamina; + +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import com.willfp.ecoenchants.mmo.integrations.mmo.MMOManager; +import com.willfp.ecoenchants.mmo.structure.MMOEnchantment; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; + +public class Motivate extends MMOEnchantment { + public Motivate() { + super("motivate", EnchantmentType.NORMAL); + } + + @Override + public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) { + if (!(attacker instanceof Player && victim instanceof Player)) + return; + Player pAttacker = (Player) attacker; + Player pVictim = (Player) victim; + + if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + + double victimStamina = MMOManager.getStamina(pVictim); + + double quantity = (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percentage-per-level") / 100) * level; + + double toSteal = victimStamina * quantity; + + MMOManager.setStamina(pVictim, victimStamina - toSteal); + MMOManager.giveStamina(pAttacker, toSteal); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/integrations/mmo/MMOIntegration.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/integrations/mmo/MMOIntegration.java new file mode 100644 index 00000000..16d3cdd0 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/integrations/mmo/MMOIntegration.java @@ -0,0 +1,23 @@ +package com.willfp.ecoenchants.mmo.integrations.mmo; + + +import com.willfp.eco.core.integrations.Integration; +import org.bukkit.entity.Player; + +public interface MMOIntegration extends Integration { + double getMana(Player player); + + void setMana(Player player, double amount); + + double getMaxMana(Player player); + + void giveMana(Player player, double amount); + + double getStamina(Player player); + + void setStamina(Player player, double amount); + + double getMaxStamina(Player player); + + void giveStamina(Player player, double amount); +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/integrations/mmo/MMOManager.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/integrations/mmo/MMOManager.java new file mode 100644 index 00000000..ea778cb6 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/integrations/mmo/MMOManager.java @@ -0,0 +1,58 @@ +package com.willfp.ecoenchants.mmo.integrations.mmo; + +import org.bukkit.entity.Player; + +import java.util.HashSet; +import java.util.Set; + +public class MMOManager { + private static final Set integrations = new HashSet<>(); + + public static void register(MMOIntegration integration) { + integrations.add(integration); + } + + private static MMOIntegration getIntegration() { + return integrations.stream().findFirst().get(); + } + + public static double getMana(Player player) { + MMOIntegration integration = getIntegration(); + return integration.getMana(player); + } + + public static double getMaxMana(Player player) { + MMOIntegration integration = getIntegration(); + return integration.getMaxMana(player); + } + + public static void setMana(Player player, double amount) { + MMOIntegration integration = getIntegration(); + integration.setMana(player, amount); + } + + public static void giveMana(Player player, double amount) { + MMOIntegration integration = getIntegration(); + integration.giveMana(player, amount); + } + + public static double getStamina(Player player) { + MMOIntegration integration = getIntegration(); + return integration.getStamina(player); + } + + public static double getMaxStamina(Player player) { + MMOIntegration integration = getIntegration(); + return integration.getMaxStamina(player); + } + + public static void setStamina(Player player, double amount) { + MMOIntegration integration = getIntegration(); + integration.setStamina(player, amount); + } + + public static void giveStamina(Player player, double amount) { + MMOIntegration integration = getIntegration(); + integration.giveStamina(player, amount); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/integrations/mmo/plugins/MMOCore.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/integrations/mmo/plugins/MMOCore.java new file mode 100644 index 00000000..a8222e3f --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/integrations/mmo/plugins/MMOCore.java @@ -0,0 +1,53 @@ +package com.willfp.ecoenchants.mmo.integrations.mmo.plugins; + +import com.willfp.ecoenchants.mmo.integrations.mmo.MMOIntegration; +import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.player.stats.StatType; +import org.bukkit.entity.Player; + +public class MMOCore implements MMOIntegration { + @Override + public double getMana(Player player) { + return PlayerData.get(player).getMana(); + } + + @Override + public void setMana(Player player, double amount) { + PlayerData.get(player).setMana(amount); + } + + @Override + public void giveMana(Player player, double amount) { + PlayerData.get(player).giveMana(amount); + } + + @Override + public double getMaxMana(Player player) { + return PlayerData.get(player).getStats().getStat(StatType.MAX_MANA); + } + + @Override + public double getStamina(Player player) { + return PlayerData.get(player).getStamina(); + } + + @Override + public void setStamina(Player player, double amount) { + PlayerData.get(player).setStamina(amount); + } + + @Override + public void giveStamina(Player player, double amount) { + PlayerData.get(player).giveStamina(amount); + } + + @Override + public double getMaxStamina(Player player) { + return PlayerData.get(player).getStats().getStat(StatType.MAX_STAMINA); + } + + @Override + public String getPluginName() { + return "MMOCore"; + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOEnchant.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOEnchant.java new file mode 100644 index 00000000..a84195f6 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOEnchant.java @@ -0,0 +1,8 @@ +package com.willfp.ecoenchants.mmo.structure; + +import java.util.HashSet; +import java.util.Set; + +public interface MMOEnchant { + Set REGISTRY = new HashSet<>(); +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOEnchantment.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOEnchantment.java new file mode 100644 index 00000000..c4540d98 --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOEnchantment.java @@ -0,0 +1,14 @@ +package com.willfp.ecoenchants.mmo.structure; + +import com.willfp.eco.core.Prerequisite; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.mmo.MMOPrerequisites; + +public abstract class MMOEnchantment extends EcoEnchant implements MMOEnchant { + protected MMOEnchantment(String key, EnchantmentType type, Prerequisite... prerequisites) { + super(key, type, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE)); + + MMOEnchant.REGISTRY.add(this); + } +} diff --git a/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOSpell.java b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOSpell.java new file mode 100644 index 00000000..d1323d4a --- /dev/null +++ b/eco-extensions/mmo/src/main/java/com/willfp/ecoenchants/mmo/structure/MMOSpell.java @@ -0,0 +1,13 @@ +package com.willfp.ecoenchants.mmo.structure; + +import com.willfp.eco.core.Prerequisite; +import com.willfp.ecoenchants.enchantments.itemtypes.Spell; +import com.willfp.ecoenchants.mmo.MMOPrerequisites; + +public abstract class MMOSpell extends Spell implements MMOEnchant { + protected MMOSpell(String key, Prerequisite... prerequisites) { + super(key, MMOPrerequisites.append(prerequisites, MMOPrerequisites.HAS_MMOCORE)); + + MMOEnchant.REGISTRY.add(this); + } +} diff --git a/eco-extensions/mmo/src/main/resources/enchants/normal/athletic.yml b/eco-extensions/mmo/src/main/resources/enchants/normal/athletic.yml new file mode 100644 index 00000000..7dff2c01 --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/enchants/normal/athletic.yml @@ -0,0 +1,26 @@ +# +# Athletic EcoEnchant +# + +name: "Athletic" +description: Increases your max stamina. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + conflicts: [ ] + maximum-level: 4 + +config: + stamina-per-level: 10 # Bonus max stamina to give per level \ No newline at end of file diff --git a/eco-extensions/mmo/src/main/resources/enchants/normal/augment.yml b/eco-extensions/mmo/src/main/resources/enchants/normal/augment.yml new file mode 100644 index 00000000..5bdf6edd --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/enchants/normal/augment.yml @@ -0,0 +1,26 @@ +# +# Augment EcoEnchant +# + +name: "Augment" +description: Increases your max mana. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + conflicts: [ ] + maximum-level: 4 + +config: + mana-per-level: 10 # Bonus max mana to give per level \ No newline at end of file diff --git a/eco-extensions/mmo/src/main/resources/enchants/normal/discounted.yml b/eco-extensions/mmo/src/main/resources/enchants/normal/discounted.yml new file mode 100644 index 00000000..da15a9f5 --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/enchants/normal/discounted.yml @@ -0,0 +1,25 @@ +# +# Discounted EcoEnchant +# + +name: "Discounted" +description: Reduces mana cost for abilities. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + - sword + - axe + grindstoneable: true + conflicts: [ ] + maximum-level: 5 + +config: + multiplier: 0.1 # Mana cost = initial cost * (1 - multiplier * level), thus 10 cost with discounted 5 means final cost is 5 \ No newline at end of file diff --git a/eco-extensions/mmo/src/main/resources/enchants/normal/elixir.yml b/eco-extensions/mmo/src/main/resources/enchants/normal/elixir.yml new file mode 100644 index 00000000..7bc72c1e --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/enchants/normal/elixir.yml @@ -0,0 +1,25 @@ +# +# Elixir EcoEnchant +# + +name: "Elixir" +description: Steals a portion of your victim's mana. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + - axe + grindstoneable: true + conflicts: [ ] + maximum-level: 3 + +config: + allow-not-fully-charged: false + percentage-per-level: 5 # Percentage of your opponents mana to steal per level \ No newline at end of file diff --git a/eco-extensions/mmo/src/main/resources/enchants/normal/endurance.yml b/eco-extensions/mmo/src/main/resources/enchants/normal/endurance.yml new file mode 100644 index 00000000..204efa0b --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/enchants/normal/endurance.yml @@ -0,0 +1,29 @@ +# +# Endurance EcoEnchant +# + +name: "Endurance" +description: Increases the rate that you regain stamina. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + conflicts: [ ] + maximum-level: 4 + +config: + multiplier: 0.1 # How many times faster to regain per level + # The formula is default amount * (1 + (multiplier * level)) + # ie, If you were going to regen 10 stamina with a multiplier of 0.1 and 8 levels, then you would regenerate: + # 10 * (1 + (0.1 * 8)) = 10 * 1.8 = 18 \ No newline at end of file diff --git a/eco-extensions/mmo/src/main/resources/enchants/normal/fortitude.yml b/eco-extensions/mmo/src/main/resources/enchants/normal/fortitude.yml new file mode 100644 index 00000000..4b7ea86f --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/enchants/normal/fortitude.yml @@ -0,0 +1,24 @@ +# +# Fortitude EcoEnchant +# + +name: "Fortitude" +description: Steals a portion of your victim's stamina. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + conflicts: [ ] + maximum-level: 3 + +config: + percentage-per-level: 5 # Percentage of your opponents stamina to steal per level \ No newline at end of file diff --git a/eco-extensions/mmo/src/main/resources/enchants/normal/motivate.yml b/eco-extensions/mmo/src/main/resources/enchants/normal/motivate.yml new file mode 100644 index 00000000..c92aeb69 --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/enchants/normal/motivate.yml @@ -0,0 +1,25 @@ +# +# Motivate EcoEnchant +# + +name: "Motivate" +description: Steals a portion of your victim's stamina. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - sword + - axe + grindstoneable: true + conflicts: [ ] + maximum-level: 3 + +config: + allow-not-fully-charged: false + percentage-per-level: 5 # Percentage of your opponents stamina to steal per level \ No newline at end of file diff --git a/eco-extensions/mmo/src/main/resources/enchants/normal/recover.yml b/eco-extensions/mmo/src/main/resources/enchants/normal/recover.yml new file mode 100644 index 00000000..e75468c5 --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/enchants/normal/recover.yml @@ -0,0 +1,25 @@ +# +# Recover EcoEnchant +# + +name: "Recover" +description: Reduces cooldown for abilities. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + - sword + - axe + grindstoneable: true + conflicts: [ ] + maximum-level: 5 + +config: + multiplier: 0.1 # Cooldown = initial cooldown * (1 - multiplier * level), thus 8 cooldown with recover 5 means final cooldown is 4 \ No newline at end of file diff --git a/eco-extensions/mmo/src/main/resources/enchants/normal/siphon.yml b/eco-extensions/mmo/src/main/resources/enchants/normal/siphon.yml new file mode 100644 index 00000000..1fb9b607 --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/enchants/normal/siphon.yml @@ -0,0 +1,24 @@ +# +# Siphon EcoEnchant +# + +name: "Siphon" +description: Steals a portion of your victim's mana. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + conflicts: [ ] + maximum-level: 3 + +config: + percentage-per-level: 5 # Percentage of your opponents mana to steal per level \ No newline at end of file diff --git a/eco-extensions/mmo/src/main/resources/enchants/normal/spirituality.yml b/eco-extensions/mmo/src/main/resources/enchants/normal/spirituality.yml new file mode 100644 index 00000000..97f85194 --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/enchants/normal/spirituality.yml @@ -0,0 +1,29 @@ +# +# Spirituality EcoEnchant +# + +name: "Spirituality" +description: Increases the rate that you regain mana. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + conflicts: [ ] + maximum-level: 4 + +config: + multiplier: 0.1 # How many times faster to regain per level + # The formula is default amount * (1 + (multiplier * level)) + # ie, If you were going to regen 10 mana with a multiplier of 0.1 and 8 levels, then you would regenerate: + # 10 * (1 + (0.1 * 8)) = 10 * 1.8 = 18 \ No newline at end of file diff --git a/eco-extensions/mmo/src/main/resources/enchants/normal/strengthening.yml b/eco-extensions/mmo/src/main/resources/enchants/normal/strengthening.yml new file mode 100644 index 00000000..ad725c66 --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/enchants/normal/strengthening.yml @@ -0,0 +1,26 @@ +# +# Strengthening EcoEnchant +# + +name: "Strengthening" +description: Increases your attack damage while wearing. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: epic + +general-config: + targets: + - helmet + - chestplate + - leggings + - boots + grindstoneable: true + conflicts: [ ] + maximum-level: 4 + +config: + multiplier: 0.02 # Multiplier * Levels * Base Attack Damage is added to your total attack damage while wearing \ No newline at end of file diff --git a/eco-extensions/mmo/src/main/resources/enchants/spell/drain.yml b/eco-extensions/mmo/src/main/resources/enchants/spell/drain.yml new file mode 100644 index 00000000..d00eec7e --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/enchants/spell/drain.yml @@ -0,0 +1,26 @@ +# +# Drain EcoEnchant +# + +name: "Drain" +description: Reduces all nearby players' mana. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - sword + grindstoneable: true + conflicts: [ ] + maximum-level: 3 + +config: + activation-sound: ENTITY_ENDERMAN_TELEPORT + cooldown: 240 # In seconds + radius-per-level: 10 # Radius to check nearby players' mana + percentage-per-level: 10 # Percentage of nearby players' mana to reduce diff --git a/eco-extensions/mmo/src/main/resources/extension.yml b/eco-extensions/mmo/src/main/resources/extension.yml new file mode 100644 index 00000000..758320be --- /dev/null +++ b/eco-extensions/mmo/src/main/resources/extension.yml @@ -0,0 +1,3 @@ +name: MMO +main: com.willfp.ecoenchants.mmo.MMOMain +version: ${projectVersion} \ No newline at end of file diff --git a/eco-extensions/precision/build.gradle b/eco-extensions/precision/build.gradle new file mode 100644 index 00000000..deee6d87 --- /dev/null +++ b/eco-extensions/precision/build.gradle @@ -0,0 +1,7 @@ +group 'com.willfp' +version '5.0.0' +description = 'Precision Extension' + +shadowJar { + archiveFileName = project.getDescription() + " v" + project.version + ".jar" +} \ No newline at end of file diff --git a/eco-extensions/precision/src/main/java/com/willfp/ecoenchants/precision/Precision.java b/eco-extensions/precision/src/main/java/com/willfp/ecoenchants/precision/Precision.java new file mode 100644 index 00000000..72ae23b0 --- /dev/null +++ b/eco-extensions/precision/src/main/java/com/willfp/ecoenchants/precision/Precision.java @@ -0,0 +1,108 @@ +package com.willfp.ecoenchants.precision; + + +import com.willfp.eco.util.TridentUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.GameMode; +import org.bukkit.entity.Enderman; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Trident; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +@SuppressWarnings("unchecked") +public class Precision extends EcoEnchant { + public Precision() { + super( + "precision", EnchantmentType.SPECIAL + ); + } + + @EventHandler + public void aimingLaunch(@NotNull final ProjectileLaunchEvent event) { + if (!(event.getEntity().getShooter() instanceof Player)) { + return; + } + + if (!(event.getEntity() instanceof Trident)) { + return; + } + + if (event.isCancelled()) { + return; + } + + Player player = (Player) event.getEntity().getShooter(); + Trident trident = (Trident) event.getEntity(); + + ItemStack itemStack = TridentUtils.getItemStack(trident); + if (!EnchantChecks.item(itemStack, this)) { + return; + } + if (this.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + int level = EnchantChecks.getMainhandLevel(player, this); + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level"); + + final double finalDistance = level * multiplier; + Runnable runnable = this.getPlugin().getRunnableFactory().create(bukkitRunnable -> { + List nearbyEntities = (List) (List) Arrays.asList(trident.getNearbyEntities(finalDistance, finalDistance, finalDistance).stream() + .filter(entity -> entity instanceof LivingEntity) + .filter(entity -> !entity.equals(player)) + .filter(entity -> !(entity instanceof Enderman)) + .filter(entity -> { + if (entity instanceof Player) { + return ((Player) entity).getGameMode().equals(GameMode.SURVIVAL) || ((Player) entity).getGameMode().equals(GameMode.ADVENTURE); + } + return true; + }).toArray()); + if (nearbyEntities.isEmpty()) { + return; + } + LivingEntity entity = nearbyEntities.get(0); + double dist = Double.MAX_VALUE; + for (LivingEntity livingEntity : nearbyEntities) { + double currentDistance = livingEntity.getLocation().distance(trident.getLocation()); + if (currentDistance >= dist) { + continue; + } + + dist = currentDistance; + entity = livingEntity; + } + if (entity != null) { + Vector vector = entity.getEyeLocation().toVector().clone().subtract(trident.getLocation().toVector()).normalize(); + trident.setVelocity(vector); + } + }); + + final int period = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "check-ticks"); + final int checks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "checks-per-level") * level; + AtomicInteger checksPerformed = new AtomicInteger(0); + + this.getPlugin().getRunnableFactory().create(bukkitRunnable -> { + checksPerformed.addAndGet(1); + if (checksPerformed.get() > checks) { + bukkitRunnable.cancel(); + } + if (trident.isDead() || trident.isInBlock() || trident.isOnGround()) { + bukkitRunnable.cancel(); + } + this.getPlugin().getScheduler().run(runnable); + }).runTaskTimer(3, period); + } +} diff --git a/eco-extensions/precision/src/main/java/com/willfp/ecoenchants/precision/PrecisionMain.java b/eco-extensions/precision/src/main/java/com/willfp/ecoenchants/precision/PrecisionMain.java new file mode 100644 index 00000000..3b5f59c6 --- /dev/null +++ b/eco-extensions/precision/src/main/java/com/willfp/ecoenchants/precision/PrecisionMain.java @@ -0,0 +1,24 @@ +package com.willfp.ecoenchants.precision; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.extensions.Extension; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import org.jetbrains.annotations.NotNull; + +public class PrecisionMain extends Extension { + public static final EcoEnchant PRECISION = new Precision(); + + public PrecisionMain(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void onEnable() { + // Handled by super + } + + @Override + public void onDisable() { + // Handled by super + } +} diff --git a/eco-extensions/precision/src/main/resources/enchants/special/precision.yml b/eco-extensions/precision/src/main/resources/enchants/special/precision.yml new file mode 100644 index 00000000..01e1e2a3 --- /dev/null +++ b/eco-extensions/precision/src/main/resources/enchants/special/precision.yml @@ -0,0 +1,26 @@ +# +# Precision EcoEnchant +# + +name: "Precision" +description: Tridents hone in on your target. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: special + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 5 + +config: + distance-per-level: 4 # Distance to scan per level + check-ticks: 10 # Ticks between rotations + checks-per-level: 2 # Amount of times to rotate arrow per level (prevents "floating") \ No newline at end of file diff --git a/eco-extensions/precision/src/main/resources/extension.yml b/eco-extensions/precision/src/main/resources/extension.yml new file mode 100644 index 00000000..8da268ac --- /dev/null +++ b/eco-extensions/precision/src/main/resources/extension.yml @@ -0,0 +1,3 @@ +name: Precision +main: com.willfp.ecoenchants.precision.PrecisionMain +version: ${projectVersion} \ No newline at end of file diff --git a/eco-extensions/rainbow/build.gradle b/eco-extensions/rainbow/build.gradle new file mode 100644 index 00000000..03328218 --- /dev/null +++ b/eco-extensions/rainbow/build.gradle @@ -0,0 +1,7 @@ +group 'com.willfp' +version '2.0.0' +description = 'Rainbow Extension' + +shadowJar { + archiveFileName = project.getDescription() + " v" + project.version + ".jar" +} \ No newline at end of file diff --git a/eco-extensions/rainbow/src/main/java/com/willfp/ecoenchants/rainbow/Rainbow.java b/eco-extensions/rainbow/src/main/java/com/willfp/ecoenchants/rainbow/Rainbow.java new file mode 100644 index 00000000..3ca79c63 --- /dev/null +++ b/eco-extensions/rainbow/src/main/java/com/willfp/ecoenchants/rainbow/Rainbow.java @@ -0,0 +1,71 @@ +package com.willfp.ecoenchants.rainbow; + +import com.willfp.eco.core.drops.DropQueue; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class Rainbow extends EcoEnchant { + public Rainbow() { + super( + "rainbow", EnchantmentType.NORMAL + ); + } + + @Override + public void onBlockBreak(@NotNull final Player player, + @NotNull final Block block, + final int level, + @NotNull final BlockBreakEvent event) { + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) { + return; + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + if (!Tag.LEAVES.isTagged(block.getType())) { + return; + } + + event.setDropItems(false); + + Material toDrop; + + List materials = new ArrayList<>(); + + for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "items")) { + Material material = Material.getMaterial(materialName.toUpperCase()); + if (material != null) { + materials.add(material); + } + } + + toDrop = materials.get(new Random().nextInt(materials.size())); + + if (toDrop == null) { + toDrop = block.getType(); + } + + ItemStack item = new ItemStack(toDrop, 1); + + new DropQueue(player) + .setLocation(block.getLocation()) + .addItem(item) + .push(); + } +} diff --git a/eco-extensions/rainbow/src/main/java/com/willfp/ecoenchants/rainbow/RainbowMain.java b/eco-extensions/rainbow/src/main/java/com/willfp/ecoenchants/rainbow/RainbowMain.java new file mode 100644 index 00000000..6694f4a8 --- /dev/null +++ b/eco-extensions/rainbow/src/main/java/com/willfp/ecoenchants/rainbow/RainbowMain.java @@ -0,0 +1,24 @@ +package com.willfp.ecoenchants.rainbow; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.extensions.Extension; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import org.jetbrains.annotations.NotNull; + +public class RainbowMain extends Extension { + public static final EcoEnchant RAINBOW = new Rainbow(); + + public RainbowMain(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void onEnable() { + // Handled by super + } + + @Override + public void onDisable() { + // Handled by super + } +} diff --git a/eco-extensions/rainbow/src/main/resources/enchants/normal/rainbow.yml b/eco-extensions/rainbow/src/main/resources/enchants/normal/rainbow.yml new file mode 100644 index 00000000..2907f83e --- /dev/null +++ b/eco-extensions/rainbow/src/main/resources/enchants/normal/rainbow.yml @@ -0,0 +1,56 @@ +# +# Rainbow EcoEnchant +# + +name: "Rainbow" +description: Chance to drop flowers and dyes from leaves. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + targets: + - axe + - shears + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - silk_touch + maximum-level: 4 + +config: + items: + - white_dye + - orange_dye + - magenta_dye + - light_blue_dye + - yellow_dye + - lime_dye + - pink_dye + - gray_dye + - light_gray_dye + - cyan_dye + - purple_dye + - blue_dye + - brown_dye + - green_dye + - red_dye + - black_dye + - dandelion + - poppy + - blue_orchid + - allium + - azure_bluet + - red_tulip + - orange_tulip + - white_tulip + - pink_tulip + - oxeye_daisy + - cornflower + - lily_of_the_valley + - wither_rose + chance-per-level: 3 # Chance to drop item. \ No newline at end of file diff --git a/eco-extensions/rainbow/src/main/resources/extension.yml b/eco-extensions/rainbow/src/main/resources/extension.yml new file mode 100644 index 00000000..83fa2fda --- /dev/null +++ b/eco-extensions/rainbow/src/main/resources/extension.yml @@ -0,0 +1,3 @@ +name: Rainbow +main: com.willfp.ecoenchants.rainbow.RainbowMain +version: ${projectVersion} \ No newline at end of file diff --git a/eco-extensions/sprint-artifacts/build.gradle b/eco-extensions/sprint-artifacts/build.gradle new file mode 100644 index 00000000..67e681d9 --- /dev/null +++ b/eco-extensions/sprint-artifacts/build.gradle @@ -0,0 +1,7 @@ +group 'com.willfp' +version '5.0.0' +description = 'Sprint Artifacts Extension' + +shadowJar { + archiveFileName = project.getDescription() + " v" + project.version + ".jar" +} \ No newline at end of file diff --git a/eco-extensions/sprint-artifacts/src/main/java/com/willfp/ecoenchants/sprintartifacts/SprintArtifactsListener.java b/eco-extensions/sprint-artifacts/src/main/java/com/willfp/ecoenchants/sprintartifacts/SprintArtifactsListener.java new file mode 100644 index 00000000..f36e2ab7 --- /dev/null +++ b/eco-extensions/sprint-artifacts/src/main/java/com/willfp/ecoenchants/sprintartifacts/SprintArtifactsListener.java @@ -0,0 +1,62 @@ +package com.willfp.ecoenchants.sprintartifacts; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantChecks; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("deprecation") +public class SprintArtifactsListener implements Listener { + @EventHandler + public void onPlayerMove(@NotNull final PlayerMoveEvent event) { + Player player = event.getPlayer(); + + if (!player.isSprinting()) { + return; + } + + if (!player.isOnGround()) { + return; + } + + ItemStack boots = player.getInventory().getBoots(); + if (boots == null) { + return; + } + ItemMeta bootsMeta = boots.getItemMeta(); + if (bootsMeta == null) { + return; + } + + Optional matching = bootsMeta.getEnchants().keySet().stream() + .map(EcoEnchants::getFromEnchantment) + .filter(Objects::nonNull) + .filter(enchantment -> enchantment.getType().equals(EnchantmentType.ARTIFACT)) + .findFirst(); + if (!matching.isPresent()) { + return; + } + Artifact artifact = (Artifact) matching.get(); + + if (!EnchantChecks.boots(player, artifact)) { + return; + } + + if (artifact.getDisabledWorlds().contains(player.getWorld())) { + return; + } + + player.getWorld().spawnParticle(artifact.getParticle(), player.getLocation().add(0, 0.1, 0), 1, 0, 0, 0, 0, artifact.getDustOptions(), true); + } +} diff --git a/eco-extensions/sprint-artifacts/src/main/java/com/willfp/ecoenchants/sprintartifacts/SprintArtifactsMain.java b/eco-extensions/sprint-artifacts/src/main/java/com/willfp/ecoenchants/sprintartifacts/SprintArtifactsMain.java new file mode 100644 index 00000000..0e55fa46 --- /dev/null +++ b/eco-extensions/sprint-artifacts/src/main/java/com/willfp/ecoenchants/sprintartifacts/SprintArtifactsMain.java @@ -0,0 +1,22 @@ +package com.willfp.ecoenchants.sprintartifacts; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.extensions.Extension; +import org.bukkit.Bukkit; +import org.jetbrains.annotations.NotNull; + +public class SprintArtifactsMain extends Extension { + public SprintArtifactsMain(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void onEnable() { + Bukkit.getPluginManager().registerEvents(new SprintArtifactsListener(), this.getPlugin()); + } + + @Override + public void onDisable() { + // Handled by super + } +} diff --git a/eco-extensions/sprint-artifacts/src/main/resources/extension.yml b/eco-extensions/sprint-artifacts/src/main/resources/extension.yml new file mode 100644 index 00000000..242d52c9 --- /dev/null +++ b/eco-extensions/sprint-artifacts/src/main/resources/extension.yml @@ -0,0 +1,3 @@ +name: Sprint Artifacts +main: com.willfp.ecoenchants.sprintartifacts.SprintArtifactsMain +version: ${projectVersion} \ No newline at end of file diff --git a/eco-extensions/summoning/build.gradle b/eco-extensions/summoning/build.gradle new file mode 100644 index 00000000..25240a97 --- /dev/null +++ b/eco-extensions/summoning/build.gradle @@ -0,0 +1,7 @@ +group 'com.willfp' +version '5.0.0' +description = 'Summoning Extension' + +shadowJar { + archiveFileName = project.getDescription() + " v" + project.version + ".jar" +} \ No newline at end of file diff --git a/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningEnchantment.java b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningEnchantment.java new file mode 100644 index 00000000..04c3d768 --- /dev/null +++ b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningEnchantment.java @@ -0,0 +1,133 @@ +package com.willfp.ecoenchants.summoning; + +import com.willfp.eco.core.Prerequisite; +import com.willfp.eco.util.NumberUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Mob; +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.EntityDeathEvent; +import org.bukkit.event.entity.EntityTargetEvent; +import org.jetbrains.annotations.NotNull; + +public abstract class SummoningEnchantment extends EcoEnchant { + private final SummoningType summoningType; + + protected SummoningEnchantment(@NotNull final String key, + @NotNull final EnchantmentType type, + @NotNull final SummoningType summoningType, + @NotNull final Prerequisite... prerequisites) { + super(key, type, prerequisites); + + this.summoningType = summoningType; + } + + public abstract EntityType getEntity(); + + @Override + public void onMeleeAttack(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!summoningType.equals(SummoningType.MELEE)) { + return; + } + + doSpawn(attacker, victim, level); + } + + @Override + public void onArrowDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Arrow arrow, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!summoningType.equals(SummoningType.RANGED)) { + return; + } + + doSpawn(attacker, victim, level); + } + + @Override + public void onTridentDamage(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + @NotNull final Trident trident, + final int level, + @NotNull final EntityDamageByEntityEvent event) { + if (!summoningType.equals(SummoningType.TRIDENT)) { + return; + } + + doSpawn(attacker, victim, level); + } + + private void doSpawn(@NotNull final LivingEntity attacker, + @NotNull final LivingEntity victim, + final int level) { + if (summoningType.equals(SummoningType.MELEE)) { + if (EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) { + return; + } + } + + if (!EnchantmentUtils.passedChance(this, level)) { + return; + } + + if (!victim.getMetadata("eco-target").isEmpty()) { + return; + } + + Location location = victim.getLocation().clone(); + World world = victim.getWorld(); + + int toSpawn = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "mobs-per-level") * level; + int ticksToLive = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-to-live-per-level") * level; + double health = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level") * level; + + for (int i = 0; i < toSpawn; i++) { + Location locToSpawn = location.clone().add(NumberUtils.randFloat(-3, 3), NumberUtils.randFloat(0, 3), NumberUtils.randFloat(-3, 3)); + Mob entity = (Mob) world.spawnEntity(locToSpawn, this.getEntity()); + + entity.setTarget(victim); + if (health > entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { + health = entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); + } + entity.setHealth(health); + entity.setMetadata("eco-target", this.getPlugin().getMetadataValueFactory().create(victim)); + this.getPlugin().getScheduler().runLater(entity::remove, ticksToLive); + } + } + + @EventHandler + public void onSwitchTarget(@NotNull final EntityTargetEvent event) { + if (event.getEntity().getMetadata("eco-target").isEmpty()) { + return; + } + + LivingEntity target = (LivingEntity) event.getEntity().getMetadata("eco-target").get(0).value(); + event.setTarget(target); + } + + @EventHandler(priority = EventPriority.LOW) + public void onDropItem(@NotNull final EntityDeathEvent event) { + if (event.getEntity().getMetadata("eco-target").isEmpty()) { + return; + } + + event.getDrops().clear(); + event.setDroppedExp(0); + } +} diff --git a/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningMain.java b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningMain.java new file mode 100644 index 00000000..0c9be4a9 --- /dev/null +++ b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningMain.java @@ -0,0 +1,33 @@ +package com.willfp.ecoenchants.summoning; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.extensions.Extension; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.summoning.enchants.Crawler; +import com.willfp.ecoenchants.summoning.enchants.Firestorm; +import com.willfp.ecoenchants.summoning.enchants.Ghoul; +import com.willfp.ecoenchants.summoning.enchants.Metallic; +import com.willfp.ecoenchants.summoning.enchants.Mortality; +import org.jetbrains.annotations.NotNull; + +public class SummoningMain extends Extension { + public static final EcoEnchant METALLIC = new Metallic(); + public static final EcoEnchant FIRESTORM = new Firestorm(); + public static final EcoEnchant MORTALITY = new Mortality(); + public static final EcoEnchant GHOUL = new Ghoul(); + public static final EcoEnchant CRAWLER = new Crawler(); + + public SummoningMain(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void onEnable() { + // Handled by super + } + + @Override + public void onDisable() { + // Handled by super + } +} diff --git a/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningType.java b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningType.java new file mode 100644 index 00000000..20f2ea2d --- /dev/null +++ b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningType.java @@ -0,0 +1,7 @@ +package com.willfp.ecoenchants.summoning; + +public enum SummoningType { + MELEE, + RANGED, + TRIDENT +} diff --git a/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Crawler.java b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Crawler.java new file mode 100644 index 00000000..89999425 --- /dev/null +++ b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Crawler.java @@ -0,0 +1,17 @@ +package com.willfp.ecoenchants.summoning.enchants; + +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.summoning.SummoningEnchantment; +import com.willfp.ecoenchants.summoning.SummoningType; +import org.bukkit.entity.EntityType; + +public class Crawler extends SummoningEnchantment { + public Crawler() { + super("crawler", EnchantmentType.NORMAL, SummoningType.TRIDENT); + } + + @Override + public EntityType getEntity() { + return EntityType.CAVE_SPIDER; + } +} diff --git a/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Firestorm.java b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Firestorm.java new file mode 100644 index 00000000..3849de91 --- /dev/null +++ b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Firestorm.java @@ -0,0 +1,17 @@ +package com.willfp.ecoenchants.summoning.enchants; + +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.summoning.SummoningEnchantment; +import com.willfp.ecoenchants.summoning.SummoningType; +import org.bukkit.entity.EntityType; + +public class Firestorm extends SummoningEnchantment { + public Firestorm() { + super("firestorm", EnchantmentType.NORMAL, SummoningType.MELEE); + } + + @Override + public EntityType getEntity() { + return EntityType.BLAZE; + } +} diff --git a/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Ghoul.java b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Ghoul.java new file mode 100644 index 00000000..00c1ce48 --- /dev/null +++ b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Ghoul.java @@ -0,0 +1,17 @@ +package com.willfp.ecoenchants.summoning.enchants; + +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.summoning.SummoningEnchantment; +import com.willfp.ecoenchants.summoning.SummoningType; +import org.bukkit.entity.EntityType; + +public class Ghoul extends SummoningEnchantment { + public Ghoul() { + super("ghoul", EnchantmentType.NORMAL, SummoningType.RANGED); + } + + @Override + public EntityType getEntity() { + return EntityType.ZOMBIE; + } +} diff --git a/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Metallic.java b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Metallic.java new file mode 100644 index 00000000..a1941965 --- /dev/null +++ b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Metallic.java @@ -0,0 +1,17 @@ +package com.willfp.ecoenchants.summoning.enchants; + +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.summoning.SummoningEnchantment; +import com.willfp.ecoenchants.summoning.SummoningType; +import org.bukkit.entity.EntityType; + +public class Metallic extends SummoningEnchantment { + public Metallic() { + super("metallic", EnchantmentType.SPECIAL, SummoningType.MELEE); + } + + @Override + public EntityType getEntity() { + return EntityType.IRON_GOLEM; + } +} diff --git a/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Mortality.java b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Mortality.java new file mode 100644 index 00000000..e366b660 --- /dev/null +++ b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Mortality.java @@ -0,0 +1,17 @@ +package com.willfp.ecoenchants.summoning.enchants; + +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.summoning.SummoningEnchantment; +import com.willfp.ecoenchants.summoning.SummoningType; +import org.bukkit.entity.EntityType; + +public class Mortality extends SummoningEnchantment { + public Mortality() { + super("mortality", EnchantmentType.NORMAL, SummoningType.RANGED); + } + + @Override + public EntityType getEntity() { + return EntityType.WITHER_SKELETON; + } +} diff --git a/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Sniper.java b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Sniper.java new file mode 100644 index 00000000..0f452cba --- /dev/null +++ b/eco-extensions/summoning/src/main/java/com/willfp/ecoenchants/summoning/enchants/Sniper.java @@ -0,0 +1,17 @@ +package com.willfp.ecoenchants.summoning.enchants; + +import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import com.willfp.ecoenchants.summoning.SummoningEnchantment; +import com.willfp.ecoenchants.summoning.SummoningType; +import org.bukkit.entity.EntityType; + +public class Sniper extends SummoningEnchantment { + public Sniper() { + super("sniper", EnchantmentType.NORMAL, SummoningType.TRIDENT); + } + + @Override + public EntityType getEntity() { + return EntityType.SKELETON; + } +} diff --git a/eco-extensions/summoning/src/main/resources/enchants/normal/crawler.yml b/eco-extensions/summoning/src/main/resources/enchants/normal/crawler.yml new file mode 100644 index 00000000..101ff194 --- /dev/null +++ b/eco-extensions/summoning/src/main/resources/enchants/normal/crawler.yml @@ -0,0 +1,28 @@ +# +# Crawler EcoEnchant +# + +name: "Crawler" +description: Spawns cave spiders to attack your target. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - sniper + maximum-level: 3 + +config: + mobs-per-level: 2 # Amount of mobs to spawn per level + ticks-to-live-per-level: 30 # Ticks for mob to live per level + health-per-level: 6 # Health for mobs to have per level + chance-per-level: 5 # Chance to spawn mobs per level \ No newline at end of file diff --git a/eco-extensions/summoning/src/main/resources/enchants/normal/firestorm.yml b/eco-extensions/summoning/src/main/resources/enchants/normal/firestorm.yml new file mode 100644 index 00000000..e9a99db0 --- /dev/null +++ b/eco-extensions/summoning/src/main/resources/enchants/normal/firestorm.yml @@ -0,0 +1,29 @@ +# +# Firestorm EcoEnchant +# + +name: "Firestorm" +description: Spawns blazes to attack your target. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - metallic + maximum-level: 3 + +config: + mobs-per-level: 2 # Amount of mobs to spawn per level + ticks-to-live-per-level: 50 # Ticks for mob to live per level + health-per-level: 4 # Health for mobs to have per level + chance-per-level: 5 # Chance to spawn mobs per level + allow-not-fully-charged: false # don't require sword attack to be at full charge \ No newline at end of file diff --git a/eco-extensions/summoning/src/main/resources/enchants/normal/ghoul.yml b/eco-extensions/summoning/src/main/resources/enchants/normal/ghoul.yml new file mode 100644 index 00000000..5d5e07e3 --- /dev/null +++ b/eco-extensions/summoning/src/main/resources/enchants/normal/ghoul.yml @@ -0,0 +1,29 @@ +# +# Ghoul EcoEnchant +# + +name: "Ghoul" +description: Spawns zombies to attack your target. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - mortality + maximum-level: 4 + +config: + mobs-per-level: 1 # Amount of mobs to spawn per level + ticks-to-live-per-level: 30 # Ticks for mob to live per level + health-per-level: 4 # Health for mobs to have per level + chance-per-level: 5 # Chance to spawn mobs per level \ No newline at end of file diff --git a/eco-extensions/summoning/src/main/resources/enchants/normal/mortality.yml b/eco-extensions/summoning/src/main/resources/enchants/normal/mortality.yml new file mode 100644 index 00000000..3f677242 --- /dev/null +++ b/eco-extensions/summoning/src/main/resources/enchants/normal/mortality.yml @@ -0,0 +1,29 @@ +# +# Mortality EcoEnchant +# + +name: "Mortality" +description: Spawns wither skeletons to attack your target. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - bow + - crossbow + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - ghoul + maximum-level: 4 + +config: + mobs-per-level: 1 # Amount of mobs to spawn per level + ticks-to-live-per-level: 30 # Ticks for mob to live per level + health-per-level: 6 # Health for mobs to have per level + chance-per-level: 5 # Chance to spawn mobs per level \ No newline at end of file diff --git a/eco-extensions/summoning/src/main/resources/enchants/normal/sniper.yml b/eco-extensions/summoning/src/main/resources/enchants/normal/sniper.yml new file mode 100644 index 00000000..3705f26e --- /dev/null +++ b/eco-extensions/summoning/src/main/resources/enchants/normal/sniper.yml @@ -0,0 +1,28 @@ +# +# Sniper EcoEnchant +# + +name: "Sniper" +description: Spawns skeletons to attack your target. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - trident + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - crawler + maximum-level: 3 + +config: + mobs-per-level: 2 # Amount of mobs to spawn per level + ticks-to-live-per-level: 40 # Ticks for mob to live per level + health-per-level: 4 # Health for mobs to have per level + chance-per-level: 5 # Chance to spawn mobs per level \ No newline at end of file diff --git a/eco-extensions/summoning/src/main/resources/enchants/special/metallic.yml b/eco-extensions/summoning/src/main/resources/enchants/special/metallic.yml new file mode 100644 index 00000000..6ebda7bb --- /dev/null +++ b/eco-extensions/summoning/src/main/resources/enchants/special/metallic.yml @@ -0,0 +1,29 @@ +# +# Metallic EcoEnchant +# + +name: "Metallic" +description: Spawns iron golems to attack your target. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: veryspecial + +general-config: + targets: + - sword + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: + - firestorm + maximum-level: 2 + +config: + mobs-per-level: 1 # Amount of mobs to spawn per level + ticks-to-live-per-level: 20 # Ticks for mob to live per level + health-per-level: 4 # Health for mobs to have per level + chance-per-level: 5 # Chance to spawn mobs per level + allow-not-fully-charged: false # don't require sword attack to be at full charge \ No newline at end of file diff --git a/eco-extensions/summoning/src/main/resources/extension.yml b/eco-extensions/summoning/src/main/resources/extension.yml new file mode 100644 index 00000000..7f5b52f0 --- /dev/null +++ b/eco-extensions/summoning/src/main/resources/extension.yml @@ -0,0 +1,3 @@ +name: Summoning +main: com.willfp.ecoenchants.summoning.SummoningMain +version: ${projectVersion} \ No newline at end of file diff --git a/eco-extensions/xray/build.gradle b/eco-extensions/xray/build.gradle new file mode 100644 index 00000000..9557b876 --- /dev/null +++ b/eco-extensions/xray/build.gradle @@ -0,0 +1,7 @@ +group 'com.willfp' +version '3.0.0' +description = 'Xray Extension' + +shadowJar { + archiveFileName = project.getDescription() + " v" + project.version + ".jar" +} \ No newline at end of file diff --git a/eco-extensions/xray/src/main/java/com/willfp/ecoenchants/xray/Xray.java b/eco-extensions/xray/src/main/java/com/willfp/ecoenchants/xray/Xray.java new file mode 100644 index 00000000..248c539b --- /dev/null +++ b/eco-extensions/xray/src/main/java/com/willfp/ecoenchants/xray/Xray.java @@ -0,0 +1,134 @@ +package com.willfp.ecoenchants.xray; + +import com.willfp.eco.util.TeamUtils; +import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.enchantments.itemtypes.Spell; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Shulker; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.metadata.MetadataValue; +import org.bukkit.scoreboard.Team; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +public class Xray extends Spell { + public Xray() { + super("xray"); + } + + @Override + public boolean onUse(@NotNull final Player player, + final int level, + @NotNull final PlayerInteractEvent event) { + Block block = event.getClickedBlock(); + + if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { + return false; + } + + Location location; + + if (block == null) { + location = player.getLocation(); + } else { + location = block.getLocation(); + } + + Set toReveal = new HashSet<>(); + + int size = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "blocks-per-level") * level; + + int ticks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks"); + + List materials = new ArrayList<>(); + + for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks")) { + Material material = Material.getMaterial(materialName.toUpperCase()); + if (material != null) { + materials.add(material); + } + } + + for (int x = -size; x <= size; x++) { + for (int y = -size; y <= size; y++) { + for (int z = -size; z <= size; z++) { + Block block1 = location.getWorld().getBlockAt(location.clone().add(x, y, z)); + + if (!materials.contains(block1.getType())) { + continue; + } + + toReveal.add(block1); + } + } + } + + toReveal.forEach(block1 -> { + Shulker shulker = (Shulker) block1.getWorld().spawnEntity(block1.getLocation(), EntityType.SHULKER); + shulker.setInvulnerable(true); + shulker.setSilent(true); + shulker.setAI(false); + shulker.setGravity(false); + shulker.setGlowing(true); + shulker.setInvisible(true); + shulker.setMetadata("xray-shulker", this.getPlugin().getMetadataValueFactory().create(true)); + + block1.setMetadata("xray-uuid", this.getPlugin().getMetadataValueFactory().create(shulker.getUniqueId())); + + if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "color-glow")) { + Team team = TeamUtils.getMaterialColorTeam(block1.getType()); + team.addEntry(shulker.getUniqueId().toString()); + } + + this.getPlugin().getScheduler().runLater(() -> { + shulker.remove(); + block1.removeMetadata("xray-uuid", this.getPlugin()); + }, ticks); + }); + + return true; + } + + @EventHandler + public void onBlockBreak(@NotNull final BlockBreakEvent event) { + Block block = event.getBlock(); + + if (!block.hasMetadata("xray-uuid")) { + return; + } + + for (MetadataValue meta : block.getMetadata("xray-uuid")) { + if (!(meta.value() instanceof UUID)) { + continue; + } + + UUID uuid = (UUID) meta.value(); + + assert uuid != null; + + Entity entity = Bukkit.getServer().getEntity(uuid); + + if (entity != null) { + entity.remove(); + } + } + + for (Entity shulkerEntity : block.getLocation().getWorld().getNearbyEntities(block.getLocation(), 2, 2, 2, entity -> entity.hasMetadata("xray-shulker"))) { + shulkerEntity.remove(); + } + } +} diff --git a/eco-extensions/xray/src/main/java/com/willfp/ecoenchants/xray/XrayMain.java b/eco-extensions/xray/src/main/java/com/willfp/ecoenchants/xray/XrayMain.java new file mode 100644 index 00000000..044e3864 --- /dev/null +++ b/eco-extensions/xray/src/main/java/com/willfp/ecoenchants/xray/XrayMain.java @@ -0,0 +1,24 @@ +package com.willfp.ecoenchants.xray; + +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.extensions.Extension; +import com.willfp.ecoenchants.enchantments.EcoEnchant; +import org.jetbrains.annotations.NotNull; + +public class XrayMain extends Extension { + public static final EcoEnchant XRAY = new Xray(); + + public XrayMain(@NotNull final EcoPlugin plugin) { + super(plugin); + } + + @Override + public void onEnable() { + // Handled by super + } + + @Override + public void onDisable() { + // Handled by super + } +} diff --git a/eco-extensions/xray/src/main/resources/enchants/spell/xray.yml b/eco-extensions/xray/src/main/resources/enchants/spell/xray.yml new file mode 100644 index 00000000..2ebd87ae --- /dev/null +++ b/eco-extensions/xray/src/main/resources/enchants/spell/xray.yml @@ -0,0 +1,36 @@ +# +# Xray EcoEnchant +# + +name: "Xray" +description: Glow nearby ores through walls. +enabled: true + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + targets: + - pickaxe + grindstoneable: true + disabled-in-worlds: [ ] + conflicts: [ ] + maximum-level: 3 + +config: + activation-sound: ENTITY_ENDERMAN_TELEPORT + cooldown: 40 # In seconds + blocks: + - coal_ore + - iron_ore + - gold_ore + - redstone_ore + - lapis_ore + - ancient_debris + - diamond_ore + blocks-per-level: 3 # Blocks on all sides to scan per level + ticks: 60 + color-glow: true # Color ore glow based on ore type. \ No newline at end of file diff --git a/eco-extensions/xray/src/main/resources/extension.yml b/eco-extensions/xray/src/main/resources/extension.yml new file mode 100644 index 00000000..9c0f6b20 --- /dev/null +++ b/eco-extensions/xray/src/main/resources/extension.yml @@ -0,0 +1,3 @@ +name: Xray +main: com.willfp.ecoenchants.xray.XrayMain +version: ${projectVersion} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 40e1ab57..f72d0cd4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 1.0.0 -plugin-name = EcoSkills \ No newline at end of file +version = 7.2.5 +plugin-name = EcoEnchants \ No newline at end of file