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 @@ -367,6 +367,10 @@ public SpawnerStorageUI getSpawnerStorageUI() {
return spawnerStorageUI;
}

public SpawnerManager getSpawnerManager() {
return spawnerManager;
}

public SpawnerRangeChecker getRangeChecker() {
return rangeChecker;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ public void onPlayerQuit(PlayerQuitEvent event) {
* Opens the filter configuration GUI for a player and spawner
*/
public void openFilterConfigGUI(Player player, SpawnerData spawner) {
// Validate that the spawner still exists before opening the GUI
if (plugin.getSpawnerManager().isGhostSpawner(spawner)) {
// Spawner no longer exists, do not open the GUI
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 0.8f, 0.5f);
return;
}

// Create a new inventory with title from language manager
String title = languageManager.getGuiTitle("gui_title_filter_config");
Inventory filterInventory = Bukkit.createInventory(
Expand Down Expand Up @@ -222,6 +229,15 @@ public void onFilterInventoryClick(InventoryClickEvent event) {
}

SpawnerData spawner = holder.getSpawnerData();

// Validate that the spawner still exists before processing any actions
if (plugin.getSpawnerManager().isGhostSpawner(spawner)) {
// Spawner no longer exists, close the inventory
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 0.8f, 0.5f);
player.closeInventory();
return;
}

int slot = event.getRawSlot();

// Handle divider clicks (return to storage)
Expand All @@ -248,6 +264,14 @@ public void onFilterInventoryClick(InventoryClickEvent event) {
* Returns to the spawner storage UI
*/
private void returnToStorage(Player player, SpawnerData spawner) {
// Validate that the spawner still exists before allowing navigation
if (plugin.getSpawnerManager().isGhostSpawner(spawner)) {
// Spawner no longer exists, close the inventory and prevent navigation
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 0.8f, 0.5f);
player.closeInventory();
return;
}

// Return to storage menu
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 0.8f, 1.0f);
player.closeInventory();
Expand Down