Bypassing Player Slot Limits

Jul 21, 2015
Bypassing Player Slot Limits
  • Bypassing Player Slot Limits



    Most small server nowadays are limited with the server's player slot limit.
    The following example will show one of many concepts of bypassing the servers player slot limit.

    First, let us create our main and only class for this example:
    Code (Java):
    package me.web.playerlimitbypass;

    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;

    public class PlayerBypass extends JavaPlugin implements Listener {

        @Override
        public void onEnable() {

        }
    }

    Pretty simple.
    Next, we will create our Event Handler and register the event:

    Code (Java):
        @EventHandler
        public void onPlayerLoginEvent(PlayerLoginEvent event){

        }
    Code (Java):
        @Override
        public void onEnable() {
            // Registering the events
            getServer().getPluginManager().registerEvents(this, this);
        }

    The following code is the very base of this concept:
    Code (Java):
        @EventHandler
        public void onPlayerLoginEvent(PlayerLoginEvent event){
            // Checking if the reason we are being kicked is a full server
            if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL) {
                // If the condition above is true, we execute the following code, that is allow the player on the server
                event.allow();
            }
        }

    You can tweak the base any way you want. For instance, check if the player has permissions to bypass the player limit:
    Code (Java):
        @EventHandler
        public void onPlayerLoginEvent(PlayerLoginEvent event) {
            // Checking if the reason we are being kicked is a full server
            if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL) {
                // Checking if the player has the specified permission node
                if (event.getPlayer().hasPermission("playerlimit.bypass"))
                    // If the condition above is true, we execute the following code, that is allow the player on the server
                    event.allow();
            }

        }
  • Loading...
  • Loading...