Hi, I want to ask if it is possible to set the max players inside a plugin. Because I tried with setConfigInt and getConfigInt but it can only get the max players and can't set it. Please help. PHP: $cmd = preg_replace("/[^a-z]+/", "", strtolower($cmd->getName())); if ($cmd === "setmaxplayers" || $cmd === "maxjoin") { if (!isset($args[0])) { $this->getLogger()->notice("Debug: Original max players: " . $this->getServer()->getConfigInt("max-players")); return true; } $args[0] = intval($args[0]); if (!is_integer($args[0])) { return false; } $this->getServer()->setConfigInt("max-players", $args[0]); $this->getLogger()->notice("Debug: Max players have been set to: " . $args[0]); $sender->sendMessage(TF::GREEN . "Max players have been set to: " . $args[0]); $this->getServer()->doAutoSave(); return true; }
PHP: public $playerCount = 20;public function onQuery(QueryRegenerateEvent $event) { $event->setMaxPlayerCount($this->playerCount);}
Nope. That just replaces displayed count. Server will still kick players if there were more than max player count specified in server.properties.
I wrote plugin for that 2 years ago. I'm not sure it still works, if it's even worked... But this function which cancells kicking player seems right.