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

Claymores Plugin Help

Comments in 'Plugin Development' started by Darunia18, Dec 9, 2013.

?

Is this plugin useful/would anyone use it?

  1. Yes

    100.0%
  2. No

    0 vote(s)
    0.0%
  1. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    Hello! A few months ago, someone suggested making a Claymore plugin (I believe it was @wies). I have finally gotten around to making it. This is only my second plugin, so there may be lots of errors. I am also unable to test it because of Wi-Fi issues, so I need some help with checking the code and making sure it works and possibly testing it if you can. Thank you.

    PHP:
    <?php

    /*
    __PocketMine Plugin__
    name=Claymores
    description=When a player steps on a claymore, it explodes.
    version=0.1
    author=Darunia18
    class=Claymores
    apiversion=10,11
    */

    class Claymores implements Plugin {
        private 
    $api;
     
        public function 
    __construct(ServerAPI $api$server false) {
            
    $this->api $api;
        }
     
        public function 
    init() {
            
    $this->config = new Config($this->api->plugin->configPath($this)."config.yml"CONFIG_YAML, array( 'enabled' => true'ClaymoreBlock' => 44'ExplosionSize' => 5));
            
    $this->api->event("entity.move", array($this"entitymove"));
            
    define("CLAYMORE"$this->config->get('ClaymoreBlock'));
            
    define("EXPLOSION_SIZE"$this->config->get('ExplosionSize'));
        }
     
        public function 
    entitymove($data){
            
    $claymore $data->level->getBlock(new Vector3($data->x, ($data->-1), $data->z));
            if(
    $claymore->getID() == CLAYMORE){
                
    $x $data["target"]->x;
                
    $y $data["target"]->y;
                
    $z $data["target"]->z;
                
    $level $data["target"]->level;
                
    $explosion = new Explosion(new Position($x$y$z$level), $this->size[EXPLOSION_SIZE]);
                
    $explosion->explode();
                return 
    false;
            }
        }
     
        public function 
    __destruct(){
        }
    }
    ?>
    Last edited: Dec 9, 2013
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Why do you return entity.move false? I haven't used that event though so I wouldn't know.
  3. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    I'm not sure why either. I looked at some other plugins and it included that so it seemed important XD
  4. wies
    Offline

    wies Notable Member

    Joined:
    Aug 23, 2013
    Posts:
    392
    PHP:
    public function entitymove($data){
        
    $claymore $data->level->getBlock(new Vector3($data->x, ($data->-1), $data->z));
        if(
    $claymore->getID() == CLAYMORE){
             
    $explosion = new Explosion(new Position($data->x, ($data->-1), $data->z$data->level), EXPLOSION_SIZE);
              
    $explosion->explode();
        }
    }

Share This Page

Advertisement