Solved Task Error

Discussion in 'Plugin Development' started by Coopah, Dec 14, 2014.

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

    Coopah

    So I'm trying to make it when you are in lava with a certian type of armor it repairs it self gradually, and when you step out of it, it stops repairing. The error is when you step out of it, it keeps going then stops after 5 seconds and starts again after 5 seconds. Am I doing something wrong? I have only done the helmet for test purposes.
    Code:
    Code:
        @EventHandler
        public void onRepair(PlayerMoveEvent e) {
    
            final Player p = e.getPlayer();
    
            if (Mage.MageEquip(p.getEquipment())) {
    
                if (p.getLocation().getBlock().getType() == Material.LAVA || p.getLocation().getBlock().getType() == Material.STATIONARY_LAVA) {
    
                    RepairingHelm.add(p.getName());
                    RepairingChestP.add(p.getName());
                    RepairingLegs.add(p.getName());
                    RepairingBoots.add(p.getName());
    
                    Bukkit.getScheduler().runTaskTimer(this.plugin, new Runnable() {
    
                        public void run() {
                            if (RepairingHelm.contains(p.getName()));                      
                            if (Mage.MageEquip(p.getEquipment())) {
                                p.getEquipment().getHelmet().setDurability((short) (p.getEquipment().getHelmet().getDurability() - 5));
                                p.sendMessage("repairing");
                            }
                        }
                    }, 0L, 100L);
                } else {
                    p.setFireTicks(0);
                    RepairingHelm.remove(p.getName());
                    p.sendMessage("test");
                }
            }
        }
     
  2. @Coopah Sorry but what exactly does this do?
    Code:
    if (RepairingHelm.contains(p.getName()));
    You're using the PlayerMoveEvent to run the timer. Even the rotation of the head will set this off and then begin the timer. What I would do is check if the player is in lava, inside the timer.
     
  3. Offline

    teej107

  4. Offline

    Coopah

    Alright I'll try these two things, thanks for the help! :D
     
Thread Status:
Not open for further replies.

Share This Page