Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Syntax Error?

Comments in 'Plugin Development' started by Radix, Jul 18, 2015.

  1. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    I don't understand what I did wrong :'(
    PHP:
    PocketMine-MP Crash Dump Sat Jul 18 16:32:14 UTC 2015

    Error
    syntax errorunexpected 'default' (T_DEFAULT)
    File: /phar_Infocmd_GusJEaGcaxC7D8m.phar/src/Infocmd/MainClass
    Line
    32
    Type
    E_PARSE

    THIS CRASH WAS CAUSED BY A PLUGIN

    Code
    :
    [
    23]         $this->getLogger()->info(TextFormat::DARK_RED "InfoCmd has been disabled!");
    [
    24]     }
    [
    25]     public function onCommand(CommandSender $senderCommand $command$label, array $args){
    [
    26]         switch($command->getName()){
    [
    27]             case "info":
    [
    28]                  $player $event->getPlayer();
    [
    29]             foreach($this->getConfig()->get("info") as $info){
    [
    30]               $player->sendMessage("[Info]" $info "!");
    [
    31]                 return true;
    [
    32]             default:
    [
    33]                 return false;
    [
    34]         }
    [
    35]     }
    [
    36
    [
    37
    [
    38
    [
    39
    [
    40
    [
    41
    [
    42
  2. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    I nreally don't get it ._.
  3. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    is "default" another command?
  4. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    no ?
  5. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    You can' t use just an if else ?
  6. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    The default: is inside the foreach :/
    PEMapModder and BlubberBoy333 like this.
  7. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    Try that :
    PHP:
    public function onCommand(CommandSender $senderCommand $command$label, array $args){
    [
    26]         switch($command->getName()){
    [
    27]             case "info":
    [
    28]                  $player $event->getPlayer();
    [
    29]             foreach($this->getConfig()->get("info") as $info){
    [
    30]               $player->sendMessage("[Info]" $info "!");}
    [
    31]                 return true;
    [
    32]             default:
    [
    33]                 return false;
    [
    34]         }
  8. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    So ehats the correct syntax
  9. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    Reload the page i ve already replyed
  10. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    still aan error
  11. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    If you tell us the error we try to help you
  12. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    [​IMG]
  13. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    [​IMG]
  14. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use proper indentation ;)
    Learn PHP :/
    Primus likes this.
  16. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I'm working on it:)
  17. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    I fixed it added a removed it and added break; && I know php :mad:
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I was replying to @BlubberBoy333 about thinking that "default" is another command. I was like facepalm when I read it :oops:
  19. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I'll try to improve the inspection message.
    Why break? If you return you can't break. If you break you can't return.
  20. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,201
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    on your foreach() part, you forgot to close it w/ closing bracket.

Share This Page

Advertisement