Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ((e.getAction() == InventoryAction.SWAP_WITH_CURSOR)) {
- if (e.getCursor().getType().equals(Material.ENCHANTED_BOOK)) {
- if (e.getCursor().getItemMeta().hasEnchant(Enchantment.PROTECTION_ENVIRONMENTAL)) {
- if (e.getCurrentItem().getType() == Material.DIAMOND_CHESTPLATE
- || e.getCurrentItem().getType() == Material.DIAMOND_BOOTS
- || e.getCurrentItem().getType() == Material.DIAMOND_HELMET
- || e.getCurrentItem().getType() == Material.DIAMOND_LEGGINGS) {
- e.setCancelled(true);
- if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) <= e
- .getCurrentItem().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL)) {
- p.sendMessage("§cEste item já possui o encantamento.");
- e.setCancelled(true);
- return;
- }
- if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 5) {
- Random rnd = new Random();
- int num = rnd.nextInt(100);
- if (num <= 85) {
- e.setCancelled(true);
- e.getCurrentItem().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
- e.getCursor().getItemMeta()
- .getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL));
- ItemMeta encanter = e.getCurrentItem().getItemMeta();
- e.getCurrentItem().setItemMeta(encanter);
- p.playSound(p.getLocation(), Sound.ANVIL_USE, 1, 1);
- p.sendMessage("§aEncantamento aplicado com sucesso!");
- ItemStack nada = new ItemStack(Material.AIR);
- p.setItemOnCursor(nada);
- } else {
- ItemStack nada = new ItemStack(Material.AIR);
- p.setItemOnCursor(nada);
- p.sendMessage("§cEncantamento não aplicado!");
- p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1, 1);
- e.setCancelled(true);
- }
- if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 6) {
- if (num <= 62) {
- e.setCancelled(true);
- e.getCurrentItem().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
- e.getCursor().getItemMeta()
- .getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL));
- ItemMeta encanter = e.getCurrentItem().getItemMeta();
- e.getCurrentItem().setItemMeta(encanter);
- p.playSound(p.getLocation(), Sound.ANVIL_USE, 1, 1);
- p.sendMessage("§aEncantamento aplicado com sucesso!");
- ItemStack nada = new ItemStack(Material.AIR);
- p.setItemOnCursor(nada);
- } else {
- ItemStack nada = new ItemStack(Material.AIR);
- p.setItemOnCursor(nada);
- p.sendMessage("§cEncantamento não aplicado!");
- p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1, 1);
- e.setCancelled(true);
- }
- }
- if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 7) {
- if (num <= 45) {
- e.setCancelled(true);
- e.getCurrentItem().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
- e.getCursor().getItemMeta()
- .getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL));
- ItemMeta encanter = e.getCurrentItem().getItemMeta();
- e.getCurrentItem().setItemMeta(encanter);
- p.playSound(p.getLocation(), Sound.ANVIL_USE, 1, 1);
- p.sendMessage("§aEncantamento aplicado com sucesso!");
- ItemStack nada = new ItemStack(Material.AIR);
- p.setItemOnCursor(nada);
- } else {
- ItemStack nada = new ItemStack(Material.AIR);
- p.setItemOnCursor(nada);
- p.sendMessage("§cEncantamento não aplicado!");
- p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1, 1);
- e.setCancelled(true);
- }
- }
- if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 8) {
- if (num <= 33) {
- e.setCancelled(true);
- e.getCurrentItem().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
- e.getCursor().getItemMeta()
- .getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL));
- ItemMeta encanter = e.getCurrentItem().getItemMeta();
- e.getCurrentItem().setItemMeta(encanter);
- p.playSound(p.getLocation(), Sound.ANVIL_USE, 1, 1);
- p.sendMessage("§aEncantamento aplicado com sucesso!");
- ItemStack nada = new ItemStack(Material.AIR);
- p.setItemOnCursor(nada);
- } else {
- ItemStack nada = new ItemStack(Material.AIR);
- p.setItemOnCursor(nada);
- p.sendMessage("§cEncantamento não aplicado!");
- p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1, 1);
- e.setCancelled(true);
- }
- }
- if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 9) {
- if (num <= 19) {
- e.setCancelled(true);
- e.getCurrentItem().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
- e.getCursor().getItemMeta()
- .getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL));
- ItemMeta encanter = e.getCurrentItem().getItemMeta();
- e.getCurrentItem().setItemMeta(encanter);
- p.playSound(p.getLocation(), Sound.ANVIL_USE, 1, 1);
- p.sendMessage("§aEncantamento aplicado com sucesso!");
- ItemStack nada = new ItemStack(Material.AIR);
- p.setItemOnCursor(nada);
- } else {
- ItemStack nada = new ItemStack(Material.AIR);
- p.setItemOnCursor(nada);
- p.sendMessage("§cEncantamento não aplicado!");
- p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1, 1);
- e.setCancelled(true);
- }
- }
- if (e.getCursor().getItemMeta().getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 10) {
- if (num <= 8) {
- e.setCancelled(true);
- e.getCurrentItem().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
- e.getCursor().getItemMeta()
- .getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL));
- ItemMeta encanter = e.getCurrentItem().getItemMeta();
- e.getCurrentItem().setItemMeta(encanter);
- p.playSound(p.getLocation(), Sound.ANVIL_USE, 1, 1);
- p.sendMessage("§aEncantamento aplicado com sucesso!");
- ItemStack nada = new ItemStack(Material.AIR);
- p.setItemOnCursor(nada);
- } else {
- ItemStack nada = new ItemStack(Material.AIR);
- p.setItemOnCursor(nada);
- p.sendMessage("§cEncantamento não aplicado!");
- p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1, 1);
- e.setCancelled(true);
- }
- }
- } else {
- p.sendMessage("§cVocê não pode adicionar este encantamento neste item.");
- e.setCancelled(true);
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement