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 @@ -86,6 +86,8 @@ public void createHologram() {
// Add custom name for identification
td.setCustomName(uniqueIdentifier);
td.setCustomNameVisible(false);
// Set persistent to false to prevent hologram from being saved and potentially getting stuck
td.setPersistent(false);
});

textDisplay.set(display);
Expand Down Expand Up @@ -115,6 +117,15 @@ public void updateText() {
replacements.put("%max_exp%", languageManager.formatNumber(maxExp));
replacements.put("%used_slots%", languageManager.formatNumber(currentItems));
replacements.put("%max_slots%", languageManager.formatNumber(maxSlots));

// Calculate and add percentage placeholders
double percentStorageDecimal = maxSlots > 0 ? ((double) currentItems / maxSlots) * 100 : 0;
String formattedPercentStorage = String.format("%.1f", percentStorageDecimal);
replacements.put("%percentage_storage%", formattedPercentStorage);

double percentExpDecimal = maxExp > 0 ? ((double) currentExp / maxExp) * 100 : 0;
String formattedPercentExp = String.format("%.1f", percentExpDecimal);
replacements.put("%percentage_exp%", formattedPercentExp);

String hologramText = languageManager.getHologramText();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ public void attemptInitialSpawnerLoad() {
if (pendingCount > 0) {
logger.info("Pending spawners will be loaded when their worlds become available.");
}

// Initialize chunk spawner limits after spawners are loaded
plugin.getChunkSpawnerLimiter().reloadConfig();
}

/**
Expand Down Expand Up @@ -180,6 +183,9 @@ private void loadPendingSpawnersForWorld(String worldName) {

if (loadedCount > 0) {
logger.info("Loaded " + loadedCount + " pending spawners for world: " + worldName);

// Reinitialize chunk spawner limits after loading pending spawners
plugin.getChunkSpawnerLimiter().reloadConfig();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ private Map<String, String> createPlaceholders(SpawnerData spawner) {

placeholders.put("current_items", String.valueOf(currentItems));
placeholders.put("max_items", languageManager.formatNumber(maxSlots));
placeholders.put("formatted_storage", formattedPercentStorage);
placeholders.put("percentage_storage", formattedPercentStorage);

// Experience information
long currentExp = spawner.getSpawnerExp();
Expand All @@ -337,7 +337,7 @@ private Map<String, String> createPlaceholders(SpawnerData spawner) {
placeholders.put("max_exp", formattedMaxExp);
placeholders.put("raw_current_exp", String.valueOf(currentExp));
placeholders.put("raw_max_exp", String.valueOf(maxExp));
placeholders.put("formatted_exp", formattedPercentExp);
placeholders.put("percentage_exp", formattedPercentExp);

// Total sell price information
double totalSellPrice = spawner.getAccumulatedSellValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public ItemStack createSpawnerInfoItem(Player player, SpawnerData spawner) {
// Storage information
placeholders.put("current_items", String.valueOf(currentItems));
placeholders.put("max_items", languageManager.formatNumber(maxSlots));
placeholders.put("formatted_storage", formattedPercentStorage);
placeholders.put("percentage_storage", formattedPercentStorage);

// Experience information
String formattedCurrentExp = languageManager.formatNumber(currentExp);
Expand All @@ -357,7 +357,7 @@ public ItemStack createSpawnerInfoItem(Player player, SpawnerData spawner) {
placeholders.put("max_exp", formattedMaxExp);
placeholders.put("raw_current_exp", String.valueOf(currentExp));
placeholders.put("raw_max_exp", String.valueOf(maxExp));
placeholders.put("formatted_exp", formattedPercentExp);
placeholders.put("percentage_exp", formattedPercentExp);

// Total sell price information
double totalSellPrice = spawner.getAccumulatedSellValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,38 @@ public void reloadAllHolograms() {
}

public void cleanupAllSpawners() {
// First, remove all holograms synchronously before clearing data
removeAllHolograms();

spawners.clear();
locationIndex.clear();
worldIndex.clear();
confirmedGhostSpawners.clear();
}

public void removeAllHolograms() {
plugin.getLogger().info("Removing all spawner holograms...");
int removed = 0;

for (SpawnerData spawner : spawners.values()) {
try {
spawner.removeHologram();
removed++;
} catch (Exception e) {
plugin.getLogger().warning("Error removing hologram for spawner " +
spawner.getSpawnerId() + ": " + e.getMessage());
}
}

// Give the scheduler time to process all removal tasks
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}

plugin.getLogger().info("Removed " + removed + " spawner holograms");
}

public int getTotalSpawners() {
return this.spawners.size();
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ hologram:
# %max_exp% - Maximum XP capacity
# %used_slots% - Used inventory slots
# %max_slots% - Total inventory slots
# %percentage_storage% - Storage usage as percentage (e.g., "75.5" for 75.5% full)
# %percentage_exp% - Experience storage as percentage (e.g., "50.0" for 50.0% full)
text:
- '[&#f8f8ff%stack_size%] &#7b68ee%ᴇɴᴛɪᴛʏ% ꜱᴘᴀᴡɴᴇʀ'
- '&#ab7afd• &#e6e6faxᴘ: &#37eb9a%current_exp%&#f8f8ff/&#37eb9a%max_exp%'
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/resources/language/DonutSMP/gui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ spawner_info_item:
name: '&#FCE300%stack_size% %ᴇɴᴛɪᴛʏ% ꜱᴘᴀᴡɴᴇʀ'
lore:
- '&#FCE300● &fClick to sell items and collect xp'
- '&#FCE300Storage:&f %formatted_storage%% &#FCE300Filled.'
- '&#FCE300Exp:&f %formatted_exp%% &#FCE300Stored.'
- '&#FCE300Storage:&f %percentage_storage%% &#FCE300Filled.'
- '&#FCE300Exp:&f %percentage_exp%% &#FCE300Stored.'
lore_no_shop:
- '&#FCE300● &fClick to collect xp'
- '&#FCE300Storage:&f %formatted_storage%% &#FCE300Filled.'
- '&#FCE300Exp:&f %formatted_exp%% &#FCE300Stored.'
- '&#FCE300Storage:&f %percentage_storage%% &#FCE300Filled.'
- '&#FCE300Exp:&f %percentage_exp%% &#FCE300Stored.'
lore_full: ''
lore_inactive: ''

Expand Down Expand Up @@ -350,10 +350,10 @@ bedrock:
- ''
- '§9◈ §fStorage:'
- ' §7• Items: §9%current_items% §7/ §9%max_items%'
- ' §7• Storage: §9%formatted_storage%% §7full'
- ' §7• Storage: §9%percentage_storage%% §7full'
- ''
- '§9◈ §fExperience:'
- ' §7• Current: §a%current_exp% §7/ §a%max_exp% §axp'
- ' §7• Stored: §a%formatted_exp%% §7xp'
- ' §7• Stored: §a%percentage_exp%% §7xp'
- ''
- '§a◈ §fSellable Value: §a+$%total_sell_price%'
8 changes: 4 additions & 4 deletions core/src/main/resources/language/de_DE/gui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ spawner_storage_item:
# %current_items% - Current number of items stored
# %max_items% - Maximum storage capacity for items
# %percent_storage% - Storage usage as integer percentage (e.g., "87")
# %formatted_storage% - Storage usage as formatted percentage with decimal (e.g., "87.5")
# %percentage_storage% - Storage usage as formatted percentage with decimal (e.g., "87.5")
#
# Experience Information:
# %current_exp% - Current experience stored (formatted with commas)
# %max_exp% - Maximum experience capacity (formatted with commas)
# %raw_current_exp% - Raw current experience number
# %raw_max_exp% - Raw maximum experience number
# %percent_exp% - Experience storage as integer percentage
# %formatted_exp% - Experience storage as formatted percentage with decimal (e.g., "42.7")
# %percentage_exp% - Experience storage as formatted percentage with decimal (e.g., "42.7")
spawner_info_item:
name: '&#3498db%ᴇɴᴛɪᴛʏ% ꜱᴘᴀᴡɴᴇʀ'
lore:
Expand Down Expand Up @@ -432,10 +432,10 @@ bedrock:
- ''
- '§9◈ §fLager:'
- ' §7• Items: §9%current_items% §7/ §9%max_items%'
- ' §7• Lager: §9%formatted_storage%% §7voll'
- ' §7• Lager: §9%percentage_storage%% §7voll'
- ''
- '§9◈ §fErfahrung:'
- ' §7• Aktuell: §a%current_exp% §7/ §a%max_exp% §aXP'
- ' §7• Gespeichert: §a%formatted_exp%% §7XP'
- ' §7• Gespeichert: §a%percentage_exp%% §7XP'
- ''
- '§a◈ §fVerkaufswert: §a+$%total_sell_price%'
12 changes: 6 additions & 6 deletions core/src/main/resources/language/en_US/gui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ spawner_storage_item:
# %current_items% - Current number of items stored
# %max_items% - Maximum storage capacity for items
# %percent_storage% - Storage usage as integer percentage (e.g., "87")
# %formatted_storage% - Storage usage as formatted percentage with decimal (e.g., "87.5")
# %percentage_storage% - Storage usage as formatted percentage with decimal (e.g., "87.5")
#
# Experience Information:
# %current_exp% - Current experience stored (formatted with commas)
# %max_exp% - Maximum experience capacity (formatted with commas)
# %raw_current_exp% - Raw current experience number
# %raw_max_exp% - Raw maximum experience number
# %percent_exp% - Experience storage as integer percentage
# %formatted_exp% - Experience storage as formatted percentage with decimal (e.g., "42.7")
# %percentage_exp% - Experience storage as formatted percentage with decimal (e.g., "42.7")
spawner_info_item:
name: '&#3498db%ᴇɴᴛɪᴛʏ% ꜱᴘᴀᴡɴᴇʀ'
lore:
Expand Down Expand Up @@ -424,8 +424,8 @@ bedrock:
# Entity: %entity%, %ᴇɴᴛɪᴛʏ%, %entity_type%
# Stack: %stack_size%
# Settings: %range%, %delay%, %delay_raw%, %min_mobs%, %max_mobs%
# Storage: %current_items%, %max_items%, %formatted_storage%
# Experience: %current_exp%, %max_exp%, %raw_current_exp%, %raw_max_exp%, %formatted_exp%
# Storage: %current_items%, %max_items%, %percentage_storage%
# Experience: %current_exp%, %max_exp%, %raw_current_exp%, %raw_max_exp%, %percentage_exp%
# Sell Price: %total_sell_price%
#
# IMPORTANT: Only use Bedrock-compatible color codes:
Expand All @@ -442,10 +442,10 @@ bedrock:
- ''
- '§9◈ §fStorage:'
- ' §7• Items: §9%current_items% §7/ §9%max_items%'
- ' §7• Storage: §9%formatted_storage%% §7full'
- ' §7• Storage: §9%percentage_storage%% §7full'
- ''
- '§9◈ §fExperience:'
- ' §7• Current: §a%current_exp% §7/ §a%max_exp% §axp'
- ' §7• Stored: §a%formatted_exp%% §7xp'
- ' §7• Stored: §a%percentage_exp%% §7xp'
- ''
- '§a◈ §fSellable Value: §a+$%total_sell_price%'
4 changes: 2 additions & 2 deletions core/src/main/resources/language/vi_VN/gui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@ bedrock:
- ''
- '§9◈ §fKho lưu trữ:'
- ' §7• Vật phẩm: §9%current_items% §7/ §9%max_items%'
- ' §7• Kho: §9%formatted_storage%% §7đầy'
- ' §7• Kho: §9%percentage_storage%% §7đầy'
- ''
- '§9◈ §fKinh nghiệm:'
- ' §7• Hiện tại: §a%current_exp% §7/ §a%max_exp% §aXP'
- ' §7• Đã lưu: §a%formatted_exp%% §7XP'
- ' §7• Đã lưu: §a%percentage_exp%% §7XP'
- ''
- '§a◈ §fGiá trị bán: §a+$%total_sell_price%'