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"); } } }
@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.
@Coopah I would ditch the PlayerMoveEvent and just use a EntityDamageEvent and check the damage cause.