Block protection?

Discussion in 'Plugin Development' started by Tordur, Jul 23, 2011.

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

    Tordur

    Hey, I have a problem. How do i protect areas inside a plugin (Like the plugin is doing it) ?
     
  2. Offline

    ParkourGrip

    in your block listener create a BlockBreakEvent

    after that in it use something like this

    Code:
    
    
    
    [B]public[/B] [B]void[/B]
    
    onBlockBreak (BlockBreakEvent event) {
    block
    
    = event.getBlock();
    player = event.getPlayer();
    
    
    if (block.getX <= [add your x here] && block.getX >= [add your x here]  &&  block.getY <= [add your y here] && block.getY >= [add your y here] && block.getZ <= [add your z here] && block.getZ >= [add your z here]) {
    
    
    if (!player.isOp()){
    player.sendRawMessage(ChatColor.[I]RED[/I] + "This land is protected."); 
    event.setCancelled([B]true[/B]);
    
    }
    }
    
    
    }
    
    public void

    onBlockBreak (BlockBreakEvent event) {
    block= event.getBlock();
    player = event.getPlayer();

    if (block.getX <= [add your x here] && block.getX >= [add your x here] && block.getY <= [add your y here] && block.getY >= [add your y here] && block.getZ <= [add your z here] && block.getZ >= [add your z here]) {
    if (!player.isOp()){
    player.sendRawMessage(ChatColor.RED + "This land is protected.");
    event.setCancelled(true);
    }
    }
    }

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
Thread Status:
Not open for further replies.

Share This Page