From 35c4bc189c532a10358fc107930f9628428a2d6f Mon Sep 17 00:00:00 2001 From: Ryder Belserion Date: Fri, 27 Sep 2024 20:05:37 -0400 Subject: [PATCH] add isCyclePrize to other crate types --- .../tasks/crates/types/CrateOnTheGo.java | 15 ++++++++++++++- .../tasks/crates/types/QuickCrate.java | 15 ++++++++++++++- .../tasks/crates/types/RouletteCrate.java | 12 ++++++++++++ .../tasks/crates/types/WheelCrate.java | 9 +++++++++ .../tasks/crates/types/WonderCrate.java | 11 +++++++++++ 5 files changed, 60 insertions(+), 2 deletions(-) diff --git a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/CrateOnTheGo.java b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/CrateOnTheGo.java index 71ca6c5ee..661436fd2 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/CrateOnTheGo.java +++ b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/CrateOnTheGo.java @@ -1,8 +1,11 @@ package com.badbones69.crazycrates.tasks.crates.types; +import com.badbones69.crazycrates.api.builders.types.features.CrateSpinMenu; +import com.badbones69.crazycrates.api.enums.misc.Files; import com.badbones69.crazycrates.api.objects.Crate; import com.badbones69.crazycrates.api.objects.Prize; import com.badbones69.crazycrates.api.PrizeManager; +import com.badbones69.crazycrates.api.objects.gui.GuiSettings; import com.badbones69.crazycrates.managers.events.enums.EventType; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; @@ -39,7 +42,17 @@ public void open(@NotNull final KeyType type, final boolean checkHand, final boo } final Prize prize = crate.pickPrize(player); - PrizeManager.givePrize(player, prize, crate); + + if (crate.isCyclePrize()) { // re-open this menu + new CrateSpinMenu(player, new GuiSettings(crate, prize, Files.respin_gui.getConfiguration())).open(); + + this.crateManager.removePlayerFromOpeningList(player); + this.crateManager.removePlayerKeyType(player); + + return; + } + + PrizeManager.givePrize(player, crate, prize); if (prize.useFireworks()) MiscUtils.spawnFirework(player.getLocation().add(0, 1, 0), null); diff --git a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/QuickCrate.java b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/QuickCrate.java index 9c1b20104..f8d060bbe 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/QuickCrate.java +++ b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/QuickCrate.java @@ -1,12 +1,15 @@ package com.badbones69.crazycrates.tasks.crates.types; +import com.badbones69.crazycrates.api.builders.types.features.CrateSpinMenu; import com.badbones69.crazycrates.api.enums.Messages; +import com.badbones69.crazycrates.api.enums.misc.Files; import com.badbones69.crazycrates.api.events.PlayerPrizeEvent; import com.badbones69.crazycrates.api.objects.Crate; import com.badbones69.crazycrates.api.objects.Prize; import com.badbones69.crazycrates.api.ChestManager; import com.badbones69.crazycrates.api.PrizeManager; import com.badbones69.crazycrates.api.objects.crates.CrateLocation; +import com.badbones69.crazycrates.api.objects.gui.GuiSettings; import com.badbones69.crazycrates.managers.events.enums.EventType; import com.badbones69.crazycrates.support.holograms.HologramManager; import com.ryderbelserion.vital.paper.util.AdvUtil; @@ -124,7 +127,17 @@ public void open(@NotNull final KeyType type, final boolean checkHand, final boo } Prize prize = crate.pickPrize(player, getLocation().clone().add(.5, 1.3, .5)); - PrizeManager.givePrize(player, prize, crate); + + if (crate.isCyclePrize()) { // re-open this menu + new CrateSpinMenu(player, new GuiSettings(crate, prize, Files.respin_gui.getConfiguration())).open(); + + this.crateManager.removePlayerFromOpeningList(player); + this.crateManager.removeCrateInUse(player); + + return; + } + + PrizeManager.givePrize(player, crate, prize); this.plugin.getServer().getPluginManager().callEvent(new PlayerPrizeEvent(player, crate, prize)); diff --git a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/RouletteCrate.java b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/RouletteCrate.java index 5c8f39abf..ee113352c 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/RouletteCrate.java +++ b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/RouletteCrate.java @@ -1,8 +1,11 @@ package com.badbones69.crazycrates.tasks.crates.types; +import com.badbones69.crazycrates.api.builders.types.features.CrateSpinMenu; +import com.badbones69.crazycrates.api.enums.misc.Files; import com.badbones69.crazycrates.api.objects.Crate; import com.badbones69.crazycrates.api.objects.Prize; import com.badbones69.crazycrates.api.PrizeManager; +import com.badbones69.crazycrates.api.objects.gui.GuiSettings; import com.badbones69.crazycrates.managers.events.enums.EventType; import com.ryderbelserion.vital.paper.util.scheduler.FoliaRunnable; import net.kyori.adventure.sound.Sound; @@ -100,6 +103,15 @@ public void run() { if (item != null) { Prize prize = crate.getPrize(item); + + if (crate.isCyclePrize()) { // re-open this menu + new CrateSpinMenu(player, new GuiSettings(crate, prize, Files.respin_gui.getConfiguration())).open(); + + crateManager.removePlayerFromOpeningList(player); + + return; + } + PrizeManager.givePrize(player, crate, prize); } diff --git a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/WheelCrate.java b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/WheelCrate.java index 793b0c408..9bdded813 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/WheelCrate.java +++ b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/WheelCrate.java @@ -1,8 +1,11 @@ package com.badbones69.crazycrates.tasks.crates.types; +import com.badbones69.crazycrates.api.builders.types.features.CrateSpinMenu; +import com.badbones69.crazycrates.api.enums.misc.Files; import com.badbones69.crazycrates.api.objects.Crate; import com.badbones69.crazycrates.api.objects.Prize; import com.badbones69.crazycrates.api.PrizeManager; +import com.badbones69.crazycrates.api.objects.gui.GuiSettings; import com.badbones69.crazycrates.managers.events.enums.EventType; import com.ryderbelserion.vital.paper.util.scheduler.FoliaRunnable; import net.kyori.adventure.sound.Sound; @@ -116,6 +119,12 @@ public void run() { prize = crate.getPrize(rewards.get(this.slots.get(this.what))); } + if (crate.isCyclePrize()) { // re-open this menu + new CrateSpinMenu(player, new GuiSettings(crate, prize, Files.respin_gui.getConfiguration())).open(); + + return; + } + PrizeManager.givePrize(player, crate, prize); playSound("stop-sound", Sound.Source.PLAYER, "entity.player.levelup"); diff --git a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/WonderCrate.java b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/WonderCrate.java index b103c4805..219ed4a67 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/WonderCrate.java +++ b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/WonderCrate.java @@ -1,10 +1,13 @@ package com.badbones69.crazycrates.tasks.crates.types; +import com.badbones69.crazycrates.api.builders.types.features.CrateSpinMenu; +import com.badbones69.crazycrates.api.enums.misc.Files; import com.badbones69.crazycrates.api.events.PlayerPrizeEvent; import com.badbones69.crazycrates.api.objects.Crate; import com.badbones69.crazycrates.api.objects.Prize; import com.badbones69.crazycrates.api.PrizeManager; import com.badbones69.crazycrates.api.builders.ItemBuilder; +import com.badbones69.crazycrates.api.objects.gui.GuiSettings; import com.badbones69.crazycrates.managers.events.enums.EventType; import com.ryderbelserion.vital.paper.util.scheduler.FoliaRunnable; import com.badbones69.crazycrates.managers.BukkitUserManager; @@ -117,6 +120,14 @@ public void run() { getPlayer().closeInventory(InventoryCloseEvent.Reason.UNLOADED); + if (crate.isCyclePrize()) { // re-open this menu + new CrateSpinMenu(player, new GuiSettings(crate, prize, Files.respin_gui.getConfiguration())).open(); + + crateManager.removePlayerFromOpeningList(player); + + return; + } + PrizeManager.givePrize(player, this.prize, crate); playSound("stop-sound", Sound.Source.PLAYER, "entity.player.levelup");