From 669313395b276de4adb0245e9d1e25e3e0134c1f Mon Sep 17 00:00:00 2001 From: Ryder Belserion Date: Fri, 30 Aug 2024 15:54:45 -0400 Subject: [PATCH] deprecate old PlayerPrizeEvent --- .../java/com/badbones69/crazycrates/api/PrizeManager.java | 2 +- .../crazycrates/api/events/PlayerPrizeEvent.java | 7 ++++++- .../crazycrates/listeners/crates/CosmicCrateListener.java | 2 +- .../crazycrates/listeners/crates/MobileCrateListener.java | 2 +- .../crazycrates/listeners/crates/WarCrateListener.java | 2 +- .../crazycrates/tasks/crates/types/QuickCrate.java | 4 ++-- .../crazycrates/tasks/crates/types/WonderCrate.java | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/badbones69/crazycrates/api/PrizeManager.java b/src/main/java/com/badbones69/crazycrates/api/PrizeManager.java index 081117a1c..e460b7878 100644 --- a/src/main/java/com/badbones69/crazycrates/api/PrizeManager.java +++ b/src/main/java/com/badbones69/crazycrates/api/PrizeManager.java @@ -180,7 +180,7 @@ public static void givePrize(@NotNull final Player player, @NotNull final Crate if (prize.useFireworks()) MiscUtils.spawnFirework(player.getLocation().add(0, 1, 0), null); - plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, crate.getFileName(), prize)); + plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, prize)); } else { Messages.prize_error.sendMessage(player, new HashMap<>() {{ put("{crate}", crate.getCrateName()); diff --git a/src/main/java/com/badbones69/crazycrates/api/events/PlayerPrizeEvent.java b/src/main/java/com/badbones69/crazycrates/api/events/PlayerPrizeEvent.java index 6c8747e27..655e55a17 100644 --- a/src/main/java/com/badbones69/crazycrates/api/events/PlayerPrizeEvent.java +++ b/src/main/java/com/badbones69/crazycrates/api/events/PlayerPrizeEvent.java @@ -14,13 +14,18 @@ public class PlayerPrizeEvent extends Event { private final Crate crate; private final Prize prize; private final String crateName; - + + @Deprecated(since = "3.8", forRemoval = true) public PlayerPrizeEvent(@NotNull final Player player, @NotNull final Crate crate, @NotNull final String crateName, @NotNull final Prize prize) { this.player = player; this.crate = crate; this.prize = prize; this.crateName = crateName; } + + public PlayerPrizeEvent(@NotNull final Player player, @NotNull final Crate crate, @NotNull final Prize prize) { + this(player, crate, crate.getFileName(), prize); + } public static HandlerList getHandlerList() { return handlers; diff --git a/src/main/java/com/badbones69/crazycrates/listeners/crates/CosmicCrateListener.java b/src/main/java/com/badbones69/crazycrates/listeners/crates/CosmicCrateListener.java index f5d0846bf..ea17bccc9 100644 --- a/src/main/java/com/badbones69/crazycrates/listeners/crates/CosmicCrateListener.java +++ b/src/main/java/com/badbones69/crazycrates/listeners/crates/CosmicCrateListener.java @@ -113,7 +113,7 @@ public void onPrizeReceive(InventoryClickEvent event) { PrizeManager.givePrize(player, prize, crate); - this.plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, crate.getFileName(), prize)); + this.plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, prize)); event.setCurrentItem(prize.getDisplayItem(player)); diff --git a/src/main/java/com/badbones69/crazycrates/listeners/crates/MobileCrateListener.java b/src/main/java/com/badbones69/crazycrates/listeners/crates/MobileCrateListener.java index fdc0bd54a..b23f27bf7 100644 --- a/src/main/java/com/badbones69/crazycrates/listeners/crates/MobileCrateListener.java +++ b/src/main/java/com/badbones69/crazycrates/listeners/crates/MobileCrateListener.java @@ -65,7 +65,7 @@ public void onCrateUse(PlayerInteractEvent event) { PrizeManager.givePrize(player, prize, crate); - this.plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, this.crateManager.getOpeningCrate(player).getFileName(), prize)); + this.plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, prize)); if (prize.useFireworks()) MiscUtils.spawnFirework(player.getLocation().add(0, 1, 0), null); diff --git a/src/main/java/com/badbones69/crazycrates/listeners/crates/WarCrateListener.java b/src/main/java/com/badbones69/crazycrates/listeners/crates/WarCrateListener.java index 4cb26f3f0..a99ecfb45 100644 --- a/src/main/java/com/badbones69/crazycrates/listeners/crates/WarCrateListener.java +++ b/src/main/java/com/badbones69/crazycrates/listeners/crates/WarCrateListener.java @@ -58,7 +58,7 @@ public void onInventoryClick(InventoryClickEvent event) { if (prize.useFireworks()) MiscUtils.spawnFirework(player.getLocation().add(0, 1, 0), null); - this.plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, crate.getFileName(), prize)); + this.plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, prize)); this.crateManager.removePlayerFromOpeningList(player); crate.playSound(player, player.getLocation(), "cycle-sound", "block.anvil.land", Sound.Source.PLAYER); diff --git a/src/main/java/com/badbones69/crazycrates/tasks/crates/types/QuickCrate.java b/src/main/java/com/badbones69/crazycrates/tasks/crates/types/QuickCrate.java index 33782d07a..32694bdbf 100644 --- a/src/main/java/com/badbones69/crazycrates/tasks/crates/types/QuickCrate.java +++ b/src/main/java/com/badbones69/crazycrates/tasks/crates/types/QuickCrate.java @@ -90,7 +90,7 @@ public void open(@NotNull final KeyType type, final boolean checkHand) { Prize prize = crate.pickPrize(player); PrizeManager.givePrize(player, prize, crate); - this.plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, fileName, prize)); + this.plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, prize)); if (prize.useFireworks()) MiscUtils.spawnFirework(getLocation().clone().add(.5, 1, .5), null); @@ -135,7 +135,7 @@ public void open(@NotNull final KeyType type, final boolean checkHand) { Prize prize = crate.pickPrize(player, getLocation().clone().add(.5, 1.3, .5)); PrizeManager.givePrize(player, prize, crate); - this.plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, fileName, prize)); + this.plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, prize)); final boolean showQuickCrateItem = ConfigManager.getConfig().getProperty(ConfigKeys.show_quickcrate_item); diff --git a/src/main/java/com/badbones69/crazycrates/tasks/crates/types/WonderCrate.java b/src/main/java/com/badbones69/crazycrates/tasks/crates/types/WonderCrate.java index 378de3520..7f31ecaab 100644 --- a/src/main/java/com/badbones69/crazycrates/tasks/crates/types/WonderCrate.java +++ b/src/main/java/com/badbones69/crazycrates/tasks/crates/types/WonderCrate.java @@ -122,7 +122,7 @@ public void run() { if (this.prize.useFireworks()) MiscUtils.spawnFirework(getPlayer().getLocation().add(0, 1, 0), null); - plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, fileName, this.prize)); + plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, this.prize)); crateManager.removePlayerFromOpeningList(player);