Fix save operation in server tick

This commit is contained in:
zontreck 2024-01-21 22:08:44 -07:00
parent 80e068c198
commit ad35b5d07c

View file

@ -120,8 +120,8 @@ public class EventHandler {
if(ALIVE_TICKS.getAndIncrement() % 10 == 0) if(ALIVE_TICKS.getAndIncrement() % 10 == 0)
{ {
restoreBurnedBlocks(); if(restoreBurnedBlocks())
FireMod.blockRestoreData.commit(); FireMod.blockRestoreData.commit();
} }
} }
@ -138,7 +138,7 @@ public class EventHandler {
} }
public void restoreBurnedBlocks() { public boolean restoreBurnedBlocks() {
long currentTime = Instant.now().getEpochSecond(); long currentTime = Instant.now().getEpochSecond();
Lock lock = FireMod.blockRestoreData.acquireWriteLock(); Lock lock = FireMod.blockRestoreData.acquireWriteLock();
@ -159,13 +159,15 @@ public class EventHandler {
//FireMod.LOGGER.info("Restoring burned block"); //FireMod.LOGGER.info("Restoring burned block");
return; return true;
} }
} }
}finally { }finally {
lock.unlock(); lock.unlock();
} }
return false;
} }
} }