Advertisement
icantthinkofone

Untitled

Jul 20th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. public function tick(){//the tick
  2.   $this->updateNormalCrops();
  3. }
  4.  
  5. public function update(array $crop){//to update the time of the crop
  6.   $cfg = (new Config($this->plugin->getDataFolder()."Farms.yml", Config::YAML))->getAll();
  7.   $cfg1 = new Config($this->plugin->getDataFolder()."Farms.yml", Config::YAML);
  8.   foreach($cfg as $data => $id){
  9.     $data = explode(":", $data);
  10.     $x = $crop[0];
  11.     $y = $crop[1];
  12.     $z = $crop[2];
  13.     unset($this->farmData[$data[0].":".$data[1].":".$data[2].":".$data[3].":".$data[4].":".$data[5].":".$data[6]]);
  14.     $cfg1->setAll($this->farmData);
  15.     $cfg1->save();
  16.     $cfg1->set($x.":".$y.":".$z.":".$crop[3].":".$crop[4].":".($crop[5]+1).":".$crop[6], $crop[6]);
  17.     return $cfg1->save();
  18.   }
  19. }
  20.  
  21. public function grow(array $crop){//to update the growth of the time
  22.   $cfg = (new Config($this->plugin->getDataFolder()."Farms.yml", Config::YAML))->getAll();
  23.   $cfg1 = new Config($this->plugin->getDataFolder()."Farms.yml", Config::YAML);
  24.   foreach($cfg as $data => $id){
  25.     $data = explode(":", $data);
  26.     $x = $crop[0];
  27.     $y = $crop[1];
  28.     $z = $crop[2];
  29.     unset($this->farmData[$data[0].":".$data[1].":".$data[2].":".$data[3].":".$data[4].":".$data[5].":".$data[6]]);
  30.     $cfg1->setAll($this->farmData);
  31.     $cfg1->save();
  32.     $cfg1->set($x.":".$y.":".$z.":".$crop[3].":".$crop[4].":"."0".":".$crop[6], $crop[6]);
  33.     return $cfg1->save();
  34.   }
  35. }
  36.  
  37. public function updateNormalCrops(){//to grow the crop
  38.   $cfg = (new Config($this->plugin->getDataFolder()."Farms.yml", Config::YAML))->getAll();
  39.   foreach($cfg as $data => $id){
  40.     if($id = 295) $id = 59;
  41.     $data = explode(":", $data);
  42.     if($data[5] > 11) $this->grow($data);
  43.     $this->update($data);
  44.     $this->grow($data);
  45.     if(++$data[3] < 8){
  46.       $this->grow($data);
  47.       $pos = new Vector3((int)$data[0], (int)$data[1], (int)$data[2]);
  48.       print($data[6]."\n");
  49.       $this->plugin->getServer()->getLevelByName($data[4])->setBlock($pos, Block::get((int)$id, (int)$data[3]));
  50.     }
  51.   }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement