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

[HELP PLEASE] What? Parsing error? WhataTerribleFailure...

Comments in 'Plugin Development' started by PEMapModder, Jan 16, 2014.

  1. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    This code:
    PHP:
    <?php
    /*
    __PocketMine Plugin__
    class=PingGrapher
    apiversion=10,11
    version=0.0.0.0
    name=PingGrapher

    */
    class PingGrapher implements Plugin {
        private 
    $streams=array();
        private 
    $dir;
        private 
    $localPlot=false;
        public function 
    __construct(ServerAPI $a,$s=false) {
         
        }
        public function 
    init() {
            
    ServerAPI::request()->schedule(100,array($this,"scheduledGraph"));
            
    ServerAPI::request()->schedule(3000,array($this,"scheduledPutContents"));
            
    $cfg=new Config(($this->dir=ServerAPI::request()->api->plugin->configPath($this))."config.properties",CONFIG_PROPERTIES,array(
                
    "plot local connections"=>false
            
    ));
            if(
    $cfg->get("plot local connections"===true))$this->localPlot=true;
            else 
    $this->localPlot=false;
        }
        public function 
    __destruct() {
         
        }
        public function 
    scheduledGraph() {
            foreach(
    $this->streams as $ign=>$stream){
                
    $this->plot($stream,$ign);
            }
        }
        private function 
    plot($stream,$ign) {
            
    $p=ServerAPI::request()->api->player->get($ign);
            
    $ping=$p->getLag();
            
    $o="";
            for(
    $i=$ping/50;$i>0;$i--){
                
    $o.=" ";
            }
            if (
    false===fwrite($stream,$o."|")) {
                
    console("An error occured while trying to plot graph to $ign's ping graph");
            }
        }
        public function 
    scheduledPutContents() {
            foreach(
    $this->streams as $s){
                
    $this->putContents($s);
            }
        }
        private function 
    putContents($stream) {
            if(
    false===fwrite($stream,date("d-n-y G:i:s\n")))
                
    console("An error occurred while trying to write current time to ".array_search($stream,$this->streams)."'s ping graph");
        }
        public function 
    onJoin(Player $p) {
            if(
    substr($p->ip,0,8)=="192.168." and $this->localPlot!==true)return;
            if(!
    file_exists($this->getFile($p->username)))
                
    $ne=true;
            
    $this->streams[$p->username]=fopen($this->getFile($p->username),"a");
            if(isset(
    $ne) and $ne===true)
                
    putContents($this->streams[$p->username]);
        }
        public function 
    onQuit(Player $p) {
            if(!isset(
    $this->streams[$p->username]))return;
            if(
    false===fclose($this->streams[$p->username])){
                
    console("Failure while trying to close output stream of $p.");
            }
        }
        private function 
    getFile($ign){
            return 
    $this->dir.substr($ign,0,1)."\\$ign.txt";
        }
    }
    Error message:
    FORMAT_RED."Failed parsing PingGrapher.php"
    WTF
    (What a Terrible Failure, not any kind of swearing)
    http://developer.android.com/refere...ml#wtf(java.lang.String, java.lang.Throwable)
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What is parsing error?
  3. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Can I have the full error please?
    A parsing error means something is wrong with your PHP code (Not the API, just raw PHP).
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    no. Just simply "error parsing PingGrapher.php" then not loaded.
  5. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Whata Terrible Failure..... :(

    Ok real post:

    Hmm, there could be something wrong with your code. I'll do some testing once I have some time.

    Standby...
  6. wies
    Offline

    wies Notable Member

    Joined:
    Aug 23, 2013
    Posts:
    390
    You need to set the author.
    PEMapModder likes this.
  7. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Oh yeah.... :)
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Oh yeah... ty
    Although I remember it didn't happen before

Share This Page

Advertisement