This commit is contained in:
sky
2020-04-12 15:04:54 +08:00
parent 5c4941f536
commit d9a8b73b51
9 changed files with 76 additions and 24 deletions

View File

@@ -137,4 +137,64 @@ public class InternalPlugin implements Plugin {
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
return null;
}
public void runTask(Runnable runnable) {
Bukkit.getScheduler().runTask(this, () -> {
try {
runnable.run();
} catch (Throwable t) {
t.printStackTrace();
}
});
}
public void runTaskAsync(Runnable runnable) {
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
try {
runnable.run();
} catch (Throwable t) {
t.printStackTrace();
}
});
}
public void runTask(Runnable runnable, long delay) {
Bukkit.getScheduler().runTaskLater(this, () -> {
try {
runnable.run();
} catch (Throwable t) {
t.printStackTrace();
}
}, delay);
}
public void runTaskAsync(Runnable runnable, long delay) {
Bukkit.getScheduler().runTaskLaterAsynchronously(this, () -> {
try {
runnable.run();
} catch (Throwable t) {
t.printStackTrace();
}
}, delay);
}
public void runTask(Runnable runnable, long delay, long period) {
Bukkit.getScheduler().runTaskTimer(this, () -> {
try {
runnable.run();
} catch (Throwable t) {
t.printStackTrace();
}
}, delay, period);
}
public void runTaskAsync(Runnable runnable, long delay, long period) {
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
try {
runnable.run();
} catch (Throwable t) {
t.printStackTrace();
}
}, delay, period);
}
}