SteamWar/BauSystem2.0
Archiviert
12
0

Added debug message for trace history map nullpointer and potential fix #257

Zusammengeführt
YoyoNow hat 3 Commits von fix-trace-history-nullpointer nach master 2024-07-16 22:38:04 +02:00 zusammengeführt
Nur Änderungen aus Commit 5153609776 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.region.Region;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
@ -32,6 +33,8 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
@Linked
public class TraceRecorder implements Listener {
@ -158,14 +161,23 @@ public class TraceRecorder implements Listener {
List<TNTPoint> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>());
// Failsave for tnt entering unloaded chunks
if (tntPrimed.isDead() || history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) {
if (tntPrimed == null || tntPrimed.isDead() || history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) {
return null;
}
int tntID;
if (history.size() == 0) {
historyMap.put(tntPrimed, history);
try {
historyMap.put(tntPrimed, history);
}
catch (NullPointerException e) {
Logger logger = Bukkit.getLogger();
logger.log(Level.WARNING, "Nullpointer thrown by historyMap");
logger.log(Level.WARNING, "TNT History: " + history);
logger.log(Level.WARNING, "History Map" + history);
throw e;
}
tntID = wrappedTrace.getNextOpenRecordIdAndIncrement();
} else {
tntID = history.get(0).getTntId();