Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bypass pre-set slots, some shared host's do this so here is a simple bypass.
package com.colt.SlotsBypass;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class SlotsBypass extends JavaPlugin implements Listener{
String permission = getConfig().getString("permission");
int maxplayers = getConfig().getInt("max-players");
@Override
public void onEnable() {
Bukkit.getServer().getPluginManager().registerEvents(this, this);
saveDefaultConfig();
}
@EventHandler(priority = EventPriority.NORMAL)
public void playerLogin(PlayerLoginEvent e) {
Player p = e.getPlayer();
if(e.getResult() == PlayerLoginEvent.Result.KICK_FULL && !(Bukkit.getOnlinePlayers().size() > maxplayers &&
p.hasPermission(permission))) {
e.setResult(PlayerLoginEvent.Result.ALLOWED);
}
}
@EventHandler
public void ping(ServerListPingEvent e){
e.setMaxPlayers(maxplayers);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment