Essentials repair

Discussion in 'Plugin Development' started by andrew4543, Jul 20, 2016.

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

    andrew4543

    So I am trying to enact essentials repair methods, but its sending a random error that does not even make sense.

    Code
    Code:
    Essentials ess = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
    User iuser = ess.getUser(player);
    Commandrepair cr = new Commandrepair();
    cr.repairAll(iuser);


    this is the error
    Code:
    Caused by: java.lang.NullPointerException
        at com.earth2me.essentials.Trade.isAffordableFor(Trade.java:94) ~[?:?]
        at com.earth2me.essentials.commands.Commandrepair.repairHand(Commandrepair.java:60) ~[?:?]
    

    the reason its so weird is that it the code for Trade line 94 is
    Code:
    if (ess.getSettings().isDebug())

    Links to essentials github
    Trade
    Commandrepair
     
  2. Offline

    Zombie_Striker

    @andrew4543
    Are you sure ess is not null? Are you sure the settings are not null?
     
  3. Offline

    MCMastery

    well ess is not null. ess.getUser() would trigger an NPE
     
  4. Offline

    andrew4543

    I have tried doing ess.getSettings().isDebug() in my code and it worked fine, that's what does not make any sense
     
    Last edited: Jul 21, 2016
  5. @andrew4543
    My bet is that your "iuser" variable is null.
     
  6. Offline

    andrew4543

    Just checked, it isnt
     
  7. Offline

    andrew4543

    I just wanted to know if u guys knew what was wrong with this code here. I already checked in a separate plugin to do the same with the same error. If the community does not know the error its ok.
     
  8. Offline

    Zombie_Striker

    @andrew4543
    The issue is that something is null at line 94 of the Trade class/line 60 of Commandrepair. We need the full class in order to understand why there is a variable that is null.
     
  9. @Zombie_Striker
    Those are essentials classes, he even linked to their github.


    @andrew4543
    I had a look through the essentials classes, and they are not the same version as you are using. But I followed the code anyway and came to the conclusion that the only thing that could be null is the "iuser" variable. Can you please show us your entire class?
     
  10. Offline

    andrew4543

    @AlvinB
    Thats what makes so sense! I have checked and double checked to see if its null or not, i have put in
    Code:
    if(iuser == null)
          return;
    and I even used iuser, and iuser works just fine
     
  11. @andrew4543
    Interesting.. Can you post your entire class?
     
Thread Status:
Not open for further replies.

Share This Page