Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

block break/interact event (bug)

Comments in 'Plugin Development' started by Creeperface, Jun 10, 2015.

  1. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    i want to send message (X: Y: Z: ) to player when breaks block
    but when touch block i want send message too.
    but when player destroys block so together he touch 2x block which destroying and 1x block at coordinates 0 0 0 so server send 4 messages to player
    is it a PM bug?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No it isn't a PM bug. You should only handle PlayerInteractEvent. Who told you only one event is fired per player action?
    Creeperface likes this.
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    and how can player touch block at coordinates 0, 0 ,0 always???​
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I think your plugin had a bug. Code?
  5. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    PHP:
    public function onTouch(PlayerInteractEvent $e){
            
    $p $e->getPlayer();
            
    $b $e->getBlock();
                
    $p->sendMessage(TextFormat::GREEN.var_dump($this->plugin->getMessage("select_point")).TextFormat::RED."($b->x$b->y$b->z)".TextFormat::GREEN);
                
    $e->setCancelled();
        }
       
        public function 
    onBlockBreak(BlockBreakEvent $e){
            
    $p $e->getPlayer();
            
    $b $e->getBlock();
                
    $p->sendMessage(TextFormat::GREEN.var_dump($this->plugin->getMessage("select_point")).TextFormat::RED."($b->x$b->y$b->z)".TextFormat::GREEN."!");
                
    $e->setCancelled();
        }
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    #facepalm...
    Do you know what var_dump means? http://php.net/var-dump
    I asked you to use the var_dump function to check the return value of the function! var_dump only echos things to console for debug purposes, and it does not return anything!
  7. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    sure sorry I didnĀ“t look on var_dump function

Share This Page

Advertisement