Commits
Wesley Wolfe authored 246c53f5a2a
22 22 | * Schedules this in the Bukkit scheduler to run on next tick. |
23 23 | * |
24 24 | * @param plugin the reference to the plugin scheduling task |
25 25 | * @return a BukkitTask that contains the id number |
26 26 | * @throws IllegalArgumentException if plugin is null |
27 27 | * @throws IllegalStateException if this was already scheduled |
28 28 | * @see BukkitScheduler#runTask(Plugin, Runnable) |
29 29 | */ |
30 30 | public synchronized BukkitTask runTask(Plugin plugin) throws IllegalArgumentException, IllegalStateException { |
31 31 | checkState(); |
32 - | return setupId(Bukkit.getScheduler().runTask(plugin, this)); |
32 + | return setupId(Bukkit.getScheduler().runTask(plugin, (Runnable) this)); |
33 33 | } |
34 34 | |
35 35 | /** |
36 36 | * <b>Asynchronous tasks should never access any API in Bukkit. Great care |
37 37 | * should be taken to assure the thread-safety of asynchronous tasks.</b> |
38 38 | * <p> |
39 39 | * Schedules this in the Bukkit scheduler to run asynchronously. |
40 40 | * |
41 41 | * @param plugin the reference to the plugin scheduling task |
42 42 | * @return a BukkitTask that contains the id number |
43 43 | * @throws IllegalArgumentException if plugin is null |
44 44 | * @throws IllegalStateException if this was already scheduled |
45 45 | * @see BukkitScheduler#runTaskAsynchronously(Plugin, Runnable) |
46 46 | */ |
47 47 | public synchronized BukkitTask runTaskAsynchronously(Plugin plugin) throws IllegalArgumentException, IllegalStateException { |
48 48 | checkState(); |
49 - | return setupId(Bukkit.getScheduler().runTaskAsynchronously(plugin, this)); |
49 + | return setupId(Bukkit.getScheduler().runTaskAsynchronously(plugin, (Runnable) this)); |
50 50 | } |
51 51 | |
52 52 | /** |
53 53 | * Schedules this to run after the specified number of server ticks. |
54 54 | * |
55 55 | * @param plugin the reference to the plugin scheduling task |
56 56 | * @param delay the ticks to wait before running the task |
57 57 | * @return a BukkitTask that contains the id number |
58 58 | * @throws IllegalArgumentException if plugin is null |
59 59 | * @throws IllegalStateException if this was already scheduled |
60 60 | * @see BukkitScheduler#runTaskLater(Plugin, Runnable, long) |
61 61 | */ |
62 62 | public synchronized BukkitTask runTaskLater(Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException { |
63 63 | checkState(); |
64 - | return setupId(Bukkit.getScheduler().runTaskLater(plugin, this, delay)); |
64 + | return setupId(Bukkit.getScheduler().runTaskLater(plugin, (Runnable) this, delay)); |
65 65 | } |
66 66 | |
67 67 | /** |
68 68 | * <b>Asynchronous tasks should never access any API in Bukkit. Great care |
69 69 | * should be taken to assure the thread-safety of asynchronous tasks.</b> |
70 70 | * <p> |
71 71 | * Schedules this to run asynchronously after the specified number of |
72 72 | * server ticks. |
73 73 | * |
74 74 | * @param plugin the reference to the plugin scheduling task |
75 75 | * @param delay the ticks to wait before running the task |
76 76 | * @return a BukkitTask that contains the id number |
77 77 | * @throws IllegalArgumentException if plugin is null |
78 78 | * @throws IllegalStateException if this was already scheduled |
79 79 | * @see BukkitScheduler#runTaskLaterAsynchronously(Plugin, Runnable, long) |
80 80 | */ |
81 81 | public synchronized BukkitTask runTaskLaterAsynchronously(Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException { |
82 82 | checkState(); |
83 - | return setupId(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, this, delay)); |
83 + | return setupId(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, (Runnable) this, delay)); |
84 84 | } |
85 85 | |
86 86 | /** |
87 87 | * Schedules this to repeatedly run until cancelled, starting after the |
88 88 | * specified number of server ticks. |
89 89 | * |
90 90 | * @param plugin the reference to the plugin scheduling task |
91 91 | * @param delay the ticks to wait before running the task |
92 92 | * @param period the ticks to wait between runs |
93 93 | * @return a BukkitTask that contains the id number |
94 94 | * @throws IllegalArgumentException if plugin is null |
95 95 | * @throws IllegalStateException if this was already scheduled |
96 96 | * @see BukkitScheduler#runTaskTimer(Plugin, Runnable, long, long) |
97 97 | */ |
98 98 | public synchronized BukkitTask runTaskTimer(Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException { |
99 99 | checkState(); |
100 - | return setupId(Bukkit.getScheduler().runTaskTimer(plugin, this, delay, period)); |
100 + | return setupId(Bukkit.getScheduler().runTaskTimer(plugin, (Runnable) this, delay, period)); |
101 101 | } |
102 102 | |
103 103 | /** |
104 104 | * <b>Asynchronous tasks should never access any API in Bukkit. Great care |
105 105 | * should be taken to assure the thread-safety of asynchronous tasks.</b> |
106 106 | * <p> |
107 107 | * Schedules this to repeatedly run asynchronously until cancelled, |
108 108 | * starting after the specified number of server ticks. |
109 109 | * |
110 110 | * @param plugin the reference to the plugin scheduling task |
111 111 | * @param delay the ticks to wait before running the task for the first |
112 112 | * time |
113 113 | * @param period the ticks to wait between runs |
114 114 | * @return a BukkitTask that contains the id number |
115 115 | * @throws IllegalArgumentException if plugin is null |
116 116 | * @throws IllegalStateException if this was already scheduled |
117 117 | * @see BukkitScheduler#runTaskTimerAsynchronously(Plugin, Runnable, long, |
118 118 | * long) |
119 119 | */ |
120 120 | public synchronized BukkitTask runTaskTimerAsynchronously(Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException { |
121 121 | checkState(); |
122 - | return setupId(Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, this, delay, period)); |
122 + | return setupId(Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, (Runnable) this, delay, period)); |
123 123 | } |
124 124 | |
125 125 | /** |
126 126 | * Gets the task id for this runnable. |
127 127 | * |
128 128 | * @return the task id that this runnable was scheduled as |
129 129 | * @throws IllegalStateException if task was not scheduled yet |
130 130 | */ |
131 131 | public synchronized int getTaskId() throws IllegalStateException { |
132 132 | final int id = taskId; |