1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Crash while sending a message to console as a log

Discussion in 'Plugin Help' started by linuxthefish, May 29, 2020.

  1. linuxthefish

    linuxthefish Creeper

    Messages:
    1
    GitHub:
    syzolin
    Here is the error:
    Fatal error: Method pocketmine\Player::__toString() must not throw an exception, caught TypeError: Return value of pocketmine\entity\Entity::getId() must be of the type int, null returned in phar:///home/linux/pmmp/plugins/cucumber.phar/src/adeynes/cucumber/CucumberListener.php on line 0

    Here is some relevant information I find near line 0:
    <?php
    declare(strict_types=1);

    namespace adeynes\cucumber;

    use adeynes\cucumber\command\VanishCommand;
    use adeynes\cucumber\event\CucumberEvent;
    use adeynes\cucumber\event\ChatAttemptEvent;
    use adeynes\cucumber\event\ChatEvent;
    use adeynes\cucumber\event\CommandEvent;
    use adeynes\cucumber\event\JoinAttemptEvent;
    use adeynes\cucumber\event\JoinEvent;
    use adeynes\cucumber\event\QuitEvent;
    use adeynes\cucumber\utils\MessageFactory;
    use adeynes\cucumber\utils\Queries;
    use pocketmine\event\Event;
    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerChatEvent;
    use pocketmine\event\player\PlayerCommandPreprocessEvent;
    use pocketmine\event\player\PlayerJoinEvent;
    use pocketmine\event\player\PlayerPreLoginEvent;
    use pocketmine\event\player\PlayerQuitEvent;
    use pocketmine\Server;
    use pocketmine\utils\TextFormat;
    use pocketmine\plugin\Plugin;

    and the best part is that whenever I place this line, it happens
    otherwise, server doesn't crash.


    $this->plugin->getLogger()->info(TextFormat::BLUE."Blacklist Check: Checking $player's IP [$ip] for a record in rbl.hyphovy.net");

    ^^

    Some more relevant information:


    public function __construct(Cucumber $plugin)
    {
    $this->plugin = $plugin;
    $config = $this->getPlugin()->getConfig();
    $this->log_traffic = $config->getNested('log.traffic');
    $this->log_chat = $config->getNested('log.chat');
    $this->log_command = $config->getNested('log.command');
    }

    public function getPlugin(): Cucumber
    {
    return $this->plugin;
    }

    I don't know if there is a syntax error, but the error doesn't explain much to me. Please help me solve it.
     
  2. folosinod71962

    folosinod71962 Silverfish

    Messages:
    23
    I Found:
    PHP:
    $this->plugin->getLogger()->info(TextFormat::BLUE."Blacklist Check: Checking $player's IP [$ip] for a record in rbl.hyphovy.net");
    You Forgot getServer() :
    PHP:
    $this->getServer()->getLogger()->info(TextFormat::BLUE."Blacklist Check: Checking $player's IP [$ip] for a record in rbl.hyphovy.net");
     
  3. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    Are you stupid or something? getServer() will return null because the function does not exist in the class. Also the thing you're trying to do would not fix the bug. Don't give fake information without knowing it's going to work.
     
  4. folosinod71962

    folosinod71962 Silverfish

    Messages:
    23
    Short Story: Yes im Stupid
    Long Story:
    I Know like 20% of PHP, I'm Not That Good in PHP, i'm Good in C++, i Say We Should Return To Original Thread Topic. Thanks
     
  5. Seeker

    Seeker Spider Jockey

    Messages:
    45
    GitHub:
    seeker-devs
    USE [./PHP] tags. Is this
    PHP:
    $this->plugin->getLogger()->info(TextFormat::BLUE."Blacklist Check: Checking $player's IP [$ip] for a record in rbl.hyphovy.net");
    in cucumber.php or the plugin file? which one is the main file? If ^^^ is in main class file, if it is in main class file, use getServer() instead of plugin.
     
  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.