What is the error

Discussion in 'Plugin Development' started by Saith1998, Dec 15, 2014.

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

    Saith1998

    Hello guys I get an error with this code
    Code:
    @EventHandler
       @SuppressWarnings("deprecation")
       public void onClicke(PlayerInteractEvent e){
         
         Player p = e.getPlayer();
         
         if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
           
           if(e.getClickedBlock().getState() instanceof Sign){
             
             Sign s = (Sign) e.getClickedBlock().getState();
             
             if(s.getLine(0).equalsIgnoreCase("[§6§lMobKit§0]")){
             
             if(s.getLine(1).equalsIgnoreCase("§5§lEnderman")){
               
               if(!(KitEisengolem.kit.contains(p.getName()))){
                 if(!(p.hasPermission("mk.enderman"))||!(p.hasPermission("mk.*"))){
                   p.sendMessage("§0[§6§lKit§0]§6Kaufe dir VIP um dieses Kit zu benutzten!");
                   return;
                 }
                 p.sendMessage("§0[§6§lKit§0]§aHier §6"+ p.getName()+ " §adas Endermankit!");
                 KitEisengolem.kit.add(p.getName());
    isEnder.add(p.getName());
                ItemStack item = new ItemStack(Material.IRON_SWORD);
                ItemStack item1 = new ItemStack(Material.LEATHER_HELMET);
                ItemStack item2 = new ItemStack(Material.IRON_CHESTPLATE);
                ItemStack item3 = new ItemStack(Material.LEATHER_LEGGINGS);
                ItemStack item4 = new ItemStack(Material.LEATHER_BOOTS);
                ItemStack item5 = new ItemStack(Material.COOKED_BEEF, 5);
                ItemStack item6 = new ItemStack(Material.ENDER_PEARL);
                 
                ItemMeta im = item.getItemMeta();
                 
                ItemMeta im2 = item2.getItemMeta();
                LeatherArmorMeta lam3 = (LeatherArmorMeta) item3.getItemMeta();
                 
                ItemMeta im5 = item5.getItemMeta();
                ItemMeta im6 = item6.getItemMeta();
                 
                LeatherArmorMeta lam = (LeatherArmorMeta) item1.getItemMeta();
                LeatherArmorMeta lam1 = (LeatherArmorMeta) item4.getItemMeta();
                im.setDisplayName("§8[§5§lENDERMAN§8]§5§lSchwert");
                lam.setDisplayName("§8[§5§lENDERMAN§8]§5§lHelm");
                im2.setDisplayName("§8[§5§lENDERMAN§8]§5§lBrustpanzer");
                lam3.setDisplayName("§8[§5§lENDERMAN§8]§5§lHose");
                lam1.setDisplayName("§8[§5§lENDERMAN§8]§5§lSchuhe");
                im5.setDisplayName("§8[§5§lENDERMAN§8]§5§lFleisch");
                im6.setDisplayName("§8[§5§lENDERMAN§8]§5§lEnderperle");
                p.getInventory().setHeldItemSlot(0);
                im.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
                p.getInventory().clear();
                   p.getInventory().setHelmet(new ItemStack (Material.AIR));
              p.getInventory().setChestplate(new ItemStack (Material.AIR));
              p.getInventory().setLeggings(new ItemStack (Material.AIR));
              p.getInventory().setBoots(new ItemStack (Material.AIR));
                 
                 
                lam.setColor((Color.BLACK));
                lam1.setColor((Color.BLACK));
                lam3.setColor((Color.BLACK));
                 
                lam1.addEnchant(Enchantment.PROTECTION_FALL, 10, true);
                 
                 
                item.setItemMeta(im);
                item5.setItemMeta(im5);
                 
                item4.setItemMeta(lam1);
                item1.setItemMeta(lam);
                item2.setItemMeta(im2);
                item3.setItemMeta(lam3);
               
                item6.setItemMeta(im6);
                p.getInventory().clear();
                p.getInventory().setHelmet(new ItemStack (Material.AIR));
            p.getInventory().setChestplate(new ItemStack (Material.AIR));
            p.getInventory().setLeggings(new ItemStack (Material.AIR));
            p.getInventory().setBoots(new ItemStack (Material.AIR));
                 
           
               
                 
                 
                 
                 
                 p.playEffect(p.getLocation(), Effect.MOBSPAWNER_FLAMES, 10);
                 
                 
                 p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 3, 5));
                 p.playSound(p.getLocation(), Sound.LEVEL_UP, 1F, 1F);
                p.getInventory().setItem(0, item);
                p.getInventory().setHelmet(item1);
                p.getInventory().setChestplate(item2);
                p.getInventory().setLeggings(item3);;
                p.getInventory().setBoots(item4);
                p.getInventory().addItem(item5);
                p.getInventory().addItem(item6);
                 return;
                 }
             
                 p.sendMessage("§0[§6§lKit§0]§4Du musst sterben bevor du dieses Kit benutzten darfst!");
                 p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);
                 p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);
                 p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);
                 return;
               }
             }
           }
             
           }
         }
     
    
    Always when I right click on a sign with
    Code:
     if(s.getLine(0).equalsIgnoreCase("[§6§lMobKit§0]")){
             
             if(s.getLine(1).equalsIgnoreCase("§5§lEnderman")){
    
    I get the kit but I also get this
    Code:
    p.sendMessage("§0[§6§lKit§0]§4Du musst sterben bevor du dieses Kit benutzten darfst!");
                 p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);
                 p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);
                 p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);
                 return;
    
    What is my mistake?
     
  2. Offline

    tcvs

    @Saith1998 It would be nice for you to tell us where your error resides your compiler should tell you which line. Or at least tell us what is wrong with it.
     
  3. Offline

    Saith1998

    @tcvs it is not really an error its just that it also says this line
    Code:
    p.sendMessage("§0[§6§lKit§0]§4Du musst sterben bevor du dieses Kit benutzten darfst!");
                 p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);
                 p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);
                 p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);
                 return;
    
    although I put a return;
    at then and of the code before
     
  4. Offline

    adam753

    @Saith1998
    Let's have a look at your code with good indentation.
    Code:java
    1. @EventHandler
    2. @SuppressWarnings("deprecation")
    3. public void onClicke(PlayerInteractEvent e){
    4.  
    5. Player p = e.getPlayer();
    6.  
    7. if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
    8.  
    9. if(e.getClickedBlock().getState() instanceof Sign){
    10.  
    11. Sign s = (Sign) e.getClickedBlock().getState();
    12.  
    13. if(s.getLine(0).equalsIgnoreCase("[§6§lMobKit§0]")){
    14.  
    15. if(s.getLine(1).equalsIgnoreCase("§5§lEnderman")){
    16.  
    17. if(!(KitEisengolem.kit.contains(p.getName()))){
    18. if(!(p.hasPermission("mk.enderman"))||!(p.hasPermission("mk.*"))){
    19. p.sendMessage("§0[§6§lKit§0]§6Kaufe dir VIP um dieses Kit zu benutzten!");
    20. return;
    21. }
    22. p.sendMessage("§0[§6§lKit§0]§aHier §6"+ p.getName()+ " §adas Endermankit!");
    23. KitEisengolem.kit.add(p.getName());
    24.  
    25. //Do lots of things
    26. return;
    27. }
    28.  
    29. p.sendMessage("§0[§6§lKit§0]§4Du musst sterben bevor du dieses Kit benutzten darfst!");
    30. p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);
    31. p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);
    32. p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);
    33. return;
    34. }
    35. }
    36. }
    37. }
    38. }

    Does that make the problem any clearer?
     
Thread Status:
Not open for further replies.

Share This Page