chore: 优化部分逻辑

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2021-08-03 17:30:53 +08:00
parent b36b63277f
commit d5c2a825fc
6 changed files with 66 additions and 18 deletions

View File

@@ -21,11 +21,11 @@ export class BukkitTaskManager extends task.TaskManager {
export class BukkitTask extends task.Task {
submit0(...args: any[]): task.Cancelable {
let run = new BukkitRunnable({ run: () => this.run(...args) })
let funcName = `runTask${this.interval ? 'Timer' : 'Later'}${this.isAsync ? 'Asynchronously' : ''}`
let suffix = this.isAsync ? 'Asynchronously' : ''
if (this.interval) {
return run[funcName](base.getInstance(), this.laterTime, this.interval)
return run[`runTaskTimer${suffix}`](base.getInstance(), this.laterTime, this.interval)
} else {
return run[funcName](base.getInstance(), this.laterTime)
return run[`runTaskLater${suffix}`](base.getInstance(), this.laterTime)
}
}
}