This site works best with JavaScript enabled. Please enable JavaScript to get the best experience from this site.
@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
To post a comment, please login or register a new account.