mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 14:38:53 +00:00
1 parent
474db95b1a
commit
dd6c23168d
4 files changed
+15
-13
No files matched your search
@@ -81,12 +81,9 @@ public interface BukkitTaskRunner extends TaskRunner {
|
|||||||
GracefulScheduling getScheduler();
|
GracefulScheduling getScheduler();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Override
|
||||||
ConcurrentHashMap<Integer, ScheduledTask> getTasks();
|
ConcurrentHashMap<Integer, ScheduledTask> getTasks();
|
||||||
|
|
||||||
private int getNextTaskId() {
|
|
||||||
return getTasks().keySet().stream().max(Integer::compareTo).orElse(0) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
default Duration getDurationTicks(long ticks) {
|
default Duration getDurationTicks(long ticks) {
|
||||||
return Duration.of(ticks * 50, ChronoUnit.MILLIS);
|
return Duration.of(ticks * 50, ChronoUnit.MILLIS);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import net.william278.huskhomes.HuskHomes;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public interface TaskRunner {
|
public interface TaskRunner {
|
||||||
@@ -41,6 +42,17 @@ public interface TaskRunner {
|
|||||||
|
|
||||||
void cancelAllTasks();
|
void cancelAllTasks();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
ConcurrentHashMap<Integer, ?> getTasks();
|
||||||
|
|
||||||
|
default int getNextTaskId() {
|
||||||
|
int taskId = 0;
|
||||||
|
while (getTasks().containsKey(taskId)) {
|
||||||
|
taskId++;
|
||||||
|
}
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
HuskHomes getPlugin();
|
HuskHomes getPlugin();
|
||||||
|
|
||||||
|
|||||||
@@ -89,12 +89,9 @@ public interface FabricTaskRunner extends TaskRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Override
|
||||||
ConcurrentHashMap<Integer, CompletableFuture<?>> getTasks();
|
ConcurrentHashMap<Integer, CompletableFuture<?>> getTasks();
|
||||||
|
|
||||||
private int getNextTaskId() {
|
|
||||||
return getTasks().keySet().stream().max(Integer::compareTo).orElse(0) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
FabricHuskHomes getPlugin();
|
FabricHuskHomes getPlugin();
|
||||||
|
|||||||
@@ -105,12 +105,9 @@ public interface SpongeTaskRunner extends TaskRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Override
|
||||||
ConcurrentHashMap<Integer, CancellableRunnable> getTasks();
|
ConcurrentHashMap<Integer, CancellableRunnable> getTasks();
|
||||||
|
|
||||||
private int getNextTaskId() {
|
|
||||||
return getTasks().keySet().stream().max(Integer::compareTo).orElse(0) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
SpongeHuskHomes getPlugin();
|
SpongeHuskHomes getPlugin();
|
||||||
@@ -119,7 +116,6 @@ public interface SpongeTaskRunner extends TaskRunner {
|
|||||||
* A wrapper for a {@link Runnable} that can be canceled
|
* A wrapper for a {@link Runnable} that can be canceled
|
||||||
*/
|
*/
|
||||||
class CancellableRunnable implements Runnable {
|
class CancellableRunnable implements Runnable {
|
||||||
|
|
||||||
private final Runnable runnable;
|
private final Runnable runnable;
|
||||||
private boolean cancelled = false;
|
private boolean cancelled = false;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user