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

AutoTree plugin finished but i cant figer out how to end file

Comments in 'Plugin Development' started by Wantedkillerss, Jun 24, 2014.

  1. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    OK so here's the file help me end it please:
    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=AutoTree
    description=Automatically grows tree when sapling placed .
    version=0.9
    author=Wantedkillers
    class=AutoTree
    apiversion=12
    */


    class AutoTree implements Plugin {
    private 
    $api;
    public function 
    __construct(ServerAPI $api$server false) {
      
    $this->api $api;
    }
      public function 
    init(){
      
    console(FORMAT_DARK_PURPLE."[Wantedkillers' AutoTree grower] loaded succefuly plugin by Wantedkillers!");
      
    $this->api->addhandler("player.block.place",array($this,"Handlecommand"));
       
        }
       public function 
    __destruct(){
     
    }
       public function 
    Handlecommand($type $arg $event $data) {
          if(
    $data["item"] == $this->api->block->getItem("6" "0")) {
    } else if(
    $data["item"] == $this->api->block->getItem("6" "1")) {
    } else if(
    $data["item"] == $this->api->block->getItem("6" "2")) {
    } else if(
    $data["item"] == $this->api->block->getItem("6" "3")) {
      switch(
    $event){
       case 
    "SAPLING,1":
         
    $tree = new SpruceTreeObject();
         
    $tree = new PineTreeObject();
                
    $level $this->api->level->get("world");
                
    $position Vector3($data->x, ($data->-1), $data->z);
                
    $tree->type 1;
                
    TreeObject::growTree($level$position$type);
        }
        break;
      switch(
    $event){
       case 
    "SAPLING,2":
          
    $tree = new smalltreeobject();
             
    $level $this->api->level->get("world");
             
    $position Vector3($data->x, ($data->-1), $data->z);
          
    $tree->type 2;
             
    TreeObject::growTree($level$position$type);
        break;
      switch(
    $event){
       case 
    "SAPLING,3":
             
    $level $this->api->level->get("world");
             
    $position Vector3($data->x, ($data->-1), $data->z);
        
    $tree = new SmallTreeObject();
        
    $tree->type 3;
              
    TreeObject::growTree($level$position$type);
          break;
      switch(
    $event){
       default:
       case 
    "SAPLING,0":
         
    $tree = new SmallTreeObject();
           
    $level $this->api->level->get("world");
           
    $position Vector3($data->x, ($data->-1), $data->z);
             
    $tree->type 0;
             
    TreeObject::growTree($level$position$type);
        break;
      }
      if(
    $tree->canPlaceObject($level$position$type)){
       
    $tree->placeObject($level$position$type);
         {
         
    $this->api->chat->sendTo($player"[AutoTree] You have grown a $tree->type tree");
         }
      }
    }
    }
    Last edited by a moderator: Jun 25, 2014
  2. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,434
    Plugins:
    14
    What do you mean by "end it"?
  3. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    I mean it says unexpected end of file on line 72
  4. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,434
    Plugins:
    14
    I might use this on my server if it works. :O
  5. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    nop didn't work
  6. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,434
    Plugins:
    14
    PHP:
    if($data["item"] == $this->api->block->getItem("6" "0")) {
    } else if(
    $data["item"] == $this->api->block->getItem("6" "1")) {
    } else if(
    $data["item"] == $this->api->block->getItem("6" "2")) { 
    } else if(
    $data["item"] == $this->api->block->getItem("6" "3")) {
    Should be something like this:

    PHP:
    if($data["item"] == $this->api->block->getItem("6" "0") or $data["item"] == $this->api->block->getItem("6" "1") or $data["item"] == $this->api->block->getItem("6" "2") or $data["item"] == $this->api->block->getItem("6" "3")) {
    xpyctum likes this.
  7. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    702
    Plugins:
    4
    Minecraft User:
    PraxHellTag
  8. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Full error please :)
  9. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    Oh u wanted it to be when an op player uses
    a sappling
  10. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    Im saying that it says unexpected end of file and I can't seem to get it to work
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    How many times had I said...
    You don't need to put "quotes" for IDs!

    For event handler, you can name your arguments with whatever name you want, but the first one will always be the value of the event data, and the second one always be the event name. You can't change this sequence by changing th param names. I just don't understand where this misconception emerged from. Also, requiring too many parameters would create an error. ( ;) like I don't understand why @LDX let his plugin main class implement every class)

    Use
    PHP:
    $position = new Vector3($x$y$z);
    instead.
  12. tnpxxsheepdog
    Offline

    tnpxxsheepdog Notable Member

    Joined:
    Dec 31, 2013
    Posts:
    356
    Minecraft User:
    TNPXXSHEEPDOG
    This should be for the new API!
  13. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    OK mapmodder thx but what should I do for
    The handlers
  14. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    702
    Plugins:
    4
    Minecraft User:
    PraxHellTag

    Reference happened =)
  15. Renzo
    Offline

    Renzo Active Member

    Joined:
    Mar 12, 2014
    Posts:
    96
    Minecraft User:
    Renzo_4
    You need:
    PHP:
    public function __destruct(){
    //Code you want to do when the server stops (can be nothing)
    }
    at the end. just the line above the last }!
  16. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    702
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    .

    Answer # 3: A translation error ...
    Last edited: Jun 25, 2014
  17. Renzo
    Offline

    Renzo Active Member

    Joined:
    Mar 12, 2014
    Posts:
    96
    Minecraft User:
    Renzo_4
    What do you mean with . ?
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Answer #1: spam
    Answer #2: repeat it thrice
  19. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    Ok could you guys please just help me
  20. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    Cause it still says unexpected syntax error on line 72
    LDX likes this.

Share This Page

Advertisement