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

Weird errors

Comments in 'Plugin Development' started by MCUnderground, Feb 9, 2016.

Thread Status:
Not open for further replies.
  1. MCUnderground
    Offline

    MCUnderground New Member

    Joined:
    Feb 6, 2016
    Posts:
    10
    Minecraft User:
    MCUnderground
    My code
    PHP:
    <?php

    namespace mcunderground\cmdrules;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\Server;
    use 
    pocketmine\utils\TextFormat;

    class 
    Main extends PluginBase {
        public 
    $configFile;

        public function 
    onEnable()
    {
            @
    mkdir($this->getDataFolder());
            
    $this->configFile = (new Config($this->getDataFolder()."config.yml"Config::YAML, array(
                
    "1." => "Don't Grief.",
                
    "2." => "Don't use bad words.",
                
    "3." => "Don't ask for OP or ranks.",
                
    "4." => "Be Nice",
                
    "5." => "Never be rude."
            
    )))->getAll();
            
    $this->getLogger()->info("[CommandRules] Loaded!");
        }



        public function 
    onCommand(CommandSender $senderCommand $cmd$label, array $args){
              if(
    $cmd->getName() == "rules"){
                  
    $sender->sendMessage(TextFormat::RED."1. " $this->configFile["1."]);
                  
    $sender->sendMessage(TextFormat::RED."2. " $this->configFile["2."]);
                  
    $sender->sendMessage(TextFormat::RED."3. " $this->configFile["3."]);
                  
    $sender->sendMessage(TextFormat::RED."4. " $this->configFile["4."]);
                  
    $sender->sendMessage(TextFormat::RED."5. " $this->configFile["5."]);


            }

        }
        public function 
    onJoin(PlayerJoinEvent $event){
              
    $player $event->getPlayer();
              
    $name $player->getName();
              
    $player->sendMessage("§9Please read rules. Use /rules command.);
         }




        public function onDisable() {
            
    $this->getLogger()->info("[CommandRulesDisabled!");

        }


    }

    Gives me synatx error like Unexpected ' ' at line 31, unexpected '{' at line31
  2. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Hmm... There must be an syntax error at line 31, no?
    Learn how to read the error message, it is displayed so that people can read.
  3. MCUnderground
    Offline

    MCUnderground New Member

    Joined:
    Feb 6, 2016
    Posts:
    10
    Minecraft User:
    MCUnderground
    This is line31:
    PHP:
    if($cmd->getName() == "rules"){
    I dont see error there.
  4. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Are you sure that is the correct code and correct error? Maybe a crashdump would be helpful.
  5. Intyre
    Offline

    Intyre Staff Member PocketMine Team

    Joined:
    Aug 24, 2013
    Posts:
    118
    Minecraft User:
    Intyre
    Hint: look at those pretty colors and spot the error :p

    It is red but should be green
    Last edited: Feb 9, 2016
  6. MCUnderground
    Offline

    MCUnderground New Member

    Joined:
    Feb 6, 2016
    Posts:
    10
    Minecraft User:
    MCUnderground
    Genisys Crash Dump Tue Feb 9 09:50:29 EST 2016

    Error: syntax error, unexpected '{'
    File: /CommandRules/src/mcunderground/cmdrules/Main
    Line: 33
    Type: E_PARSE

    THIS CRASH WAS CAUSED BY A PLUGIN
    此次出错由插件引起

    Code:
    [24] "4." => "Be Nice",
    [25] "5." => "Never be rude."
    [26] )))->getAll();
    [27] $this->getLogger()->info("[CommandRules] Loaded!");
    [28] }
    [29]
    [30]
    [31]
    [32] public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){
    [33] if($cmd->getName() == "rules"){
    [34] $sender->sendMessage(TextFormat::RED."1. " . $this->configFile["1."]);
    [35] $sender->sendMessage(TextFormat::RED."2. " . $this->configFile["2."]);
    [36] $sender->sendMessage(TextFormat::RED."3. " . $this->configFile["3."]);
    [37] $sender->sendMessage(TextFormat::RED."4. " . $this->configFile["4."]);
    [38] $sender->sendMessage(TextFormat::RED."5. " . $this->configFile["5."]);
    [39]
    [40]
    [41] }
    [42]
    [43] }

    Backtrace:
    #0 (): pocketmine\Server->crashDump(boolean)

    Genisys version: 1.0dev #0 [Protocol 38; API 1.13.1]
    uname -a: Linux 03559f2d9488 3.19.8-031908-generic #201505110938 SMP Mon May 11 13:39:59 UTC 2015 x86_64
    PHP version: 5.6.9
    Zend version: 2.6.0
    OS : Linux, linux

    Loaded plugins:
    加载的插件:
    Blood 1.1.1 by boybook for API(s) 1.8.0
    VPNGuard 1.0.4 by basprohop for API(s) 1.10.0
    ItemCasePE 1.0.8 by aliuly for API(s) 1.10.0, 1.13.0
    FactionsPro 1.3.2 by Tethered_ for API(s) 1.12.0
    iProtector 3.1a by LDX for API(s) 1.9.0
    VIPSlots 0.0.4 by iJoshuaHD for API(s) 1.12.0
    Alias 1.2.0 by ZacHack for API(s) 1.12.0
    ManyWorlds 2.0.3 by aliuly for API(s) 1.10.0
    MSpawns 1.5 by EvolSoft for API(s) 1.11.0
    AdminFun 1.0.0 by hoyinm14mc for API(s) 1.12.0, 1.13.0, 2.0.0
    TapToDo 2.2.1 by Falk for API(s) 1.0.0
    AutoInv 1.0.1 by HotshotHD for API(s) 1.12.0, 1.13.0
    EssentialsPE 1.1.3 by LegendsOfMCPE Team for API(s) 1.12.0
    SexyMOTD 0.2 by hoyinm for API(s) 1.12.0
    WorldEditArt 1.0.0_beta_dev_#048 by PEMapModder for API(s) 1.0.0
    PurePerms 1.2.2 by 64FF00 for API(s) 1.12.0
    DevTools 1.10.0 by PocketMine Team for API(s) 1.3.1
    LaunchPads 1.0.0 by MCPEPIG for API(s) 1.0.0
    LeetAuth 1.3.1 by ProjectInfinity for API(s) 1.13.0
    Leaps 1.0.0 by LittleBigMC for API(s) 1.0.0
    CSWeapons 1 by Ragnok113 for API(s) 1.13.1
    AntiAdvertising 1.1 by Ragnok123 for API(s) 1.0.0
  7. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    That was not helpful.
  8. MCUnderground
    Offline

    MCUnderground New Member

    Joined:
    Feb 6, 2016
    Posts:
    10
    Minecraft User:
    MCUnderground
    Yeah
  9. Intyre
    Offline

    Intyre Staff Member PocketMine Team

    Joined:
    Aug 24, 2013
    Posts:
    118
    Minecraft User:
    Intyre
    Colorblindness?
    PHP:
    public function onJoin(PlayerJoinEvent $event){
        
    $player $event->getPlayer();
        
    $name $player->getName();
        
    $player->sendMessage("§9Please read rules. Use /rules command.);
    }
    vs
    PHP:
    public function onJoin(PlayerJoinEvent $event){
        
    $player $event->getPlayer();
        
    $name $player->getName();
        
    $player->sendMessage("§9Please read rules. Use /rules command.");
    }
  10. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Your problem is, you use genisys ;)

    Just kidding (you really shouldn't..)

    Code:
             $player->sendMessage("§9Please read rules. Use /rules command.);
     }
    i correct.. It is xD
Thread Status:
Not open for further replies.

Share This Page

Advertisement