@@ -92,6 +92,13 @@ public void onPlayerQuit(PlayerQuitEvent event) {
9292 * Opens the filter configuration GUI for a player and spawner
9393 */
9494 public void openFilterConfigGUI (Player player , SpawnerData spawner ) {
95+ // Validate that the spawner still exists before opening the GUI
96+ if (plugin .getSpawnerManager ().isGhostSpawner (spawner )) {
97+ // Spawner no longer exists, do not open the GUI
98+ player .playSound (player .getLocation (), Sound .BLOCK_NOTE_BLOCK_BASS , 0.8f , 0.5f );
99+ return ;
100+ }
101+
95102 // Create a new inventory with title from language manager
96103 String title = languageManager .getGuiTitle ("gui_title_filter_config" );
97104 Inventory filterInventory = Bukkit .createInventory (
@@ -222,6 +229,15 @@ public void onFilterInventoryClick(InventoryClickEvent event) {
222229 }
223230
224231 SpawnerData spawner = holder .getSpawnerData ();
232+
233+ // Validate that the spawner still exists before processing any actions
234+ if (plugin .getSpawnerManager ().isGhostSpawner (spawner )) {
235+ // Spawner no longer exists, close the inventory
236+ player .playSound (player .getLocation (), Sound .BLOCK_NOTE_BLOCK_BASS , 0.8f , 0.5f );
237+ player .closeInventory ();
238+ return ;
239+ }
240+
225241 int slot = event .getRawSlot ();
226242
227243 // Handle divider clicks (return to storage)
@@ -248,6 +264,14 @@ public void onFilterInventoryClick(InventoryClickEvent event) {
248264 * Returns to the spawner storage UI
249265 */
250266 private void returnToStorage (Player player , SpawnerData spawner ) {
267+ // Validate that the spawner still exists before allowing navigation
268+ if (plugin .getSpawnerManager ().isGhostSpawner (spawner )) {
269+ // Spawner no longer exists, close the inventory and prevent navigation
270+ player .playSound (player .getLocation (), Sound .BLOCK_NOTE_BLOCK_BASS , 0.8f , 0.5f );
271+ player .closeInventory ();
272+ return ;
273+ }
274+
251275 // Return to storage menu
252276 player .playSound (player .getLocation (), Sound .UI_BUTTON_CLICK , 0.8f , 1.0f );
253277 player .closeInventory ();
0 commit comments