我目前在使用插件时遇到问题。我想给播放器效果 5 秒,5 秒后,应该是白天。我的问题是,day 命令立即执行,所以在效果结束之前是 day。 你能帮我吗,将时间设置为 1000 的命令在执行前等待 5 秒? 帮助将不胜感激, 直到
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);
最佳答案
我还建议使用 BukkitRunnable .提供此类作为处理调度任务的简单方法。
new BukkitRunnable(
public void run() {
Bukkit.getWorld("world").setTime(1000);
}
).runTaskLater(yourPluginInstance, delayInTicks);
请记住,20 个服务器滴答等于 1 个服务器秒。所以 delayInTicks = 5s * 20 = 100
关于Java (Bukkit) - 在执行下一行之前等待,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49352995/