Skip to content

Commit cf036f5

Browse files
authored
Merge pull request #6 from NighterDevelopment/copilot/fix-d35cb45c-c317-4574-b6a0-29dea4dfdc6f
Fix spawner filter GUI exploit allowing navigation after spawner destruction
2 parents 334fea5 + d4f5310 commit cf036f5

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

core/src/main/java/github/nighter/smartspawner/SmartSpawner.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ public SpawnerStorageUI getSpawnerStorageUI() {
367367
return spawnerStorageUI;
368368
}
369369

370+
public SpawnerManager getSpawnerManager() {
371+
return spawnerManager;
372+
}
373+
370374
public SpawnerRangeChecker getRangeChecker() {
371375
return rangeChecker;
372376
}

core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/filter/FilterConfigUI.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)