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

onBlockBreakEvent

Comments in 'Plugin Development' started by iDirtPlayzMC, Dec 16, 2015.

  1. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    Can you guys tel me the code to setcancelled(true); on block break event?
    so basicly only op can ( $player->isOp ) :p
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    PHP:
    public function onBreak(\pocketmine\event\block\BlockBreakEvent $event){
    if(!
    $event->getPlayer()->isOp()){
    $event->setCancelled(true);
    return;
    }
    }
  3. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    That would make op un breakable ? I wanted player to not break any thing on my server so I use if(!$event->getPlayer()){$event->setCancelled(true);} would that works?
  4. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    PHP:
    public function onBreak(BlockBreakEvent $break){
            
    $player $break->getPlayer();
            if(!
    $break->getPlayer()->isOp()){
                
    $player->sendTIP("§l§7[§4!§7] §cYou are OP");
                
    $event->setCancelled(true);
            return;
            }
        }
    ?
  5. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    this wont work -3-
    PHP:
    public function onBreak(BlockBreakEvent $break){
             
    $player $break->getPlayer();
            if(!
    $player->isOp()){
                
    $player->sendTIP("§l§7[§4!§7] §cYou are OP");
                
    $event->setCancelled(true);
            return;
            }
        }
  6. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    PHP:
    public function onBreak(BlockBreakEvent $break){
             
    $player $break->getPlayer();
            if(!
    $player->isOp()){
                
    $player->sendTIP("§l§7[§4!§7] §cYou are OP");
                
    $break->setCancelled(true);
            return;
            }
        }
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    $player->sendTIP("§l§7[§4!§7] §cYou are not OP");
    because '!' means not!
    e.g:
    PHP:
    if(!true){ // If not true
    if(!false// If not false
    PEMapModder and iDirtPlayzMC like this.
  8. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    wow new things! thanks !!!
  9. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    YAAAAAAAAAAAAAAAAAAAAAAAAAY WORKS!!!! for da first time!!!! thanks babe! x3
  10. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Why should you return;?
  11. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    because i end and i was just playing because i'm bored lol.
  12. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You don't need to return anything. Also, the function ends at $event->setCancelled();
  13. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    what does returns do
  14. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    ik
  15. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    to ends the statements?
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    iDirtPlayzMC likes this.
  17. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr

Share This Page

Advertisement