From 903144e460b4a8b649c8a0ac8cec8d78dedd5746 Mon Sep 17 00:00:00 2001 From: JustAHuman-xD <65748158+JustAHuman-xD@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:21:50 -0600 Subject: [PATCH] Suggestions, Formatting, and cleanup --- ...dEvent.java => TalismanActivateEvent.java} | 158 +++++++++--------- .../items/magical/talismans/Talisman.java | 9 +- 2 files changed, 79 insertions(+), 88 deletions(-) rename src/main/java/io/github/thebusybiscuit/slimefun4/api/events/{TalismanActivatedEvent.java => TalismanActivateEvent.java} (68%) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/TalismanActivatedEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/TalismanActivateEvent.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/TalismanActivatedEvent.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/api/events/TalismanActivateEvent.java index 4ded742237..3b89284eae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/TalismanActivatedEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/TalismanActivateEvent.java @@ -1,84 +1,76 @@ -package io.github.thebusybiscuit.slimefun4.api.events; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - -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 io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.Talisman; - -/** - * - * This {@link PlayerEvent} is called when a {@link Player} activates a {@link Talisman} - * - * @author cworldstar - * - */ - -public class TalismanActivatedEvent extends PlayerEvent implements Cancellable { - - private static HandlerList Handlers = new HandlerList(); - private Talisman talisman; - private ItemStack talismanItemStack; - private boolean cancelled = false; - - - /** - * - * @param player - * The {@link Player} who activated the talisman. - * - * @param talisman - * The {@link Talisman} that was activated. - * - * @param talismanItem - * The {@link ItemStack} corresponding to the Talisman. - */ - @ParametersAreNonnullByDefault - public TalismanActivatedEvent(Player player, Talisman talisman, ItemStack talismanItem) { - super(player); - this.talisman = talisman; - this.talismanItemStack = talismanItem; - } - /** - * - * @return The {@link Talisman} used. - * - */ - @Nonnull - public Talisman getTalisman() { - return this.talisman; - } - /** - * - * @return The {@link ItemStack} of the used {@link Talisman}. - */ - @Nonnull - public ItemStack getTalismanItem() { - return this.talismanItemStack; - } - - public static HandlerList getHandlerList() { - return Handlers; - } - - @Override - public HandlerList getHandlers() { - return getHandlerList(); - } - @Override - public boolean isCancelled() { - return this.cancelled; - } - @Override - public void setCancelled(boolean cancel) { - this.cancelled = cancel; - } - - - +package io.github.thebusybiscuit.slimefun4.api.events; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +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 io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.Talisman; + +/** + * This {@link PlayerEvent} is called when a {@link Player} activates a {@link Talisman} + * + * @author cworldstar + */ + +public class TalismanActivateEvent extends PlayerEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private final Talisman talisman; + private final ItemStack talismanItemStack; + private boolean cancelled = false; + + /** + * @param player + * The {@link Player} who activated the talisman. + * + * @param talisman + * The {@link Talisman} that was activated. + * + * @param talismanItem + * The {@link ItemStack} corresponding to the Talisman. + */ + @ParametersAreNonnullByDefault + public TalismanActivateEvent(Player player, Talisman talisman, ItemStack talismanItem) { + super(player); + this.talisman = talisman; + this.talismanItemStack = talismanItem; + } + + /** + * @return The {@link Talisman} used. + */ + public @Nonnull Talisman getTalisman() { + return this.talisman; + } + + /** + * @return The {@link ItemStack} of the used {@link Talisman}. + */ + public @Nonnull ItemStack getTalismanItem() { + return this.talismanItemStack; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @Override + public @Nonnull HandlerList getHandlers() { + return getHandlerList(); + } + + public static @Nonnull HandlerList getHandlerList() { + return handlers; + } } \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java index 9a0fca65a0..39bc4a1ddf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java @@ -28,7 +28,7 @@ import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.events.TalismanActivatedEvent; +import io.github.thebusybiscuit.slimefun4.api.events.TalismanActivateEvent; import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; @@ -205,14 +205,13 @@ public static boolean trigger(Event e, SlimefunItem item, boolean sendMessage) { @ParametersAreNonnullByDefault private static void activateTalisman(Event e, Player p, Inventory inv, Talisman talisman, ItemStack talismanItem, boolean sendMessage) { - TalismanActivatedEvent TalismanEvent = new TalismanActivatedEvent(p, talisman, talismanItem); - Bukkit.getPluginManager().callEvent(TalismanEvent); - if (!TalismanEvent.isCancelled()) { + TalismanActivateEvent talismanEvent = new TalismanActivateEvent(p, talisman, talismanItem); + Bukkit.getPluginManager().callEvent(talismanEvent); + if (!talismanEvent.isCancelled()) { consumeItem(inv, talisman, talismanItem); applyTalismanEffects(p, talisman); cancelEvent(e, talisman); - if (sendMessage) { talisman.sendMessage(p); }