1.8.8 Custom Enchants

Discussion in 'Spigot Plugin Development' started by Ninjablader101, Mar 24, 2020.

  1. Code (Java):
    package prisons.prisons.Enchants.Armour;

    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.inventory.ItemStack;

    public class OverLoad implements Listener {
        @EventHandler
        public void ArmourEquipevent(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            ItemStack Boots = player.getInventory().getBoots();
            ItemStack Legs = player.getInventory().getLeggings();
            ItemStack Chest = player.getInventory().getChestplate();
            ItemStack Helm = player.getInventory().getHelmet();

            if (Boots != null || Legs != null || Chest != null || Helm != null){
                if ((Boots.getItemMeta().getLore() != null) || Legs.getItemMeta().getLore() != null || Chest.getItemMeta().getLore() != null || Helm.getItemMeta().getLore() != null){
                    if (Boots.getItemMeta().getLore().contains(ChatColor.GOLD +"Overload " + ChatColor.AQUA + "I")){
                        player.setMaxHealth(24);
                    } else if (Boots.getItemMeta().getLore().contains(ChatColor.GOLD +"OverLoad " + ChatColor.AQUA + "II")){
                        player.setMaxHealth(28);
                    } else if (Boots.getItemMeta().getLore().contains(ChatColor.GOLD +"Overload " + ChatColor.AQUA + "III")){
                        player.setMaxHealth(32);
                    } else player.setMaxHealth(20);
                    player.sendMessage("DEBUG 3");

                }else player.setMaxHealth(20);
                player.sendMessage("DEBUG 2");
            } else player.setMaxHealth(20);
            player.sendMessage("DEBUG 1");
        }
    }
     
    if i take the boots with overload III off i get 28 hearts i put them on i only get 20. what am i doing wrong?
     
  2. The only thing I see is that in the 1. if else clause you check for "OverLoad" and in the second you check for "Overload" (lowercase 'l').
    - If your post is marked as solved please provide a solution for everyone else having this issue. (+ close the post)
     
  3. it's not solved and I don't think having a lowercase really matters that much. Since it worked while off.
     
  4. Capitalization matters a lot lol.
     
  5. + The thread is marked as solved.
     
  6. Yeah idk why i marked it as solved.