diff --git a/core/src/main/java/github/nighter/smartspawner/spawner/gui/main/SpawnerMenuFormUI.java b/core/src/main/java/github/nighter/smartspawner/spawner/gui/main/SpawnerMenuFormUI.java index 34131b40..69c4b693 100644 --- a/core/src/main/java/github/nighter/smartspawner/spawner/gui/main/SpawnerMenuFormUI.java +++ b/core/src/main/java/github/nighter/smartspawner/spawner/gui/main/SpawnerMenuFormUI.java @@ -340,6 +340,10 @@ private Map createPlaceholders(SpawnerData spawner) { placeholders.put("percentage_exp", formattedPercentExp); // Total sell price information + // Check if sell value needs recalculation before displaying + if (spawner.isSellValueDirty()) { + spawner.recalculateSellValue(); + } double totalSellPrice = spawner.getAccumulatedSellValue(); placeholders.put("total_sell_price", languageManager.formatNumber(totalSellPrice)); diff --git a/core/src/main/java/github/nighter/smartspawner/spawner/gui/main/SpawnerMenuUI.java b/core/src/main/java/github/nighter/smartspawner/spawner/gui/main/SpawnerMenuUI.java index 6d906c67..a71d3fd8 100644 --- a/core/src/main/java/github/nighter/smartspawner/spawner/gui/main/SpawnerMenuUI.java +++ b/core/src/main/java/github/nighter/smartspawner/spawner/gui/main/SpawnerMenuUI.java @@ -362,6 +362,10 @@ public ItemStack createSpawnerInfoItem(Player player, SpawnerData spawner) { placeholders.put("percentage_exp", formattedPercentExp); // Total sell price information + // Check if sell value needs recalculation before displaying + if (spawner.isSellValueDirty()) { + spawner.recalculateSellValue(); + } double totalSellPrice = spawner.getAccumulatedSellValue(); placeholders.put("total_sell_price", languageManager.formatNumber(totalSellPrice)); diff --git a/core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/SpawnerStorageUI.java b/core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/SpawnerStorageUI.java index 8cf58c33..7192577e 100644 --- a/core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/SpawnerStorageUI.java +++ b/core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/SpawnerStorageUI.java @@ -331,6 +331,10 @@ private ItemStack createNavigationButton(String type, int targetPage, Material m private ItemStack createSellButton(SpawnerData spawner, Material material) { // Create placeholders for total sell price Map placeholders = new HashMap<>(); + // Check if sell value needs recalculation before displaying + if (spawner.isSellValueDirty()) { + spawner.recalculateSellValue(); + } double totalSellPrice = spawner.getAccumulatedSellValue(); placeholders.put("total_sell_price", languageManager.formatNumber(totalSellPrice)); diff --git a/core/src/main/java/github/nighter/smartspawner/spawner/lootgen/SpawnerLootGenerator.java b/core/src/main/java/github/nighter/smartspawner/spawner/lootgen/SpawnerLootGenerator.java index a03adf17..2a7ecd46 100644 --- a/core/src/main/java/github/nighter/smartspawner/spawner/lootgen/SpawnerLootGenerator.java +++ b/core/src/main/java/github/nighter/smartspawner/spawner/lootgen/SpawnerLootGenerator.java @@ -125,14 +125,13 @@ public void spawnLootToSpawner(SpawnerData spawner) { return; // Skip generation if both exp and inventory are full } - // Update spawn time immediately - spawner.setLastSpawnTime(currentTime); - // Important: Store the current values we need for async processing final EntityType entityType = spawner.getEntityType(); final int minMobs = spawner.getMinMobs(); final int maxMobs = spawner.getMaxMobs(); final String spawnerId = spawner.getSpawnerId(); + // Store currentTime to update lastSpawnTime after successful loot addition + final long spawnTime = currentTime; // Run heavy calculations async and batch updates using the Scheduler Scheduler.runTaskAsync(() -> { @@ -197,6 +196,10 @@ public void spawnLootToSpawner(SpawnerData spawner) { return; } + // Update spawn time only after successful loot addition + // This prevents skipped spawns when the lock fails + spawner.setLastSpawnTime(spawnTime); + // Check if spawner is now at capacity and update status if needed spawner.updateCapacityStatus();