onPlayerLogin Permissions?

Discussion in 'Plugin Development' started by THEK, Mar 10, 2012.

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

    THEK

    Hi,

    I'm trying to check if a player has a permission, if not they get kicked. However, it is always returning false when I use player.hasPermission();

    Should I be using this in the onPlayerLogin event?
     
  2. Offline

    zachoooo

    Are you adding a node? Like player.hasPermission("Permission.node");?
     
  3. Offline

    THEK

    Yes, player.hasPermission("plugin.allow");
     
  4. Offline

    Njol

    Do you have a superperms compatible permissions plugin installed and added the permission correctly?
     
  5. Offline

    zachoooo

    Are you using a good permissions manager? Because using player.hasPermission() on player join should work perfectly fine.
     
  6. Offline

    Soxra

    Do you have something like this?
    Code:
    public void onPlayerJoin(PlayerJoinEvent event){
    Player player = event.getPlayer();
    }
    
     
  7. Offline

    zachoooo

    If he didnt his IDE would give him errors
     
  8. Offline

    THEK

    I'm using permissionsBukkit. Here's my code:

    Code:
    @EventHandler
        public void onPlayerLogin(PlayerLoginEvent event) {
            Player p = event.getPlayer();
     
            System.out.println(p.hasPermission("autokick.nokick"));
            if(AutoKickConfig.akEnabled) {
                if(p.hasPermission("autokick.nokick") || p.isOp())
                    plugin.msghandler.sendInfo(p,"is still enabled");
                else
                    event.disallow(PlayerLoginEvent.Result.KICK_OTHER, AutoKickConfig.akList.get(AutoKickConfig.akMessage));
            } else if(AutoKickConfig.akPending) {
                if(p.hasPermission("autokick.nokick") || p.isOp()) {
                    plugin.msghandler.sendInfo(p, "You're immnune from AutoKick");
                } else {
                    plugin.msghandler.sendInfo(p, "You will be kicked in <"+AutoKickConfig.akTime+"s");
                }
            }
        }
    It is always kicking the player when akEnabled is true no matter what permission they have.
     
  9. Offline

    Soxra

    Oh yes right also player.hasPermission wouldnt work.
     
  10. Offline

    zachoooo

    Code:
    if(p.hasPermission("autokick.nokick") || p.isOp())
                    plugin.msghandler.sendInfo(p,"is still enabled");
                else
    Your IDE isnt giving you a warning about that ^? Where are you curly braces?
     
  11. Offline

    THEK

    That is a quicker way for if statements. If you leave out the curly braces it only executes 1 line after the if statement.

    It's a perfectly legal java statement.
     
  12. Offline

    zachoooo

    But what about the else? I was unaware that elses could be used without them.
     
  13. the else is correct there as well. the else need to be right after that statement.

    you can even do
    Code:
    if(p.hasPermission("autokick.nokick") || p.isOp()) plugin.msghandler.sendInfo(p,"is still enabled");
    else (PlayerLoginEvent.Result.KICK_OTHER, AutoKickConfig.akList.get(AutoKickConfig.akMessage));
    without getting an error.
     
  14. Offline

    THEK

    So does anyone have any ideas as to why this isn't working?
     
Thread Status:
Not open for further replies.

Share This Page