Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.scheduler.BukkitRunnable Class Referenceabstract
Inheritance diagram for org.bukkit.scheduler.BukkitRunnable:

Public Member Functions

synchronized void cancel () throws IllegalStateException
 
synchronized BukkitTask runTask (Plugin plugin) throws IllegalArgumentException, IllegalStateException
 
synchronized BukkitTask runTaskAsynchronously (Plugin plugin) throws IllegalArgumentException, IllegalStateException
 
synchronized BukkitTask runTaskLater (Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException
 
synchronized BukkitTask runTaskLaterAsynchronously (Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException
 
synchronized BukkitTask runTaskTimer (Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException
 
synchronized BukkitTask runTaskTimerAsynchronously (Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException
 
synchronized int getTaskId () throws IllegalStateException
 

Detailed Description

This class is provided as an easy way to handle scheduling tasks.

Definition at line 9 of file BukkitRunnable.java.

Member Function Documentation

synchronized void org.bukkit.scheduler.BukkitRunnable.cancel ( ) throws IllegalStateException

Attempts to cancel this task.

Exceptions
IllegalStateExceptionif task was not scheduled yet

Definition at line 17 of file BukkitRunnable.java.

References org.bukkit.scheduler.BukkitScheduler.cancelTask(), org.bukkit.Bukkit.getScheduler(), and org.bukkit.scheduler.BukkitRunnable.getTaskId().

17  {
18  Bukkit.getScheduler().cancelTask(getTaskId());
19  }
synchronized int org.bukkit.scheduler.BukkitRunnable.getTaskId ( ) throws IllegalStateException

Gets the task id for this runnable.

Returns
the task id that this runnable was scheduled as
Exceptions
IllegalStateExceptionif task was not scheduled yet

Definition at line 131 of file BukkitRunnable.java.

Referenced by org.bukkit.scheduler.BukkitRunnable.cancel().

131  {
132  final int id = taskId;
133  if (id == -1) {
134  throw new IllegalStateException("Not scheduled yet");
135  }
136  return id;
137  }
synchronized BukkitTask org.bukkit.scheduler.BukkitRunnable.runTask ( Plugin  plugin) throws IllegalArgumentException, IllegalStateException

Schedules this in the Bukkit scheduler to run on next tick.

Parameters
pluginthe reference to the plugin scheduling task
Returns
a BukkitTask that contains the id number
Exceptions
IllegalArgumentExceptionif plugin is null
IllegalStateExceptionif this was already scheduled
See also
BukkitScheduler::runTask(Plugin, Runnable)

Definition at line 30 of file BukkitRunnable.java.

References org.bukkit.Bukkit.getScheduler(), and org.bukkit.scheduler.BukkitScheduler.runTask().

30  {
31  checkState();
32  return setupId(Bukkit.getScheduler().runTask(plugin, this));
33  }
synchronized BukkitTask org.bukkit.scheduler.BukkitRunnable.runTaskAsynchronously ( Plugin  plugin) throws IllegalArgumentException, IllegalStateException

Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.

Schedules this in the Bukkit scheduler to run asynchronously.

Parameters
pluginthe reference to the plugin scheduling task
Returns
a BukkitTask that contains the id number
Exceptions
IllegalArgumentExceptionif plugin is null
IllegalStateExceptionif this was already scheduled
See also
BukkitScheduler::runTaskAsynchronously(Plugin, Runnable)

Definition at line 47 of file BukkitRunnable.java.

References org.bukkit.Bukkit.getScheduler(), and org.bukkit.scheduler.BukkitScheduler.runTaskAsynchronously().

47  {
48  checkState();
49  return setupId(Bukkit.getScheduler().runTaskAsynchronously(plugin, this));
50  }
synchronized BukkitTask org.bukkit.scheduler.BukkitRunnable.runTaskLater ( Plugin  plugin,
long  delay 
) throws IllegalArgumentException, IllegalStateException

Schedules this to run after the specified number of server ticks.

Parameters
pluginthe reference to the plugin scheduling task
delaythe ticks to wait before running the task
Returns
a BukkitTask that contains the id number
Exceptions
IllegalArgumentExceptionif plugin is null
IllegalStateExceptionif this was already scheduled
See also
BukkitScheduler::runTaskLater(Plugin, Runnable, long)

Definition at line 62 of file BukkitRunnable.java.

References org.bukkit.Bukkit.getScheduler(), and org.bukkit.scheduler.BukkitScheduler.runTaskLater().

62  {
63  checkState();
64  return setupId(Bukkit.getScheduler().runTaskLater(plugin, this, delay));
65  }
synchronized BukkitTask org.bukkit.scheduler.BukkitRunnable.runTaskLaterAsynchronously ( Plugin  plugin,
long  delay 
) throws IllegalArgumentException, IllegalStateException

Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.

Schedules this to run asynchronously after the specified number of server ticks.

Parameters
pluginthe reference to the plugin scheduling task
delaythe ticks to wait before running the task
Returns
a BukkitTask that contains the id number
Exceptions
IllegalArgumentExceptionif plugin is null
IllegalStateExceptionif this was already scheduled
See also
BukkitScheduler::runTaskLaterAsynchronously(Plugin, Runnable, long)

Definition at line 81 of file BukkitRunnable.java.

References org.bukkit.Bukkit.getScheduler(), and org.bukkit.scheduler.BukkitScheduler.runTaskLaterAsynchronously().

81  {
82  checkState();
83  return setupId(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, this, delay));
84  }
synchronized BukkitTask org.bukkit.scheduler.BukkitRunnable.runTaskTimer ( Plugin  plugin,
long  delay,
long  period 
) throws IllegalArgumentException, IllegalStateException

Schedules this to repeatedly run until cancelled, starting after the specified number of server ticks.

Parameters
pluginthe reference to the plugin scheduling task
delaythe ticks to wait before running the task
periodthe ticks to wait between runs
Returns
a BukkitTask that contains the id number
Exceptions
IllegalArgumentExceptionif plugin is null
IllegalStateExceptionif this was already scheduled
See also
BukkitScheduler::runTaskTimer(Plugin, Runnable, long, long)

Definition at line 98 of file BukkitRunnable.java.

References org.bukkit.Bukkit.getScheduler(), and org.bukkit.scheduler.BukkitScheduler.runTaskTimer().

98  {
99  checkState();
100  return setupId(Bukkit.getScheduler().runTaskTimer(plugin, this, delay, period));
101  }
synchronized BukkitTask org.bukkit.scheduler.BukkitRunnable.runTaskTimerAsynchronously ( Plugin  plugin,
long  delay,
long  period 
) throws IllegalArgumentException, IllegalStateException

Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.

Schedules this to repeatedly run asynchronously until cancelled, starting after the specified number of server ticks.

Parameters
pluginthe reference to the plugin scheduling task
delaythe ticks to wait before running the task for the first time
periodthe ticks to wait between runs
Returns
a BukkitTask that contains the id number
Exceptions
IllegalArgumentExceptionif plugin is null
IllegalStateExceptionif this was already scheduled
See also
BukkitScheduler::runTaskTimerAsynchronously(Plugin, Runnable, long, long)

Definition at line 120 of file BukkitRunnable.java.

References org.bukkit.Bukkit.getScheduler(), and org.bukkit.scheduler.BukkitScheduler.runTaskTimerAsynchronously().

120  {
121  checkState();
122  return setupId(Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, this, delay, period));
123  }

The documentation for this class was generated from the following file: