Skip to content

Commit

Permalink
seems like it works well enough
Browse files Browse the repository at this point in the history
  • Loading branch information
dan28000 committed Aug 21, 2024
1 parent ad0e1e2 commit 5ea0c20
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -65,29 +66,20 @@ public RouletteStandard(CrateBuilder builder, List<Result> 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) {
player.playSound(UltimateMenuStuff.OPEN);
}

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)) {
Expand All @@ -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() {
Expand Down Expand Up @@ -182,4 +197,4 @@ public void skip() {
public void updateTimer() {
time = System.currentTimeMillis();
}
}
}

0 comments on commit 5ea0c20

Please sign in to comment.