disable block break

Discussion in 'Plugin Development' started by nitrousspark, Jun 1, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    nitrousspark

    im making a plugin and i need to disable block breaking. how would i do that
     
  2. Offline

    hawkfalcon

    cancel the event.
     
  3. Offline

    javoris767

    Code:java
    1. @EventHandler(priority = EventPriority.HIGHEST)
    2. public void onBlockBreak(BlockBreakEvent event) {
    3. event.setCancelled(true);
    4. }
    5. }
     
    McLuke500 likes this.
  4. Offline

    chaseoes

    You're new to this, aren't you?
     
  5. Offline

    nitrousspark

    how would i add an event to an event. so like onPlayerDeath disable block breaking from that on
     
  6. Offline

    whatapigdoes

    Code:
    public break = true;
    public boolean onPlayerDeath(PlayerDeathEvent event){
    public break = false;
    }
    public boolean onBlockPlace(BlockPlayeEvent event){
    if (break == false){
    event.isCancelled(true);
    }
     
  7. Offline

    noraver

    you can always do :cool:

    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerDeath(PlayerDeathEvent e) {
    4. e.getPlayer().setGameMode(Adventure);
    5. }
    6. }
    7.  
     
    blackwolf12333 likes this.
  8. Offline

    justcool393

    The only problem with that is in Adventure mode, if you have the right tool (cobble needs pick, wood needs axe, etc.) you can break the blocks
     
  9. Offline

    noraver

    well if they die they wont have anything for the time being i dont think the idea is to make it perm so they can never do anything once they die :eek:
     
  10. Offline

    Chinwe

    Have a List that a player (name) is added to on death, and then cancel the BlockBreakEvent if the list contains event.getPlayer().getName() .
     
Thread Status:
Not open for further replies.

Share This Page