From 8cdefcdfb28608e1d27f650d18d808e38674de56 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 21 Dec 2020 17:12:46 +0000 Subject: [PATCH] Removed unused classes --- .../illusioner/nms/api/BlockBreakWrapper.java | 11 - .../illusioner/nms/api/CooldownWrapper.java | 10 - .../nms/api/OpenInventoryWrapper.java | 7 - .../nms/api/TridentStackWrapper.java | 11 - .../illusioner/v1_15_R1/BlockBreak.java | 14 -- .../willfp/illusioner/v1_15_R1/Cooldown.java | 14 -- .../illusioner/v1_15_R1/OpenInventory.java | 12 -- .../illusioner/v1_15_R1/TridentStack.java | 16 -- .../illusioner/v1_16_R1/BlockBreak.java | 14 -- .../willfp/illusioner/v1_16_R1/Cooldown.java | 11 - .../illusioner/v1_16_R1/OpenInventory.java | 12 -- .../illusioner/v1_16_R1/TridentStack.java | 16 -- .../illusioner/v1_16_R2/BlockBreak.java | 14 -- .../willfp/illusioner/v1_16_R2/Cooldown.java | 11 - .../illusioner/v1_16_R2/OpenInventory.java | 12 -- .../illusioner/v1_16_R2/TridentStack.java | 16 -- .../illusioner/v1_16_R3/BlockBreak.java | 14 -- .../willfp/illusioner/v1_16_R3/Cooldown.java | 11 - .../illusioner/v1_16_R3/OpenInventory.java | 12 -- .../illusioner/v1_16_R3/TridentStack.java | 16 -- .../events/armorequip/ArmorEquipEvent.java | 123 ----------- .../events/armorequip/ArmorListener.java | 204 ------------------ .../events/armorequip/ArmorType.java | 38 ---- .../armorequip/DispenserArmorListener.java | 28 --- .../NaturalExpGainBuilder.java | 46 ---- .../NaturalExpGainEvent.java | 46 ---- .../NaturalExpGainListeners.java | 56 ----- .../com/willfp/illusioner/nms/BlockBreak.java | 39 ---- .../com/willfp/illusioner/nms/Cooldown.java | 38 ---- .../willfp/illusioner/nms/OpenInventory.java | 38 ---- .../willfp/illusioner/nms/TridentStack.java | 40 ---- .../willfp/illusioner/util/BlockUtils.java | 37 ---- .../willfp/illusioner/util/ClassUtils.java | 19 -- .../illusioner/util/DurabilityUtils.java | 112 ---------- .../illusioner/util/LightningUtils.java | 26 --- .../willfp/illusioner/util/VectorUtils.java | 141 ------------ .../util/interfaces/ObjectBiCallable.java | 12 -- .../util/interfaces/ObjectCallable.java | 11 - .../illusioner/util/internal/Loader.java | 44 ---- .../illusioner/util/tuplets/Triplet.java | 86 -------- 40 files changed, 1438 deletions(-) delete mode 100644 NMS/API/src/main/java/com/willfp/illusioner/nms/api/BlockBreakWrapper.java delete mode 100644 NMS/API/src/main/java/com/willfp/illusioner/nms/api/CooldownWrapper.java delete mode 100644 NMS/API/src/main/java/com/willfp/illusioner/nms/api/OpenInventoryWrapper.java delete mode 100644 NMS/API/src/main/java/com/willfp/illusioner/nms/api/TridentStackWrapper.java delete mode 100644 NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/BlockBreak.java delete mode 100644 NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/Cooldown.java delete mode 100644 NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/OpenInventory.java delete mode 100644 NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/TridentStack.java delete mode 100644 NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/BlockBreak.java delete mode 100644 NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/Cooldown.java delete mode 100644 NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/OpenInventory.java delete mode 100644 NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/TridentStack.java delete mode 100644 NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/BlockBreak.java delete mode 100644 NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/Cooldown.java delete mode 100644 NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/OpenInventory.java delete mode 100644 NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/TridentStack.java delete mode 100644 NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/BlockBreak.java delete mode 100644 NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/Cooldown.java delete mode 100644 NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/OpenInventory.java delete mode 100644 NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/TridentStack.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/events/armorequip/ArmorEquipEvent.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/events/armorequip/ArmorListener.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/events/armorequip/ArmorType.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/events/armorequip/DispenserArmorListener.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/events/naturalexpgainevent/NaturalExpGainBuilder.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/events/naturalexpgainevent/NaturalExpGainEvent.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/events/naturalexpgainevent/NaturalExpGainListeners.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/nms/BlockBreak.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/nms/Cooldown.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/nms/OpenInventory.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/nms/TridentStack.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/util/BlockUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/util/ClassUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/util/DurabilityUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/util/LightningUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/util/VectorUtils.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/util/interfaces/ObjectBiCallable.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/util/interfaces/ObjectCallable.java delete mode 100644 Plugin/src/main/java/com/willfp/illusioner/util/tuplets/Triplet.java diff --git a/NMS/API/src/main/java/com/willfp/illusioner/nms/api/BlockBreakWrapper.java b/NMS/API/src/main/java/com/willfp/illusioner/nms/api/BlockBreakWrapper.java deleted file mode 100644 index 1ddae00..0000000 --- a/NMS/API/src/main/java/com/willfp/illusioner/nms/api/BlockBreakWrapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.illusioner.nms.api; - -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - -/** - * NMS Interface for breaking blocks as player - */ -public interface BlockBreakWrapper { - void breakBlock(Player player, Block block); -} diff --git a/NMS/API/src/main/java/com/willfp/illusioner/nms/api/CooldownWrapper.java b/NMS/API/src/main/java/com/willfp/illusioner/nms/api/CooldownWrapper.java deleted file mode 100644 index df03f6d..0000000 --- a/NMS/API/src/main/java/com/willfp/illusioner/nms/api/CooldownWrapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.willfp.illusioner.nms.api; - -import org.bukkit.entity.Player; - -/** - * NMS Interface for getting attack cooldown - */ -public interface CooldownWrapper { - double getAttackCooldown(Player player); -} diff --git a/NMS/API/src/main/java/com/willfp/illusioner/nms/api/OpenInventoryWrapper.java b/NMS/API/src/main/java/com/willfp/illusioner/nms/api/OpenInventoryWrapper.java deleted file mode 100644 index 127d2bb..0000000 --- a/NMS/API/src/main/java/com/willfp/illusioner/nms/api/OpenInventoryWrapper.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.willfp.illusioner.nms.api; - -import org.bukkit.entity.Player; - -public interface OpenInventoryWrapper { - Object getOpenInventory(Player player); -} diff --git a/NMS/API/src/main/java/com/willfp/illusioner/nms/api/TridentStackWrapper.java b/NMS/API/src/main/java/com/willfp/illusioner/nms/api/TridentStackWrapper.java deleted file mode 100644 index 1dc1fd2..0000000 --- a/NMS/API/src/main/java/com/willfp/illusioner/nms/api/TridentStackWrapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.illusioner.nms.api; - -import org.bukkit.entity.Trident; -import org.bukkit.inventory.ItemStack; - -/** - * NMS Interface for getting an ItemStack from a Trident - */ -public interface TridentStackWrapper { - ItemStack getTridentStack(Trident trident); -} \ No newline at end of file diff --git a/NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/BlockBreak.java b/NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/BlockBreak.java deleted file mode 100644 index 8dc0039..0000000 --- a/NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/BlockBreak.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.illusioner.v1_15_R1; - -import com.willfp.illusioner.nms.api.BlockBreakWrapper; -import net.minecraft.server.v1_15_R1.BlockPosition; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class BlockBreak implements BlockBreakWrapper { - @Override - public void breakBlock(Player player, Block block) { - ((CraftPlayer)player).getHandle().playerInteractManager.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ())); - } -} diff --git a/NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/Cooldown.java b/NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/Cooldown.java deleted file mode 100644 index 0645b3a..0000000 --- a/NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/Cooldown.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.illusioner.v1_15_R1; - -import com.willfp.illusioner.nms.api.CooldownWrapper; -import net.minecraft.server.v1_15_R1.EntityHuman; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class Cooldown implements CooldownWrapper { - @Override - public double getAttackCooldown(Player player) { - EntityHuman entityHuman = ((CraftPlayer) player).getHandle(); - return entityHuman.s(0); - } -} diff --git a/NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/OpenInventory.java b/NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/OpenInventory.java deleted file mode 100644 index d5e3592..0000000 --- a/NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/OpenInventory.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.willfp.illusioner.v1_15_R1; - -import com.willfp.illusioner.nms.api.OpenInventoryWrapper; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class OpenInventory implements OpenInventoryWrapper { - @Override - public Object getOpenInventory(Player player) { - return ((CraftPlayer) player).getHandle().activeContainer; - } -} diff --git a/NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/TridentStack.java b/NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/TridentStack.java deleted file mode 100644 index c91da96..0000000 --- a/NMS/v1_15_R1/src/main/java/com/willfp/illusioner/v1_15_R1/TridentStack.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.illusioner.v1_15_R1; - -import com.willfp.illusioner.nms.api.TridentStackWrapper; -import net.minecraft.server.v1_15_R1.EntityThrownTrident; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftTrident; -import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack; -import org.bukkit.entity.Trident; -import org.bukkit.inventory.ItemStack; - -public class TridentStack implements TridentStackWrapper { - @Override - public ItemStack getTridentStack(Trident trident) { - EntityThrownTrident t = ((CraftTrident) trident).getHandle(); - return CraftItemStack.asBukkitCopy(t.trident); - } -} \ No newline at end of file diff --git a/NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/BlockBreak.java b/NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/BlockBreak.java deleted file mode 100644 index c2656fe..0000000 --- a/NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/BlockBreak.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.illusioner.v1_16_R1; - -import com.willfp.illusioner.nms.api.BlockBreakWrapper; -import net.minecraft.server.v1_16_R1.BlockPosition; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class BlockBreak implements BlockBreakWrapper { - @Override - public void breakBlock(Player player, Block block) { - ((CraftPlayer)player).getHandle().playerInteractManager.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ())); - } -} diff --git a/NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/Cooldown.java b/NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/Cooldown.java deleted file mode 100644 index d291abf..0000000 --- a/NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/Cooldown.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.illusioner.v1_16_R1; - -import com.willfp.illusioner.nms.api.CooldownWrapper; -import org.bukkit.entity.Player; - -public class Cooldown implements CooldownWrapper { - @Override - public double getAttackCooldown(Player player) { - return player.getAttackCooldown(); - } -} diff --git a/NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/OpenInventory.java b/NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/OpenInventory.java deleted file mode 100644 index 6623fb7..0000000 --- a/NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/OpenInventory.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.willfp.illusioner.v1_16_R1; - -import com.willfp.illusioner.nms.api.OpenInventoryWrapper; -import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class OpenInventory implements OpenInventoryWrapper { - @Override - public Object getOpenInventory(Player player) { - return ((CraftPlayer) player).getHandle().activeContainer; - } -} diff --git a/NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/TridentStack.java b/NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/TridentStack.java deleted file mode 100644 index 9596d19..0000000 --- a/NMS/v1_16_R1/src/main/java/com/willfp/illusioner/v1_16_R1/TridentStack.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.illusioner.v1_16_R1; - -import com.willfp.illusioner.nms.api.TridentStackWrapper; -import net.minecraft.server.v1_16_R1.EntityThrownTrident; -import org.bukkit.craftbukkit.v1_16_R1.entity.CraftTrident; -import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack; -import org.bukkit.entity.Trident; -import org.bukkit.inventory.ItemStack; - -public class TridentStack implements TridentStackWrapper { - @Override - public ItemStack getTridentStack(Trident trident) { - EntityThrownTrident t = ((CraftTrident) trident).getHandle(); - return CraftItemStack.asBukkitCopy(t.trident); - } -} \ No newline at end of file diff --git a/NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/BlockBreak.java b/NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/BlockBreak.java deleted file mode 100644 index 0667c85..0000000 --- a/NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/BlockBreak.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.illusioner.v1_16_R2; - -import com.willfp.illusioner.nms.api.BlockBreakWrapper; -import net.minecraft.server.v1_16_R2.BlockPosition; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class BlockBreak implements BlockBreakWrapper { - @Override - public void breakBlock(Player player, Block block) { - ((CraftPlayer)player).getHandle().playerInteractManager.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ())); - } -} diff --git a/NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/Cooldown.java b/NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/Cooldown.java deleted file mode 100644 index da51219..0000000 --- a/NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/Cooldown.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.illusioner.v1_16_R2; - -import com.willfp.illusioner.nms.api.CooldownWrapper; -import org.bukkit.entity.Player; - -public class Cooldown implements CooldownWrapper { - @Override - public double getAttackCooldown(Player player) { - return player.getAttackCooldown(); - } -} diff --git a/NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/OpenInventory.java b/NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/OpenInventory.java deleted file mode 100644 index fd289d1..0000000 --- a/NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/OpenInventory.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.willfp.illusioner.v1_16_R2; - -import com.willfp.illusioner.nms.api.OpenInventoryWrapper; -import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class OpenInventory implements OpenInventoryWrapper { - @Override - public Object getOpenInventory(Player player) { - return ((CraftPlayer) player).getHandle().activeContainer; - } -} diff --git a/NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/TridentStack.java b/NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/TridentStack.java deleted file mode 100644 index ef7973c..0000000 --- a/NMS/v1_16_R2/src/main/java/com/willfp/illusioner/v1_16_R2/TridentStack.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.illusioner.v1_16_R2; - -import com.willfp.illusioner.nms.api.TridentStackWrapper; -import net.minecraft.server.v1_16_R2.EntityThrownTrident; -import org.bukkit.craftbukkit.v1_16_R2.entity.CraftTrident; -import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack; -import org.bukkit.entity.Trident; -import org.bukkit.inventory.ItemStack; - -public class TridentStack implements TridentStackWrapper { - @Override - public ItemStack getTridentStack(Trident trident) { - EntityThrownTrident t = ((CraftTrident) trident).getHandle(); - return CraftItemStack.asBukkitCopy(t.trident); - } -} \ No newline at end of file diff --git a/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/BlockBreak.java b/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/BlockBreak.java deleted file mode 100644 index 11902a6..0000000 --- a/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/BlockBreak.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.illusioner.v1_16_R3; - -import com.willfp.illusioner.nms.api.BlockBreakWrapper; -import net.minecraft.server.v1_16_R3.BlockPosition; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class BlockBreak implements BlockBreakWrapper { - @Override - public void breakBlock(Player player, Block block) { - ((CraftPlayer)player).getHandle().playerInteractManager.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ())); - } -} diff --git a/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/Cooldown.java b/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/Cooldown.java deleted file mode 100644 index 92f2d98..0000000 --- a/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/Cooldown.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.illusioner.v1_16_R3; - -import com.willfp.illusioner.nms.api.CooldownWrapper; -import org.bukkit.entity.Player; - -public class Cooldown implements CooldownWrapper { - @Override - public double getAttackCooldown(Player player) { - return player.getAttackCooldown(); - } -} diff --git a/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/OpenInventory.java b/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/OpenInventory.java deleted file mode 100644 index 970fe74..0000000 --- a/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/OpenInventory.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.willfp.illusioner.v1_16_R3; - -import com.willfp.illusioner.nms.api.OpenInventoryWrapper; -import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class OpenInventory implements OpenInventoryWrapper { - @Override - public Object getOpenInventory(Player player) { - return ((CraftPlayer) player).getHandle().activeContainer; - } -} diff --git a/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/TridentStack.java b/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/TridentStack.java deleted file mode 100644 index 54fdfce..0000000 --- a/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/TridentStack.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.illusioner.v1_16_R3; - -import com.willfp.illusioner.nms.api.TridentStackWrapper; -import net.minecraft.server.v1_16_R3.EntityThrownTrident; -import org.bukkit.craftbukkit.v1_16_R3.entity.CraftTrident; -import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack; -import org.bukkit.entity.Trident; -import org.bukkit.inventory.ItemStack; - -public class TridentStack implements TridentStackWrapper { - @Override - public ItemStack getTridentStack(Trident trident) { - EntityThrownTrident t = ((CraftTrident) trident).getHandle(); - return CraftItemStack.asBukkitCopy(t.trident); - } -} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/illusioner/events/armorequip/ArmorEquipEvent.java b/Plugin/src/main/java/com/willfp/illusioner/events/armorequip/ArmorEquipEvent.java deleted file mode 100644 index ce1ceb0..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/events/armorequip/ArmorEquipEvent.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.willfp.illusioner.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/illusioner/events/armorequip/ArmorListener.java b/Plugin/src/main/java/com/willfp/illusioner/events/armorequip/ArmorListener.java deleted file mode 100644 index 09bc503..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/events/armorequip/ArmorListener.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.willfp.illusioner.events.armorequip; - -import com.willfp.illusioner.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.ClickType; -import org.bukkit.event.inventory.InventoryAction; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.event.inventory.InventoryType; -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/illusioner/events/armorequip/ArmorType.java b/Plugin/src/main/java/com/willfp/illusioner/events/armorequip/ArmorType.java deleted file mode 100644 index 63e4689..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/events/armorequip/ArmorType.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.willfp.illusioner.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/illusioner/events/armorequip/DispenserArmorListener.java b/Plugin/src/main/java/com/willfp/illusioner/events/armorequip/DispenserArmorListener.java deleted file mode 100644 index 32f8bf7..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/events/armorequip/DispenserArmorListener.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.willfp.illusioner.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/illusioner/events/naturalexpgainevent/NaturalExpGainBuilder.java b/Plugin/src/main/java/com/willfp/illusioner/events/naturalexpgainevent/NaturalExpGainBuilder.java deleted file mode 100644 index 294a7ce..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/events/naturalexpgainevent/NaturalExpGainBuilder.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.willfp.illusioner.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; - - public NaturalExpGainBuilder() { - - } - - 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 void push() { - if(this.event == null) return; - if(this.cancelled) return; - - NaturalExpGainEvent naturalExpGainEvent = new NaturalExpGainEvent(event); - - Bukkit.getPluginManager().callEvent(naturalExpGainEvent); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/events/naturalexpgainevent/NaturalExpGainEvent.java b/Plugin/src/main/java/com/willfp/illusioner/events/naturalexpgainevent/NaturalExpGainEvent.java deleted file mode 100644 index 7c4a83c..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/events/naturalexpgainevent/NaturalExpGainEvent.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.willfp.illusioner.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/illusioner/events/naturalexpgainevent/NaturalExpGainListeners.java b/Plugin/src/main/java/com/willfp/illusioner/events/naturalexpgainevent/NaturalExpGainListeners.java deleted file mode 100644 index b25f9b8..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/events/naturalexpgainevent/NaturalExpGainListeners.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.willfp.illusioner.events.naturalexpgainevent; - -import com.willfp.illusioner.IllusionerPlugin; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.ExpBottleEvent; -import org.bukkit.event.player.PlayerExpChangeEvent; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; - -public class NaturalExpGainListeners implements Listener { - - final Set events = new HashSet<>(); - - @EventHandler - public void onExpChange(PlayerExpChangeEvent event) { - NaturalExpGainBuilder builtEvent = new NaturalExpGainBuilder(); - builtEvent.setEvent(event); - - AtomicBoolean isNatural = new AtomicBoolean(true); - AtomicReference atomicBuiltEvent = new AtomicReference<>(); - - Set eventsClone = new HashSet<>(events); - eventsClone.forEach((builder) -> { - if(builder.getLoc().getWorld().getNearbyEntities(builder.getLoc(), 7.25, 7.25, 7.25).contains(event.getPlayer())) { - events.remove(builder); - isNatural.set(false); - atomicBuiltEvent.set(builder); - } - }); - - if(isNatural.get()) { - events.remove(atomicBuiltEvent.get()); - builtEvent.push(); - } - - new BukkitRunnable() { - @Override - public void run() { - events.remove(builtEvent); - } - }.runTaskLater(IllusionerPlugin.getInstance(), 1); - } - - @EventHandler - public void onExpBottle(ExpBottleEvent event) { - NaturalExpGainBuilder builtEvent = new NaturalExpGainBuilder(); - builtEvent.setLoc(event.getEntity().getLocation()); - - events.add(builtEvent); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/nms/BlockBreak.java b/Plugin/src/main/java/com/willfp/illusioner/nms/BlockBreak.java deleted file mode 100644 index 2eda5af..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/nms/BlockBreak.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.willfp.illusioner.nms; - -import com.willfp.illusioner.IllusionerPlugin; -import com.willfp.illusioner.nms.api.BlockBreakWrapper; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.ApiStatus; - -/** - * Utility class to break a block as if the player had done it manually - */ -public class BlockBreak { - private static BlockBreakWrapper blockBreakWrapper; - - @ApiStatus.Internal - public static boolean init() { - try { - final Class class2 = Class.forName("com.willfp.illusioner." + IllusionerPlugin.NMS_VERSION + ".BlockBreak"); - if (BlockBreakWrapper.class.isAssignableFrom(class2)) { - blockBreakWrapper = (BlockBreakWrapper) class2.getConstructor().newInstance(); - } - } catch (Exception e) { - e.printStackTrace(); - blockBreakWrapper = null; - } - return blockBreakWrapper != null; - } - - /** - * 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) { - assert blockBreakWrapper != null; - blockBreakWrapper.breakBlock(player, block); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/nms/Cooldown.java b/Plugin/src/main/java/com/willfp/illusioner/nms/Cooldown.java deleted file mode 100644 index d42223a..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/nms/Cooldown.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.willfp.illusioner.nms; - -import com.willfp.illusioner.IllusionerPlugin; -import com.willfp.illusioner.nms.api.CooldownWrapper; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.ApiStatus; - -/** - * Utility class to get the attack cooldown of a player - */ -public class Cooldown { - private static CooldownWrapper cooldown; - - @ApiStatus.Internal - public static boolean init() { - try { - final Class class2 = Class.forName("com.willfp.illusioner." + IllusionerPlugin.NMS_VERSION + ".Cooldown"); - if (CooldownWrapper.class.isAssignableFrom(class2)) { - cooldown = (CooldownWrapper) class2.getConstructor().newInstance(); - } - } catch (Exception e) { - e.printStackTrace(); - cooldown = null; - } - return cooldown != null; - } - - /** - * 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) { - assert cooldown != null; - return cooldown.getAttackCooldown(player); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/nms/OpenInventory.java b/Plugin/src/main/java/com/willfp/illusioner/nms/OpenInventory.java deleted file mode 100644 index 2c29a21..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/nms/OpenInventory.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.willfp.illusioner.nms; - -import com.willfp.illusioner.IllusionerPlugin; -import com.willfp.illusioner.nms.api.OpenInventoryWrapper; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.ApiStatus; - -/** - * Utility class to get the NMS implementation of a players' currently open inventory - */ -public class OpenInventory { - private static OpenInventoryWrapper openInventoryWrapper; - - @ApiStatus.Internal - public static boolean init() { - try { - final Class class2 = Class.forName("com.willfp.illusioner." + IllusionerPlugin.NMS_VERSION + ".OpenInventory"); - if (OpenInventoryWrapper.class.isAssignableFrom(class2)) { - openInventoryWrapper = (OpenInventoryWrapper) class2.getConstructor().newInstance(); - } - } catch (Exception e) { - e.printStackTrace(); - openInventoryWrapper = null; - } - return openInventoryWrapper != null; - } - - /** - * Get the NMS container of the inventory - * - * @param player The player to check - * @return The NMS container - */ - public static Object getOpenInventory(Player player) { - assert openInventoryWrapper != null; - return openInventoryWrapper.getOpenInventory(player); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/nms/TridentStack.java b/Plugin/src/main/java/com/willfp/illusioner/nms/TridentStack.java deleted file mode 100644 index 48a4b8b..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/nms/TridentStack.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.illusioner.nms; - - -import com.willfp.illusioner.IllusionerPlugin; -import com.willfp.illusioner.nms.api.TridentStackWrapper; -import org.bukkit.entity.Trident; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.ApiStatus; - -/** - * Utility class to get the {@link ItemStack} of a given {@link Trident} - */ -public class TridentStack { - private static TridentStackWrapper tridentStackWrapper; - - @ApiStatus.Internal - public static boolean init() { - try { - final Class class2 = Class.forName("com.willfp.illusioner." + IllusionerPlugin.NMS_VERSION + ".TridentStack"); - if (TridentStackWrapper.class.isAssignableFrom(class2)) { - tridentStackWrapper = (TridentStackWrapper) class2.getConstructor().newInstance(); - } - } catch (Exception e) { - e.printStackTrace(); - tridentStackWrapper = null; - } - return tridentStackWrapper != null; - } - - /** - * 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) { - assert tridentStackWrapper != null; - return tridentStackWrapper.getTridentStack(trident); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/util/BlockUtils.java b/Plugin/src/main/java/com/willfp/illusioner/util/BlockUtils.java deleted file mode 100644 index bcc4a52..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/util/BlockUtils.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.willfp.illusioner.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/illusioner/util/ClassUtils.java b/Plugin/src/main/java/com/willfp/illusioner/util/ClassUtils.java deleted file mode 100644 index a0360aa..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/util/ClassUtils.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.willfp.illusioner.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/illusioner/util/DurabilityUtils.java b/Plugin/src/main/java/com/willfp/illusioner/util/DurabilityUtils.java deleted file mode 100644 index 821ce7f..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/util/DurabilityUtils.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.willfp.illusioner.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/illusioner/util/LightningUtils.java b/Plugin/src/main/java/com/willfp/illusioner/util/LightningUtils.java deleted file mode 100644 index 6a6c209..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/util/LightningUtils.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.illusioner.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/illusioner/util/VectorUtils.java b/Plugin/src/main/java/com/willfp/illusioner/util/VectorUtils.java deleted file mode 100644 index 7914328..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/util/VectorUtils.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.willfp.illusioner.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/illusioner/util/interfaces/ObjectBiCallable.java b/Plugin/src/main/java/com/willfp/illusioner/util/interfaces/ObjectBiCallable.java deleted file mode 100644 index 06404e2..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/util/interfaces/ObjectBiCallable.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.willfp.illusioner.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/illusioner/util/interfaces/ObjectCallable.java b/Plugin/src/main/java/com/willfp/illusioner/util/interfaces/ObjectCallable.java deleted file mode 100644 index 16fc3ba..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/util/interfaces/ObjectCallable.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.illusioner.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/illusioner/util/internal/Loader.java b/Plugin/src/main/java/com/willfp/illusioner/util/internal/Loader.java index fc56885..b3e204a 100644 --- a/Plugin/src/main/java/com/willfp/illusioner/util/internal/Loader.java +++ b/Plugin/src/main/java/com/willfp/illusioner/util/internal/Loader.java @@ -4,21 +4,13 @@ import com.willfp.illusioner.IllusionerPlugin; import com.willfp.illusioner.command.commands.CommandIldebug; import com.willfp.illusioner.command.commands.CommandIlreload; import com.willfp.illusioner.config.ConfigManager; -import com.willfp.illusioner.events.armorequip.ArmorListener; -import com.willfp.illusioner.events.armorequip.DispenserArmorListener; -import com.willfp.illusioner.events.entitydeathbyentity.EntityDeathByEntityListeners; -import com.willfp.illusioner.events.naturalexpgainevent.NaturalExpGainListeners; import com.willfp.illusioner.illusioner.IllusionerManager; import com.willfp.illusioner.illusioner.listeners.AttackListeners; import com.willfp.illusioner.illusioner.listeners.DeathListeners; import com.willfp.illusioner.illusioner.listeners.SpawnListeners; import com.willfp.illusioner.integrations.ecoenchants.EcoEnchantsManager; import com.willfp.illusioner.integrations.ecoenchants.plugins.EcoEnchantsIntegrationImpl; -import com.willfp.illusioner.nms.BlockBreak; -import com.willfp.illusioner.nms.Cooldown; import com.willfp.illusioner.nms.NMSIllusioner; -import com.willfp.illusioner.nms.OpenInventory; -import com.willfp.illusioner.nms.TridentStack; import com.willfp.illusioner.util.interfaces.Callable; import com.willfp.illusioner.util.internal.updater.PlayerJoinListener; import com.willfp.illusioner.util.internal.updater.UpdateChecker; @@ -62,38 +54,6 @@ public class Loader { Logger.info("Loading NMS APIs..."); - if (Cooldown.init()) { - Logger.info("Cooldown: &aSUCCESS"); - } else { - Logger.info("Cooldown: &cFAILURE"); - Logger.error("&cAborting..."); - Bukkit.getPluginManager().disablePlugin(IllusionerPlugin.getInstance()); - } - - if (TridentStack.init()) { - Logger.info("Trident API: &aSUCCESS"); - } else { - Logger.info("Trident API: &cFAILURE"); - Logger.error("&cAborting..."); - Bukkit.getPluginManager().disablePlugin(IllusionerPlugin.getInstance()); - } - - if (BlockBreak.init()) { - Logger.info("Block Break: &aSUCCESS"); - } else { - Logger.info("Block Break: &cFAILURE"); - Logger.error("&cAborting..."); - Bukkit.getPluginManager().disablePlugin(IllusionerPlugin.getInstance()); - } - - if (OpenInventory.init()) { - Logger.info("Open Inventory: &aSUCCESS"); - } else { - Logger.info("Open Inventory: &cFAILURE"); - Logger.error("&cAborting..."); - Bukkit.getPluginManager().disablePlugin(IllusionerPlugin.getInstance()); - } - if (NMSIllusioner.init()) { Logger.info("NMS Illusioner: &aSUCCESS"); } else { @@ -134,11 +94,7 @@ public class Loader { */ Logger.info("Registering Events..."); - Bukkit.getPluginManager().registerEvents(new ArmorListener(), IllusionerPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new DispenserArmorListener(), IllusionerPlugin.getInstance()); Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(), IllusionerPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new EntityDeathByEntityListeners(), IllusionerPlugin.getInstance()); - Bukkit.getPluginManager().registerEvents(new NaturalExpGainListeners(), IllusionerPlugin.getInstance()); Bukkit.getPluginManager().registerEvents(new AttackListeners(), IllusionerPlugin.getInstance()); Bukkit.getPluginManager().registerEvents(new DeathListeners(), IllusionerPlugin.getInstance()); Bukkit.getPluginManager().registerEvents(new SpawnListeners(), IllusionerPlugin.getInstance()); diff --git a/Plugin/src/main/java/com/willfp/illusioner/util/tuplets/Triplet.java b/Plugin/src/main/java/com/willfp/illusioner/util/tuplets/Triplet.java deleted file mode 100644 index 9425dbd..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/util/tuplets/Triplet.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.willfp.illusioner.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 + - '}'; - } -}