Poor attempt at adding pregen pausing

Please fix /command/CommandIrisPregen.java (has // TODO:)
and
/util/PregenJob.java
(has // TODO:)
This commit is contained in:
BuildTools 2020-10-21 17:47:20 +02:00
parent 265936a791
commit 6199256058
2 changed files with 69 additions and 2 deletions

View File

@ -35,11 +35,41 @@ public class CommandIrisPregen extends MortarCommand
} }
else else
{ {
sender.sendMessage("Stopped all pregens."); sender.sendMessage("Stopped All Pregens.");
PregenJob.stop();
} }
PregenJob.stop();
return true; return true;
} }
/* TODO: help
else if(args[0].equalsIgnoreCase("pause"))
{
if(PregenJob.task == -1)
{
sender.sendMessage("No Active Pregens");
}
else
{
if (PregenJob.isPaused()) {
PregenJob.resume();
} else {
PregenJob.pause();
}
sender.sendMessage("Paused Active Pregen");
}
return true;
} else if(args[0].equalsIgnoreCase("resume")){
if(!PregenJob.isPaused())
{
sender.sendMessage("No Paused Pregens");
}
else
{
sender.sendMessage("Resumed Paused Pregen");
PregenJob.resume();
}
return true;
}
*/
if(sender.isPlayer()) if(sender.isPlayer())
{ {

View File

@ -17,6 +17,7 @@ import com.volmit.iris.gen.scaffold.IrisWorlds;
import com.volmit.iris.gui.PregenGui; import com.volmit.iris.gui.PregenGui;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import org.bukkit.scheduler.BukkitTask;
public class PregenJob implements Listener public class PregenJob implements Listener
{ {
@ -51,6 +52,8 @@ public class PregenJob implements Listener
private long nogen = M.ms(); private long nogen = M.ms();
private KList<ChunkPosition> requeueMCA = new KList<ChunkPosition>(); private KList<ChunkPosition> requeueMCA = new KList<ChunkPosition>();
private RollingSequence acps = new RollingSequence(PaperLib.isPaper() ? 8 : 32); private RollingSequence acps = new RollingSequence(PaperLib.isPaper() ? 8 : 32);
private BukkitTask pausedTask;
private boolean isPaused = false;
int xc = 0; int xc = 0;
public PregenJob(World world, int size, MortarSender sender, Runnable onDone) public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
@ -124,6 +127,40 @@ public class PregenJob implements Listener
task = -1; task = -1;
} }
// TODO: Cannot get paused value from this. Have to check bukkit tasks, not sure how.
// TODO: Trying to add functionality here to allow for pausing an continuing.
public static boolean isPaused(){
return false;
//return this.isPaused;
}
public static void pause()
{
try
{
// Save the task, tell bukkit to cancel it
stop();
}
catch(Throwable e)
{
}
task = -1;
}
public static void resume()
{
try
{
// Load task and tell bukkit to continue it
}
catch(Throwable e)
{
}
task = -1;
}
public void onTick() public void onTick()
{ {
if(completed) if(completed)