1.16.5 How can i get rid of nulls using IsSimilar here?

Discussion in 'Spigot Plugin Development' started by StTrigger, Jul 18, 2021.

  1. i need to check is player wearing Hazmat itemstack on the head and if he is effects dont apply
    but i dont need any nulls t appear in the cosnsole

    Code (Java):
        public void wither70(PlayerMoveEvent e) {
            Player p = e.getPlayer();
            float y = (float) p.getLocation().getBlockY();
                if (nuker.isBombActivated() == true) {
                    if (y >= 70.0F) {
                        p.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 20, 2));
                        p.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, 20, 2));
                        p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20, 2));
                        p.addPotionEffect(new PotionEffect(PotionEffectType.HARM, 20, 2));
                        p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 2));

  2. You have not put anything regarding player armor over there so I'm assuming you will implement it after getting answers, ItemStack.isSimilar(itemstack) checks if the itemstack you are comparing (the parameter) is null and if so just returns false. However if the item is null then it throws an error. So you could use (your armor name).isSimilar(player.getInventory().getBoots(); (or chestplate leggins.. whatever item you want)
    • Useful Useful x 1