Solved another Caused by: java.lang.NullPointerException...

Discussion in 'Plugin Development' started by @Kas, Mar 14, 2016.

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

    @Kas

    Hello everybody,
    I've been making a tpa plugin because I thought why not! well that was 2 days ago and I still can't figure out his error... hope someone can help me here:
    console error: http://pastebin.com/auHHVAMx
    tpatest class: http://pastebin.com/63g2Tph5
    main class: http://pastebin.com/NskrLfTc

    hope someone can help me :)

    (don't say essentials has a tpa command etc. I know that I just wanted to make for myself)
    (just saw I put this on the wrong place... placed here now...)
     
  2. Offline

    Desle

    The error is pointing to line 43 of your tpatest class

    Code:
    Location location = target.getLocation(loctemp.get(1));
    guessing that loctemp.get(1) returns null
     
  3. Offline

    Swakiny

    Check if your hashmap is empty
     
  4. Offline

    @Kas

    @Desle I saw there was something at line 43 but what is the problem? I do not see what's the problem?

    @Swakiny just:
    if(playertemp contain.(1, Player){

    }
    ?

    thx for replying anyway

    @Swakiny would this work then:
    http://pastebin.com/nPLADy7b ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Mar 14, 2016
  5. @@Kas
    Your class name should be capitalized.
    You probably should take a look at java coding conventions.
    Edit: This has nothing to do with your error btw.
     
  6. Offline

    Swakiny


    Something in your code doesn't look right. If someone type /tpaccept you will get error because there's nothing in the hashmap yet.

    And I think this part isn't being read for some reason if you are getting nullpointexception typing in correct order(/tprequest then /tpaccept):


    1. if(target != null){
    2. player.sendMessage("tou tried to tp");
    3. target.sendMessage("someone tried to tp to you");
    4. playertemp.put(1, player);
    5. playertemp.put(2, target);
    6. loctemp.put(1, target.getLocation());
    7. return true;
    8. }
     
    Last edited: Mar 14, 2016
  7. Offline

    @Kas

    @Swakiny of cource I tried in the correct order lel :) but what I got now when I type in /tpaccept I do not get any errors but I do not tp as well any idea? (not get any message that I got tped)
    thx anyway :)
    http://pastebin.com/FbqfUc9g

    I gave it up I'll mark it as done just going to look over java programming once again.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Mar 15, 2016
Thread Status:
Not open for further replies.

Share This Page