Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. public class PicaretaEvento implements Listener {
  2.  
  3. private static List<String> MUNDOS = Main.getPlugin().getConfig().getStringList("Blacklist.Mundos");
  4. private static int CAMADA = Main.getPlugin().getConfig().getInt("Config.Camada");
  5.  
  6. @EventHandler
  7. public static void aoQuebrar(PlayerInteractEvent e) {
  8. Player p = e.getPlayer();
  9. MPlayer mp = MPlayer.get(p);
  10. if (e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
  11. if (e.getPlayer().getGameMode().equals(GameMode.SURVIVAL)) {
  12. int dura = 25;
  13. if (p.getItemInHand() != null) {
  14. if (!p.getItemInHand().getType().equals(Material.AIR)) {
  15. if (p.getItemInHand().hasItemMeta()) {
  16. if (p.getItemInHand().getType().equals(Material.DIAMOND_PICKAXE)) {
  17. if (p.getItemInHand().getItemMeta().getLore().contains("§7Força bruta I§2§2§3§4§7§1§r")) {
  18. if (p.getItemInHand().getItemMeta().getLore().contains("§7Força bruta I§2§2§3§4§7§1§r")) {
  19. if (e.getClickedBlock() == null) {
  20. return;
  21. }
  22. for (String mundos : MUNDOS) {
  23. if (p.getWorld().getName().equalsIgnoreCase(mundos)) {
  24. return;
  25. }
  26. }
  27. if (e.getClickedBlock().getType().equals(Material.AIR)) {
  28. return;
  29. }
  30. if (e.getClickedBlock().getType().equals(Material.BEDROCK)) {
  31. if (e.getClickedBlock().getLocation().getBlockY() <= CAMADA) {
  32. p.sendMessage(Main.getPlugin().getConfig().getString("Mensagens.CamadaInvalida").replace("&", "§").replace("{camada}", "" + e.getClickedBlock().getY()));
  33. return;
  34. }
  35. FactionUtil fu = new FactionUtil();
  36. if (p.getItemInHand().containsEnchantment(Enchantment.DURABILITY)) {
  37. int lvl = p.getItemInHand().getEnchantmentLevel(Enchantment.DURABILITY);
  38. if (lvl == 1) {
  39. dura = 23;
  40. }
  41. if (lvl == 2) {
  42. dura = 21;
  43. }
  44. if (lvl == 3) {
  45. dura = 19;
  46. }
  47. if (lvl == 4) {
  48. dura = 17;
  49. }
  50. if (lvl == 5){
  51. dura = 15;
  52. }
  53. }
  54. if (!fu.getFaction(e.getClickedBlock().getLocation()).isNone()) {
  55. if (!mp.isOverriding()) {
  56. if (fu.getFaction(e.getClickedBlock().getLocation()).equals(mp.getFaction())) {
  57. if (mp.getRole().equals(Rel.RECRUIT)) {
  58. p.sendMessage(Main.getPlugin().getConfig().getString("Mensagens.Recruta").replace("&", "§"));
  59. return;
  60. }
  61. e.getClickedBlock().breakNaturally();
  62. int du = p.getItemInHand().getDurability() + dura;
  63. if (du >= p.getItemInHand().getType().getMaxDurability()) {
  64. p.setItemInHand(new ItemStack(Material.AIR));
  65. p.playSound(p.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);
  66. return;
  67. }
  68. p.getItemInHand().setDurability((short)du);
  69. return;
  70. }
  71. return;
  72. }
  73. }
  74. e.getClickedBlock().breakNaturally();
  75. int du = p.getItemInHand().getDurability() + dura;
  76. if (du >= p.getItemInHand().getType().getMaxDurability()) {
  77. p.setItemInHand(new ItemStack(Material.AIR));
  78. p.playSound(p.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);
  79. return;
  80. }
  81. p.getItemInHand().setDurability((short)du);
  82. }
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement