Solved Unexpected "}"

Discussion in 'Development' started by SJames, May 12, 2019.

  1. SJames

    SJames Silverfish

    Messages:
    24
    GitHub:
    sjamese
    Hello. I am developing a plugin and I am getting this error:
    Code:
    2019-05-12 [07:38:05] [Server thread/CRITICAL]: ParseError: "syntax error, unexpected '}'" (EXCEPTION) in "plugins/ThruCommand/src/ThruCommand/SJames/Main" at line 22
    I don't understand why. I have an if-statement 2 lines above. Any help?
    Thanks.

    PHP:
    <Main file>
    <?php

    namespace ThruCommand\SJames;

    use 
    pocketmine\Sever;
    use 
    pocketmine\Player;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\level\position;
    use 
    pocketmine\Vector3;
    use 
    pocketmine\utils\TextFormat as c;

    class 
    Main extends PluginBase{
      public function 
    onEnable(){
      }
      public function 
    onCommand(CommandSender $playerCommand $cmdString $label, array $args){
      switch(
    $cmd -> getName()){
        case 
    "thru" ;
          if (!(
    $player instanceof Player)){
            
    $sender->sendMessage(TextFormat::DARK_RED "Please run this command in-game.")
          }else{      
    #line 22
            
    $distance 1;
            switch(
    $player->getTargetBlock($distance));
              case 
    "stone"
                
    $player->sendMessage(TextFormat::GREEN."You are looking at Stone"
         
          
    }
      return 
    true;
      }
     
      return 
    true;
      }
    }
     
  2. GamakCZ

    GamakCZ Zombie

    Messages:
    229
    GitHub:
    GamakCZ
    PHP:
    $sender->sendMessage(TextFormat::DARK_RED "Please run this command in-game.")
    1) missing ;

    PHP:
    $player->sendMessage(TextFormat::GREEN."You are looking at Stone"
    2) missing );
    3) missing endswitch;


     
    SJames likes this.
  3. Levi

    Levi Skeleton

    Messages:
    846
    GitHub:
    captainleviftw
    Did you read the error
     
  4. SJames

    SJames Silverfish

    Messages:
    24
    GitHub:
    sjamese
    T
    Thanks.
    And yes I did read it.
     
  5. Emirhan Akpınar

    Emirhan Akpınar Witch

    Messages:
    59
    GitHub:
    EmirhanWSD
    PHP:
    case "thru":
     
    SJames likes this.
  6. GamakCZ

    GamakCZ Zombie

    Messages:
    229
    GitHub:
    GamakCZ
    that isn't problem :D try it with ;
     
  7. Emirhan Akpınar

    Emirhan Akpınar Witch

    Messages:
    59
    GitHub:
    EmirhanWSD
    how? :D Can I use ; or : on case?
     
  8. GamakCZ

    GamakCZ Zombie

    Messages:
    229
    GitHub:
    GamakCZ
    yes
     

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.