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

Crash on prevent block place event

Comments in 'Plugin Development' started by abler98, Jan 21, 2015.

  1. abler98
    Offline

    abler98 New Member

    Joined:
    Nov 15, 2014
    Posts:
    26
    Minecraft User:
    abler98
    How to Fix a crash when the event is canceled place a sign?

    PHP:
        public function onBlockPlace(BlockPlaceEvent $event) {
            
    $player $event->getPlayer();
            
    $level $player->getLevel();
           
            
    $block $event->getBlockAgainst();
            
    $pos = new Vector3($block->getX(), $block->getY(), $block->getZ());
           
            if (
    $this->findShop($pos)) {
                
    $event->setCancelled(true);
            }
        }
  2. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    Two things:
    1. Provide the error/crash log
    2. Provide the whole code, so we can search for issues
  3. abler98
    Offline

    abler98 New Member

    Joined:
    Nov 15, 2014
    Posts:
    26
    Minecraft User:
    abler98
    In the console, there are no mistakes, just flies out of the game. This is all the code

    PHP:
    <?php namespace Test;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\block\BlockPlaceEvent;

    class 
    Plugin extends PluginBase implements Listener
    {
        public function 
    onEnable()
        {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }

        public function 
    onBlockPlace(BlockPlaceEvent $event)
        {
            
    $event->setCancelled(true);
        }
    }
    Last edited: Jan 21, 2015
  4. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    Add the PHPDoc comment to the function... It may works
  5. abler98
    Offline

    abler98 New Member

    Joined:
    Nov 15, 2014
    Posts:
    26
    Minecraft User:
    abler98
    Can be an example?
  6. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    Like:
    PHP:
    /** 
       * @param [event name]
       */
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No this is not relevant.
  8. abler98
    Offline

    abler98 New Member

    Joined:
    Nov 15, 2014
    Posts:
    26
    Minecraft User:
    abler98
    I and made
    PHP:
    /**
    * @param BlockPlaceEvent $event
    *
    * @priority HIGH
    */

    public function onBlockPlace(BlockPlaceEvent $event) {
        
    $player $event->getPlayer();
        
    $level $player->getLevel();

        
    $block $event->getBlockAgainst();
        
    $pos = new Vector3($block->getX(), $block->getY(), $block->getZ());

        if (
    $this->findShop($pos)) {
            
    $event->setCancelled(true);
        }
    }
  9. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    Maybe is the 'Find Shop' function that has issues?
  10. abler98
    Offline

    abler98 New Member

    Joined:
    Nov 15, 2014
    Posts:
    26
    Minecraft User:
    abler98
    No. Without this condition is also takes off.
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    This alone also makes your client crash?
  12. abler98
    Offline

    abler98 New Member

    Joined:
    Nov 15, 2014
    Posts:
    26
    Minecraft User:
    abler98
    Yes, and is not only on my device, and at all
  13. abler98
    Offline

    abler98 New Member

    Joined:
    Nov 15, 2014
    Posts:
    26
    Minecraft User:
    abler98
    Yes, and is not only on my device, and at all

Share This Page

Advertisement