我的 bukkit 有问题。我想做一个重复任务,发送带有玩家坐标的消息。 感谢您的帮助!
Bukkit.getScheduler().scheduleAsyncRepeatingTask(this.main, new Runnable() {
@Override
public void run() {
Player tp = Bukkit.getPlayer(args[1]);
p.sendMessage("§bThe coordinates of §4" + tp.getName());
p.sendMessage("§eX: " + tp.getLocation().getBlockX());
p.sendMessage("§eY: " + tp.getLocation().getBlockY());
p.sendMessage("§eZ: " + tp.getLocation().getBlockZ());
p.sendMessage("§eD: " + tp.getLocation().getDirection());
}
}, 1, 1);
最佳答案
您不应使用异步任务来访问 bukkit api。相反,安排同步任务,例如使用 BukkitRunnable 和 lambda:
new BukkitRunnable( () -> {
//Runnable run method, do stuff here
}).runTaskTimer (plugin, initialDelay, repeatingDelay);
关于java - bukkit 调度程序重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45745546/