Get who have left the server in the PlayerQuitEvent, then check if player is in game (I don't know your system, do this yourself).
Sorry look this... PHP: public function onQuit(PlayerQuitEvent $event){ $player = $event->getPlayer(); $lvl = $playet->getLevel()->getName(); if($lvl === "test"){ unset($this->players[$player->getName()]); $event->setQuitMessage("§l§c§o[GAME] ".$player->getName()." quit game !"); if(count($this->players) <= 1){ if(count($this->players) === 1){ foreach($this->players as $p){ $p->sendMessage("§l§6won game !"); $this->getServer()->loadLevel("world"); $p->teleport($this->getServer()->getLevelByName("world")->getSafeSpawn()); $p->setNameTag($p->getName()); $p->getInventory()->clearAll(); $this->min = 20; } } }
Can you tell me what is not working? Errors? Also: Spoiler 1. Unless you are planning to use one game per plugin, I recommend having a similar structure like this: players: arenaname: - Someone - SomeoneElse arenaname2: - Toby - Jack 2. if(count($this->players) <= 1){ if(count($this->players) === 1){ Why double-check?
As I told you, the player count is on PlayerQuitEvent outdated, so when the count on quit is 2, then there is only 1 player in the world.