Better Source #1


  • New
  • Patch
Open
Assigned to _ForgeUser7013700
  • _ForgeUser7052759 created this issue Nov 8, 2012

        @EventHandler
        public void onTrample(PlayerInteractEvent event){
            if (event.isCancelled()) return;

            if (event.getAction() == Action.PHYSICAL){
                //event.setCancelled(true);
                Block block = event.getClickedBlock();
                if(block == null)
                    return;
                int blockType = block.getTypeId();

                if(blockType == Material.getMaterial(59).getId() | (blockType == Material.getMaterial(60).getId())){
                    event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
                    event.setCancelled(true);

                    block.setTypeId(blockType);
                    block.setData(block.getData());

                }
            }
        }

    I was wondering how to prevent the changing of blocks by trampling, and I came across this plugin along with the source code. I looked it over and you had repeated two if's when you could have just put in a simple 'or' operator, this is half the size and does the same thing =P.

    In case you're new to java (I am), the '|' key (the shift-backslash key above the enter key) is the or operator, very useful

  • _ForgeUser7052759 added the tags New Patch Nov 8, 2012

To post a comment, please login or register a new account.