Only Join Server If Permission Is Held By Player

Discussion in 'Plugin Development' started by eleectricman226, Jul 1, 2014.

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


    So, coding my 'Hub' plugin, I ran across wanting to make a 'maintenance mode' kind of thing, where only people can join if they have the perm 'server.join.maintenance'. Now, when it is activated (not via command, but via GUI) it will first check all the players online to see if they have it, than all other players that attempt to log in. But, when they attempt to log in, have the perm on not, they are disallowed, and i'm not sure why. No stack traces either.

    PlayerLoginEvent code:

    1. @EventHandler
    2. public void playerLogin(PlayerLoginEvent e){
    3. try {
    4. if(!e.getPlayer().hasPermission("server.join.maintenance") && LanguageFileSystem.getStringFromFile(new File("plugins/Hub/config.cfg"), "maintenanceMode").equalsIgnoreCase("true")) {
    5. e.disallow(Result.KICK_OTHER, ChatColor.RED + "Server Is In Maintenance Mode.\n" + ChatColor.YELLOW + "Check Back Soon!");
    6. }else{
    7. e.allow();
    8. }
    9. } catch (FileNotFoundException e1) {
    10. // TODO Auto-generated catch block
    11. e1.printStackTrace();
    12. }
    13. }

    The 'LanguageFileSystem' was so my server could support multi language, but so far it is doing more than just that. It is just a basic file reading system.(Made by: eleectricman226)
  2. Offline


  3. Offline


    NoLiver92 Hmm... You might be right, they would already be logging into the server and such, so maybe it is.
  4. Offline


    When a player is logging into the game, it wont have its proper permissions attached, its the job of permission plugin to do this inside the playerjoinevent, this event is later called than the login events
Thread Status:
Not open for further replies.

Share This Page