PlayerPreLoginEvent issues.

Discussion in 'Plugin Development' started by Razorcane, Dec 7, 2011.

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

    Razorcane

    Either my event is just not running, or I'm doing something wrong. I have a login priority system for members and up, and I check in the pre-login event if a player is an admin or not. The only problem is, when I have the limit set to 0, so that only admins can log in, anyone else can still log in regardless of me setting the limit or not. I am led to believe that my pre-login event doesn't even initialize. Here is the code if it helps:

    Code:
        @Override
        public void onPlayerPreLogin(PlayerPreLoginEvent event){
            try {
                if(!plugin.members.contains(event.getName())){
                    if(Origins.guestLimit == 0){
                        event.setResult(PlayerPreLoginEvent.Result.KICK_FULL);
                        event.disallow(PlayerPreLoginEvent.Result.KICK_FULL, "The server is in members-only mode. Please try again later.");
                    }
                    else if(Origins.guestCount == Origins.guestLimit) {
                        event.setResult(PlayerPreLoginEvent.Result.KICK_FULL);
                        event.disallow(PlayerPreLoginEvent.Result.KICK_FULL, "All guest slots are full.  Please try again later.");
                    }
                    else {
                        event.allow();
                        event.setResult(PlayerPreLoginEvent.Result.ALLOWED);
                    }
                } else {
                    event.allow();
                    event.setResult(PlayerPreLoginEvent.Result.ALLOWED);
                }
            }
            catch(Exception e){
                Origins.log.info(plugin.name + "Some weird shit happened.");
            }
        }
    I also have it initialized in my onEnable, with the rest of my listener events, but this is the only one that doesn't seem to work. Any help would be appreciated.

    Here is the code in onEnable() in case it helps:
    Code:
    pm.registerEvent(Event.Type.PLAYER_PRELOGIN, playerListener, Event.Priority.Normal, this);
    Nevermind, I was using the wrong event! Herp derp!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  2. Offline

    ArcheCane

    Yes. Herp derp to you!
     
Thread Status:
Not open for further replies.

Share This Page