Java Code Examples for org.bukkit.scheduler.BukkitTask#getTaskId()

The following examples show how to use org.bukkit.scheduler.BukkitTask#getTaskId() . 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: TasksCommand.java    From LagMonitor with MIT License 6 votes vote down vote up
private BaseComponent[] formatTask(BukkitTask pendingTask) {
    Plugin owner = pendingTask.getOwner();
    int taskId = pendingTask.getTaskId();
    boolean sync = pendingTask.isSync();

    String id = Integer.toString(taskId);
    if (sync) {
        id += "-Sync";
    } else if (Bukkit.getScheduler().isCurrentlyRunning(taskId)) {
        id += "-Running";
    }

    return new ComponentBuilder(owner.getName())
            .color(PRIMARY_COLOR.asBungee())
            .append('-' + id)
            .color(SECONDARY_COLOR.asBungee())
            .create();
}
 
Example 2
Source File: TasksCommand.java    From LagMonitor with MIT License 6 votes vote down vote up
private BaseComponent[] formatTask(BukkitTask pendingTask) {
    Plugin owner = pendingTask.getOwner();
    int taskId = pendingTask.getTaskId();
    boolean sync = pendingTask.isSync();

    String id = Integer.toString(taskId);
    if (sync) {
        id += "-Sync";
    } else if (Bukkit.getScheduler().isCurrentlyRunning(taskId)) {
        id += "-Running";
    }

    return new ComponentBuilder(owner.getName())
            .color(PRIMARY_COLOR.asBungee())
            .append('-' + id)
            .color(SECONDARY_COLOR.asBungee())
            .create();
}
 
Example 3
Source File: BukkitExecutorService.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected int runTask(Runnable task, long delayInTicks) {
  BukkitTask bukkitTask =
      async
          ? scheduler.runTaskLaterAsynchronously(plugin, task, delayInTicks)
          : scheduler.runTaskLater(plugin, task, delayInTicks);
  return bukkitTask.getTaskId();
}
 
Example 4
Source File: BukkitExecutorService.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected int runPeriodicTask(
    Runnable task, long initialDelayInTicks, long periodicDelayInTicks) {
  BukkitTask bukkitTask =
      async
          ? scheduler.runTaskTimerAsynchronously(
              plugin, task, initialDelayInTicks, periodicDelayInTicks)
          : scheduler.runTaskTimer(plugin, task, initialDelayInTicks, periodicDelayInTicks);
  return bukkitTask.getTaskId();
}
 
Example 5
Source File: BukkitSchedulerBackend.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public int taskId(BukkitTask bukkitTask) {
    return bukkitTask.getTaskId();
}