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

Change block every second?

Comments in 'Plugin Development' started by Legoboy0215, May 17, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I have main.php...
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Make sure your file is at /src/legoboy/blockchanger/Main.php
  3. Pman1220
    Offline

    Pman1220 Active Member Plugin Developer

    Joined:
    Nov 21, 2013
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Pman1220
    You need to set up your plugin.yml file correctly. Make sure everything is spelt right. My suggestion is take out the 3rd folder named legoboy and put your files in the blockchanger folder. After that your plugin.yml should look like this:
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Wait, is your namespace legoboy\blockchanger or blockchanger?

    Also, the files might be case-sensitive.
    Pman1220 likes this.
  5. Pman1220
    Offline

    Pman1220 Active Member Plugin Developer

    Joined:
    Nov 21, 2013
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Pman1220
    He has Legoboy\blockchanger\main.... I personally never put in 2 folders in SRC that's why I recommended removing a folder.
  6. GamesLoad
    Offline

    GamesLoad Active Member

    Joined:
    Jun 28, 2014
    Posts:
    106
    Minecraft User:
    GamesLoad
    pemapmodder you can give me a phar I did not understand how to operate it gives me error
    [WARNING] RuntimeException: "Missing argument 2 for pocketmine \ scheduler \ ServerScheduler :: scheduleDelayedRepeatingTask (), called inphar://C:/Users/Salvatore/Documents/tutorialServer/PocketMine-MP/plugins/BudinoCraft_ChangeBlock_v1.0.0.phar/src/robozeri/ChangeBlock/Main.php on line 8 and defined "(E_WARNING) in" / src / pocketmine / scheduler / ServerScheduler "at line 130
  7. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    It is legoboy\blockchanger\Main.php
    Ok. I will try to remove the legoboy folder.
  8. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Nope. The same error.
    My Main.php:
    PHP:
    <?php
    namespace blockchanger;
    use 
    pocketmine\scheduler\PluginTask;
    class 
    ChangeBlockTask extends PluginTask{
      private 
    $pos;
      private 
    $list;
      private 
    $current 0;
      public function 
    __construct(Main $mainPosition $pos, array $list){
        
    parent::__construct($main);
        
    $this->pos $pos;
        
    $this->list $list;
        if(
    count($list) === 0){
          throw new \
    InvalidArgumentException;
        }
      }
      public function 
    onRun($t){
        
    $this->pos->getLevel()->setBlock($this->pos$this->list[$this->next()]);
      }
      private function 
    next(){
        
    $this->current++;
        if(
    $this->current >= count($this->list)) $this->current 0// loop back to the initial item
        
    return $this->current;
      }
    }
    My ChangeBlockTask.php:
    PHP:
    <?php
    namespace blockchanger;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\plugin\PluginBase;
    class 
    main extends PluginBase{
      public function 
    onEnable(){
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position(1103151$this->getServer()->getDefaultLevel()), [Block::get(Block::WOOL0), Block::get(Block::WOOL15)]), 2020);
      }
    }
    My plugin.yml:
    Code:
    name: blockchanger
    version: 1.0.0
    api: 1.0.0
    main: blockchanger\Main
    author: legoboy
    My Folder Structure:
    2015-05-18_175954.jpg
    2015-05-18_180013.jpg
    2015-05-18_180022.jpg
  9. Pman1220
    Offline

    Pman1220 Active Member Plugin Developer

    Joined:
    Nov 21, 2013
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Pman1220
    Ill put this plugin together and put a link in the thread when I have some downtime.
  10. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Thanks!
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Traditional Chinese!!!
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    #facepalm

    How many times do I have to tell you that the class name must be same as filename?
  13. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Ok... I will change it. Sorry for all probelms. PS: Do you have any problems with Traditional Chinese?
  14. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Error still:
    Code:
    21:03:22 [CRITICAL] ClassNotFoundException: "Class blockchanger\Main not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 111
    
    Main.php:
    PHP:
    <?php
    namespace blockchanger;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\plugin\PluginBase;
    class 
    ChangeBlockTask extends PluginTask{
      private 
    $pos;
      private 
    $list;
      private 
    $current 0;
      public function 
    __construct(Main $mainPosition $pos, array $list){
        
    parent::__construct($main);
        
    $this->pos $pos;
        
    $this->list $list;
        if(
    count($list) === 0){
          throw new \
    InvalidArgumentException;
        }
      }
      public function 
    onRun($t){
        
    $this->pos->getLevel()->setBlock($this->pos$this->list[$this->next()]);
      }
      private function 
    next(){
        
    $this->current++;
        if(
    $this->current >= count($this->list)) $this->current 0// loop back to the initial item
        
    return $this->current;
      }
    }
    ChangeBlocktask.php:
    PHP:
    <?php
    namespace blockchanger;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\plugin\PluginBase;
    class 
    Main extends PluginBase{
      public function 
    onEnable(){
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position(1103151$this->getServer()->getDefaultLevel()), [Block::get(Block::WOOL0), Block::get(Block::WOOL15)]), 2020);
      }
    }
    plugin.yml:
    Code:
    name: blockchanger
    version: 1.0.0
    api: 1.0.0
    main: blockchanger\Main
    author: legoboy
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Because I write Traditional Chinese too :p
    For the billionth time, file name must be the same as class name.
    Is it so hard to understand that?
  16. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    Maybe if you write that in Traditional Chinese...
    Legoboy0215 and PEMapModder like this.
  17. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    檔名必須和class名一樣。
    例如, class MyClassName ... 的檔名必須是 MyClassName.php ,所以你兩個檔名應該調轉。

    @aliuly happy? :p
    Samueljh1 likes this.
  18. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    ChangeBlockTask.php
    Main.php
    plugin.yml
    src\blockchanger\Main
    Is this right? Also, change the class main to class Main?
  19. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    No Ignore my last post. I typed it on my Kindle White. I know now...... Sorry for all the problems you got from me. :(
  20. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Class not found....
    Now it is that it can not find blockchanger\Position.
    Where did the class come from?

Share This Page

Advertisement