Store last delay, so if a search takes a long time, it does not bog the server down.

This commit is contained in:
zontreck 2023-12-18 18:59:52 -07:00
parent 949ec511b7
commit 1c866e304e
3 changed files with 11 additions and 3 deletions

View file

@ -49,7 +49,7 @@ mod_name=Aria's Essentials
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPLv3
# The mod version. See https://semver.org/
mod_version=1.1.121823.1657
mod_version=1.1.121823.1856
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -52,6 +52,13 @@ public class RTP
public WorldPosition position;
private List<Block> BLACKLIST = Lists.of(Blocks.LAVA, Blocks.WATER);
protected int tries;
protected int lastThreadDelay = 1;
protected RTP withThreadDelay(int delay)
{
lastThreadDelay=delay;
return this;
}
public boolean isDimension(ServerLevel level)
{

View file

@ -70,8 +70,9 @@ public class RandomPositionLocator extends Task
}else {
// Schedule the task to execute
//run();
RandomPositionLocator next = new RandomPositionLocator(contain);
DelayedExecutorService.getInstance().schedule(next, 1);
RandomPositionLocator next = new RandomPositionLocator(contain.withThreadDelay(contain.lastThreadDelay+1));
DelayedExecutorService.getInstance().schedule(next, contain.lastThreadDelay+1);
AriasEssentials.LOGGER.info("Giving up current RTP search. Scheduling another search in 1 second");
}
}