Skip to content

Commit

Permalink
deprecate old PlayerPrizeEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Aug 30, 2024
1 parent 96f1e6e commit 6693133
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 6693133

Please sign in to comment.