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

Cancel break block

Discussion in 'Development' started by MasApip, May 11, 2020.

  1. MasApip

    MasApip Spider

    Messages:
    8
    GitHub:
    MasApip
    So, i want to ban block is Polished Andesite in my mining world.

    PHP:
    public function onBreak(BlockBreakEvent $event)
    {
       
    $block $event->getBlock();
       
    $player $event->getPlayer()
       if(
    $player->getLevel()->getName() === "Mining"){
       if(
    $block->getId() == Block::STONE_BRICK_STAIRS || $block->getId() == Block::STAINED_GLASS || $block->getId() == Block::get(16) || $block->getId() == Block::STONE_BRICKS || $block->getId() == Block::STONE_SLAB || $block->getId() == Block::get(3514) || $block->getId() == Block::SEA_LANTERN){
                   
    $event->setCancelled();
                   
    $player->sendMessage("§cYou cant break the block here!");
           }
       }
    }
    but i get internal server error when i break block in the mining world
     
    Last edited: May 11, 2020
  2. ppaalo

    ppaalo Spider

    Messages:
    7
    GitHub:
    ppaalo
    Eu tenho um plugin que criei AntiXRay I have a plugin that I made AntiXRay I think that if I change some values I can prevent the breaking of that block, or even make it drop Stone like mine
     
  3. I Am ScRay

    I Am ScRay Silverfish

    Messages:
    16
    GitHub:
    iamscray
    Code:
    Block::get(35, 14)
    returns Block object, but not the expected ID. You should compare the ID with ID 35 directly but this will restrict any Wool block. If you want to restrict specifically Red or Green Wool, you need to compare the damage value too.
     
  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.