diff --git a/src/main/java/com/alttd/hunger_games/services/LootService.java b/src/main/java/com/alttd/hunger_games/services/LootService.java index 5cc3c26..bd0e384 100644 --- a/src/main/java/com/alttd/hunger_games/services/LootService.java +++ b/src/main/java/com/alttd/hunger_games/services/LootService.java @@ -2,6 +2,7 @@ package com.alttd.hunger_games.services; import com.alttd.hunger_games.config.LootItems; import com.alttd.hunger_games.data_objects.RARITY; +import lombok.extern.slf4j.Slf4j; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -14,6 +15,7 @@ import java.util.List; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; +@Slf4j public class LootService { private final HashMap chestInventories = new HashMap<>(); @@ -31,16 +33,18 @@ public class LootService { private Inventory generateLoot() { Inventory inventory = Bukkit.createInventory(null, 27, Component.text("Chest")); - RARITY rarity = decideRarity(); - List possibleItems = LootItems.ITEMS.get(rarity); - - if (possibleItems.isEmpty()) { - return inventory; - } int itemCount = random.nextInt(3, 7); for (int i = 0; i < itemCount; i++) { int slot = random.nextInt(27); + RARITY rarity = decideRarity(); + List possibleItems = LootItems.ITEMS.get(rarity); + + if (possibleItems == null || possibleItems.isEmpty()) { + log.warn("No items found for rarity: {}", rarity); + continue; + } + Material material = possibleItems.get(random.nextInt(possibleItems.size())); inventory.setItem(slot, new ItemStack(material)); }