Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ private Map<String, String> 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));

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

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

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

Expand Down