Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Commit

Permalink
Version 1.1.6
Browse files Browse the repository at this point in the history
Add getPendingTasks
  • Loading branch information
Euphillya committed Mar 16, 2024
1 parent 4dee836 commit d269c41
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "fr.euphyllia"
version = "1.1.5"
version = "1.1.6"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;

Expand Down Expand Up @@ -212,6 +214,11 @@ public void execute(@NotNull SchedulerType schedulerType, @Nullable Object chunk
throw new UnsupportedOperationException();
}

@Override
public List<SchedulerTaskInter> getPendingTasks() {
return new ArrayList<>(mapSchedulerTask.values());
}

@Override
public void cancelAllTask() {
for (Map.Entry<Integer, SchedulerTaskInter> entry : mapSchedulerTask.entrySet()) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/fr/euphyllia/energie/folia/FoliaScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

public class FoliaScheduler implements Scheduler {

Expand Down Expand Up @@ -471,6 +474,11 @@ public void execute(@NotNull SchedulerType schedulerType, @Nullable Object chunk
}
}

@Override
public List<SchedulerTaskInter> getPendingTasks() {
return new ArrayList<>(mapSchedulerTask.values());
}

@Override
public void cancelAllTask() {
for (Map.Entry<Integer, SchedulerTaskInter> entry : mapSchedulerTask.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

public class LegacyScheduler implements Scheduler {
private final Plugin plugin;
Expand Down Expand Up @@ -265,6 +268,11 @@ public void execute(@NotNull SchedulerType schedulerType, @Nullable Object chunk
this.scheduleSyncDelayed(schedulerType, callBack);
}

@Override
public List<SchedulerTaskInter> getPendingTasks() {
return Bukkit.getScheduler().getPendingTasks().stream().map(LegacySchedulerTask::new).collect(Collectors.toList());
}

@Override
public void cancelAllTask() {
Bukkit.getScheduler().cancelTasks(this.plugin);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/fr/euphyllia/energie/model/Scheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.concurrent.Future;

public interface Scheduler {
Expand Down Expand Up @@ -85,6 +86,7 @@ public interface Scheduler {
@Deprecated
void execute(@NotNull SchedulerType schedulerType, @Nullable Object chunkOrLocOrEntity, @Nullable Runnable retired, SchedulerCallBack callBack);

List<SchedulerTaskInter> getPendingTasks();

void cancelAllTask();

Expand Down

0 comments on commit d269c41

Please # to comment.