You should not. The max-players value is a hard limit that should never be exceeded. You should set this limit to a larger number, and set a soft limit, and kick normal players if the server player count exceeded the soft limit. Also, you should not make the hard limit too large. In the future {{When?}}, PocketMine may preallocate memory to store that number of players. So we may be unhappy if the server always reserved memory for 9950 slots that are not going to be used {{Really that unhappy?}}.
For a server wich is now dead i coded a VIPjoin plugin. It did hack a bit, and you have to get the idea: Just construct this class with your main class of your plugin... PHP: /* __ _______ _____ _ _ \ \ / /_ _| __ (_) (_) \ \ / / | | | |__) | ___ _ _ __ \ \/ / | | | ___/ |/ _ \| | '_ \ \ / _| |_| | | | (_) | | | | | \/ |_____|_| | |\___/|_|_| |_| _/ | |__/ */class VIPjoin implements Listener{ public $VIPplayers = []; public $enabled = true; public function __construct($Main){ $this->main = $Main; $this->server = $Main->getServer(); $this->server->getPluginManager()->registerEvents($this, $this->main); $this->AnimatedMODTCfg = new Config($this->main->getDataFolder() . "JoinVIPconfig.yml", Config::YAML, array()); if($this->AnimatedMODTCfg->get("ConfigVersion") != 1){ $this->AnimatedMODTCfg->set('max-normal-players', 100); $this->AnimatedMODTCfg->set('FakeServerList', true); $this->AnimatedMODTCfg->set('disable', false); $this->AnimatedMODTCfg->set('debug', true); $this->AnimatedMODTCfg->set('ConfigVersion', 1); } $this->AnimatedMODTCfg->save(); if($this->AnimatedMODTCfg->get("disable")){ $this->enabled = false; } if($this->AnimatedMODTCfg->get("debug") && $this->enabled){ $this->debug = fopen($this->main->getDataFolder().time()."VIPjoinDebug.txt", "w"); if(!$this->debug){ $this->server->getLogger()->critical("ERROR: COULD NOT OPEN/CREATE FILE IN '".$this->main->getDataFolder()."'! Please ensure that the php process has write rights to that directory!"); $this->server->shutdown(); } fwrite($this->debug, "initial_info_m-n-p(".$this->AnimatedMODTCfg->get("max-normal-players").")__"); fwrite($this->debug, "initial_info_m_p(".$this->server->getMaxPlayers().")__"); fwrite($this->debug, "initial_info_fsl(".$this->AnimatedMODTCfg->get("FakeServerList").") \n"); } } public function __destruct(){ if($this->AnimatedMODTCfg->get("debug") && $this->enabled){ fclose($this->debug); } } private function isVIP($player){ $rawPlayerData = $this->server->getPluginManager()->getPlugin("PurePerms")->getUserDataMgr()->getData($player); return (in_array($player->getName(), $this->VIPplayers) || $rawPlayerData["group"] != "Player"); } public function onPreJoin(PlayerPreLoginEvent $event){ if($this->enabled){ $player = $event->getPlayer(); if(!$this->isVIP($player) && count($this->server->getOnlinePlayers()) >= $this->AnimatedMODTCfg->get("max-normal-players")){ $player->kick("The server is full!", false); $event->setCancelled(true); if($this->AnimatedMODTCfg->get("debug")){ fwrite($this->debug, "kick_player_".$player->getName()."_due(SERVER_FULL&&NOT_VIP) \n"); } }else{ if($this->AnimatedMODTCfg->get("debug")){ if(!$this->isVIP($player)){ fwrite($this->debug, "let_player_".$player->getName()."_in_due(SERVER:NOTFULL) \n"); }else{ fwrite($this->debug, "let_player_".$player->getName()."_in_due(SERVER:FULL&&VIP) \n"); } } } } } public function onQueryRegenerate(QueryRegenerateEvent $event){ if($this->enabled && $this->AnimatedMODTCfg->get("FakeServerList")){ $event->setMaxPlayerCount($this->AnimatedMODTCfg->get("max-normal-players")); if($this->AnimatedMODTCfg->get("debug")){ fwrite($this->debug, "regenerateQuery \n"); } } } public function onServerCmd(ServerCommandEvent $event){ $msg = strtolower($event->getCommand()); $sender = $event->getSender(); $doNotCancell = false; if($msg == "doRemPlayersOverMaxNormal"){ if($this->server->getOnlinePlayers() >= $this->AnimatedMODTCfg->get("max-normal-players")){ foreach($this->server->getOnlinePlayers() as $player){ if(count($this->server->getOnlinePlayers()) <= $this->AnimatedMODTCfg->get("max-normal-players")){ break; } if($this->isVIP($player->getName())){ $player->kick("You have been kicked!"); } } } }elseif($msg == "disableVIPjoin"){ $this->enabled = false; }elseif($msg == "enableVIPjoin"){ $this->enabled = true; }else{ $doNotCancell = true; } if(!$doNotCancell){ $event->setCancelled(true); } } public function addVIP($vipPlayerName){ $this->VIPplayers[] = $vipPlayerName; return true; }}
You might want to modify isVIP, it currently checks if you have added your VIP via addVIP(); or just if he is not in the pperm group Player please remember that i did this for a server and now just quickly made the cod usable for everyone... You just set your server-side player limit to, for example 120 and in the config the limit for 100. Now you have room for 100 normal players and 20 vip players. If fakeServerList is set to true it'll look like this: 102/100, with false it looks like this 102/120. I recommend setting it to true.
I want this code cause the hosters these days. puts a player limits for servers and I want to make it unlimited
Why won't you do a bit research? PHP: public function onPlayerKick(PlayerKickEvent $event) { var_dump($event->getReason());} Now try to join full server and you'll see what is the reason.
You're better off storing the data in a database, letting the player join then execute the check and then kick the player if the server is full and they're not a VIP.
Well, this is being stored in a database this is the low level class and the database classes of the server used to call addVIP() for their stuff
i got this Code: string(30) "disconnectionScreen.serverFull" so now i should but this right ? PHP: if($event->getReason() == ("disconnectionScreen.serverFull"){ $event->setCancelled();}
Using PlayerKickEvent basically means bypassing the hard limit. You should not. Read this post I posted 10 hours ago for why not and how otherwise.
Alright using PlayerKickEvent might work for now, but might not work in the future. I already explained why. I believe we all aren't here to help you cheat your hosting service.