Solved "Object of class could not be converted to string"

Discussion in 'Development' started by minijaham, Jul 26, 2020.

  1. minijaham

    minijaham Witch

    Messages:
    63
    GitHub:
    minijaham
    Hey! I am getting this error, and this seems to be the error code. Could someone please help?
    Full error:
    Code:
    Server thread/CRITICAL ErrorException: "Object of class DaPigGuy\PiggyFactions\factions\Faction could not be converted to string" (EXCEPTION) in "plugins/Factions/src/DaPigGuy/PiggyFactions/commands/FactionCommand" at line 77
    26.07 04:20:13 [Server] Server thread/CRITICAL #0 plugins/Factions/src/DaPigGuy/PiggyFactions/commands/FactionCommand(77): pocketmine\utils\Utils::errorExceptionHandler(integer 4096, string[88] Object of class DaPigGuy\PiggyFactions\factions\Faction could not be converted t, string[118] /plugins/Factions/src/DaPigGuy/Pig, integer 77, array[7])
    26.07 04:20:13 [Server] Server thread/CRITICAL #1 plugins/Factions/src/DaPigGuy/PiggyFactions/libs/CortexPE/Commando/BaseCommand(132): DaPigGuy\PiggyFactions\commands\FactionCommand->onRun(object pocketmine\Player, string[1] f, array[0])
    26.07 04:20:13 [Server] Server thread/CRITICAL #2 src/pocketmine/command/SimpleCommandMap(248): DaPigGuy\PiggyFactions\libs\CortexPE\Commando\BaseCommand->execute(object pocketmine\Player, string[1] f, array[0])
    26.07 04:20:13 [Server] Server thread/CRITICAL #3 src/pocketmine/Server(1811): pocketmine\command\SimpleCommandMap->dispatch(object pocketmine\Player, string[1] f)
    26.07 04:20:13 [Server] Server thread/CRITICAL #4 src/pocketmine/Player(2310): pocketmine\Server->dispatchCommand(object pocketmine\Player, string[1] f)
    26.07 04:20:13 [Server] Server thread/CRITICAL #5 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(244): pocketmine\Player->chat(string[2] /f)
    26.07 04:20:13 [Server] Server thread/CRITICAL #6 src/pocketmine/network/mcpe/protocol/CommandRequestPacket(54): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleCommandRequest(object pocketmine\network\mcpe\protocol\CommandRequestPacket)
    26.07 04:20:13 [Server] Server thread/CRITICAL #7 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(110): pocketmine\network\mcpe\protocol\CommandRequestPacket->handle(object pocketmine\network\mcpe\PlayerNetworkSessionAdapter)
    26.07 04:20:13 [Server] Server thread/CRITICAL #8 src/pocketmine/network/mcpe/protocol/BatchPacket(127): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(object pocketmine\network\mcpe\protocol\CommandRequestPacket)
    26.07 04:20:13 [Server] Server thread/CRITICAL #9 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(110): pocketmine\network\mcpe\protocol\BatchPacket->handle(object pocketmine\network\mcpe\PlayerNetworkSessionAdapter)
    26.07 04:20:13 [Server] Server thread/CRITICAL #10 src/pocketmine/Player(3247): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(object pocketmine\network\mcpe\protocol\BatchPacket)
    26.07 04:20:13 [Server] Server thread/CRITICAL #11 src/pocketmine/network/mcpe/RakLibInterface(169): pocketmine\Player->handleDataPacket(object pocketmine\network\mcpe\protocol\BatchPacket)
    26.07 04:20:13 [Server] Server thread/CRITICAL #12 vendor/pocketmine/raklib/src/server/ServerHandler(99): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string[18] 68.7.150.203 54466, object raklib\protocol\EncapsulatedPacket, integer 0)
    26.07 04:20:13 [Server] Server thread/CRITICAL #13 src/pocketmine/network/mcpe/RakLibInterface(109): raklib\server\ServerHandler->handlePacket()
    26.07 04:20:13 [Server] Server thread/CRITICAL #14 src/pocketmine/network/mcpe/RakLibInterface(99): pocketmine\network\mcpe\RakLibInterface->process()
    26.07 04:20:13 [Server] Server thread/CRITICAL #15 vendor/pocketmine/snooze/src/SleeperHandler(123): pocketmine\network\mcpe\RakLibInterface->pocketmine\network\mcpe\{closure}()
    26.07 04:20:13 [Server] Server thread/CRITICAL #16 vendor/pocketmine/snooze/src/SleeperHandler(85): pocketmine\snooze\SleeperHandler->processNotifications()
    26.07 04:20:13 [Server] Server thread/CRITICAL #17 src/pocketmine/Server(2157): pocketmine\snooze\SleeperHandler->sleepUntil(double 1595737213.2062)
    26.07 04:20:13 [Server] Server thread/CRITICAL #18 src/pocketmine/Server(1994): pocketmine\Server->tickProcessor()
    26.07 04:20:13 [Server] Server thread/CRITICAL #19 src/pocketmine/Server(1588): pocketmine\Server->start()
    26.07 04:20:13 [Server] Server thread/CRITICAL #20 src/pocketmine/PocketMine(273): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[47] /, string[55] /plugins/)
    26.07 04:20:13 [Server] Server thread/CRITICAL #21 src/pocketmine/PocketMine(304): pocketmine\server()
    26.07 04:20:13 [Server] Server thread/CRITICAL #22 (11): require(string[107] phar:///PMMP-Latest-Stable.phar/sr)
    Code:
    PHP:
    public function onRun(CommandSender $senderstring $aliasUsed, array $args): void
        
    {
            
    $member PlayerManager::getInstance()->getPlayer($sender->getUniqueId());
                
    $faction $member === null null $member->getFaction();
            if (
    $this->plugin->areFormsEnabled() && $sender instanceof Player) {
                
    $subcommands array_filter($this->getSubCommands(), function (BaseSubCommand $subCommandstring $alias) use ($sender): bool {
                    return 
    $subCommand->getName() === $alias && $sender->hasPermission($subCommand->getPermission());
                }, 
    ARRAY_FILTER_USE_BOTH);
                
    $form = new SimpleForm(function (Player $player, ?int $data) use ($subcommands): void {
                    if (
    $data !== null) {
                        
    $subcommand $subcommands[array_keys($subcommands)[$data]];
                        
    $subcommand->onRun($player$subcommand->getName(), []);
                    }
                });
                
    $form->setTitle(LanguageManager::getInstance()->getMessage(LanguageManager::getInstance()->getPlayerLanguage($sender), "forms.title"));
                
    $form->setContent(C::AQUA."Faction: ".C::BLUE.$faction === null "NONE" $faction->getName());
                foreach (
    $subcommands as $key => $subcommand) {
                    
    $form->addButton(C::GREEN ucfirst($subcommand->getName()) . C::EOL "§7Click to see more...");
                }
                
    $sender->sendForm($form);
                return;
            }
            
    $this->sendUsage();
        }
     
  2. GodWeedZao

    GodWeedZao Zombie

    Messages:
    205
    GitHub:
    godweedzao
    can you give me Line 77 code?
     
  3. minijaham

    minijaham Witch

    Messages:
    63
    GitHub:
    minijaham
    xD I forgot about that lol
    The "$form->setContent()" part is the 77th line in the original code
     
  4. Seeker

    Seeker Witch

    Messages:
    65
    GitHub:
    seeker-devs
    What were the function params in setContent()
     
  5. minijaham

    minijaham Witch

    Messages:
    63
    GitHub:
    minijaham
    I'm using FormAPI lib
     
  6. Seeker

    Seeker Witch

    Messages:
    65
    GitHub:
    seeker-devs
    Read the error? An object cannot be converted to a string.
     
    GodWeedZao likes this.
  7. minijaham

    minijaham Witch

    Messages:
    63
    GitHub:
    minijaham
    I already fixed the issue xD
    Thank you for trying to help
     
  8. Seeker

    Seeker Witch

    Messages:
    65
    GitHub:
    seeker-devs
    mark this as solved
     
  9. Emirhan Akpınar

    Emirhan Akpınar Slime

    Messages:
    88
    GitHub:
    EmirhanWSD
    Write your shorthand if/else inside on ( )
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.