Advertisement
riking

Untitled

Jul 8th, 2013
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1.    
  2.     @EventHandler
  3.     public void onEntityBlockChangeEvent(EntityBlockChangeEvent event) {
  4.         testBlockBreak(event, event.getBlock());
  5.     }
  6.  
  7.     @EventHandler
  8.     public void onBlockBreak(BlockBreakEvent event) {
  9.         testBlockBreak(event, event.getBlock());
  10.     }
  11.  
  12.     private void testBlockBreak(Cancellable event, Block block) {
  13.         final BlockFace[] directions = new BlockFace[]
  14.         {
  15.                 BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST
  16.         };
  17.        
  18.         for (BlockFace blockFace : directions)
  19.         {
  20.            
  21.             Util.info("Test 2");
  22.            
  23.             Block signBlock = block.getRelative(blockFace);
  24.             if (signBlock.getType() == Material.WALL_SIGN)
  25.             {
  26.                 Util.info("Found wall sign in " + blockFace + " direction");
  27.                 if (new org.bukkit.material.Sign(Material.WALL_SIGN, signBlock.getData()).getFacing() == blockFace) {
  28.                     Util.info("Sign is attached to broken block");
  29.                     Sign sign = (Sign) signBlock.getState();
  30.                     if (sign.getLine(0).equalsIgnoreCase("HELLO") || sign.getLine(0).equalsIgnoreCase("§b[ReadMe]") || sign.getLine(0).equalsIgnoreCase("§6[Help]") || sign.getLine(0).equalsIgnoreCase("§a[Info]"))
  31.                     {
  32.                         Util.info("Sign has trigger text");
  33.                         event.setCancelled(true);
  34.                         return;
  35.     `               }
  36.                 }
  37.             }
  38.         }
  39.         Block signBlock = block.getRelative(BlockFace.UP);
  40.         if (signBlock.getType() == Material.SIGN_POST) {
  41.             Util.info("Found sign post above");
  42.  
  43.             if (sign.getLine(0).equalsIgnoreCase("HELLO") || sign.getLine(0).equalsIgnoreCase("§b[ReadMe]") || sign.getLine(0).equalsIgnoreCase("§6[Help]") || sign.getLine(0).equalsIgnoreCase("§a[Info]"))
  44.             {
  45.                 Util.info("Sign has trigger text");
  46.                 event.setCancelled(true);
  47.                 return;
  48.             }
  49.         }
  50.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement