From 38f8e47b9208dbf0ad74b5ca5371658ccf153359 Mon Sep 17 00:00:00 2001 From: Elikill58 Date: Mon, 20 May 2024 22:57:59 +0200 Subject: [PATCH] Fix for empty items --- .../chatitem/chatmanager/v2/ChatListener.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/dadus33/chatitem/chatmanager/v2/ChatListener.java b/src/main/java/me/dadus33/chatitem/chatmanager/v2/ChatListener.java index 8621643..5240dfc 100644 --- a/src/main/java/me/dadus33/chatitem/chatmanager/v2/ChatListener.java +++ b/src/main/java/me/dadus33/chatitem/chatmanager/v2/ChatListener.java @@ -9,6 +9,7 @@ import java.util.logging.Logger; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -326,11 +327,15 @@ private static BaseComponent[] createComponent(Player to, String text, ChatColor ComponentBuilder littleBuilder = new ComponentBuilder(text); if(color != null && color != ChatColor.RESET) // don't add reset thing littleBuilder.color(color); - if (action.isItem()) - littleBuilder.event(Utils.createItemHover(action.getItem(), to)); - else { + if (action.isItem()) { + if(action.getItem().getType().equals(Material.AIR)) + littleBuilder.event(Utils.createTextHover(String.join("\n", ChatItem.getInstance().getStorage().tooltipHand))); + else + littleBuilder.event(Utils.createItemHover(action.getItem(), to)); + } else { littleBuilder.event(Utils.createTextHover(Messages.getMessage(action.getSlot().name().toLowerCase() + ".hover"))); - littleBuilder.event(Utils.createRunCommand(action.getCommand())); + if(action.getCommand() != "") + littleBuilder.event(Utils.createRunCommand(action.getCommand())); } return littleBuilder.create(); }