PlayerRespawnEvent 不是 运行 所有代码 SpigotMC
PlayerRespawnEvent not running all the code SpigotMC
所以我正在尝试制作一个受 Fundy 启发的 impossibleX 难度,并且我正在尝试制作它以便当玩家重生时他会感到虚弱,如下所示,但事实是它不会将他们的健康设置为一半,并在他重生后添加 slowness/weakness/mining 疲劳,但它确实会发送消息“重生后你感到虚弱......”
我可以帮忙吗?
public static void nahwouldyounotrespawn(PlayerRespawnEvent e){
Player player = e.getPlayer();
player.sendMessage("You feel weak after respawning...");
player.setHealth(10);
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 30000, 5));
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 30000, 5));
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 30000, 255));
}
这是 您得到的答案包含有关如何安排任务的信息。我强烈建议您实际阅读您收到的文章,因为它们会对您有所帮助。
public void playerRespawnEffects(PlayerRespawnEvent e){
Player player = e.getPlayer();
player.sendMessage("You feel weak after respawning...");
Bukkit.getScheduler().runTaskLater(/*Your plugin instance*/, () -> {
player.setHealth(10);
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 30000, 5));
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 30000, 5));
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 30000, 255));
}, /*Tick delay here e.g. 1L*/);
}
所以我正在尝试制作一个受 Fundy 启发的 impossibleX 难度,并且我正在尝试制作它以便当玩家重生时他会感到虚弱,如下所示,但事实是它不会将他们的健康设置为一半,并在他重生后添加 slowness/weakness/mining 疲劳,但它确实会发送消息“重生后你感到虚弱......”
我可以帮忙吗?
public static void nahwouldyounotrespawn(PlayerRespawnEvent e){
Player player = e.getPlayer();
player.sendMessage("You feel weak after respawning...");
player.setHealth(10);
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 30000, 5));
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 30000, 5));
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 30000, 255));
}
这是
public void playerRespawnEffects(PlayerRespawnEvent e){
Player player = e.getPlayer();
player.sendMessage("You feel weak after respawning...");
Bukkit.getScheduler().runTaskLater(/*Your plugin instance*/, () -> {
player.setHealth(10);
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 30000, 5));
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 30000, 5));
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 30000, 255));
}, /*Tick delay here e.g. 1L*/);
}