SpaceEmotion

Untitled

Jan 21st, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. @EventHandler
  2.     public void c( CraftItemEvent event ) {
  3.         if (event.isCancelled()) return;
  4.  
  5.         Recipe recipe = event.getRecipe();
  6.         ItemStack result = recipe.getResult();
  7.  
  8.         CustomRecipe cr = getRecipe( result.getTypeId(), result.getData().getData() );
  9.  
  10.         if (cr != null) {
  11.             event.setCurrentItem( cr.getItem() );
  12.  
  13.             String perm = cr.getPermission();
  14.             HumanEntity entity = event.getWhoClicked();
  15.  
  16.             if (!perm.isEmpty() && !entity.isOp() && !entity.hasPermission( perm )) {
  17.                 event.setCancelled( true );
  18.  
  19.                 String msg = cr.getNoPermissionMessage();
  20.                 if (msg.isEmpty()) msg = getConfig().getString( "permissions.message" );
  21.  
  22.                 if (msg != null && !msg.isEmpty() && entity instanceof Player) ((Player) entity).sendMessage( TextUtil.parseColors( msg ) );
  23.             }
  24.         }
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment