0

So I'm trying to make a impossibleX difficulty which is inspired by Fundy and I'm trying to make it so that when a player respawns he feels weak as shown below, but the thing is that it won't set their health to half and add the slowness/weakness/mining fatigue after he respawns, but it does send the message "You feel weak after respawning..."

May I have some help?

    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));
    }

1 Answers1

2

This is the fourth time you've got an answer containing information on how to schedule a task. I would strongly urge you to actually read the articles you have been given as they will help you.

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*/);
}
Lucan
  • 2,907
  • 2
  • 16
  • 30