Advertisement
TungstenVn

Untitled

Aug 27th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.88 KB | None | 0 0
  1. public function taskRunner(){
  2.       foreach($this->getConfig()->getNested("CheckTime") as $time){
  3.        if(date("H",time()) == $time){
  4.            if(!$this->getConfig()->getNested("isCheckItem")){
  5.               $this->getConfig()->setNested("isCheckItem",true);
  6.               foreach($this->getConfig()->getNested("playerjobs") as $p){
  7.                 $this->getConfig()->setNested("$p.isCheck",false);
  8.               }
  9.               $this->getConfig()->setAll($this->getConfig()->getAll());
  10.               $this->getConfig()->save();
  11.  
  12.                foreach($this->getServer()->getOnlinePlayers() as $a){
  13.                     $n = $a->getName();
  14.                     $inv = $a->getInventory();
  15.                     $p = $this->getConfig()->getNested("playerjobs.$n");
  16.                     if(null == $p){goto lol;}
  17.                     $name = $p["name"];            
  18.                     foreach($this->getConfig()->getNested("job")[$p["idjob"]]["item"] as $item){
  19.                       $exp = explode(":", $item);
  20.                       $it = Item::get($exp[0],$exp[1],$exp[2]);
  21.                       $amount = $exp[2];
  22.                       if($inv->contains($it)){
  23.                         foreach($this->getConfig()->getNested("CommandForDoneJob") as $a){
  24.                            $this->getServer()->dispatchCommand(new ConsoleCommandSender(),str_replace(["{name}"],[$name],$a)); 
  25.                         }
  26.                         $inv->removeItem($it);
  27.                       }else{
  28.                         foreach($this->getConfig()->getNested("CommandForUnDoneJob") as $a){
  29.                            $this->getServer()->dispatchCommand(new ConsoleCommandSender(),str_replace(["{name}"],[$name],$a)); 
  30.                         }  
  31.                       }
  32.                     }        
  33.                     $this->getConfig()->setNested("playerjobs.$n.isCheck",true);
  34.                     $this->getConfig()->setAll($this->getConfig()->getAll());
  35.                     $this->getConfig()->save();
  36.                     lol:
  37.                }
  38.            }
  39.        }else{
  40.         if($this->getConfig()->getNested("isCheckItem")){
  41.             $this->getConfig()->setNested("isCheckItem",false);
  42.             $this->getConfig()->setAll($this->getConfig()->getAll());
  43.             $this->getConfig()->save();
  44.         }
  45.        }
  46.       }
  47.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement