I've a problem with a EntityDeathEvent

Discussion in 'Plugin Development' started by brunodm99, Mar 25, 2017.

Thread Status:
Not open for further replies.
  1. Why my code doesn't work, the console give me a "NoSuchFieldError: Elder_Guardian" when I kill it. The error is in the if statement (I think). Here's the code:


    Code:
    }else if (event.getEntityType() == EntityType.ELDER_GUARDIAN){
                String completed3 = plugin.getPlayersData().getString((new StringBuilder("Players.")).append(p.getName()).append(".missionsCompleted").append(".ElderGuardianDeath").toString());
               
                if(completed3.equalsIgnoreCase("false")){
                    plugin.getPlayersData().set((new StringBuilder("Players.")).append(p.getName()).append(".missionsCompleted").append(".ElderGuardianDeath").toString(), true);
                    plugin.savePlayersData();
                   
                    p.playSound(lctn, Sound.ENTITY_PLAYER_LEVELUP, 1, 10);
                    p.sendMessage(ChatColor.GOLD+"Felicidades, has conseguido el logro matar al Elder Guardian, toma aquí tu recompensa");
                    esm.addStoredEnchant(Enchantment.OXYGEN, 3, true);
                    book.setItemMeta(esm);
                    p.getInventory().addItem(book);
                    p.closeInventory();
                    p.updateInventory();
                }
    Thanks in advance.
     
  2. Online

    timtower Administrator Administrator Moderator

    @brunodm99 What is the version that you are developing for and what version are you testing on?
     
  3. @timtower I'm developing and testing on 1.10.2
     
  4. Offline

    mehboss

    @brunodm99
    Can I see the full error please?
    ~ post it in pastebin.
    try getEntity.getType() instead.. I have no clue what the difference is though
    no difference... show us the error.
     
    Last edited: Mar 25, 2017
  5. Tomorrow I send you de full error, I go to bed. Here's later.

    @mehboss
    Here's the log http://pastebin.com/i9nK4VXW.
    If I change the line
    "if (event.getEntityType() == EntityType.ELDER_GUARDIAN){" (the plugin doesn't work)
    by
    "if (event.getEntityType() == EntityType.CHICKEN){" (the plugin works)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Mar 26, 2017
  6. Offline

    mehboss

    There is another error at:
    Code:
    Caused by: java.lang.NullPointerException
        at com.bruno.pluginmc.PlayerListener.onBossDeath(PlayerListener.java:33) ~[?:?]
    &
    Code:
    Caused by: java.lang.NoSuchFieldError: ELDER_GUARDIAN
        at com.bruno.pluginmc.PlayerListener.onBossDeath(PlayerListener.java:66) ~[?:?]
     
  7. The first error is solved, but the suchFieldError no. If I use instanceof, eclipse give me a that "EntityType.ELDER_GUARDIAN cannot be resolved to a type".

    Enviado desde mi LG-K350 mediante Tapatalk
     
  8. Online

    timtower Administrator Administrator Moderator

    Locked
    Offline mode is not supported by Bukkit
     
    raunak114 and mehboss like this.
Thread Status:
Not open for further replies.

Share This Page