OnPlayerJoin check permissions

Discussion in 'Plugin Development' started by THEK, Nov 25, 2012.

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



    I'm updating a plugin that I haven't touched for a while. I need to check the players permissions as they Join but it is always returning false.

    I have to use onPlayerJoin so the message "x has joined the game" doesn't come up, so instead of kicking the player I disallow the join event.

    Anyone know how I can get round this permissions issue? I've checked it with onPlayerLogin and it works fine, if I could get rid of the "x has joined the game" message that'd work fine.
  2. Offline


    Any code?
  3. Offline


    Works fine for me. heres a code snippet!

        public void onJoin(PlayerJoinEvent e){
                    plugin.log.info("player " +  e.getPlayer().getName() + " was disconnected due to lockdown.");
    note, this was for my plugin lockdown, so pardon the unnecessary code but checking player join permissions works fine.
  4. Offline


    Probably would help.

        public void onPlayerLogin(PlayerLoginEvent event) {
            Player p = event.getPlayer();
                if(!p.hasPermission("pp.immune")) {
                    event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You have been kicked");
                    msgHandler.sendInfo(null, p.getName() + " was kicked");
    The same code (within the method) but swap event.disallow for p.kickPlayer() works but it has already displayed "x has joined the game" by the time.

    Just tried yours, permissions work fine and the "x has joined game" isn't there. But now it says "x has left the game". Is there any way to remove that?

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


    PlayerJoinEvent and PlayerLoginEvent are 2 different things by the way. I think it is impossible to kick player in PlayerLoginEvent, setting result to kick should work though.

    Leaving message appears because onPlayerJoin, Player actually Joins the game and then aftrer the split second leaves it. However, using PlayerLoginEvent completely prevents player from joining, so no messages at all should be shown.

    Oh and permission checks don't wotk in PlayerLoginEvent because there is no player on the server yet, so it can't check his permissions. It can be solved by checking if he is OP, or having some list with players that are allowed to go in.
Thread Status:
Not open for further replies.

Share This Page