I get this error at interacrt

Discussion in 'Plugin Development' started by letsgo00, Mar 16, 2016.

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

    letsgo00

    I'm making a plugin for a minigame, and when I start the server and click on the join sign I get this error
    But after a reload it works fine so i dont get it

    And the line at Game.java:137:
    Code:
    p.teleport(arena.team1Spawn);
    Where I have null checks for the location and the player
     
  2. Offline

    I Al Istannen

    @letsgo00
    Judging from the error, the checks weren't enough. The player "p" could be null, the "arena" and "arena.team1Spawn". You surely haven't checked for all, or your check is flawed. You could add some debug messages right above, printing out "p == null", "arena == null" and "arena.team1Spawn == null", ideally everyone on it's own line. It's hard to help though, as you haven't posted your code.

    Apart from that, I would suggest using getters and setters, instead of directly referring to a variable of another class.
     
  3. Offline

    MajorSkillage

    The player value could have been defined but when it was referenced the player could have left making it undefined.
     
  4. Offline

    letsgo00

    @I Al Istannen Here is the code, the console shows that none of the variables are null.
    Code:
    public void addPlayer(Player p, Team team){
            if(arena == null || arena.team1Spawn == null || arena.team2Spawn == null) return;
            System.out.println(arena + "" + arena.team1Spawn + arena.team2Spawn + p);
            players.put(p, team);
            if(team instanceof TeamRed){
                Scoreboardmanager.getScoreboardManager().addPlayerToRed(p);
                if(isRunning){
                    p.teleport(arena.team2Spawn);
                }
            }
            else{
                Scoreboardmanager.getScoreboardManager().addPlayerToGreen(p);
                if(isRunning){
                    p.teleport(arena.team1Spawn);
                }
            }
        }
    I don't know if it matters but I have a multiverse core crash too which is about player teleport event

    @I Al Istannen @MajorSkillage Multicerse core was crashing my plugin, removed it works fine exept now I cannot use multiple worlds

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Mar 17, 2016
  5. Offline

    mcdorli

    If you want to use multiple worlds, and multiverse core, then use it's API, it definitely has one
     
  6. Offline

    letsgo00

    @mcdorli Multiverse core crashes my plugin at a teleport event. But I might not have the latest version
     
  7. Offline

    Rexcantor64

    I also have multiverse core on my minigames server and it works fine! I'm using version 2.5-b678 for minecraft 1.8. I hope it help, and try to update it. If you are using minecraft 1.9, I can't do anything, because I don't like it and I didn't update my server.
     
  8. Offline

    MajorSkillage

    In addPlayer method you're not checking if Player instance is null.
     
Thread Status:
Not open for further replies.

Share This Page