diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index a5076d0..8b0ca80 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,10 +7,11 @@
-
+
-
-
+
+
+
diff --git a/build.gradle.kts b/build.gradle.kts
index 77dd89b..8628546 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -4,7 +4,7 @@ plugins {
}
group = "fr.euphyllia"
-version = "1.1.6"
+version = "1.1.7"
repositories {
mavenCentral()
diff --git a/src/main/java/fr/euphyllia/energie/executors/ExecutorsSchedulerTask.java b/src/main/java/fr/euphyllia/energie/executors/ExecutorsSchedulerTask.java
index f5b57f5..a4839cd 100644
--- a/src/main/java/fr/euphyllia/energie/executors/ExecutorsSchedulerTask.java
+++ b/src/main/java/fr/euphyllia/energie/executors/ExecutorsSchedulerTask.java
@@ -35,4 +35,9 @@ public void cancel() {
public int getTaskId() {
return this.executors.hashCode();
}
+
+ @Override
+ public boolean isSync() {
+ return false;
+ }
}
diff --git a/src/main/java/fr/euphyllia/energie/folia/FoliaScheduler.java b/src/main/java/fr/euphyllia/energie/folia/FoliaScheduler.java
index ee46def..3ff51af 100644
--- a/src/main/java/fr/euphyllia/energie/folia/FoliaScheduler.java
+++ b/src/main/java/fr/euphyllia/energie/folia/FoliaScheduler.java
@@ -45,21 +45,22 @@ public FoliaScheduler(Plugin pluginBukkit) {
periodTicks = 1;
}
ScheduledTask scheduledTask;
+ boolean isSynchronous = !schedulerType.equals(SchedulerType.ASYNC);
if (schedulerType.equals(SchedulerType.ASYNC)) {
scheduledTask = Bukkit.getAsyncScheduler().runAtFixedRate(this.plugin, task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, isSynchronous);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
}, initialDelayTicks * 50, periodTicks * 50, TimeUnit.MILLISECONDS);
} else {
scheduledTask = Bukkit.getGlobalRegionScheduler().runAtFixedRate(this.plugin, task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, isSynchronous);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
}, initialDelayTicks, periodTicks);
}
- return new FoliaSchedulerTask(scheduledTask);
+ return new FoliaSchedulerTask(scheduledTask, isSynchronous);
}
@Override
@@ -74,11 +75,11 @@ public FoliaScheduler(Plugin pluginBukkit) {
periodTicks = 1;
}
ScheduledTask scheduledTask = Bukkit.getRegionScheduler().runAtFixedRate(this.plugin, worldChunk.world(), worldChunk.chunkX(), worldChunk.chunkZ(), task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, true);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
}, initialDelayTicks, periodTicks);
- return new FoliaSchedulerTask(scheduledTask);
+ return new FoliaSchedulerTask(scheduledTask, true);
}
}
@@ -94,11 +95,11 @@ public FoliaScheduler(Plugin pluginBukkit) {
periodTicks = 1;
}
ScheduledTask scheduledTask = Bukkit.getRegionScheduler().runAtFixedRate(this.plugin, location, task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, true);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
}, initialDelayTicks, periodTicks);
- return new FoliaSchedulerTask(scheduledTask);
+ return new FoliaSchedulerTask(scheduledTask, true);
}
}
@@ -114,11 +115,11 @@ public FoliaScheduler(Plugin pluginBukkit) {
periodTicks = 1;
}
ScheduledTask scheduledTask = entity.getScheduler().runAtFixedRate(this.plugin, task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, true);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
}, retired, initialDelayTicks, periodTicks);
- return new FoliaSchedulerTask(scheduledTask);
+ return new FoliaSchedulerTask(scheduledTask, true);
}
}
@@ -128,20 +129,21 @@ public FoliaScheduler(Plugin pluginBukkit) {
delayTicks = 1;
}
ScheduledTask scheduledTask;
+ boolean isSynchronous = !schedulerType.equals(SchedulerType.ASYNC);
if (schedulerType.equals(SchedulerType.ASYNC)) {
scheduledTask = Bukkit.getAsyncScheduler().runDelayed(this.plugin, task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, isSynchronous);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
}, delayTicks * 50, TimeUnit.MILLISECONDS);
} else {
scheduledTask = Bukkit.getGlobalRegionScheduler().runDelayed(this.plugin, task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, isSynchronous);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
}, delayTicks);
}
- return new FoliaSchedulerTask(scheduledTask);
+ return new FoliaSchedulerTask(scheduledTask, isSynchronous);
}
@Override
@@ -153,11 +155,11 @@ public FoliaScheduler(Plugin pluginBukkit) {
delayTicks = 1;
}
ScheduledTask scheduledTask = Bukkit.getRegionScheduler().runDelayed(this.plugin, worldChunk.world(), worldChunk.chunkX(), worldChunk.chunkZ(), task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, true);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
}, delayTicks);
- return new FoliaSchedulerTask(scheduledTask);
+ return new FoliaSchedulerTask(scheduledTask, true);
}
}
@@ -170,11 +172,11 @@ public FoliaScheduler(Plugin pluginBukkit) {
delayTicks = 1;
}
ScheduledTask scheduledTask = Bukkit.getRegionScheduler().runDelayed(this.plugin, location, task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, true);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
}, delayTicks);
- return new FoliaSchedulerTask(scheduledTask);
+ return new FoliaSchedulerTask(scheduledTask, true);
}
}
@@ -187,31 +189,32 @@ public FoliaScheduler(Plugin pluginBukkit) {
delayTicks = 1;
}
ScheduledTask scheduledTask = entity.getScheduler().runDelayed(this.plugin, task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, true);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
}, retired, delayTicks);
- return new FoliaSchedulerTask(scheduledTask);
+ return new FoliaSchedulerTask(scheduledTask, true);
}
}
@Override
public @Nullable SchedulerTaskInter runTask(@NotNull SchedulerType schedulerType, SchedulerCallBack callBack) {
ScheduledTask scheduledTask;
+ boolean isSynchronous = !schedulerType.equals(SchedulerType.ASYNC);
if (schedulerType.equals(SchedulerType.ASYNC)) {
scheduledTask = Bukkit.getAsyncScheduler().runNow(this.plugin, task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, isSynchronous);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
});
} else {
scheduledTask = Bukkit.getGlobalRegionScheduler().run(this.plugin, task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, isSynchronous);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
});
}
- return new FoliaSchedulerTask(scheduledTask);
+ return new FoliaSchedulerTask(scheduledTask, isSynchronous);
}
@Override
@@ -220,11 +223,11 @@ public FoliaScheduler(Plugin pluginBukkit) {
return this.runTask(schedulerType, callBack);
} else {
ScheduledTask scheduledTask = Bukkit.getRegionScheduler().run(this.plugin, worldChunk.world(), worldChunk.chunkX(), worldChunk.chunkZ(), task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, true);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
});
- return new FoliaSchedulerTask(scheduledTask);
+ return new FoliaSchedulerTask(scheduledTask, true);
}
}
@@ -234,11 +237,11 @@ public FoliaScheduler(Plugin pluginBukkit) {
return this.runTask(schedulerType, callBack);
} else {
ScheduledTask scheduledTask = Bukkit.getRegionScheduler().run(this.plugin, location, task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, true);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
});
- return new FoliaSchedulerTask(scheduledTask);
+ return new FoliaSchedulerTask(scheduledTask, true);
}
}
@@ -248,11 +251,11 @@ public FoliaScheduler(Plugin pluginBukkit) {
return this.runTask(schedulerType, callBack);
} else {
ScheduledTask scheduledTask = entity.getScheduler().run(this.plugin, task -> {
- SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task);
+ SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task, true);
mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask);
callBack.run(schedulerTask);
}, retired);
- return new FoliaSchedulerTask(scheduledTask);
+ return new FoliaSchedulerTask(scheduledTask, true);
}
}
diff --git a/src/main/java/fr/euphyllia/energie/folia/FoliaSchedulerTask.java b/src/main/java/fr/euphyllia/energie/folia/FoliaSchedulerTask.java
index 8bf3a08..b13b510 100644
--- a/src/main/java/fr/euphyllia/energie/folia/FoliaSchedulerTask.java
+++ b/src/main/java/fr/euphyllia/energie/folia/FoliaSchedulerTask.java
@@ -8,9 +8,11 @@
public class FoliaSchedulerTask implements SchedulerTaskInter {
private final ScheduledTask schedulerTask;
+ private boolean isSynchronous = false;
- public FoliaSchedulerTask(ScheduledTask schedulerTask) {
+ public FoliaSchedulerTask(ScheduledTask schedulerTask, boolean sync) {
this.schedulerTask = schedulerTask;
+ this.isSynchronous = sync;
}
@@ -33,4 +35,9 @@ public void cancel() {
public int getTaskId() {
return this.schedulerTask.hashCode();
}
+
+ @Override
+ public boolean isSync() {
+ return this.isSynchronous;
+ }
}
diff --git a/src/main/java/fr/euphyllia/energie/legacy/LegacySchedulerTask.java b/src/main/java/fr/euphyllia/energie/legacy/LegacySchedulerTask.java
index 03a72ca..a45657c 100644
--- a/src/main/java/fr/euphyllia/energie/legacy/LegacySchedulerTask.java
+++ b/src/main/java/fr/euphyllia/energie/legacy/LegacySchedulerTask.java
@@ -32,4 +32,9 @@ public void cancel() {
public int getTaskId() {
return this.task.getTaskId();
}
+
+ @Override
+ public boolean isSync() {
+ return this.task.isSync();
+ }
}
diff --git a/src/main/java/fr/euphyllia/energie/model/SchedulerTaskInter.java b/src/main/java/fr/euphyllia/energie/model/SchedulerTaskInter.java
index 3fe42c5..e98ed51 100644
--- a/src/main/java/fr/euphyllia/energie/model/SchedulerTaskInter.java
+++ b/src/main/java/fr/euphyllia/energie/model/SchedulerTaskInter.java
@@ -12,4 +12,6 @@ public interface SchedulerTaskInter {
void cancel();
int getTaskId();
+
+ boolean isSync();
}