我目前有一个插件的问题。感谢你的帮助,直到
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 100, 100, true));
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 100, true));
p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 100, -100, true));
p.sendMessage("§aGute Nacht!"); //german, dont worry :D
//here should be the delay of 5 seconds
Bukkit.getWorld("world").setTime(1000);发布于 2018-03-20 17:52:10
我也推荐使用BukkitRunnable。这个类是作为处理调度任务的一种简单方法提供的。
new BukkitRunnable(
public void run() {
Bukkit.getWorld("world").setTime(1000);
}
).runTaskLater(yourPluginInstance, delayInTicks);请记住,20个服务器节拍等于1个服务器秒。所以delayInTicks = 5s * 20 = 100
发布于 2018-03-19 05:33:26
你应该研究一下scheduleSyncDelayedTask我还没有测试过,但是你应该把目标定在这样的东西上。
myPlugin.getServer().getScheduler().scheduleSyncDelayedTask(myPlugin, new Runnable() {
public void run() {
Bukkit.getWorld("world").setTime(1000);
}
}, 100);将一次性任务安排为尽快发生。此任务将由主服务器线程执行。
参数:
plugin -拥有任务的插件
task -要执行的任务
返回:任务id号(如果调度失败,则为-1)
https://stackoverflow.com/questions/49352995
复制相似问题