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

[Solved] Check if player is breaking block in task

Discussion in 'Development' started by kaliiks, Jan 28, 2017.

  1. kaliiks

    kaliiks Zombie

    Messages:
    250
    How can i do it?
     
    Muqsit likes this.
  2. VentroxStudio

    VentroxStudio Witch

    Messages:
    71
    PHP:
    public function onBreak(BlockBreakEvent $event) {
    $player $event->getPlayer();
    }
     
  3. kaliiks

    kaliiks Zombie

    Messages:
    250
    Sorry i dont gived sufficient information i want check it in task
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    you may have to log it somewhere else
    like on main with an array of it
     
  5. kaliiks

    kaliiks Zombie

    Messages:
    250
    I want check when player is breaking block no when breaked block
     
  6. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    PlayerInteractEvent
     
  7. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    waittt, cant you just implement Listener under the task and Boom now you can get it under a "task"
     
  8. kaliiks

    kaliiks Zombie

    Messages:
    250
    It check first tap on block before start breaking, but i want start check it when start breaking block
     
  9. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Try

    PHP:
    public $breaks;

    public function 
    onInteract(PlayerInteractEvent $e) {
      
    $this->breaks true
    }
    public function 
    onBreak(BlockBreakEvent $e) {
      
    $this->breaks false;
    }
    In task you can use
    PHP:
    $breaking $this->plugin->breaks;
     
  10. kaliiks

    kaliiks Zombie

    Messages:
    250
    I want check when player start breaking block no when finish it please read older posts
     
    gistrec likes this.
  11. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    What do you mean by 'start breaking'
     
    gistrec likes this.
  12. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    I don't think that's possible.
     
  13. gistrec

    gistrec Witch

    Messages:
    68
    GitHub:
    gistrec
    Muqsit likes this.
  14. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    kaliiks, Muqsit and gistrec like this.
  15. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    @kaliiks , For what purpose do you want to use?
     
  16. kaliiks

    kaliiks Zombie

    Messages:
    250
    set player gamemode to adventure and then to their gamemode before setting adventure to cancel block breaking if i use blockbreak event hackers can bug out from map on server
     
    gistrec likes this.
  17. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    you should just set gamemode to adventure on block break,
    then fire a delayed task to re set the player's gamemode
     
    kaliiks likes this.
  18. kaliiks

    kaliiks Zombie

    Messages:
    250
    Ok, i used player interact packet and re seted player gamemode in task. Thanks robske_110(Tim) and Thunder33345
     
  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.