Solved A (scheduler) inside a (implements Listener)

Discussion in 'Plugin Development' started by thorvaldemar, Mar 27, 2016.

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

    thorvaldemar

    Hi Everyone.

    I'm trying to make a training doll thing, so when you kill the training doll(Armorstand) it will desapear and the n come back after a short amount of time. I know how i will make it desapear and how i would make it comeback, but i don't know how i would make a time.

    Hope you understand my question.
     
  2. Offline

    Corndogoz

    try using a bukkit scheduler.
     
  3. Offline

    thorvaldemar

    @Corndogoz Yea... I've tryed that, but i don't know how to do that inside a implements Listener?
     
  4. Offline

    Zombie_Striker

  5. Offline

    Corndogoz

    are schedulers really different in listeners then not?
     
  6. Offline

    Zombie_Striker

    @Corndogoz
    They are different. Schedulers work by setting a point in which they update (E.g. Every tick/ every second/ every couple of seconds), and after that point it will update and run the "run" method.
     
  7. Offline

    Corndogoz

    i still don't see how that makes it different in a listener.

    EDIT: i just looked over that page again, nowwww i see :)
     
  8. Offline

    Swakiny

    Have you tried, right? Can you show us the code?
     
  9. Offline

    thorvaldemar

    Okay. I've tryed reading it through again and i think i understand now... Thanks for all your help XD

    @Corndogoz Ohh... i've find a problem... When i tun the task it execute it rwo times???

    Code:
     else if (e.getDamager() instanceof Arrow) {
                Entity entity = e.getEntity();
                Arrow arrow = (Arrow) e.getDamager();
                Player p = (Player) arrow.getShooter();
    
                if (entity instanceof ArmorStand) {
                    ArmorStand armorstand = (ArmorStand) e.getEntity();
                    armorstand.setHealth(20);
    
                    if ((armorstand.getHealth() - e.getDamage()) <= 19) {
    
                        armorstand.setVisible(false);
                        armorstand.setMarker(true);
    
                        delay.put(armorstand, 0);
    
                        p.sendMessage(ChatColor.AQUA + "You've killed a ArmorStand");
                     
                        new BukkitRunnable() {
                         
                            @Override
                            public void run() {
                                armorstand.setVisible(true);
                                armorstand.setMarker(false);
                            }
                         
                        }.runTaskLater(this.plugin, 20);
                    }
    
                }
            }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited: Mar 27, 2016
Thread Status:
Not open for further replies.

Share This Page