Solved Can't figure out why the HP regen is working

Discussion in 'Plugin Help/Development/Requests' started by Kieran98, Mar 8, 2016.

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

    Kieran98

    Hello, I'm currently updating an old plugin from 1.7 to 1.8 and up until now everything has been successful.
    The problem is a custom lore "HP regen" so the first problem was to add a special for loop and after doing this it removed all the errors but when i exported it to test the HP wasn't regening.
    I've been learning to code java for a month or 2 now and i can't seem to get it to work.
    I apologize if the description of the problem so If you need me to supply any more information just tell me what and i'll get it for you :)
    Thank you for your time
    Code:
    BEFORE:
        new BukkitRunnable()
        {
          public void run()
          {
            Main.this.reboot();
          }
        }.runTaskLater(this, 144000L);
        Bukkit.getServer().getScheduler()
          .scheduleSyncRepeatingTask(this, new Runnable()
          {
            public void run()
            {
              Player[] arrayOfPlayer;
              int j = (arrayOfPlayer = Bukkit.getServer().getOnlinePlayers()).length;
              for (int i = 0; i < j; i++)
              {
                Player p = arrayOfPlayer;
                if ((!Main.tagged.contains(p.getName())) &&
                  (!p.isDead()))
                {
                  PlayerInventory i = p.getInventory();
                  double amt = 5.0D;
                  if (i.getHelmet() != null) {
                    if (i.getHelmet().getItemMeta().hasLore())
                    {
                      double added = Main.getHpgenFromLore(
                        i.getHelmet(), "HP REGEN");
                      amt += added;
                    }
                  }
                  if (i.getChestplate() != null) {
                    if (i.getChestplate().getItemMeta().hasLore())
                    {
                      double added = Main.getHpgenFromLore(
                        i.getChestplate(), "HP REGEN");
                      amt += added;
                    }
                  }
                  if (i.getLeggings() != null) {
                    if (i.getLeggings().getItemMeta().hasLore())
                    {
                      double added = Main.getHpgenFromLore(
                        i.getLeggings(), "HP REGEN");
                      amt += added;
                    }
                  }
                  if (i.getBoots() != null) {
                    if (i.getBoots().getItemMeta().hasLore())
                    {
                      double added = Main.getHpgenFromLore(
                        i.getBoots(), "HP REGEN");
                      amt += added;
                    }
                  }
                  if (p.getHealth() + amt > p.getMaxHealth()) {
                    p.setHealth(p.getMaxHealth());
                  } else {
                    p.setHealth(p.getHealth() + amt);
                  }
                }
              }
            }
          }, 1L, 20L);
      }
    }
    AFTER:
    new BukkitRunnable()
        {
          public void run()
          {
            Mmo.this.reboot();
          }
        }.runTaskLater(this, 144000L);
     
        Bukkit.getServer().getScheduler()
          .scheduleSyncRepeatingTask(this, new Runnable()
          {
            public void run()
            {
              for (Player p : Bukkit.getOnlinePlayers())
              {
                if ((!Mmo.tagged.contains(p.getName())) &&
                  (!p.isDead()))
                {
                  PlayerInventory i = p.getInventory();
                  double amt = 5.0D;
                  if (i.getHelmet() != null) {
                    if (i.getHelmet().getItemMeta().hasLore())
                    {
                      double added = Mmo.getHpgenFromLore(
                        i.getHelmet(), "HP REGEN");
                      amt += added;
                    }
                  }
                  if (i.getChestplate() != null) {
                    if (i.getChestplate().getItemMeta().hasLore())
                    {
                      double added = Mmo.getHpgenFromLore(
                        i.getChestplate(), "HP REGEN");
                      amt += added;
                    }
                  }
                  if (i.getLeggings() != null) {
                    if (i.getLeggings().getItemMeta().hasLore())
                    {
                      double added = Mmo.getHpgenFromLore(
                        i.getLeggings(), "HP REGEN");
                      amt += added;
                    }
                  }
                  if (i.getBoots() != null) {
                    if (i.getBoots().getItemMeta().hasLore())
                    {
                      double added = Mmo.getHpgenFromLore(
                        i.getBoots(), "HP REGEN");
                      amt += added;
                    }
                  }
                  if (p.getHealth() + amt > p.getMaxHealth()) {
                    p.setHealth(p.getMaxHealth());
                  } else {
                    p.setHealth(p.getHealth() + amt);
                  }
                }
              }
            }
          }, 1L, 20L);
      }
    }
     
    Last edited: Mar 8, 2016
  2. Offline

    WolfMage1

    @Kieran98 please remove the code and put it back in using the import code (left of the floppy disk)
     
  3. Offline

    Kieran98

    Done. Ty
     
Thread Status:
Not open for further replies.

Share This Page