From 0fa31ab91458998fbb1d96909f0e124e54be7521 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 28 Nov 2023 10:39:57 +0100 Subject: [PATCH 1/4] Implement hard shutdown after 80s --- .../src/de/steamwar/core/CrashDetector.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java b/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java index a0bb826..26a12f0 100644 --- a/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java +++ b/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java @@ -31,13 +31,17 @@ public class CrashDetector { private static final long TIMEOUT = 20000; private final AtomicLong lastTick = new AtomicLong(Long.MAX_VALUE); + private final AtomicLong lastMessage = new AtomicLong(Long.MAX_VALUE); private final Thread mainThread = Thread.currentThread(); private final Thread watchdog; private boolean run = true; public CrashDetector () { - Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> lastTick.set(System.currentTimeMillis()), 0, 1); + Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> { + lastTick.set(System.currentTimeMillis()); + lastMessage.set(System.currentTimeMillis()); + }, 0, 1); watchdog = new Thread(this::run, "SteamWar Watchdog"); watchdog.setDaemon(true); watchdog.start(); @@ -56,19 +60,17 @@ public class CrashDetector { SWException.init(); while (run) { long curTime = System.currentTimeMillis(); - if(curTime - TIMEOUT > lastTick.get()) { + if(curTime - 4*TIMEOUT >= lastTick.get()) { + SWException.log("Server did not recover in " + (curTime - lastTick.get()) + "ms, unclean server stop", ""); + hardStop(); + } else if(curTime - TIMEOUT > lastMessage.get()) { if(mainThread.isAlive()) { SWException.log("Server hung for " + (curTime - lastTick.get()) + "ms", Arrays.stream(mainThread.getStackTrace()).map(StackTraceElement::toString).collect(Collectors.joining("\n"))); } else { SWException.log("Server thread already dead, unclean server stop", "Core enabled: " + Core.getInstance().isEnabled()); - if(Core.getInstance().isEnabled()) { - Core.getInstance().onDisable(); - } - Statement.closeAll(); - //System.exit(0); Does freeze, potential freezing issues: ConsoleRestoreHook, ApplicationShutdownHooks or DeleteOnExitHook - Runtime.getRuntime().halt(0); + hardStop(); } - lastTick.set(curTime); + lastMessage.set(curTime); } try { Thread.sleep(1000); @@ -77,4 +79,13 @@ public class CrashDetector { } } } + + private void hardStop() { + if(Core.getInstance().isEnabled()) { + Core.getInstance().onDisable(); + } + Statement.closeAll(); + //System.exit(0); Does freeze, potential freezing issues: ConsoleRestoreHook, ApplicationShutdownHooks or DeleteOnExitHook + Runtime.getRuntime().halt(0); + } } From badaa081e6d93e736068216aa5256bf9e6603a7e Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 28 Nov 2023 18:56:43 +0100 Subject: [PATCH 2/4] Supress protocol conversion errors --- SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java b/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java index 2a5ffa5..c958584 100644 --- a/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java +++ b/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java @@ -149,6 +149,7 @@ public class ErrorHandler extends Handler { startsWith.add("Chunk coordinates: "); startsWith.add("Failed to save history"); startsWith.add("\t... "); + startsWith.add("ERROR IN Protocol"); ignoreStartsWith = Collections.unmodifiableList(startsWith); List contains = new ArrayList<>(); From 95093e527860bf08366462db85ddff27e148c8d9 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 29 Nov 2023 16:27:20 +0100 Subject: [PATCH 3/4] Fix QuickGear --- SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java b/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java index c6d833d..7428574 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java @@ -52,12 +52,14 @@ public class SQLWrapperImpl implements SQLWrapper { String material = config.getString("Schematic.Material", "STONE_BUTTON"); if(!config.getStringList("CheckQuestions").isEmpty()) { - checktype = new SchematicType("C" + type, "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material); + checktype = new SchematicType("C" + type, "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material, true); tmpTypes.add(checktype); tmpFromDB.put(checktype.toDB(), checktype); } - SchematicType current = new SchematicType(type, shortcut, config.isConfigurationSection("Server") ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material); + boolean manualCheck = config.getBoolean("Schematic.ManualCheck", true); + + SchematicType current = new SchematicType(type, shortcut, config.isConfigurationSection("Server") ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material, manualCheck); tmpTypes.add(current); tmpFromDB.put(type.toLowerCase(), current); } From 733c117bd1add02b6102530d1a29e77a603a83f5 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 29 Nov 2023 16:35:38 +0100 Subject: [PATCH 4/4] Fix QuickGear --- CommonCore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CommonCore b/CommonCore index e0c1d1c..e664c6c 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit e0c1d1c2e2c4359fc706e9b58268a0b93873a669 +Subproject commit e664c6cf4e3e9a056918cf15030c247e7bc6fe19