From ad35b5d07cadfd0932d8b508e50250127e8ba0f6 Mon Sep 17 00:00:00 2001 From: zontreck Date: Sun, 21 Jan 2024 22:08:44 -0700 Subject: [PATCH] Fix save operation in server tick --- .../java/dev/zontreck/fire/events/EventHandler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/dev/zontreck/fire/events/EventHandler.java b/src/main/java/dev/zontreck/fire/events/EventHandler.java index c518df5..fe95700 100644 --- a/src/main/java/dev/zontreck/fire/events/EventHandler.java +++ b/src/main/java/dev/zontreck/fire/events/EventHandler.java @@ -120,8 +120,8 @@ public class EventHandler { if(ALIVE_TICKS.getAndIncrement() % 10 == 0) { - restoreBurnedBlocks(); - FireMod.blockRestoreData.commit(); + if(restoreBurnedBlocks()) + FireMod.blockRestoreData.commit(); } } @@ -138,7 +138,7 @@ public class EventHandler { } - public void restoreBurnedBlocks() { + public boolean restoreBurnedBlocks() { long currentTime = Instant.now().getEpochSecond(); Lock lock = FireMod.blockRestoreData.acquireWriteLock(); @@ -159,13 +159,15 @@ public class EventHandler { //FireMod.LOGGER.info("Restoring burned block"); - return; + return true; } } }finally { lock.unlock(); } + return false; + } }