From 1f4b54daca3faebaf8ee8aba5ec410a32e7a38b8 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 22 Dec 2020 02:50:27 +0000 Subject: [PATCH] Continued overhaul --- Plugin/build.gradle | 0 .../willfp/ecoenchants/EcoEnchantsPlugin.java | 64 -- .../ecoenchants/command/AbstractCommand.java | 71 --- .../command/AbstractTabCompleter.java | 31 - .../command/commands/CommandEcodebug.java | 112 ---- .../command/commands/CommandEcoreload.java | 20 - .../command/commands/CommandEnchantinfo.java | 132 ----- .../TabCompleterEnchantinfo.java | 51 -- .../ecoenchants/config/ConfigManager.java | 99 ---- .../config/EnchantmentYamlConfig.java | 121 ---- .../config/UpdatingYamlConfig.java | 73 --- .../ecoenchants/config/configs/Config.java | 55 -- .../config/configs/EnchantmentConfig.java | 118 ---- .../ecoenchants/config/configs/Lang.java | 36 -- .../ecoenchants/config/configs/Rarity.java | 55 -- .../ecoenchants/config/configs/Target.java | 29 - .../display/AbstractPacketAdapter.java | 59 -- .../ecoenchants/display/EnchantDisplay.java | 247 -------- .../ecoenchants/display/EnchantmentCache.java | 140 ----- .../display/options/DescriptionOptions.java | 34 -- .../display/options/DisplayOptions.java | 102 ---- .../display/options/NumbersOptions.java | 25 - .../display/options/ShrinkOptions.java | 33 -- .../options/interfaces/ThresholdedOption.java | 5 - .../options/interfaces/ToggleableOption.java | 5 - .../options/interfaces/UpdateableOption.java | 5 - .../options/sorting/EnchantmentSorter.java | 10 - .../options/sorting/SortParameters.java | 7 - .../options/sorting/SorterManager.java | 36 -- .../implementations/AlphabeticSorter.java | 20 - .../sorting/implementations/LengthSorter.java | 21 - .../RarityAlphabeticSorter.java | 33 -- .../implementations/RarityLengthSorter.java | 34 -- .../RarityTypeAlphabeticSorter.java | 39 -- .../RarityTypeLengthSorter.java | 40 -- .../implementations/TypeAlphabeticSorter.java | 33 -- .../implementations/TypeLengthSorter.java | 34 -- .../display/packets/PacketChat.java | 27 - .../packets/PacketOpenWindowMerchant.java | 71 --- .../packets/PacketSetCreativeSlot.java | 20 - .../display/packets/PacketSetSlot.java | 30 - .../display/packets/PacketWindowItems.java | 33 -- .../ecoenchants/enchantments/EcoEnchant.java | 555 ------------------ .../ecoenchants/enchantments/EcoEnchants.java | 384 ------------ .../ecoenchants/artifact/AshArtifact.java | 19 - .../ecoenchants/artifact/CloudsArtifact.java | 22 - .../ecoenchants/artifact/CrimsonArtifact.java | 19 - .../ecoenchants/artifact/DamageArtifact.java | 16 - .../ecoenchants/artifact/DragonArtifact.java | 16 - .../ecoenchants/artifact/DustArtifact.java | 16 - .../ecoenchants/artifact/EmeraldArtifact.java | 16 - .../artifact/EnchantmentArtifact.java | 16 - .../ecoenchants/artifact/EndArtifact.java | 16 - .../ecoenchants/artifact/FireArtifact.java | 16 - .../ecoenchants/artifact/HeartArtifact.java | 16 - .../ecoenchants/artifact/HoneyArtifact.java | 16 - .../ecoenchants/artifact/InkArtifact.java | 16 - .../ecoenchants/artifact/LavaArtifact.java | 16 - .../ecoenchants/artifact/LimeArtifact.java | 23 - .../ecoenchants/artifact/MagicArtifact.java | 16 - .../ecoenchants/artifact/MagmaArtifact.java | 16 - .../ecoenchants/artifact/MusicArtifact.java | 16 - .../ecoenchants/artifact/NetherArtifact.java | 16 - .../artifact/RedstoneArtifact.java | 22 - .../ecoenchants/artifact/SmokeArtifact.java | 16 - .../ecoenchants/artifact/SnowArtifact.java | 16 - .../ecoenchants/artifact/SoulArtifact.java | 19 - .../artifact/SoulFireArtifact.java | 19 - .../ecoenchants/artifact/SparkleArtifact.java | 16 - .../ecoenchants/artifact/TearArtifact.java | 19 - .../ecoenchants/artifact/TotemArtifact.java | 16 - .../ecoenchants/artifact/WarpedArtifact.java | 19 - .../ecoenchants/artifact/WaterArtifact.java | 16 - .../ecoenchants/artifact/WitchArtifact.java | 16 - .../ecoenchants/artifact/ZapArtifact.java | 22 - .../ecoenchants/curse/BreaklessnessCurse.java | 26 - .../ecoenchants/curse/CallingCurse.java | 83 --- .../ecoenchants/curse/DecayCurse.java | 103 ---- .../ecoenchants/curse/FragilityCurse.java | 33 -- .../ecoenchants/curse/HarmlessnessCurse.java | 26 - .../ecoenchants/curse/HungerCurse.java | 35 -- .../ecoenchants/curse/InaccuracyCurse.java | 30 - .../ecoenchants/curse/MisfortuneCurse.java | 26 - .../ecoenchants/curse/PermanenceCurse.java | 15 - .../ecoenchants/normal/Abattoir.java | 28 - .../ecoenchants/normal/Abrasion.java | 55 -- .../ecoenchants/normal/Aerial.java | 40 -- .../ecoenchants/normal/Aquatic.java | 29 - .../ecoenchants/normal/Arachnid.java | 29 - .../ecoenchants/normal/Arcanic.java | 27 - .../ecoenchants/normal/Atmospheric.java | 37 -- .../ecoenchants/normal/Backstab.java | 36 -- .../ecoenchants/normal/Beheading.java | 74 --- .../ecoenchants/normal/BlastMining.java | 76 --- .../ecoenchants/normal/Bleed.java | 52 -- .../ecoenchants/normal/Blind.java | 34 -- .../ecoenchants/normal/BlockBreather.java | 29 - .../ecoenchants/normal/BossHunter.java | 29 - .../ecoenchants/normal/Buckshot.java | 49 -- .../ecoenchants/normal/Butchering.java | 25 - .../ecoenchants/normal/Cerebral.java | 31 - .../ecoenchants/normal/Chopless.java | 31 - .../ecoenchants/normal/Cleave.java | 46 -- .../ecoenchants/normal/Collateral.java | 21 - .../ecoenchants/normal/Conclude.java | 32 - .../ecoenchants/normal/Corrosive.java | 51 -- .../ecoenchants/normal/Cranial.java | 28 - .../ecoenchants/normal/Criticals.java | 34 -- .../ecoenchants/normal/Cubism.java | 28 - .../ecoenchants/normal/Defender.java | 30 - .../ecoenchants/normal/Deflection.java | 26 - .../ecoenchants/normal/Defusion.java | 25 - .../ecoenchants/normal/Dexterous.java | 38 -- .../ecoenchants/normal/Disable.java | 35 -- .../ecoenchants/normal/Disappear.java | 31 - .../ecoenchants/normal/Diurnal.java | 29 - .../ecoenchants/normal/Diverse.java | 28 - .../ecoenchants/normal/Drill.java | 56 -- .../ecoenchants/normal/Dullness.java | 35 -- .../ecoenchants/normal/Dweller.java | 28 - .../ecoenchants/normal/Economical.java | 27 - .../ecoenchants/normal/Electroshock.java | 28 - .../ecoenchants/normal/EndInfusion.java | 28 - .../ecoenchants/normal/EnderSlayer.java | 36 -- .../ecoenchants/normal/Enderism.java | 55 -- .../ecoenchants/normal/Evasion.java | 25 - .../ecoenchants/normal/Extinguishing.java | 27 - .../ecoenchants/normal/Extract.java | 29 - .../ecoenchants/normal/Famine.java | 37 -- .../ecoenchants/normal/Farmhand.java | 86 --- .../ecoenchants/normal/Fetching.java | 62 -- .../ecoenchants/normal/Finality.java | 32 - .../ecoenchants/normal/Finishing.java | 30 - .../ecoenchants/normal/FireAffinity.java | 26 - .../ecoenchants/normal/FirstStrike.java | 27 - .../ecoenchants/normal/Flinch.java | 33 -- .../ecoenchants/normal/Forcefield.java | 79 --- .../ecoenchants/normal/Freerunner.java | 25 - .../ecoenchants/normal/Frozen.java | 54 -- .../enchantments/ecoenchants/normal/Fury.java | 51 -- .../ecoenchants/normal/Goliath.java | 34 -- .../ecoenchants/normal/Graceful.java | 46 -- .../ecoenchants/normal/Grapple.java | 28 - .../ecoenchants/normal/GreenThumb.java | 47 -- .../enchantments/ecoenchants/normal/Grit.java | 49 -- .../ecoenchants/normal/Hellish.java | 29 - .../enchantments/ecoenchants/normal/Hook.java | 29 - .../ecoenchants/normal/Horde.java | 29 - .../ecoenchants/normal/IceShot.java | 30 - .../ecoenchants/normal/Identify.java | 33 -- .../ecoenchants/normal/Ignite.java | 48 -- .../ecoenchants/normal/IllusionAspect.java | 36 -- .../ecoenchants/normal/Impact.java | 28 - .../ecoenchants/normal/Incandescence.java | 42 -- .../ecoenchants/normal/InfernalTouch.java | 108 ---- .../ecoenchants/normal/Inferno.java | 29 - .../ecoenchants/normal/Infuriate.java | 45 -- .../ecoenchants/normal/Insecticide.java | 30 - .../ecoenchants/normal/Instantaneous.java | 33 -- .../ecoenchants/normal/Invigoration.java | 60 -- .../ecoenchants/normal/Kinetic.java | 25 - .../ecoenchants/normal/Launch.java | 47 -- .../ecoenchants/normal/Leeching.java | 28 - .../ecoenchants/normal/Lesion.java | 48 -- .../ecoenchants/normal/Levitate.java | 32 - .../ecoenchants/normal/LiquidShot.java | 28 - .../ecoenchants/normal/Lumberjack.java | 62 -- .../ecoenchants/normal/MagmaWalker.java | 92 --- .../ecoenchants/normal/Magnetic.java | 87 --- .../ecoenchants/normal/Marking.java | 48 -- .../ecoenchants/normal/Marksman.java | 50 -- .../ecoenchants/normal/Necrotic.java | 48 -- .../ecoenchants/normal/NetherInfusion.java | 27 - .../ecoenchants/normal/Netheric.java | 29 - .../ecoenchants/normal/Nocturnal.java | 30 - .../ecoenchants/normal/Optics.java | 32 - .../ecoenchants/normal/Oxygenate.java | 30 - .../ecoenchants/normal/Pacify.java | 29 - .../ecoenchants/normal/Paladin.java | 27 - .../ecoenchants/normal/Paralyze.java | 33 -- .../ecoenchants/normal/Parasitic.java | 29 - .../ecoenchants/normal/Parry.java | 40 -- .../ecoenchants/normal/Phantasm.java | 30 - .../ecoenchants/normal/Plasmic.java | 65 -- .../ecoenchants/normal/Protector.java | 26 - .../ecoenchants/normal/Proximity.java | 31 - .../ecoenchants/normal/Puncture.java | 30 - .../ecoenchants/normal/Quadrilateralism.java | 31 - .../ecoenchants/normal/Radiance.java | 36 -- .../enchantments/ecoenchants/normal/Rage.java | 45 -- .../ecoenchants/normal/Rapid.java | 29 - .../enchantments/ecoenchants/normal/Reel.java | 50 -- .../ecoenchants/normal/Reinforcement.java | 25 - .../ecoenchants/normal/Rejuvenation.java | 40 -- .../ecoenchants/normal/Replenish.java | 56 -- .../ecoenchants/normal/Respirator.java | 28 - .../ecoenchants/normal/Revenant.java | 30 - .../ecoenchants/normal/Sating.java | 36 -- .../ecoenchants/normal/Serrated.java | 25 - .../ecoenchants/normal/Settle.java | 29 - .../ecoenchants/normal/Shockwave.java | 70 --- .../ecoenchants/normal/ShotAssist.java | 46 -- .../ecoenchants/normal/Sickening.java | 33 -- .../ecoenchants/normal/Slaughter.java | 29 - .../ecoenchants/normal/Slicing.java | 59 -- .../ecoenchants/normal/Spearfishing.java | 71 --- .../ecoenchants/normal/Spiked.java | 45 -- .../ecoenchants/normal/Splash.java | 66 --- .../enchantments/ecoenchants/normal/Stab.java | 26 - .../ecoenchants/normal/Stalwart.java | 35 -- .../ecoenchants/normal/Stamina.java | 37 -- .../ecoenchants/normal/StoneSwitcher.java | 51 -- .../ecoenchants/normal/StrayAspect.java | 36 -- .../ecoenchants/normal/Succession.java | 45 -- .../ecoenchants/normal/Supercritical.java | 32 - .../ecoenchants/normal/Sycophant.java | 29 - .../ecoenchants/normal/Tectonic.java | 44 -- .../ecoenchants/normal/Telekinesis.java | 148 ----- .../enchantments/ecoenchants/normal/Thor.java | 36 -- .../ecoenchants/normal/Thrive.java | 57 -- .../ecoenchants/normal/Tornado.java | 31 - .../ecoenchants/normal/Toxic.java | 35 -- .../ecoenchants/normal/Transfuse.java | 56 -- .../ecoenchants/normal/Tripleshot.java | 37 -- .../ecoenchants/normal/VampireAspect.java | 34 -- .../enchantments/ecoenchants/normal/Vein.java | 62 -- .../ecoenchants/normal/Venom.java | 28 - .../ecoenchants/normal/VoidAffinity.java | 29 - .../ecoenchants/normal/Voltage.java | 56 -- .../ecoenchants/normal/WaterAffinity.java | 28 - .../ecoenchants/normal/WaterAspect.java | 31 - .../ecoenchants/normal/Weakening.java | 47 -- .../ecoenchants/normal/Wisdom.java | 32 - .../ecoenchants/normal/Wound.java | 48 -- .../enchantments/ecoenchants/normal/Zeus.java | 30 - .../ecoenchants/special/Aiming.java | 111 ---- .../ecoenchants/special/Annihilate.java | 28 - .../ecoenchants/special/Bladed.java | 26 - .../ecoenchants/special/Bolt.java | 34 -- .../ecoenchants/special/Carve.java | 46 -- .../ecoenchants/special/Confusion.java | 48 -- .../ecoenchants/special/Energizing.java | 27 - .../ecoenchants/special/Force.java | 26 - .../ecoenchants/special/Frenzy.java | 37 -- .../ecoenchants/special/Harpoon.java | 45 -- .../special/Indestructibility.java | 35 -- .../ecoenchants/special/Instability.java | 53 -- .../ecoenchants/special/Intellect.java | 32 - .../ecoenchants/special/LifeSteal.java | 28 - .../ecoenchants/special/Pentashot.java | 37 -- .../ecoenchants/special/Preservation.java | 27 - .../ecoenchants/special/Prosperity.java | 13 - .../ecoenchants/special/Razor.java | 32 - .../ecoenchants/special/Repairing.java | 103 ---- .../ecoenchants/special/Soulbound.java | 73 --- .../ecoenchants/special/Spring.java | 30 - .../ecoenchants/special/Streamlining.java | 26 - .../ecoenchants/special/Volatile.java | 49 -- .../ecoenchants/spell/Ascend.java | 38 -- .../ecoenchants/spell/Charge.java | 22 - .../ecoenchants/spell/Dynamite.java | 76 --- .../ecoenchants/spell/Missile.java | 47 -- .../enchantments/ecoenchants/spell/Quake.java | 36 -- .../ecoenchants/spell/Vitalize.java | 17 - .../enchantments/itemtypes/Artifact.java | 166 ------ .../enchantments/itemtypes/Spell.java | 121 ---- .../enchantments/meta/EnchantmentRarity.java | 179 ------ .../enchantments/meta/EnchantmentTarget.java | 99 ---- .../support/merging/anvil/AnvilListeners.java | 108 ---- .../support/merging/anvil/AnvilMerge.java | 233 -------- .../grindstone/GrindstoneListeners.java | 64 -- .../merging/grindstone/GrindstoneMerge.java | 55 -- .../obtaining/EnchantingListeners.java | 234 -------- .../support/obtaining/LootPopulator.java | 118 ---- .../support/obtaining/VillagerListeners.java | 170 ------ .../enchantments/util/EnchantChecks.java | 418 ------------- .../enchantments/util/EnchantmentUtils.java | 55 -- .../enchantments/util/SpellRunnable.java | 39 -- .../enchantments/util/Watcher.java | 56 -- .../enchantments/util/WatcherTriggers.java | 380 ------------ .../events/armorequip/ArmorEquipEvent.java | 124 ---- .../events/armorequip/ArmorListener.java | 201 ------- .../events/armorequip/ArmorType.java | 38 -- .../armorequip/DispenserArmorListener.java | 28 - .../EntityDeathByEntityBuilder.java | 58 -- .../EntityDeathByEntityEvent.java | 115 ---- .../EntityDeathByEntityListeners.java | 69 --- .../NaturalExpGainBuilder.java | 56 -- .../NaturalExpGainEvent.java | 46 -- .../NaturalExpGainListeners.java | 44 -- .../ecoenchants/integrations/Integration.java | 12 - .../anticheat/AnticheatManager.java | 49 -- .../anticheat/AnticheatWrapper.java | 23 - .../anticheat/plugins/AnticheatAAC.java | 28 - .../anticheat/plugins/AnticheatMatrix.java | 40 -- .../anticheat/plugins/AnticheatNCP.java | 37 -- .../anticheat/plugins/AnticheatSpartan.java | 40 -- .../antigrief/AntigriefManager.java | 66 --- .../antigrief/AntigriefWrapper.java | 48 -- .../plugins/AntigriefFactionsUUID.java | 66 --- .../plugins/AntigriefGriefPrevention.java | 56 -- .../antigrief/plugins/AntigriefKingdoms.java | 60 -- .../antigrief/plugins/AntigriefLands.java | 64 -- .../antigrief/plugins/AntigriefTowny.java | 50 -- .../plugins/AntigriefWorldGuard.java | 80 --- .../essentials/EssentialsManager.java | 27 - .../essentials/EssentialsWrapper.java | 13 - .../plugins/IntegrationEssentials.java | 29 - .../integrations/mcmmo/McmmoIntegration.java | 14 - .../integrations/mcmmo/McmmoManager.java | 41 -- .../mcmmo/plugins/McmmoIntegrationImpl.java | 20 - .../placeholder/PlaceholderEntry.java | 65 -- .../placeholder/PlaceholderIntegration.java | 24 - .../placeholder/PlaceholderManager.java | 67 --- .../plugins/PlaceholderIntegrationPAPI.java | 59 -- .../worldguard/WorldguardManager.java | 59 -- .../worldguard/WorldguardWrapper.java | 10 - .../plugins/WorldguardIntegrationImpl.java | 29 - .../willfp/ecoenchants/nms/BlockBreak.java | 37 -- .../willfp/ecoenchants/nms/ChatComponent.java | 40 -- .../com/willfp/ecoenchants/nms/Cooldown.java | 38 -- .../ecoenchants/nms/FastGetEnchants.java | 50 -- .../willfp/ecoenchants/nms/OpenInventory.java | 37 -- .../willfp/ecoenchants/nms/RepairCost.java | 49 -- .../willfp/ecoenchants/nms/TridentStack.java | 39 -- .../willfp/ecoenchants/util/BlockUtils.java | 38 -- .../willfp/ecoenchants/util/ClassUtils.java | 21 - .../ecoenchants/util/DurabilityUtils.java | 112 ---- .../ecoenchants/util/LightningUtils.java | 26 - .../willfp/ecoenchants/util/NumberUtils.java | 157 ----- .../willfp/ecoenchants/util/StringUtils.java | 99 ---- .../willfp/ecoenchants/util/VectorUtils.java | 146 ----- .../ecoenchants/util/interfaces/Callable.java | 9 - .../util/interfaces/EcoRunnable.java | 8 - .../util/interfaces/ObjectBiCallable.java | 12 - .../util/interfaces/ObjectCallable.java | 11 - .../util/internal/ArrowListeners.java | 40 -- .../ecoenchants/util/internal/DropQueue.java | 110 ---- .../ecoenchants/util/internal/Loader.java | 405 ------------- .../ecoenchants/util/internal/Logger.java | 39 -- .../internal/drops/AbstractDropQueue.java | 66 --- .../internal/drops/FastCollatedDropQueue.java | 115 ---- .../internal/drops/InternalDropQueue.java | 169 ------ .../util/optional/Prerequisite.java | 90 --- .../willfp/ecoenchants/util/tuplets/Pair.java | 64 -- .../ecoenchants/util/tuplets/Triplet.java | 86 --- .../willfp/ecoenchants/EcoEnchantsPlugin.java | 2 +- .../ecoenchants/config/ConfigManager.java | 4 +- .../config/EnchantmentYamlConfig.java | 8 +- .../ecoenchants/display/EnchantmentCache.java | 10 +- .../display/options/DescriptionOptions.java | 8 +- .../display/options/DisplayOptions.java | 12 +- .../display/options/NumbersOptions.java | 6 +- .../display/options/ShrinkOptions.java | 8 +- .../ecoenchants/enchantments/EcoEnchant.java | 13 +- .../ecoenchants/artifact/AshArtifact.java | 2 +- .../ecoenchants/artifact/CrimsonArtifact.java | 2 +- .../ecoenchants/artifact/SoulArtifact.java | 2 +- .../artifact/SoulFireArtifact.java | 2 +- .../ecoenchants/artifact/TearArtifact.java | 2 +- .../ecoenchants/artifact/WarpedArtifact.java | 2 +- .../ecoenchants/curse/CallingCurse.java | 6 +- .../ecoenchants/curse/DecayCurse.java | 4 +- .../ecoenchants/curse/FragilityCurse.java | 2 +- .../ecoenchants/curse/InaccuracyCurse.java | 2 +- .../ecoenchants/normal/Abrasion.java | 7 +- .../ecoenchants/normal/Beheading.java | 2 +- .../ecoenchants/normal/BlastMining.java | 5 +- .../ecoenchants/normal/Bleed.java | 5 +- .../ecoenchants/normal/Buckshot.java | 2 +- .../ecoenchants/normal/Cleave.java | 5 +- .../ecoenchants/normal/Corrosive.java | 2 +- .../ecoenchants/normal/Disable.java | 5 +- .../ecoenchants/normal/Drill.java | 7 +- .../ecoenchants/normal/Dullness.java | 6 +- .../ecoenchants/normal/Economical.java | 2 +- .../ecoenchants/normal/Electroshock.java | 2 +- .../ecoenchants/normal/Famine.java | 5 +- .../ecoenchants/normal/Farmhand.java | 4 +- .../ecoenchants/normal/Fetching.java | 4 +- .../ecoenchants/normal/Forcefield.java | 6 +- .../enchantments/ecoenchants/normal/Fury.java | 13 +- .../ecoenchants/normal/Grapple.java | 2 +- .../ecoenchants/normal/GreenThumb.java | 2 +- .../enchantments/ecoenchants/normal/Grit.java | 2 +- .../enchantments/ecoenchants/normal/Hook.java | 2 +- .../ecoenchants/normal/IllusionAspect.java | 6 +- .../ecoenchants/normal/InfernalTouch.java | 4 +- .../ecoenchants/normal/Infuriate.java | 8 +- .../ecoenchants/normal/LiquidShot.java | 6 +- .../ecoenchants/normal/Lumberjack.java | 7 +- .../ecoenchants/normal/MagmaWalker.java | 2 +- .../ecoenchants/normal/Magnetic.java | 6 +- .../ecoenchants/normal/Necrotic.java | 2 +- .../ecoenchants/normal/Oxygenate.java | 2 +- .../ecoenchants/normal/Plasmic.java | 2 +- .../enchantments/ecoenchants/normal/Rage.java | 8 +- .../enchantments/ecoenchants/normal/Reel.java | 2 +- .../ecoenchants/normal/Shockwave.java | 5 +- .../ecoenchants/normal/Slicing.java | 2 +- .../ecoenchants/normal/Spearfishing.java | 9 +- .../ecoenchants/normal/Splash.java | 5 +- .../ecoenchants/normal/StoneSwitcher.java | 4 +- .../ecoenchants/normal/StrayAspect.java | 6 +- .../ecoenchants/normal/Succession.java | 2 +- .../ecoenchants/normal/Supercritical.java | 6 +- .../ecoenchants/normal/Telekinesis.java | 13 +- .../enchantments/ecoenchants/normal/Thor.java | 7 +- .../ecoenchants/normal/Thrive.java | 2 +- .../ecoenchants/normal/Toxic.java | 5 +- .../ecoenchants/normal/Transfuse.java | 4 +- .../ecoenchants/normal/VampireAspect.java | 6 +- .../enchantments/ecoenchants/normal/Vein.java | 7 +- .../ecoenchants/normal/Wisdom.java | 2 +- .../enchantments/ecoenchants/normal/Zeus.java | 2 +- .../ecoenchants/special/Aiming.java | 2 +- .../ecoenchants/special/Annihilate.java | 2 +- .../ecoenchants/special/Bolt.java | 8 +- .../ecoenchants/special/Carve.java | 6 +- .../ecoenchants/special/Confusion.java | 5 +- .../special/Indestructibility.java | 2 +- .../ecoenchants/special/Intellect.java | 2 +- .../ecoenchants/special/Razor.java | 6 +- .../ecoenchants/special/Repairing.java | 4 +- .../ecoenchants/special/Streamlining.java | 2 +- .../ecoenchants/special/Volatile.java | 6 +- .../ecoenchants/spell/Dynamite.java | 5 +- .../enchantments/itemtypes/Spell.java | 6 +- .../support/merging/anvil/AnvilListeners.java | 4 +- .../support/merging/anvil/AnvilMerge.java | 18 +- .../obtaining/EnchantingListeners.java | 28 +- .../support/obtaining/LootPopulator.java | 16 +- .../support/obtaining/VillagerListeners.java | 16 +- .../plugins/AntigriefFactionsUUID.java | 6 +- .../integrations/mcmmo/McmmoManager.java | 2 +- .../eco/util/interfaces/EcoRunnable.java | 5 + gradle.properties | 2 +- 437 files changed, 276 insertions(+), 18080 deletions(-) delete mode 100644 Plugin/build.gradle delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/command/AbstractCommand.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/command/AbstractTabCompleter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcoreload.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterEnchantinfo.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/config/UpdatingYamlConfig.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Config.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Lang.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Rarity.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Target.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/AbstractPacketAdapter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/DescriptionOptions.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/DisplayOptions.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/NumbersOptions.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/ShrinkOptions.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/interfaces/ThresholdedOption.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/interfaces/ToggleableOption.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/interfaces/UpdateableOption.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/EnchantmentSorter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SortParameters.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SorterManager.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/AlphabeticSorter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/LengthSorter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityAlphabeticSorter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityLengthSorter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeAlphabeticSorter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeLengthSorter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeAlphabeticSorter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeLengthSorter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketChat.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketOpenWindowMerchant.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketSetCreativeSlot.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketSetSlot.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketWindowItems.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/AshArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CloudsArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CrimsonArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DamageArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DragonArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DustArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EmeraldArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EnchantmentArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EndArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/FireArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HeartArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HoneyArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/InkArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LavaArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LimeArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagicArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagmaArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MusicArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/NetherArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/RedstoneArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SmokeArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SnowArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulFireArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SparkleArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TearArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TotemArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WarpedArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WaterArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WitchArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/ZapArtifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/BreaklessnessCurse.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/FragilityCurse.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HarmlessnessCurse.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HungerCurse.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/MisfortuneCurse.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/PermanenceCurse.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abattoir.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abrasion.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aerial.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aquatic.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arachnid.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arcanic.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Atmospheric.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Backstab.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Beheading.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlastMining.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Bleed.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Blind.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlockBreather.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BossHunter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Buckshot.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Butchering.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cerebral.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Chopless.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cleave.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Collateral.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Corrosive.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cranial.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Criticals.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cubism.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defender.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Deflection.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defusion.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dexterous.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disable.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disappear.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diurnal.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diverse.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Drill.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dullness.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dweller.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Economical.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Electroshock.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EndInfusion.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EnderSlayer.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Enderism.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Evasion.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extinguishing.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extract.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Famine.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Farmhand.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fetching.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FireAffinity.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FirstStrike.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Flinch.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Freerunner.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Frozen.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Goliath.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Graceful.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grapple.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/GreenThumb.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grit.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hellish.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hook.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Horde.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IceShot.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Identify.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Ignite.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IllusionAspect.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Incandescence.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/InfernalTouch.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Inferno.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Insecticide.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Invigoration.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Kinetic.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Launch.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Leeching.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lesion.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Levitate.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LiquidShot.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lumberjack.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/MagmaWalker.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marking.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marksman.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/NetherInfusion.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Netheric.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Nocturnal.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Optics.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Oxygenate.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Pacify.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paladin.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paralyze.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parasitic.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parry.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Phantasm.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Plasmic.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Protector.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Proximity.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Puncture.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Quadrilateralism.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Radiance.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rapid.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reel.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reinforcement.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rejuvenation.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Replenish.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Respirator.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Revenant.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sating.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Serrated.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Settle.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Shockwave.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/ShotAssist.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sickening.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slaughter.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slicing.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spearfishing.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spiked.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Splash.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stab.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stalwart.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stamina.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StoneSwitcher.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StrayAspect.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Succession.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sycophant.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tectonic.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thor.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thrive.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tornado.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Toxic.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Transfuse.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tripleshot.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VampireAspect.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Vein.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Venom.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VoidAffinity.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Voltage.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAffinity.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAspect.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Weakening.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wisdom.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wound.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Zeus.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Annihilate.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bolt.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Carve.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Energizing.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Frenzy.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Harpoon.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Indestructibility.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Instability.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Intellect.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/LifeSteal.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Pentashot.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Preservation.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Prosperity.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Spring.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Streamlining.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Volatile.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Ascend.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Charge.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Dynamite.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Missile.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Quake.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Vitalize.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneListeners.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneMerge.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantChecks.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellRunnable.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/Watcher.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorEquipEvent.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorListener.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorType.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/DispenserArmorListener.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityBuilder.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityEvent.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityListeners.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainBuilder.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainEvent.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainListeners.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/Integration.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/AnticheatManager.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/AnticheatWrapper.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatAAC.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatMatrix.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatNCP.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatSpartan.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/AntigriefManager.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/AntigriefWrapper.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefFactionsUUID.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefGriefPrevention.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefKingdoms.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefLands.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefTowny.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefWorldGuard.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsManager.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsWrapper.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/plugins/IntegrationEssentials.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/McmmoIntegration.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/McmmoManager.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/plugins/McmmoIntegrationImpl.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/PlaceholderEntry.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/PlaceholderIntegration.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/PlaceholderManager.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/plugins/PlaceholderIntegrationPAPI.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardManager.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardWrapper.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/plugins/WorldguardIntegrationImpl.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/nms/BlockBreak.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/nms/ChatComponent.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/nms/Cooldown.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/nms/FastGetEnchants.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/nms/OpenInventory.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/nms/RepairCost.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/nms/TridentStack.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/BlockUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/ClassUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/DurabilityUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/LightningUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/NumberUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/StringUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/VectorUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/Callable.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/EcoRunnable.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/ObjectBiCallable.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/ObjectCallable.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/internal/ArrowListeners.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/internal/DropQueue.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/internal/Loader.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/internal/Logger.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/AbstractDropQueue.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/FastCollatedDropQueue.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/InternalDropQueue.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/optional/Prerequisite.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/tuplets/Pair.java delete mode 100644 Plugin/src/main/java/com/willfp/ecoenchants/util/tuplets/Triplet.java create mode 100644 eco-util/src/main/java/com/willfp/eco/util/interfaces/EcoRunnable.java diff --git a/Plugin/build.gradle b/Plugin/build.gradle deleted file mode 100644 index e69de29b..00000000 diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java b/Plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java deleted file mode 100644 index 6ec2ac18..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.willfp.ecoenchants; - -import com.willfp.ecoenchants.extensions.loader.EcoExtensionLoader; -import com.willfp.ecoenchants.extensions.loader.ExtensionLoader; -import com.willfp.ecoenchants.util.internal.Loader; -import org.bukkit.Bukkit; -import org.bukkit.plugin.java.JavaPlugin; - -/** - * The Main class for EcoEnchants - */ -public class EcoEnchantsPlugin extends JavaPlugin { - /** - * Instance of EcoEnchants - */ - private static EcoEnchantsPlugin instance; - - /** - * Extension loader - */ - private final ExtensionLoader loader = new EcoExtensionLoader(); - - /** - * NMS version - */ - public static final String NMS_VERSION = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; - - /** - * Calls {@link Loader#load()} - */ - public void onEnable() { - Loader.load(); - } - - /** - * Calls {@link Loader#unload()} - */ - public void onDisable() { - Loader.unload(); - } - - /** - * Sets instance - */ - public void onLoad() { - instance = this; - } - - /** - * Get extension loader - * @return The {@link ExtensionLoader} attached to EcoEnchants - */ - public ExtensionLoader getExtensionLoader() { - return loader; - } - - /** - * Get plugin instance - * @return Plugin instance - */ - public static EcoEnchantsPlugin getInstance() { - return instance; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/command/AbstractCommand.java b/Plugin/src/main/java/com/willfp/ecoenchants/command/AbstractCommand.java deleted file mode 100644 index de20d745..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/command/AbstractCommand.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.willfp.ecoenchants.command; - -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.util.interfaces.Registerable; -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.PluginCommand; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public abstract class AbstractCommand implements CommandExecutor, Registerable { - private final String name; - private final String permission; - private final boolean playersOnly; - - protected AbstractCommand(String name, String permission, boolean playersOnly) { - this.name = name; - this.permission = permission; - this.playersOnly = playersOnly; - } - - public AbstractTabCompleter getTab() { - return null; - } - - public String getPermission() { - return this.permission; - } - - public String getName() { - return this.name; - } - - @Override - public boolean onCommand(@NotNull CommandSender sender, Command command, @NotNull String label, String[] args) { - if (!command.getName().equalsIgnoreCase(name)) return false; - - if (playersOnly && !(sender instanceof Player)) { - sender.sendMessage(ConfigManager.getLang().getMessage("not-player")); - return true; - } - - if (!sender.hasPermission(permission) && sender instanceof Player) { - sender.sendMessage(ConfigManager.getLang().getNoPermission()); - return true; - } - - onExecute(sender, Arrays.asList(args)); - - return true; - } - - @Override - public final void register() { - PluginCommand command = Bukkit.getPluginCommand(name); - assert command != null; - command.setExecutor(this); - - AbstractTabCompleter tabCompleter = this.getTab(); - if (tabCompleter != null) { - command.setTabCompleter(tabCompleter); - } - } - - public abstract void onExecute(CommandSender sender, List args); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/command/AbstractTabCompleter.java b/Plugin/src/main/java/com/willfp/ecoenchants/command/AbstractTabCompleter.java deleted file mode 100644 index 6fdf897e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/command/AbstractTabCompleter.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.willfp.ecoenchants.command; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCompleter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.List; - -public abstract class AbstractTabCompleter implements TabCompleter { - private final AbstractCommand command; - - protected AbstractTabCompleter(AbstractCommand command) { - this.command = command; - } - - @Override - public @Nullable List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - if (!command.getName().equalsIgnoreCase(this.command.getName())) - return null; - - if (!sender.hasPermission(this.command.getPermission())) - return null; - - return onTab(sender, Arrays.asList(args)); - } - - public abstract List onTab(CommandSender sender, List args); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java b/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java deleted file mode 100644 index 90e584a3..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.willfp.ecoenchants.command.commands; - -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.events.ListenerPriority; -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.command.AbstractCommand; -import com.willfp.ecoenchants.display.EnchantmentCache; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.util.internal.Logger; -import com.willfp.ecoenchants.util.internal.drops.FastCollatedDropQueue; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import java.lang.reflect.Field; -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 { - public CommandEcodebug() { - super("ecodebug", "ecoenchants.ecodebug", false); - } - - @Override - public void onExecute(CommandSender sender, List args) { - Logger.info("--------------- BEGIN DEBUG ----------------"); - if (sender instanceof Player) { - Player player = (Player) sender; - player.sendMessage("Held Item: " + player.getInventory().getItemInMainHand().toString()); - Logger.info(""); - - Logger.info("Held Item: " + player.getInventory().getItemInMainHand().toString()); - Logger.info(""); - } - - Logger.info("Running Version: " + EcoEnchantsPlugin.getInstance().getDescription().getVersion()); - Logger.info(""); - - Logger.info("Loaded Extensions: " + EcoEnchantsPlugin.getInstance().getExtensionLoader().getLoadedExtensions().stream().map(extension -> extension.getName() + " v" + extension.getVersion()).collect(Collectors.joining())); - Logger.info(""); - - Logger.info("EcoEnchants.getAll(): " + EcoEnchants.getAll().toString()); - Logger.info(""); - - Logger.info("Enchantment.values(): " + Arrays.toString(Enchantment.values())); - Logger.info(""); - - Logger.info("Enchantment Cache: " + EnchantmentCache.getCache().toString()); - Logger.info(""); - - try { - Field byNameField = Enchantment.class.getDeclaredField("byName"); - byNameField.setAccessible(true); - Map byName = (Map) byNameField.get(null); - Logger.info("Enchantment.byName: " + byName.toString()); - } catch (NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); - } - Logger.info(""); - - - List extern = Arrays.stream(Enchantment.values()).collect(Collectors.toList()); - extern.removeAll(EcoEnchants.getAll().stream().map(EcoEnchant::getEnchantment).collect(Collectors.toList())); - Logger.info("External/Vanilla Enchantments: " + extern.toString()); - Logger.info(""); - - List uncached = Arrays.stream(Enchantment.values()).collect(Collectors.toList()); - uncached.removeAll(EnchantmentCache.getCache().stream().map(EnchantmentCache.CacheEntry::getEnchantment).collect(Collectors.toList())); - Logger.info("Uncached Enchantments: " + uncached.toString()); - Logger.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"))); - Logger.info("Enchantments with broken cache: " + brokenCache.toString()); - Logger.info(""); - - Logger.info("Installed Plugins: " + Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList()).toString()); - Logger.info(""); - - Set withIssues = new HashSet<>(); - EcoEnchants.getAll().forEach(enchant -> { - if (enchant.getRarity() == null) withIssues.add(enchant); - if (enchant.getRawTargets().isEmpty()) withIssues.add(enchant); - }); - Logger.info("Enchantments with evident issues: " + withIssues.toString()); - Logger.info(""); - - Logger.info("Collate? " + FastCollatedDropQueue.use()); - Logger.info(""); - - Logger.info("Packets: " + ProtocolLibrary.getProtocolManager().getPacketListeners().stream().filter(packetListener -> packetListener.getSendingWhitelist().getPriority().equals(ListenerPriority.MONITOR)).collect(Collectors.toList()).toString()); - Logger.info(""); - - Logger.info("Server Information: "); - Logger.info("Players Online: " + Bukkit.getServer().getOnlinePlayers().size()); - Logger.info("Bukkit IP: " + Bukkit.getIp()); - Logger.info("Running Version: " + Bukkit.getVersion() + ", Bukkit Version: " + Bukkit.getBukkitVersion() + ", Alt Version: " + Bukkit.getServer().getVersion() + ", NMS: " + EcoEnchantsPlugin.NMS_VERSION); - Logger.info("Motd: " + Bukkit.getServer().getMotd()); - Logger.info("--------------- END DEBUG ----------------"); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcoreload.java b/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcoreload.java deleted file mode 100644 index 7d68fe95..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcoreload.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.willfp.ecoenchants.command.commands; - -import com.willfp.ecoenchants.command.AbstractCommand; -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.util.internal.Loader; -import org.bukkit.command.CommandSender; - -import java.util.List; - -public class CommandEcoreload extends AbstractCommand { - public CommandEcoreload() { - super("ecoreload", "ecoenchants.reload", false); - } - - @Override - public void onExecute(CommandSender sender, List args) { - Loader.reload(); - sender.sendMessage(ConfigManager.getLang().getMessage("reloaded")); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java b/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java deleted file mode 100644 index a10cd98d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.willfp.ecoenchants.command.commands; - -import com.willfp.ecoenchants.command.AbstractCommand; -import com.willfp.ecoenchants.command.AbstractTabCompleter; -import com.willfp.ecoenchants.command.tabcompleters.TabCompleterEnchantinfo; -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.display.EnchantmentCache; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.util.StringUtils; -import org.apache.commons.lang.WordUtils; -import org.bukkit.Material; -import org.bukkit.command.CommandSender; -import org.bukkit.enchantments.Enchantment; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class CommandEnchantinfo extends AbstractCommand { - public CommandEnchantinfo() { - super("enchantinfo", "ecoenchants.enchantinfo", false); - } - - @Override - public AbstractTabCompleter getTab() { - return new TabCompleterEnchantinfo(); - } - - @Override - public void onExecute(CommandSender sender, List args) { - if (args.size() == 0) { - sender.sendMessage(ConfigManager.getLang().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 || !enchantment.isEnabled()) { - String message = ConfigManager.getLang().getMessage("not-found").replace("%name%", searchName); - sender.sendMessage(message); - return; - } - - Set conflictNames = new HashSet<>(); - - Set conflicts = enchantment.getConflicts(); - - new HashSet<>(conflicts).forEach(enchantment1 -> { - if (EcoEnchants.getFromEnchantment(enchantment1) != null) { - if (!EcoEnchants.getFromEnchantment(enchantment1).isEnabled()) - conflicts.remove(enchantment1); - } - }); - - conflicts.forEach((enchantment1 -> { - if (EcoEnchants.getFromEnchantment(enchantment1) != null) { - conflictNames.add(EcoEnchants.getFromEnchantment(enchantment1).getName()); - } else { - conflictNames.add(ConfigManager.getLang().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(ConfigManager.getLang().getString("no-conflicts")); - } - - Set targets = enchantment.getTarget(); - - Set applicableItemsSet = new HashSet<>(); - - if (ConfigManager.getConfig().getBool("commands.enchantinfo.show-target-group")) { - enchantment.getRawTargets().forEach(target -> { - String targetName = target.getName(); - targetName = targetName.toLowerCase(); - targetName = targetName.replaceAll("_", " "); - targetName = WordUtils.capitalize(targetName); - applicableItemsSet.add(targetName); - }); - } else { - targets.forEach(material -> { - String matName = material.toString(); - matName = matName.toLowerCase(); - matName = matName.replaceAll("_", " "); - 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(ConfigManager.getLang().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(ConfigManager.getLang().getMessage("enchantinfo").split("\\r?\\n")).forEach((string -> { - string = string.replaceAll("%name%", finalName) - .replaceAll("%description%", finalDescription) - .replaceAll("%target%", finalTargets) - .replaceAll("%conflicts%", finalConflicts) - .replaceAll("%maxlevel%", finalMaxLevel); - sender.sendMessage(string); - })); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterEnchantinfo.java b/Plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterEnchantinfo.java deleted file mode 100644 index 2b4e1770..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterEnchantinfo.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.willfp.ecoenchants.command.tabcompleters; - -import com.willfp.ecoenchants.command.AbstractCommand; -import com.willfp.ecoenchants.command.AbstractTabCompleter; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.util.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.util.StringUtil; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -public class TabCompleterEnchantinfo extends AbstractTabCompleter { - private static final List enchantsNames = EcoEnchants.getAll().stream().filter(EcoEnchant::isEnabled).map(EcoEnchant::getName).collect(Collectors.toList()); - - public TabCompleterEnchantinfo() { - super((AbstractCommand) Bukkit.getPluginCommand("enchantinfo").getExecutor()); - } - - public static void reload() { - enchantsNames.clear(); - enchantsNames.addAll(EcoEnchants.getAll().stream().filter(EcoEnchant::isEnabled).map(EcoEnchant::getName).collect(Collectors.toList())); - } - - @Override - public List onTab(CommandSender sender, List args) { - List completions = new ArrayList<>(); - - if (args.size() == 0) { - // Currently, this case is not ever reached - return enchantsNames; - } - - StringUtil.copyPartialMatches(String.join(" ", args), enchantsNames, 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/Plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java deleted file mode 100644 index e0b9961d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.willfp.ecoenchants.config; - -import com.willfp.ecoenchants.config.configs.*; - -import java.util.HashSet; -import java.util.Set; - -public class ConfigManager { - private static final Lang LANG = new Lang(); - private static final Config CONFIG = new Config(); - private static final Target TARGET = new Target(); - private static final Rarity RARITY = new Rarity(); - private static final Set enchantmentConfigs = new HashSet<>(); - - /** - * Update all configs - * Called on /ecoreload - */ - public static void updateConfigs() { - LANG.update(); - CONFIG.update(); - TARGET.update(); - RARITY.update(); - updateEnchantmentConfigs(); - } - - /** - * Update enchantment configs - */ - public static void updateEnchantmentConfigs() { - enchantmentConfigs.forEach((EnchantmentYamlConfig::update)); - } - - /** - * Get all enchantment configs - * - * @return Set of all enchantment configs - */ - public static Set getEnchantmentConfigs() { - return enchantmentConfigs; - } - - /** - * Get EnchantmentConfig matching permission name - * - * @param permissionName The permission name to match - * - * @return The matching {@link EnchantmentConfig} - */ - @SuppressWarnings("OptionalGetWithoutIsPresent") - public static EnchantmentConfig getEnchantmentConfig(String permissionName) { - return enchantmentConfigs.stream().filter(config -> config.getName().equalsIgnoreCase(permissionName)).findFirst().get(); - } - - /** - * Adds new enchantment config yml - * - * @param config The config to add - */ - public static void addEnchantmentConfig(EnchantmentConfig config) { - enchantmentConfigs.add(config); - } - - /** - * Get lang.yml - * - * @return lang.yml - */ - public static Lang getLang() { - return LANG; - } - - /** - * Get config.yml - * - * @return config.yml - */ - public static Config getConfig() { - return CONFIG; - } - - /** - * Get target.yml - * - * @return target.yml - */ - public static Target getTarget() { - return TARGET; - } - - /** - * Get rarity.yml - * - * @return rarity.yml - */ - public static Rarity getRarity() { - return RARITY; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java deleted file mode 100644 index b066a18c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.willfp.ecoenchants.config; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.*; -import java.nio.charset.StandardCharsets; - -/** - * Class implemented by enchantment configs - */ -public abstract class EnchantmentYamlConfig { - - private final String name; - public YamlConfiguration config; - protected File configFile; - private final File directory; - private final Class source; - private final EcoEnchant.EnchantmentType type; - - /** - * Create new config yml - * - * @param name The config name - * @param plugin The class of the main class of plugin or extension - * @param type The enchantment type - */ - public EnchantmentYamlConfig(String name, Class plugin, EcoEnchant.EnchantmentType type) { - this.name = name; - this.source = plugin; - this.type = type; - - File basedir = new File(EcoEnchantsPlugin.getInstance().getDataFolder(), "enchants/"); - if (!basedir.exists()) basedir.mkdirs(); - - File dir = new File(basedir, type.getName() + "/"); - if (!dir.exists()) { - dir.mkdirs(); - } - this.directory = dir; - - init(); - } - - private void init() { - if (!new File(directory, name + ".yml").exists()) { - createFile(); - } - - this.configFile = new File(directory, name + ".yml"); - this.config = YamlConfiguration.loadConfiguration(configFile); - - update(); - } - - private void saveResource() { - String resourcePath = "/enchants/" + type.getName() + "/" + name + ".yml"; - - InputStream in = source.getResourceAsStream(resourcePath); - - File outFile = new File(EcoEnchantsPlugin.getInstance().getDataFolder(), resourcePath); - int lastIndex = resourcePath.lastIndexOf('/'); - File outDir = new File(EcoEnchantsPlugin.getInstance().getDataFolder(), resourcePath.substring(0, Math.max(lastIndex, 0))); - - if (!outDir.exists()) { - outDir.mkdirs(); - } - - try { - if (!outFile.exists()) { - OutputStream out = new FileOutputStream(outFile); - byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } - out.close(); - in.close(); - } - } catch (IOException ignored) { - } - } - - private void createFile() { - saveResource(); - } - - public void update() { - try { - config.load(configFile); - - String resourcePath = "/enchants/" + type.getName() + "/" + name + ".yml"; - InputStream newIn = source.getResourceAsStream(resourcePath); - - BufferedReader reader = new BufferedReader(new InputStreamReader(newIn, StandardCharsets.UTF_8)); - YamlConfiguration newConfig = new YamlConfiguration(); - newConfig.load(reader); - - if (newConfig.getKeys(true).equals(config.getKeys(true))) - return; - - newConfig.getKeys(true).forEach((s -> { - if (!config.getKeys(true).contains(s)) { - config.set(s, newConfig.get(s)); - } - })); - - config.getKeys(true).forEach((s -> { - if (!newConfig.getKeys(true).contains(s)) { - config.set(s, null); - } - })); - - config.save(configFile); - } catch (IOException | InvalidConfigurationException e) { - e.printStackTrace(); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/UpdatingYamlConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/UpdatingYamlConfig.java deleted file mode 100644 index fb791474..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/UpdatingYamlConfig.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.willfp.ecoenchants.config; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.util.internal.Logger; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.*; -import java.nio.charset.StandardCharsets; - -public abstract class UpdatingYamlConfig { - public YamlConfiguration config; - private File configFile; - private final String name; - private final boolean removeUnused; - - public UpdatingYamlConfig(String name, boolean removeUnused) { - this.name = name + ".yml"; - this.removeUnused = removeUnused; - init(); - } - - private void init() { - if (!new File(EcoEnchantsPlugin.getInstance().getDataFolder(), name).exists()) { - createFile(); - } - - this.configFile = new File(EcoEnchantsPlugin.getInstance().getDataFolder(), name); - this.config = YamlConfiguration.loadConfiguration(configFile); - - update(); - } - - private void createFile() { - EcoEnchantsPlugin.getInstance().saveResource(name, false); - } - - public void update() { - try { - config.load(configFile); - - InputStream newIn = EcoEnchantsPlugin.getInstance().getResource(name); - if (newIn == null) { - Logger.error(name + " is null?"); - return; - } - BufferedReader reader = new BufferedReader(new InputStreamReader(newIn, StandardCharsets.UTF_8)); - YamlConfiguration newConfig = new YamlConfiguration(); - newConfig.load(reader); - - if (newConfig.getKeys(true).equals(config.getKeys(true))) - return; - - newConfig.getKeys(true).forEach((s -> { - if (!config.getKeys(true).contains(s)) { - config.set(s, newConfig.get(s)); - } - })); - - if (this.removeUnused) { - config.getKeys(true).forEach((s -> { - if (!newConfig.getKeys(true).contains(s)) { - config.set(s, null); - } - })); - } - - config.save(configFile); - } catch (IOException | InvalidConfigurationException e) { - e.printStackTrace(); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Config.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Config.java deleted file mode 100644 index 7ffce3de..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Config.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.willfp.ecoenchants.config.configs; - -import com.willfp.ecoenchants.config.UpdatingYamlConfig; -import org.bukkit.inventory.ItemStack; - -import java.util.List; - -/** - * Wrapper for config.yml - */ -public class Config extends UpdatingYamlConfig { - public Config() { - super("config", true); - } - - public int getInt(String path) { - return config.getInt(path); - } - - public int getInt(String path, int def) { - return config.getInt(path, def); - } - - public List getInts(String path) { - return config.getIntegerList(path); - } - - public boolean getBool(String path) { - return config.getBoolean(path); - } - - public List getBools(String path) { - return config.getBooleanList(path); - } - - public String getString(String path) { - return config.getString(path); - } - - public List getStrings(String path) { - return config.getStringList(path); - } - - public double getDouble(String path) { - return config.getDouble(path); - } - - public List getDoubles(String path) { - return config.getDoubleList(path); - } - - public ItemStack getItemStack(String path) { - return config.getItemStack(path); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java deleted file mode 100644 index d9c6fda7..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.willfp.ecoenchants.config.configs; - -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.config.EnchantmentYamlConfig; -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.EnchantmentTarget; -import com.willfp.ecoenchants.util.internal.Logger; -import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemStack; - -import java.io.IOException; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * Wrapper for enchantment-specific configs - */ -public class EnchantmentConfig extends EnchantmentYamlConfig { - private final String name; - - public EnchantmentConfig(String name, Class plugin, EcoEnchant.EnchantmentType type) { - super(name, plugin, type); - this.name = name; - } - - public String getName() { - return name; - } - - public int getInt(String path) { - return config.getInt(path); - } - - public int getInt(String path, int def) { - return config.getInt(path, def); - } - - public List getInts(String path) { - return config.getIntegerList(path); - } - - public boolean getBool(String path) { - return config.getBoolean(path); - } - - public boolean getBool(String path, boolean def) { - return config.getBoolean(path, def); - } - - public List getBools(String path) { - return config.getBooleanList(path); - } - - public String getString(String path) { - return config.getString(path); - } - - public List getStrings(String path) { - return config.getStringList(path); - } - - public double getDouble(String path) { - return config.getDouble(path); - } - - public List getDoubles(String path) { - return config.getDoubleList(path); - } - - public ItemStack getItemStack(String path) { - return config.getItemStack(path); - } - - public Set getEnchantments(String path) { - Set enchantments = new HashSet<>(); - List enchantmentKeys = config.getStringList(path); - enchantmentKeys.forEach((key -> enchantments.add(Enchantment.getByKey(NamespacedKey.minecraft(key))))); - return enchantments; - } - - public EnchantmentRarity getRarity() { - String rarityName = this.getString("obtaining.rarity"); - return EnchantmentRarity.getByName(rarityName); - } - - public Set getTargets() { - List targetNames = config.getStringList(EcoEnchants.GENERAL_LOCATION + "targets"); - if (targetNames == null || targetNames.isEmpty()) return new HashSet<>(); - Set targets = new HashSet<>(); - - targetNames.forEach((s -> { - if (EnchantmentTarget.getByName(s) == null) { - Logger.error(s + " is an invalid target!"); - return; - } - targets.add(EnchantmentTarget.getByName(s)); - })); - - return targets; - } - - public void loadFromLang() { - if (!ConfigManager.getLang().config.contains("enchantments." + this.getName())) - return; - - config.set("name", ConfigManager.getLang().getString("enchantments." + this.getName() + ".name")); - config.set("description", ConfigManager.getLang().getString("enchantments." + this.getName() + ".description")); - try { - this.config.save(this.configFile); - } catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Lang.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Lang.java deleted file mode 100644 index ea75b60f..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Lang.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoenchants.config.configs; - -import com.willfp.ecoenchants.config.UpdatingYamlConfig; -import com.willfp.ecoenchants.util.StringUtils; - -import java.util.List; - -/** - * Wrapper for lang.yml - */ -public class Lang extends UpdatingYamlConfig { - public Lang() { - super("lang", false); - } - - public String getString(String path) { - return StringUtils.translate(String.valueOf(config.getString(path))); - } - - public List getStrings(String path) { - return config.getStringList(path); - } - - - public String getPrefix() { - return StringUtils.translate(config.getString("messages.prefix")); - } - - public String getNoPermission() { - return getPrefix() + StringUtils.translate(config.getString("messages.no-permission")); - } - - public String getMessage(String message) { - return getPrefix() + StringUtils.translate(config.getString("messages." + message)); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Rarity.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Rarity.java deleted file mode 100644 index 8b22c6fa..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Rarity.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.willfp.ecoenchants.config.configs; - -import com.willfp.ecoenchants.config.UpdatingYamlConfig; - -import java.util.List; -import java.util.Set; - -/** - * Wrapper for config.yml - */ -public class Rarity extends UpdatingYamlConfig { - public Rarity() { - super("rarity", false); - } - - public Set getRarities() { - return config.getConfigurationSection("rarities").getKeys(false); - } - - public int getInt(String path) { - return config.getInt(path); - } - - public int getInt(String path, int def) { - return config.getInt(path, def); - } - - public List getInts(String path) { - return config.getIntegerList(path); - } - - public boolean getBool(String path) { - return config.getBoolean(path); - } - - public List getBools(String path) { - return config.getBooleanList(path); - } - - public String getString(String path) { - return config.getString(path); - } - - public List getStrings(String path) { - return config.getStringList(path); - } - - public double getDouble(String path) { - return config.getDouble(path); - } - - public List getDoubles(String path) { - return config.getDoubleList(path); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Target.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Target.java deleted file mode 100644 index 533ee755..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/Target.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.config.configs; - -import com.willfp.ecoenchants.config.UpdatingYamlConfig; -import org.bukkit.Material; - -import java.util.HashSet; -import java.util.Set; - -/** - * Wrapper for config.yml - */ -public class Target extends UpdatingYamlConfig { - public Target() { - super("target", false); - } - - public Set getTargets() { - return config.getConfigurationSection("targets").getKeys(false); - } - - public Set getTargetMaterials(String target) { - Set materials = new HashSet<>(); - config.getStringList("targets." + target).forEach((materialName) -> { - materials.add(Material.getMaterial(materialName.toUpperCase())); - }); - - return materials; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/AbstractPacketAdapter.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/AbstractPacketAdapter.java deleted file mode 100644 index ca9c5de1..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/AbstractPacketAdapter.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.willfp.ecoenchants.display; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.events.PacketEvent; -import com.willfp.ecoenchants.EcoEnchantsPlugin; - -import java.util.Collections; - -public abstract class AbstractPacketAdapter extends PacketAdapter { - private final PacketType type; - - protected AbstractPacketAdapter(PacketType type, ListenerPriority priority) { - super(EcoEnchantsPlugin.getInstance(), priority, Collections.singletonList(type)); - this.type = type; - } - - protected AbstractPacketAdapter(PacketType type) { - super(EcoEnchantsPlugin.getInstance(), Collections.singletonList(type)); - this.type = type; - } - - public void onReceive(PacketContainer packet) { - } - - public void onSend(PacketContainer packet) { - } - - @Override - public final void onPacketReceiving(PacketEvent event) { - if (event.getPacket() == null) - return; - - if (!event.getPacket().getType().equals(type)) - return; - - onReceive(event.getPacket()); - } - - @Override - public final void onPacketSending(PacketEvent event) { - if (event.getPacket() == null) - return; - - if (!event.getPacket().getType().equals(type)) - return; - - onSend(event.getPacket()); - } - - public final void register() { - if (!ProtocolLibrary.getProtocolManager().getPacketListeners().contains(this)) { - ProtocolLibrary.getProtocolManager().addPacketListener(this); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java deleted file mode 100644 index 563a3411..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java +++ /dev/null @@ -1,247 +0,0 @@ -package com.willfp.ecoenchants.display; - -import com.google.common.collect.Lists; -import com.willfp.ecoenchants.EcoEnchantsPlugin; -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.util.NumberUtils; -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 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 { - /** - * The meta key to hide enchantments in lore - *

- * Only used for parity in {@link com.willfp.ecoenchants.display.packets.PacketSetCreativeSlot}. - * More robust method to be introduced - * - * @deprecated Temporary fix - */ - @Deprecated - public static final NamespacedKey KEY_SKIP = new NamespacedKey(EcoEnchantsPlugin.getInstance(), "ecoenchantlore-skip"); - - /** - * The meta key to notify the server that an item is from a villager trade - *

- * Bit of a bodge - plan on making it better. - */ - public static final NamespacedKey KEY_V = new NamespacedKey(EcoEnchantsPlugin.getInstance(), "ecoenchantlore-v"); - - /** - * The prefix for all enchantment lines to have in lore - */ - public static final String PREFIX = "§w"; - - /** - * The configurable options for displaying enchantments - */ - public static final DisplayOptions OPTIONS = new DisplayOptions(); - - /** - * Update config values - */ - public static void update() { - OPTIONS.update(); - EnchantmentCache.update(); - } - - /** - * Bodge to fix hidden enchantments from villagers. - *

- * It isn't recommended to mess with this unless you really know your way around EcoEnchants. - * - * @param item The item to modify - * - * @return The item, with KEY_V - */ - public static ItemStack addV(ItemStack item) { - if (item == null || item.getItemMeta() == null) return item; - - ItemMeta meta = item.getItemMeta(); - meta.getPersistentDataContainer().set(KEY_V, PersistentDataType.INTEGER, 1); - item.setItemMeta(meta); - return item; - } - - /** - * Revert display - * - * @param item The item to revert - * - * @return The item, updated - */ - public static ItemStack revertDisplay(final ItemStack item) { - if (item == null || !EnchantmentTarget.ALL.getMaterials().contains(item.getType()) || item.getItemMeta() == null) - return item; - - ItemMeta meta = item.getItemMeta(); - List itemLore; - - if (meta.hasLore()) - itemLore = meta.getLore(); - else - itemLore = new ArrayList<>(); - - if (itemLore == null) itemLore = new ArrayList<>(); - - if (meta.getPersistentDataContainer().has(KEY_V, PersistentDataType.INTEGER)) { - meta.getPersistentDataContainer().remove(KEY_V); - } - itemLore.removeIf((s) -> s.startsWith(PREFIX)); - - if (!meta.getPersistentDataContainer().has(KEY_SKIP, PersistentDataType.INTEGER)) { - if (meta instanceof EnchantmentStorageMeta) - meta.removeItemFlags(ItemFlag.HIDE_POTION_EFFECTS); // Thanks ShaneBee! - meta.removeItemFlags(ItemFlag.HIDE_ENCHANTS); - } - meta.getPersistentDataContainer().remove(KEY_SKIP); - meta.setLore(itemLore); - item.setItemMeta(meta); - - return item; - } - - public static ItemStack displayEnchantments(final ItemStack item) { - return displayEnchantments(item, false); - } - - /** - * Show all enchantments in item lore - * - * @param item The item to update - * - * @return The item, updated - */ - public static ItemStack displayEnchantments(final ItemStack item, boolean hideEnchants) { - if (item == null || item.getItemMeta() == null || !EnchantmentTarget.ALL.getMaterials().contains(item.getType())) - return item; - - if (item.getItemMeta().getPersistentDataContainer().has(KEY_V, PersistentDataType.INTEGER)) { - if (hideEnchants) - hideEnchants = false; - } - - revertDisplay(item); - - ItemMeta meta = item.getItemMeta(); - if (meta == null) return item; - List itemLore = new ArrayList<>(); - - if (hideEnchants || meta.getPersistentDataContainer().has(KEY_SKIP, PersistentDataType.INTEGER)) { - meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); - meta.getPersistentDataContainer().set(KEY_SKIP, PersistentDataType.INTEGER, 1); - item.setItemMeta(meta); - return item; - } - - 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.isUseNumerals() && item.getEnchantmentLevel(enchantment) < OPTIONS.getNumbersThreshold()) { - name += " " + NumberUtils.toNumeral(level); - } else { - name += " " + level; - } - } - - lore.add(PREFIX + name); - if (enchantments.size() <= OPTIONS.getDescribeThreshold() && OPTIONS.isUseDescribe()) - lore.addAll(EnchantmentCache.getEntry(enchantment).getDescription()); - }); - - if (OPTIONS.isUseShrink() && (enchantments.size() > OPTIONS.getShrinkThreshold())) { - List> partitionedCombinedLoreList = Lists.partition(lore, OPTIONS.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); - item.setItemMeta(meta); - - return item; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java deleted file mode 100644 index a39de368..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.willfp.ecoenchants.display; - -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity; -import com.willfp.ecoenchants.util.internal.Logger; -import org.apache.commons.lang.WordUtils; -import org.bukkit.enchantments.Enchantment; - -import java.util.*; - -@SuppressWarnings("deprecation") -public class EnchantmentCache { - private static final Set CACHE = new HashSet<>(); - - @SuppressWarnings("OptionalGetWithoutIsPresent") - public static CacheEntry getEntry(Enchantment enchantment) { - Optional matching = CACHE.stream().filter(entry -> entry.getEnchantment().getKey().getKey().equals(enchantment.getKey().getKey())).findFirst(); - return matching.orElse(new CacheEntry(enchantment, EnchantDisplay.PREFIX + "§7" + enchantment.getKey().getKey(), enchantment.getKey().getKey(), Collections.singletonList(EnchantDisplay.PREFIX + "No Description Found"), EcoEnchant.EnchantmentType.NORMAL, EnchantmentRarity.values().stream().findFirst().get())); - } - - public static Set getCache() { - return new HashSet<>(CACHE); - } - - public static void update() { - CACHE.clear(); - Arrays.asList(Enchantment.values()).parallelStream().forEach(enchantment -> { - String name; - String color; - EcoEnchant.EnchantmentType type; - EnchantmentRarity rarity; - List description; - if (EcoEnchants.getFromEnchantment(enchantment) != null) { - EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchantment); - description = ecoEnchant.getDescription(); - name = ecoEnchant.getName(); - type = ecoEnchant.getType(); - rarity = ecoEnchant.getRarity(); - } else { - description = Arrays.asList( - WordUtils.wrap( - String.valueOf(ConfigManager.getLang().getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".description")), - ConfigManager.getConfig().getInt("lore.describe.wrap"), - "\n", false - ).split("\\r?\\n") - ); - name = String.valueOf(ConfigManager.getLang().getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".name")); - type = enchantment.isCursed() ? EcoEnchant.EnchantmentType.CURSE : EcoEnchant.EnchantmentType.NORMAL; - rarity = enchantment.isTreasure() ? EnchantmentRarity.getByName(ConfigManager.getConfig().getString("rarity.vanilla-treasure-rarity")) : EnchantmentRarity.getByName(ConfigManager.getConfig().getString("rarity.vanilla-rarity")); - } - - color = type.getColor(); - - if (rarity != null) { - if (rarity.hasCustomColor() && type != EcoEnchant.EnchantmentType.CURSE) { - color = rarity.getCustomColor(); - } - } else { - Logger.warn("Enchantment " + enchantment.getKey().getKey() + " has an invalid rarity"); - } - - String rawName = name; - name = color + name; - description.replaceAll(line -> EnchantDisplay.PREFIX + EnchantDisplay.OPTIONS.getDescriptionColor() + line); - CACHE.add(new CacheEntry(enchantment, name, rawName, description, type, rarity)); - }); - } - - - public static class CacheEntry { - private final Enchantment enchantment; - private final String name; - private final String rawName; - private final List description; - private final String stringDescription; - private final EcoEnchant.EnchantmentType type; - private final EnchantmentRarity rarity; - - public CacheEntry(Enchantment enchantment, String name, String rawName, List description, EcoEnchant.EnchantmentType type, 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 stringDescription = descriptionBuilder.toString(); - stringDescription = stringDescription.replaceAll("§w", ""); - this.stringDescription = stringDescription.replaceAll(EnchantDisplay.OPTIONS.getDescriptionColor(), ""); - } - - public Enchantment getEnchantment() { - return enchantment; - } - - public String getName() { - return name; - } - - public String getRawName() { - return rawName; - } - - public List getDescription() { - return description; - } - - public String getStringDescription() { - return stringDescription; - } - - public EcoEnchant.EnchantmentType getType() { - return type; - } - - public EnchantmentRarity getRarity() { - return rarity; - } - - @Override - public String toString() { - return "CacheEntry{" + - "enchantment=" + enchantment + - "§f, name='" + name + '\'' + - "§f, rawName='" + rawName + '\'' + - "§f, description=" + description + - "§f, stringDescription='" + stringDescription + '\'' + - "§f}"; - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/DescriptionOptions.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/DescriptionOptions.java deleted file mode 100644 index d4f08107..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/DescriptionOptions.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.willfp.ecoenchants.display.options; - -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.display.options.interfaces.ThresholdedOption; -import com.willfp.ecoenchants.display.options.interfaces.ToggleableOption; -import com.willfp.ecoenchants.display.options.interfaces.UpdateableOption; -import com.willfp.ecoenchants.util.StringUtils; - -public class DescriptionOptions implements ThresholdedOption, ToggleableOption, UpdateableOption { - private int threshold; - private boolean enabled; - private String color; - - @Override - public int getThreshold() { - return threshold; - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public void update() { - threshold = ConfigManager.getConfig().getInt("lore.describe.before-lines"); - enabled = ConfigManager.getConfig().getBool("lore.describe.enabled"); - color = StringUtils.translate(ConfigManager.getLang().getString("description-color")); - } - - public String getColor() { - return color; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/DisplayOptions.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/DisplayOptions.java deleted file mode 100644 index 760dc0e4..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/DisplayOptions.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.willfp.ecoenchants.display.options; - -import com.willfp.ecoenchants.config.ConfigManager; -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.EcoEnchant; -import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity; - -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 { - private EnchantmentSorter sorter; - private final DescriptionOptions descriptionOptions = new DescriptionOptions(); - private final NumbersOptions numbersOptions = new NumbersOptions(); - private final ShrinkOptions shrinkOptions = new ShrinkOptions(); - private final List sortedTypes = new ArrayList<>(); - private final List sortedRarities = new ArrayList<>(); - - public DisplayOptions() { - update(); - } - - public String getDescriptionColor() { - return descriptionOptions.getColor(); - } - - public int getNumbersThreshold() { - return numbersOptions.getThreshold(); - } - - public boolean isUseNumerals() { - return numbersOptions.useNumerals(); - } - - public int getDescribeThreshold() { - return descriptionOptions.getThreshold(); - } - - public boolean isUseDescribe() { - return descriptionOptions.isEnabled(); - } - - public int getShrinkThreshold() { - return shrinkOptions.getThreshold(); - } - - public int getShrinkPerLine() { - return shrinkOptions.getShrinkPerLine(); - } - - public boolean isUseShrink() { - return shrinkOptions.isEnabled(); - } - - public List getSortedTypes() { - return sortedTypes; - } - - public List getSortedRarities() { - return sortedRarities; - } - - public EnchantmentSorter getSorter() { - return sorter; - } - - public void update() { - descriptionOptions.update(); - numbersOptions.update(); - shrinkOptions.update(); - - sortedTypes.clear(); - sortedTypes.addAll(ConfigManager.getConfig().getStrings("lore.type-ordering").stream() - .map(typeName -> EcoEnchant.EnchantmentType.values().stream().filter(type -> type.getName().equalsIgnoreCase(typeName)).findFirst().orElse(null)) - .filter(Objects::nonNull) - .collect(Collectors.toList())); - sortedTypes.addAll(EcoEnchant.EnchantmentType.values().stream().filter(enchantmentType -> !sortedTypes.contains(enchantmentType)).collect(Collectors.toList())); - - sortedRarities.clear(); - sortedRarities.addAll(ConfigManager.getConfig().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())); - - boolean byType = ConfigManager.getConfig().getBool("lore.sort-by-type"); - boolean byLength = ConfigManager.getConfig().getBool("lore.sort-by-length"); - boolean byRarity = ConfigManager.getConfig().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/Plugin/src/main/java/com/willfp/ecoenchants/display/options/NumbersOptions.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/NumbersOptions.java deleted file mode 100644 index c1f6fe2b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/NumbersOptions.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.willfp.ecoenchants.display.options; - -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.display.options.interfaces.ThresholdedOption; -import com.willfp.ecoenchants.display.options.interfaces.UpdateableOption; - -public class NumbersOptions implements ThresholdedOption, UpdateableOption { - private boolean useNumerals; - private int threshold; - - @Override - public int getThreshold() { - return threshold; - } - - @Override - public void update() { - useNumerals = ConfigManager.getConfig().getBool("lore.use-numerals"); - threshold = ConfigManager.getConfig().getInt("lore.use-numbers-above-threshold"); - } - - public boolean useNumerals() { - return useNumerals; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/ShrinkOptions.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/ShrinkOptions.java deleted file mode 100644 index 1b0aa40b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/ShrinkOptions.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.willfp.ecoenchants.display.options; - -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.display.options.interfaces.ThresholdedOption; -import com.willfp.ecoenchants.display.options.interfaces.ToggleableOption; -import com.willfp.ecoenchants.display.options.interfaces.UpdateableOption; - -public class ShrinkOptions implements ThresholdedOption, ToggleableOption, UpdateableOption { - private int threshold; - private boolean enabled; - private int shrinkPerLine; - - @Override - public int getThreshold() { - return threshold; - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public void update() { - threshold = ConfigManager.getConfig().getInt("lore.shrink.after-lines"); - enabled = ConfigManager.getConfig().getBool("lore.shrink.enabled"); - shrinkPerLine = ConfigManager.getConfig().getInt("lore.shrink.maximum-per-line"); - } - - public int getShrinkPerLine() { - return shrinkPerLine; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/interfaces/ThresholdedOption.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/interfaces/ThresholdedOption.java deleted file mode 100644 index fa75e225..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/interfaces/ThresholdedOption.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.willfp.ecoenchants.display.options.interfaces; - -public interface ThresholdedOption { - int getThreshold(); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/interfaces/ToggleableOption.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/interfaces/ToggleableOption.java deleted file mode 100644 index 6fd90879..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/interfaces/ToggleableOption.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.willfp.ecoenchants.display.options.interfaces; - -public interface ToggleableOption { - boolean isEnabled(); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/interfaces/UpdateableOption.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/interfaces/UpdateableOption.java deleted file mode 100644 index 09193e17..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/interfaces/UpdateableOption.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.willfp.ecoenchants.display.options.interfaces; - -public interface UpdateableOption { - void update(); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/EnchantmentSorter.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/EnchantmentSorter.java deleted file mode 100644 index 0a24d90d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/EnchantmentSorter.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.willfp.ecoenchants.display.options.sorting; - -import org.bukkit.enchantments.Enchantment; - -import java.util.List; - -public interface EnchantmentSorter { - void sortEnchantments(final List toSort); - SortParameters[] getParameters(); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SortParameters.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SortParameters.java deleted file mode 100644 index eb768f88..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SortParameters.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.willfp.ecoenchants.display.options.sorting; - -public enum SortParameters { - TYPE, - RARITY, - LENGTH -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SorterManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SorterManager.java deleted file mode 100644 index 07b3ad22..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SorterManager.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoenchants.display.options.sorting; - -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 java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -public class SorterManager { - private static final Set values = new HashSet<>(); - - public static EnchantmentSorter getSorter(SortParameters... parameters) { - return values.stream() - .filter(enchantmentSorter -> Arrays.asList(enchantmentSorter.getParameters()).containsAll(Arrays.asList(parameters)) && enchantmentSorter.getParameters().length == parameters.length) - .findFirst() - .orElse(new AlphabeticSorter()); - } - - static { - values.add(new AlphabeticSorter()); - values.add(new LengthSorter()); - values.add(new TypeAlphabeticSorter()); - values.add(new TypeLengthSorter()); - values.add(new RarityAlphabeticSorter()); - values.add(new RarityLengthSorter()); - values.add(new RarityTypeAlphabeticSorter()); - values.add(new RarityTypeLengthSorter()); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/AlphabeticSorter.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/AlphabeticSorter.java deleted file mode 100644 index 3e26e0ab..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/AlphabeticSorter.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.willfp.ecoenchants.display.options.sorting.implementations; - -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 java.util.List; - -public class AlphabeticSorter implements EnchantmentSorter { - @Override - public void sortEnchantments(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/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/LengthSorter.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/LengthSorter.java deleted file mode 100644 index 660a7a0c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/LengthSorter.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.willfp.ecoenchants.display.options.sorting.implementations; - -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 java.util.Comparator; -import java.util.List; - -public class LengthSorter implements EnchantmentSorter { - @Override - public void sortEnchantments(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/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityAlphabeticSorter.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityAlphabeticSorter.java deleted file mode 100644 index 7005562a..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityAlphabeticSorter.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.willfp.ecoenchants.display.options.sorting.implementations; - -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 java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -public class RarityAlphabeticSorter implements EnchantmentSorter { - @Override - public void sortEnchantments(final List toSort) { - List sorted = new ArrayList<>(); - EnchantDisplay.OPTIONS.getSortedRarities().forEach(enchantmentRarity -> { - List rarityEnchants = toSort.stream() - .filter(enchantment -> EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) - .sorted((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName())) - .collect(Collectors.toList()); - sorted.addAll(rarityEnchants); - }); - - toSort.clear(); - toSort.addAll(sorted); - } - - @Override - public SortParameters[] getParameters() { - return new SortParameters[]{SortParameters.RARITY}; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityLengthSorter.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityLengthSorter.java deleted file mode 100644 index fccf0167..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityLengthSorter.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.willfp.ecoenchants.display.options.sorting.implementations; - -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 java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - -public class RarityLengthSorter implements EnchantmentSorter { - @Override - public void sortEnchantments(final List toSort) { - List sorted = new ArrayList<>(); - EnchantDisplay.OPTIONS.getSortedRarities().forEach(enchantmentRarity -> { - List rarityEnchants = toSort.stream() - .filter(enchantment -> EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) - .sorted(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length())) - .collect(Collectors.toList()); - sorted.addAll(rarityEnchants); - }); - - toSort.clear(); - toSort.addAll(sorted); - } - - @Override - public SortParameters[] getParameters() { - return new SortParameters[]{SortParameters.RARITY, SortParameters.LENGTH}; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeAlphabeticSorter.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeAlphabeticSorter.java deleted file mode 100644 index 20182969..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeAlphabeticSorter.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.willfp.ecoenchants.display.options.sorting.implementations; - -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 java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -public class RarityTypeAlphabeticSorter implements EnchantmentSorter { - @Override - public void sortEnchantments(final List toSort) { - List sorted = new ArrayList<>(); - EnchantDisplay.OPTIONS.getSortedTypes().forEach(enchantmentType -> { - List typeEnchants = toSort.stream() - .filter(enchantment -> EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) - .sorted((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName())) - .collect(Collectors.toList()); - EnchantDisplay.OPTIONS.getSortedRarities().forEach(enchantmentRarity -> { - List rarityEnchants = typeEnchants.stream() - .filter(enchantment -> EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) - .sorted((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName())) - .collect(Collectors.toList()); - sorted.addAll(rarityEnchants); - }); - }); - - toSort.clear(); - toSort.addAll(sorted); - } - - @Override - public SortParameters[] getParameters() { - return new SortParameters[]{SortParameters.RARITY, SortParameters.TYPE}; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeLengthSorter.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeLengthSorter.java deleted file mode 100644 index 89e33667..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeLengthSorter.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.ecoenchants.display.options.sorting.implementations; - -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 java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - -public class RarityTypeLengthSorter implements EnchantmentSorter { - @Override - public void sortEnchantments(final List toSort) { - List sorted = new ArrayList<>(); - EnchantDisplay.OPTIONS.getSortedTypes().forEach(enchantmentType -> { - List typeEnchants = toSort.stream() - .filter(enchantment -> EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) - .sorted(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length())) - .collect(Collectors.toList()); - EnchantDisplay.OPTIONS.getSortedRarities().forEach(enchantmentRarity -> { - List rarityEnchants = typeEnchants.stream() - .filter(enchantment -> EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) - .sorted(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length())) - .collect(Collectors.toList()); - sorted.addAll(rarityEnchants); - }); - }); - - toSort.clear(); - toSort.addAll(sorted); - } - - @Override - public SortParameters[] getParameters() { - return new SortParameters[]{SortParameters.RARITY, SortParameters.TYPE, SortParameters.LENGTH}; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeAlphabeticSorter.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeAlphabeticSorter.java deleted file mode 100644 index 9173899e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeAlphabeticSorter.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.willfp.ecoenchants.display.options.sorting.implementations; - -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 java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -public class TypeAlphabeticSorter implements EnchantmentSorter { - @Override - public void sortEnchantments(final List toSort) { - List sorted = new ArrayList<>(); - EnchantDisplay.OPTIONS.getSortedTypes().forEach(enchantmentType -> { - List typeEnchants = toSort.stream() - .filter(enchantment -> EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) - .sorted((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName())) - .collect(Collectors.toList()); - sorted.addAll(typeEnchants); - }); - - toSort.clear(); - toSort.addAll(sorted); - } - - @Override - public SortParameters[] getParameters() { - return new SortParameters[]{SortParameters.TYPE}; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeLengthSorter.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeLengthSorter.java deleted file mode 100644 index d1c0883f..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeLengthSorter.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.willfp.ecoenchants.display.options.sorting.implementations; - -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 java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - -public class TypeLengthSorter implements EnchantmentSorter { - @Override - public void sortEnchantments(final List toSort) { - List sorted = new ArrayList<>(); - EnchantDisplay.OPTIONS.getSortedTypes().forEach(enchantmentType -> { - List typeEnchants = toSort.stream() - .filter(enchantment -> EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) - .sorted(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length())) - .collect(Collectors.toList()); - sorted.addAll(typeEnchants); - }); - - toSort.clear(); - toSort.addAll(sorted); - } - - @Override - public SortParameters[] getParameters() { - return new SortParameters[]{SortParameters.TYPE, SortParameters.LENGTH}; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketChat.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketChat.java deleted file mode 100644 index 1e1ed04d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketChat.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.willfp.ecoenchants.display.packets; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.wrappers.WrappedChatComponent; -import com.willfp.ecoenchants.display.AbstractPacketAdapter; -import com.willfp.ecoenchants.nms.ChatComponent; - -public class PacketChat extends AbstractPacketAdapter { - public PacketChat() { - super(PacketType.Play.Server.CHAT, ListenerPriority.MONITOR); - } - - @Override - public void onSend(PacketContainer packet) { - for (int i = 0; i < packet.getChatComponents().size(); i++) { - WrappedChatComponent component = packet.getChatComponents().read(i); - if (component == null) - continue; - if (component.getHandle() == null) - return; - WrappedChatComponent newComponent = WrappedChatComponent.fromHandle(ChatComponent.modifyComponent(component.getHandle())); - packet.getChatComponents().write(i, newComponent); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketOpenWindowMerchant.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketOpenWindowMerchant.java deleted file mode 100644 index 9838531d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketOpenWindowMerchant.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.willfp.ecoenchants.display.packets; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.display.AbstractPacketAdapter; -import com.willfp.ecoenchants.display.EnchantDisplay; -import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.MerchantRecipe; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Modifier; -import java.util.List; -import java.util.stream.Collectors; - -public class PacketOpenWindowMerchant extends AbstractPacketAdapter { - public PacketOpenWindowMerchant() { - super(PacketType.Play.Server.OPEN_WINDOW_MERCHANT); - } - - @Override - public void onSend(PacketContainer packet) { - List recipes = packet.getMerchantRecipeLists().readSafely(0); - - recipes = recipes.stream().peek(merchantRecipe -> { - try { - if (!EnchantmentTarget.ALL.getMaterials().contains(merchantRecipe.getResult().getType())) - return; - - // Enables removing final modifier - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - - // Bukkit MerchantRecipe result - Field fResult = merchantRecipe.getClass().getSuperclass().getDeclaredField("result"); - fResult.setAccessible(true); - ItemStack result = EnchantDisplay.displayEnchantments(merchantRecipe.getResult()); - result = EnchantDisplay.addV(result); - fResult.set(merchantRecipe, result); - - // Get NMS MerchantRecipe from CraftMerchantRecipe - Field fHandle = merchantRecipe.getClass().getDeclaredField("handle"); - fHandle.setAccessible(true); - Object handle = fHandle.get(merchantRecipe); // NMS Recipe - modifiersField.setInt(fHandle, fHandle.getModifiers() & ~Modifier.FINAL); // Remove final - - // NMS MerchantRecipe - Field fSelling = fHandle.get(merchantRecipe).getClass().getDeclaredField("sellingItem"); - fSelling.setAccessible(true); - Object selling = fSelling.get(handle); // NMS Selling ItemStack - modifiersField.setInt(fSelling, fSelling.getModifiers() & ~Modifier.FINAL); - - // Reflectively access CraftItemStack.class for respective version - Class craftItemStack = Class.forName("org.bukkit.craftbukkit." + EcoEnchantsPlugin.NMS_VERSION + ".inventory.CraftItemStack"); - - // Bukkit Result ItemStack from NMS Result ItemStack - ItemStack nmsSelling = (ItemStack) craftItemStack.getMethod("asBukkitCopy", selling.getClass()).invoke(null, selling); - nmsSelling = EnchantDisplay.displayEnchantments(nmsSelling); - nmsSelling = EnchantDisplay.addV(nmsSelling); - fSelling.set(handle, craftItemStack.getMethod("asNMSCopy", ItemStack.class).invoke(null, nmsSelling)); - - } catch (IllegalAccessException | NoSuchFieldException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) { - e.printStackTrace(); - } - }).collect(Collectors.toList()); - - packet.getMerchantRecipeLists().writeSafely(0, recipes); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketSetCreativeSlot.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketSetCreativeSlot.java deleted file mode 100644 index ed8866fa..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketSetCreativeSlot.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.willfp.ecoenchants.display.packets; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.willfp.ecoenchants.display.AbstractPacketAdapter; -import com.willfp.ecoenchants.display.EnchantDisplay; - -public class PacketSetCreativeSlot extends AbstractPacketAdapter { - public PacketSetCreativeSlot() { - super(PacketType.Play.Client.SET_CREATIVE_SLOT); - } - - @Override - public void onReceive(PacketContainer packet) { - packet.getItemModifier().modify(0, (item) -> { - item = EnchantDisplay.revertDisplay(item); - return item; - }); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketSetSlot.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketSetSlot.java deleted file mode 100644 index e7c28935..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketSetSlot.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.display.packets; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.willfp.ecoenchants.display.AbstractPacketAdapter; -import com.willfp.ecoenchants.display.EnchantDisplay; -import org.bukkit.inventory.ItemFlag; - -public class PacketSetSlot extends AbstractPacketAdapter { - public PacketSetSlot() { - super(PacketType.Play.Server.SET_SLOT); - } - - @Override - public void onSend(PacketContainer packet) { - packet.getItemModifier().modify(0, (item) -> { - boolean hideEnchants = false; - - if (item == null) - return item; - - if (item.getItemMeta() != null) { - hideEnchants = item.getItemMeta().getItemFlags().contains(ItemFlag.HIDE_ENCHANTS); - } - - item = EnchantDisplay.displayEnchantments(item, hideEnchants); - return item; - }); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketWindowItems.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketWindowItems.java deleted file mode 100644 index ad5a8f6b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketWindowItems.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.willfp.ecoenchants.display.packets; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.willfp.ecoenchants.display.AbstractPacketAdapter; -import com.willfp.ecoenchants.display.EnchantDisplay; -import org.bukkit.inventory.ItemFlag; - -public class PacketWindowItems extends AbstractPacketAdapter { - public PacketWindowItems() { - super(PacketType.Play.Server.WINDOW_ITEMS); - } - - @Override - public void onSend(PacketContainer packet) { - packet.getItemListModifier().modify(0, (itemStacks) -> { - if (itemStacks == null) return null; - itemStacks.forEach(item -> { - if (item == null) - return; - - boolean hideEnchants = false; - - if (item.getItemMeta() != null) { - hideEnchants = item.getItemMeta().getItemFlags().contains(ItemFlag.HIDE_ENCHANTS); - } - - EnchantDisplay.displayEnchantments(item, hideEnchants); - }); - return itemStacks; - }); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java deleted file mode 100644 index cd5103e1..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java +++ /dev/null @@ -1,555 +0,0 @@ -package com.willfp.ecoenchants.enchantments; - -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.config.configs.EnchantmentConfig; -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.enchantments.itemtypes.Spell; -import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.enchantments.util.Watcher; -import com.willfp.ecoenchants.util.StringUtils; -import com.willfp.ecoenchants.util.interfaces.ObjectCallable; -import com.willfp.ecoenchants.util.interfaces.Registerable; -import com.willfp.ecoenchants.util.internal.Logger; -import com.willfp.ecoenchants.util.optional.Prerequisite; -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.enchantments.EnchantmentTarget; -import org.bukkit.event.Listener; -import org.bukkit.inventory.ItemStack; -import org.bukkit.permissions.Permission; -import org.bukkit.permissions.PermissionDefault; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -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"}) -public abstract class EcoEnchant extends Enchantment implements Listener, Registerable, Watcher { - private String name; - private String description; - private final String permissionName; - private final EnchantmentType type; - - private final EnchantmentConfig config; - - private boolean grindstoneable; - private boolean canGetFromTable; - private boolean canGetFromVillager; - private boolean canGetFromLoot; - private int maxLvl; - private Set conflicts; - private EnchantmentRarity rarity; - private final Set target = new HashSet<>(); - private final Set targetMaterials = new HashSet<>(); - private final Set disabledWorldNames = new HashSet<>(); - private final List disabledWorlds = new ArrayList<>(); - - 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(String key, EcoEnchant.EnchantmentType type, Prerequisite... prerequisites) { - super(NamespacedKey.minecraft(key)); - - this.type = type; - this.permissionName = key.replaceAll("_", ""); - ConfigManager.addEnchantmentConfig(new EnchantmentConfig(this.permissionName, this.getClass(), this.type)); - this.config = ConfigManager.getEnchantmentConfig(this.permissionName); - - 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); - } - - //WorldguardManager.registerFlag(this.getPermissionName() + "-enabled", true); - - if(type.getRequiredToExtend() != null && !type.getRequiredToExtend().isInstance(this)) { - Logger.error("Enchantment " + key + " has type " + this.getType().getName() + " but doesn't extend " + type.getRequiredToExtend().getName()); - return; - } - - if (!Prerequisite.areMet(prerequisites)) - return; - - this.update(); - EcoEnchants.addNewEcoEnchant(this); - } - - /** - * Create a new EcoEnchant that exists within an extension or external plugin - * - * @param key The key name of the enchantment - * @param type The type of the enchantment - * @param plugin Unused value - * @param prerequisites Optional {@link Prerequisite}s that must be met - * - * @deprecated Specifying the source class is no longer needed - */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "6.0.0") - protected EcoEnchant(String key, EcoEnchant.EnchantmentType type, Class plugin, Prerequisite... prerequisites) { - this(key, type, prerequisites); - - Logger.warn("Enchantment " + key + " (Generated by " + plugin.getName() + ") is using a legacy constructor!"); - Logger.warn("Update your extensions - support for legacy enchantments will be removed in subsequent versions."); - } - - /** - * Update the enchantment based off config values - * This can be overriden but may lead to unexpected behavior - */ - public void update() { - config.loadFromLang(); - rarity = config.getRarity(); - conflicts = config.getEnchantments(EcoEnchants.GENERAL_LOCATION + "conflicts"); - grindstoneable = config.getBool(EcoEnchants.GENERAL_LOCATION + "grindstoneable"); - canGetFromTable = config.getBool(EcoEnchants.OBTAINING_LOCATION + "table"); - canGetFromVillager = config.getBool(EcoEnchants.OBTAINING_LOCATION + "villager"); - canGetFromLoot = config.getBool(EcoEnchants.OBTAINING_LOCATION + "loot"); - maxLvl = 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())); - target.clear(); - targetMaterials.clear(); - target.addAll(config.getTargets()); - target.forEach(enchantmentTarget -> targetMaterials.addAll(enchantmentTarget.getMaterials())); - enabled = config.getBool("enabled", true); - 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 - */ - @Override - 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 if enchantment can be removed in grindstone - * - * @return Whether the enchantment can be removed - */ - public boolean isGrindstoneable() { - return grindstoneable; - } - - /** - * Get {@link EnchantmentType} of enchantment - * - * @return The {@link EnchantmentType} - */ - public EnchantmentType getType() { - return this.type; - } - - /** - * Get a set of all conflicts - * - * @return Conflicts - */ - public Set getConflicts() { - return this.conflicts; - } - - /** - * Get if enchantment is enabled - * - * @return If enabled - */ - public boolean isEnabled() { - return this.enabled; - } - - /** - * Get permission name of enchantment - * - * @return The permission name - */ - public String getPermissionName() { - return permissionName; - } - - /** - * Get description of enchantment - * - * @return The description - */ - public List getDescription() { - return Arrays.asList(WordUtils.wrap(description, ConfigManager.getConfig().getInt("lore.describe.wrap"), "\n", false).split("\\r?\\n")); - } - - /** - * Get if enchantment can be obtained from an enchanting table - * - * @return If can be obtained - */ - public boolean canGetFromTable() { - return canGetFromTable; - } - - /** - * Get if enchantment can be obtained from a villager - * - * @return If can be obtained - */ - public boolean canGetFromVillager() { - return canGetFromVillager; - } - - /** - * Get if enchantment can be obtained from chest loot - * - * @return If can be obtained - */ - public boolean canGetFromLoot() { - return canGetFromLoot; - } - - /** - * Get {@link EnchantmentRarity} of enchantment - * - * @return The enchantment rarity - */ - public EnchantmentRarity getRarity() { - return rarity; - } - - /** - * If enchantment conflicts with any enchantment in set - * - * @param enchantments The set to test against - * - * @return If there are any conflicts - */ - public boolean conflictsWithAny(Set enchantments) { - return conflicts.stream().anyMatch(enchantments::contains); - } - - /** - * Get enchantment cast to {@link Enchantment} - * - * @return The enchantment - */ - public Enchantment getEnchantment() { - return this; - } - - /** - * Get the target of enchantment - * - * @return Set of enchantable items - */ - public Set getTarget() { - return targetMaterials; - } - - /** - * Get raw target of enchantment - * - * @return {@link com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget} - */ - public Set getRawTargets() { - return target; - } - - /** - * Get {@link EnchantmentConfig} of enchantment - * - * @return The config - */ - public EnchantmentConfig getConfig() { - return config; - } - - /** - * Get worlds that the enchantment is disabled in - * - * @return A list of all disabled worlds - */ - public List getDisabledWorlds() { - return disabledWorlds; - } - - /** - * Get world names that the enchantment is disabled in - * - * @return A list of all disabled world names - */ - public Set getDisabledWorldNames() { - return disabledWorldNames; - } - - /** - * Get display name of enchantment. - * Not deprecated, unlike {@link Enchantment#getName()} - * - * @return The display name - */ - @Override - public @NotNull String getName() { - return name; - } - - /** - * Get max level of enchantment - * - * @return The max level - */ - @Override - public int getMaxLevel() { - return maxLvl; - } - - /** - * @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#getTarget()} instead. - */ - @Override - @Deprecated - public @NotNull EnchantmentTarget getItemTarget() { - return EnchantmentTarget.ALL; - } - - /** - * Treasure enchantments do not exist in EcoEnchants - * @see EnchantmentType#SPECIAL - * - * @return false - * - * @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. - * @see EnchantmentType#CURSE - * - * @return Returns if enchantment is cursed. - * - * @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 Enchantment enchantment) { - 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(ItemStack itemStack) { - return targetMaterials.contains(itemStack.getType()) || itemStack.getType().equals(Material.BOOK) || itemStack.getType().equals(Material.ENCHANTED_BOOK); - } - - public static class EnchantmentType { - private static final List values = new ArrayList<>(); - - public static final EnchantmentType NORMAL = new EnchantmentType("normal", false, () -> ConfigManager.getLang().getString("not-curse-color")); - public static final EnchantmentType CURSE = new EnchantmentType("curse", false, () -> ConfigManager.getLang().getString("curse-color")); - public static final EnchantmentType SPECIAL = new EnchantmentType("special", () -> !ConfigManager.getConfig().getBool("types.special.allow-multiple"), () -> ConfigManager.getLang().getString("special-color")); - public static final EnchantmentType ARTIFACT = new EnchantmentType("artifact", () -> !ConfigManager.getConfig().getBool("types.artifact.allow-multiple"), () -> ConfigManager.getLang().getString("artifact-color"), Artifact.class); - public static final EnchantmentType SPELL = new EnchantmentType("spell", true, () -> ConfigManager.getLang().getString("spell-color"), Spell.class); - - private boolean singular; - private String color; - private final String name; - private final ObjectCallable colorCallable; - private final ObjectCallable singularCallable; - private final Class requiredToExtend; - - /** - * 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(String name, boolean singular, 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 colorCallable Lambda to fetch the color of enchantments with this type to have. Updates on /ecoreload - */ - public EnchantmentType(String name, boolean singular, ObjectCallable colorCallable) { - this(name, () -> singular, colorCallable); - } - - /** - * 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 colorCallable 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(String name, boolean singular, ObjectCallable colorCallable, Class requiredToExtend) { - this(name, () -> singular, colorCallable, requiredToExtend); - } - - /** - * Create EnchantmentType with updatable color and singularity - * - * @param name The name of the type - * @param singularCallable Lambda to fetch whether an item can have several enchantments of this type. Updates on /ecoreload - * @param colorCallable Lambda to fetch the color of enchantments with this type to have. Updates on /ecoreload - */ - public EnchantmentType(String name, ObjectCallable singularCallable, ObjectCallable colorCallable) { - this(name, singularCallable, colorCallable, null); - } - - /** - * Create EnchantmentType with updatable color and singularity that must extend a specified class - * - * @param name The name of the type - * @param singularCallable Lambda to fetch whether an item can have several enchantments of this type. Updates on /ecoreload - * @param colorCallable 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(String name, ObjectCallable singularCallable, ObjectCallable colorCallable, Class requiredToExtend) { - this.name = name; - this.singularCallable = singularCallable; - this.colorCallable = colorCallable; - this.requiredToExtend = requiredToExtend; - color = colorCallable.call(); - singular = singularCallable.call(); - values.add(this); - } - - private void refresh() { - this.color = colorCallable.call(); - this.singular = singularCallable.call(); - } - - public String getColor() { - return color; - } - - public boolean isSingular() { - return singular; - } - - public String getName() { - return name; - } - - public Class getRequiredToExtend() { - return requiredToExtend; - } - - public static void update() { - values.forEach(EnchantmentType::refresh); - } - - public static List values() { - return new ArrayList<>(values); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java deleted file mode 100644 index eeb14714..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java +++ /dev/null @@ -1,384 +0,0 @@ -package com.willfp.ecoenchants.enchantments; - -import com.google.common.collect.ImmutableList; -import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.*; -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.*; -import com.willfp.ecoenchants.enchantments.ecoenchants.special.*; -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 org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.EnchantmentStorageMeta; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * Contains general methods for EcoEnchants - */ -@SuppressWarnings("unused") -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 List ecoEnchants = new ArrayList<>(); - private static final Map byKey = new HashMap<>(); - - 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(); - - /** - * Get all registered {@link EcoEnchant}s - * - * @return A list of all {@link EcoEnchant}s - */ - public static List getAll() { - return ImmutableList.copyOf(ecoEnchants); - } - - /** - * Gets {@link EcoEnchant} from {@link Enchantment} - * - * @param enchantment The enchantment - * - * @return The matching {@link EcoEnchant}, or null if not found. - */ - public static EcoEnchant getFromEnchantment(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(String name) { - Optional matching = getAll().stream().filter(enchant -> enchant.getName().equalsIgnoreCase(name)).findFirst(); - return matching.orElse(null); - } - - /** - * 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(String permissionName) { - Optional matching = getAll().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(NamespacedKey key) { - return byKey.get(key); - } - - /** - * Get if {@link ItemStack} has any {@link EcoEnchant} matching specified {@link com.willfp.ecoenchants.enchantments.EcoEnchant.EnchantmentType} - * - * @param item The {@link ItemStack} to check - * @param type The {@link com.willfp.ecoenchants.enchantments.EcoEnchant.EnchantmentType} to match - * - * @return True if has, false if doesn't have. - */ - public static boolean hasAnyOfType(ItemStack item, EcoEnchant.EnchantmentType type) { - if (item == null) return false; - - AtomicBoolean hasOfType = new AtomicBoolean(false); - - if (item.getItemMeta() instanceof EnchantmentStorageMeta) { - ((EnchantmentStorageMeta) item.getItemMeta()).getStoredEnchants().forEach(((enchantment, integer) -> { - if (getFromEnchantment(enchantment) != null) { - if (getFromEnchantment(enchantment).getType().equals(type)) hasOfType.set(true); - } - })); - } else { - item.getEnchantments().forEach(((enchantment, integer) -> { - if (getFromEnchantment(enchantment) != null) { - if (getFromEnchantment(enchantment).getType().equals(type)) hasOfType.set(true); - } - })); - } - return hasOfType.get(); - } - - /** - * Update all {@link EcoEnchant}s - * Called on /ecoreload - */ - public static void update() { - for (EcoEnchant ecoEnchant : new HashSet<>(getAll())) { - 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(EcoEnchant enchant) { - ecoEnchants.remove(enchant); - ecoEnchants.add(enchant); - byKey.remove(enchant.getKey()); - byKey.put(enchant.getKey(), enchant); - } - - /** - * Remove {@link EcoEnchant} from EcoEnchants - * - * @param enchant The {@link EcoEnchant} to remove - */ - public static void removeEcoEnchant(EcoEnchant enchant) { - ecoEnchants.remove(enchant); - byKey.remove(enchant.getKey()); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/AshArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/AshArtifact.java deleted file mode 100644 index 66038cfb..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/AshArtifact.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.util.optional.Prerequisite; -import org.bukkit.Particle; - -public class AshArtifact extends Artifact { - public AshArtifact() { - super( - "ash_artifact", - Prerequisite.MinVer1_16 - ); - } - - @Override - public Particle getParticle() { - return Particle.WHITE_ASH; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CloudsArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CloudsArtifact.java deleted file mode 100644 index 0637b09d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CloudsArtifact.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Color; -import org.bukkit.Particle; -public class CloudsArtifact extends Artifact { - public CloudsArtifact() { - super( - "clouds_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.REDSTONE; - } - - @Override - public Particle.DustOptions getDustOptions() { - return new Particle.DustOptions(Color.AQUA, 1.0f); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CrimsonArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CrimsonArtifact.java deleted file mode 100644 index 062e00cc..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/CrimsonArtifact.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.util.optional.Prerequisite; -import org.bukkit.Particle; - -public class CrimsonArtifact extends Artifact { - public CrimsonArtifact() { - super( - "crimson_artifact", - Prerequisite.MinVer1_16 - ); - } - - @Override - public Particle getParticle() { - return Particle.CRIMSON_SPORE; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DamageArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DamageArtifact.java deleted file mode 100644 index b29c8fa9..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DamageArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class DamageArtifact extends Artifact { - public DamageArtifact() { - super( - "damage_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.DAMAGE_INDICATOR; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DragonArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DragonArtifact.java deleted file mode 100644 index b7a77cb3..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DragonArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class DragonArtifact extends Artifact { - public DragonArtifact() { - super( - "dragon_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.DRAGON_BREATH; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DustArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DustArtifact.java deleted file mode 100644 index 693fe818..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/DustArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class DustArtifact extends Artifact { - public DustArtifact() { - super( - "dust_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.CRIT; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EmeraldArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EmeraldArtifact.java deleted file mode 100644 index 21defa08..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EmeraldArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class EmeraldArtifact extends Artifact { - public EmeraldArtifact() { - super( - "emerald_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.COMPOSTER; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EnchantmentArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EnchantmentArtifact.java deleted file mode 100644 index 58da1ae1..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EnchantmentArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class EnchantmentArtifact extends Artifact { - public EnchantmentArtifact() { - super( - "enchantment_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.ENCHANTMENT_TABLE; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EndArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EndArtifact.java deleted file mode 100644 index 095fb38e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/EndArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class EndArtifact extends Artifact { - public EndArtifact() { - super( - "end_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.END_ROD; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/FireArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/FireArtifact.java deleted file mode 100644 index ceb8e66a..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/FireArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class FireArtifact extends Artifact { - public FireArtifact() { - super( - "fire_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.FLAME; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HeartArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HeartArtifact.java deleted file mode 100644 index ea4577f3..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HeartArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class HeartArtifact extends Artifact { - public HeartArtifact() { - super( - "heart_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.HEART; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HoneyArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HoneyArtifact.java deleted file mode 100644 index 7a77a6d3..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/HoneyArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class HoneyArtifact extends Artifact { - public HoneyArtifact() { - super( - "honey_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.FALLING_HONEY; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/InkArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/InkArtifact.java deleted file mode 100644 index e835932a..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/InkArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class InkArtifact extends Artifact { - public InkArtifact() { - super( - "ink_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.SQUID_INK; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LavaArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LavaArtifact.java deleted file mode 100644 index 674815e4..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LavaArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class LavaArtifact extends Artifact { - public LavaArtifact() { - super( - "lava_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.DRIP_LAVA; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LimeArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LimeArtifact.java deleted file mode 100644 index 16822f69..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/LimeArtifact.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Color; -import org.bukkit.Particle; - -public class LimeArtifact extends Artifact { - public LimeArtifact() { - super( - "lime_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.REDSTONE; - } - - @Override - public Particle.DustOptions getDustOptions() { - return new Particle.DustOptions(Color.fromRGB(3, 252, 140), 1.0f); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagicArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagicArtifact.java deleted file mode 100644 index 9951d971..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagicArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class MagicArtifact extends Artifact { - public MagicArtifact() { - super( - "magic_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.CRIT_MAGIC; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagmaArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagmaArtifact.java deleted file mode 100644 index e8174ac7..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MagmaArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class MagmaArtifact extends Artifact { - public MagmaArtifact() { - super( - "magma_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.LAVA; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MusicArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MusicArtifact.java deleted file mode 100644 index 903630fa..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/MusicArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class MusicArtifact extends Artifact { - public MusicArtifact() { - super( - "music_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.NOTE; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/NetherArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/NetherArtifact.java deleted file mode 100644 index fde2bb69..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/NetherArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class NetherArtifact extends Artifact { - public NetherArtifact() { - super( - "nether_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.PORTAL; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/RedstoneArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/RedstoneArtifact.java deleted file mode 100644 index 9f3a929c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/RedstoneArtifact.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Color; -import org.bukkit.Particle; -public class RedstoneArtifact extends Artifact { - public RedstoneArtifact() { - super( - "redstone_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.REDSTONE; - } - - @Override - public Particle.DustOptions getDustOptions() { - return new Particle.DustOptions(Color.RED, 1.0f); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SmokeArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SmokeArtifact.java deleted file mode 100644 index 16881cd8..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SmokeArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class SmokeArtifact extends Artifact { - public SmokeArtifact() { - super( - "smoke_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.CAMPFIRE_COSY_SMOKE; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SnowArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SnowArtifact.java deleted file mode 100644 index 438f65e8..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SnowArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class SnowArtifact extends Artifact { - public SnowArtifact() { - super( - "snow_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.SNOWBALL; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulArtifact.java deleted file mode 100644 index 4497daa0..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulArtifact.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.util.optional.Prerequisite; -import org.bukkit.Particle; - -public class SoulArtifact extends Artifact { - public SoulArtifact() { - super( - "soul_artifact", - Prerequisite.MinVer1_16 - ); - } - - @Override - public Particle getParticle() { - return Particle.SOUL; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulFireArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulFireArtifact.java deleted file mode 100644 index fd6d9ce8..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SoulFireArtifact.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.util.optional.Prerequisite; -import org.bukkit.Particle; - -public class SoulFireArtifact extends Artifact { - public SoulFireArtifact() { - super( - "soul_fire_artifact", - Prerequisite.MinVer1_16 - ); - } - - @Override - public Particle getParticle() { - return Particle.SOUL_FIRE_FLAME; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SparkleArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SparkleArtifact.java deleted file mode 100644 index 53deb656..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/SparkleArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class SparkleArtifact extends Artifact { - public SparkleArtifact() { - super( - "sparkle_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.FIREWORKS_SPARK; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TearArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TearArtifact.java deleted file mode 100644 index a7855c1c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TearArtifact.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.util.optional.Prerequisite; -import org.bukkit.Particle; - -public class TearArtifact extends Artifact { - public TearArtifact() { - super( - "tear_artifact", - Prerequisite.MinVer1_16 - ); - } - - @Override - public Particle getParticle() { - return Particle.DRIPPING_OBSIDIAN_TEAR; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TotemArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TotemArtifact.java deleted file mode 100644 index b21dad79..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/TotemArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class TotemArtifact extends Artifact { - public TotemArtifact() { - super( - "totem_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.TOTEM; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WarpedArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WarpedArtifact.java deleted file mode 100644 index a0286766..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WarpedArtifact.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.util.optional.Prerequisite; -import org.bukkit.Particle; - -public class WarpedArtifact extends Artifact { - public WarpedArtifact() { - super( - "warped_artifact", - Prerequisite.MinVer1_16 - ); - } - - @Override - public Particle getParticle() { - return Particle.WARPED_SPORE; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WaterArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WaterArtifact.java deleted file mode 100644 index 68b59612..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WaterArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class WaterArtifact extends Artifact { - public WaterArtifact() { - super( - "water_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.DRIP_WATER; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WitchArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WitchArtifact.java deleted file mode 100644 index 9e343aa6..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/WitchArtifact.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Particle; -public class WitchArtifact extends Artifact { - public WitchArtifact() { - super( - "witch_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.SPELL_WITCH; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/ZapArtifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/ZapArtifact.java deleted file mode 100644 index 9b1aa4ad..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/artifact/ZapArtifact.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; - -import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import org.bukkit.Color; -import org.bukkit.Particle; -public class ZapArtifact extends Artifact { - public ZapArtifact() { - super( - "zap_artifact" - ); - } - - @Override - public Particle getParticle() { - return Particle.REDSTONE; - } - - @Override - public Particle.DustOptions getDustOptions() { - return new Particle.DustOptions(Color.YELLOW, 1.0f); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/BreaklessnessCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/BreaklessnessCurse.java deleted file mode 100644 index 382948da..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/BreaklessnessCurse.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.curse; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockDamageEvent; - -public class BreaklessnessCurse extends EcoEnchant { - public BreaklessnessCurse() { - super( - "breaklessness_curse", EnchantmentType.CURSE - ); - } - - // START OF LISTENERS - - - @Override - public void onDamageBlock(Player player, Block block, int level, BlockDamageEvent event) { - if (!EnchantmentUtils.passedChance(this, level)) - return; - - event.setCancelled(true); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java deleted file mode 100644 index dfdf1be7..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.curse; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent; -import com.willfp.ecoenchants.util.VectorUtils; -import com.willfp.ecoenchants.util.interfaces.EcoRunnable; -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 java.util.HashMap; - -public class CallingCurse extends EcoEnchant implements EcoRunnable { - public CallingCurse() { - super( - "calling_curse", EnchantmentType.CURSE - ); - } - - private final HashMap players = new HashMap<>(); - - @EventHandler - public void onArmorEquip(ArmorEquipEvent event) { - refresh(); - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) { - refresh(); - } - - @EventHandler - public void onPlayerLeave(PlayerQuitEvent event) { - refresh(); - } - - private void refresh() { - players.clear(); - EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().forEach(player -> { - int level = EnchantChecks.getArmorPoints(player, this, 0); - if (level > 0) { - players.put(player, level); - } - }); - } - - @Override - public void run() { - players.forEach((player, level) -> { - double distance = EcoEnchants.CALLING_CURSE.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance"); - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java deleted file mode 100644 index d8db8949..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.curse; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.DurabilityUtils; -import com.willfp.ecoenchants.util.interfaces.EcoRunnable; -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 java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -public class DecayCurse extends EcoEnchant implements EcoRunnable { - 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(EntityPickupItemEvent event) { - if (!(event.getEntity() instanceof Player)) - return; - refreshPlayer((Player) event.getEntity()); - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) { - refresh(); - } - - @EventHandler - public void onPlayerLeave(PlayerQuitEvent event) { - refresh(); - } - - @EventHandler - public void onInventoryDrop(EntityDropItemEvent event) { - if (!(event.getEntity() instanceof Player)) - return; - refreshPlayer((Player) event.getEntity()); - } - - @EventHandler - public void onInventoryClick(InventoryClickEvent event) { - if (!(event.getWhoClicked() instanceof Player)) - return; - refreshPlayer((Player) event.getWhoClicked()); - } - - private void refresh() { - players.clear(); - EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().forEach(player -> { - if (Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, this))) - players.add(player); - }); - amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier"); - } - - private void refreshPlayer(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); - player.updateInventory(); - } - })); - } - - @Override - public long getTime() { - return this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "repeat-ticks"); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/FragilityCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/FragilityCurse.java deleted file mode 100644 index 57dedcb3..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/FragilityCurse.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.curse; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.NumberUtils; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerItemDamageEvent; -import org.bukkit.inventory.ItemStack; - -public class FragilityCurse extends EcoEnchant { - public FragilityCurse() { - super( - "fragility_curse", EnchantmentType.CURSE - ); - } - - // START OF LISTENERS - - @EventHandler - public void onItemDamage(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HarmlessnessCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HarmlessnessCurse.java deleted file mode 100644 index d69e3d68..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HarmlessnessCurse.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.curse; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class HarmlessnessCurse extends EcoEnchant { - public HarmlessnessCurse() { - super( - "harmlessness_curse", EnchantmentType.CURSE - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if (!EnchantmentUtils.passedChance(this, level)) - return; - - event.setDamage(0); - event.setCancelled(true); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HungerCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HungerCurse.java deleted file mode 100644 index 835aa48e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HungerCurse.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.curse; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.FoodLevelChangeEvent; - -public class HungerCurse extends EcoEnchant { - public HungerCurse() { - super( - "hunger_curse", EnchantmentType.CURSE - ); - } - - // START OF LISTENERS - - @EventHandler - public void onHunger(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java deleted file mode 100644 index c5ce396e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.curse; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.util.NumberUtils; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.util.Vector; - -public class InaccuracyCurse extends EcoEnchant { - public InaccuracyCurse() { - super( - "inaccuracy_curse", EnchantmentType.CURSE - ); - } - - // START OF LISTENERS - - - @Override - public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/MisfortuneCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/MisfortuneCurse.java deleted file mode 100644 index d272cfe1..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/MisfortuneCurse.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.curse; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; - -public class MisfortuneCurse extends EcoEnchant { - public MisfortuneCurse() { - super( - "misfortune_curse", EnchantmentType.CURSE - ); - } - - // START OF LISTENERS - - - @Override - public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) { - if (!EnchantmentUtils.passedChance(this, level)) - return; - - event.setDropItems(false); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/PermanenceCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/PermanenceCurse.java deleted file mode 100644 index fe95f235..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/PermanenceCurse.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.curse; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; - -public class PermanenceCurse extends EcoEnchant { - public PermanenceCurse() { - super( - "permanence_curse", EnchantmentType.CURSE - ); - } - - // START OF LISTENERS - - // Listeners are in anvil listeners -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abattoir.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abattoir.java deleted file mode 100644 index d5a673c4..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abattoir.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Monster; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Abattoir extends EcoEnchant { - public Abattoir() { - super( - "abattoir", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { - if(victim instanceof Monster) 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abrasion.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abrasion.java deleted file mode 100644 index 5653c3b3..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abrasion.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.nms.Cooldown; -import com.willfp.ecoenchants.util.DurabilityUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.Arrays; -public class Abrasion extends EcoEnchant { - public Abrasion() { - super( - "abrasion", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity uncastVictim, int level, EntityDamageByEntityEvent event) { - if(!(uncastVictim instanceof Player)) return; - Player victim = (Player) uncastVictim; - - boolean notcharged = this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"); - if (attacker instanceof Player && Cooldown.getCooldown((Player) attacker) != 1.0f && !notcharged) - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aerial.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aerial.java deleted file mode 100644 index ae6b1d0a..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aerial.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.metadata.FixedMetadataValue; - -public class Aerial extends EcoEnchant { - public Aerial() { - super( - "aerial", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, EntityShootBowEvent event) { - if (!(event.getProjectile() instanceof Arrow)) return; - - if (shooter.isOnGround()) return; - - event.getProjectile().setMetadata("shot-in-air", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - } - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aquatic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aquatic.java deleted file mode 100644 index 0f227201..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Aquatic.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.Material; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Aquatic extends EcoEnchant { - public Aquatic() { - super( - "aquatic", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arachnid.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arachnid.java deleted file mode 100644 index fb948bcb..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arachnid.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Spider; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Arachnid extends EcoEnchant { - public Arachnid() { - super( - "arachnid", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arcanic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arcanic.java deleted file mode 100644 index eb8f8207..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arcanic.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageEvent; -public class Arcanic extends EcoEnchant { - public Arcanic() { - super( - "arcanic", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onDamageWearingArmor(LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Atmospheric.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Atmospheric.java deleted file mode 100644 index acee34f9..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Atmospheric.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.ProjectileLaunchEvent; -import org.bukkit.metadata.FixedMetadataValue; - -public class Atmospheric extends EcoEnchant { - public Atmospheric() { - super( - "atmospheric", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onTridentLaunch(LivingEntity shooter, Trident trident, int level, ProjectileLaunchEvent event) { - if(shooter.isOnGround()) return; - - trident.setMetadata("shot-in-air", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - } - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Backstab.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Backstab.java deleted file mode 100644 index b7444411..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Backstab.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.util.Vector; - -public class Backstab extends EcoEnchant { - public Backstab() { - super( - "backstab", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Beheading.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Beheading.java deleted file mode 100644 index 38a82722..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Beheading.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.internal.DropQueue; -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; - -public class Beheading extends EcoEnchant { - public Beheading() { - super( - "beheading", EnchantmentType.NORMAL - ); - } - // START OF LISTENERS - - @EventHandler - public void onDeath(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlastMining.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlastMining.java deleted file mode 100644 index ee694518..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlastMining.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.BlockBreak; -import org.bukkit.Particle; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.metadata.FixedMetadataValue; - -import java.util.HashSet; -import java.util.Set; - -public class BlastMining extends EcoEnchant { - public BlastMining() { - super( - "blast_mining", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) { - if (block.hasMetadata("block-ignore")) - return; - - if(player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) return; - - boolean hasExploded = false; - - 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", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - BlockBreak.breakBlock(player, block1); - block1.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance()); - })); - - AnticheatManager.unexemptPlayer(player); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Bleed.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Bleed.java deleted file mode 100644 index eb8793a4..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Bleed.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.concurrent.atomic.AtomicInteger; - -public class Bleed extends EcoEnchant { - public Bleed() { - super( - "bleed", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if (attacker instanceof Player && Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - 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); - - new BukkitRunnable() { - @Override - public void run() { - currentBleedCount.addAndGet(1); - - victim.damage(bleedDamage); - - if (currentBleedCount.get() >= finalBleedCount) this.cancel(); - } - }.runTaskTimer(EcoEnchantsPlugin.getInstance(), 0, 10); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Blind.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Blind.java deleted file mode 100644 index 338e282d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Blind.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; - -public class Blind extends EcoEnchant { - public Blind() { - super( - "blind", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlockBreather.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlockBreather.java deleted file mode 100644 index ce808a31..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlockBreather.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageEvent; - -public class BlockBreather extends EcoEnchant { - public BlockBreather() { - super( - "block_breather", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { - if(!event.getCause().equals(EntityDamageEvent.DamageCause.SUFFOCATION)) - return; - - - if(!EnchantmentUtils.passedChance(this, level)) - return; - - event.setCancelled(true); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BossHunter.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BossHunter.java deleted file mode 100644 index 18a11c1b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BossHunter.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; -public class BossHunter extends EcoEnchant { - public BossHunter() { - super( - "boss_hunter", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { - if(!(victim instanceof Boss || victim instanceof ElderGuardian)) return; - - double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); - - double damageMultiplier = (level * multiplier) + 1; - - event.setDamage(event.getDamage() * damageMultiplier); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Buckshot.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Buckshot.java deleted file mode 100644 index 3fcbfc79..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Buckshot.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.NumberUtils; -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; -public class Buckshot extends EcoEnchant { - public Buckshot() { - super( - "buckshot", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Butchering.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Butchering.java deleted file mode 100644 index 3924a7af..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Butchering.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Monster; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Butchering extends EcoEnchant { - public Butchering() { - super( - "butchering", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if(victim instanceof Monster) return; - - double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level"); - event.setDamage(event.getDamage() + (level * multiplier)); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cerebral.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cerebral.java deleted file mode 100644 index dc2aaa0c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cerebral.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Cerebral extends EcoEnchant { - public Cerebral() { - super( - "cerebral", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Chopless.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Chopless.java deleted file mode 100644 index 0fccc02b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Chopless.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageEvent; - -public class Chopless extends EcoEnchant { - public Chopless() { - super( - "chopless", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDamageWearingArmor(LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cleave.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cleave.java deleted file mode 100644 index 6cfee1a4..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cleave.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.nms.Cooldown; -import org.bukkit.Bukkit; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.metadata.FixedMetadataValue; - -public class Cleave extends EcoEnchant { - public Cleave() { - super( - "cleave", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if (victim.hasMetadata("cleaved")) - return; - - if (attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - 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", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - ((LivingEntity) entity).damage(damage, attacker); - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> entity.removeMetadata("cleaved", EcoEnchantsPlugin.getInstance()), 5); - }); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Collateral.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Collateral.java deleted file mode 100644 index 87c4cb4f..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Collateral.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityShootBowEvent; -public class Collateral extends EcoEnchant { - public Collateral() { - super( - "collateral", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, EntityShootBowEvent event) { - arrow.setPierceLevel(level); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java deleted file mode 100644 index 712c7fc6..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Conclude extends EcoEnchant { - public Conclude() { - super( - "conclude", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Corrosive.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Corrosive.java deleted file mode 100644 index 2819c1bd..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Corrosive.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.util.DurabilityUtils; -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 java.util.ArrayList; -import java.util.Arrays; - -public class Corrosive extends EcoEnchant { - public Corrosive() { - super( - "corrosive", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity uncastVictim, Arrow arrow, int level, 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); - } - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cranial.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cranial.java deleted file mode 100644 index 01e8bc89..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cranial.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Cranial extends EcoEnchant { - public Cranial() { - super( - "cranial", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Criticals.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Criticals.java deleted file mode 100644 index 7b4df9d3..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Criticals.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Criticals extends EcoEnchant { - public Criticals() { - super( - "criticals", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cubism.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cubism.java deleted file mode 100644 index 0b6e0656..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cubism.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Slime; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Cubism extends EcoEnchant { - public Cubism() { - super( - "cubism", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defender.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defender.java deleted file mode 100644 index da3bc336..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defender.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Tameable; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Defender extends EcoEnchant { - public Defender() { - super( - "defender", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Deflection.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Deflection.java deleted file mode 100644 index e21ea660..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Deflection.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Deflection extends EcoEnchant { - public Deflection() { - super( - "deflection", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) { - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defusion.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defusion.java deleted file mode 100644 index 259a9561..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Defusion.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.Creeper; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Defusion extends EcoEnchant { - public Defusion() { - super( - "defusion", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dexterous.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dexterous.java deleted file mode 100644 index 840307fe..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dexterous.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; -public class Dexterous extends EcoEnchant { - public Dexterous() { - super( - "dexterous", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @EventHandler - public void onDextHold(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disable.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disable.java deleted file mode 100644 index cc382ceb..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disable.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -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; - -public class Disable extends EcoEnchant { - public Disable() { - super( - "disable", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - return; - } - - if(!EnchantmentUtils.passedChance(this, level)) - return; - - victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, level * 10, 5)); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disappear.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disappear.java deleted file mode 100644 index e969752c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disappear.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.Bukkit; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -public class Disappear extends EcoEnchant { - public Disappear() { - super( - "disappear", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diurnal.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diurnal.java deleted file mode 100644 index 6ee2fa6d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diurnal.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.World; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Diurnal extends EcoEnchant { - public Diurnal() { - super( - "diurnal", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diverse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diverse.java deleted file mode 100644 index 12c21844..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Diverse.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Diverse extends EcoEnchant { - public Diverse() { - super( - "diverse", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Drill.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Drill.java deleted file mode 100644 index a9e2ef90..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Drill.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.BlockBreak; -import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.util.Vector; - -public class Drill extends EcoEnchant { - public Drill() { - super( - "drill", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onBlockBreak(Player player, Block block, int level, 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", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), 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; - - BlockBreak.breakBlock(player, block1); - block1.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance()); - } - - AnticheatManager.unexemptPlayer(player); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dullness.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dullness.java deleted file mode 100644 index 95aa46de..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dullness.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -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; -public class Dullness extends EcoEnchant { - public Dullness() { - super( - "dullness", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dweller.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dweller.java deleted file mode 100644 index 5a6395a2..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dweller.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.Illager; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Dweller extends EcoEnchant { - public Dweller() { - super( - "dweller", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Economical.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Economical.java deleted file mode 100644 index 40754ebf..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Economical.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.optional.Prerequisite; -import org.bukkit.event.EventHandler; - -public class Economical extends EcoEnchant { - public Economical() { - super( - "economical", EnchantmentType.NORMAL, - Prerequisite.HasPaper - ); - } - - @EventHandler - public void onElytraBoost(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Electroshock.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Electroshock.java deleted file mode 100644 index c0938e80..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Electroshock.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.LightningUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Electroshock extends EcoEnchant { - public Electroshock() { - super( - "electroshock", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) { - double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage"); - - if(!EnchantmentUtils.passedChance(this, level)) - return; - - LightningUtils.strike(attacker, damage); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EndInfusion.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EndInfusion.java deleted file mode 100644 index 73026947..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EndInfusion.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.World; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class EndInfusion extends EcoEnchant { - public EndInfusion() { - super( - "end_infusion", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EnderSlayer.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EnderSlayer.java deleted file mode 100644 index afd15f26..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EnderSlayer.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -import java.util.HashSet; -import java.util.Set; -public class EnderSlayer extends EcoEnchant { - public EnderSlayer() { - super( - "ender_slayer", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - private static final Set endMobs = new HashSet() {{ - add(EntityType.ENDERMITE); - add(EntityType.ENDERMAN); - add(EntityType.ENDER_DRAGON); - add(EntityType.SHULKER); - }}; - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if (!endMobs.contains(victim.getType())) - return; - - double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level"); - - event.setDamage(event.getDamage() + (level * multiplier)); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Enderism.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Enderism.java deleted file mode 100644 index 52b8e33a..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Enderism.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; - -public class Enderism extends EcoEnchant { - public Enderism() { - super( - "enderism", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Evasion.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Evasion.java deleted file mode 100644 index 1cd3d72d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Evasion.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageEvent; -public class Evasion extends EcoEnchant { - public Evasion() { - super( - "evasion", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { - - if(!EnchantmentUtils.passedChance(this, level)) - return; - - event.setCancelled(true); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extinguishing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extinguishing.java deleted file mode 100644 index 38845a64..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extinguishing.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageEvent; -public class Extinguishing extends EcoEnchant { - public Extinguishing() { - super( - "extinguishing", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { - if(!event.getCause().equals(EntityDamageEvent.DamageCause.FIRE_TICK)) - return; - - - if(!EnchantmentUtils.passedChance(this, level)) - return; - - victim.setFireTicks(0); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extract.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extract.java deleted file mode 100644 index 21980a32..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extract.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.attribute.Attribute; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Extract extends EcoEnchant { - public Extract() { - super( - "extract", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Famine.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Famine.java deleted file mode 100644 index 9ce333a7..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Famine.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -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; - -public class Famine extends EcoEnchant { - public Famine() { - super( - "famine", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if (attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Farmhand.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Farmhand.java deleted file mode 100644 index 68fc1f73..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Farmhand.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.util.DurabilityUtils; -import com.willfp.ecoenchants.util.VectorUtils; -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; -public class Farmhand extends EcoEnchant { - public Farmhand() { - super( - "farmhand", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onTill(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fetching.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fetching.java deleted file mode 100644 index 8ac93d0e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fetching.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.entitydeathbyentity.EntityDeathByEntityEvent; -import com.willfp.ecoenchants.util.internal.DropQueue; -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 java.util.Collection; - -public class Fetching extends EcoEnchant { - public Fetching() { - super( - "fetching", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler(priority = EventPriority.HIGH) - public void onWolfKill(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.getDroppedExp(); - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java deleted file mode 100644 index eb77daf0..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Finality extends EcoEnchant { - public Finality() { - super( - "finality", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java deleted file mode 100644 index b7e53253..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Finishing extends EcoEnchant { - public Finishing() { - super( - "finishing", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FireAffinity.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FireAffinity.java deleted file mode 100644 index 4b59b9a3..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FireAffinity.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class FireAffinity extends EcoEnchant { - public FireAffinity() { - super( - "fire_affinity", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FirstStrike.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FirstStrike.java deleted file mode 100644 index cd2a7cac..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/FirstStrike.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.attribute.Attribute; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class FirstStrike extends EcoEnchant { - public FirstStrike() { - super( - "first_strike", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Flinch.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Flinch.java deleted file mode 100644 index 2e70a20b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Flinch.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; - -public class Flinch extends EcoEnchant { - public Flinch() { - super( - "flinch", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDeflect(Player blocker, LivingEntity attacker, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java deleted file mode 100644 index 8f7f28c0..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent; -import com.willfp.ecoenchants.util.NumberUtils; -import com.willfp.ecoenchants.util.interfaces.EcoRunnable; -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 java.util.HashMap; - -public class Forcefield extends EcoEnchant implements EcoRunnable { - public Forcefield() { - super( - "forcefield", EnchantmentType.NORMAL - ); - } - - private final HashMap players = new HashMap<>(); - - @EventHandler - public void onArmorEquip(ArmorEquipEvent event) { - refresh(); - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) { - refresh(); - } - - @EventHandler - public void onPlayerLeave(PlayerQuitEvent event) { - refresh(); - } - - private void refresh() { - players.clear(); - EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().forEach(player -> { - int level = EnchantChecks.getArmorPoints(player, this, 0); - if(level > 0) { - players.put(player, level); - } - }); - } - - @Override - public void run() { - players.forEach((player, level) -> { - if(this.getDisabledWorlds().contains(player.getWorld())) return; - double initialDistance = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance"); - double bonus = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level"); - double distance = initialDistance + (level * bonus); - double damagePerPoint = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level"); - 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, EcoEnchants.FORCEFIELD, 1); - } - } - }); - } - - @Override - public long getTime() { - return this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "repeat-ticks"); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Freerunner.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Freerunner.java deleted file mode 100644 index a888487b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Freerunner.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageEvent; -public class Freerunner extends EcoEnchant { - public Freerunner() { - super( - "freerunner", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onFallDamage(LivingEntity faller, int level, EntityDamageEvent event) { - - if(!EnchantmentUtils.passedChance(this, level)) - return; - - event.setCancelled(true); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Frozen.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Frozen.java deleted file mode 100644 index 60ce60e7..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Frozen.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.Bukkit; -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; - -public class Frozen extends EcoEnchant { - public Frozen() { - super( - "frozen", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onHurt(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); - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, points * 5, level)); - victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, points * 5, level)); - }, 1); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java deleted file mode 100644 index a560e438..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.entity.*; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.util.Vector; - -public class Fury extends EcoEnchant { - public Fury() { - super( - "fury", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if (attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Goliath.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Goliath.java deleted file mode 100644 index 06f7e290..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Goliath.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.attribute.Attribute; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Goliath extends EcoEnchant { - public Goliath() { - super( - "goliath", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Graceful.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Graceful.java deleted file mode 100644 index 229c4a2b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Graceful.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -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; - -@SuppressWarnings("deprecation") -public class Graceful extends EcoEnchant { - public Graceful() { - super( - "graceful", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onFall(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grapple.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grapple.java deleted file mode 100644 index 16f295ba..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grapple.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.util.Vector; -public class Grapple extends EcoEnchant { - public Grapple() { - super( - "grapple", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/GreenThumb.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/GreenThumb.java deleted file mode 100644 index 160a583d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/GreenThumb.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.util.DurabilityUtils; -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; -public class GreenThumb extends EcoEnchant { - public GreenThumb() { - super( - "green_thumb", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onInteract(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grit.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grit.java deleted file mode 100644 index cd2a1e96..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Grit.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.util.DurabilityUtils; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.inventory.meta.Damageable; - -public class Grit extends EcoEnchant { - public Grit() { - super( - "grit", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onGritHurt(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(player, player.getInventory().getItemInMainHand(), 1, player.getInventory().getHeldItemSlot()); - } - -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hellish.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hellish.java deleted file mode 100644 index 1691ac00..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hellish.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.World; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Hellish extends EcoEnchant { - public Hellish() { - super( - "hellish", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hook.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hook.java deleted file mode 100644 index 8f5a0342..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hook.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.util.Vector; - -public class Hook extends EcoEnchant { - public Hook() { - super( - "hook", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Horde.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Horde.java deleted file mode 100644 index 268c6724..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Horde.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Horde extends EcoEnchant { - public Horde() { - super( - "horde", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IceShot.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IceShot.java deleted file mode 100644 index 769d16bf..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IceShot.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -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; -public class IceShot extends EcoEnchant { - public IceShot() { - super( - "ice_shot", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Identify.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Identify.java deleted file mode 100644 index f363ef58..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Identify.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; - -public class Identify extends EcoEnchant { - public Identify() { - super( - "identify", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDeflect(Player blocker, LivingEntity attacker, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Ignite.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Ignite.java deleted file mode 100644 index 8089ed11..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Ignite.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -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; - -public class Ignite extends EcoEnchant { - public Ignite() { - super( - "ignite", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowHit(LivingEntity uncastShooter, int level, 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); - } - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IllusionAspect.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IllusionAspect.java deleted file mode 100644 index eeef9401..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IllusionAspect.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -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; -public class IllusionAspect extends EcoEnchant { - public IllusionAspect() { - super( - "illusion_aspect", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java deleted file mode 100644 index 0de29a5c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Impact extends EcoEnchant { - public Impact() { - super( - "impact", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { - - if (!EnchantmentUtils.passedChance(this, level)) - return; - - event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier")); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Incandescence.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Incandescence.java deleted file mode 100644 index d399c405..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Incandescence.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import org.bukkit.Bukkit; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Incandescence extends EcoEnchant { - public Incandescence() { - super( - "incandescence", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onIncandescenceHurt(EntityDamageByEntityEvent event) { - 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, 1); - - if (totalIncandescencePoints == 0) - return; - if(this.getDisabledWorlds().contains(player.getWorld())) return; - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - victim.setFireTicks(totalIncandescencePoints * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-point") + this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "initial-ticks")); - }, 1); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/InfernalTouch.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/InfernalTouch.java deleted file mode 100644 index 96067113..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/InfernalTouch.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.util.internal.DropQueue; -import com.willfp.ecoenchants.util.tuplets.Pair; -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 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 allowsFortune = new HashSet<>(Arrays.asList(Material.GOLD_INGOT, Material.IRON_INGOT)); - - public InfernalTouch() { - super( - "infernal_touch", EnchantmentType.NORMAL - ); - } - - 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)); - } - } - - private static Pair getOutput(Material input) { - Pair toReturn = recipes.get(input); - if(toReturn == null) return new Pair<>(input, 0); - return toReturn; - } - - // START OF LISTENERS - - @EventHandler - public void infernalTouchBreak(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.getBlock().getState() 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 && allowsFortune.contains(itemStack.getType())) { - itemStack.setAmount((int) Math.ceil(1 / ((double) fortune + 2) + ((double) fortune + 1) / 2)); - experience++; - } - } - - event.getItems().clear(); - - new DropQueue(player) - .setLocation(block.getLocation()) - .addItems(drops) - .addXP(experience) - .push(); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Inferno.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Inferno.java deleted file mode 100644 index 3b1dad80..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Inferno.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.ProjectileLaunchEvent; -public class Inferno extends EcoEnchant { - public Inferno() { - super( - "inferno", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentLaunch(LivingEntity shooter, Trident trident, int level, ProjectileLaunchEvent event) { - trident.setFireTicks(Integer.MAX_VALUE); - } - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { - if(trident.getFireTicks() <= 0) return; - - victim.setFireTicks(100); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java deleted file mode 100644 index 1ea9e557..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.entity.*; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.util.Vector; - -public class Infuriate extends EcoEnchant { - public Infuriate() { - super( - "infuriate", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDeflect(Player blocker, LivingEntity attacker, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Insecticide.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Insecticide.java deleted file mode 100644 index 25643470..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Insecticide.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Spider; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Insecticide extends EcoEnchant { - public Insecticide() { - super( - "insecticide", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java deleted file mode 100644 index b939f275..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockDamageEvent; -public class Instantaneous extends EcoEnchant { - public Instantaneous() { - super( - "instantaneous", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDamageBlock(Player player, Block block, int level, 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); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Invigoration.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Invigoration.java deleted file mode 100644 index 31d9038e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Invigoration.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; -public class Invigoration extends EcoEnchant { - public Invigoration() { - super( - "invigoration", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onInvigorationHurt(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(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Kinetic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Kinetic.java deleted file mode 100644 index 367bed3d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Kinetic.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageEvent; -public class Kinetic extends EcoEnchant { - public Kinetic() { - super( - "kinetic", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDamageWearingArmor(LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Launch.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Launch.java deleted file mode 100644 index 593c27dc..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Launch.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import org.bukkit.Bukkit; -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; - -public class Launch extends EcoEnchant { - public Launch() { - super( - "launch", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - @EventHandler - public void onFireworkUse(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); - - Bukkit.getScheduler().runTask(EcoEnchantsPlugin.getInstance(), () -> player.setVelocity(player.getVelocity().multiply(boost))); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Leeching.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Leeching.java deleted file mode 100644 index f54527f1..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Leeching.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.attribute.Attribute; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Leeching extends EcoEnchant { - public Leeching() { - super( - "leeching", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lesion.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lesion.java deleted file mode 100644 index 323b21cf..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lesion.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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.bukkit.scheduler.BukkitRunnable; - -import java.util.concurrent.atomic.AtomicInteger; - -public class Lesion extends EcoEnchant { - public Lesion() { - super( - "lesion", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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); - - new BukkitRunnable() { - @Override - public void run() { - currentBleedCount.addAndGet(1); - - victim.damage(bleedDamage); - - if(currentBleedCount.get() >= finalBleedCount) this.cancel(); - } - }.runTaskTimer(EcoEnchantsPlugin.getInstance(), 0, 10); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Levitate.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Levitate.java deleted file mode 100644 index 5d9e183c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Levitate.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; -public class Levitate extends EcoEnchant { - public Levitate() { - super( - "levitate", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LiquidShot.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LiquidShot.java deleted file mode 100644 index efa70308..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LiquidShot.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.*; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class LiquidShot extends EcoEnchant { - public LiquidShot() { - super( - "liquid_shot", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lumberjack.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lumberjack.java deleted file mode 100644 index fd4e601a..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lumberjack.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.BlockBreak; -import com.willfp.ecoenchants.util.BlockUtils; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.metadata.FixedMetadataValue; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -public class Lumberjack extends EcoEnchant { - public Lumberjack() { - super( - "lumberjack", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBlockBreak(Player player, Block block, int level, 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", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - if(!AntigriefManager.canBreakBlock(player, treeBlock)) continue; - - BlockBreak.breakBlock(player, treeBlock); - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> treeBlock.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance()),1); - } - - AnticheatManager.unexemptPlayer(player); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/MagmaWalker.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/MagmaWalker.java deleted file mode 100644 index 2a188a7b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/MagmaWalker.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.Bukkit; -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.metadata.FixedMetadataValue; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; -public class MagmaWalker extends EcoEnchant { - public MagmaWalker() { - super( - "magma_walker", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onLavaWalk(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", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - - long afterTicks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "remove-after-ticks"); - - BukkitRunnable replace = new BukkitRunnable() { - @Override - public void run() { - 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", EcoEnchantsPlugin.getInstance()); - this.cancel(); - } - } - } - }; - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - 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", EcoEnchantsPlugin.getInstance()); - } else { - replace.runTaskTimer(EcoEnchantsPlugin.getInstance(), afterTicks, afterTicks); - } - } - }, afterTicks); - } - - AnticheatManager.unexemptPlayer(player); - } - -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java deleted file mode 100644 index ff8ea3d8..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent; -import com.willfp.ecoenchants.util.VectorUtils; -import com.willfp.ecoenchants.util.interfaces.EcoRunnable; -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 java.util.HashMap; - -public class Magnetic extends EcoEnchant implements EcoRunnable { - public Magnetic() { - super( - "magnetic", EnchantmentType.NORMAL - ); - } - - private final HashMap players = new HashMap<>(); - private double initialDistance = 1; - private double bonus = 1; - - @EventHandler - public void onArmorEquip(ArmorEquipEvent event) { - refresh(); - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) { - refresh(); - } - - @EventHandler - public void onPlayerLeave(PlayerQuitEvent event) { - refresh(); - } - - private void refresh() { - players.clear(); - EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().forEach(player -> { - int level = EnchantChecks.getArmorPoints(player, this, 0); - if(level > 0) { - players.put(player, level); - } - }); - 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) { - if (((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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marking.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marking.java deleted file mode 100644 index a3fc9d1a..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marking.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.Bukkit; -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.bukkit.metadata.FixedMetadataValue; - -public class Marking extends EcoEnchant { - public Marking() { - super( - "marking", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { - int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); - int ticks = ticksPerLevel * level; - - victim.setMetadata("marked", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - victim.removeMetadata("marked", EcoEnchantsPlugin.getInstance()); - }, ticks); - } - - @EventHandler - public void onHitWhileMarked(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marksman.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marksman.java deleted file mode 100644 index f52cf4ed..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Marksman.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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.ProjectileLaunchEvent; -import org.bukkit.scheduler.BukkitRunnable; -public class Marksman extends EcoEnchant { - public Marksman() { - super( - "marksman", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onMarksmanShoot(ProjectileLaunchEvent 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; - Arrow a = (Arrow) event.getEntity(); - a.setGravity(false); - - int ticks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "remove-arrow-after-ticks"); - - new BukkitRunnable() { - @Override - public void run() { - if (!a.isOnGround()) { - a.remove(); - } - } - }.runTaskLater(EcoEnchantsPlugin.getInstance(), ticks); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java deleted file mode 100644 index a27e3ab4..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.internal.DropQueue; -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; -public class Necrotic extends EcoEnchant { - public Necrotic() { - super( - "necrotic", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void necroticKill(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/NetherInfusion.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/NetherInfusion.java deleted file mode 100644 index 8463bf9e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/NetherInfusion.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.World; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class NetherInfusion extends EcoEnchant { - public NetherInfusion() { - super( - "nether_infusion", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Netheric.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Netheric.java deleted file mode 100644 index 9dff1390..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Netheric.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.World; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Netheric extends EcoEnchant { - public Netheric() { - super( - "netheric", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Nocturnal.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Nocturnal.java deleted file mode 100644 index f4e8bb09..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Nocturnal.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.World; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Nocturnal extends EcoEnchant { - public Nocturnal() { - super( - "nocturnal", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Optics.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Optics.java deleted file mode 100644 index 25d2bd94..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Optics.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.Location; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Optics extends EcoEnchant { - public Optics() { - super( - "optics", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Oxygenate.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Oxygenate.java deleted file mode 100644 index 2061d1d2..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Oxygenate.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.util.NumberUtils; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; -public class Oxygenate extends EcoEnchant { - public Oxygenate() { - super( - "oxygenate", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBlockBreak(Player player, Block block, int level, 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); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Pacify.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Pacify.java deleted file mode 100644 index b3d0c2f1..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Pacify.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.Creeper; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Pacify extends EcoEnchant { - public Pacify() { - super( - "pacify", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paladin.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paladin.java deleted file mode 100644 index 4ac9bcd6..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paladin.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.Horse; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Paladin extends EcoEnchant { - public Paladin() { - super( - "paladin", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paralyze.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paralyze.java deleted file mode 100644 index 05bef2de..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paralyze.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; - -public class Paralyze extends EcoEnchant { - public Paralyze() { - super( - "paralyze", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDeflect(Player blocker, LivingEntity attacker, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parasitic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parasitic.java deleted file mode 100644 index ba443b2c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parasitic.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.attribute.Attribute; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Parasitic extends EcoEnchant { - public Parasitic() { - super( - "parasitic", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parry.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parry.java deleted file mode 100644 index 31aab665..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Parry.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Parry extends EcoEnchant { - public Parry() { - super( - "parry", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void parryHit(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Phantasm.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Phantasm.java deleted file mode 100644 index 894d2e61..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Phantasm.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; - -public class Phantasm extends EcoEnchant { - public Phantasm() { - super( - "phantasm", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Plasmic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Plasmic.java deleted file mode 100644 index 29159012..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Plasmic.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.util.optional.Prerequisite; -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 java.util.Arrays; - -public class Plasmic extends EcoEnchant { - public Plasmic() { - super( - "plasmic", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - private static final Material[] items; - - static { - if(Prerequisite.MinVer1_16.isMet()) { - 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 - }; - } else { - items = new Material[]{ - Material.DIAMOND_HELMET, - Material.DIAMOND_CHESTPLATE, - Material.DIAMOND_LEGGINGS, - Material.DIAMOND_BOOTS - }; - } - } - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Protector.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Protector.java deleted file mode 100644 index 07da1981..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Protector.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Tameable; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Protector extends EcoEnchant { - public Protector() { - super( - "protector", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity uncastVictim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Proximity.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Proximity.java deleted file mode 100644 index 2c693199..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Proximity.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Proximity extends EcoEnchant { - public Proximity() { - super( - "proximity", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Puncture.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Puncture.java deleted file mode 100644 index 62af3e74..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Puncture.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; -public class Puncture extends EcoEnchant { - public Puncture() { - super( - "puncture", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Quadrilateralism.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Quadrilateralism.java deleted file mode 100644 index a8414ea4..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Quadrilateralism.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Slime; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Quadrilateralism extends EcoEnchant { - public Quadrilateralism() { - super( - "quadrilateralism", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Radiance.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Radiance.java deleted file mode 100644 index 00cf1651..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Radiance.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; -public class Radiance extends EcoEnchant { - public Radiance() { - super( - "radiance", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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)); - } - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java deleted file mode 100644 index 165fa032..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.entity.*; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.util.Vector; - -public class Rage extends EcoEnchant { - public Rage() { - super( - "rage", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rapid.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rapid.java deleted file mode 100644 index 4902cdfd..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rapid.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityShootBowEvent; - -public class Rapid extends EcoEnchant { - public Rapid() { - super( - "rapid", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reel.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reel.java deleted file mode 100644 index 0f3a720f..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reel.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.util.VectorUtils; -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; - -public class Reel extends EcoEnchant { - public Reel() { - super( - "reel", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onFish(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reinforcement.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reinforcement.java deleted file mode 100644 index f224f7fa..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reinforcement.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageEvent; -public class Reinforcement extends EcoEnchant { - public Reinforcement() { - super( - "reinforcement", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDamageWearingArmor(LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rejuvenation.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rejuvenation.java deleted file mode 100644 index 6c6dac78..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rejuvenation.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityRegainHealthEvent; -public class Rejuvenation extends EcoEnchant { - public Rejuvenation() { - super( - "rejuvenation", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onRejuvenationHeal(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Replenish.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Replenish.java deleted file mode 100644 index 1f085904..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Replenish.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -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.bukkit.scheduler.BukkitRunnable; -public class Replenish extends EcoEnchant { - public Replenish() { - super( - "replenish", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBlockBreak(Player player, Block block, int level, 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); - - new BukkitRunnable() { - @Override - public void run() { - block.setType(type); - block.setBlockData(data); - } - }.runTaskLater(EcoEnchantsPlugin.getInstance(), 1); - } - - data.setAge(0); - - new BukkitRunnable() { - @Override - public void run() { - block.setType(type); - block.setBlockData(data); - } - }.runTaskLater(EcoEnchantsPlugin.getInstance(), 1); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Respirator.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Respirator.java deleted file mode 100644 index 7f49583a..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Respirator.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageEvent; - -public class Respirator extends EcoEnchant { - public Respirator() { - super( - "respirator", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDamageWearingArmor(LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Revenant.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Revenant.java deleted file mode 100644 index 7f892f30..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Revenant.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; - -public class Revenant extends EcoEnchant { - public Revenant() { - super( - "revenant", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sating.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sating.java deleted file mode 100644 index 65ee48d1..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sating.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -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; -public class Sating extends EcoEnchant { - public Sating() { - super( - "sating", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onSatingHunger(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Serrated.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Serrated.java deleted file mode 100644 index 1c69cc1f..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Serrated.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Serrated extends EcoEnchant { - public Serrated() { - super( - "serrated", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Settle.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Settle.java deleted file mode 100644 index 79374fb6..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Settle.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Creeper; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Settle extends EcoEnchant { - public Settle() { - super( - "settle", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Shockwave.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Shockwave.java deleted file mode 100644 index 9c9af193..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Shockwave.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.nms.TridentStack; -import org.bukkit.Bukkit; -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.bukkit.metadata.FixedMetadataValue; -import org.bukkit.scheduler.BukkitRunnable; -public class Shockwave extends EcoEnchant { - public Shockwave() { - super( - "shockwave", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onShoot(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 = TridentStack.getTridentStack((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; - - new BukkitRunnable() { - @Override - public void run() { - if(entity.isOnGround() || entity.isInBlock() || entity.isDead()) this.cancel(); - entity.getNearbyEntities(1.5, 1.5, 1.5).stream() - .filter(entity1 -> entity1 instanceof LivingEntity) - .filter(entity1 -> entity1 != player) - .filter(entity1 -> !entity1.hasMetadata("shockwaved")) - .forEach((mob -> { - ((LivingEntity) mob).damage(finalDamage, player); - mob.setMetadata("shockwaved", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - mob.removeMetadata("shockwaved", EcoEnchantsPlugin.getInstance()); - }, 10); - } - )); - } - }.runTaskTimer(EcoEnchantsPlugin.getInstance(), 4, ticks); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/ShotAssist.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/ShotAssist.java deleted file mode 100644 index e1ca8549..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/ShotAssist.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; -public class ShotAssist extends EcoEnchant { - public ShotAssist() { - super( - "shot_assist", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onHit(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(); - Arrow arrow = (Arrow) event.getDamager(); - LivingEntity victim = (LivingEntity) event.getEntity(); - - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sickening.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sickening.java deleted file mode 100644 index a9d02b8c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sickening.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; - -public class Sickening extends EcoEnchant { - public Sickening() { - super( - "sickening", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slaughter.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slaughter.java deleted file mode 100644 index b4308bee..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slaughter.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Monster; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Slaughter extends EcoEnchant { - public Slaughter() { - super( - "slaughter", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { - if(victim instanceof Monster) 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slicing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slicing.java deleted file mode 100644 index c557d3bb..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slicing.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.DurabilityUtils; -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 java.util.ArrayList; -public class Slicing extends EcoEnchant { - public Slicing() { - super( - "slicing", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - private final ArrayList entities = new ArrayList<>(); - - @EventHandler - public void onPlayerCollide(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(EcoEnchantsPlugin.getInstance(), () -> 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spearfishing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spearfishing.java deleted file mode 100644 index 4e37880c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spearfishing.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.TridentStack; -import com.willfp.ecoenchants.util.NumberUtils; -import com.willfp.ecoenchants.util.internal.DropQueue; -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 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 - ); - } - - // START OF LISTENERS - - @EventHandler - public void onSpearfishingLand(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 = TridentStack.getTridentStack(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); - - new DropQueue(player) - .addItem(drop) - .setItem(item) - .setLocation(trident.getLocation()) - .push(); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spiked.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spiked.java deleted file mode 100644 index 280dedc6..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spiked.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerFishEvent; -public class Spiked extends EcoEnchant { - public Spiked() { - super( - "spiked", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onFish(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Splash.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Splash.java deleted file mode 100644 index 3d9b9500..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Splash.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.TridentStack; -import org.bukkit.Bukkit; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -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.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.inventory.ItemStack; -public class Splash extends EcoEnchant { - public Splash() { - super( - "splash", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onSplashLand(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(); - Player player = (Player) event.getEntity().getShooter(); - - ItemStack item = TridentStack.getTridentStack(trident); - - if (!EnchantChecks.item(item, this)) return; - if(this.getDisabledWorlds().contains(player.getWorld())) return; - - int level = EnchantChecks.getItemLevel(item, this); - - 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 e : trident.getNearbyEntities(radius, radius, radius)) { - if(e.hasMetadata("NPC")) continue; - - if (!(e instanceof LivingEntity)) continue; - LivingEntity entity = (LivingEntity) e; - if(e.equals(player)) continue; - - Bukkit.getPluginManager().callEvent(new EntityDamageByEntityEvent(trident, entity, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); - - if(!AntigriefManager.canInjure(player, entity)) continue; - entity.damage(damage, trident); - } - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stab.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stab.java deleted file mode 100644 index 7cda6122..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stab.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Stab extends EcoEnchant { - public Stab() { - super( - "stab", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stalwart.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stalwart.java deleted file mode 100644 index 86a96c59..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stalwart.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; - -public class Stalwart extends EcoEnchant { - public Stalwart() { - super( - "stalwart", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDamageWearingArmor(LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stamina.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stamina.java deleted file mode 100644 index 362b33e2..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stamina.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -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; -public class Stamina extends EcoEnchant { - public Stamina() { - super( - "stamina", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onStaminaHunger(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StoneSwitcher.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StoneSwitcher.java deleted file mode 100644 index 951599c2..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StoneSwitcher.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.internal.DropQueue; -import com.willfp.ecoenchants.util.NumberUtils; -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; -public class StoneSwitcher extends EcoEnchant { - public StoneSwitcher() { - super( - "stone_switcher", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBlockBreak(Player player, Block block, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StrayAspect.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StrayAspect.java deleted file mode 100644 index 2b902887..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StrayAspect.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -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; -public class StrayAspect extends EcoEnchant { - public StrayAspect() { - super( - "stray_aspect", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Succession.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Succession.java deleted file mode 100644 index 4e1c0e52..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Succession.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.DurabilityUtils; -import org.bukkit.Bukkit; -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; -public class Succession extends EcoEnchant { - public Succession() { - super( - "succession", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, EntityShootBowEvent event) { - int number = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "extra-arrows"); - - boolean fire = EnchantChecks.mainhand(shooter, Enchantment.ARROW_FIRE); - - for (int i = 1; i <= number; i++) { - Bukkit.getScheduler().scheduleSyncDelayedTask(EcoEnchantsPlugin.getInstance(), () -> { - 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")) { - if(shooter instanceof Player) { - DurabilityUtils.damageItem((Player) shooter, ((Player) shooter).getInventory().getItemInMainHand(), 1, ((Player) shooter).getInventory().getHeldItemSlot()); - } - } - }, i * 2L); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java deleted file mode 100644 index 7dc53ba2..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Supercritical extends EcoEnchant { - public Supercritical() { - super( - "supercritical", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - return; - } - - if(!EnchantmentUtils.passedChance(this, level)) - return; - - event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier")); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sycophant.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sycophant.java deleted file mode 100644 index a4a1a1e8..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sycophant.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.attribute.Attribute; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Sycophant extends EcoEnchant { - public Sycophant() { - super( - "sycophant", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDeflect(Player blocker, LivingEntity attacker, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tectonic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tectonic.java deleted file mode 100644 index 1dc4aab7..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tectonic.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent; - -import java.util.Collection; -public class Tectonic extends EcoEnchant { - public Tectonic() { - super( - "tectonic", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onFallDamage(LivingEntity faller, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java deleted file mode 100644 index 7a127c74..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.ecoenchants.special.Soulbound; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.entitydeathbyentity.EntityDeathByEntityEvent; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.TridentStack; -import com.willfp.ecoenchants.util.internal.DropQueue; -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 java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class Telekinesis extends EcoEnchant { - public Telekinesis() { - super( - "telekinesis", EnchantmentType.NORMAL - ); - } - - private static boolean always = false; - - // START OF LISTENERS - - @Override - protected void postUpdate() { - always = ConfigManager.getConfig().getBool("drops.force-dropqueue"); - } - - // For block drops - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void telekinesisDropItem(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()); - - 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(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(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 = TridentStack.getTridentStack((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.getDroppedExp(); - Collection drops = event.getDrops(); - - if(entity instanceof Player) { - if(Soulbound.getSoulboundItems((Player) entity) != null) { - drops.removeAll(Soulbound.getSoulboundItems((Player) entity)); - } - } - - new DropQueue(player) - .addItems(drops) - .setLocation(entity.getLocation()) - .addXP(xp) - .forceTelekinesis() - .push(); - - event.getDeathEvent().setDroppedExp(0); - event.getDeathEvent().getDrops().clear(); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thor.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thor.java deleted file mode 100644 index 2f67ee72..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thor.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -import com.willfp.ecoenchants.util.LightningUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Thor extends EcoEnchant { - public Thor() { - super( - "thor", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if (attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - return; - } - - if (!EnchantmentUtils.passedChance(this, level)) - return; - - double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "lightning-damage"); - - LightningUtils.strike(victim, damage); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thrive.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thrive.java deleted file mode 100644 index a753c5ad..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thrive.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent; -import org.bukkit.attribute.Attribute; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.scheduler.BukkitRunnable; -public class Thrive extends EcoEnchant { - public Thrive() { - super( - "thrive", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onArmorEquip(ArmorEquipEvent event) { - final Player player = event.getPlayer(); - - new BukkitRunnable() { - public void run() { - int totalProsperityPoints = EnchantChecks.getArmorPoints(player, EcoEnchants.PROSPERITY, 0); - int totalThrivePoints = EnchantChecks.getArmorPoints(player, EcoEnchants.THRIVE, 0); - if (totalThrivePoints == 0 && totalProsperityPoints == 0) { - player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue()); - return; - } - if(EcoEnchants.THRIVE.getDisabledWorlds().contains(player.getWorld())) return; - - double thriveBonus = totalThrivePoints * EcoEnchants.THRIVE.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-point"); - double prosperityBonus = totalProsperityPoints * EcoEnchants.PROSPERITY.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-point"); - double bonus = thriveBonus + prosperityBonus; - - boolean onMaxHealth = false; - if (player.getHealth() == player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) - onMaxHealth = true; - - player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue() + bonus); - boolean finalOnMaxHealth = onMaxHealth; - new BukkitRunnable() { - public void run() { - if (finalOnMaxHealth) { - player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 255, false, false, false)); - } - } - }.runTaskLater(EcoEnchantsPlugin.getInstance(), 1); - } - }.runTaskLater(EcoEnchantsPlugin.getInstance(), 1); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tornado.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tornado.java deleted file mode 100644 index 6fb674d7..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tornado.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.Bukkit; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.util.Vector; -public class Tornado extends EcoEnchant { - public Tornado() { - super( - "tornado", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - double baseVelocity = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-per-level"); - double yVelocity = baseVelocity * level; - - Vector toAdd = new Vector(0, yVelocity, 0); - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - victim.setVelocity(victim.getVelocity().clone().add(toAdd)); - }, 1); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Toxic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Toxic.java deleted file mode 100644 index 2cee5886..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Toxic.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -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; - -public class Toxic extends EcoEnchant { - public Toxic() { - super( - "toxic", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if (attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - return; - } - - if (!EnchantmentUtils.passedChance(this, level)) - return; - - victim.addPotionEffect(new PotionEffect(PotionEffectType.POISON, level * 10 + 20, level)); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Transfuse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Transfuse.java deleted file mode 100644 index 8d6d9848..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Transfuse.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.internal.DropQueue; -import com.willfp.ecoenchants.util.NumberUtils; -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 java.util.stream.Collectors; - -public class Transfuse extends EcoEnchant { - public Transfuse() { - super( - "transfuse", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBlockBreak(Player player, Block block, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tripleshot.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tripleshot.java deleted file mode 100644 index abc6fd51..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Tripleshot.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; -public class Tripleshot extends EcoEnchant { - public Tripleshot() { - super( - "tripleshot", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VampireAspect.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VampireAspect.java deleted file mode 100644 index d75ee15c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VampireAspect.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -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; -public class VampireAspect extends EcoEnchant { - public VampireAspect() { - super( - "vampire_aspect", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - return; - } - - if(!EnchantmentUtils.passedChance(this, level)) - return; - - victim.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, level * 10 + 20, level)); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Vein.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Vein.java deleted file mode 100644 index 5689b93f..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Vein.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.BlockBreak; -import com.willfp.ecoenchants.util.BlockUtils; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.metadata.FixedMetadataValue; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -public class Vein extends EcoEnchant { - public Vein() { - super( - "vein", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBlockBreak(Player player, Block block, int level, 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", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - if (!AntigriefManager.canBreakBlock(player, veinBlock)) continue; - - BlockBreak.breakBlock(player, veinBlock); - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> veinBlock.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance()), 1); - } - - AnticheatManager.unexemptPlayer(player); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Venom.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Venom.java deleted file mode 100644 index 1040f7d3..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Venom.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -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; - -public class Venom extends EcoEnchant { - public Venom() { - super( - "venom", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { - if (!EnchantmentUtils.passedChance(this, level)) - return; - - victim.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, level * 10 + 20, level)); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VoidAffinity.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VoidAffinity.java deleted file mode 100644 index a15f3329..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VoidAffinity.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.World; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class VoidAffinity extends EcoEnchant { - public VoidAffinity() { - super( - "void_affinity", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Voltage.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Voltage.java deleted file mode 100644 index 37e37cb5..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Voltage.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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 java.util.Arrays; - -public class Voltage extends EcoEnchant { - public Voltage() { - super( - "voltage", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - 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, - }; - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAffinity.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAffinity.java deleted file mode 100644 index 43d36b21..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAffinity.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.Material; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class WaterAffinity extends EcoEnchant { - public WaterAffinity() { - super( - "water_affinity", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAspect.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAspect.java deleted file mode 100644 index 6ec71838..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/WaterAspect.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; -public class WaterAspect extends EcoEnchant { - public WaterAspect() { - super( - "water_aspect", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Weakening.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Weakening.java deleted file mode 100644 index 840eda9e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Weakening.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.Bukkit; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.metadata.FixedMetadataValue; - -public class Weakening extends EcoEnchant { - public Weakening() { - super( - "weakening", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); - int ticks = ticksPerLevel * level; - - victim.setMetadata("weak", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - victim.removeMetadata("weak", EcoEnchantsPlugin.getInstance()); - }, ticks); - } - - @EventHandler - public void onDamage(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wisdom.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wisdom.java deleted file mode 100644 index 1064f679..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wisdom.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.naturalexpgainevent.NaturalExpGainEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -public class Wisdom extends EcoEnchant { - public Wisdom() { - super( - "wisdom", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onExpChange(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wound.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wound.java deleted file mode 100644 index ef9b2f90..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wound.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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.scheduler.BukkitRunnable; - -import java.util.concurrent.atomic.AtomicInteger; - -public class Wound extends EcoEnchant { - public Wound() { - super( - "wound", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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); - - new BukkitRunnable() { - @Override - public void run() { - currentBleedCount.addAndGet(1); - - victim.damage(bleedDamage); - - if (currentBleedCount.get() >= finalBleedCount) this.cancel(); - } - }.runTaskTimer(EcoEnchantsPlugin.getInstance(), 0, 10); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Zeus.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Zeus.java deleted file mode 100644 index aa6cd9c8..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Zeus.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.normal; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.LightningUtils; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Zeus extends EcoEnchant { - public Zeus() { - super( - "zeus", EnchantmentType.NORMAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java deleted file mode 100644 index 528b28a1..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.NumberUtils; -import org.bukkit.Bukkit; -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.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; - -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 - ); - } - - // START OF LISTENERS - - @EventHandler - public void aimingLaunch(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 = new BukkitRunnable() { - @Override - public void run() { - List nearbyEntities = (List)(List) Arrays.asList(arrow.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 distance = Double.MAX_VALUE; - for(LivingEntity livingEntity : nearbyEntities) { - double currentDistance = livingEntity.getLocation().distance(arrow.getLocation()); - if(currentDistance >= distance) continue; - - distance = 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); - - new BukkitRunnable() { - @Override - public void run() { - checksPerformed.addAndGet(1); - if(checksPerformed.get() > checks) this.cancel(); - if(arrow.isDead() || arrow.isInBlock() || arrow.isOnGround()) this.cancel(); - Bukkit.getScheduler().runTask(EcoEnchantsPlugin.getInstance(), runnable); - } - }.runTaskTimer(EcoEnchantsPlugin.getInstance(), 3, period); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Annihilate.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Annihilate.java deleted file mode 100644 index 2a39f884..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Annihilate.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.util.Vector; -public class Annihilate extends EcoEnchant { - public Annihilate() { - super( - "annihilate", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java deleted file mode 100644 index 2ad5488a..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Trident; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Bladed extends EcoEnchant { - public Bladed() { - super( - "bladed", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bolt.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bolt.java deleted file mode 100644 index 02eefc93..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bolt.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -import com.willfp.ecoenchants.util.LightningUtils; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Bolt extends EcoEnchant { - public Bolt() { - super( - "bolt", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - return; - } - if(!EnchantmentUtils.passedChance(this, level)) - return; - - double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "lightning-damage"); - - LightningUtils.strike(victim, damage); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Carve.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Carve.java deleted file mode 100644 index bc2c7e61..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Carve.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.nms.Cooldown; -import org.bukkit.Bukkit; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.metadata.FixedMetadataValue; -public class Carve extends EcoEnchant { - public Carve() { - super( - "carve", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - return; - } - - victim.getNearbyEntities(radius, radius, radius).stream() - .filter(entity -> entity instanceof LivingEntity) - .filter(entity -> !entity.equals(attacker)) - .forEach(entity -> { - entity.setMetadata("carved", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - ((LivingEntity) entity).damage(damage, attacker); - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> entity.removeMetadata("carved", EcoEnchantsPlugin.getInstance()), 20); - }); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java deleted file mode 100644 index 88b1ccd0..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -public class Confusion extends EcoEnchant { - public Confusion() { - super( - "confusion", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity uncastVictim, int level, EntityDamageByEntityEvent event) { - if(!(uncastVictim instanceof Player)) return; - Player victim = (Player) uncastVictim; - - if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Energizing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Energizing.java deleted file mode 100644 index 5d36f112..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Energizing.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; - -public class Energizing extends EcoEnchant { - public Energizing() { - super( - "energizing", EnchantmentType.SPECIAL - ); - } - // START OF LISTENERS - - - @Override - public void onBlockBreak(Player player, Block block, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java deleted file mode 100644 index 1d60d35c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - -public class Force extends EcoEnchant { - public Force() { - super( - "force", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Frenzy.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Frenzy.java deleted file mode 100644 index 2541be95..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Frenzy.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; - -public class Frenzy extends EcoEnchant { - public Frenzy() { - super( - "frenzy", EnchantmentType.SPECIAL - ); - } - // START OF LISTENERS - - @EventHandler - public void onFrenzyKill(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Harpoon.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Harpoon.java deleted file mode 100644 index 1f77c3e1..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Harpoon.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerFishEvent; -public class Harpoon extends EcoEnchant { - public Harpoon() { - super( - "harpoon", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onFish(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Indestructibility.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Indestructibility.java deleted file mode 100644 index 8fc1b4da..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Indestructibility.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.NumberUtils; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerItemDamageEvent; -import org.bukkit.inventory.ItemStack; -public class Indestructibility extends EcoEnchant { - public Indestructibility() { - super( - "indestructibility", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onItemDamage(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Instability.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Instability.java deleted file mode 100644 index ee4f7b03..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Instability.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -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; -public class Instability extends EcoEnchant { - public Instability() { - super( - "instability", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onInstabilityLand(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(); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Intellect.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Intellect.java deleted file mode 100644 index 57748e30..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Intellect.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.naturalexpgainevent.NaturalExpGainEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -public class Intellect extends EcoEnchant { - public Intellect() { - super( - "intellect", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - @EventHandler - public void onExpChange(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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/LifeSteal.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/LifeSteal.java deleted file mode 100644 index 28ddae0d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/LifeSteal.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.attribute.Attribute; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class LifeSteal extends EcoEnchant { - public LifeSteal() { - super( - "life_steal", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Pentashot.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Pentashot.java deleted file mode 100644 index a7452d30..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Pentashot.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -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; -public class Pentashot extends EcoEnchant { - public Pentashot() { - super( - "pentashot", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, EntityShootBowEvent event) { - for (int i = -2; i <= 2; 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Preservation.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Preservation.java deleted file mode 100644 index 6692c06c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Preservation.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageEvent; -public class Preservation extends EcoEnchant { - public Preservation() { - super( - "preservation", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDamageWearingArmor(LivingEntity victim, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Prosperity.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Prosperity.java deleted file mode 100644 index 55c2a4f2..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Prosperity.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; - -public class Prosperity extends EcoEnchant { - public Prosperity() { - super( - "prosperity", EnchantmentType.SPECIAL - ); - } - - // Prosperity listeners are located in Thrive -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java deleted file mode 100644 index a3d03c48..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.nms.Cooldown; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Razor extends EcoEnchant { - public Razor() { - super( - "razor", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, 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")) { - if(attacker instanceof Player) { - extra *= Cooldown.getCooldown((Player) attacker); - } - } - - event.setDamage(event.getDamage() + extra); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java deleted file mode 100644 index 88891ca7..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.DurabilityUtils; -import com.willfp.ecoenchants.util.interfaces.EcoRunnable; -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 java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -public class Repairing extends EcoEnchant implements EcoRunnable { - 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(EntityPickupItemEvent event) { - if(!(event.getEntity() instanceof Player)) - return; - refreshPlayer((Player) event.getEntity()); - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) { - refresh(); - } - - @EventHandler - public void onPlayerLeave(PlayerQuitEvent event) { - refresh(); - } - - @EventHandler - public void onInventoryDrop(EntityDropItemEvent event) { - if(!(event.getEntity() instanceof Player)) - return; - refreshPlayer((Player) event.getEntity()); - } - - @EventHandler - public void onInventoryClick(InventoryClickEvent event) { - if(!(event.getWhoClicked() instanceof Player)) - return; - refreshPlayer((Player) event.getWhoClicked()); - } - - private void refresh() { - players.clear(); - EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().forEach(player -> { - if(Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, this))) - players.add(player); - }); - amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier"); - } - - private void refreshPlayer(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); - player.updateInventory(); - } - })); - } - - @Override - public long getTime() { - return this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "repeat-ticks"); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java deleted file mode 100644 index 4ec2cece..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import org.bukkit.Bukkit; -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 java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Objects; -public class Soulbound extends EcoEnchant { - public Soulbound() { - super( - "soulbound", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - private static final HashMap> soulboundItemsMap = new HashMap<>(); - - public static List getSoulboundItems(Player player) { - return soulboundItemsMap.get(player); - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onSoulboundDeath(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; - - Arrays.stream(player.getInventory().getContents()).filter(Objects::nonNull).forEach((itemStack -> { - if(itemStack.containsEnchantment(this)) soulboundItems.add(itemStack); - - if(itemStack.getItemMeta() instanceof EnchantmentStorageMeta) { - if(((EnchantmentStorageMeta) itemStack.getItemMeta()).getStoredEnchants().containsKey(this)) soulboundItems.add(itemStack); - } - })); - - event.getDrops().removeAll(soulboundItems); - - soulboundItemsMap.remove(player); - soulboundItemsMap.put(player, soulboundItems); - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onSoulboundRespawn(PlayerRespawnEvent event) { - if(!soulboundItemsMap.containsKey(event.getPlayer())) return; - - List soulboundItems = soulboundItemsMap.get(event.getPlayer()); - - soulboundItems.forEach((itemStack -> { - if(Arrays.asList(event.getPlayer().getInventory().getContents()).contains(itemStack)) return; - - event.getPlayer().getInventory().addItem(itemStack); - })); - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - soulboundItemsMap.remove(event.getPlayer()); - }, 1); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Spring.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Spring.java deleted file mode 100644 index bb37d1ea..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Spring.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.player.PlayerMoveEvent; -public class Spring extends EcoEnchant { - public Spring() { - super( - "spring", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { - if (event.getCause() == EntityDamageEvent.DamageCause.FALL) { - event.setCancelled(true); - } - } - - @Override - public void onJump(Player player, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Streamlining.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Streamlining.java deleted file mode 100644 index 11db94f1..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Streamlining.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent; -import org.bukkit.entity.Player; -public class Streamlining extends EcoEnchant { - public Streamlining() { - super( - "streamlining", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onArmorEquip(Player player, int level, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Volatile.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Volatile.java deleted file mode 100644 index f33ef339..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Volatile.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.special; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.Cooldown; -import org.bukkit.Location; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -public class Volatile extends EcoEnchant { - public Volatile() { - super( - "volatile", EnchantmentType.SPECIAL - ); - } - - // START OF LISTENERS - - - @Override - public void onMeleeAttack(LivingEntity uncastAttacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if(!(uncastAttacker instanceof Player)) return; - - Player attacker = (Player) uncastAttacker; - - if (Cooldown.getCooldown(attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) - 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) { - if (!AntigriefManager.canBreakBlock(attacker, event.getEntity().getLocation().getWorld().getBlockAt(event.getEntity().getLocation()))) - return; - } - - double distance = attacker.getLocation().distance(victim.getLocation()); - Location explosionLoc = victim.getEyeLocation(); - - victim.getWorld().createExplosion(explosionLoc, power, fire, breakblocks); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Ascend.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Ascend.java deleted file mode 100644 index 6aed4683..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Ascend.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.spell; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.itemtypes.Spell; -import org.bukkit.Bukkit; -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.metadata.FixedMetadataValue; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public class Ascend extends Spell { - public Ascend() { - super("ascend"); - } - - @Override - public void onUse(Player player, int level, 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-damage", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> player.removeMetadata("ignore-fall-damage", EcoEnchantsPlugin.getInstance()), ticks * 4L); - } - - @EventHandler - public void onFallDamage(EntityDamageEvent event) { - if(!event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) - return; - - if(!event.getEntity().hasMetadata("ignore-fall-damage")) - return; - - event.setCancelled(true); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Charge.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Charge.java deleted file mode 100644 index 5330223a..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Charge.java +++ /dev/null @@ -1,22 +0,0 @@ -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; - -public class Charge extends Spell { - public Charge() { - super("charge"); - } - - @Override - public void onUse(Player player, int level, 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); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Dynamite.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Dynamite.java deleted file mode 100644 index 2abd6aa0..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Dynamite.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.spell; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.itemtypes.Spell; -import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.BlockBreak; -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.bukkit.metadata.FixedMetadataValue; - -import java.util.HashSet; -import java.util.Set; - -public class Dynamite extends Spell { - public Dynamite() { - super("dynamite"); - } - - @Override - public void onUse(Player player, int level, PlayerInteractEvent event) { - Block block = event.getClickedBlock(); - - if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) - return; - - if (block == null) return; - - if (block.hasMetadata("block-ignore")) { - return; - } - - 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", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - BlockBreak.breakBlock(player, block1); - block1.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance()); - })); - - AnticheatManager.unexemptPlayer(player); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Missile.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Missile.java deleted file mode 100644 index 1ada3b4f..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Missile.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.spell; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -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.bukkit.metadata.FixedMetadataValue; - -public class Missile extends Spell { - public Missile() { - super("missile"); - } - - @Override - public void onUse(Player player, int level, 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", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * level)); - skull.setMetadata("nobreak", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - skull.setShooter(player); - } - - @EventHandler(priority = EventPriority.LOW) - public void onWitherSkullDamage(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(); - - event.setDamage(multiplier); - } - - @EventHandler - public void onWitherSkullExplode(EntityExplodeEvent event) { - if (!(event.getEntity() instanceof WitherSkull)) return; - if (event.getEntity().getMetadata("nobreak").isEmpty()) return; - - event.setCancelled(true); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Quake.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Quake.java deleted file mode 100644 index 28a6191a..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Quake.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoenchants.enchantments.ecoenchants.spell; - -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.itemtypes.Spell; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerInteractEvent; - -import java.util.Collection; - -public class Quake extends Spell { - public Quake() { - super("quake"); - } - - @Override - public void onUse(Player player, int level, 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); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Vitalize.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Vitalize.java deleted file mode 100644 index 3338be70..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Vitalize.java +++ /dev/null @@ -1,17 +0,0 @@ -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; - -public class Vitalize extends Spell { - public Vitalize() { - super("vitalize"); - } - - @Override - public void onUse(Player player, int level, PlayerInteractEvent event) { - player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java deleted file mode 100644 index 6854b380..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java +++ /dev/null @@ -1,166 +0,0 @@ -package com.willfp.ecoenchants.enchantments.itemtypes; - -import com.google.common.util.concurrent.AtomicDouble; -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.nms.TridentStack; -import com.willfp.ecoenchants.util.NumberUtils; -import com.willfp.ecoenchants.util.optional.Prerequisite; -import org.bukkit.Location; -import org.bukkit.Particle; -import org.bukkit.block.Block; -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.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.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; -import org.jetbrains.annotations.ApiStatus; - -/** - * Wrapper for Artifact enchantments - * in order to reduce copying existing code between artifacts. - */ -public abstract class Artifact extends EcoEnchant { - private Particle particle; - private Particle.DustOptions extra; - - protected Artifact(String key, 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(); - } - - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "6.0.0") - protected Artifact(String key, Class plugin, Prerequisite... prerequisites) { - this(key, prerequisites); - } - - public abstract Particle getParticle(); - - public Particle.DustOptions getDustOptions() { - return null; - } - - @EventHandler - public void onBreak(BlockBreakEvent event) { - Player player = event.getPlayer(); - Block block = event.getBlock(); - - if (!this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "on-blocks").contains(block.getType().name().toLowerCase())) - return; - - if (!EnchantChecks.mainhand(player, this)) 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); - } - - @EventHandler - public void onElytra(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); - } - - @EventHandler - public void onHit(EntityDamageByEntityEvent event) { - if (!(event.getDamager() instanceof Player)) return; - if (!(event.getEntity() instanceof LivingEntity)) return; - - Player player = (Player) event.getDamager(); - LivingEntity entity = (LivingEntity) event.getEntity(); - - if (!EnchantChecks.mainhand(player, this)) return; - - 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); - - new BukkitRunnable() { - @Override - public void run() { - for (int i = 0; i < 3; i++) { - if (yAtomic.get() > entity.getHeight()) this.cancel(); - yAtomic.addAndGet(yDelta); - double y = yAtomic.get(); - double x = radius * Math.cos((y + offset) * radiusMultiplier); - double z = radius * Math.sin((y + offset) * radiusMultiplier); - Location particleLocation = entity.getLocation(); - particleLocation.add(x, y, z); - entity.getWorld().spawnParticle(particle, particleLocation, 1, 0, 0, 0, 0, extra, false); - } - } - }.runTaskTimer(EcoEnchantsPlugin.getInstance(), 0, 1); - } - - @EventHandler - public void onShoot(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 = TridentStack.getTridentStack((Trident) entity); - } - - if (!EnchantChecks.item(item, this)) return; - - 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(); - - new BukkitRunnable() { - @Override - public void run() { - if (entity.isOnGround() || entity.isInBlock() || entity.isDead()) this.cancel(); - entity.getLocation().getWorld().spawnParticle(particle, entity.getLocation(), 1, 0, 0, 0, finalColor, extra, true); - } - }.runTaskTimer(EcoEnchantsPlugin.getInstance(), 4, ticks); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java deleted file mode 100644 index 2dce9eee..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.willfp.ecoenchants.enchantments.itemtypes; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.display.EnchantmentCache; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.enchantments.util.SpellRunnable; -import com.willfp.ecoenchants.util.optional.Prerequisite; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.SoundCategory; -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.ApiStatus; - -import java.util.*; - -/** - * Wrapper for Spell enchantments - */ -public abstract class Spell extends EcoEnchant { - private final HashMap cooldownTracker = new HashMap<>(); - private final Set runningSpell = new HashSet<>(); - private static final List leftClickItems = Arrays.asList( - Material.FISHING_ROD, - Material.BOW - ); - - protected Spell(String key, Prerequisite... prerequisites) { - super(key, EnchantmentType.SPELL, prerequisites); - } - - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "6.0.0") - protected Spell(String key, Class plugin, Prerequisite... prerequisites) { - this(key, prerequisites); - } - - public int getCooldownTime() { - return this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "cooldown"); - } - - public final Sound getActivationSound() { - return Sound.valueOf(this.getConfig().getString(EcoEnchants.CONFIG_LOCATION + "activation-sound").toUpperCase()); - } - - @EventHandler - public void onUseEventHandler(PlayerInteractEvent event) { - Player player = event.getPlayer(); - - if (runningSpell.contains(player.getUniqueId())) return; - runningSpell.add(player.getUniqueId()); - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> runningSpell.remove(player.getUniqueId()), 5); - - if (leftClickItems.contains(player.getInventory().getItemInMainHand().getType())) { - if (!(event.getAction().equals(Action.LEFT_CLICK_AIR) || 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 (!EnchantChecks.mainhand(player, this)) - return; - - int level = EnchantChecks.getMainhandLevel(player, this); - if (this.getDisabledWorlds().contains(player.getWorld())) return; - - if (!cooldownTracker.containsKey(player.getUniqueId())) - cooldownTracker.put(player.getUniqueId(), new SpellRunnable(this, player)); - - SpellRunnable runnable = cooldownTracker.get(player.getUniqueId()); - runnable.setTask(() -> { - this.onUse(player, level, event); - }); - - int cooldown = getCooldown(this, player); - - if (cooldown > 0) { - String message = ConfigManager.getLang().getMessage("on-cooldown").replaceAll("%seconds%", String.valueOf(cooldown)).replaceAll("%name%", EnchantmentCache.getEntry(this).getRawName()); - player.sendMessage(message); - player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 0.5f); - return; - } - - String message = ConfigManager.getLang().getMessage("used-spell").replaceAll("%name%", EnchantmentCache.getEntry(this).getRawName()); - player.sendMessage(message); - player.playSound(player.getLocation(), this.getActivationSound(), SoundCategory.PLAYERS, 1, 1); - runnable.run(); - } - - public abstract void onUse(Player player, int level, PlayerInteractEvent event); - - public static int getCooldown(Spell spell, Player player) { - if (!spell.cooldownTracker.containsKey(player.getUniqueId())) - spell.cooldownTracker.put(player.getUniqueId(), new SpellRunnable(spell, player)); - - SpellRunnable runnable = spell.cooldownTracker.get(player.getUniqueId()); - - long msLeft = runnable.getEndTime() - System.currentTimeMillis(); - - long secondsLeft = (long) Math.ceil((double) msLeft / 1000); - - return new Long(secondsLeft).intValue(); - } - - public static double getCooldownMultiplier(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; - return 1; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java deleted file mode 100644 index ed4a26f2..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java +++ /dev/null @@ -1,179 +0,0 @@ -package com.willfp.ecoenchants.enchantments.meta; - -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.integrations.placeholder.PlaceholderEntry; -import com.willfp.ecoenchants.integrations.placeholder.PlaceholderManager; -import com.willfp.ecoenchants.util.NumberUtils; -import com.willfp.ecoenchants.util.StringUtils; -import com.willfp.ecoenchants.util.interfaces.Registerable; - -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; - -/** - * Class for storing all enchantment rarities - */ -public class EnchantmentRarity implements Registerable { - private static final Set rarities = new HashSet<>(); - - private final String name; - private final double probability; - private final int minimumLevel; - private final double villagerProbability; - private final double lootProbability; - private final String customColor; - - /** - * Create new EnchantmentRarity - * - * @param name The name of the rarity - * @param probability The probability - * @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(String name, double probability, int minimumLevel, double villagerProbability, double lootProbability, String customColor) { - this.name = name; - this.probability = probability; - this.minimumLevel = minimumLevel; - this.villagerProbability = villagerProbability; - this.lootProbability = lootProbability; - this.customColor = customColor; - } - - @Override - public void register() { - Optional matching = rarities.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst(); - matching.ifPresent(rarities::remove); - - PlaceholderManager.registerPlaceholder(new PlaceholderEntry( - "rarity_" + this.getName() + "_probability", - (player) -> NumberUtils.format(this.probability) - )); - PlaceholderManager.registerPlaceholder(new PlaceholderEntry( - "rarity_" + this.getName() + "_minlevel", - (player) -> NumberUtils.format(this.minimumLevel) - )); - PlaceholderManager.registerPlaceholder(new PlaceholderEntry( - "rarity_" + this.getName() + "_villagerprobability", - (player) -> NumberUtils.format(this.villagerProbability) - )); - PlaceholderManager.registerPlaceholder(new PlaceholderEntry( - "rarity_" + this.getName() + "_lootprobability", - (player) -> NumberUtils.format(this.lootProbability) - )); - PlaceholderManager.registerPlaceholder(new PlaceholderEntry( - "rarity_" + this.getName() + "_color", - (player) -> this.customColor - )); - - rarities.add(this); - } - - /** - * Get the name of the rarity - * - * @return The name - */ - public String getName() { - return this.name; - } - - /** - * Is custom color enabled - * - * @return If has enabled custom color - */ - public boolean hasCustomColor() { - return this.customColor != null; - } - - /** - * Get custom color - * - * @return The custom color - */ - public String getCustomColor() { - return this.customColor; - } - - /** - * Get the probability of obtaining enchantment with this rarity from an enchanting table - * - * @return The probability as a percentage - */ - public double getProbability() { - return this.probability; - } - - /** - * Get the probability of obtaining enchantment with this rarity from a villager - * - * @return The probability as a percentage - */ - public double getVillagerProbability() { - return this.villagerProbability; - } - - /** - * Get the probability of obtaining enchantment with this rarity from a loot chest - * - * @return The probability as a percentage - */ - public double getLootProbability() { - return this.lootProbability; - } - - /** - * Get the minimum level required to obtain enchantment with this rarity from an enchanting table - * - * @return The minimum level - */ - public int getMinimumLevel() { - return this.minimumLevel; - } - - /** - * Get EnchantmentRarity matching name - * - * @param name The name to search for - * - * @return The matching EnchantmentRarity, or null if not found - */ - public static EnchantmentRarity getByName(String name) { - Optional matching = rarities.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst(); - return matching.orElse(null); - } - - /** - * Update all rarities - * Called on /ecoreload - */ - - public static void update() { - Set raritiesNames = ConfigManager.getRarity().getRarities(); - raritiesNames.forEach((rarity) -> { - double probability = ConfigManager.getRarity().getDouble("rarities." + rarity + ".table-probability"); - int minimumLevel = ConfigManager.getRarity().getInt("rarities." + rarity + ".minimum-level"); - double villagerProbability = ConfigManager.getRarity().getDouble("rarities." + rarity + ".villager-probability"); - double lootProbability = ConfigManager.getRarity().getDouble("rarities." + rarity + ".loot-probability"); - String customColor = null; - if (ConfigManager.getRarity().getBool("rarities." + rarity + ".custom-color.enabled")) { - customColor = StringUtils.translate(ConfigManager.getRarity().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 rarities; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java deleted file mode 100644 index 1ee0c03d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.willfp.ecoenchants.enchantments.meta; - -import com.google.common.collect.ImmutableSet; -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.util.interfaces.Registerable; -import org.bukkit.Material; - -import java.util.HashSet; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; - -/** - * Class for storing all enchantment rarities - */ -public class EnchantmentTarget implements Registerable { - private static final Set targets = new HashSet<>(); - public static final EnchantmentTarget ALL = new EnchantmentTarget("all", new HashSet<>()); - - static { - targets.add(ALL); - } - - private final String name; - private final Set materials; - - /** - * Create new EnchantmentRarity - * - * @param name The name of the rarity - * @param materials The items for the target - */ - public EnchantmentTarget(String name, Set materials) { - this.name = name; - materials.removeIf(Objects::isNull); - this.materials = materials; - } - - @Override - public void register() { - Optional matching = targets.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst(); - matching.ifPresent(targets::remove); - matching.ifPresent(enchantmentTarget -> ALL.materials.removeAll(enchantmentTarget.getMaterials())); - targets.add(this); - ALL.materials.addAll(this.getMaterials()); - } - - /** - * Get the name of the rarity - * - * @return The name - */ - public String getName() { - return this.name; - } - - /** - * Get the materials of the rarity - * - * @return The materials - */ - public Set getMaterials() { - return ImmutableSet.copyOf(this.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(String name) { - Optional matching = targets.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst(); - return matching.orElse(null); - } - - /** - * Update all targets - * Called on /ecoreload - */ - public static void update() { - Set targetNames = ConfigManager.getTarget().getTargets(); - ALL.materials.clear(); - targetNames.forEach((name) -> { - Set materials = ConfigManager.getTarget().getTargetMaterials(name); - new EnchantmentTarget(name, materials).register(); - }); - } - - /** - * Get all rarities - * - * @return A set of all rarities - */ - public static Set values() { - return targets; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java deleted file mode 100644 index fa47ce10..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.willfp.ecoenchants.enchantments.support.merging.anvil; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.nms.OpenInventory; -import com.willfp.ecoenchants.nms.RepairCost; -import com.willfp.ecoenchants.util.NumberUtils; -import com.willfp.ecoenchants.util.tuplets.Pair; -import org.bukkit.Bukkit; -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 java.util.HashMap; -import java.util.Objects; -import java.util.UUID; - -public class AnvilListeners implements Listener { - private static final HashMap noIncreaseXpMap = new HashMap<>(); - private static final String ANVIL_GUI_CLASS = "net.wesjd.anvilgui.version.Wrapper" + EcoEnchantsPlugin.NMS_VERSION.substring(1) + "$AnvilContainer"; - - @EventHandler(priority = EventPriority.HIGHEST) - public void onAnvilPrepare(PrepareAnvilEvent event) { - ItemStack left = event.getInventory().getItem(0); - ItemStack right = event.getInventory().getItem(1); - ItemStack out = event.getResult(); - String name = event.getInventory().getRenameText(); - - event.setResult(null); - event.getInventory().setItem(2, null); - - if (event.getViewers().isEmpty()) return; // Prevent ArrayIndexOutOfBoundsException when using AnvilGUI - - Player player = (Player) event.getViewers().get(0); - if (OpenInventory.getOpenInventory(player).getClass().toString().equals(ANVIL_GUI_CLASS)) - return; - - 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(); - } - - Bukkit.getScheduler().runTask(EcoEnchantsPlugin.getInstance(), () -> { - - // This is a disgusting bodge - if (!noIncreaseXpMap.containsKey(player.getUniqueId())) - noIncreaseXpMap.put(player.getUniqueId(), 0); - - Integer num = noIncreaseXpMap.get(player.getUniqueId()); - num += 1; - noIncreaseXpMap.put(player.getUniqueId(), num); - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - noIncreaseXpMap.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 (ConfigManager.getConfig().getBool("anvil.rework-cost")) { - int repairCost = RepairCost.getRepairCost(item); - int reworkCount = NumberUtils.log2(repairCost + 1); - if (repairCost == 0) reworkCount = 0; - reworkCount++; - repairCost = (int) Math.pow(2, reworkCount) - 1; - item = RepairCost.setRepairCost(item, repairCost); - } - - int cost; - - if (noIncreaseXpMap.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(); - }); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java deleted file mode 100644 index 0d454340..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java +++ /dev/null @@ -1,233 +0,0 @@ -package com.willfp.ecoenchants.enchantments.support.merging.anvil; - -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; -import com.willfp.ecoenchants.util.tuplets.Pair; -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 java.util.HashMap; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - - -public class AnvilMerge { - - /** - * 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 name 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 static Pair doMerge(ItemStack left, ItemStack right, ItemStack old, String name, Player player) { - // Here so it can be accessed later (scope) - - int outDamage = -1; - if (old != null) { - if (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); - - 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; - assert left.getItemMeta() != null; - - outMeta.setDisplayName(name); - - if (left.getItemMeta().getDisplayName().equals(name)) { - - if (left.getItemMeta() instanceof Damageable) { - int leftDamage = ((Damageable) left.getItemMeta()).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); - - 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) { - if (rightLevel > enchantment.getMaxLevel() && ConfigManager.getConfig().getBool("anvil.allow-combining-unsafe")) { - level++; - } else if ((rightLevel + 1) <= enchantment.getMaxLevel() || ConfigManager.getConfig().getBool("anvil.allow-unsafe-levels")) { - level++; - } - } - rightEnchants.remove(enchantment); - } - - outEnchants.put(enchantment, level); - })); - - rightEnchants.forEach(((enchantment, integer) -> { - AtomicBoolean doesConflict = new AtomicBoolean(false); - - EcoEnchant.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 (ConfigManager.getConfig().getBool("anvil.hard-cap.enabled") && !player.hasPermission("ecoenchants.anvil.bypasshardcap")) { - if (outEnchants.size() >= ConfigManager.getConfig().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)) { - if (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, ConfigManager.getConfig().getBool("anvil.allow-existing-unsafe-levels") || ConfigManager.getConfig().getBool("anvil.allow-unsafe-levels")); - })); - - 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, ConfigManager.getConfig().getBool("anvil.allow-existing-unsafe-levels") || ConfigManager.getConfig().getBool("anvil.allow-unsafe-levels")); - })); - - 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 (ConfigManager.getConfig().getBool("anvil.cost-exponent.enabled")) { - double exponent = ConfigManager.getConfig().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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneListeners.java deleted file mode 100644 index 826fdf49..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneListeners.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.willfp.ecoenchants.enchantments.support.merging.grindstone; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import org.bukkit.Bukkit; -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 java.util.Map; - -public class GrindstoneListeners implements Listener { - @EventHandler - public void onGrindstone(InventoryClickEvent event) { - Player player = (Player) event.getWhoClicked(); - - if (player.getOpenInventory().getTopInventory().getType() != InventoryType.GRINDSTONE) - return; - - GrindstoneInventory inventory = (GrindstoneInventory) player.getOpenInventory().getTopInventory(); - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - - 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; - - Bukkit.getScheduler().runTask(EcoEnchantsPlugin.getInstance(), () -> { - inventory.setItem(2, finalOut); - }); - - }, 1); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneMerge.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneMerge.java deleted file mode 100644 index 568a87c4..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneMerge.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.willfp.ecoenchants.enchantments.support.merging.grindstone; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.EnchantmentStorageMeta; - -import java.util.HashMap; -import java.util.Map; - -@SuppressWarnings("deprecation") -public class GrindstoneMerge { - public static Map doMerge(ItemStack top, 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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java deleted file mode 100644 index e274029d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java +++ /dev/null @@ -1,234 +0,0 @@ -package com.willfp.ecoenchants.enchantments.support.obtaining; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.util.NumberUtils; -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.bukkit.scheduler.BukkitRunnable; - -import java.util.*; -import java.util.concurrent.atomic.AtomicBoolean; - -public class EnchantingListeners implements Listener { - private static final Set secondary = new HashSet() {{ - add(Material.ELYTRA); - add(Material.SHIELD); - add(Material.FLINT_AND_STEEL); - add(Material.SHEARS); - add(Material.CARROT_ON_A_STICK); - }}; - public static final HashMap currentlyEnchantingSecondary = new HashMap<>(); - - @EventHandler - public void onPlayerLeave(PlayerQuitEvent event) { - currentlyEnchantingSecondary.remove(event.getPlayer()); - } - - @EventHandler - public void enchantItem(EnchantItemEvent event) { - Player player = event.getEnchanter(); - ItemStack item = event.getItem(); - int cost = event.getExpLevelCost(); - - Map toAdd = event.getEnchantsToAdd(); - if (!ConfigManager.getConfig().getBool("enchanting-table.enabled")) { - new BukkitRunnable() { - @Override - public void run() { - ItemStack item = event.getInventory().getItem(0); - event.getInventory().setItem(0, item); - } - }.runTaskLater(EcoEnchantsPlugin.getInstance(), 1); - return; - } - - if ((secondary.contains(event.getItem().getType()))) { - try { - ItemStack lapis = event.getInventory().getItem(1); - lapis.setAmount(event.getInventory().getItem(1).getAmount() - (event.whichButton() + 1)); - event.getInventory().setItem(1, lapis); - } catch (NullPointerException ignored) { - } // Triggered if you're in creative - } - - double multiplier = 0.01; - if (item.getType().equals(Material.BOOK) || item.getType().equals(Material.ENCHANTED_BOOK)) { - multiplier /= ConfigManager.getConfig().getInt("enchanting-table.book-times-less-likely"); - } - - if (ConfigManager.getConfig().getBool("enchanting-table.reduce-probability.enabled")) { - multiplier /= ConfigManager.getConfig().getDouble("enchanting-table.reduce-probability.factor"); - } - - ArrayList enchantments = new ArrayList<>(EcoEnchants.getAll()); - 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().getProbability() * multiplier) - continue; - if (enchantment.getRarity().getMinimumLevel() > cost) - continue; - if (!enchantment.isEnabled()) - continue; - if (!enchantment.canGetFromTable()) - 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(EcoEnchant.EnchantmentType.SPECIAL)) { - double enchantlevel1 = NumberUtils.randFloat(0, 1); - double enchantlevel2 = NumberUtils.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); - double enchantlevel3 = 1 / maxLevelDouble; - level = (int) Math.ceil(enchantlevel2 / enchantlevel3); - } else { - int maxLevel = ConfigManager.getConfig().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 (ConfigManager.getConfig().getBool("enchanting-table.cap-amount.enabled")) { - if (toAdd.size() >= ConfigManager.getConfig().getInt("enchanting-table.cap-amount.limit")) { - break; - } - } - - if (enchantment.getType().equals(EcoEnchant.EnchantmentType.SPECIAL)) gotSpecial = true; - - if (ConfigManager.getConfig().getBool("enchanting-table.reduce-probability.enabled")) { - multiplier /= ConfigManager.getConfig().getDouble("enchanting-table.reduce-probability.factor"); - } - } - toAdd.forEach(event.getEnchantsToAdd()::putIfAbsent); - - if ((secondary.contains(event.getItem().getType()))) { - if (!toAdd.containsKey(EcoEnchants.INDESTRUCTIBILITY)) { - event.getEnchantsToAdd().put(Enchantment.DURABILITY, currentlyEnchantingSecondary.get(player)[event.whichButton()]); - currentlyEnchantingSecondary.remove(player); - } - } - - if (gotSpecial && ConfigManager.getConfig().getBool("enchanting-table.notify-on-special")) { - player.sendMessage(ConfigManager.getLang().getMessage("got-special")); - } - - // Ew - new BukkitRunnable() { - @Override - public void run() { - ItemStack item = event.getInventory().getItem(0); - assert item != null; - if (item.getItemMeta() instanceof EnchantmentStorageMeta) { - EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta(); - for (Enchantment enchantment : meta.getStoredEnchants().keySet()) { - meta.removeStoredEnchant(enchantment); - } - event.getEnchantsToAdd().forEach(((enchantment, integer) -> { - meta.addStoredEnchant(enchantment, integer, false); - })); - item.setItemMeta(meta); - } - event.getInventory().setItem(0, item); - } - }.runTaskLater(EcoEnchantsPlugin.getInstance(), 1); - } - - @EventHandler - public void secondaryEnchant(PrepareItemEnchantEvent event) { - int maxLevel = ConfigManager.getConfig().getInt("enchanting-table.maximum-obtainable-level"); - - try { - event.getOffers()[2].setCost(NumberUtils.equalIfOver(event.getOffers()[2].getCost(), maxLevel)); - } catch (ArrayIndexOutOfBoundsException | NullPointerException ignored) { - } - - if (!secondary.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]; - } - - currentlyEnchantingSecondary.remove(event.getEnchanter()); - - int[] unbLevels = { - event.getOffers()[0].getEnchantmentLevel(), - event.getOffers()[1].getEnchantmentLevel(), - event.getOffers()[2].getEnchantmentLevel() - }; - - currentlyEnchantingSecondary.put(event.getEnchanter(), unbLevels); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java deleted file mode 100644 index ca831a0b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.willfp.ecoenchants.enchantments.support.obtaining; - -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; -import com.willfp.ecoenchants.util.NumberUtils; -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 { - public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) { - if (!ConfigManager.getConfig().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.getAll()); - 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 /= ConfigManager.getConfig().getInt("loot.book-times-less-likely"); - } - - if (ConfigManager.getConfig().getBool("loot.reduce-probability.enabled")) { - multiplier /= ConfigManager.getConfig().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.canGetFromLoot()) - 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(EcoEnchant.EnchantmentType.SPECIAL)) { - double enchantlevel1 = NumberUtils.randFloat(0, 1); - double enchantlevel2 = NumberUtils.bias(enchantlevel1, ConfigManager.getConfig().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 (ConfigManager.getConfig().getBool("loot.reduce-probability.enabled")) { - multiplier /= ConfigManager.getConfig().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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java deleted file mode 100644 index eba8640b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.willfp.ecoenchants.enchantments.support.obtaining; - -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; -import com.willfp.ecoenchants.util.NumberUtils; -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 java.util.*; -import java.util.concurrent.atomic.AtomicBoolean; - -public class VillagerListeners implements Listener { - - // For books - @EventHandler - public void onVillagerGainBookTrade(VillagerAcquireTradeEvent event) { - if (!event.getRecipe().getResult().getType().equals(Material.ENCHANTED_BOOK)) - return; - - if (!ConfigManager.getConfig().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.getAll()); - Collections.shuffle(enchantments); // Prevent list bias towards early enchantments like telekinesis - - double multiplier = 0.01 / ConfigManager.getConfig().getDouble("villager.book-times-less-likely"); - - for (EcoEnchant enchantment : enchantments) { - if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getVillagerProbability() * multiplier) - continue; - if (!enchantment.canGetFromVillager()) - continue; - if (!enchantment.isEnabled()) - continue; - - int level; - - if (enchantment.getType().equals(EcoEnchant.EnchantmentType.SPECIAL)) { - double enchantlevel1 = NumberUtils.randFloat(0, 1); - double enchantlevel2 = NumberUtils.bias(enchantlevel1, ConfigManager.getConfig().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); - } - - // For tools - @EventHandler - public void onVillagerGainItemTrade(VillagerAcquireTradeEvent event) { - - if (!EnchantmentTarget.ALL.getMaterials().contains(event.getRecipe().getResult().getType())) - return; - - if (event.getRecipe().getResult().getType().equals(Material.BOOK)) return; - - if (!ConfigManager.getConfig().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.getAll()); - 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.canGetFromVillager()) - 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); - - 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(EcoEnchant.EnchantmentType.SPECIAL)) { - double enchantlevel1 = NumberUtils.randFloat(0, 1); - double enchantlevel2 = NumberUtils.bias(enchantlevel1, ConfigManager.getConfig().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 (ConfigManager.getConfig().getBool("villager.reduce-probability.enabled")) { - multiplier /= ConfigManager.getConfig().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/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantChecks.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantChecks.java deleted file mode 100644 index 83d0ad6f..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantChecks.java +++ /dev/null @@ -1,418 +0,0 @@ -package com.willfp.ecoenchants.enchantments.util; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.nms.FastGetEnchants; -import com.willfp.ecoenchants.util.DurabilityUtils; -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 java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * Utility class to simplify enchantment fetching - */ -@SuppressWarnings("unchecked") -public class EnchantChecks { - /** - * 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(ItemStack item, 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(ItemStack item, Enchantment enchantment) { - if (item == null) return 0; - if (item.getType().equals(Material.AIR)) return 0; - - return FastGetEnchants.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(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 : FastGetEnchants.getEnchantsOnItem(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(Arrow arrow, 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(Arrow arrow, Enchantment enchantment) { - if (arrow.getMetadata("enchantments").isEmpty()) return 0; - - MetadataValue enchantmentsMetaValue = arrow.getMetadata("enchantments").get(0); - if (!(enchantmentsMetaValue.value() instanceof Map)) - return 0; - - Map enchantments = (Map) enchantmentsMetaValue.value(); - if (enchantments == null) return 0; - if (!enchantments.containsKey(enchantment)) return 0; - return enchantments.get(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(Arrow arrow) { - if (arrow.getMetadata("enchantments").isEmpty()) return new HashMap<>(); - - MetadataValue enchantmentsMetaValue = arrow.getMetadata("enchantments").get(0); - if (!(enchantmentsMetaValue.value() instanceof Map)) - return new HashMap<>(); - - Map ecoEnchants = new HashMap<>(); - ((Map) enchantmentsMetaValue.value()).forEach(((enchantment, integer) -> { - if (EcoEnchants.getFromEnchantment(enchantment) != null) { - ecoEnchants.put(EcoEnchants.getFromEnchantment(enchantment), integer); - } - })); - - return ecoEnchants; - } - - /** - * 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(LivingEntity entity, 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(LivingEntity entity, 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(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(LivingEntity entity, 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(LivingEntity entity, 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(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(LivingEntity entity, 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(LivingEntity entity, Enchantment enchantment, 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(LivingEntity entity) { - if (entity.getEquipment() == null) - return new HashMap<>(); - - AtomicInteger armorPoints = new AtomicInteger(0); - List armor = Arrays.asList(entity.getEquipment().getArmorContents()); - - Map ecoEnchants = new HashMap<>(); - - armor.forEach((itemStack -> { - 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(LivingEntity entity, 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(LivingEntity entity, 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(LivingEntity entity, 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(LivingEntity entity, 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(LivingEntity entity, 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(LivingEntity entity, 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(LivingEntity entity, 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(LivingEntity entity, Enchantment enchantment) { - if (entity.getEquipment() == null) - return 0; - - ItemStack item = entity.getEquipment().getBoots(); - - return getItemLevel(item, enchantment); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java deleted file mode 100644 index 292ef26c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/EnchantmentUtils.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.willfp.ecoenchants.enchantments.util; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.itemtypes.Spell; -import com.willfp.ecoenchants.integrations.placeholder.PlaceholderEntry; -import com.willfp.ecoenchants.integrations.placeholder.PlaceholderManager; -import com.willfp.ecoenchants.util.NumberUtils; -import com.willfp.ecoenchants.util.StringUtils; - -public class EnchantmentUtils { - public static boolean passedChance(EcoEnchant enchantment, int level) { - return NumberUtils.randFloat(0, 1) < ((enchantment.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level") * level) / 100); - } - - public static void registerPlaceholders(EcoEnchant enchantment) { - - PlaceholderManager.registerPlaceholder( - new PlaceholderEntry(enchantment.getPermissionName() + "_" + "enabled", (player) -> String.valueOf(enchantment.isEnabled())) - ); - - enchantment.getConfig().config.getKeys(true).forEach(string -> { - String key = string.replaceAll("\\.", "_").replaceAll("-", "_"); - Object object = enchantment.getConfig().config.get(string); - - PlaceholderManager.registerPlaceholder( - new PlaceholderEntry(enchantment.getPermissionName() + "_" + key, (player) -> StringUtils.internalToString(object)) - ); - }); - - if (enchantment.getConfig().config.get(EcoEnchants.CONFIG_LOCATION + "chance-per-level") != null) { - PlaceholderManager.registerPlaceholder( - new PlaceholderEntry(enchantment.getPermissionName() + "_" + "chance_per_level", (player) -> NumberUtils.format(enchantment.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))) - ); - } - - if (enchantment.getConfig().config.get(EcoEnchants.CONFIG_LOCATION + "multiplier") != null) { - PlaceholderManager.registerPlaceholder( - new PlaceholderEntry(enchantment.getPermissionName() + "_" + "multiplier", (player) -> NumberUtils.format(enchantment.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"))) - ); - PlaceholderManager.registerPlaceholder( - new PlaceholderEntry(enchantment.getPermissionName() + "_" + "multiplier_percentage", (player) -> NumberUtils.format(enchantment.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier") * 100)) - ); - } - - if (enchantment instanceof Spell) { - PlaceholderManager.registerPlaceholder( - new PlaceholderEntry(enchantment.getPermissionName() + "_" + "cooldown", (player) -> NumberUtils.format(Spell.getCooldown((Spell) enchantment, player)), true) - ); - PlaceholderManager.registerPlaceholder( - new PlaceholderEntry(enchantment.getPermissionName() + "_" + "cooldown_total", (player) -> NumberUtils.format(((Spell) enchantment).getCooldownTime())) - ); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellRunnable.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellRunnable.java deleted file mode 100644 index eb3fd0ef..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellRunnable.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.willfp.ecoenchants.enchantments.util; - -import com.willfp.ecoenchants.enchantments.itemtypes.Spell; -import com.willfp.ecoenchants.util.interfaces.Callable; -import org.bukkit.entity.Player; - -public class SpellRunnable { - private final Spell spell; - private final Player player; - private long endTime = 0; - private Callable callable = () -> { - }; - - public SpellRunnable(Spell spell, Player player) { - this.spell = spell; - this.player = player; - } - - public Spell getSpell() { - return spell; - } - - public void run() { - callable.call(); - updateEndTime(); - } - - public long getEndTime() { - return endTime; - } - - public void updateEndTime() { - endTime = System.currentTimeMillis() + (long) ((spell.getCooldownTime() * 1000L) * Spell.getCooldownMultiplier(player)); - } - - public void setTask(Callable callable) { - this.callable = callable; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/Watcher.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/Watcher.java deleted file mode 100644 index 7226f371..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/Watcher.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.willfp.ecoenchants.enchantments.util; - -import com.willfp.ecoenchants.events.armorequip.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.Trident; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockDamageEvent; -import org.bukkit.event.entity.*; -import org.bukkit.event.player.PlayerMoveEvent; - -public interface Watcher { - default void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { - } - - default void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { - } - - default void onJump(Player player, int level, PlayerMoveEvent event) { - } - - default void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - } - - default void onBowShoot(LivingEntity shooter, Arrow arrow, int level, EntityShootBowEvent event) { - } - - default void onFallDamage(LivingEntity faller, int level, EntityDamageEvent event) { - } - - default void onArrowHit(LivingEntity shooter, int level, ProjectileHitEvent event) { - } - - default void onTridentHit(LivingEntity shooter, int level, ProjectileHitEvent event) { - } - - default void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) { - } - - default void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { - } - - default void onArmorEquip(Player player, int level, ArmorEquipEvent event) { - } - - default void onDamageBlock(Player player, Block block, int level, BlockDamageEvent event) { - } - - default void onTridentLaunch(LivingEntity shooter, Trident trident, int level, ProjectileLaunchEvent event) { - } - - default void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) { - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java deleted file mode 100644 index d11c1035..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java +++ /dev/null @@ -1,380 +0,0 @@ -package com.willfp.ecoenchants.enchantments.util; - -import com.google.common.collect.Sets; -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.integrations.mcmmo.McmmoManager; -import com.willfp.ecoenchants.nms.TridentStack; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -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 java.text.DecimalFormat; -import java.util.Set; -import java.util.UUID; - -@SuppressWarnings("deprecation") -public class WatcherTriggers implements Listener { - - @EventHandler(ignoreCancelled = true) - public void onArrowDamage(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 (victim.hasMetadata("NPC")) return; - - if (attacker instanceof Player) { - if (!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); - })); - } - - @EventHandler(ignoreCancelled = true) - public void onTridentDamage(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 = TridentStack.getTridentStack(trident); - - LivingEntity victim = (LivingEntity) event.getEntity(); - - if (victim.hasMetadata("NPC")) return; - - if (attacker instanceof Player) { - if (!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); - })); - } - - - private static final Set prevPlayersOnGround = Sets.newHashSet(); - private static final DecimalFormat df = new DecimalFormat("0.00"); - - @EventHandler(ignoreCancelled = true) - public void onJump(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(df.format(jumpVelocity).replace(',', '.')); - if (event.getPlayer().getLocation().getBlock().getType() != Material.LADDER && prevPlayersOnGround.contains(player.getUniqueId())) { - if (!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()) { - prevPlayersOnGround.add(player.getUniqueId()); - } else { - prevPlayersOnGround.remove(player.getUniqueId()); - } - } - - @EventHandler(ignoreCancelled = true) - public void onMeleeAttack(EntityDamageByEntityEvent event) { - if (McmmoManager.isFake(event)) - return; - if (!(event.getDamager() instanceof LivingEntity)) - return; - - if (!(event.getEntity() instanceof LivingEntity)) - return; - - if (event.isCancelled()) - return; - - LivingEntity attacker = (LivingEntity) event.getDamager(); - LivingEntity victim = (LivingEntity) event.getEntity(); - - if (victim.hasMetadata("NPC")) return; - - if (attacker instanceof Player) { - if (!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); - }); - } - - @EventHandler(ignoreCancelled = true) - public void onBowShoot(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); - }); - } - - @EventHandler(ignoreCancelled = true) - public void onFallDamage(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); - }); - } - - @EventHandler(ignoreCancelled = true) - public void onArrowHit(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); - })); - } - - @EventHandler(ignoreCancelled = true) - public void onTridentHit(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 = TridentStack.getTridentStack(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); - })); - } - - @EventHandler(ignoreCancelled = true) - public void onBlockBreak(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); - }); - } - - @EventHandler(ignoreCancelled = true) - public void onDamageWearingArmor(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); - }); - } - - @EventHandler(ignoreCancelled = true) - public void onArmorEquip(ArmorEquipEvent event) { - if (McmmoManager.isFake(event)) - return; - Player player = event.getPlayer(); - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - EcoEnchants.getAll().forEach((enchant -> { - if (event.isCancelled()) return; - if (!enchant.isEnabled()) return; - if (enchant.getDisabledWorlds().contains(player.getWorld())) return; - int level = EnchantChecks.getArmorPoints(player, enchant); - enchant.onArmorEquip(player, level, event); - })); - }, 1); - } - - @EventHandler(ignoreCancelled = true) - public void onDamageBlock(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); - }); - } - - @EventHandler(ignoreCancelled = true) - public void onTridentLaunch(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 = TridentStack.getTridentStack(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); - }); - } - - @EventHandler(ignoreCancelled = true) - public void onDeflect(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; - - EcoEnchants.getAll().forEach((enchant -> { - if (event.isCancelled()) return; - if (!enchant.isEnabled()) return; - if (enchant.getDisabledWorlds().contains(blocker.getWorld())) return; - int level; - if (!EnchantChecks.offhand(blocker, enchant) && !EnchantChecks.mainhand(blocker, enchant)) return; - if (EnchantChecks.offhand(blocker, enchant)) level = EnchantChecks.getOffhandLevel(blocker, enchant); - else level = EnchantChecks.getMainhandLevel(blocker, enchant); - enchant.onDeflect(blocker, attacker, level, event); - })); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorEquipEvent.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorEquipEvent.java deleted file mode 100644 index e5445890..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorEquipEvent.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.willfp.ecoenchants.events.armorequip; - - -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.bukkit.event.player.PlayerEvent; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -/** - * @author Arnah - * @since Jul 30, 2015 - */ -public class ArmorEquipEvent extends PlayerEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; - private final EquipMethod equipType; - private final ArmorType type; - private ItemStack oldArmorPiece, newArmorPiece; - - public ArmorEquipEvent(final Player player, final EquipMethod equipType, final ArmorType type, final ItemStack oldArmorPiece, final ItemStack newArmorPiece) { - super(player); - this.equipType = equipType; - this.type = type; - this.oldArmorPiece = oldArmorPiece; - this.newArmorPiece = newArmorPiece; - } - - /** - * Gets a list of handlers handling this event. - * - * @return A list of handlers handling this event. - */ - - @Override - public @NotNull HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } - - /** - * Sets if this event should be cancelled. - * - * @param cancel If this event should be cancelled. - */ - public final void setCancelled(final boolean cancel) { - this.cancel = cancel; - } - - /** - * Gets if this event is cancelled. - * - * @return If this event is cancelled - */ - public final boolean isCancelled() { - return cancel; - } - - public final ArmorType getType() { - return type; - } - - public final ItemStack getOldArmorPiece() { - return oldArmorPiece; - } - - public final void setOldArmorPiece(final ItemStack oldArmorPiece) { - this.oldArmorPiece = oldArmorPiece; - } - - public final ItemStack getNewArmorPiece() { - return newArmorPiece; - } - - public final void setNewArmorPiece(final ItemStack newArmorPiece) { - this.newArmorPiece = newArmorPiece; - } - - public EquipMethod getMethod() { - return equipType; - } - - public enum EquipMethod {// These have got to be the worst documentations ever. - /** - * When you shift click an armor piece to equip or unequip - */ - SHIFT_CLICK, - /** - * When you drag and drop the item to equip or unequip - */ - DRAG, - /** - * When you manually equip or unequip the item. Use to be DRAG - */ - PICK_DROP, - /** - * When you right click an armor piece in the hotbar without the inventory open to equip. - */ - HOTBAR, - /** - * When you press the hotbar slot number while hovering over the armor slot to equip or unequip - */ - HOTBAR_SWAP, - /** - * When in range of a dispenser that shoots an armor piece to equip.
- * Requires the spigot version to have {@link org.bukkit.event.block.BlockDispenseArmorEvent} implemented. - */ - DISPENSER, - /** - * When an armor piece is removed due to it losing all durability. - */ - BROKE, - /** - * When you die causing all armor to unequip - */ - DEATH, - ; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorListener.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorListener.java deleted file mode 100644 index 5500d2a4..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorListener.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.willfp.ecoenchants.events.armorequip; - -import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent.EquipMethod; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.Event.Result; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.inventory.*; -import org.bukkit.event.inventory.InventoryType.SlotType; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerItemBreakEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.inventory.ItemStack; - -/** - * @author Arnah - * @since Jul 30, 2015 - */ -@SuppressWarnings("deprecation") -public class ArmorListener implements Listener { - //Event Priority is highest because other plugins might cancel the events before we check. - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public final void inventoryClick(final InventoryClickEvent e) { - boolean shift = false, numberkey = false; - if (e.isCancelled()) return; - if (e.getAction() == InventoryAction.NOTHING) return;// Why does this get called if nothing happens?? - if (e.getClick().equals(ClickType.SHIFT_LEFT) || e.getClick().equals(ClickType.SHIFT_RIGHT)) { - shift = true; - } - if (e.getClick().equals(ClickType.NUMBER_KEY)) { - numberkey = true; - } - if (e.getSlotType() != SlotType.ARMOR && e.getSlotType() != SlotType.QUICKBAR && e.getSlotType() != SlotType.CONTAINER) - return; - if (e.getClickedInventory() != null && !e.getClickedInventory().getType().equals(InventoryType.PLAYER)) return; - if (!e.getInventory().getType().equals(InventoryType.CRAFTING) && !e.getInventory().getType().equals(InventoryType.PLAYER)) - return; - if (!(e.getWhoClicked() instanceof Player)) return; - ArmorType newArmorType = ArmorType.matchType(shift ? e.getCurrentItem() : e.getCursor()); - if (!shift && newArmorType != null && e.getRawSlot() != newArmorType.getSlot()) { - // Used for drag and drop checking to make sure you aren't trying to place a helmet in the boots slot. - return; - } - if (shift) { - newArmorType = ArmorType.matchType(e.getCurrentItem()); - if (newArmorType != null) { - boolean equipping = true; - if (e.getRawSlot() == newArmorType.getSlot()) { - equipping = false; - } - if (newArmorType.equals(ArmorType.HELMET) && (equipping == isAirOrNull(e.getWhoClicked().getInventory().getHelmet())) || newArmorType.equals(ArmorType.CHESTPLATE) && (equipping == isAirOrNull(e.getWhoClicked().getInventory().getChestplate())) || newArmorType.equals(ArmorType.LEGGINGS) && (equipping == isAirOrNull(e.getWhoClicked().getInventory().getLeggings())) || newArmorType.equals(ArmorType.BOOTS) && (equipping == isAirOrNull(e.getWhoClicked().getInventory().getBoots()))) { - ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent((Player) e.getWhoClicked(), EquipMethod.SHIFT_CLICK, newArmorType, equipping ? null : e.getCurrentItem(), equipping ? e.getCurrentItem() : null); - Bukkit.getPluginManager().callEvent(armorEquipEvent); - if (armorEquipEvent.isCancelled()) { - e.setCancelled(true); - } - } - } - } else { - ItemStack newArmorPiece = e.getCursor(); - ItemStack oldArmorPiece = e.getCurrentItem(); - if (numberkey) { - if (e.getClickedInventory().getType().equals(InventoryType.PLAYER)) {// Prevents shit in the 2by2 crafting - // e.getClickedInventory() == The players inventory - // e.getHotBarButton() == key people are pressing to equip or unequip the item to or from. - // e.getRawSlot() == The slot the item is going to. - // e.getSlot() == Armor slot, can't use e.getRawSlot() as that gives a hotbar slot ;-; - ItemStack hotbarItem = e.getClickedInventory().getItem(e.getHotbarButton()); - if (!isAirOrNull(hotbarItem)) {// Equipping - newArmorType = ArmorType.matchType(hotbarItem); - newArmorPiece = hotbarItem; - oldArmorPiece = e.getClickedInventory().getItem(e.getSlot()); - } else {// Unequipping - newArmorType = ArmorType.matchType(!isAirOrNull(e.getCurrentItem()) ? e.getCurrentItem() : e.getCursor()); - } - } - } else { - if (isAirOrNull(e.getCursor()) && !isAirOrNull(e.getCurrentItem())) {// unequip with no new item going into the slot. - newArmorType = ArmorType.matchType(e.getCurrentItem()); - } - // e.getCurrentItem() == Unequip - // e.getCursor() == Equip - // newArmorType = ArmorType.matchType(!isAirOrNull(e.getCurrentItem()) ? e.getCurrentItem() : e.getCursor()); - } - if (newArmorType != null && e.getRawSlot() == newArmorType.getSlot()) { - EquipMethod method = EquipMethod.PICK_DROP; - if (e.getAction().equals(InventoryAction.HOTBAR_SWAP) || numberkey) method = EquipMethod.HOTBAR_SWAP; - ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent((Player) e.getWhoClicked(), method, newArmorType, oldArmorPiece, newArmorPiece); - Bukkit.getPluginManager().callEvent(armorEquipEvent); - if (armorEquipEvent.isCancelled()) { - e.setCancelled(true); - } - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void playerInteractEvent(PlayerInteractEvent e) { - if (e.useItemInHand().equals(Result.DENY)) return; - // - if (e.getAction() == Action.PHYSICAL) return; - if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) { - Player player = e.getPlayer(); - if (!e.useInteractedBlock().equals(Result.DENY)) { - if (e.getClickedBlock() != null && e.getAction() == Action.RIGHT_CLICK_BLOCK && !player.isSneaking()) {// Having both of these checks is useless, might as well do it though. - // Some blocks have actions when you right click them which stops the client from equipping the armor in hand. - Material mat = e.getClickedBlock().getType(); - } - } - ArmorType newArmorType = ArmorType.matchType(e.getItem()); - if (newArmorType != null) { - if (newArmorType.equals(ArmorType.HELMET) && isAirOrNull(e.getPlayer().getInventory().getHelmet()) || newArmorType.equals(ArmorType.CHESTPLATE) && isAirOrNull(e.getPlayer().getInventory().getChestplate()) || newArmorType.equals(ArmorType.LEGGINGS) && isAirOrNull(e.getPlayer().getInventory().getLeggings()) || newArmorType.equals(ArmorType.BOOTS) && isAirOrNull(e.getPlayer().getInventory().getBoots())) { - ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(e.getPlayer(), EquipMethod.HOTBAR, ArmorType.matchType(e.getItem()), null, e.getItem()); - Bukkit.getPluginManager().callEvent(armorEquipEvent); - if (armorEquipEvent.isCancelled()) { - e.setCancelled(true); - player.updateInventory(); - } - } - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void inventoryDrag(InventoryDragEvent event) { - // getType() seems to always be even. - // Old Cursor gives the item you are equipping - // Raw slot is the ArmorType slot - // Can't replace armor using this method making getCursor() useless. - ArmorType type = ArmorType.matchType(event.getOldCursor()); - if (event.getRawSlots().isEmpty()) return;// Idk if this will ever happen - if (type != null && type.getSlot() == event.getRawSlots().stream().findFirst().orElse(0)) { - ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent((Player) event.getWhoClicked(), EquipMethod.DRAG, type, null, event.getOldCursor()); - Bukkit.getPluginManager().callEvent(armorEquipEvent); - if (armorEquipEvent.isCancelled()) { - event.setResult(Result.DENY); - event.setCancelled(true); - } - } - // Debug shit - } - - @EventHandler - public void playerJoinEvent(PlayerJoinEvent e) { - ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(e.getPlayer(), null, null, null, null); - Bukkit.getPluginManager().callEvent(armorEquipEvent); - } - - @EventHandler - public void playerRespawnEvent(PlayerRespawnEvent e) { - ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(e.getPlayer(), null, null, null, null); - Bukkit.getPluginManager().callEvent(armorEquipEvent); - } - - @EventHandler - public void itemBreakEvent(PlayerItemBreakEvent e) { - ArmorType type = ArmorType.matchType(e.getBrokenItem()); - if (type != null) { - Player p = e.getPlayer(); - ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(p, EquipMethod.BROKE, type, e.getBrokenItem(), null); - Bukkit.getPluginManager().callEvent(armorEquipEvent); - if (armorEquipEvent.isCancelled()) { - ItemStack i = e.getBrokenItem().clone(); - i.setAmount(1); - i.setDurability((short) (i.getDurability() - 1)); - if (type.equals(ArmorType.HELMET)) { - p.getInventory().setHelmet(i); - } else if (type.equals(ArmorType.CHESTPLATE)) { - p.getInventory().setChestplate(i); - } else if (type.equals(ArmorType.LEGGINGS)) { - p.getInventory().setLeggings(i); - } else if (type.equals(ArmorType.BOOTS)) { - p.getInventory().setBoots(i); - } - } - } - } - - @EventHandler - public void playerDeathEvent(PlayerDeathEvent e) { - Player p = e.getEntity(); - if (e.getKeepInventory()) return; - for (ItemStack i : p.getInventory().getArmorContents()) { - if (!isAirOrNull(i)) { - Bukkit.getPluginManager().callEvent(new ArmorEquipEvent(p, EquipMethod.DEATH, ArmorType.matchType(i), i, null)); - // No way to cancel a death event. - } - } - } - - public static boolean isAirOrNull(ItemStack item) { - return item == null || item.getType().equals(Material.AIR); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorType.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorType.java deleted file mode 100644 index 7ca54e70..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorType.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.willfp.ecoenchants.events.armorequip; - -import org.bukkit.inventory.ItemStack; - -/** - * @author Arnah - * @since Jul 30, 2015 - */ -public enum ArmorType { - HELMET(5), CHESTPLATE(6), LEGGINGS(7), BOOTS(8); - - private final int slot; - - ArmorType(int slot) { - this.slot = slot; - } - - /** - * Attempts to match the ArmorType for the specified ItemStack. - * - * @param itemStack The ItemStack to parse the type of. - * - * @return The parsed ArmorType, or null if not found. - */ - public static ArmorType matchType(final ItemStack itemStack) { - if (ArmorListener.isAirOrNull(itemStack)) return null; - String type = itemStack.getType().name(); - if (type.endsWith("_HELMET") || type.endsWith("_SKULL") || type.endsWith("PLAYER_HEAD")) return HELMET; - else if (type.endsWith("_CHESTPLATE") || type.endsWith("ELYTRA")) return CHESTPLATE; - else if (type.endsWith("_LEGGINGS")) return LEGGINGS; - else if (type.endsWith("_BOOTS")) return BOOTS; - else return null; - } - - public int getSlot() { - return slot; - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/DispenserArmorListener.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/DispenserArmorListener.java deleted file mode 100644 index 5ce0d2cd..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/DispenserArmorListener.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.events.armorequip; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockDispenseArmorEvent; - -/** - * @author Arnah - * @since Feb 08, 2019 - */ -public class DispenserArmorListener implements Listener { - @EventHandler - public void dispenseArmorEvent(BlockDispenseArmorEvent event) { - ArmorType type = ArmorType.matchType(event.getItem()); - if (type != null) { - if (event.getTargetEntity() instanceof Player) { - Player p = (Player) event.getTargetEntity(); - ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(p, ArmorEquipEvent.EquipMethod.DISPENSER, type, null, event.getItem()); - Bukkit.getPluginManager().callEvent(armorEquipEvent); - if (armorEquipEvent.isCancelled()) { - event.setCancelled(true); - } - } - } - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityBuilder.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityBuilder.java deleted file mode 100644 index 65e63981..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityBuilder.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.willfp.ecoenchants.events.entitydeathbyentity; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.List; - -class EntityDeathByEntityBuilder { - private LivingEntity victim = null; - private Entity damager; - private EntityDeathEvent deathEvent; - - private List drops; - private int xp = 0; - private boolean dropItems; - - public EntityDeathByEntityBuilder() { - - } - - public LivingEntity getVictim() { - return this.victim; - } - - public void setDeathEvent(EntityDeathEvent deathEvent) { - this.deathEvent = deathEvent; - } - - public void setVictim(LivingEntity victim) { - this.victim = victim; - } - - public void setDamager(Entity damager) { - this.damager = damager; - } - - public void setDrops(List drops) { - this.drops = drops; - } - - public void setXp(int xp) { - this.xp = xp; - } - - public void push() { - if (this.victim == null) return; - if (this.damager == null) return; - if (this.drops == null) return; - if (this.deathEvent == null) return; - - EntityDeathByEntityEvent event = new EntityDeathByEntityEvent(victim, damager, drops, xp, deathEvent); - - Bukkit.getPluginManager().callEvent(event); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityEvent.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityEvent.java deleted file mode 100644 index a8ebf791..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityEvent.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.willfp.ecoenchants.events.entitydeathbyentity; - -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -/** - * Event triggered when entity is killed by entity. - */ -public class EntityDeathByEntityEvent extends Event { - private static final HandlerList HANDLERS = new HandlerList(); - - /** - * The {@link LivingEntity} killed - */ - private final LivingEntity victim; - - /** - * The {@link Entity} that killed; - */ - private final Entity damager; - - /** - * The associated {@link EntityDeathEvent} - */ - private final EntityDeathEvent deathEvent; - - /** - * The entity drops - */ - private final List drops; - - /** - * The xp to drop - */ - private final int xp; - - /** - * Create event based off parameters - * - * @param victim The killed entity - * @param damager The killer - * @param drops The item drops - * @param xp The amount of xp to drop - * @param deathEvent The associated {@link EntityDeathEvent} - */ - public EntityDeathByEntityEvent(@NotNull LivingEntity victim, @NotNull Entity damager, @NotNull List drops, int xp, @NotNull EntityDeathEvent deathEvent) { - this.victim = victim; - this.damager = damager; - this.drops = drops; - this.xp = xp; - this.deathEvent = deathEvent; - } - - /** - * Get victim - * - * @return The victim - */ - public LivingEntity getVictim() { - return this.victim; - } - - /** - * Get killer - * - * @return The killer - */ - public Entity getKiller() { - return this.damager; - } - - /** - * Get xp amount - * - * @return The xp - */ - public int getDroppedExp() { - return this.xp; - } - - /** - * Get drops - * - * @return {@link List} of drops - */ - public List getDrops() { - return this.drops; - } - - /** - * Get associated {@link EntityDeathEvent} - * Use this to modify event parameters. - * - * @return The associated {@link EntityDeathEvent} - */ - public EntityDeathEvent getDeathEvent() { - return this.deathEvent; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityListeners.java deleted file mode 100644 index dfe56a6e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityListeners.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.willfp.ecoenchants.events.entitydeathbyentity; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; - -public class EntityDeathByEntityListeners implements Listener { - - final Set events = new HashSet<>(); - - @EventHandler(priority = EventPriority.HIGH) - public void onEntityDamage(EntityDamageByEntityEvent event) { - if (!(event.getEntity() instanceof LivingEntity)) return; - - LivingEntity victim = (LivingEntity) event.getEntity(); - - if (victim.getHealth() > event.getFinalDamage()) return; - - EntityDeathByEntityBuilder builtEvent = new EntityDeathByEntityBuilder(); - builtEvent.setVictim(victim); - builtEvent.setDamager(event.getDamager()); - events.add(builtEvent); - - new BukkitRunnable() { - @Override - public void run() { - events.remove(builtEvent); - } - }.runTaskLater(EcoEnchantsPlugin.getInstance(), 1); - } - - @EventHandler - public void onEntityDeath(EntityDeathEvent event) { - LivingEntity victim = event.getEntity(); - - List drops = event.getDrops(); - int xp = event.getDroppedExp(); - - AtomicReference atomicBuiltEvent = new AtomicReference<>(null); - EntityDeathByEntityBuilder builtEvent; - - events.forEach((deathByEntityEvent) -> { - if (deathByEntityEvent.getVictim().equals(victim)) { - atomicBuiltEvent.set(deathByEntityEvent); - } - }); - - if (atomicBuiltEvent.get() == null) return; - - builtEvent = atomicBuiltEvent.get(); - events.remove(builtEvent); - builtEvent.setDrops(drops); - builtEvent.setXp(xp); - builtEvent.setDeathEvent(event); - - builtEvent.push(); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainBuilder.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainBuilder.java deleted file mode 100644 index e21d5e30..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainBuilder.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.willfp.ecoenchants.events.naturalexpgainevent; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.player.PlayerExpChangeEvent; - -class NaturalExpGainBuilder { - private final LivingEntity victim = null; - private boolean cancelled = false; - private PlayerExpChangeEvent event; - private Location loc; - private BuildReason reason; - - public NaturalExpGainBuilder(BuildReason reason) { - this.reason = reason; - } - - public LivingEntity getVictim() { - return this.victim; - } - - public void setEvent(PlayerExpChangeEvent event) { - this.event = event; - } - - public void setCancelled(boolean cancel) { - this.cancelled = cancel; - } - - public void setLoc(Location location) { - this.loc = location; - } - - public Location getLoc() { - return this.loc; - } - - public BuildReason getReason() { - return reason; - } - - public void push() { - if (this.event == null) return; - if (this.cancelled) return; - - NaturalExpGainEvent naturalExpGainEvent = new NaturalExpGainEvent(event); - - Bukkit.getPluginManager().callEvent(naturalExpGainEvent); - } - - public enum BuildReason { - BOTTLE, - PLAYER - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainEvent.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainEvent.java deleted file mode 100644 index cb06a0ef..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainEvent.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.willfp.ecoenchants.events.naturalexpgainevent; - -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.bukkit.event.player.PlayerExpChangeEvent; -import org.jetbrains.annotations.NotNull; - -/** - * Event triggered when player receives experience not from bottle - */ -public class NaturalExpGainEvent extends Event { - private static final HandlerList HANDLERS = new HandlerList(); - - /** - * The associated {@link PlayerExpChangeEvent} - */ - private final PlayerExpChangeEvent event; - - /** - * Create event based off parameters - * - * @param event The associate PlayerExpChangeEvent - */ - public NaturalExpGainEvent(@NotNull PlayerExpChangeEvent event) { - this.event = event; - } - - /** - * Get associated {@link PlayerExpChangeEvent} - * Use this to modify event parameters. - * - * @return The associated {@link PlayerExpChangeEvent} - */ - public PlayerExpChangeEvent getExpChangeEvent() { - return this.event; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainListeners.java deleted file mode 100644 index 30df3c11..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainListeners.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.willfp.ecoenchants.events.naturalexpgainevent; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.ExpBottleEvent; -import org.bukkit.event.player.PlayerExpChangeEvent; - -import java.util.HashSet; -import java.util.Set; - -public class NaturalExpGainListeners implements Listener { - private final Set events = new HashSet<>(); - - @EventHandler - public void playerChange(PlayerExpChangeEvent event) { - NaturalExpGainBuilder builder = new NaturalExpGainBuilder(NaturalExpGainBuilder.BuildReason.PLAYER); - builder.setEvent(event); - - NaturalExpGainBuilder toRemove = null; - for (NaturalExpGainBuilder searchBuilder : events) { - if(!searchBuilder.getLoc().getWorld().equals(event.getPlayer().getLocation().getWorld())) continue; - if(searchBuilder.getReason().equals(NaturalExpGainBuilder.BuildReason.BOTTLE) && searchBuilder.getLoc().distanceSquared(event.getPlayer().getLocation()) > 52) - toRemove = searchBuilder; - } - - if(toRemove != null) { - events.remove(toRemove); - return; - } - - builder.setEvent(event); - builder.push(); - - events.remove(builder); - } - - @EventHandler - public void onExpBottle(ExpBottleEvent event) { - NaturalExpGainBuilder builtEvent = new NaturalExpGainBuilder(NaturalExpGainBuilder.BuildReason.BOTTLE); - builtEvent.setLoc(event.getEntity().getLocation()); - - events.add(builtEvent); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/Integration.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/Integration.java deleted file mode 100644 index 2bbfc456..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/Integration.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.willfp.ecoenchants.integrations; - -/** - * Interface for all integrations with optional dependencies - */ -public interface Integration { - /** - * Get the name of integration - * @return The name - */ - String getPluginName(); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/AnticheatManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/AnticheatManager.java deleted file mode 100644 index e7855b2d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/AnticheatManager.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.willfp.ecoenchants.integrations.anticheat; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; - -import java.util.HashSet; -import java.util.Set; - -/** - * Utility class for Anticheat Integrations - */ -public class AnticheatManager { - private static final Set anticheats = new HashSet<>(); - - /** - * Register a new anticheat - * - * @param anticheat The anticheat to register - */ - public static void register(AnticheatWrapper anticheat) { - if (anticheat instanceof Listener) { - Bukkit.getPluginManager().registerEvents((Listener) anticheat, EcoEnchantsPlugin.getInstance()); - } - anticheats.add(anticheat); - } - - /** - * Exempt a player from triggering anticheats - * - * @param player The player to exempt - */ - public static void exemptPlayer(Player player) { - anticheats.forEach(anticheat -> anticheat.exempt(player)); - } - - /** - * Unexempt a player from triggering anticheats - * This is ran a tick after it is called to ensure that there are no event timing conflicts - * - * @param player The player to remove the exemption - */ - public static void unexemptPlayer(Player player) { - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - anticheats.forEach(anticheat -> anticheat.unexempt(player)); - }, 1); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/AnticheatWrapper.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/AnticheatWrapper.java deleted file mode 100644 index f5055318..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/AnticheatWrapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.willfp.ecoenchants.integrations.anticheat; - -import com.willfp.ecoenchants.integrations.Integration; -import org.bukkit.entity.Player; - -/** - * Interface for anticheat integrations - */ -public interface AnticheatWrapper extends Integration { - /** - * Exempt a player from checks - * - * @param player The player to exempt - */ - void exempt(Player player); - - /** - * Unexempt a player from checks - * - * @param player The player to unexempt - */ - void unexempt(Player player); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatAAC.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatAAC.java deleted file mode 100644 index 5d675bc8..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatAAC.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.ecoenchants.integrations.anticheat.plugins; - -import com.willfp.ecoenchants.integrations.anticheat.AnticheatWrapper; -import me.konsolas.aac.api.AACAPI; -import me.konsolas.aac.api.AACExemption; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; - -public class AnticheatAAC implements AnticheatWrapper, Listener { - private final AACExemption ECOENCHANTS = new AACExemption("EcoEnchants"); - private final AACAPI api = Bukkit.getServicesManager().load(AACAPI.class); - - @Override - public String getPluginName() { - return "AAC"; - } - - @Override - public void exempt(Player player) { - api.addExemption(player, ECOENCHANTS); - } - - @Override - public void unexempt(Player player) { - api.removeExemption(player, ECOENCHANTS); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatMatrix.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatMatrix.java deleted file mode 100644 index d4fc67ec..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatMatrix.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.ecoenchants.integrations.anticheat.plugins; - -import com.willfp.ecoenchants.integrations.anticheat.AnticheatWrapper; -import me.rerere.matrix.api.events.PlayerViolationEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -public class AnticheatMatrix implements AnticheatWrapper, Listener { - private final Set exempt = new HashSet<>(); - - @Override - public String getPluginName() { - return "Matrix"; - } - - @Override - public void exempt(Player player) { - this.exempt.add(player.getUniqueId()); - } - - @Override - public void unexempt(Player player) { - this.exempt.remove(player.getUniqueId()); - } - - @EventHandler(priority = EventPriority.LOWEST) - private void onViolate(PlayerViolationEvent event) { - if (!exempt.contains(event.getPlayer().getUniqueId())) { - return; - } - - event.setCancelled(true); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatNCP.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatNCP.java deleted file mode 100644 index a6f2e585..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatNCP.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.willfp.ecoenchants.integrations.anticheat.plugins; - -import com.willfp.ecoenchants.integrations.anticheat.AnticheatWrapper; -import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager; -import org.bukkit.entity.Player; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -public class AnticheatNCP implements AnticheatWrapper { - private final Set exempt = new HashSet<>(); - - @Override - public String getPluginName() { - return "NCP"; - } - - @Override - public void exempt(Player player) { - if (!NCPExemptionManager.isExempted(player, CheckType.ALL)) { - return; - } - - if (exempt.add(player.getUniqueId())) { - NCPExemptionManager.exemptPermanently(player, CheckType.ALL); - } - } - - @Override - public void unexempt(Player player) { - if (exempt.remove(player.getUniqueId())) { - NCPExemptionManager.unexempt(player, CheckType.ALL); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatSpartan.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatSpartan.java deleted file mode 100644 index 9ec1eb80..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatSpartan.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.ecoenchants.integrations.anticheat.plugins; - -import com.willfp.ecoenchants.integrations.anticheat.AnticheatWrapper; -import me.vagdedes.spartan.api.PlayerViolationEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -public class AnticheatSpartan implements AnticheatWrapper, Listener { - private final Set exempt = new HashSet<>(); - - @Override - public String getPluginName() { - return "Spartan"; - } - - @Override - public void exempt(Player player) { - this.exempt.add(player.getUniqueId()); - } - - @Override - public void unexempt(Player player) { - this.exempt.remove(player.getUniqueId()); - } - - @EventHandler(priority = EventPriority.LOWEST) - private void onViolate(PlayerViolationEvent event) { - if (!exempt.contains(event.getPlayer().getUniqueId())) { - return; - } - - event.setCancelled(true); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/AntigriefManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/AntigriefManager.java deleted file mode 100644 index c5671b26..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/AntigriefManager.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.willfp.ecoenchants.integrations.antigrief; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -import java.util.HashSet; -import java.util.Set; - -public class AntigriefManager { - private static final Set antigriefs = new HashSet<>(); - - /** - * Register a new AntiGrief/Land Management integration - * - * @param antigrief The integration to register - */ - public static void register(AntigriefWrapper antigrief) { - antigriefs.add(antigrief); - } - - /** - * Can player break block - * - * @param player The player - * @param block The block - * @return If player can break block - */ - public static boolean canBreakBlock(Player player, Block block) { - return antigriefs.stream().allMatch(antigriefWrapper -> antigriefWrapper.canBreakBlock(player, block)); - } - - /** - * Can player create explosion at location - * - * @param player The player - * @param location The location - * @return If player can create explosion - */ - public static boolean canCreateExplosion(Player player, Location location) { - return antigriefs.stream().allMatch(antigriefWrapper -> antigriefWrapper.canCreateExplosion(player, location)); - } - - /** - * Can player place block - * - * @param player The player - * @param block The block - * @return If player can place block - */ - public static boolean canPlaceBlock(Player player, Block block) { - return antigriefs.stream().allMatch(antigriefWrapper -> antigriefWrapper.canPlaceBlock(player, block)); - } - - /** - * Can player injure living entity - * - * @param player The player - * @param victim The victim - * @return If player can injure - */ - public static boolean canInjure(Player player, LivingEntity victim) { - return antigriefs.stream().allMatch(antigriefWrapper -> antigriefWrapper.canInjure(player, victim)); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/AntigriefWrapper.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/AntigriefWrapper.java deleted file mode 100644 index 82085871..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/AntigriefWrapper.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.willfp.ecoenchants.integrations.antigrief; - -import com.willfp.ecoenchants.integrations.Integration; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -/** - * Interface for Antigrief integrations - */ -public interface AntigriefWrapper extends Integration { - /** - * Can player break block - * - * @param player The player - * @param block The block - * @return If player cna break block - */ - boolean canBreakBlock(Player player, Block block); - - /** - * Can player create explosion at location - * - * @param player The player - * @param location The location - * @return If player can create explosion - */ - boolean canCreateExplosion(Player player, Location location); - - /** - * Can player place block - * - * @param player The player - * @param block The block - * @return If player can place block - */ - boolean canPlaceBlock(Player player, Block block); - - /** - * Can player injure living entity - * - * @param player The player - * @param victim The victim - * @return If player can injure - */ - boolean canInjure(Player player, LivingEntity victim); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefFactionsUUID.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefFactionsUUID.java deleted file mode 100644 index ee9795cf..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefFactionsUUID.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.willfp.ecoenchants.integrations.antigrief.plugins; - -import com.massivecraft.factions.*; -import com.massivecraft.factions.perms.PermissibleAction; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -public class AntigriefFactionsUUID implements AntigriefWrapper { - @Override - public boolean canBreakBlock(Player player, Block block) { - FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); - FLocation flocation = new FLocation(block.getLocation()); - Faction faction = Board.getInstance().getFactionAt(flocation); - - if (!faction.hasAccess(fplayer, PermissibleAction.DESTROY)) { - return fplayer.isAdminBypassing(); - } - return true; - } - - @Override - public boolean canCreateExplosion(Player player, Location location) { - FLocation flocation = new FLocation(location); - Faction faction = Board.getInstance().getFactionAt(flocation); - - return !faction.noExplosionsInTerritory(); - } - - @Override - public boolean canPlaceBlock(Player player, Block block) { - FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); - FLocation flocation = new FLocation(block.getLocation()); - Faction faction = Board.getInstance().getFactionAt(flocation); - - if (!faction.hasAccess(fplayer, PermissibleAction.BUILD)) { - return fplayer.isAdminBypassing(); - } - return true; - } - - @Override - public boolean canInjure(Player player, LivingEntity victim) { - FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); - FLocation flocation = new FLocation(victim.getLocation()); - Faction faction = Board.getInstance().getFactionAt(flocation); - - if(victim instanceof Player) { - if (faction.isPeaceful()) { - return fplayer.isAdminBypassing(); - } - } else { - if (faction.hasAccess(fplayer, PermissibleAction.DESTROY)) { - return fplayer.isAdminBypassing(); - } - } - return true; - } - - @Override - public String getPluginName() { - return "FactionsUUID"; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefGriefPrevention.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefGriefPrevention.java deleted file mode 100644 index e9dc0e23..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefGriefPrevention.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.willfp.ecoenchants.integrations.antigrief.plugins; - -import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper; -import me.ryanhamshire.GriefPrevention.Claim; -import me.ryanhamshire.GriefPrevention.GriefPrevention; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -public class AntigriefGriefPrevention implements AntigriefWrapper { - @Override - public boolean canBreakBlock(Player player, Block block) { - Claim claim = GriefPrevention.instance.dataStore.getClaimAt(block.getLocation(), false, null); - if (claim != null) { - return claim.allowBreak(player, block.getType()) == null; - } - return true; - } - - @Override - public boolean canCreateExplosion(Player player, Location location) { - Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, false, null); - if (claim != null) { - return claim.areExplosivesAllowed; - } - return true; - } - - @Override - public boolean canPlaceBlock(Player player, Block block) { - Claim claim = GriefPrevention.instance.dataStore.getClaimAt(block.getLocation(), false, null); - if (claim != null) { - return claim.allowBuild(player, block.getType()) == null; - } - return true; - } - - @Override - public boolean canInjure(Player player, LivingEntity victim) { - Claim claim = GriefPrevention.instance.dataStore.getClaimAt(victim.getLocation(), false, null); - if(victim instanceof Player) { - return claim == null; - } else { - if (claim != null && claim.ownerID != null) { - return claim.ownerID.equals(player.getUniqueId()); - } - return true; - } - } - - @Override - public String getPluginName() { - return "GriefPrevention"; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefKingdoms.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefKingdoms.java deleted file mode 100644 index 66ebe22e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefKingdoms.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.willfp.ecoenchants.integrations.antigrief.plugins; - -import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.inventory.EquipmentSlot; -import org.kingdoms.constants.kingdom.Kingdom; -import org.kingdoms.constants.land.Land; -import org.kingdoms.managers.PvPManager; -import org.kingdoms.managers.land.LandManager; - -public class AntigriefKingdoms implements AntigriefWrapper { - @Override - public boolean canBreakBlock(Player player, Block block) { - BlockBreakEvent event = new BlockBreakEvent(block, player); - LandManager.onBreak(event); - return !event.isCancelled(); - } - - @Override - public boolean canCreateExplosion(Player player, Location location) { - Land land = Land.getLand(location); - if (land == null) return true; - if(!land.isClaimed()) return true; - - Kingdom kingdom = land.getKingdom(); - return kingdom.isMember(player); - } - - @Override - public boolean canPlaceBlock(Player player, Block block) { - Block placedOn = block.getRelative(0, -1, 0); - BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), placedOn, player.getInventory().getItemInMainHand(), player, true, EquipmentSlot.HAND); - LandManager.onPlace(event); - return !event.isCancelled(); - } - - @Override - public boolean canInjure(Player player, LivingEntity victim) { - if(victim instanceof Player) { - return PvPManager.canFight(player, (Player) victim); - } else { - Land land = Land.getLand(victim.getLocation()); - if (land == null) return true; - if(!land.isClaimed()) return true; - - Kingdom kingdom = land.getKingdom(); - return kingdom.isMember(player); - } - } - - @Override - public String getPluginName() { - return "Kingdoms"; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefLands.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefLands.java deleted file mode 100644 index 9ae1f0c8..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefLands.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.willfp.ecoenchants.integrations.antigrief.plugins; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper; -import me.angeschossen.lands.api.integration.LandsIntegration; -import me.angeschossen.lands.api.land.Area; -import me.angeschossen.lands.api.role.enums.RoleSetting; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -public class AntigriefLands implements AntigriefWrapper { - @Override - public boolean canBreakBlock(Player player, Block block) { - LandsIntegration landsIntegration = new LandsIntegration(EcoEnchantsPlugin.getInstance()); - Area area = landsIntegration.getAreaByLoc(block.getLocation()); - if (area != null) { - return area.canSetting(player, RoleSetting.BLOCK_BREAK, false); - } - return true; - } - - @Override - public boolean canCreateExplosion(Player player, Location location) { - LandsIntegration landsIntegration = new LandsIntegration(EcoEnchantsPlugin.getInstance()); - Area area = landsIntegration.getAreaByLoc(location); - if (area != null) { - return area.canSetting(player, RoleSetting.BLOCK_IGNITE, false); - } - return true; - } - - @Override - public boolean canPlaceBlock(Player player, Block block) { - LandsIntegration landsIntegration = new LandsIntegration(EcoEnchantsPlugin.getInstance()); - Area area = landsIntegration.getAreaByLoc(block.getLocation()); - if (area != null) { - return area.canSetting(player, RoleSetting.BLOCK_PLACE, false); - } - return true; - } - - @Override - public boolean canInjure(Player player, LivingEntity victim) { - LandsIntegration landsIntegration = new LandsIntegration(EcoEnchantsPlugin.getInstance()); - Area area = landsIntegration.getAreaByLoc(victim.getLocation()); - if(victim instanceof Player) { - if (area != null) { - return area.canSetting(player, RoleSetting.ATTACK_PLAYER, false); - } - } else { - if (area != null) { - return area.canSetting(player, RoleSetting.ATTACK_ANIMAL, false); - } - } - return true; - } - - @Override - public String getPluginName() { - return "Lands"; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefTowny.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefTowny.java deleted file mode 100644 index cc927b64..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefTowny.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.willfp.ecoenchants.integrations.antigrief.plugins; - -import com.palmergames.bukkit.towny.object.Town; -import com.palmergames.bukkit.towny.object.TownyPermission; -import com.palmergames.bukkit.towny.object.WorldCoord; -import com.palmergames.bukkit.towny.utils.PlayerCacheUtil; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -public class AntigriefTowny implements AntigriefWrapper { - @Override - public boolean canBreakBlock(Player player, Block block) { - return PlayerCacheUtil.getCachePermission(player, block.getLocation(), block.getType(), TownyPermission.ActionType.DESTROY); - } - - @Override - public boolean canCreateExplosion(Player player, Location location) { - return PlayerCacheUtil.getCachePermission(player, location, Material.TNT, TownyPermission.ActionType.ITEM_USE); - } - - @Override - public boolean canPlaceBlock(Player player, Block block) { - return PlayerCacheUtil.getCachePermission(player, block.getLocation(), block.getType(), TownyPermission.ActionType.BUILD); - } - - @Override - public boolean canInjure(Player player, LivingEntity victim) { - if(victim instanceof Player) { - try { - Town town = WorldCoord.parseWorldCoord(victim.getLocation()).getTownBlock().getTown(); - return town.isPVP(); - } catch (Exception ignored) {} - } else { - try { - Town town = WorldCoord.parseWorldCoord(victim.getLocation()).getTownBlock().getTown(); - return town.hasMobs(); - } catch (Exception ignored) {} - } - return true; - } - - @Override - public String getPluginName() { - return "Towny"; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefWorldGuard.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefWorldGuard.java deleted file mode 100644 index d3bb6a82..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefWorldGuard.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.willfp.ecoenchants.integrations.antigrief.plugins; - -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldguard.LocalPlayer; -import com.sk89q.worldguard.WorldGuard; -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.protection.flags.Flags; -import com.sk89q.worldguard.protection.flags.StateFlag; -import com.sk89q.worldguard.protection.regions.RegionContainer; -import com.sk89q.worldguard.protection.regions.RegionQuery; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper; -import org.apache.commons.lang.Validate; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -public class AntigriefWorldGuard implements AntigriefWrapper { - @Override - public boolean canBreakBlock(Player player, Block block) { - LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); - RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - RegionQuery query = container.createQuery(); - - if (query.queryState(BukkitAdapter.adapt(block.getLocation()), localPlayer, Flags.BUILD) == StateFlag.State.DENY) { - return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(block.getWorld())); - } - return true; - } - - @Override - public boolean canCreateExplosion(Player player, Location location) { - LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); - RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - RegionQuery query = container.createQuery(); - World world = location.getWorld(); - Validate.notNull(world, "World cannot be null!"); - - if (query.queryState(BukkitAdapter.adapt(location), localPlayer, Flags.OTHER_EXPLOSION) == StateFlag.State.DENY) { - return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(world)); - } - return true; - } - - @Override - public boolean canPlaceBlock(Player player, Block block) { - LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); - RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - RegionQuery query = container.createQuery(); - - if (query.queryState(BukkitAdapter.adapt(block.getLocation()), localPlayer, Flags.BLOCK_PLACE) == StateFlag.State.DENY) { - return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(block.getWorld())); - } - return true; - } - - @Override - public boolean canInjure(Player player, LivingEntity victim) { - LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); - RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - RegionQuery query = container.createQuery(); - - if(victim instanceof Player) { - if (query.queryState(BukkitAdapter.adapt(victim.getLocation()), localPlayer, Flags.PVP) == StateFlag.State.DENY) { - return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(player.getWorld())); - } - } else { - if (query.queryState(BukkitAdapter.adapt(victim.getLocation()), localPlayer, Flags.DAMAGE_ANIMALS) == StateFlag.State.DENY) { - return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(player.getWorld())); - } - } - return true; - } - - @Override - public String getPluginName() { - return "WorldGuard"; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsManager.java deleted file mode 100644 index 0869bcf7..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsManager.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.willfp.ecoenchants.integrations.essentials; - -import java.util.HashSet; -import java.util.Set; - -/** - * Utility class for interfacing with EssentialsX - */ -public class EssentialsManager { - private static final Set registered = new HashSet<>(); - - /** - * Register a new essentials integration - * - * @param essentials The integration to register - */ - public static void register(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/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsWrapper.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsWrapper.java deleted file mode 100644 index 4330a61c..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsWrapper.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.willfp.ecoenchants.integrations.essentials; - -import com.willfp.ecoenchants.integrations.Integration; - -/** - * Interface for Essentials Integration - */ -public interface EssentialsWrapper extends Integration { - /** - * @see EssentialsManager#registerEnchantments() - */ - void registerAllEnchantments(); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/plugins/IntegrationEssentials.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/plugins/IntegrationEssentials.java deleted file mode 100644 index 30d35b34..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/plugins/IntegrationEssentials.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.integrations.essentials.plugins; - -import com.earth2me.essentials.Enchantments; -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; - -/** - * Concrete implementation of {@link EssentialsWrapper} - */ -@SuppressWarnings("unchecked") -public class IntegrationEssentials implements EssentialsWrapper { - @Override - public void registerAllEnchantments() { - try { - for (Enchantment enchantment : EcoEnchants.getAll()) { - ((Map) FieldUtils.readDeclaredStaticField(Enchantments.class, "ENCHANTMENTS", true)).put(enchantment.getKey().getKey(), enchantment); - } - } catch (IllegalAccessException ignored) {} - } - - @Override - public String getPluginName() { - return "Essentials"; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/McmmoIntegration.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/McmmoIntegration.java deleted file mode 100644 index 3e7c3cfc..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/McmmoIntegration.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.ecoenchants.integrations.mcmmo; - -import com.willfp.ecoenchants.integrations.Integration; -import org.bukkit.event.Event; - -/** - * Interface for mcMMO integrations - */ -public interface McmmoIntegration extends Integration { - /** - * @see McmmoManager#isFake(Event) - */ - boolean isFake(Event event); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/McmmoManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/McmmoManager.java deleted file mode 100644 index a63f27a6..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/McmmoManager.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.willfp.ecoenchants.integrations.mcmmo; - -import com.willfp.ecoenchants.util.ClassUtils; -import org.bukkit.event.Event; - -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * Utility class for interfacing with mcMMO - */ -public class McmmoManager { - private static final Set integrations = new HashSet<>(); - - /** - * Register a new mcMMO integration - * - * @param integration The integration to register - */ - public static void registerIntegration(McmmoIntegration integration) { - if(!ClassUtils.exists("com.gmail.nossr50.events.fake.FakeEvent")) - return; - integrations.add(integration); - } - - /** - * Get if an event is fake - * - * @param event The event to check - * @return If the event is fake - */ - public static boolean isFake(Event event) { - AtomicBoolean isFake = new AtomicBoolean(false); - integrations.forEach(integration -> { - if (integration.isFake(event)) isFake.set(true); - }); - - return isFake.get(); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/plugins/McmmoIntegrationImpl.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/plugins/McmmoIntegrationImpl.java deleted file mode 100644 index 8d05c1c9..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/plugins/McmmoIntegrationImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.willfp.ecoenchants.integrations.mcmmo.plugins; - -import com.gmail.nossr50.events.fake.FakeEvent; -import com.willfp.ecoenchants.integrations.mcmmo.McmmoIntegration; -import org.bukkit.event.Event; - -/** - * Concrete implementation of {@link McmmoIntegration} - */ -public class McmmoIntegrationImpl implements McmmoIntegration { - @Override - public boolean isFake(Event event) { - return event instanceof FakeEvent; - } - - @Override - public String getPluginName() { - return "mcMMO"; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/PlaceholderEntry.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/PlaceholderEntry.java deleted file mode 100644 index d7c3d26e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/PlaceholderEntry.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.willfp.ecoenchants.integrations.placeholder; - -import com.willfp.ecoenchants.util.interfaces.ObjectBiCallable; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.Nullable; - -/** - * A placeholder entry consists of an identifier and an {@link ObjectBiCallable} to fetch the result - */ -public class PlaceholderEntry { - private final String identifier; - private final ObjectBiCallable function; - private final boolean requiresPlayer; - - /** - * Create a placeholder entry that doesn't require a player - * - * @param identifier The identifier of the placeholder - * @param function A lambda to get the result of the placeholder - */ - public PlaceholderEntry(String identifier, ObjectBiCallable function) { - this(identifier, function, false); - } - - /** - * Create a placeholder entry that may require a player - * - * @param identifier The identifier of the placeholder - * @param function A lambda to get the result of the placeholder - * @param requiresPlayer If the placeholder requires a player - */ - public PlaceholderEntry(String identifier, ObjectBiCallable function, boolean requiresPlayer) { - this.identifier = identifier; - this.function = function; - this.requiresPlayer = requiresPlayer; - } - - /** - * Get the identifier of the placeholder - * - * @return The identifier - */ - public String getIdentifier() { - return this.identifier; - } - - /** - * Get the result of the placeholder with respect to a player - * - * @param player The player to translate with respect to - * @return The result of the placeholder - */ - public String getResult(@Nullable Player player) { - return this.function.call(player); - } - - /** - * Get if the placeholder requires a player to get a result - * - * @return If the placeholder requires a player - */ - public boolean requiresPlayer() { - return requiresPlayer; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/PlaceholderIntegration.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/PlaceholderIntegration.java deleted file mode 100644 index 45773a0b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/PlaceholderIntegration.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.willfp.ecoenchants.integrations.placeholder; - -import com.willfp.ecoenchants.integrations.Integration; -import org.bukkit.entity.Player; - -/** - * Interface for Placeholder integrations - */ -public interface PlaceholderIntegration extends Integration { - /** - * Register the integration with the specified plugin - * Not to be confused with internal registration in {@link PlaceholderManager#addIntegration(PlaceholderIntegration)} - */ - void registerIntegration(); - - /** - * Translate all the placeholders in a string with respect to a player - * - * @param text The text to translate - * @param player The player to translate with respect to - * @return The string, translated - */ - String translate(String text, Player player); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/PlaceholderManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/PlaceholderManager.java deleted file mode 100644 index 2282d203..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/PlaceholderManager.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.willfp.ecoenchants.integrations.placeholder; - -import org.bukkit.entity.Player; -import org.jetbrains.annotations.Nullable; - -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; - -/** - * Utility class for placeholders - */ -public class PlaceholderManager { - private static final Set placeholders = new HashSet<>(); - private static final Set integrations = new HashSet<>(); - - /** - * Register a new placeholder integration - * - * @param integration The {@link PlaceholderIntegration} to register - */ - public static void addIntegration(PlaceholderIntegration integration) { - integration.registerIntegration(); - integrations.add(integration); - } - - /** - * Register a placeholder - * - * @param expansion The {@link PlaceholderEntry} to register - */ - public static void registerPlaceholder(PlaceholderEntry expansion) { - placeholders.removeIf(placeholderEntry -> placeholderEntry.getIdentifier().equalsIgnoreCase(expansion.getIdentifier())); - placeholders.add(expansion); - } - - /** - * Get the result of a placeholder with respect to a player - * - * @param player The player to get the result from - * @param identifier The placeholder identifier - * @return The value of the placeholder - */ - public static String getResult(@Nullable Player player, String identifier) { - Optional matching = placeholders.stream().filter(expansion -> expansion.getIdentifier().equalsIgnoreCase(identifier)).findFirst(); - if (!matching.isPresent()) - return null; - PlaceholderEntry entry = matching.get(); - if (player == null && entry.requiresPlayer()) - return ""; - return entry.getResult(player); - } - - /** - * Translate all placeholders with respect to a player - * - * @param text The text that may contain placeholders to translate - * @param player The player to translate the placeholders with respect to - * @return The text, translated - */ - public static String translatePlaceholders(String text, @Nullable Player player) { - AtomicReference translatedReference = new AtomicReference<>(text); - integrations.forEach(placeholderIntegration -> translatedReference.set(placeholderIntegration.translate(translatedReference.get(), player))); - return translatedReference.get(); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/plugins/PlaceholderIntegrationPAPI.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/plugins/PlaceholderIntegrationPAPI.java deleted file mode 100644 index 7c2303cc..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/plugins/PlaceholderIntegrationPAPI.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.willfp.ecoenchants.integrations.placeholder.plugins; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.integrations.placeholder.PlaceholderIntegration; -import com.willfp.ecoenchants.integrations.placeholder.PlaceholderManager; -import me.clip.placeholderapi.PlaceholderAPI; -import me.clip.placeholderapi.expansion.PlaceholderExpansion; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; - -/** - * PlaceholderAPI integration - */ -public class PlaceholderIntegrationPAPI extends PlaceholderExpansion implements PlaceholderIntegration { - @Override - public boolean persist() { - return true; - } - - @Override - public boolean canRegister() { - return true; - } - - @Override - public @NotNull String getAuthor() { - return "Auxilor"; - } - - @Override - public @NotNull String getIdentifier() { - return "ecoenchants"; - } - - @Override - public @NotNull String getVersion() { - return EcoEnchantsPlugin.getInstance().getDescription().getVersion(); - } - - @Override - public String onPlaceholderRequest(Player player, @NotNull String identifier) { - return PlaceholderManager.getResult(player, identifier); - } - - @Override - public void registerIntegration() { - this.register(); - } - - @Override - public String getPluginName() { - return "PlaceholderAPI"; - } - - @Override - public String translate(String text, Player player) { - return PlaceholderAPI.setPlaceholders(player, text); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardManager.java deleted file mode 100644 index f86ae04d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardManager.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.willfp.ecoenchants.integrations.worldguard; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import org.bukkit.Location; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -import java.util.HashSet; -import java.util.Set; - -public class WorldguardManager { - private static final Set worldguardWrappers = new HashSet<>(); - - /** - * Register a new WorldGuard integration - * - * @param worldguard The integration to register - */ - public static void register(WorldguardWrapper worldguard) { - worldguardWrappers.add(worldguard); - } - - /** - * Register a new StateFlag with worldguard - * - * @param flagName The name of the flag - * @param defaultValue The default value for the flag to have - */ - public static void registerFlag(String flagName, boolean defaultValue) { - worldguardWrappers.forEach(worldguardWrapper -> worldguardWrapper.registerFlag(flagName, defaultValue)); - } - - /** - * Get if an enchant is enabled at a player's location - * - * @param enchant The enchantment to check - * @param player The player to query - * @return If the enchantment is enabled at a player's location - */ - public static boolean enabledForPlayer(EcoEnchant enchant, LivingEntity player) { - if (!(player instanceof Player)) return true; - if(worldguardWrappers.isEmpty()) return true; - return worldguardWrappers.stream().anyMatch(worldguardWrapper -> worldguardWrapper.enabledForPlayer(enchant, (Player) player, player.getLocation())); - } - - /** - * Get if an enchant is enabled at a specific location - * - * @param enchant The enchantment to check - * @param player The player to query - * @param location The location to query - * @return If the enchantment is enabled at a player's location - */ - public static boolean enabledForPlayer(EcoEnchant enchant, LivingEntity player, Location location) { - if (!(player instanceof Player)) return true; - if(worldguardWrappers.isEmpty()) return true; - return worldguardWrappers.stream().anyMatch(worldguardWrapper -> worldguardWrapper.enabledForPlayer(enchant, (Player) player, location)); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardWrapper.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardWrapper.java deleted file mode 100644 index 1206e2d5..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardWrapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.willfp.ecoenchants.integrations.worldguard; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -public interface WorldguardWrapper { - void registerFlag(String name, boolean def); - boolean enabledForPlayer(EcoEnchant enchant, Player player, Location location); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/plugins/WorldguardIntegrationImpl.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/plugins/WorldguardIntegrationImpl.java deleted file mode 100644 index 64add0de..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/plugins/WorldguardIntegrationImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.ecoenchants.integrations.worldguard.plugins; - -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldguard.WorldGuard; -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.protection.flags.StateFlag; -import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.integrations.worldguard.WorldguardWrapper; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -public class WorldguardIntegrationImpl implements WorldguardWrapper { - private static final FlagRegistry REGISTRY = WorldGuard.getInstance().getFlagRegistry(); - - @Override - public void registerFlag(String name, boolean def) { - StateFlag flag = new StateFlag(name, def); - if(REGISTRY.get(name) == null) { - REGISTRY.register(flag); - } - } - - @Override - public boolean enabledForPlayer(EcoEnchant enchant, Player player, Location location) { - if(WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(WorldGuardPlugin.inst().wrapPlayer(player), BukkitAdapter.adapt(location.getWorld()))) return true; - return WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(location), WorldGuardPlugin.inst().wrapPlayer(player), (StateFlag) REGISTRY.get(enchant.getKey().getKey() + "-enabled")) == StateFlag.State.ALLOW; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/nms/BlockBreak.java b/Plugin/src/main/java/com/willfp/ecoenchants/nms/BlockBreak.java deleted file mode 100644 index f54b03ed..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/nms/BlockBreak.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.willfp.ecoenchants.nms; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.nms.api.BlockBreakWrapper; -import com.willfp.ecoenchants.util.internal.Logger; -import org.bukkit.Bukkit; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - -/** - * Utility class to break a block as if the player had done it manually - */ -public class BlockBreak { - private static BlockBreakWrapper blockBreakWrapper; - - /** - * Break a block as a player - * - * @param player The player to break the block as - * @param block The block to break - */ - public static void breakBlock(Player player, Block block) { - blockBreakWrapper.breakBlock(player, block); - } - - static { - try { - final Class class2 = Class.forName("com.willfp.ecoenchants.nms." + EcoEnchantsPlugin.NMS_VERSION + ".BlockBreak"); - if (BlockBreakWrapper.class.isAssignableFrom(class2)) { - blockBreakWrapper = (BlockBreakWrapper) class2.getConstructor().newInstance(); - } - } catch (Exception e) { - Logger.error("&cYou're running an unsupported server version: " + EcoEnchantsPlugin.NMS_VERSION); - Bukkit.getPluginManager().disablePlugin(EcoEnchantsPlugin.getInstance()); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/nms/ChatComponent.java b/Plugin/src/main/java/com/willfp/ecoenchants/nms/ChatComponent.java deleted file mode 100644 index d0087866..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/nms/ChatComponent.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.ecoenchants.nms; - - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.nms.api.ChatComponentWrapper; -import com.willfp.ecoenchants.util.internal.Logger; -import org.bukkit.Bukkit; -import org.bukkit.inventory.ItemStack; - -/** - * Utility class to manage chat components - */ -public class ChatComponent { - private static ChatComponentWrapper chatComponentWrapper; - - /** - * Modify NMS chat component - *

- * This method will convert any show_item Hover Events using {@link com.willfp.ecoenchants.display.EnchantDisplay#displayEnchantments(ItemStack)} - * - * @param object The NMS chat component to modify - * - * @return The NMS chat component, having been modified - */ - public static Object modifyComponent(Object object) { - return chatComponentWrapper.modifyComponent(object); - } - - static { - try { - final Class class2 = Class.forName("com.willfp.ecoenchants.nms." + EcoEnchantsPlugin.NMS_VERSION + ".ChatComponent"); - if (ChatComponentWrapper.class.isAssignableFrom(class2)) { - chatComponentWrapper = (ChatComponentWrapper) class2.getConstructor().newInstance(); - } - } catch (Exception e) { - Logger.error("&cYou're running an unsupported server version: " + EcoEnchantsPlugin.NMS_VERSION); - Bukkit.getPluginManager().disablePlugin(EcoEnchantsPlugin.getInstance()); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/nms/Cooldown.java b/Plugin/src/main/java/com/willfp/ecoenchants/nms/Cooldown.java deleted file mode 100644 index fea3e26d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/nms/Cooldown.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.willfp.ecoenchants.nms; - - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.nms.api.CooldownWrapper; -import com.willfp.ecoenchants.util.internal.Logger; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -/** - * Utility class to get the attack cooldown of a player - */ -public class Cooldown { - private static CooldownWrapper cooldown; - - /** - * Get a player's attack cooldown - * - * @param player The player to check - * - * @return A value between 0 and 1, with 1 representing max strength - */ - public static double getCooldown(Player player) { - return cooldown.getAttackCooldown(player); - } - - static { - try { - final Class class2 = Class.forName("com.willfp.ecoenchants.nms." + EcoEnchantsPlugin.NMS_VERSION + ".Cooldown"); - if (CooldownWrapper.class.isAssignableFrom(class2)) { - cooldown = (CooldownWrapper) class2.getConstructor().newInstance(); - } - } catch (Exception e) { - Logger.error("&cYou're running an unsupported server version: " + EcoEnchantsPlugin.NMS_VERSION); - Bukkit.getPluginManager().disablePlugin(EcoEnchantsPlugin.getInstance()); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/nms/FastGetEnchants.java b/Plugin/src/main/java/com/willfp/ecoenchants/nms/FastGetEnchants.java deleted file mode 100644 index 16936a0d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/nms/FastGetEnchants.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.willfp.ecoenchants.nms; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.nms.api.FastGetEnchantsWrapper; -import com.willfp.ecoenchants.util.internal.Logger; -import org.bukkit.Bukkit; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemStack; - -import java.util.Map; - -/** - * Utility class to break a block as if the player had done it manually - */ -public class FastGetEnchants { - private static FastGetEnchantsWrapper fastGetEnchantsWrapper; - - /** - * Efficiently get enchantments on an item without instantiating ItemMeta - * - * @param item The item to query - * @return A map of all enchantments, where the integer is the level - */ - public static Map getEnchantsOnItem(ItemStack item) { - return fastGetEnchantsWrapper.getEnchantmentsOnItem(item); - } - - /** - * Efficiently get level of enchantment on an item without using getByKey or instantiating keys or ItemMeta - * - * @param item The item to query - * @param enchantment The enchantment to query - * @return The level found, or 0 if not found - */ - public static int getLevelOnItem(ItemStack item, Enchantment enchantment) { - return fastGetEnchantsWrapper.getLevelOnItem(item, enchantment); - } - - static { - try { - final Class class2 = Class.forName("com.willfp.ecoenchants.nms." + EcoEnchantsPlugin.NMS_VERSION + ".FastGetEnchants"); - if (FastGetEnchantsWrapper.class.isAssignableFrom(class2)) { - fastGetEnchantsWrapper = (FastGetEnchantsWrapper) class2.getConstructor().newInstance(); - } - } catch (Exception e) { - Logger.error("&cYou're running an unsupported server version: " + EcoEnchantsPlugin.NMS_VERSION); - Bukkit.getPluginManager().disablePlugin(EcoEnchantsPlugin.getInstance()); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/nms/OpenInventory.java b/Plugin/src/main/java/com/willfp/ecoenchants/nms/OpenInventory.java deleted file mode 100644 index d709584e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/nms/OpenInventory.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.willfp.ecoenchants.nms; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.nms.api.OpenInventoryWrapper; -import com.willfp.ecoenchants.util.internal.Logger; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -/** - * Utility class to get the NMS implementation of a players' currently open inventory - */ -public class OpenInventory { - private static OpenInventoryWrapper openInventoryWrapper; - - /** - * Get the NMS container of the inventory - * - * @param player The player to check - * - * @return The NMS container - */ - public static Object getOpenInventory(Player player) { - return openInventoryWrapper.getOpenInventory(player); - } - - static { - try { - final Class class2 = Class.forName("com.willfp.ecoenchants.nms." + EcoEnchantsPlugin.NMS_VERSION + ".OpenInventory"); - if (OpenInventoryWrapper.class.isAssignableFrom(class2)) { - openInventoryWrapper = (OpenInventoryWrapper) class2.getConstructor().newInstance(); - } - } catch (Exception e) { - Logger.error("&cYou're running an unsupported server version: " + EcoEnchantsPlugin.NMS_VERSION); - Bukkit.getPluginManager().disablePlugin(EcoEnchantsPlugin.getInstance()); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/nms/RepairCost.java b/Plugin/src/main/java/com/willfp/ecoenchants/nms/RepairCost.java deleted file mode 100644 index cbc7a0b2..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/nms/RepairCost.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.willfp.ecoenchants.nms; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.nms.api.RepairCostWrapper; -import com.willfp.ecoenchants.util.internal.Logger; -import org.bukkit.Bukkit; -import org.bukkit.inventory.ItemStack; - -/** - * Utility class to get and set the anvil rework penalty of an item - */ -public class RepairCost { - private static RepairCostWrapper repairCostWrapper; - - /** - * Get the rework penalty of an ItemStack - * - * @param itemStack The item to check - * - * @return The anvil rework penalty - */ - public static int getRepairCost(ItemStack itemStack) { - return repairCostWrapper.getRepairCost(itemStack); - } - - /** - * Set the rework penalty of an ItemStack - * - * @param itemStack The item to set - * @param cost The penalty to set - * - * @return The ItemStack, with the repair cost set - */ - public static ItemStack setRepairCost(ItemStack itemStack, int cost) { - return repairCostWrapper.setRepairCost(itemStack, cost); - } - - static { - try { - final Class class2 = Class.forName("com.willfp.ecoenchants.nms." + EcoEnchantsPlugin.NMS_VERSION + ".RepairCost"); - if (RepairCostWrapper.class.isAssignableFrom(class2)) { - repairCostWrapper = (RepairCostWrapper) class2.getConstructor().newInstance(); - } - } catch (Exception e) { - Logger.error("&cYou're running an unsupported server version: " + EcoEnchantsPlugin.NMS_VERSION); - Bukkit.getPluginManager().disablePlugin(EcoEnchantsPlugin.getInstance()); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/nms/TridentStack.java b/Plugin/src/main/java/com/willfp/ecoenchants/nms/TridentStack.java deleted file mode 100644 index 922f6044..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/nms/TridentStack.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.willfp.ecoenchants.nms; - - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.nms.api.TridentStackWrapper; -import com.willfp.ecoenchants.util.internal.Logger; -import org.bukkit.Bukkit; -import org.bukkit.entity.Trident; -import org.bukkit.inventory.ItemStack; - -/** - * Utility class to get the {@link ItemStack} of a given {@link Trident} - */ -public class TridentStack { - private static TridentStackWrapper tridentStackWrapper; - - /** - * Get the {@link ItemStack} of a given {@link Trident} - * - * @param trident The trident to get the ItemStack from - * - * @return The ItemStack associated with the trident - */ - public static ItemStack getTridentStack(Trident trident) { - return tridentStackWrapper.getTridentStack(trident); - } - - static { - try { - final Class class2 = Class.forName("com.willfp.ecoenchants.nms." + EcoEnchantsPlugin.NMS_VERSION + ".TridentStack"); - if (TridentStackWrapper.class.isAssignableFrom(class2)) { - tridentStackWrapper = (TridentStackWrapper) class2.getConstructor().newInstance(); - } - } catch (Exception e) { - Logger.error("&cYou're running an unsupported server version: " + EcoEnchantsPlugin.NMS_VERSION); - Bukkit.getPluginManager().disablePlugin(EcoEnchantsPlugin.getInstance()); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/BlockUtils.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/BlockUtils.java deleted file mode 100644 index 4ee7b26a..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/BlockUtils.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.willfp.ecoenchants.util; - -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class BlockUtils { - private static Set getNearbyBlocks(Block start, List allowedMaterials, HashSet blocks, int limit) { - for (BlockFace face : BlockFace.values()) { - Block block = start.getRelative(face); - if (!blocks.contains(block) && allowedMaterials.contains(block.getType())) { - blocks.add(block); - if (blocks.size() > limit) return blocks; - if (blocks.size() > 2500) return blocks; // anti stack overflow - blocks.addAll(getNearbyBlocks(block, allowedMaterials, blocks, limit)); - } - } - return blocks; - } - - - /** - * Get a set of all blocks in contact with each other of a specific type - * - * @param start The initial block - * @param allowedMaterials A list of all valid {@link Material}s - * @param limit The maximum size of vein to return - * - * @return A set of all {@link Block}s - */ - public static Set getVein(Block start, List allowedMaterials, int limit) { - return getNearbyBlocks(start, allowedMaterials, new HashSet<>(), limit); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/ClassUtils.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/ClassUtils.java deleted file mode 100644 index 85bc0c49..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/ClassUtils.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.willfp.ecoenchants.util; - -public class ClassUtils { - /** - * Get if a class exists - * - * @param className The class to check - * - * @return If the class exists - * - * @see Class#forName(String) - */ - public static boolean exists(String className) { - try { - Class.forName(className); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/DurabilityUtils.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/DurabilityUtils.java deleted file mode 100644 index 600ae987..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/DurabilityUtils.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.willfp.ecoenchants.util; - -import org.bukkit.Bukkit; -import org.bukkit.Sound; -import org.bukkit.SoundCategory; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerItemBreakEvent; -import org.bukkit.event.player.PlayerItemDamageEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.inventory.meta.Damageable; -import org.bukkit.inventory.meta.ItemMeta; - -/** - * Contains methods for damaging/repairing items - */ -public class DurabilityUtils { - /** - * Damage an item in a player's inventory - * The slot of a held item can be obtained with {@link PlayerInventory#getHeldItemSlot()} - * Armor slots are 39 (helmet), 38 (chestplate), 37 (leggings), 36 (boots) - * - * @param player The player - * @param item The item to damage - * @param damage The amount of damage to deal - * @param slot The slot in the inventory of the item - */ - public static void damageItem(Player player, ItemStack item, int damage, int slot) { - if (item == null) return; - if (item.getItemMeta() == null) return; - - if (item.getItemMeta().isUnbreakable()) return; - - PlayerItemDamageEvent event3 = new PlayerItemDamageEvent(player, item, damage); - Bukkit.getPluginManager().callEvent(event3); - - if (!event3.isCancelled()) { - int damage2 = event3.getDamage(); - if (item.getItemMeta() instanceof Damageable) { - Damageable meta = (Damageable) item.getItemMeta(); - meta.setDamage(meta.getDamage() + damage2); - - if (meta.getDamage() >= item.getType().getMaxDurability()) { - meta.setDamage(item.getType().getMaxDurability()); - item.setItemMeta((ItemMeta) meta); - PlayerItemBreakEvent event = new PlayerItemBreakEvent(player, item); - Bukkit.getPluginManager().callEvent(event); - player.getInventory().clear(slot); - player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, SoundCategory.BLOCKS, 1, 1); - } else { - item.setItemMeta((ItemMeta) meta); - } - } - } - } - - /** - * Damage an item in a player's inventory without breaking it - * The slot of a held item can be obtained with {@link PlayerInventory#getHeldItemSlot()} - * Armor slots are 39 (helmet), 38 (chestplate), 37 (leggings), 36 (boots) - * - * @param item The item to damage - * @param damage The amount of damage to deal - * @param player The player - */ - public static void damageItemNoBreak(ItemStack item, int damage, Player player) { - if (item == null) return; - if (item.getItemMeta() == null) return; - - if (item.getItemMeta().isUnbreakable()) return; - - PlayerItemDamageEvent event3 = new PlayerItemDamageEvent(player, item, damage); - Bukkit.getPluginManager().callEvent(event3); - - if (!event3.isCancelled()) { - int damage2 = event3.getDamage(); - if (item.getItemMeta() instanceof Damageable) { - Damageable meta = (Damageable) item.getItemMeta(); - meta.setDamage(meta.getDamage() + damage2); - - if (meta.getDamage() >= item.getType().getMaxDurability()) { - meta.setDamage(item.getType().getMaxDurability() - 1); - } - item.setItemMeta((ItemMeta) meta); - } - } - } - - /** - * Repair an item in a player's inventory - * The slot of a held item can be obtained with {@link PlayerInventory#getHeldItemSlot()} - * Armor slots are 39 (helmet), 38 (chestplate), 37 (leggings), 36 (boots) - * - * @param item The item to damage - * @param repair The amount of damage to heal - */ - public static void repairItem(ItemStack item, int repair) { - if (item == null) return; - if (item.getItemMeta() == null) return; - - if (item.getItemMeta().isUnbreakable()) return; - if (item.getItemMeta() instanceof Damageable) { - Damageable meta = (Damageable) item.getItemMeta(); - meta.setDamage(meta.getDamage() - repair); - - if (meta.getDamage() < 0) { - meta.setDamage(0); - } - item.setItemMeta((ItemMeta) meta); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/LightningUtils.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/LightningUtils.java deleted file mode 100644 index ac00bf22..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/LightningUtils.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.util; - -import org.bukkit.Location; -import org.bukkit.entity.LivingEntity; - -/** - * Class containing methods for striking lightning - */ -public class LightningUtils { - - /** - * Strike lightning on player without fire - * - * @param victim The entity to smite - * @param damage The damage to deal - */ - public static void strike(LivingEntity victim, double damage) { - if (victim == null) return; - - Location loc = victim.getLocation(); - - victim.getWorld().strikeLightningEffect(loc); - - victim.damage(damage); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/NumberUtils.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/NumberUtils.java deleted file mode 100644 index 1a7e7a3e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/NumberUtils.java +++ /dev/null @@ -1,157 +0,0 @@ -package com.willfp.ecoenchants.util; - -import java.text.DecimalFormat; -import java.util.TreeMap; - -public class NumberUtils { - - private final static TreeMap NUMERALS = new TreeMap<>(); - - static { - - NUMERALS.put(1000, "M"); - NUMERALS.put(900, "CM"); - NUMERALS.put(500, "D"); - NUMERALS.put(400, "CD"); - NUMERALS.put(100, "C"); - NUMERALS.put(90, "XC"); - NUMERALS.put(50, "L"); - NUMERALS.put(40, "XL"); - NUMERALS.put(10, "X"); - NUMERALS.put(9, "IX"); - NUMERALS.put(5, "V"); - NUMERALS.put(4, "IV"); - NUMERALS.put(1, "I"); - - } - - /** - * Bias the input value according to a curve - * - * @param input The input value - * @param bias The bias between -1 and 1, where higher values bias input values to lower output values - * - * @return The biased output - */ - public static double bias(double input, double bias) { - double k = Math.pow(1 - bias, 3); - - return (input * k) / (input * k - input + 1); - } - - /** - * If value is above maximum, set it to maximum - * - * @param toChange The value to test - * @param limit The maximum - * - * @return The new value - */ - public static int equalIfOver(int toChange, int limit) { - if (toChange > limit) { - toChange = limit; - } - return toChange; - } - - /** - * If value is above maximum, set it to maximum - * - * @param toChange The value to test - * @param limit The maximum - * - * @return The new value - */ - public static double equalIfOver(double toChange, double limit) { - if (toChange > limit) { - toChange = limit; - } - return toChange; - } - - /** - * Get Roman Numeral from number - * - * @param number The number to convert - * - * @return The number, converted to a roman numeral - */ - public static String toNumeral(int number) { - if (number >= 1 && number <= 4096) { - int l = NUMERALS.floorKey(number); - if (number == l) { - return NUMERALS.get(number); - } - return NUMERALS.get(l) + toNumeral(number - l); - } else return String.valueOf(number); - } - - /** - * Generate random integer in range - * - * @param min Minimum - * @param max Maximum - * - * @return Random integer - */ - public static int randInt(int min, int max) { - return (int) ((long) min + Math.random() * ((long) max - min + 1)); - } - - /** - * Generate random double in range - * - * @param min Minimum - * @param max Maximum - * - * @return Random double - */ - public static double randFloat(double min, double max) { - java.util.Random rand = new java.util.Random(); - return rand.nextFloat() * (max - min) + min; - } - - /** - * Generate random double with a triangular distribution - * - * @param minimum Minimum - * @param maximum Maximum - * @param peak Peak - * - * @return Random double - */ - public static double triangularDistribution(double minimum, double maximum, double peak) { - double F = (peak - minimum) / (maximum - minimum); - double rand = Math.random(); - if (rand < F) { - return minimum + Math.sqrt(rand * (maximum - minimum) * (peak - minimum)); - } else { - return maximum - Math.sqrt((1 - rand) * (maximum - minimum) * (maximum - peak)); - } - } - - /** - * Get Log base 2 of a number - * - * @param N The number - * - * @return The result - */ - public static int log2(int N) { - return (int) (Math.log(N) / Math.log(2)); - } - - /** - * Format double to string - * - * @param toFormat The number to format - * - * @return Formatted - */ - public static String format(double toFormat) { - DecimalFormat df = new DecimalFormat("0.00"); - String formatted = df.format(toFormat); - - return formatted.endsWith("00") ? String.valueOf((int) toFormat) : formatted; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/StringUtils.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/StringUtils.java deleted file mode 100644 index e6814b5d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/StringUtils.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.willfp.ecoenchants.util; - -import com.willfp.ecoenchants.integrations.placeholder.PlaceholderManager; -import net.md_5.bungee.api.ChatColor; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.Nullable; - -import java.util.Collection; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -import static net.md_5.bungee.api.ChatColor.COLOR_CHAR; - -public class StringUtils { - /** - * Translate a string - converts Placeholders and Color codes - * - * @param message The message to translate - * @param player The player to translate placeholders with respect to - * - * @return The message, translated - */ - public static String translate(String message, @Nullable Player player) { - message = PlaceholderManager.translatePlaceholders(message, player); - message = translateHexColorCodes(message); - message = ChatColor.translateAlternateColorCodes('&', message); - return ChatColor.translateAlternateColorCodes('&', translateHexColorCodes(message)); - } - - /** - * Translate a string without respect to a player - * - * @param message The message to translate - * - * @return The message, translated - * - * @see StringUtils#translate(String, Player) - */ - public static String translate(String message) { - message = PlaceholderManager.translatePlaceholders(message, null); - message = translateHexColorCodes(message); - message = ChatColor.translateAlternateColorCodes('&', message); - return ChatColor.translateAlternateColorCodes('&', translateHexColorCodes(message)); - } - - private static String translateHexColorCodes(String message) { - Pattern hexPattern = Pattern.compile("&#" + "([A-Fa-f0-9]{6})" + ""); - Matcher matcher = hexPattern.matcher(message); - StringBuffer buffer = new StringBuffer(message.length() + 4 * 8); - while (matcher.find()) { - String group = matcher.group(1); - matcher.appendReplacement(buffer, COLOR_CHAR + "x" - + COLOR_CHAR + group.charAt(0) + COLOR_CHAR + group.charAt(1) - + COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3) - + COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)); - } - - return matcher.appendTail(buffer).toString(); - } - - /** - * Internal implementation of {@link String#valueOf} - * Formats collections and doubles better - * - * @param object The object to convert to string - * - * @return The object stringified - */ - public static String internalToString(@Nullable Object object) { - if (object == null) return "null"; - - if (object instanceof Integer) { - return ((Integer) object).toString(); - } else if (object instanceof String) { - return (String) object; - } else if (object instanceof Double) { - return NumberUtils.format((Double) object); - } else if (object instanceof Collection) { - Collection c = (Collection) object; - return c.stream().map(StringUtils::internalToString).collect(Collectors.joining(", ")); - } else return String.valueOf(object); - } - - /** - * Remove a string of characters from the start of a string - * - * @param s The string to remove the prefix from - * @param prefix The substring to remove - * - * @return The string with the prefix removed - */ - public static String removePrefix(String s, String prefix) { - if (s != null && prefix != null && s.startsWith(prefix)) { - return s.substring(prefix.length()); - } - return s; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/VectorUtils.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/VectorUtils.java deleted file mode 100644 index b863a77d..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/VectorUtils.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.willfp.ecoenchants.util; - -import org.bukkit.util.NumberConversions; -import org.bukkit.util.Vector; - -import java.util.ArrayList; - -public class VectorUtils { - /** - * If vector has all components as finite - * - * @param vector The vector to check - * - * @return If the vector is finite - */ - public static boolean isFinite(Vector vector) { - try { - NumberConversions.checkFinite(vector.getX(), "x not finite"); - NumberConversions.checkFinite(vector.getY(), "y not finite"); - NumberConversions.checkFinite(vector.getZ(), "z not finite"); - } catch (IllegalArgumentException e) { - return false; - } - - return true; - } - - /** - * Only keep largest part of normalised vector. - * For example: -0.8, 0.01, -0.2 would become -1, 0, 0 - * - * @param vec The vector to simplify - * - * @return The vector, simplified - */ - public static Vector simplifyVector(Vector vec) { - double x = Math.abs(vec.getX()); - double y = Math.abs(vec.getY()); - double z = Math.abs(vec.getZ()); - double max = Math.max(x, Math.max(y, z)); - if (x > 1 || z > 1) { - max = y; - } - if (max == x) { - if (vec.getX() < 0) { - return new Vector(-1, 0, 0); - } - return new Vector(1, 0, 0); - } else if (max == y) { - if (vec.getY() < 0) { - return new Vector(0, -1, 0); - } - return new Vector(0, 1, 0); - } else { - if (vec.getZ() < 0) { - return new Vector(0, 0, -1); - } - return new Vector(0, 0, 1); - } - } - - /** - * Get circle as relative vectors - * - * @param radius The radius - * - * @return An array of {@link Vector}s - */ - public static Vector[] getCircle(int radius) { - ArrayList circleVecs = new ArrayList<>(); - - int xoffset = -radius; - int zoffset = -radius; - - while (zoffset <= radius) { - while (xoffset <= radius) { - if (Math.round(Math.sqrt((xoffset * xoffset) + (zoffset * zoffset))) <= radius) { - circleVecs.add(new Vector(xoffset, 0, zoffset)); - } else { - xoffset++; - continue; - } - xoffset++; - } - xoffset = -radius; - zoffset++; - } - - return circleVecs.toArray(new Vector[0]); - } - - /** - * Get square as relative vectors - * - * @param radius The radius of the square - * - * @return An array of {@link Vector}s - */ - public static Vector[] getSquare(int radius) { - ArrayList circleVecs = new ArrayList<>(); - - int xoffset = -radius; - int zoffset = -radius; - - while (zoffset <= radius) { - while (xoffset <= radius) { - circleVecs.add(new Vector(xoffset, 0, zoffset)); - xoffset++; - } - xoffset = -radius; - zoffset++; - } - - return circleVecs.toArray(new Vector[0]); - } - - /** - * Get cube as relative vectors - * - * @param radius The radius of the cube - * - * @return An array of {@link Vector}s - */ - public static Vector[] getCube(int radius) { - ArrayList cubeVecs = new ArrayList<>(); - - int xoffset = -radius; - int zoffset = -radius; - int yoffset = -radius; - - while (yoffset <= radius) { - while (zoffset <= radius) { - while (xoffset <= radius) { - cubeVecs.add(new Vector(xoffset, yoffset, zoffset)); - xoffset++; - } - xoffset = -radius; - zoffset++; - } - zoffset = -radius; - yoffset++; - } - - return cubeVecs.toArray(new Vector[0]); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/Callable.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/Callable.java deleted file mode 100644 index fd53028f..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/Callable.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.willfp.ecoenchants.util.interfaces; - -/** - * Simple functional interface to run some code on demand - */ -@FunctionalInterface -public interface Callable { - void call(); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/EcoRunnable.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/EcoRunnable.java deleted file mode 100644 index ec3c8c25..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/EcoRunnable.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.willfp.ecoenchants.util.interfaces; - -/** - * Interface for Enchantments with tasks - */ -public interface EcoRunnable extends Runnable { - long getTime(); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/ObjectBiCallable.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/ObjectBiCallable.java deleted file mode 100644 index 6cc26a37..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/ObjectBiCallable.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.willfp.ecoenchants.util.interfaces; - -/** - * Functional Interface to return a value of a specified type given a certain parameter - * - * @param The type of object to return - * @param The type of object for the parameter - */ -@FunctionalInterface -public interface ObjectBiCallable { - A call(B object); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/ObjectCallable.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/ObjectCallable.java deleted file mode 100644 index c9d537b3..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/interfaces/ObjectCallable.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.ecoenchants.util.interfaces; - -/** - * Functional Interface to return a value of a given type - * - * @param The type to return - */ -@FunctionalInterface -public interface ObjectCallable { - A call(); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/ArrowListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/ArrowListeners.java deleted file mode 100644 index 16dec210..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/ArrowListeners.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.ecoenchants.util.internal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.ProjectileLaunchEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; - -import java.util.Map; - -public class ArrowListeners implements Listener { - @EventHandler(priority = EventPriority.LOWEST) - public void onLaunch(ProjectileLaunchEvent event) { - if (!(event.getEntity() instanceof Arrow)) - return; - if (!(event.getEntity().getShooter() instanceof LivingEntity)) - return; - - Arrow arrow = (Arrow) event.getEntity(); - LivingEntity entity = (LivingEntity) arrow.getShooter(); - - if (entity.getEquipment() == null) - return; - - ItemStack item = entity.getEquipment().getItemInMainHand(); - - if (item.getType().equals(Material.AIR)) return; - if (!item.hasItemMeta()) return; - if (item.getItemMeta() == null) return; - - Map enchantments = item.getItemMeta().getEnchants(); - arrow.setMetadata("enchantments", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), enchantments)); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/DropQueue.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/DropQueue.java deleted file mode 100644 index 74c0efd3..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/DropQueue.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.willfp.ecoenchants.util.internal; - -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.util.internal.drops.AbstractDropQueue; -import com.willfp.ecoenchants.util.internal.drops.FastCollatedDropQueue; -import com.willfp.ecoenchants.util.internal.drops.InternalDropQueue; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.Collection; - -/** - * All drops generated from enchantments should be sent through a {@link DropQueue} - * Interacts with {@link EcoEnchants#TELEKINESIS} - */ -public class DropQueue { - private final AbstractDropQueue handle; - - /** - * Create {@link DropQueue} linked to player - * - * @param player The player - */ - public DropQueue(Player player) { - handle = FastCollatedDropQueue.use() ? new FastCollatedDropQueue(player) : new InternalDropQueue(player); - } - - /** - * Add item to queue - * - * @param item The item to add - * - * @return The DropQueue - */ - public DropQueue addItem(ItemStack item) { - handle.addItem(item); - return this; - } - - /** - * Add multiple items to queue - * - * @param itemStacks The items to add - * - * @return The DropQueue - */ - public DropQueue addItems(Collection itemStacks) { - handle.addItems(itemStacks); - return this; - } - - /** - * Add xp to queue - * - * @param amount The amount to add - * - * @return The DropQueue - */ - public DropQueue addXP(int amount) { - handle.addXP(amount); - return this; - } - - /** - * Set location of the origin of the drops - * - * @param l The location - * - * @return The DropQueue - */ - public DropQueue setLocation(Location l) { - handle.setLocation(l); - return this; - } - - /** - * Force the queue to act as if player has {@link EcoEnchants#TELEKINESIS} - * - * @return The DropQueue - */ - public DropQueue forceTelekinesis() { - handle.forceTelekinesis(); - return this; - } - - /** - * Set the queue to test specific item for {@link EcoEnchants#TELEKINESIS} - * Default item is the player's held item, however for this is required for Tridents. - * - * @param item The item to test - * - * @return The DropQueue - */ - public DropQueue setItem(ItemStack item) { - handle.setItem(item); - return this; - } - - /** - * Push the queue - */ - public void push() { - handle.push(); - } - - static { - FastCollatedDropQueue.update(); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/Loader.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/Loader.java deleted file mode 100644 index 30a9b584..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/Loader.java +++ /dev/null @@ -1,405 +0,0 @@ -package com.willfp.ecoenchants.util.internal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -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.tabcompleters.TabCompleterEnchantinfo; -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.display.EnchantDisplay; -import com.willfp.ecoenchants.display.EnchantmentCache; -import com.willfp.ecoenchants.display.packets.PacketChat; -import com.willfp.ecoenchants.display.packets.PacketOpenWindowMerchant; -import com.willfp.ecoenchants.display.packets.PacketSetCreativeSlot; -import com.willfp.ecoenchants.display.packets.PacketSetSlot; -import com.willfp.ecoenchants.display.packets.PacketWindowItems; -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.EnchantmentTarget; -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.WatcherTriggers; -import com.willfp.ecoenchants.events.armorequip.ArmorListener; -import com.willfp.ecoenchants.events.armorequip.DispenserArmorListener; -import com.willfp.ecoenchants.events.entitydeathbyentity.EntityDeathByEntityListeners; -import com.willfp.ecoenchants.events.naturalexpgainevent.NaturalExpGainListeners; -import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; -import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatAAC; -import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatMatrix; -import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatNCP; -import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatSpartan; -import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefFactionsUUID; -import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefGriefPrevention; -import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefKingdoms; -import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefLands; -import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefTowny; -import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefWorldGuard; -import com.willfp.ecoenchants.integrations.essentials.EssentialsManager; -import com.willfp.ecoenchants.integrations.essentials.plugins.IntegrationEssentials; -import com.willfp.ecoenchants.integrations.mcmmo.McmmoManager; -import com.willfp.ecoenchants.integrations.mcmmo.plugins.McmmoIntegrationImpl; -import com.willfp.ecoenchants.integrations.placeholder.PlaceholderManager; -import com.willfp.ecoenchants.integrations.placeholder.plugins.PlaceholderIntegrationPAPI; -import com.willfp.ecoenchants.integrations.worldguard.WorldguardManager; -import com.willfp.ecoenchants.integrations.worldguard.plugins.WorldguardIntegrationImpl; -import com.willfp.ecoenchants.util.interfaces.Callable; -import com.willfp.ecoenchants.util.interfaces.EcoRunnable; -import com.willfp.ecoenchants.util.internal.drops.FastCollatedDropQueue; -import com.willfp.ecoenchants.util.internal.drops.InternalDropQueue; -import com.willfp.ecoenchants.util.internal.updater.PlayerJoinListener; -import com.willfp.ecoenchants.util.internal.updater.UpdateChecker; -import com.willfp.ecoenchants.util.optional.Prerequisite; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.bstats.bukkit.Metrics; -import org.bukkit.Bukkit; -import org.bukkit.event.HandlerList; -import org.bukkit.generator.BlockPopulator; -import org.bukkit.plugin.Plugin; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * Class containing methods for the loading and unloading of EcoEnchants - */ -public class Loader { - - /** - * Called by {@link EcoEnchantsPlugin#onEnable()} - */ - public static void load() { - Logger.info("=========================================="); - Logger.info(""); - Logger.info("Loading &aEcoEnchants"); - Logger.info("Made by &aAuxilor&f - willfp.com"); - Logger.info(""); - Logger.info("=========================================="); - - /* - Load Configs - */ - - Logger.info("Loading Configs..."); - ConfigManager.updateConfigs(); - Logger.info(""); - - /* - Load ProtocolLib - */ - - Logger.info("Loading ProtocolLib..."); - if (ConfigManager.getConfig().getBool("villager.enabled")) { - new PacketOpenWindowMerchant().register(); - } - new PacketSetCreativeSlot().register(); - new PacketSetSlot().register(); - new PacketWindowItems().register(); - - Logger.info(""); - - /* - Register Events - */ - - Logger.info("Registering Events..."); - Bukkit.getPluginManager().registerEvents(new ArmorListener(), EcoEnchantsPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new DispenserArmorListener(), EcoEnchantsPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(), EcoEnchantsPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new EnchantingListeners(), EcoEnchantsPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new GrindstoneListeners(), EcoEnchantsPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new AnvilListeners(), EcoEnchantsPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new EntityDeathByEntityListeners(), EcoEnchantsPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new NaturalExpGainListeners(), EcoEnchantsPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new VillagerListeners(), EcoEnchantsPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new ArrowListeners(), EcoEnchantsPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new WatcherTriggers(), EcoEnchantsPlugin.getInstance()); - Logger.info(""); - - /* - Load integrations - */ - - Logger.info("Loading Integrations..."); - - final HashMap integrations = new HashMap() {{ - // AntiGrief - put("WorldGuard", () -> { - AntigriefManager.register(new AntigriefWorldGuard()); - WorldguardManager.register(new WorldguardIntegrationImpl()); - }); - put("GriefPrevention", () -> AntigriefManager.register(new AntigriefGriefPrevention())); - put("FactionsUUID", () -> AntigriefManager.register(new AntigriefFactionsUUID())); - put("Towny", () -> AntigriefManager.register(new AntigriefTowny())); - put("Lands", () -> AntigriefManager.register(new AntigriefLands())); - put("Kingdoms", () -> AntigriefManager.register(new AntigriefKingdoms())); - - // AntiCheat - put("AAC", () -> AnticheatManager.register(new AnticheatAAC())); - put("Matrix", () -> AnticheatManager.register(new AnticheatMatrix())); - put("NoCheatPlus", () -> AnticheatManager.register(new AnticheatNCP())); - put("Spartan", () -> AnticheatManager.register(new AnticheatSpartan())); - - // MISC - put("Essentials", () -> EssentialsManager.register(new IntegrationEssentials())); - put("PlaceholderAPI", () -> PlaceholderManager.addIntegration(new PlaceholderIntegrationPAPI())); - put("mcMMO", () -> McmmoManager.registerIntegration(new McmmoIntegrationImpl())); - }}; - - Set enabledPlugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toSet()); - - integrations.forEach(((s, callable) -> { - StringBuilder log = new StringBuilder(); - log.append(s).append(": "); - if (enabledPlugins.contains(s)) { - callable.call(); - log.append("&aENABLED"); - } else { - log.append("&9DISABLED"); - } - Logger.info(log.toString()); - })); - - Prerequisite.update(); - Logger.info(""); - - /* - Create enchantment config files (for first time use) - */ - - Logger.info("Creating Enchantment Configs..."); - ConfigManager.updateEnchantmentConfigs(); - Logger.info(""); - - /* - Load all enchantments, rarities, and targets - */ - - Logger.info("Adding Enchantments to API..."); - EnchantmentRarity.update(); - EnchantmentTarget.update(); - if (EnchantmentRarity.values().size() == 0 || EnchantmentTarget.values().size() == 0) { - Logger.error("&cError loading rarities or targets! Aborting..."); - Bukkit.getPluginManager().disablePlugin(EcoEnchantsPlugin.getInstance()); - return; - } else { - Logger.info(EnchantmentRarity.values().size() + " Rarities Loaded:"); - EnchantmentRarity.values().forEach((rarity -> { - Logger.info("- " + rarity.getName() + ": Table Probability=" + rarity.getProbability() + ", Minimum Level=" + rarity.getMinimumLevel() + ", Villager Probability=" + rarity.getVillagerProbability() + ", Loot Probability=" + rarity.getLootProbability() + ", Has Custom Color=" + rarity.hasCustomColor()); - })); - - Logger.info(""); - - Logger.info(EnchantmentTarget.values().size() + " Targets Loaded:"); - EnchantmentTarget.values().forEach((target) -> { - Logger.info("- " + target.getName() + ": Materials=" + target.getMaterials().toString()); - }); - } - Logger.info(""); - - /* - Load Extensions - */ - - Logger.info("Loading Extensions..."); - - EcoEnchantsPlugin.getInstance().getExtensionLoader().loadExtensions(); - - if (EcoEnchantsPlugin.getInstance().getExtensionLoader().getLoadedExtensions().isEmpty()) { - Logger.info("&cNo extensions found"); - } else { - Logger.info("Extensions Loaded:"); - EcoEnchantsPlugin.getInstance().getExtensionLoader().getLoadedExtensions().forEach((extension) -> { - Logger.info("- " + extension.getName() + " v" + extension.getVersion()); - }); - } - Logger.info(""); - - if (EcoEnchants.getAll().size() == 0) { - Logger.error("&cError adding enchantments! Aborting..."); - Bukkit.getPluginManager().disablePlugin(EcoEnchantsPlugin.getInstance()); - return; - } else { - Logger.info(EcoEnchants.getAll().size() + " Enchantments Loaded:"); - Logger.info(EcoEnchants.getAll().stream().map(ecoEnchant -> ecoEnchant.getType().getColor() + ecoEnchant.getName()).collect(Collectors.joining(", "))); - } - Logger.info(""); - - /* - Load enchantment configs - */ - - Logger.info("Loading Enchantment Configs..."); - ConfigManager.updateEnchantmentConfigs(); - Logger.info(""); - - /* - Register Enchantments - */ - - Logger.info("Registering Enchantments..."); - EcoEnchants.update(); - EnchantDisplay.update(); - Logger.info(""); - - /* - Register Enchantment Listeners - */ - - Logger.info("Registering Enchantment Listeners..."); - EcoEnchants.getAll().forEach((ecoEnchant -> { - if (ecoEnchant.isEnabled()) { - Bukkit.getPluginManager().registerEvents(ecoEnchant, EcoEnchantsPlugin.getInstance()); - } - })); - Logger.info(""); - - /* - Register Enchantment Tasks - */ - - Logger.info("Registering Enchantment Tasks..."); - EcoEnchants.getAll().forEach((ecoEnchant -> { - if (ecoEnchant instanceof EcoRunnable) { - Bukkit.getScheduler().scheduleSyncRepeatingTask(EcoEnchantsPlugin.getInstance(), (Runnable) ecoEnchant, 5, ((EcoRunnable) ecoEnchant).getTime()); - } - })); - Logger.info(""); - - - /* - Load Commands - */ - - Logger.info("Loading Commands..."); - new CommandEcoreload().register(); - new CommandEcodebug().register(); - new CommandEnchantinfo().register(); - Logger.info(""); - - /* - Start bStats - */ - - Logger.info("Hooking into bStats..."); - new Metrics(EcoEnchantsPlugin.getInstance(), 7666); - Logger.info(""); - - /* - Finish - */ - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), Loader::postLoad, 1); - } - - /** - * Called after server is loaded - */ - public static void postLoad() { - Logger.info("Adding block populators..."); - - Bukkit.getServer().getWorlds().forEach((world -> { - world.getPopulators().add(new LootPopulator()); - })); - - Logger.info(""); - - new UpdateChecker(EcoEnchantsPlugin.getInstance(), 79573).getVersion((version) -> { - DefaultArtifactVersion currentVersion = new DefaultArtifactVersion(EcoEnchantsPlugin.getInstance().getDescription().getVersion()); - DefaultArtifactVersion mostRecentVersion = new DefaultArtifactVersion(version); - if (!(currentVersion.compareTo(mostRecentVersion) > 0 || currentVersion.equals(mostRecentVersion))) { - UpdateChecker.setOutdated(true); - UpdateChecker.setNewVersion(version); - Bukkit.getScheduler().runTaskTimer(EcoEnchantsPlugin.getInstance(), () -> { - Logger.info("&cEcoEnchants is out of date! (Version " + EcoEnchantsPlugin.getInstance().getDescription().getVersion() + ")"); - Logger.info("&cThe newest version is &f" + version); - Logger.info("&cDownload the new version here:&f https://www.spigotmc.org/resources/ecoenchants.79573/"); - }, 0, 864000); - } - }); - - /* - Check for paper - */ - - if (!Prerequisite.HasPaper.isMet()) { - Logger.error(""); - Logger.error("----------------------------"); - Logger.error(""); - Logger.error("You don't seem to be running paper!"); - Logger.error("Paper is strongly recommended for all servers,"); - Logger.error("and some enchantments may not function properly without it"); - Logger.error("Download Paper from &fhttps://papermc.io"); - Logger.error(""); - Logger.error("----------------------------"); - Logger.error(""); - } - - Logger.info(""); - - Logger.info("Updating cache..."); - new PacketChat().register(); - EcoEnchants.getAll().forEach(EcoEnchant::update); - EnchantmentCache.update(); - EssentialsManager.registerEnchantments(); - - Logger.info("Loaded &aEcoEnchants!"); - } - - /** - * Called by {@link EcoEnchantsPlugin#onDisable()} - */ - public static void unload() { - Logger.info("&cDisabling EcoEnchants..."); - Logger.info("Removing Block Populators..."); - Bukkit.getServer().getWorlds().forEach((world -> { - List populators = new ArrayList<>(world.getPopulators()); - populators.forEach((blockPopulator -> { - if (blockPopulator instanceof LootPopulator) { - world.getPopulators().remove(blockPopulator); - } - })); - })); - Logger.info(""); - Logger.info("&cUnloading Extensions..."); - EcoEnchantsPlugin.getInstance().getExtensionLoader().unloadExtensions(); - Logger.info("&fBye! :)"); - } - - /** - * Called by /ecoreload - */ - public static void reload() { - ConfigManager.updateConfigs(); - EnchantmentRarity.update(); - EnchantmentTarget.update(); - EcoEnchants.update(); - InternalDropQueue.update(); - EnchantDisplay.update(); - TabCompleterEnchantinfo.reload(); - FastCollatedDropQueue.update(); - EcoEnchant.EnchantmentType.update(); - - Bukkit.getScheduler().cancelTasks(EcoEnchantsPlugin.getInstance()); - - EcoEnchants.getAll().forEach((ecoEnchant -> { - HandlerList.unregisterAll(ecoEnchant); - - Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> { - if (ecoEnchant.isEnabled()) { - Bukkit.getPluginManager().registerEvents(ecoEnchant, EcoEnchantsPlugin.getInstance()); - } - }, 1); - })); - - Bukkit.getScheduler().runTaskTimer(EcoEnchantsPlugin.getInstance(), FastCollatedDropQueue.RUNNABLE, 0, 1); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/Logger.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/Logger.java deleted file mode 100644 index 0d67b184..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/Logger.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.willfp.ecoenchants.util.internal; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.util.StringUtils; - -/** - * The internal logger for EcoEnchants - * Automatically formats all inputs using {@link StringUtils#translate(String)} - */ -public class Logger { - private static final EcoEnchantsPlugin INSTANCE = EcoEnchantsPlugin.getInstance(); - - /** - * Print an info (neutral) message to console - * - * @param message The message to send - */ - public static void info(String message) { - INSTANCE.getLogger().info(StringUtils.translate(message)); - } - - /** - * Print a warning to console - * - * @param message The warning - */ - public static void warn(String message) { - INSTANCE.getLogger().warning(StringUtils.translate(message)); - } - - /** - * Print an error to console - * - * @param message The error - */ - public static void error(String message) { - INSTANCE.getLogger().severe(StringUtils.translate(message)); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/AbstractDropQueue.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/AbstractDropQueue.java deleted file mode 100644 index 3a39e83b..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/AbstractDropQueue.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.willfp.ecoenchants.util.internal.drops; - -import org.bukkit.Location; -import org.bukkit.inventory.ItemStack; - -import java.util.Collection; - -public interface AbstractDropQueue { - /** - * Add item to queue - * - * @param item The item to add - * - * @return The DropQueue - */ - AbstractDropQueue addItem(ItemStack item); - - /** - * Add multiple items to queue - * - * @param itemStacks The items to add - * - * @return The DropQueue - */ - AbstractDropQueue addItems(Collection itemStacks); - - /** - * Add xp to queue - * - * @param amount The amount to add - * - * @return The DropQueue - */ - AbstractDropQueue addXP(int amount); - - /** - * Set location of the origin of the drops - * - * @param l The location - * - * @return The DropQueue - */ - AbstractDropQueue setLocation(Location l); - - /** - * Force the queue to act as if player has {@link com.willfp.ecoenchants.enchantments.EcoEnchants#TELEKINESIS} - * - * @return The DropQueue - */ - AbstractDropQueue forceTelekinesis(); - - /** - * Set the queue to test specific item for {@link com.willfp.ecoenchants.enchantments.EcoEnchants#TELEKINESIS} - * Default item is the player's held item, however for this is required for Tridents. - * - * @param item The item to test - * - * @return The DropQueue - */ - AbstractDropQueue setItem(ItemStack item); - - /** - * Push the queue - */ - void push(); -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/FastCollatedDropQueue.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/FastCollatedDropQueue.java deleted file mode 100644 index 5e900ac0..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/FastCollatedDropQueue.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.willfp.ecoenchants.util.internal.drops; - -import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.config.ConfigManager; -import com.willfp.ecoenchants.util.internal.DropQueue; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Backend implementation of {@link AbstractDropQueue} - * {@link this#push()} adds to a map that creates a new {@link InternalDropQueue} at the end of every tick - * - * The drops are not instantly pushed when called, instead the map is iterated over at the end of every tick. This massively improves performance. - */ -public class FastCollatedDropQueue extends InternalDropQueue { - private static boolean collate = false; - private static final HashMap COLLATED_MAP = new HashMap<>(); - public static final Runnable RUNNABLE = new BukkitRunnable() { - @Override - public void run() { - for (Map.Entry entry : COLLATED_MAP.entrySet()) { - new InternalDropQueue(entry.getKey()) - .setLocation(entry.getValue().getLocation()) - .addItems(entry.getValue().getDrops()) - .addXP(entry.getValue().getXp()) - .push(); - } - COLLATED_MAP.clear(); - } - }; - - /** - * Create {@link DropQueue} linked to player - * - * @param player The player - */ - public FastCollatedDropQueue(Player player) { - super(player); - } - - @Override - public void push() { - CollatedDrops fetched = COLLATED_MAP.get(player); - CollatedDrops collatedDrops = fetched == null ? new CollatedDrops(items, loc, xp) : fetched.addDrops(items).setLocation(loc).addXp(xp); - COLLATED_MAP.put(player, collatedDrops); - } - - public static boolean use() { - return collate; - } - - public static void update() { - collate = ConfigManager.getConfig().getBool( "drops.collate"); - } - - static { - Bukkit.getScheduler().runTaskTimer(EcoEnchantsPlugin.getInstance(), RUNNABLE, 0, 1); - update(); - } - - private static class CollatedDrops { - private final List drops; - private Location location; - private int xp; - - private CollatedDrops(List drops, Location location, int xp) { - this.drops = drops; - this.location = location; - this.xp = xp; - } - - public List getDrops() { - return drops; - } - - public Location getLocation() { - return location; - } - - public int getXp() { - return xp; - } - - public CollatedDrops addDrops(List toAdd) { - drops.addAll(toAdd); - return this; - } - - public CollatedDrops setLocation(Location loc) { - this.location = loc; - return this; - } - - public CollatedDrops addXp(int xp) { - this.xp += xp; - return this; - } - - @Override - public String toString() { - return "CollatedDrops{" + - "drops=" + drops + - ", location=" + location + - ", xp=" + xp + - '}'; - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/InternalDropQueue.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/InternalDropQueue.java deleted file mode 100644 index 3a76ace1..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/InternalDropQueue.java +++ /dev/null @@ -1,169 +0,0 @@ -package com.willfp.ecoenchants.util.internal.drops; - -import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.NumberUtils; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.SoundCategory; -import org.bukkit.World; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.ExperienceOrb; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerExpChangeEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; - -public class InternalDropQueue implements AbstractDropQueue { - protected final List items; - protected int xp; - protected final Player player; - protected Location loc; - protected boolean hasTelekinesis = false; - protected ItemStack item; - - private static boolean useOrb; - - /** - * Create {@link com.willfp.ecoenchants.util.internal.drops.InternalDropQueue} linked to player - * - * @param player The player - */ - public InternalDropQueue(Player player) { - this.items = new ArrayList<>(); - this.xp = 0; - this.player = player; - this.loc = player.getLocation(); - this.item = player.getInventory().getItemInMainHand(); - } - - /** - * Add item to queue - * - * @param item The item to add - * - * @return The DropQueue - */ - @Override - public AbstractDropQueue addItem(ItemStack item) { - this.items.add(item); - return this; - } - - /** - * Add multiple items to queue - * - * @param itemStacks The items to add - * - * @return The DropQueue - */ - @Override - public AbstractDropQueue addItems(Collection itemStacks) { - this.items.addAll(itemStacks); - return this; - } - - /** - * Add xp to queue - * - * @param amount The amount to add - * - * @return The DropQueue - */ - @Override - public AbstractDropQueue addXP(int amount) { - this.xp += amount; - return this; - } - - /** - * Set location of the origin of the drops - * - * @param l The location - * - * @return The DropQueue - */ - @Override - public AbstractDropQueue setLocation(Location l) { - this.loc = l; - return this; - } - - /** - * Force the queue to act as if player has {@link EcoEnchants#TELEKINESIS} - * - * @return The DropQueue - */ - @Override - public AbstractDropQueue forceTelekinesis() { - this.hasTelekinesis = true; - return this; - } - - /** - * Set the queue to test specific item for {@link EcoEnchants#TELEKINESIS} - * Default item is the player's held item, however for this is required for Tridents. - * - * @param item The item to test - * - * @return The DropQueue - */ - @Override - public AbstractDropQueue setItem(ItemStack item) { - this.item = item; - return this; - } - - /** - * Push the queue - */ - public void push() { - if(!hasTelekinesis) hasTelekinesis = EnchantChecks.item(item, EcoEnchants.TELEKINESIS); - if(hasTelekinesis && !EcoEnchants.TELEKINESIS.isEnabled()) hasTelekinesis = false; - - World world = loc.getWorld(); - assert world != null; - loc = loc.add(0.5, 0.5, 0.5); - - if(hasTelekinesis) { - HashMap leftover = player.getInventory().addItem(items.toArray(new ItemStack[0])); - for(ItemStack drop : leftover.values()) { - world.dropItem(loc, drop).setVelocity(new Vector()); - } - if (xp > 0) { - PlayerExpChangeEvent event = new PlayerExpChangeEvent(player, xp); - Bukkit.getPluginManager().callEvent(event); - if (useOrb) { - ExperienceOrb orb = (ExperienceOrb) world.spawnEntity(player.getLocation().add(0, 0.2, 0), EntityType.EXPERIENCE_ORB); - orb.setVelocity(new Vector(0, 0, 0)); - orb.setExperience(event.getAmount()); - } else { - player.giveExp(event.getAmount()); - player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.AMBIENT, 1f, (float) NumberUtils.randFloat(0.7, 1.2)); - } - } - } else { - for (ItemStack drop : items) { - world.dropItem(loc, drop).setVelocity(new Vector()); - } - if (xp > 0) { - ExperienceOrb orb = (ExperienceOrb) world.spawnEntity(loc, EntityType.EXPERIENCE_ORB); - orb.setExperience(xp); - } - } - } - - public static void update() { - useOrb = EcoEnchants.TELEKINESIS.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "use-orb"); - } - - static { - update(); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/optional/Prerequisite.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/optional/Prerequisite.java deleted file mode 100644 index ef7a2203..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/optional/Prerequisite.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.willfp.ecoenchants.util.optional; - -import com.willfp.ecoenchants.util.ClassUtils; -import com.willfp.ecoenchants.util.interfaces.ObjectCallable; -import org.bukkit.Bukkit; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * An object representing a condition that must be met in order to perform an action - */ -public class Prerequisite { - private static final List values = new ArrayList<>(); - - /** - * Requires the server to be running minecraft version 1.16 or higher - */ - public static final Prerequisite MinVer1_16 = new Prerequisite( - () -> !Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].contains("15"), - "Requires minimum server version of 1.16" - ); - - /** - * Requires the server to be running an implementation of paper - */ - public static final Prerequisite HasPaper = new Prerequisite( - () -> ClassUtils.exists("com.destroystokyo.paper.event.player.PlayerElytraBoostEvent"), - "Requires server to be running paper (or a fork)" - ); - - private boolean isMet; - private final ObjectCallable isMetCallable; - private final String description; - - /** - * Create a prerequisite - * - * @param isMetCallable An {@link ObjectCallable} that returns if the prerequisite is met - * @param description The description of the prerequisite, shown to the user if it isn't - */ - public Prerequisite(ObjectCallable isMetCallable, String description) { - this.isMetCallable = isMetCallable; - this.isMet = isMetCallable.call(); - this.description = description; - values.add(this); - } - - /** - * Get the description of the prerequisite - * - * @return The description - */ - public String getDescription() { - return description; - } - - /** - * Get if the prerequisite has been met - * - * @return If the prerequisite is met - */ - public boolean isMet() { - return isMet; - } - - private void refresh() { - this.isMet = this.isMetCallable.call(); - } - - /** - * Update all prerequisites' {@link Prerequisite#isMet} - */ - public static void update() { - values.forEach(Prerequisite::refresh); - } - - /** - * Check if all prerequisites in array are met - * - * @param prerequisites A primitive array of prerequisites to check - * - * @return If all the prerequisites are met - */ - public static boolean areMet(Prerequisite[] prerequisites) { - update(); - return Arrays.stream(prerequisites).allMatch(Prerequisite::isMet); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/tuplets/Pair.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/tuplets/Pair.java deleted file mode 100644 index 39c9f448..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/tuplets/Pair.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.willfp.ecoenchants.util.tuplets; - -/** - * Spigot doesn't include javafx - */ -public class Pair { - private A first; - private B second; - - /** - * Create a pair - * - * @param first The first item in the tuplet - * @param second The second item in the tuplet - */ - public Pair(A first, B second) { - this.first = first; - this.second = second; - } - - /** - * Get the first item in the tuplet - * - * @return The first item - */ - public A getFirst() { - return first; - } - - /** - * Get the second item in the tuplet - * - * @return The second item - */ - public B getSecond() { - return second; - } - - /** - * Set the first item in the tuplet - * - * @param first The value to set the first item to - */ - public void setFirst(A first) { - this.first = first; - } - - /** - * Set the second item in the tuplet - * - * @param second The value to set the second item to - */ - public void setSecond(B second) { - this.second = second; - } - - @Override - public String toString() { - return "Pair{" + - "first=" + first + - ", second=" + second + - '}'; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/tuplets/Triplet.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/tuplets/Triplet.java deleted file mode 100644 index 1a80f94e..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/tuplets/Triplet.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.willfp.ecoenchants.util.tuplets; - -/** - * Spigot doesn't include javafx - */ -public class Triplet { - private A first; - private B second; - private C third; - - /** - * Create a triplet - * - * @param first The first item in the tuplet - * @param second The second item in the tuplet - * @param third The third item in the tuplet - */ - public Triplet(A first, B second, C third) { - this.first = first; - this.second = second; - this.third = third; - } - - /** - * Get the first item in the tuplet - * - * @return The first item - */ - public A getFirst() { - return first; - } - - /** - * Get the second item in the tuplet - * - * @return The second item - */ - public B getSecond() { - return second; - } - - /** - * Get the third item in the tuplet - * - * @return The third item - */ - public C getThird() { - return third; - } - - /** - * Set the first item in the tuplet - * - * @param first The value to set - */ - public void setFirst(A first) { - this.first = first; - } - - /** - * Set the second item in the tuplet - * - * @param second The value to set - */ - public void setSecond(B second) { - this.second = second; - } - - /** - * Set the third item in the tuplet - * - * @param third The value to set - */ - public void setThird(C third) { - this.third = third; - } - - @Override - public String toString() { - return "Triplet{" + - "first=" + first + - ", second=" + second + - ", third=" + third + - '}'; - } -} 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 index 2470777a..5e9d55f0 100644 --- 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 @@ -29,7 +29,7 @@ import java.util.Arrays; import java.util.List; public class EcoEnchantsPlugin extends AbstractEcoPlugin { - protected EcoEnchantsPlugin() { + public EcoEnchantsPlugin() { super("EcoEnchants", 79573, 7666); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java index 4222d868..bb1686e9 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java @@ -1,6 +1,8 @@ package com.willfp.ecoenchants.config; -import com.willfp.ecoenchants.config.configs.*; +import com.willfp.ecoenchants.config.configs.EnchantmentConfig; +import com.willfp.ecoenchants.config.configs.Rarity; +import com.willfp.ecoenchants.config.configs.Target; import java.util.HashSet; import java.util.Set; diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java index b066a18c..a3c963f1 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java @@ -5,7 +5,13 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; import java.nio.charset.StandardCharsets; /** 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 index a1dd4b3b..fad4ca54 100644 --- 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 @@ -1,6 +1,6 @@ package com.willfp.ecoenchants.display; -import com.willfp.ecoenchants.config.ConfigManager; +import com.willfp.eco.util.config.Configs; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity; @@ -45,14 +45,14 @@ public class EnchantmentCache { } else { description = Arrays.asList( WordUtils.wrap( - String.valueOf(ConfigManager.getLang().getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".description")), - ConfigManager.getConfig().getInt("lore.describe.wrap"), + String.valueOf(Configs.LANG.getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".description")), + Configs.CONFIG.getInt("lore.describe.wrap"), "\n", false ).split("\\r?\\n") ); - name = String.valueOf(ConfigManager.getLang().getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".name")); + name = String.valueOf(Configs.LANG.getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".name")); type = enchantment.isCursed() ? EcoEnchant.EnchantmentType.CURSE : EcoEnchant.EnchantmentType.NORMAL; - rarity = enchantment.isTreasure() ? EnchantmentRarity.getByName(ConfigManager.getConfig().getString("rarity.vanilla-treasure-rarity")) : EnchantmentRarity.getByName(ConfigManager.getConfig().getString("rarity.vanilla-rarity")); + rarity = enchantment.isTreasure() ? EnchantmentRarity.getByName(Configs.CONFIG.getString("rarity.vanilla-treasure-rarity")) : EnchantmentRarity.getByName(Configs.CONFIG.getString("rarity.vanilla-rarity")); } color = type.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 index bad29b4e..2146df5b 100644 --- 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 @@ -1,7 +1,7 @@ package com.willfp.ecoenchants.display.options; import com.willfp.eco.util.StringUtils; -import com.willfp.ecoenchants.config.ConfigManager; +import com.willfp.eco.util.config.Configs; import com.willfp.ecoenchants.display.options.interfaces.ThresholdedOption; import com.willfp.ecoenchants.display.options.interfaces.ToggleableOption; import com.willfp.ecoenchants.display.options.interfaces.UpdateableOption; @@ -23,9 +23,9 @@ public class DescriptionOptions implements ThresholdedOption, ToggleableOption, @Override public void update() { - threshold = ConfigManager.getConfig().getInt("lore.describe.before-lines"); - enabled = ConfigManager.getConfig().getBool("lore.describe.enabled"); - color = StringUtils.translate(ConfigManager.getLang().getString("description-color")); + threshold = Configs.CONFIG.getInt("lore.describe.before-lines"); + enabled = Configs.CONFIG.getBool("lore.describe.enabled"); + color = StringUtils.translate(Configs.LANG.getString("description-color")); } public String getColor() { 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 index 760dc0e4..97b55973 100644 --- 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 @@ -1,6 +1,6 @@ package com.willfp.ecoenchants.display.options; -import com.willfp.ecoenchants.config.ConfigManager; +import com.willfp.eco.util.config.Configs; import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter; import com.willfp.ecoenchants.display.options.sorting.SortParameters; import com.willfp.ecoenchants.display.options.sorting.SorterManager; @@ -76,22 +76,22 @@ public class DisplayOptions { shrinkOptions.update(); sortedTypes.clear(); - sortedTypes.addAll(ConfigManager.getConfig().getStrings("lore.type-ordering").stream() + sortedTypes.addAll(Configs.CONFIG.getStrings("lore.type-ordering").stream() .map(typeName -> EcoEnchant.EnchantmentType.values().stream().filter(type -> type.getName().equalsIgnoreCase(typeName)).findFirst().orElse(null)) .filter(Objects::nonNull) .collect(Collectors.toList())); sortedTypes.addAll(EcoEnchant.EnchantmentType.values().stream().filter(enchantmentType -> !sortedTypes.contains(enchantmentType)).collect(Collectors.toList())); sortedRarities.clear(); - sortedRarities.addAll(ConfigManager.getConfig().getStrings("lore.rarity-ordering").stream() + sortedRarities.addAll(Configs.CONFIG.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())); - boolean byType = ConfigManager.getConfig().getBool("lore.sort-by-type"); - boolean byLength = ConfigManager.getConfig().getBool("lore.sort-by-length"); - boolean byRarity = ConfigManager.getConfig().getBool("lore.sort-by-rarity"); + boolean byType = Configs.CONFIG.getBool("lore.sort-by-type"); + boolean byLength = Configs.CONFIG.getBool("lore.sort-by-length"); + boolean byRarity = Configs.CONFIG.getBool("lore.sort-by-rarity"); Set params = new HashSet<>(); if(byType) params.add(SortParameters.TYPE); if(byLength) params.add(SortParameters.LENGTH); 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 index c1f6fe2b..d65853a3 100644 --- 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 @@ -1,6 +1,6 @@ package com.willfp.ecoenchants.display.options; -import com.willfp.ecoenchants.config.ConfigManager; +import com.willfp.eco.util.config.Configs; import com.willfp.ecoenchants.display.options.interfaces.ThresholdedOption; import com.willfp.ecoenchants.display.options.interfaces.UpdateableOption; @@ -15,8 +15,8 @@ public class NumbersOptions implements ThresholdedOption, UpdateableOption { @Override public void update() { - useNumerals = ConfigManager.getConfig().getBool("lore.use-numerals"); - threshold = ConfigManager.getConfig().getInt("lore.use-numbers-above-threshold"); + useNumerals = Configs.CONFIG.getBool("lore.use-numerals"); + threshold = Configs.CONFIG.getInt("lore.use-numbers-above-threshold"); } public boolean useNumerals() { 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 index 1b0aa40b..1bb77cef 100644 --- 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 @@ -1,6 +1,6 @@ package com.willfp.ecoenchants.display.options; -import com.willfp.ecoenchants.config.ConfigManager; +import com.willfp.eco.util.config.Configs; import com.willfp.ecoenchants.display.options.interfaces.ThresholdedOption; import com.willfp.ecoenchants.display.options.interfaces.ToggleableOption; import com.willfp.ecoenchants.display.options.interfaces.UpdateableOption; @@ -22,9 +22,9 @@ public class ShrinkOptions implements ThresholdedOption, ToggleableOption, Updat @Override public void update() { - threshold = ConfigManager.getConfig().getInt("lore.shrink.after-lines"); - enabled = ConfigManager.getConfig().getBool("lore.shrink.enabled"); - shrinkPerLine = ConfigManager.getConfig().getInt("lore.shrink.maximum-per-line"); + threshold = Configs.CONFIG.getInt("lore.shrink.after-lines"); + enabled = Configs.CONFIG.getBool("lore.shrink.enabled"); + shrinkPerLine = Configs.CONFIG.getInt("lore.shrink.maximum-per-line"); } public int getShrinkPerLine() { 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 index f43ab2f4..e68be00e 100644 --- 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 @@ -2,6 +2,7 @@ package com.willfp.ecoenchants.enchantments; import com.willfp.eco.util.StringUtils; +import com.willfp.eco.util.config.Configs; import com.willfp.eco.util.interfaces.Registerable; import com.willfp.eco.util.lambda.ObjectCallable; import com.willfp.eco.util.optional.Prerequisite; @@ -218,7 +219,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist * @return The description */ public List getDescription() { - return Arrays.asList(WordUtils.wrap(description, ConfigManager.getConfig().getInt("lore.describe.wrap"), "\n", false).split("\\r?\\n")); + return Arrays.asList(WordUtils.wrap(description, Configs.CONFIG.getInt("lore.describe.wrap"), "\n", false).split("\\r?\\n")); } /** @@ -420,11 +421,11 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist public static class EnchantmentType { private static final List values = new ArrayList<>(); - public static final EnchantmentType NORMAL = new EnchantmentType("normal", false, () -> ConfigManager.getLang().getString("not-curse-color")); - public static final EnchantmentType CURSE = new EnchantmentType("curse", false, () -> ConfigManager.getLang().getString("curse-color")); - public static final EnchantmentType SPECIAL = new EnchantmentType("special", () -> !ConfigManager.getConfig().getBool("types.special.allow-multiple"), () -> ConfigManager.getLang().getString("special-color")); - public static final EnchantmentType ARTIFACT = new EnchantmentType("artifact", () -> !ConfigManager.getConfig().getBool("types.artifact.allow-multiple"), () -> ConfigManager.getLang().getString("artifact-color"), Artifact.class); - public static final EnchantmentType SPELL = new EnchantmentType("spell", true, () -> ConfigManager.getLang().getString("spell-color"), Spell.class); + public static final EnchantmentType NORMAL = new EnchantmentType("normal", false, () -> Configs.LANG.getString("not-curse-color")); + public static final EnchantmentType CURSE = new EnchantmentType("curse", false, () -> Configs.LANG.getString("curse-color")); + public static final EnchantmentType SPECIAL = new EnchantmentType("special", () -> !Configs.CONFIG.getBool("types.special.allow-multiple"), () -> Configs.LANG.getString("special-color")); + public static final EnchantmentType ARTIFACT = new EnchantmentType("artifact", () -> !Configs.CONFIG.getBool("types.artifact.allow-multiple"), () -> Configs.LANG.getString("artifact-color"), Artifact.class); + public static final EnchantmentType SPELL = new EnchantmentType("spell", true, () -> Configs.LANG.getString("spell-color"), Spell.class); private boolean singular; private String color; 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 index 66038cfb..19352828 100644 --- 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 @@ -1,7 +1,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; +import com.willfp.eco.util.optional.Prerequisite; import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.util.optional.Prerequisite; import org.bukkit.Particle; public class AshArtifact extends Artifact { 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 index 062e00cc..ea8ed27e 100644 --- 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 @@ -1,7 +1,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; +import com.willfp.eco.util.optional.Prerequisite; import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.util.optional.Prerequisite; import org.bukkit.Particle; public class CrimsonArtifact extends Artifact { 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 index 4497daa0..16769740 100644 --- 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 @@ -1,7 +1,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; +import com.willfp.eco.util.optional.Prerequisite; import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.util.optional.Prerequisite; import org.bukkit.Particle; public class SoulArtifact extends Artifact { 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 index fd6d9ce8..408e01e1 100644 --- 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 @@ -1,7 +1,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; +import com.willfp.eco.util.optional.Prerequisite; import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.util.optional.Prerequisite; import org.bukkit.Particle; public class SoulFireArtifact extends Artifact { 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 index a7855c1c..ca835ef5 100644 --- 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 @@ -1,7 +1,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; +import com.willfp.eco.util.optional.Prerequisite; import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.util.optional.Prerequisite; import org.bukkit.Particle; public class TearArtifact extends Artifact { 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 index a0286766..6d27809f 100644 --- 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 @@ -1,7 +1,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.artifact; +import com.willfp.eco.util.optional.Prerequisite; import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; -import com.willfp.ecoenchants.util.optional.Prerequisite; import org.bukkit.Particle; public class WarpedArtifact extends Artifact { 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 index dfdf1be7..02cd3c6f 100644 --- 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 @@ -1,12 +1,12 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.curse; +import com.willfp.eco.util.VectorUtils; +import com.willfp.eco.util.events.armorequip.ArmorEquipEvent; +import com.willfp.eco.util.interfaces.EcoRunnable; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent; -import com.willfp.ecoenchants.util.VectorUtils; -import com.willfp.ecoenchants.util.interfaces.EcoRunnable; import org.bukkit.entity.Entity; import org.bukkit.entity.Monster; import org.bukkit.entity.PigZombie; 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 index d8db8949..3363300a 100644 --- 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 @@ -1,11 +1,11 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.curse; +import com.willfp.eco.util.DurabilityUtils; +import com.willfp.eco.util.interfaces.EcoRunnable; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.DurabilityUtils; -import com.willfp.ecoenchants.util.interfaces.EcoRunnable; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDropItemEvent; 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 index 57dedcb3..56840938 100644 --- 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 @@ -1,9 +1,9 @@ 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.util.EnchantChecks; -import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.inventory.ItemStack; 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 index c5ce396e..47d4287f 100644 --- 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 @@ -1,8 +1,8 @@ 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.util.NumberUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityShootBowEvent; 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 index 5653c3b3..0045bae6 100644 --- 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 @@ -1,9 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; +import com.willfp.eco.util.DurabilityUtils; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.nms.Cooldown; -import com.willfp.ecoenchants.util.DurabilityUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -27,7 +28,7 @@ public class Abrasion extends EcoEnchant { Player victim = (Player) uncastVictim; boolean notcharged = this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"); - if (attacker instanceof Player && Cooldown.getCooldown((Player) attacker) != 1.0f && !notcharged) + if (attacker instanceof Player && new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !notcharged) return; ArrayList armor = new ArrayList<>(Arrays.asList(victim.getInventory().getArmorContents())); 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 index 38a82722..39aeca29 100644 --- 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 @@ -1,9 +1,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.drops.DropQueue; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.internal.DropQueue; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; 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 index ee694518..d2c08c56 100644 --- 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 @@ -1,11 +1,12 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.BlockBreakProxy; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.BlockBreak; import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -67,7 +68,7 @@ public class BlastMining extends EcoEnchant { toBreak.forEach((block1 -> { block1.setMetadata("block-ignore", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - BlockBreak.breakBlock(player, block1); + new ProxyFactory<>(BlockBreakProxy.class).getProxy().breakBlock(player, block1); block1.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance()); })); 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 index eb8793a4..e25c35e1 100644 --- 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 @@ -1,10 +1,11 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -24,7 +25,7 @@ public class Bleed extends EcoEnchant { @Override public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { - if (attacker instanceof Player && Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (attacker instanceof Player && new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; if (!EnchantmentUtils.passedChance(this, level)) 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 index 3fcbfc79..8f8383f5 100644 --- 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 @@ -1,9 +1,9 @@ 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.util.EnchantChecks; -import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Sound; import org.bukkit.SoundCategory; import org.bukkit.enchantments.Enchantment; 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 index 6cfee1a4..07d1983b 100644 --- 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 @@ -1,9 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.nms.Cooldown; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -25,7 +26,7 @@ public class Cleave extends EcoEnchant { return; if (attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } 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 index 2819c1bd..5a826f39 100644 --- 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 @@ -1,7 +1,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.DurabilityUtils; import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.util.DurabilityUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; 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 index cc382ceb..ef050ffb 100644 --- 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 @@ -1,9 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -23,7 +24,7 @@ public class Disable extends EcoEnchant { @Override public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } 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 index a9e2ef90..21212524 100644 --- 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 @@ -1,12 +1,13 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.BlockBreakProxy; +import com.willfp.eco.util.VectorUtils; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.BlockBreak; -import com.willfp.ecoenchants.util.VectorUtils; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; @@ -47,7 +48,7 @@ public class Drill extends EcoEnchant { if (!AntigriefManager.canBreakBlock(player, block1)) continue; - BlockBreak.breakBlock(player, block1); + new ProxyFactory<>(BlockBreakProxy.class).getProxy().breakBlock(player, block1); block1.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance()); } 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 index 95aa46de..c710b5a2 100644 --- 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 @@ -1,14 +1,16 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; 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; + public class Dullness extends EcoEnchant { public Dullness() { super( @@ -21,7 +23,7 @@ public class Dullness extends EcoEnchant { @Override public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } 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 index 40754ebf..1e103e04 100644 --- 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 @@ -1,10 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent; +import com.willfp.eco.util.optional.Prerequisite; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.optional.Prerequisite; import org.bukkit.event.EventHandler; public class Economical extends EcoEnchant { 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 index c0938e80..c85d4b04 100644 --- 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 @@ -1,9 +1,9 @@ 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.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.LightningUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; 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 index 9ce333a7..b14a53b8 100644 --- 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 @@ -1,9 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -23,7 +24,7 @@ public class Famine extends EcoEnchant { @Override public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { if (attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } 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 index 68fc1f73..acbd210e 100644 --- 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 @@ -1,11 +1,11 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +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.util.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.util.DurabilityUtils; -import com.willfp.ecoenchants.util.VectorUtils; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; 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 index 8ac93d0e..47dc9eb1 100644 --- 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 @@ -1,10 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.drops.DropQueue; +import com.willfp.eco.util.events.entitydeathbyentity.EntityDeathByEntityEvent; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.entitydeathbyentity.EntityDeathByEntityEvent; -import com.willfp.ecoenchants.util.internal.DropQueue; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Wolf; 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 index 8f7f28c0..ac0553fb 100644 --- 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 @@ -1,12 +1,12 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.NumberUtils; +import com.willfp.eco.util.events.armorequip.ArmorEquipEvent; +import com.willfp.eco.util.interfaces.EcoRunnable; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent; -import com.willfp.ecoenchants.util.NumberUtils; -import com.willfp.ecoenchants.util.interfaces.EcoRunnable; import org.bukkit.entity.Entity; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; 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 index a560e438..0aeb8df0 100644 --- 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 @@ -1,11 +1,16 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; +import com.willfp.eco.util.VectorUtils; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.entity.*; +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; @@ -21,7 +26,7 @@ public class Fury extends EcoEnchant { @Override public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { if (attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } 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 index 16f295ba..44dade9d 100644 --- 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 @@ -1,8 +1,8 @@ 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.util.VectorUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.util.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 index 160a583d..6b5c988d 100644 --- 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 @@ -1,10 +1,10 @@ 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.util.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.util.DurabilityUtils; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; 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 index cd2a1e96..00f3a7e6 100644 --- 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 @@ -1,10 +1,10 @@ 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.util.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.util.DurabilityUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; 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 index 8f5a0342..415ef052 100644 --- 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 @@ -1,8 +1,8 @@ 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.util.VectorUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; 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 index eeef9401..cb745823 100644 --- 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 @@ -1,14 +1,16 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; 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; + public class IllusionAspect extends EcoEnchant { public IllusionAspect() { super( @@ -22,7 +24,7 @@ public class IllusionAspect extends EcoEnchant { @Override public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } 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 index 96067113..794a4627 100644 --- 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 @@ -1,10 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.drops.DropQueue; +import com.willfp.eco.util.tuplets.Pair; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.util.internal.DropQueue; -import com.willfp.ecoenchants.util.tuplets.Pair; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; 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 index 1ea9e557..23d8d1a4 100644 --- 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 @@ -1,10 +1,14 @@ 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.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.entity.*; +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; 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 index efa70308..6830d52b 100644 --- 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 @@ -2,7 +2,11 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.*; +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; public class LiquidShot extends EcoEnchant { public LiquidShot() { 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 index fd4e601a..daaaa7b3 100644 --- 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 @@ -1,12 +1,13 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.BlockBreakProxy; +import com.willfp.eco.util.BlockUtils; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.BlockBreak; -import com.willfp.ecoenchants.util.BlockUtils; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -52,7 +53,7 @@ public class Lumberjack extends EcoEnchant { treeBlock.setMetadata("block-ignore", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); if(!AntigriefManager.canBreakBlock(player, treeBlock)) continue; - BlockBreak.breakBlock(player, treeBlock); + new ProxyFactory<>(BlockBreakProxy.class).getProxy().breakBlock(player, treeBlock); Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> treeBlock.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance()),1); } 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 index 2a188a7b..5736fb04 100644 --- 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 @@ -1,12 +1,12 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.VectorUtils; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.util.VectorUtils; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; 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 index ff8ea3d8..38c6db61 100644 --- 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 @@ -1,12 +1,12 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.VectorUtils; +import com.willfp.eco.util.events.armorequip.ArmorEquipEvent; +import com.willfp.eco.util.interfaces.EcoRunnable; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent; -import com.willfp.ecoenchants.util.VectorUtils; -import com.willfp.ecoenchants.util.interfaces.EcoRunnable; import org.bukkit.entity.Entity; import org.bukkit.entity.ExperienceOrb; import org.bukkit.entity.Item; 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 index a27e3ab4..c2a9f6d0 100644 --- 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 @@ -1,9 +1,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.drops.DropQueue; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.internal.DropQueue; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.entity.WitherSkeleton; 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 index 2061d1d2..2165ac1d 100644 --- 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 @@ -1,8 +1,8 @@ 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.util.NumberUtils; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; 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 index 29159012..237de898 100644 --- 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 @@ -1,8 +1,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.optional.Prerequisite; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.util.optional.Prerequisite; import org.bukkit.Material; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; 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 index 165fa032..a1f05179 100644 --- 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 @@ -1,10 +1,14 @@ 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.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.entity.*; +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; 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 index 0f3a720f..5cc7ff49 100644 --- 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 @@ -1,10 +1,10 @@ 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.util.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.util.VectorUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; 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 index 9c9af193..794b7a7c 100644 --- 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 @@ -1,10 +1,11 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.TridentStackProxy; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.nms.TridentStack; import org.bukkit.Bukkit; import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.LivingEntity; @@ -35,7 +36,7 @@ public class Shockwave extends EcoEnchant { AbstractArrow entity = (AbstractArrow) event.getEntity(); ItemStack item = player.getInventory().getItemInMainHand(); if(entity instanceof Trident) { - item = TridentStack.getTridentStack((Trident) entity); + item = new ProxyFactory<>(TridentStackProxy.class).getProxy().getTridentStack((Trident) entity); } if (!EnchantChecks.item(item, this)) return; 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 index c557d3bb..9aafc47d 100644 --- 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 @@ -1,10 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.DurabilityUtils; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.DurabilityUtils; import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; 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 index 4e37880c..6c505cc8 100644 --- 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 @@ -1,12 +1,13 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.TridentStackProxy; +import com.willfp.eco.util.NumberUtils; +import com.willfp.eco.util.drops.DropQueue; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.TridentStack; -import com.willfp.ecoenchants.util.NumberUtils; -import com.willfp.ecoenchants.util.internal.DropQueue; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -46,7 +47,7 @@ public class Spearfishing extends EcoEnchant { Player player = (Player) event.getEntity().getShooter(); if(this.getDisabledWorlds().contains(player.getWorld())) return; - ItemStack item = TridentStack.getTridentStack(trident); + ItemStack item = new ProxyFactory<>(TridentStackProxy.class).getProxy().getTridentStack(trident); if (!EnchantChecks.item(item, this)) return; 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 index 3d9b9500..b9194b0c 100644 --- 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 @@ -1,10 +1,11 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.TridentStackProxy; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.TridentStack; import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -40,7 +41,7 @@ public class Splash extends EcoEnchant { Trident trident = (Trident) event.getEntity(); Player player = (Player) event.getEntity().getShooter(); - ItemStack item = TridentStack.getTridentStack(trident); + ItemStack item = new ProxyFactory<>(TridentStackProxy.class).getProxy().getTridentStack(trident); if (!EnchantChecks.item(item, this)) return; if(this.getDisabledWorlds().contains(player.getWorld())) return; 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 index 951599c2..5f45f159 100644 --- 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 @@ -1,10 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.NumberUtils; +import com.willfp.eco.util.drops.DropQueue; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.internal.DropQueue; -import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.block.Block; 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 index 2b902887..0c439f11 100644 --- 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 @@ -1,14 +1,16 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; 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; + public class StrayAspect extends EcoEnchant { public StrayAspect() { super( @@ -22,7 +24,7 @@ public class StrayAspect extends EcoEnchant { @Override public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } if(!EnchantmentUtils.passedChance(this, 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 index 4e1c0e52..e02d4afc 100644 --- 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 @@ -1,10 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.DurabilityUtils; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.DurabilityUtils; import org.bukkit.Bukkit; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.AbstractArrow; 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 index 7dc53ba2..940328df 100644 --- 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 @@ -1,12 +1,14 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; + public class Supercritical extends EcoEnchant { public Supercritical() { super( @@ -20,7 +22,7 @@ public class Supercritical extends EcoEnchant { @Override public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } 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 index 7a127c74..251b3f15 100644 --- 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 @@ -1,14 +1,15 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; -import com.willfp.ecoenchants.config.ConfigManager; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.TridentStackProxy; +import com.willfp.eco.util.config.Configs; +import com.willfp.eco.util.drops.DropQueue; +import com.willfp.eco.util.events.entitydeathbyentity.EntityDeathByEntityEvent; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.ecoenchants.special.Soulbound; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.entitydeathbyentity.EntityDeathByEntityEvent; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.TridentStack; -import com.willfp.ecoenchants.util.internal.DropQueue; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.block.Block; @@ -40,7 +41,7 @@ public class Telekinesis extends EcoEnchant { @Override protected void postUpdate() { - always = ConfigManager.getConfig().getBool("drops.force-dropqueue"); + always = Configs.CONFIG.getBool("drops.force-dropqueue"); } // For block drops @@ -117,7 +118,7 @@ public class Telekinesis extends EcoEnchant { } else if(event.getKiller() instanceof Trident) { if(((Trident) event.getKiller()).getShooter() instanceof Player) { player = (Player) ((Trident) event.getKiller()).getShooter(); - item = TridentStack.getTridentStack((Trident) event.getKiller()); + item = new ProxyFactory<>(TridentStackProxy.class).getProxy().getTridentStack((Trident) event.getKiller()); } } 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 index 2f67ee72..a55e3680 100644 --- 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 @@ -1,10 +1,11 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; +import com.willfp.eco.util.LightningUtils; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -import com.willfp.ecoenchants.util.LightningUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -22,7 +23,7 @@ public class Thor extends EcoEnchant { @Override public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { if (attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } 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 index a753c5ad..0ac33ff6 100644 --- 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 @@ -1,10 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.events.armorequip.ArmorEquipEvent; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent; import org.bukkit.attribute.Attribute; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; 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 index 2cee5886..35129419 100644 --- 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 @@ -1,9 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -23,7 +24,7 @@ public class Toxic extends EcoEnchant { @Override public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { if (attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } 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 index 8d6d9848..e7765347 100644 --- 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 @@ -1,10 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.NumberUtils; +import com.willfp.eco.util.drops.DropQueue; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.internal.DropQueue; -import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.block.Block; 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 index d75ee15c..03c26c0c 100644 --- 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 @@ -1,14 +1,16 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; 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; + public class VampireAspect extends EcoEnchant { public VampireAspect() { super( @@ -22,7 +24,7 @@ public class VampireAspect extends EcoEnchant { @Override public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } 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 index 5689b93f..a2f136eb 100644 --- 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 @@ -1,12 +1,13 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.BlockBreakProxy; +import com.willfp.eco.util.BlockUtils; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.BlockBreak; -import com.willfp.ecoenchants.util.BlockUtils; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -52,7 +53,7 @@ public class Vein extends EcoEnchant { veinBlock.setMetadata("block-ignore", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); if (!AntigriefManager.canBreakBlock(player, veinBlock)) continue; - BlockBreak.breakBlock(player, veinBlock); + new ProxyFactory<>(BlockBreakProxy.class).getProxy().breakBlock(player, veinBlock); Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> veinBlock.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance()), 1); } 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 index 1064f679..3ad5b1d9 100644 --- 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 @@ -1,9 +1,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; +import com.willfp.eco.util.events.naturalexpgainevent.NaturalExpGainEvent; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.naturalexpgainevent.NaturalExpGainEvent; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; public class Wisdom extends EcoEnchant { 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 index aa6cd9c8..6a0c9ef8 100644 --- 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 @@ -1,9 +1,9 @@ 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.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.LightningUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; 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 index 528b28a1..504baea8 100644 --- 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 @@ -1,10 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special; +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.util.EnchantChecks; -import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.entity.Arrow; 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 index 2a39f884..9682734f 100644 --- 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 @@ -1,8 +1,8 @@ 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.util.VectorUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.util.Vector; 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 index 02eefc93..80a7d198 100644 --- 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 @@ -1,13 +1,15 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; +import com.willfp.eco.util.LightningUtils; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; -import com.willfp.ecoenchants.util.LightningUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; + public class Bolt extends EcoEnchant { public Bolt() { super( @@ -21,7 +23,7 @@ public class Bolt extends EcoEnchant { @Override public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } if(!EnchantmentUtils.passedChance(this, level)) 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 index bc2c7e61..47424c20 100644 --- 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 @@ -1,14 +1,16 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.nms.Cooldown; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.metadata.FixedMetadataValue; + public class Carve extends EcoEnchant { public Carve() { super( @@ -30,7 +32,7 @@ public class Carve extends EcoEnchant { final double radius = radiusPerLevel * level; if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } 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 index 88b1ccd0..6d3cfd5e 100644 --- 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 @@ -1,9 +1,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.nms.Cooldown; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -28,7 +29,7 @@ public class Confusion extends EcoEnchant { Player victim = (Player) uncastVictim; if(attacker instanceof Player) { - if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; } if(!EnchantmentUtils.passedChance(this, level)) 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 index 8fc1b4da..8515295a 100644 --- 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 @@ -1,9 +1,9 @@ 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.util.EnchantChecks; -import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.inventory.ItemStack; 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 index 57748e30..c06751a4 100644 --- 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 @@ -1,9 +1,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special; +import com.willfp.eco.util.events.naturalexpgainevent.NaturalExpGainEvent; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.events.naturalexpgainevent.NaturalExpGainEvent; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; public class Intellect extends EcoEnchant { 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 index a3d03c48..518ae87a 100644 --- 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 @@ -1,11 +1,13 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.nms.Cooldown; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; + public class Razor extends EcoEnchant { public Razor() { super( @@ -23,7 +25,7 @@ public class Razor extends EcoEnchant { double extra = level*perLevelMultiplier + baseDamage; if(this.getConfig().getBool((EcoEnchants.CONFIG_LOCATION) + "decrease-if-cooldown")) { if(attacker instanceof Player) { - extra *= Cooldown.getCooldown((Player) attacker); + extra *= new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown((Player) attacker); } } 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 index 88891ca7..77edf297 100644 --- 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 @@ -1,11 +1,11 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special; +import com.willfp.eco.util.DurabilityUtils; +import com.willfp.eco.util.interfaces.EcoRunnable; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import com.willfp.ecoenchants.util.DurabilityUtils; -import com.willfp.ecoenchants.util.interfaces.EcoRunnable; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDropItemEvent; 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 index 11db94f1..257e4d44 100644 --- 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 @@ -1,8 +1,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special; +import com.willfp.eco.util.events.armorequip.ArmorEquipEvent; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.events.armorequip.ArmorEquipEvent; import org.bukkit.entity.Player; public class Streamlining extends EcoEnchant { public Streamlining() { 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 index f33ef339..a4608ce5 100644 --- 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 @@ -1,14 +1,16 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.CooldownProxy; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.Cooldown; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; + public class Volatile extends EcoEnchant { public Volatile() { super( @@ -25,7 +27,7 @@ public class Volatile extends EcoEnchant { Player attacker = (Player) uncastAttacker; - if (Cooldown.getCooldown(attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) + if (new ProxyFactory<>(CooldownProxy.class).getProxy().getAttackCooldown(attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; if(!EnchantmentUtils.passedChance(this, level)) return; 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 index 2abd6aa0..8476864a 100644 --- 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 @@ -1,11 +1,12 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.spell; +import com.willfp.eco.core.proxy.ProxyFactory; +import com.willfp.eco.core.proxy.proxies.BlockBreakProxy; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.itemtypes.Spell; import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.nms.BlockBreak; import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -67,7 +68,7 @@ public class Dynamite extends Spell { toBreak.forEach((block1 -> { block1.setMetadata("block-ignore", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); - BlockBreak.breakBlock(player, block1); + new ProxyFactory<>(BlockBreakProxy.class).getProxy().breakBlock(player, block1); block1.removeMetadata("block-ignore", EcoEnchantsPlugin.getInstance()); })); 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 index 77fdc1f4..21c99ca3 100644 --- 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 @@ -1,8 +1,8 @@ package com.willfp.ecoenchants.enchantments.itemtypes; +import com.willfp.eco.util.config.Configs; import com.willfp.eco.util.optional.Prerequisite; import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.config.ConfigManager; import com.willfp.ecoenchants.display.EnchantmentCache; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; @@ -82,13 +82,13 @@ public abstract class Spell extends EcoEnchant { int cooldown = getCooldown(this, player); if (cooldown > 0) { - String message = ConfigManager.getLang().getMessage("on-cooldown").replaceAll("%seconds%", String.valueOf(cooldown)).replaceAll("%name%", EnchantmentCache.getEntry(this).getRawName()); + String message = Configs.LANG.getMessage("on-cooldown").replaceAll("%seconds%", String.valueOf(cooldown)).replaceAll("%name%", EnchantmentCache.getEntry(this).getRawName()); player.sendMessage(message); player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 0.5f); return; } - String message = ConfigManager.getLang().getMessage("used-spell").replaceAll("%name%", EnchantmentCache.getEntry(this).getRawName()); + String message = Configs.LANG.getMessage("used-spell").replaceAll("%name%", EnchantmentCache.getEntry(this).getRawName()); player.sendMessage(message); player.playSound(player.getLocation(), this.getActivationSound(), SoundCategory.PLAYERS, 1, 1); runnable.run(); 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 index 64378bf6..a405764b 100644 --- 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 @@ -5,11 +5,11 @@ import com.willfp.eco.core.proxy.ProxyFactory; import com.willfp.eco.core.proxy.proxies.OpenInventoryProxy; import com.willfp.eco.core.proxy.proxies.RepairCostProxy; import com.willfp.eco.util.NumberUtils; +import com.willfp.eco.util.config.Configs; import com.willfp.eco.util.injection.PluginDependent; import com.willfp.eco.util.plugin.AbstractEcoPlugin; import com.willfp.eco.util.tuplets.Pair; import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.config.ConfigManager; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -84,7 +84,7 @@ public class AnvilListeners extends PluginDependent implements Listener { if (!Objects.requireNonNull(event.getInventory().getItem(0)).getType().equals(item.getType())) return; - if (ConfigManager.getConfig().getBool("anvil.rework-cost")) { + if (Configs.CONFIG.getBool("anvil.rework-cost")) { int repairCost = new ProxyFactory<>(RepairCostProxy.class).getProxy().getRepairCost(item); int reworkCount = NumberUtils.log2(repairCost + 1); if (repairCost == 0) reworkCount = 0; 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 index fded5165..dfa10d4b 100644 --- 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 @@ -1,7 +1,7 @@ package com.willfp.ecoenchants.enchantments.support.merging.anvil; +import com.willfp.eco.util.config.Configs; import com.willfp.eco.util.tuplets.Pair; -import com.willfp.ecoenchants.config.ConfigManager; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; @@ -109,9 +109,9 @@ public class AnvilMerge { if (rightLevel > level) { level = rightLevel; } else if (rightLevel == level) { - if (rightLevel > enchantment.getMaxLevel() && ConfigManager.getConfig().getBool("anvil.allow-combining-unsafe")) { + if (rightLevel > enchantment.getMaxLevel() && Configs.CONFIG.getBool("anvil.allow-combining-unsafe")) { level++; - } else if ((rightLevel + 1) <= enchantment.getMaxLevel() || ConfigManager.getConfig().getBool("anvil.allow-unsafe-levels")) { + } else if ((rightLevel + 1) <= enchantment.getMaxLevel() || Configs.CONFIG.getBool("anvil.allow-unsafe-levels")) { level++; } } @@ -140,8 +140,8 @@ public class AnvilMerge { if (left.getItemMeta() instanceof EnchantmentStorageMeta) canEnchantItem = true; if (canEnchantItem && !doesConflict.get()) { - if (ConfigManager.getConfig().getBool("anvil.hard-cap.enabled") && !player.hasPermission("ecoenchants.anvil.bypasshardcap")) { - if (outEnchants.size() >= ConfigManager.getConfig().getInt("anvil.hard-cap.cap")) { + if (Configs.CONFIG.getBool("anvil.hard-cap.enabled") && !player.hasPermission("ecoenchants.anvil.bypasshardcap")) { + if (outEnchants.size() >= Configs.CONFIG.getInt("anvil.hard-cap.cap")) { return; } } @@ -169,7 +169,7 @@ public class AnvilMerge { })); outEnchants.forEach(((enchantment, integer) -> { - meta.addStoredEnchant(enchantment, integer, ConfigManager.getConfig().getBool("anvil.allow-existing-unsafe-levels") || ConfigManager.getConfig().getBool("anvil.allow-unsafe-levels")); + meta.addStoredEnchant(enchantment, integer, Configs.CONFIG.getBool("anvil.allow-existing-unsafe-levels") || Configs.CONFIG.getBool("anvil.allow-unsafe-levels")); })); meta.setDisplayName(name); @@ -182,7 +182,7 @@ public class AnvilMerge { })); outEnchants.forEach(((enchantment, integer) -> { - meta.addEnchant(enchantment, integer, ConfigManager.getConfig().getBool("anvil.allow-existing-unsafe-levels") || ConfigManager.getConfig().getBool("anvil.allow-unsafe-levels")); + meta.addEnchant(enchantment, integer, Configs.CONFIG.getBool("anvil.allow-existing-unsafe-levels") || Configs.CONFIG.getBool("anvil.allow-unsafe-levels")); })); if (output.getItemMeta() instanceof Damageable) { @@ -215,8 +215,8 @@ public class AnvilMerge { if (output.equals(left)) return new Pair<>(null, null); - if (ConfigManager.getConfig().getBool("anvil.cost-exponent.enabled")) { - double exponent = ConfigManager.getConfig().getDouble("anvil.cost-exponent.exponent"); + if (Configs.CONFIG.getBool("anvil.cost-exponent.enabled")) { + double exponent = Configs.CONFIG.getDouble("anvil.cost-exponent.exponent"); int prevDelta = totalEnchantLevelDelta; double costMultiplier = Math.pow(exponent, totalEnchantLevelDelta); 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 index 9cacba1f..e4762f12 100644 --- 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 @@ -1,10 +1,10 @@ package com.willfp.ecoenchants.enchantments.support.obtaining; import com.willfp.eco.util.NumberUtils; +import com.willfp.eco.util.config.Configs; import com.willfp.eco.util.injection.PluginDependent; import com.willfp.eco.util.plugin.AbstractEcoPlugin; import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.config.ConfigManager; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import org.bukkit.Material; @@ -55,7 +55,7 @@ public class EnchantingListeners extends PluginDependent implements Listener { int cost = event.getExpLevelCost(); Map toAdd = event.getEnchantsToAdd(); - if (!ConfigManager.getConfig().getBool("enchanting-table.enabled")) { + if (!Configs.CONFIG.getBool("enchanting-table.enabled")) { this.plugin.getScheduler().runLater(() -> { ItemStack item0 = event.getInventory().getItem(0); event.getInventory().setItem(0, item0); @@ -75,11 +75,11 @@ public class EnchantingListeners extends PluginDependent implements Listener { double multiplier = 0.01; if (item.getType().equals(Material.BOOK) || item.getType().equals(Material.ENCHANTED_BOOK)) { - multiplier /= ConfigManager.getConfig().getInt("enchanting-table.book-times-less-likely"); + multiplier /= Configs.CONFIG.getInt("enchanting-table.book-times-less-likely"); } - if (ConfigManager.getConfig().getBool("enchanting-table.reduce-probability.enabled")) { - multiplier /= ConfigManager.getConfig().getDouble("enchanting-table.reduce-probability.factor"); + if (Configs.CONFIG.getBool("enchanting-table.reduce-probability.enabled")) { + multiplier /= Configs.CONFIG.getDouble("enchanting-table.reduce-probability.factor"); } ArrayList enchantments = new ArrayList<>(EcoEnchants.getAll()); @@ -121,11 +121,11 @@ public class EnchantingListeners extends PluginDependent implements Listener { if (enchantment.getType().equals(EcoEnchant.EnchantmentType.SPECIAL)) { double enchantlevel1 = NumberUtils.randFloat(0, 1); - double enchantlevel2 = NumberUtils.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); + double enchantlevel2 = NumberUtils.bias(enchantlevel1, Configs.CONFIG.getDouble("enchanting-table.special-bias")); double enchantlevel3 = 1 / maxLevelDouble; level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } else { - int maxLevel = ConfigManager.getConfig().getInt("enchanting-table.maximum-obtainable-level"); + int maxLevel = Configs.CONFIG.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; @@ -135,16 +135,16 @@ public class EnchantingListeners extends PluginDependent implements Listener { level = NumberUtils.equalIfOver(level, enchantment.getMaxLevel()); toAdd.put(enchantment, level); - if (ConfigManager.getConfig().getBool("enchanting-table.cap-amount.enabled")) { - if (toAdd.size() >= ConfigManager.getConfig().getInt("enchanting-table.cap-amount.limit")) { + if (Configs.CONFIG.getBool("enchanting-table.cap-amount.enabled")) { + if (toAdd.size() >= Configs.CONFIG.getInt("enchanting-table.cap-amount.limit")) { break; } } if (enchantment.getType().equals(EcoEnchant.EnchantmentType.SPECIAL)) gotSpecial = true; - if (ConfigManager.getConfig().getBool("enchanting-table.reduce-probability.enabled")) { - multiplier /= ConfigManager.getConfig().getDouble("enchanting-table.reduce-probability.factor"); + if (Configs.CONFIG.getBool("enchanting-table.reduce-probability.enabled")) { + multiplier /= Configs.CONFIG.getDouble("enchanting-table.reduce-probability.factor"); } } toAdd.forEach(event.getEnchantsToAdd()::putIfAbsent); @@ -156,8 +156,8 @@ public class EnchantingListeners extends PluginDependent implements Listener { } } - if (gotSpecial && ConfigManager.getConfig().getBool("enchanting-table.notify-on-special")) { - player.sendMessage(ConfigManager.getLang().getMessage("got-special")); + if (gotSpecial && Configs.CONFIG.getBool("enchanting-table.notify-on-special")) { + player.sendMessage(Configs.LANG.getMessage("got-special")); } // Ew @@ -183,7 +183,7 @@ public class EnchantingListeners extends PluginDependent implements Listener { @EventHandler public void secondaryEnchant(PrepareItemEnchantEvent event) { - int maxLevel = ConfigManager.getConfig().getInt("enchanting-table.maximum-obtainable-level"); + int maxLevel = Configs.CONFIG.getInt("enchanting-table.maximum-obtainable-level"); try { event.getOffers()[2].setCost(NumberUtils.equalIfOver(event.getOffers()[2].getCost(), maxLevel)); 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 index 7c65e709..770acb2a 100644 --- 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 @@ -2,7 +2,7 @@ package com.willfp.ecoenchants.enchantments.support.obtaining; import com.willfp.eco.util.NumberUtils; -import com.willfp.ecoenchants.config.ConfigManager; +import com.willfp.eco.util.config.Configs; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; @@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicBoolean; public class LootPopulator extends BlockPopulator { public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) { - if (!ConfigManager.getConfig().getBool("loot.enabled")) + if (!Configs.CONFIG.getBool("loot.enabled")) return; for (BlockState state : chunk.getTileEntities()) { @@ -50,11 +50,11 @@ public class LootPopulator extends BlockPopulator { double multiplier = 0.01; if (item.getType().equals(Material.BOOK) || item.getType().equals(Material.ENCHANTED_BOOK)) { - multiplier /= ConfigManager.getConfig().getInt("loot.book-times-less-likely"); + multiplier /= Configs.CONFIG.getInt("loot.book-times-less-likely"); } - if (ConfigManager.getConfig().getBool("loot.reduce-probability.enabled")) { - multiplier /= ConfigManager.getConfig().getDouble("loot.reduce-probability.factor"); + if (Configs.CONFIG.getBool("loot.reduce-probability.enabled")) { + multiplier /= Configs.CONFIG.getDouble("loot.reduce-probability.factor"); } for (EcoEnchant enchantment : enchantments) { @@ -84,7 +84,7 @@ public class LootPopulator extends BlockPopulator { if (enchantment.getType().equals(EcoEnchant.EnchantmentType.SPECIAL)) { double enchantlevel1 = NumberUtils.randFloat(0, 1); - double enchantlevel2 = NumberUtils.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); + double enchantlevel2 = NumberUtils.bias(enchantlevel1, Configs.CONFIG.getDouble("enchanting-table.special-bias")); double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } else { @@ -95,8 +95,8 @@ public class LootPopulator extends BlockPopulator { toAdd.put(enchantment, level); - if (ConfigManager.getConfig().getBool("loot.reduce-probability.enabled")) { - multiplier /= ConfigManager.getConfig().getDouble("loot.reduce-probability.factor"); + if (Configs.CONFIG.getBool("loot.reduce-probability.enabled")) { + multiplier /= Configs.CONFIG.getDouble("loot.reduce-probability.factor"); } } 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 index d8cb1f75..23683721 100644 --- 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 @@ -2,7 +2,7 @@ package com.willfp.ecoenchants.enchantments.support.obtaining; import com.willfp.eco.util.NumberUtils; -import com.willfp.ecoenchants.config.ConfigManager; +import com.willfp.eco.util.config.Configs; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; @@ -30,7 +30,7 @@ public class VillagerListeners implements Listener { if (!event.getRecipe().getResult().getType().equals(Material.ENCHANTED_BOOK)) return; - if (!ConfigManager.getConfig().getBool("villager.enabled")) + if (!Configs.CONFIG.getBool("villager.enabled")) return; ItemStack result = event.getRecipe().getResult().clone(); @@ -48,7 +48,7 @@ public class VillagerListeners implements Listener { ArrayList enchantments = new ArrayList<>(EcoEnchants.getAll()); Collections.shuffle(enchantments); // Prevent list bias towards early enchantments like telekinesis - double multiplier = 0.01 / ConfigManager.getConfig().getDouble("villager.book-times-less-likely"); + double multiplier = 0.01 / Configs.CONFIG.getDouble("villager.book-times-less-likely"); for (EcoEnchant enchantment : enchantments) { if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getVillagerProbability() * multiplier) @@ -62,7 +62,7 @@ public class VillagerListeners implements Listener { if (enchantment.getType().equals(EcoEnchant.EnchantmentType.SPECIAL)) { double enchantlevel1 = NumberUtils.randFloat(0, 1); - double enchantlevel2 = NumberUtils.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); + double enchantlevel2 = NumberUtils.bias(enchantlevel1, Configs.CONFIG.getDouble("enchanting-table.special-bias")); double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } else { @@ -97,7 +97,7 @@ public class VillagerListeners implements Listener { if (event.getRecipe().getResult().getType().equals(Material.BOOK)) return; - if (!ConfigManager.getConfig().getBool("villager.enabled")) + if (!Configs.CONFIG.getBool("villager.enabled")) return; ItemStack result = event.getRecipe().getResult().clone(); @@ -144,7 +144,7 @@ public class VillagerListeners implements Listener { if (enchantment.getType().equals(EcoEnchant.EnchantmentType.SPECIAL)) { double enchantlevel1 = NumberUtils.randFloat(0, 1); - double enchantlevel2 = NumberUtils.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); + double enchantlevel2 = NumberUtils.bias(enchantlevel1, Configs.CONFIG.getDouble("enchanting-table.special-bias")); double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } else { @@ -157,8 +157,8 @@ public class VillagerListeners implements Listener { toAdd.put(enchantment, level); - if (ConfigManager.getConfig().getBool("villager.reduce-probability.enabled")) { - multiplier /= ConfigManager.getConfig().getDouble("villager.reduce-probability.factor"); + if (Configs.CONFIG.getBool("villager.reduce-probability.enabled")) { + multiplier /= Configs.CONFIG.getDouble("villager.reduce-probability.factor"); } } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefFactionsUUID.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefFactionsUUID.java index ee9795cf..5f32f72b 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefFactionsUUID.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefFactionsUUID.java @@ -1,6 +1,10 @@ package com.willfp.ecoenchants.integrations.antigrief.plugins; -import com.massivecraft.factions.*; +import com.massivecraft.factions.Board; +import com.massivecraft.factions.FLocation; +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.FPlayers; +import com.massivecraft.factions.Faction; import com.massivecraft.factions.perms.PermissibleAction; import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper; import org.bukkit.Location; diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/McmmoManager.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/McmmoManager.java index a63f27a6..5e5498d2 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/McmmoManager.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/mcmmo/McmmoManager.java @@ -1,6 +1,6 @@ package com.willfp.ecoenchants.integrations.mcmmo; -import com.willfp.ecoenchants.util.ClassUtils; +import com.willfp.eco.util.ClassUtils; import org.bukkit.event.Event; import java.util.HashSet; diff --git a/eco-util/src/main/java/com/willfp/eco/util/interfaces/EcoRunnable.java b/eco-util/src/main/java/com/willfp/eco/util/interfaces/EcoRunnable.java new file mode 100644 index 00000000..579d2801 --- /dev/null +++ b/eco-util/src/main/java/com/willfp/eco/util/interfaces/EcoRunnable.java @@ -0,0 +1,5 @@ +package com.willfp.eco.util.interfaces; + +public interface EcoRunnable extends Runnable { + long getTime(); +} diff --git a/gradle.properties b/gradle.properties index 3697bce6..169b33b0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 5.10.7 +version = 6.0.0 plugin-name = EcoEnchants \ No newline at end of file