Player from PlayerPreLogin

Discussion in 'Plugin Development' started by iPhysX, Jan 5, 2012.

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

    iPhysX

    Is there any way to get the player from a PlayerPreLoginEvent, or at least check a permission against a player. :)
    I'm highly doubtful, but i thought i would ask.
     
  2. Offline

    knightidus

    have you tried

    event.getPlayer();

    ?
     
  3. Offline

    iPhysX

    It's a PlayerPreLoginEvent....
     
  4. Offline

    wwsean08

    You can't get the player object, but you can get the name, and in theory you can get an offline player object from the server for that name, and from there you use the Offline Players .getPlayer() method to get the player and then check the permission node, granted I've never tried this so don't know if it will work.
     
  5. Offline

    iPhysX

    Seems Legit :) I'll give it a go thanks!
     
  6. Offline

    wwsean08

    no problem, that's probably your best bet in my opinion
     
    iPhysX likes this.
  7. Offline

    knightidus

    ohhh... yeah... lol...
     
    iPhysX likes this.
  8. Offline

    wwsean08

    so just wondering, did it work?
     
  9. Offline

    iPhysX

    well, I was slightly unsure of certain things, i got this...
    Code:java
    1. public static boolean hasPermOff(OfflinePlayer player, String perm) {
    2. if (permission.has(player.getPlayer(), perm)) {
    3. return true;
    4. } else {
    5. return false;
    6. }
    7. }


    and

    Code:java
    1. OfflinePlayer op = Bukkit.getOfflinePlayer(event.getName());
    2. if (ExploitBegone.hasPermOff(op, "ebg.bypass.login")) {
    3.  
    4. } else {
    5. event.setResult(Result.KICK_OTHER);
    6. event.setKickMessage(ChatColor.RED + ExploitBegone.kickmessage);
    7. }


    I get a nullpointer somewhere down the line, probably because of permissions or i didn't do a null check on the player's existance.

    EDIT: event.getName(), what was I thinking? Ha.
     
  10. Offline

    wwsean08

    yah thats roughly what I was thinking
     
    iPhysX likes this.
Thread Status:
Not open for further replies.

Share This Page