R1DD1
Активный участник
- Баллы
- 61
- Имя в Minecraft
- R1DD1
Код:
public class Upgrade implements Listener {
@EventHandler
public void interact(PlayerInteractEvent e ) {
Action a = e.getAction();
Player p = e.getPlayer();
Block b = e.getClickedBlock();
if(b.getType().equals(Material.ANVIL)) return; {
if (a == Action.RIGHT_CLICK_BLOCK) return;
if (p.getItemInHand().getType() == Material.AIR || p.getItemInHand().getType() != Material.AIR );
e.setCancelled(true);
}
if( a == Action.LEFT_CLICK_BLOCK) return;
if(b.getType().equals(Material.ANVIL)) {
return;
if(e.getPlayer().getItemInHand().getType() == Material.IRON_SWORD ) return; // выводит ошибку - Unreachable code
ItemStack Enchant = new ItemStack (Material.IRON_SWORD, 1);
ItemMeta EnchantMeta = Enchant.getItemMeta();
EnchantMeta.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
Enchant.setItemMeta(EnchantMeta);
p.sendMessage("success");
p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1, 4);
}
}
}