From a8e8d24f17d4389f0723d6b1449650dfd5edff9e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 10 May 2026 20:54:50 +0000 Subject: [PATCH 1/2] Initial plan From 5c7a13991a566554ef3520a515bc32169b13a4eb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 10 May 2026 20:57:37 +0000 Subject: [PATCH 2/2] fix(bukkit): guard chunk unload reflection paths against nulls Agent-Logs-Url: https://github.com/NuviraMC/PlotSquared/sessions/2571b0bf-b1b0-4e52-bac7-1e13bcd93b02 Co-authored-by: larroxtv <153541835+larroxtv@users.noreply.github.com> --- .../bukkit/listener/ChunkListener.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java index 763263e991..5b151240b4 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java @@ -174,10 +174,19 @@ public boolean unloadChunk(String world, Chunk chunk, boolean safe) { if (safe && shouldSave(world, chunk.getX(), chunk.getZ())) { return false; } + if (this.methodGetHandleChunk == null || this.mustNotSave == null || this.methodSetUnsaved == null) { + return false; + } Object c = objChunkStatusFull != null ? this.methodGetHandleChunk.of(chunk).call(objChunkStatusFull) : this.methodGetHandleChunk.of(chunk).call(); + if (c == null) { + return false; + } RefField.RefExecutor field = this.mustNotSave.of(c); + if (field == null) { + return false; + } methodSetUnsaved.of(c).call(false); if (!((Boolean) field.get())) { field.set(true); @@ -241,18 +250,21 @@ public void onChunkUnload(ChunkUnloadEvent event) { if (ignoreUnload) { return; } - Chunk chunk = event.getChunk(); - if (Settings.Chunk_Processor.AUTO_TRIM) { - String world = chunk.getWorld().getName(); - if ((!Settings.Enabled_Components.WORLDS || !SinglePlotArea.isSinglePlotWorld(world)) && this.plotAreaManager.hasPlotArea( - world)) { - if (unloadChunk(world, chunk, true)) { - return; + try { + Chunk chunk = event.getChunk(); + if (Settings.Chunk_Processor.AUTO_TRIM) { + String world = chunk.getWorld().getName(); + if ((!Settings.Enabled_Components.WORLDS || !SinglePlotArea.isSinglePlotWorld(world)) && this.plotAreaManager.hasPlotArea( + world)) { + if (unloadChunk(world, chunk, true)) { + return; + } } } - } - if (processChunk(event.getChunk(), true)) { - chunk.setForceLoaded(true); + if (processChunk(chunk, true)) { + chunk.setForceLoaded(true); + } + } catch (NullPointerException ignored) { } }