diff --git a/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/gacha/GachaSystem.java b/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/gacha/GachaSystem.java index 539b6312e..98e753dfd 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/gacha/GachaSystem.java +++ b/paper/src/main/java/com/badbones69/crazycrates/api/objects/gacha/gacha/GachaSystem.java @@ -11,7 +11,6 @@ import java.util.HashSet; import java.util.Map; -import java.util.Random; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; diff --git a/paper/src/main/java/com/badbones69/crazycrates/listeners/crates/GachaCrateListener.java b/paper/src/main/java/com/badbones69/crazycrates/listeners/crates/GachaCrateListener.java index 21ba97eef..58f7ff9f2 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/listeners/crates/GachaCrateListener.java +++ b/paper/src/main/java/com/badbones69/crazycrates/listeners/crates/GachaCrateListener.java @@ -75,16 +75,21 @@ public void onInventoryClick(InventoryClickEvent event) { return; } - if (count == 10) { - int i = 0; - for (Integer slot : slots) { - inventory.setItem(slot, prize.get(i++).getPrize().getDisplayItem()); + if (rouletteStandard.isSneak()) { + if (count == 10) { + int i = 0; + for (Integer slot : slots) { + inventory.setItem(slot, prize.get(i++).getPrize().getDisplayItem()); + } + rouletteStandard.incrementCount(); + return; } + + inv.setItem(22, prize.get(count).getPrize().getDisplayItem()); rouletteStandard.incrementCount(); - return; + } else { + rouletteStandard.incrementCount(); + if (count == 1) manager.getGachaRunnables().remove(uuid); } - - inv.setItem(22, prize.get(count).getPrize().getDisplayItem()); - rouletteStandard.incrementCount(); } } \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/roulette/RouletteStandard.java b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/roulette/RouletteStandard.java index bd499f918..bce66053a 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/roulette/RouletteStandard.java +++ b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/types/roulette/RouletteStandard.java @@ -36,6 +36,7 @@ public class RouletteStandard extends FoliaRunnable { private final CrazyCrates plugin = JavaPlugin.getPlugin(CrazyCrates.class); private final CrateManager crateManager = plugin.getCrateManager(); private final Rarity highestRarity; + @Getter private final boolean sneak; private final ItemBuilder glass = new ItemBuilder(Material.GRAY_STAINED_GLASS_PANE); @Getter @@ -65,17 +66,12 @@ public RouletteStandard(CrateBuilder builder, List prize, boolean sneak) @Override public void run() { if (!player.isOnline()) { - ((GachaCrateManager) crate.getManager()).getGachaRunnables().remove(uuid); - crateManager.endCrate(player); - crateManager.removePlayerFromOpeningList(player); - cancel(); + endCrate(); return; } if (!put) { - GachaCrateManager gachaCrateManager = (GachaCrateManager) crate.getManager(); - gachaCrateManager.getGachaRunnables().putIfAbsent(uuid, this); - put = true; + putGachaRunnable(); } if (modelData == 8) { @@ -83,11 +79,7 @@ public void run() { } if (!first && !skip) { - builder.setItem(36, glass.setCustomModelData(modelData).getStack()); - for (int i = 0; i < 45; i++) { - if (i == 36 || i == 37 || i == 8) continue; - builder.setItem(i, MiscUtils.getRandomPaneColor().setCustomModelData(2000000).getStack()); - } + setupInventory(); } if (!player.getOpenInventory().getTopInventory().equals(inventory)) { @@ -103,24 +95,47 @@ public void run() { } if (modelData == 64) { - if (!first && sneak) { - first = true; - lock = true; - builder.setItem(36, glass.setCustomModelData(600).getStack()); - if (!skip) builder.setItem(22, prize.getFirst().getPrize().getDisplayItem()); - skip = true; - return; - } + handleModelData64(); + } - if (sneak) { - if (check()) return; - } + if (!lock) modelData++; + } + + private void endCrate() { + ((GachaCrateManager) crate.getManager()).getGachaRunnables().remove(uuid); + crateManager.endCrate(player); + crateManager.removePlayerFromOpeningList(player); + cancel(); + } - endTask(); - cancel(); + private void putGachaRunnable() { + GachaCrateManager gachaCrateManager = (GachaCrateManager) crate.getManager(); + gachaCrateManager.getGachaRunnables().putIfAbsent(uuid, this); + put = true; + } + + private void setupInventory() { + builder.setItem(36, glass.setCustomModelData(modelData).getStack()); + for (int i = 0; i < 45; i++) { + if (i == 36 || i == 37 || i == 8) continue; + builder.setItem(i, MiscUtils.getRandomPaneColor().setCustomModelData(2000000).getStack()); } + } - if (!lock) modelData++; + private void handleModelData64() { + if (!first) { + first = true; + lock = true; + builder.setItem(36, glass.setCustomModelData(600).getStack()); + builder.setItem(22, prize.getFirst().getPrize().getDisplayItem()); + skip = true; + return; + } + + if (check()) return; + + endTask(); + cancel(); } private int getPortalData() { @@ -182,4 +197,4 @@ public void skip() { public void updateTimer() { time = System.currentTimeMillis(); } -} +} \ No newline at end of file