Solved Weird Issue with PlayerInteractEvent

Discussion in 'BungeeCord Plugin Development' started by CosmicFlameV2, Jun 20, 2016.

  1. My Non Working IronGolem Pet Class (I have registered it!)
    Code (Text):

    package com.prophecyrealms.net.pets;

    import org.bukkit.ChatColor;
    import org.bukkit.Effect;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;

    public class IronGolemPet implements Listener{
       
        @SuppressWarnings("deprecation")
        public void IGPet(PlayerInteractEvent e){
            Player p = e.getPlayer();
            ItemStack hand = p.getItemInHand();
           
      if(p.getWorld().getName().equalsIgnoreCase(p.getWorld().getName())){

        if(hand.hasItemMeta() && hand.getItemMeta().hasDisplayName() && ChatColor.stripColor(hand.getItemMeta().getDisplayName()).contains("Irongolem Pet")){
           
            p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 1000, 5));
            p.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 1000, 5));
            p.playEffect(p.getLocation(), Effect.MOBSPAWNER_FLAMES, 10);
            p.playEffect(p.getLocation(), Effect.MOBSPAWNER_FLAMES, 10);
            p.playEffect(p.getLocation(), Effect.MOBSPAWNER_FLAMES, 10);
            p.playEffect(p.getLocation(), Effect.MOBSPAWNER_FLAMES, 10);

           
        }
           
        }

    }
    }
     

    My Working Valentines Pet Class (Its same code wtf)
    Code (Text):

    package com.prophecyrealms.net.pets;
    import org.bukkit.ChatColor;
    import org.bukkit.Effect;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;


    public class ValentinesPet implements Listener {
       
        @SuppressWarnings("deprecation")
        @EventHandler
        public void VPet(PlayerInteractEvent e){

                Player p = e.getPlayer();
                ItemStack hand = p.getItemInHand();
             if(p.getWorld().getName().equalsIgnoreCase(p.getWorld().getName())){
                if(hand.hasItemMeta() && hand.getItemMeta().hasDisplayName() && ChatColor.stripColor(hand.getItemMeta().getDisplayName()).contains("Valentines Pet")){
                    p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 1));
                    p.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 100, 3));
                    p.playEffect(p.getLocation(), Effect.HEART, 30);
                }
               
             }
             
       

        }
       
       
    }
     

    I Need Urgent Help!
     
  2. Code (Text):
     if(p.getWorld().getName().equalsIgnoreCase(p.getWorld().getName()))

    what's the point of this...?