Solved Bukkit.getPlayer() returning null

Discussion in 'Plugin Development' started by holysteward, Oct 15, 2013.

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

    holysteward

    So in my plugin I have a line of code...
    Code:java
    1. Bukkit.getPlayer(r.getName()).hasPermission("reviewplugin.vipplus")
    and this is reading in saying that the player associated with r.getName() is a null player object. I get the r.getName from the construction of my object, activated via command with
    Code:java
    1. new Review(player.getName(), Bukkit.getPlayer(player.getName()).getLocation())
    so the name should be valid. I don't know how it could possibly go wrong. I have been trying to resolve this issue for weeks now and I am pulling out my hair trying to come up with a solution.
     
  2. Offline

    Zarkopafilis

    Code:java
    1. Bukkit.getPlayer(name).hasPermission(x)//or any other thing you want;
    2.  
     
  3. Offline

    bobbob1870

    If in the constructor r is player.getName() then r would already be a string of the player name. Try:
    Code:java
    1. Bukkit.getPlayer(r).hasPermission("reviewplugin.vipplus");
     
  4. Offline

    holysteward

    r is a review object with the method to get the name of the player.

    thats what I did with the getname() method of the review object r

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

    Zarkopafilis

    try getPlayerExact() and the try to store the player and then check stuff.
     
  6. Offline

    holysteward

    I realize now it may be that the player isn't online... I am going to add an int in my object's constructor though to have the object track this.
     
Thread Status:
Not open for further replies.

Share This Page