org.bukkit.scheduler.BukkitWorker Java Examples
The following examples show how to use
org.bukkit.scheduler.BukkitWorker.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftScheduler.java From Kettle with GNU General Public License v3.0 | 6 votes |
@Override public List<BukkitWorker> getActiveWorkers() { // Paper start if (!isAsyncScheduler) { //noinspection TailRecursion return this.asyncScheduler.getActiveWorkers(); } // Paper end final ArrayList<BukkitWorker> workers = new ArrayList<BukkitWorker>(); for (final CraftTask taskObj : runners.values()) { // Iterator will be a best-effort (may fail to grab very new values) if called from an async thread if (taskObj.isSync()) { continue; } final CraftAsyncTask task = (CraftAsyncTask) taskObj; synchronized (task.getWorkers()) { // This will never have an issue with stale threads; it's state-safe workers.addAll(task.getWorkers()); } } return workers; }
Example #2
Source File: CraftScheduler.java From Thermos with GNU General Public License v3.0 | 5 votes |
public List<BukkitWorker> getActiveWorkers() { final ArrayList<BukkitWorker> workers = new ArrayList<BukkitWorker>(); for (final CraftTask taskObj : runners.values()) { // Iterator will be a best-effort (may fail to grab very new values) if called from an async thread if (taskObj.isSync()) { continue; } final CraftAsyncTask task = (CraftAsyncTask) taskObj; synchronized (task.getWorkers()) { // This will never have an issue with stale threads; it's state-safe workers.addAll(task.getWorkers()); } } return workers; }
Example #3
Source File: TaskCloser.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
private List<Integer> getPendingTasks() { List<Integer> pendingTasks = new ArrayList<>(); //returns only the async tasks for (BukkitWorker pendingTask : scheduler.getActiveWorkers()) { if (pendingTask.getOwner().equals(plugin) //it's not a periodic task && !scheduler.isQueued(pendingTask.getTaskId())) { pendingTasks.add(pendingTask.getTaskId()); } } return pendingTasks; }
Example #4
Source File: TaskCloserTest.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
private void mockActiveWorkers() { Plugin otherOwner = mock(Plugin.class); List<BukkitWorker> tasks = Arrays.asList( mockBukkitWorker(authMe, ACTIVE_WORKERS_ID[0], false), mockBukkitWorker(otherOwner, 3, false), mockBukkitWorker(authMe, ACTIVE_WORKERS_ID[1], false), mockBukkitWorker(authMe, 7, true), mockBukkitWorker(otherOwner, 11, true)); given(bukkitScheduler.getActiveWorkers()).willReturn(tasks); }
Example #5
Source File: TaskCloserTest.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
private BukkitWorker mockBukkitWorker(Plugin owner, int taskId, boolean isQueued) { BukkitWorker worker = mock(BukkitWorker.class); given(worker.getOwner()).willReturn(owner); given(worker.getTaskId()).willReturn(taskId); given(bukkitScheduler.isQueued(taskId)).willReturn(isQueued); return worker; }
Example #6
Source File: CraftAsyncTask.java From Kettle with GNU General Public License v3.0 | 4 votes |
LinkedList<BukkitWorker> getWorkers() { return workers; }
Example #7
Source File: LoggedScheduler.java From VoxelGamesLibv2 with MIT License | 4 votes |
@Override public List<BukkitWorker> getActiveWorkers() { return delegate.getActiveWorkers(); }
Example #8
Source File: CraftAsyncTask.java From Thermos with GNU General Public License v3.0 | 4 votes |
LinkedList<BukkitWorker> getWorkers() { return workers; }