@ -7,17 +7,14 @@ const Callable = Java.type('java.util.concurrent.Callable')
|
||||
|
||||
@provideSingleton(task.TaskManager)
|
||||
export class BukkitTaskManager extends task.TaskManager {
|
||||
@inject(plugin.PluginInstance)
|
||||
private pluginInstance: any
|
||||
|
||||
create0(func: Function): task.Task {
|
||||
return new BukkitTask(this.pluginInstance, func)
|
||||
create0(owner: plugin.Plugin, func: Function, id: number): task.Task {
|
||||
return new BukkitTask(owner, func, id)
|
||||
}
|
||||
callSyncMethod(func: Function): any {
|
||||
return Bukkit.getScheduler().callSyncMethod(this.pluginInstance, new Callable({ call: () => func() })).get()
|
||||
return Bukkit.getScheduler().callSyncMethod(base.getInstance(), new Callable({ call: () => func() })).get()
|
||||
}
|
||||
disable0() {
|
||||
Bukkit.getScheduler().cancelTasks(this.pluginInstance)
|
||||
Bukkit.getScheduler().cancelTasks(base.getInstance())
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,9 +23,9 @@ export class BukkitTask extends task.Task {
|
||||
let run = new BukkitRunnable({ run: () => this.run(...args) })
|
||||
let funcName = `runTask${this.interval ? 'Timer' : 'Later'}${this.isAsync ? 'Asynchronously' : ''}`
|
||||
if (this.interval) {
|
||||
return run[funcName](this.plugin, this.laterTime, this.interval)
|
||||
return run[funcName](base.getInstance(), this.laterTime, this.interval)
|
||||
} else {
|
||||
return run[funcName](this.plugin, this.laterTime)
|
||||
return run[funcName](base.getInstance(), this.laterTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user