MrLucasX

CmdBlock Listener

Jan 21st, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. import org.bukkit.Material;
  2. import org.bukkit.event.EventHandler;
  3. import org.bukkit.event.Listener;
  4. import org.bukkit.event.block.Action;
  5. import org.bukkit.event.block.BlockBreakEvent;
  6. import org.bukkit.event.player.PlayerInteractEvent;
  7.  
  8. public class BlockClickListener implements Listener{
  9.    
  10.     @EventHandler
  11.     public void onClickBlock(PlayerInteractEvent e){
  12.         if(e.isCancelled())return;
  13.         if(e.getClickedBlock() == null)return;
  14.         if(e.getClickedBlock().getType() == Material.AIR)return;
  15.         if(e.getAction() != Action.RIGHT_CLICK_BLOCK)return;
  16.        
  17.         Main.cbm.clickedBlock(e.getPlayer(), e.getClickedBlock().getLocation());
  18.     }
  19.    
  20.     @EventHandler
  21.     public void onBreakBlock(BlockBreakEvent e){
  22.        
  23.         Main.cbm.removeCmdBlock(e.getBlock().getLocation());
  24.        
  25.     }
  26.  
  27. }
Add Comment
Please, Sign In to add comment