Neither of these Events are working or throwing an error

Discussion in 'Plugin Development' started by JarFile, Jan 17, 2015.

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

    JarFile

    Code:
        @EventHandler
        public void SoapDrop(PlayerDropItemEvent e)
        {
            Player p = e.getPlayer();
            ItemStack soap = new ItemStack(Material.WOOL, 1, (short)6);
            ItemMeta a = soap.getItemMeta();
            a.setDisplayName("§d§lSoap");
            soap.setItemMeta(a);
           if(e.getItemDrop().equals(soap)){
              p.sendMessage("§8§l[§b§lUL§8§l] §f§lYou have just dropped the §d§lSoap!");
              if(p.getGameMode() == GameMode.ADVENTURE)
              {
                  p.setGameMode(GameMode.SURVIVAL);
              }
              if(p.getGameMode() == GameMode.CREATIVE)
              {
                  p.setGameMode(GameMode.SURVIVAL);
              }
              p.setHealth(0.5F);
              p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10000, 3));
              p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 10000, 3));
              p.sendMessage(ChatColor.BLACK + "You just got banged!");
              p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 10000, 1));
              p.getLocation().add(5, 1, 5);
              p.playSound(p.getLocation(), Sound.CAT_HISS, 1, 1);
              p.playSound(p.getLocation(), Sound.BURP, 1, 1);
              p.playSound(p.getLocation(), Sound.BLAZE_BREATH, 1, 1);
           }
        }
    
    and
    Code:
        @EventHandler
        public void Soap(PlayerInteractEvent e)
        {
            Player p = e.getPlayer();
            ItemStack agua = new ItemStack(Material.WATER);
            ItemStack soap = new ItemStack(Material.WOOL, 1, (short)6);
            ItemMeta a = soap.getItemMeta();
            a.setDisplayName("§d§lSoap");
            soap.setItemMeta(a);
            Action action = e.getAction();
            if(!(e.getAction() == Action.RIGHT_CLICK_AIR || action.equals(Action.RIGHT_CLICK_BLOCK))) return;
            if(!(e.getItem().getType() == Material.CHEST)) return;
            if(p.getInventory().contains(soap, 1) || p.getInventory().contains(soap, 2) || p.getInventory().contains(soap, 3) || p.getInventory().contains(soap, 4) || p.getInventory().contains(soap, 5) || p.getInventory().contains(soap, 6) || p.getInventory().contains(soap, 7) || p.getInventory().contains(soap, 8) || p.getInventory().contains(soap, 9) || p.getInventory().contains(soap, 10) || p.getInventory().contains(soap, 11) || p.getInventory().contains(soap, 12) || p.getInventory().contains(soap, 13) || p.getInventory().contains(soap, 14) || p.getInventory().contains(soap, 15) || p.getInventory().contains(soap, 16) || p.getInventory().contains(soap, 17) || p.getInventory().contains(soap, 18) || p.getInventory().contains(soap, 19) || p.getInventory().contains(soap, 20) || p.getInventory().contains(soap, 21) || p.getInventory().contains(soap, 22) || p.getInventory().contains(soap, 23) || p.getInventory().contains(soap, 24) || p.getInventory().contains(soap, 25) || p.getInventory().contains(soap, 26) || p.getInventory().contains(soap, 27) || p.getInventory().contains(soap, 28) || p.getInventory().contains(soap, 29) || p.getInventory().contains(soap, 30) || p.getInventory().contains(soap, 31) || p.getInventory().contains(soap, 32) || p.getInventory().contains(soap, 33) || p.getInventory().contains(soap, 34) || p.getInventory().contains(soap, 35) || p.getInventory().contains(soap, 36) || p.getInventory().contains(soap, 37) || p.getInventory().contains(soap, 38) || p.getInventory().contains(soap, 39) || p.getInventory().contains(soap, 40) || p.getInventory().contains(soap, 41) || p.getInventory().contains(soap, 42) || p.getInventory().contains(soap, 43) || p.getInventory().contains(soap, 44) || p.getInventory().contains(soap, 45) || p.getInventory().contains(soap, 46) || p.getInventory().contains(soap, 47) || p.getInventory().contains(soap, 48) || p.getInventory().contains(soap, 49) || p.getInventory().contains(soap, 50) || p.getInventory().contains(soap, 51) || p.getInventory().contains(soap, 52) || p.getInventory().contains(soap, 53) || p.getInventory().contains(soap, 54) || p.getInventory().contains(soap, 55) || p.getInventory().contains(soap, 56) || p.getInventory().contains(soap, 57) || p.getInventory().contains(soap, 58) || p.getInventory().contains(soap, 59) || p.getInventory().contains(soap, 60) || p.getInventory().contains(soap, 61) || p.getInventory().contains(soap, 62) || p.getInventory().contains(soap, 63) || p.getInventory().contains(soap, 64))
            {
                p.playSound(p.getLocation(), Sound.LEVEL_UP, 1, 1);
                p.sendMessage(ChatColor.AQUA + "Cleaning your body!" + ChatColor.LIGHT_PURPLE + " Remember DON'T DROP THE SOAP!");
                p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 1000, 5));
                p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 1000, 1));
                p.getInventory().removeItem(soap);
            }
        }
    
    Neither of these events are working, or throwing an error. What did I do wrong?
     
  2. Offline

    teej107

  3. Offline

    DatCookiez

  4. Offline

    JarFile

    @DatCookiez Yes... Every other Event works... but those two.
     
  5. Offline

    teej107

  6. Offline

    JarFile

  7. Offline

    teej107

    @JarFile
     
  8. Offline

    JarFile

    @teej107 Did that with console outputs. When I drop and right click anything it prints that to the console.
    So this is the problem:
    if(e.getItemDrop().equals(soap))
    Found the first ones problem, but not the second
     
    Last edited: Jan 17, 2015
  9. Offline

    teej107

    Well the dropped item does not equal "soap" obviously. Make sure you are dropping the right item.
     
  10. Offline

    JarFile

    @teej107 I did the same Item for the Right click and it doesn't work:
    Code:
        @EventHandler
        public void SoapDrop(PlayerDropItemEvent e)
        {
            Player p = e.getPlayer();
            ItemStack soap = new ItemStack(Material.WOOL, 1, (short)6);
            ItemMeta a = soap.getItemMeta();
            a.setDisplayName("§d§lSoap");
            soap.setItemMeta(a);
           if(e.getItemDrop().equals(soap)){
              p.sendMessage("§8§l[§b§lUL§8§l] §f§lYou have just dropped the §d§lSoap!");
              if(p.getGameMode() == GameMode.ADVENTURE)
              {
                  p.setGameMode(GameMode.SURVIVAL);
              }
              if(p.getGameMode() == GameMode.CREATIVE)
              {
                  p.setGameMode(GameMode.SURVIVAL);
              }
              p.setHealth(0.5F);
              p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10000, 3));
              p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 10000, 3));
              p.sendMessage(ChatColor.BLACK + "You just got banged!");
              p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 10000, 1));
              p.getLocation().add(5, 1, 5);
              p.playSound(p.getLocation(), Sound.CAT_HISS, 1, 1);
              p.playSound(p.getLocation(), Sound.BURP, 1, 1);
              p.playSound(p.getLocation(), Sound.BLAZE_BREATH, 1, 1);
           }
        }
    
    ItemStack soap = new ItemStack(Material.WOOL, 1, (short)6);
    Is the same as the right click event.
     
  11. Offline

    teej107

    @JarFile
    Create a method that returns the soap object. You'll be guaranteed that their value will be equal.
     
Thread Status:
Not open for further replies.

Share This Page