Итак, я использую API Bukkit. В основном, я ищу, чтобы PlayerInteractEvent был вызван, и после этого я делаю кучу вещей после этого. Однако, когда я должен получить уведомление, что я на самом деле пнул блок, я не получаю никакого сообщения, хотя он компилируется без ошибок в моем коде. У меня также нет исключений из консоли. Вот мой код:Почему PlayerInteractEvent не работает для API Bukkit?
@EventHandler(priority=EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event, final Player who, final Action action,
final ItemStack item, final Block clickedBlock, final BlockFace clickedFace) {
if (who != null) {
if (clickedBlock != null) {
if ((action == Action.LEFT_CLICK_BLOCK) && (clickedBlock.getType() == Material.ANVIL)) {
if (item == null) {
who.sendMessage(ChatColor.YELLOW + "To repair an item, hold it in your inventory and " +
ChatColor.UNDERLINE + "RIGHT CLICK" + ChatColor.RESET + "" + ChatColor.YELLOW +
" the anvil with the item.");
event.setCancelled(true);
}
else {
Material type = item.getType();
short durability = item.getDurability();
short maximum = type.getMaxDurability();
if (maximum == 0) {
who.sendMessage(ChatColor.RED + "You can " + ChatColor.UNDERLINE + "NOT" +
ChatColor.RESET + "" + ChatColor.RED + " repair that item.");
}
else {
short add = (short) Math.round(maximum * 0.03);
int result = (maximum - durability)/add;
int gems = getAmount(who, 388);
if (gems < result) {
who.sendMessage(ChatColor.RED + "You do " + ChatColor.UNDERLINE + "NOT" +
ChatColor.RESET + "" + ChatColor.RED + " have enough Gems to repair "
+ "that item.");
who.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "Gems Needed: " + result);
}
else {
who.sendMessage(ChatColor.YELLOW + "It will cost " + ChatColor.WHITE +
result + "g " + ChatColor.GREEN + "to repair this item.");
who.sendMessage(ChatColor.YELLOW + "Continue repairing? " + ChatColor.GREEN +
"" + ChatColor.BOLD + "Y" + ChatColor.RESET + "" + ChatColor.WHITE +
"/" + ChatColor.RESET + "" + ChatColor.RED + "" + ChatColor.BOLD +
"N");
map.put(who, item);
}
}
}
}
}
}
}
Я сделал это, поэтому я не уверен, что еще может быть проблемой. – user2646941