Skip to content

Commit

Permalink
add isCyclePrize to other crate types
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Sep 28, 2024
1 parent 6e3b34b commit 35c4bc1
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);

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

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

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

0 comments on commit 35c4bc1

Please sign in to comment.