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

Solved Where is my mistake?

Discussion in 'Development' started by 7awariGamer, Mar 26, 2019.

  1. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    PHP:
    <?php
    namespace com\hawari\Gg;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerRespawnEvent;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Server;
    use 
    pocketmine\utils\TextFormat;

    class 
    Main extends PluginBase implements Listener{
     
      public function 
    onEnable()
      {
        
    $this->getServer()->getPluginManager()->registerEvents(thisthis);
        
    $this->getLogger()->info(TextFormat::GREEN "plugin works by 7awari");
      }
     
     
        
      public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){       
           switch(
    $command->getName()){
                   case 
    "about":
                      
    $sender->sendMessage("§6This server is running StockPE.phar for Minecraft: Bedrock Edition v1.10.x (protocol 180)");
                         break;
            
             case 
    "ver":
                
    $sender->sendMessage("§6This server is running StockPE.phar for Minecraft: Bedrock Edition v1.10.x (protocol 180)");
                         break;

             case 
    "version":
                                  
    $sender->sendMessage("§6This server is running StockPE.phar for Minecraft: Bedrock Edition v1.10.x (protocol 180)");
                                          }
      }
    }
    ?>
     
  2. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    you have to register the command in your plugin.yml if you're listening to commands like that
    also I recommend you using an IDE with autocomplete, maybe PHPStorm etc
     
  3. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    Code:
    name: Private
    version: 0.0.5
    api: [3.0.0, 3.7.0, 3.5.0, 3.2.6, 4.0 0]
    author: 7awariGamer(7Wdev)
    main: com\hawari\Gg\Main
    
    commands:
      about:
        description: Gets the version of this server including any plugins in use
        usage: "/about"
        permission: pmmpabout
      ver:
        description: Gets the version of this server including any plugins in use
        usage: "/ver"
        permission: pmmpabout
      version:
        description: Gets the version of this server including any plugins in use
        usage: "/version"
        permission: pmmpabout
    permissions:
      pmmpabout:
        description: "Allow /ver to display PMMP."
        default: true

    But the server still crash when i put this plugin in plugins folder
     
  4. UnknownOre

    UnknownOre Silverfish

    Messages:
    21
    GitHub:
    UnknownOre
    PHP:
    <?php
    namespace com\hawari\Gg;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerRespawnEvent;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Server;
    use 
    pocketmine\utils\TextFormat;

    class 
    Main extends PluginBase implements Listener{

      public function 
    onEnable()
      {
        
    $this->getServer()->getPluginManager()->registerEvents(thisthis);
        
    $this->getLogger()->info(TextFormat::GREEN "plugin works by 7awari");
      }


     
      public function 
    onCommand(CommandSender $senderCommand $command$label, array $args): bool{     
           switch(
    $command->getName()){
              case 
    "about":
             case 
    "version":
             case 
    "ver":
                                  
    $sender->sendMessage("§6This server is running StockPE.phar for Minecraft: Bedrock Edition v1.10.x (protocol 180)");
                                          break;
      }
    return 
    true;
    }
    ?>
    use this code and next time Consider posting the error with the code
     
    Last edited: Mar 26, 2019
  5. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    Doesn't work

    Log:
    Code:
    [13:20:22] [Server thread/DEBUG]: #0 (): BaseClassLoader->loadClass(string com\hawari\Gg\Main)
    [13:20:22] [Server thread/DEBUG]: #1 (): spl_autoload_call(string com\hawari\Gg\Main)
    [13:20:22] [Server thread/DEBUG]: #2 src/pocketmine/plugin/PluginManager(178): class_exists(string com\hawari\Gg\Main, boolean 1)
    [13:20:22] [Server thread/DEBUG]: #3 src/pocketmine/plugin/PluginManager(343): pocketmine\plugin\PluginManager->loadPlugin(string /storage/emulated/0/PocketMine-MP/plugins/Private, array Array())
    [13:20:22] [Server thread/DEBUG]: #4 plugins/PocketMine-DevTools.phar/src/DevTools/DevTools(49): pocketmine\plugin\PluginManager->loadPlugins(string /storage/emulated/0/PocketMine-MP/plugins/, array Array())
    [13:20:22] [Server thread/DEBUG]: #5 src/pocketmine/plugin/PluginBase(123): DevTools\DevTools->onEnable()
    [13:20:22] [Server thread/DEBUG]: #6 src/pocketmine/plugin/PluginManager(587): pocketmine\plugin\PluginBase->setEnabled(boolean 1)
    [13:20:22] [Server thread/DEBUG]: #7 src/pocketmine/Server(1984): pocketmine\plugin\PluginManager->enablePlugin(DevTools\DevTools object)
    [13:20:22] [Server thread/DEBUG]: #8 src/pocketmine/Server(1970): pocketmine\Server->enablePlugin(DevTools\DevTools object)
    [13:20:22] [Server thread/DEBUG]: #9 src/pocketmine/Server(1703): pocketmine\Server->enablePlugins(integer 0)
    [13:20:22] [Server thread/DEBUG]: #10 src/pocketmine/PocketMine(250): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string /storage/emulated/0/PocketMine-MP/, string /storage/emulated/0/PocketMine-MP/plugins/)
    [13:20:22] [Server thread/DEBUG]: #11 (1): require(string phar:///storage/emulated/0/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
     
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    What is the error message? You just showed the stack trace.
     
  7. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    Code:
    [07:26:36] [Server thread/CRITICAL]: ParseError: "syntax error, unexpected '{'" (EXCEPTION) in "plugins/Private/src/com/hawari/Gg/Main" at line 13
     
  8. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    That error shouldn't happen with the code you posted. Try deleting the first 13 lines and manually type them again.
     
  9. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    Same doesn't work , but idk why
     
  10. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    There is no closing curly bracket for the switch
     
  11. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    Yes, I put it but still doesn't work
     
  12. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    can you post your current code in hastebin or something?
    make sure you're editing the right file, sometimes I edit the same file name but in a different directory :confused:
    make sure it saves too, try CTRL + S
    make sure you restarted your server too
     
  13. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    Take it and test it ...
    Link : https://www.mediafire.com/download/bc746vazmiq4b6r
     
  14. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
  15. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    I gave u all informations up !
    I can't give u anything more...
    You can test the plugin in your server , and thx
     
  16. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    Welp. This is the most messy code i have ever seen in my entire life
     
  17. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
  18. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    Try /genplugin <Name plugin> <Author> if you have DevTools to get a skeleton_plugin
     
  19. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    Thx
     
  20. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    It isn't my code , my orginorl code is up ._.
     
  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.