mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-03 14:26:27 +00:00
create TaskScheduler
This commit is contained in:
@@ -7,6 +7,7 @@ import com.dfsek.terra.api.platform.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.LockedRegistry;
|
||||
import com.dfsek.terra.api.task.TaskScheduler;
|
||||
import com.dfsek.terra.api.util.logging.DebugLogger;
|
||||
import com.dfsek.terra.api.util.logging.Logger;
|
||||
import com.dfsek.terra.config.PluginConfig;
|
||||
@@ -64,4 +65,6 @@ public interface TerraPlugin extends LoaderRegistrar {
|
||||
default void runPossiblyUnsafeTask(Runnable task) {
|
||||
task.run();
|
||||
}
|
||||
|
||||
TaskScheduler getScheduler();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.dfsek.terra.api.task;
|
||||
|
||||
public interface TaskScheduler {
|
||||
/**
|
||||
* Run a task synchronously on the next tick.
|
||||
* Functionally equivalent to {@link #runTask(Runnable, long)}
|
||||
* @param task Task to run.
|
||||
*/
|
||||
default void runTask(Runnable task) {
|
||||
runTask(task, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a task asynchronously immediately.
|
||||
* Functionally equivalent to {@link #runTaskAsynchronously(Runnable)} (Runnable, long)}
|
||||
* @param task Task to run.
|
||||
*/
|
||||
default void runTaskAsynchronously(Runnable task) {
|
||||
runTaskAsynchronously(task, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a task asynchronously after a number of ticks.
|
||||
* @param task Task to run.
|
||||
* @param ticks Delay before running the task, in ticks.
|
||||
*/
|
||||
void runTaskAsynchronously(Runnable task, long ticks);
|
||||
|
||||
/**
|
||||
* Run a task synchronously after a number of ticks.
|
||||
* @param task Task to run.
|
||||
* @param ticks Delay before running the task, in ticks.
|
||||
*/
|
||||
void runTask(Runnable task, long ticks);
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import com.dfsek.terra.api.platform.world.Biome;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.LockedRegistry;
|
||||
import com.dfsek.terra.api.task.TaskScheduler;
|
||||
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.logging.DebugLogger;
|
||||
import com.dfsek.terra.api.util.logging.JavaLogger;
|
||||
@@ -137,6 +138,11 @@ public class DistributionTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskScheduler getScheduler() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(TypeRegistry registry) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user