Hello, I have this code: PHP: public function onCommand(CommandSender $sender, Command $command, $label, array $args) : bool{ switch($command->getName()){ case "friend": if ($sender instanceof Player){ if (isset($args[0])){ switch ($args[0]){ case "add": if (isset($args[1])){ $player = $this->getServer()->getPlayer($args[1]); if($args[1] = $sender); $sender->sendMessage("§cYou can't become friends with yourself."); }else{ if(!$player == null){ $this->addRequest($player, $sender); } } }else{ $sender->sendMessage("§c" . $args[1] . " §cis not online"); } }else{ $sender->sendMessage("§eUsage: /friend add <name>"); } break; case "remove": if (isset($args[1])){ if ($this->removeFriend($sender, $args[1])){ $sender->sendMessage("§c" . $args[1] . " §cremoved as your friend"); }else{ $sender->sendMessage("§cFriend not found do /friend list to list your friends"); } }else{ $sender->sendMessage("§eUsage: /friend remove <name>"); } break; case "list": $config = new Config($this->getDataFolder()."players/". strtolower($sender->getName()).".yml", Config::YAML); $array = $config->get("friends", []); $sender->sendMessage(TextFormat::GOLD.TextFormat::BOLD."Friends:"); foreach ($array as $friendname){ $sender->sendMessage(TextFormat::GREEN."* ".$friendname); } } }else{ $sender->sendMessage("§e/friend add <name> §7become friends with a player"); $sender->sendMessage("§e/friend remove <name> §7remove a player as your friend"); $sender->sendMessage("§e/friend remove <name> §7remove a player as your friend"); $sender->sendMessage("§e/accept §7accept a friend request"); } }else{ $sender->sendMessage("Must use command in-game"); } break; case "accept": //echo var_dump($this->request); if (in_array($sender->getName(), $this->request)){ //echo "added"; foreach ($this->request as $target => $requestp){ $target = $this->getServer()->getPlayer($target); $requestp = $this->getServer()->getPlayer($requestp); echo $target->getName().$requestp->getName(); if ($requestp->getName() === $sender->getName()){ //echo "yes"; $this->addFriend($target, $requestp); $this->addFriend($requestp, $target); }else{ $sender->sendMessage("§cNo pending friend requests"); } } }else{ $sender->sendMessage(TextFormat::RED."§cNo pending friend requests"); } } return true; I keep getting this error in the console when the plugin starts: Code: [23:08:51] [Server thread/INFO]: Loading source plugin Friends v0.3 [23:08:51] [Server thread/CRITICAL]: ParseError: "syntax error, unexpected 'else' (T_ELSE)" (EXCEPTION) in "Friends-master/src/friends/main" at line 49 [23:08:51] [Server thread/DEBUG]: #0 (): BaseClassLoader->loadClass(string friends\main) [23:08:51] [Server thread/DEBUG]: #1 (): spl_autoload_call(string friends\main) [23:08:51] [Server thread/DEBUG]: #2 DevTools (1).phar/src/FolderPluginLoader/FolderPluginLoader(66): class_exists(string friends\main, boolean 1) [23:08:51] [Server thread/DEBUG]: #3 src/pocketmine/plugin/PluginManager(161): FolderPluginLoader\FolderPluginLoader->loadPlugin(string C:\Users\Admin\Creative Cloud Files\Desktop\Lobby - DEV\plugins\Friends-master) [23:08:51] [Server thread/DEBUG]: #4 src/pocketmine/plugin/PluginManager(305): pocketmine\plugin\PluginManager->loadPlugin(string C:\Users\Admin\Creative Cloud Files\Desktop\Lobby - DEV\plugins\Friends-master, array Array()) [23:08:51] [Server thread/DEBUG]: #5 DevTools (1).phar/src/DevTools/DevTools(47): pocketmine\plugin\PluginManager->loadPlugins(string C:\Users\Admin\Creative Cloud Files\Desktop\Lobby - DEV\plugins\, array Array()) [23:08:51] [Server thread/DEBUG]: #6 src/pocketmine/plugin/PluginBase(90): DevTools\DevTools->onEnable() [23:08:51] [Server thread/DEBUG]: #7 src/pocketmine/plugin/PharPluginLoader(122): pocketmine\plugin\PluginBase->setEnabled(boolean 1) [23:08:51] [Server thread/DEBUG]: #8 src/pocketmine/plugin/PluginManager(610): pocketmine\plugin\PharPluginLoader->enablePlugin(DevTools\DevTools object) [23:08:51] [Server thread/DEBUG]: #9 src/pocketmine/Server(1955): pocketmine\plugin\PluginManager->enablePlugin(DevTools\DevTools object) [23:08:51] [Server thread/DEBUG]: #10 src/pocketmine/Server(1941): pocketmine\Server->enablePlugin(DevTools\DevTools object) [23:08:51] [Server thread/DEBUG]: #11 src/pocketmine/Server(1655): pocketmine\Server->enablePlugins(integer 0) [23:08:51] [Server thread/DEBUG]: #12 src/pocketmine/PocketMine(554): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string C:\Users\Admin\Creative Cloud Files\Desktop\Lobby - DEV\, string C:\Users\Admin\Creative Cloud Files\Desktop\Lobby - DEV\plugins\) [23:08:51] [Server thread/DEBUG]: #13 C:/Users/Admin/Creative Cloud Files/Desktop/Lobby - DEV/PocketMine-MP.phar(1): require(string phar://C:/Users/Admin/Creative Cloud Files/Desktop/Lobby - DEV/PocketMine-MP.phar/src/pocketmine/PocketMine.php) [23:08:51] [Server thread/CRITICAL]: Could not load plugin 'Friends' this is line 47 - 50: PHP: } } }else{ $sender->sendMessage("§c" . $args[1] . " §cis not online"); I don't understand whats wrong with '}else{' here. could someone pls help me with the formatting of this :/
There's an else right after an else which doesn't make a lot of sense.. maybe try removing the } right before the else
You put a wrong semicolon on the if block on line 10 You wrote PHP: if($args[1] = $sender); instead of PHP: if($args[1] = $sender){ (you should also replace = with ==)
Yes, I didn't notice it. This should be the correct code: PHP: if($args[1] == $sender->getName()){ Or better: PHP: if(strcasecmp($args[1], $sender->getName()) == 0){ (^ You will do the case-insensitive string comparison by using strcasecmp function)