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

Get all blocks by id

Comments in 'Plugin Development' started by AndrewBit, Jan 13, 2016.

  1. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Just use:
    PHP:
    $event->getBlock()->getId();
  2. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    The real problem is that I don't know how to create an multidimensional array in my yaml (with coords and level).
  3. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351

    I don't know how configs works exactly, but maybe use the serialize method with a php 5 multidimensional array ?

    PHP:
        $blocks = [];
            
    $x 1;
            
    $y 2;
            
    $z 3;
            
    $levelName "world";
            
    array_push($blocks,[$x,$y,$z,$levelName]);
    Then you serialize $blocks and save it in config ? (Of course you have to replace all those values by getting coodinates and level of the block)
  4. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PHP:
    public function onEnable() {
      
    $this->config = new Config($this->getDataFolder() . "blocks.yml"Config::YAML, array(
      
    "Blocks" => array(

      ),
      ));
    }
  5. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Really I need to send you again my question? -.-
  6. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    You asked how to create an array in YAML. I showed you how, I don't see the problem.

Share This Page

Advertisement