Hello I have this plugin but it's got an error. here is the error: Unhandled exception executing command 'pwb MBLobby ke' in pwb: Call to a member function [PocketMine] [21:16:01] > Unhandled exception executing command 'pwb MBLobby ke' in pwb: Call to a member function getOnlinePlayers() on null [PocketMine] [21:16:01] > Error: "Call to a member function getOnlinePlayers() on null" (EXCEPTION) in "/phar_PerWorldBroadcast-master_WOZU_qlz9U8gXBR.phar/src/pwb/main" at line 18 Here is the code: PHP: <?phpnamespace pwb;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\Player;class main extends PluginBase { public function onEnable(){ $this->getLogger()->info("loaded!"); } public function onCommand(CommandSender $sender,Command $command, $label,array $args){ switch ($command->getName()){ case "pwb": if ($sender->hasPermission("pwb.use")){ if (isset($args[0]) and isset($args[1])){ $players = $this->getServer()->getLevelByName($args[0])->getPlayers(); unset($args[0]); $message = implode(" ", $args); if (!$players == null){ foreach ($players as $player){ $player->sendMessage($message); } }else{ $sender->sendMessage("no such world"); } }else{ $sender->sendMessage("Usage: /pwb [world] [message]"); }}else{ $sender->sendMessage("No permission to use this command!"); } break; } } } The line " $players = $this->getServer()->getLevelByName($args[0])->getPlayers(); " is line 18 btw that's where the error is :/ Could someone help?! I have also attached the zip file Just something completely different I wanna add, wtf happened to the forums? It's a bit messed up in my opinion.
There is no -BUTTONS YOU ARE HURTING MY EYES!- getPlayers function in Level. You might want to write your own PHP: /* $this must have a getServer function which returns \pocketmine\Server (classes extending pluginBase do */function aprilFoolsSuck(\fools\pocketmine\level\Level $level): array{$players = [];foreach($this->getServer()->getPlayers() as $player){if($player->getLevel() == $level){$players[] = $player;}return $players;}} Sorry for no formatting and no phpdoc. April fools btw.