Advertisement
Rob5Underscores

Untitled

Jan 21st, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. @Listener
  2. public void onBlockBreak(ChangeBlockEvent.Break event) {
  3. BlockSnapshot block = event.getTransactions().get(0).getOriginal();
  4. if(block == null){
  5. return;
  6. }
  7. boolean isBlock = false;
  8. String aBlockName = null;
  9. for(String blockName: blocksList){
  10. if(blockName.equalsIgnoreCase(block.getState().getType().getName())){
  11. isBlock=true;
  12. aBlockName = blockName;
  13. }
  14. }
  15. if(!isBlock) {
  16. return;
  17. }
  18. if(block.getLocation().isPresent()){
  19. event.setCancelled(true);
  20. block.getLocation().get().removeBlock(Cause.source(Sponge.getPluginManager().fromInstance(spongeFixer).get()).build());
  21. if(event.getCause().containsType(Player.class)) {
  22. if(event.getCause().first(Player.class).isPresent()) {
  23. Player player = event.getCause().first(Player.class).get();
  24. if(player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) {
  25. if(player.getItemInHand(HandTypes.MAIN_HAND).get().getItem().getName().matches("^excompressum:compressed_hammer_\\s*(diamond|gold|iron|stone|wood)?$")) {
  26. spawnBlocks(block.getLocation().get(), event.getCause(), aBlockName);
  27. }
  28. }
  29. }
  30. }
  31. } else {
  32. return;
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement