1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Help for task

Discussion in 'Help' started by Mochi, Mar 9, 2020.

  1. Mochi

    Mochi Baby Zombie

    Messages:
    113
    This is my code :

    PHP:
    <?php

    namespace moch\pl;

     use 
    pocketmine\plugin\PluginBase;
     use 
    pocketmine\Player;
     use 
    pocketmine\Server;
     use 
    pocketmine\event\Listener;
     use 
    pocketmine\event\player\PlayerJoinEvent;
     
     use 
    pocketmine\item\Item;
     use 
    pocketmine\event\block\BlockPlaceEvent;
     use 
    pocketmine\event\block\BlockBreakEvent;
     
     use 
    pocketmine\block\Block;
     
     use 
    pocketmine\utils\Config;
     use 
    pocketmine\math\Vector3;
     
     use 
    pocketmine\level\particle\{DustParticleFlameParticleFloatingTextParticleEntityFlameParticleCriticalParticleExplodeParticleHeartParticleLavaParticleMobSpawnParticleSplashParticle};
     
    class 
    Main extends PluginBase implements Listener {
        
        public 
    $plugin;

        public function 
    onEnable(){
            
    $this->getLogger()->info("Leaderboard Enable...");
            
            @
    mkdir($this->getDataFolder() . "Top_Player");
            
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
        
        public function 
    LeadTask(PlayerJoinEvent $event){
            
    $player $event->getPlayer();
            
            
    $this->getScheduler()->scheduleDelayedTask(new LeadTask($this$player), 20); //30min.
        
    }
        
        public function 
    setfarmdata(BlockBreakEvent $event) {
            
    $player $event->getPlayer();
            
    $name $player->getName();
            
    $break $event->getBlock();
            if(
    $break->getId() === 141 || $break->getId() === 142 || $break->getId() === 59 || $break->getId() === 86 || $break->getId() === 103){
                
    $data = new Config($this->getDataFolder() . "Top_Player/topfarm.yml"Config::YAML);
                
    $up $data->get($name);
                
    $data->set($name$up 0.1);
                
    $data->save();
            }
        }
        
        public function 
    createtopten(PlayerJoinEvent $event){
            
    $player $event->getPlayer();
            
    $w $this->getConfig()->get("world");
            
    $world $player->getLevel()->getName() === "$w";
            
    $top $this->getConfig()->get("enable");
            
            if(
    $world){
                if(
    $top == "true"){
                    
    $this->TopFarm($player);
                }
            }
        }
        
        public function 
    TopFarm($p){
            
    $player $p->getPlayer();
            
    $data = new Config($this->getDataFolder() . "Top_Player/topfarm.yml"Config::YAML);
            
    $swallet $data->getAll();
            
    $c count($swallet);
            
    $message "";
            
    $top "§b§l=====§eTopFarm§b§l=====";
            
    arsort($swallet);
            
    $i 1;
            foreach (
    $swallet as $name => $amount) {
                        
                
    $message .= "§b ".$i.". §7".$name."  §akeep  §f".$amount." §aItem\n";
                if(
    $i 9){
                    break;
                }
                ++
    $i;
            }
            
            
    $x $this->getConfig()->get("farm-x");
            
    $y $this->getConfig()->get("farm-y");
            
    $z $this->getConfig()->get("farm-x");
            
            
    $p = new FloatingTextParticle(new Vector3($x$y 1$z), $message$top);
            
    $player->getLevel()->addParticle($p);
        }
    }
        
     

    Attached Files:

  2. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    First of all
    It's not 30 minute but 1 second .-.
    Than were is the task class located?? The error is pretty clear
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.