Hi, I'm trying to optimize as well my plugin. PHP: public function OnMove(PlayerMoveEvent $event) { $player = $event->getPlayer(); $games = ["PvP-1","PvP-2","PvP-3","PvP-4","PvP-5","PvP-6","PvP-7","PvP-8","PvP-9","PvP-10"]; foreach($games as $game){ if($player->getLevel()->getName() == $game and $this->getGameValue($game) == false){ $event->setCancelled(true); } } } Here is a thing that I'm not pretty sure if it's good at all... I was thinking that is maybe faster use this: PHP: public function OnMove(PlayerMoveEvent $event) { /*$player = $event->getPlayer(); $games = ["PvP-1","PvP-2","PvP-3","PvP-4","PvP-5","PvP-6","PvP-7","PvP-8","PvP-9","PvP-10"]; foreach($games as $game){ if($player->getLevel()->getName() == $game and $this->getGameValue($game) == false){ $event->setCancelled(true); } }*/ $level = $event->getPlayer()->getLevel(); if($level != $this->getServer()->getDefaultLevel() and $this->getGameValue($level->getName()) == false){ $event->setCancelled(); } } What do you all think? It's the best way?
If you want to check that the player is not in a specific world,use @luca28pet 's method, if you want to check if the player is in any of the specified worlds,use @PEMapModder 's method