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

Plugin Error

Discussion in 'Development' started by StuckDexter, Apr 26, 2017.

Thread Status:
Not open for further replies.
  1. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    I Have a problem with my plugin
    Code:
    [Server] [21:18:46] [Server thread/INFO]: Loading source plugin GameLobby v1
    [Server] [21:18:46] [Server thread/CRITICAL]: ParseError: "syntax error, unexpected 'public function Receive' (T_STRING), expecting function (T_FUNCTION)" (EXCEPTION) in "/GameLobby/src/StuckDexter/lg" at line 101
    [Server] [21:18:46] [Server thread/EMERGENCY]: An unrecoverable error has occurred and the server has crashed. Creating a crash dump
    [Server] [21:18:46] [Server thread/EMERGENCY]: Please upload the "/storage/emulated/0/PocketMine/crashdumps/Wed_Apr_26-21.18.46-UTC_2017.log" file to the Crash Archive and submit the link to the Bug Reporting page. Give as much info as you can.
    
    I don't know why.

    Thats the code:
    PHP:
    public function Receive(DataPacketReceiveEvent $event)
    {
        
    $packet $event->getPacket();
        if (
    $packet instanceof PlayerActionPacket) {
            
    $this->plugin->getLogger()->warning("DataPacket: PlayerActionPacket was received with action id: " $packet->action);
        }
    }
    Thanks.
     
    Last edited: Apr 26, 2017
  2. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    1. Use Code Bocks
    2. Show us the code about that, there is your syntax error.
    Maybe you forgot a "}"
     
  3. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    I testet it i didn't forgot a "}"
     
  4. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    If you want help, show us the code about that (With Code Blocks)
     
  5. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    PHP:
    <?php


    namespace StuckDexter;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Player;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\event\server\DataPacketReceiveEvent;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\block\Block;

    class 
    lg extends PluginBase implements Listener{

    public 
    $prefix "§7[§5Lobby§7]§r ";

    public function 
    onEnable(){
    $this->getLogger()->info($this->prefix."§awurde aktiviert");
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    }

    public function 
    onDisable(){
    $this->getLogger()->info($this->prefix."§4wurde deaktiviert");
    }


    public function 
    Receive(DataPacketReceiveEvent $event)
    {
        
    $packet $event->getPacket();
        if (
    $packet instanceof PlayerActionPacket) {
            
    $this->plugin->getLogger()->warning("DataPacket: PlayerActionPacket was received with action id: " $packet->action);
        }
    }
    }

    ?>
     
    Last edited: Apr 26, 2017
  6. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    I'm not sure, but I think the initial letter of a function must always be lowercase.
     
  7. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    But the function onMove does work.
     
  8. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    Because the first letter is lowercase
     
  9. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    If name the onRecive and recive it also doesn't work.
     
  10. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    it should work
     
  11. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    No there is the same error as the beginning.
     
  12. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    The Code works :D
     
  13. udwarf

    udwarf Silverfish

    Messages:
    21
    You gave us not the full file that throws an error.
    Bug somewere in removed part. Looks like there is extra "}"
     
  14. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    your first version too :D
     
  15. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    @udwarf I cutted it, but it also doesn't work on my server.
    Is the problem that I use a localhost server without PortForwanding?
     
  16. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    This isn't a PMMP issue, this is a PHP issue. I suggest searching StackOverflow for a better answer.
     
  17. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    avoid using ?> at the end. any byte after tag can lead to syntax error
     
  18. udwarf

    udwarf Silverfish

    Messages:
    21
    So, you've cutted the reason of the error.Check it by yourself for extra brackets (}) if you afraid to share an original file
     
    McpeBooster likes this.
  19. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    Uh, anything written after the closing tag isn't interpreted as PHP, so unless you haven't written your syntax properly(i.e. forgetting a closing brace when ending the class), it wouldn't cause any syntax errors as far as I'm aware. But yes, the best practice is to omit the closing tags.
     
  20. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    jasonwynn10 likes this.
Thread Status:
Not open for further replies.
  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.