Replace GeneratedFullDataFileHandler wait threads with a timer

It's still a bad solution, but now it won't create several hundred threads, so that's nice
This commit is contained in:
James Seibel
2023-10-28 12:19:43 -05:00
parent 488b598d97
commit 643112953e
@@ -46,6 +46,7 @@ import java.util.function.Function;
public class GeneratedFullDataFileHandler extends FullDataFileHandler
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
private static final Timer CHUNK_GEN_FINISHED_TIMER = new Timer();
private final AtomicReference<IWorldGenerationQueue> worldGenQueueRef = new AtomicReference<>(null);
@@ -275,12 +276,11 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler
// FIXME this is a bad fix to prevent full data sources saving incomplete, causing holes in the world after generation.
// The problem appears to be that the save may be happening too quickly,
// potentially happening before the meta file has the newly generated data added to it.
new Thread(() ->
CHUNK_GEN_FINISHED_TIMER.schedule(new TimerTask()
{
try{ Thread.sleep(4000); }catch (InterruptedException e){}
this.flushAndSaveAsync(pos).join();
}).start();
@Override
public void run() { GeneratedFullDataFileHandler.this.flushAndSaveAsync(pos).join(); }
}, 4000L);
this.fireOnGenPosSuccessListeners(pos);
return;