Do something until player is killed

Discussion in 'Plugin Development' started by wowlover6877, Jan 27, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    wowlover6877

    How would you make something happen over and over again until the player is killed? I know this involves a loop, but I can't figure out how.
     
  2. Offline

    DJSanderrr

    What do you want to do? Maybe we get an idea what you mean then.
     
  3. Offline

    wowlover6877

    I want the player to have these potion effects every 10 seconds until the player dies. Here's a part of my code:
    Code:
                            target.sendMessage(ChatColor.BOLD + "You feel drowsy.");
                            target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 10, 10));
                            plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                                @Override
                                public void run() {
                                    int currentLife2 = target.getHealth();
                                    target.sendMessage(ChatColor.BOLD + "You feel confused and a bit blind.");
                                    target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10, 10));
                                    target.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 10, 10));
                                    target.setHealth(currentLife2 - 2);
                                }
                            }, 200L);
     
  4. Offline

    DJSanderrr

    Don't you just need to add; if (event.getPlayer().getHealth() == 0){
    **stop**
    }else{
    **continue**
     
Thread Status:
Not open for further replies.

Share This Page