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

Breakblockevent get count block and get reward

Discussion in 'Plugin Help' started by Edo, Dec 31, 2020.

  1. Edo

    Edo Spider

    Messages:
    6
    GitHub:
    Edo
    How do I set BlockBreakEvent so that when I break 10 grass I do a command
     
  2. Edo

    Edo Spider

    Messages:
    6
    GitHub:
    Edo
    Please help me
     
  3. Primus

    Primus Zombie Pigman

    Messages:
    749
    You barely waited for 5 minutes.

    Anyways check plugin MockingBird. I think that it is capable of doing that.
     
  4. SeferA

    SeferA Spider

    Messages:
    6
    önce bunun kodunu görmemiz gerekiyor, ancak blockbreak sınıfını miras alan bir sınıf oluşturmanıza ve çimeni her kırdığınızda config olarak kaydetmenize yardımcı olacağım
     
  5. OguzhanUmutlu

    OguzhanUmutlu Witch

    Messages:
    63
    GitHub:
    OguzhanUmutlu
    Main:
    PHP:
    <?php
    namespace test;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\event\BlockBreakEvent;
    use 
    pocketmine\command\ConsoleCommandSender;

    class 
    Main extends PluginBase implements Listener {
      public function 
    onEnable() {
        
    $this->config = new Config($this->getDataFolder()."myconfig.yml"Config:YAML, array());
      }
      public function 
    onBreak(BlockBreakEvent $event) {
        
    $block $event->getBlock();
        
    $player $event->getPlayer();
        
    $this->config->setNested($player->getName(), ($this->config->getNested($player->getName()) ?? 0)+1);
        
    $this->config->save();
        
    $this->config->reload();
        if((
    $this->config->getNested($player->getName()) ?? 0) > 200) {
          
    $player->sendMessage("you earned 1 diamond for digging 200 blocks.");
          
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(), "give " $player->getName() . " diamond 1");
        }
      }
    }
     
  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.