Skip to content

Commit

Permalink
Add chat functionality to ItemInfo command class
Browse files Browse the repository at this point in the history
The code changes include additions which allow the ItemInfo command class to send chat messages to the sender. It generates a text component and attaches it to the sender using spigot's sendMessage method, enhancing user interaction.
  • Loading branch information
Feli499 committed Jan 1, 2024
1 parent df8ae51 commit e6c9d62
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/com/Acrobot/ChestShop/Commands/ItemInfo.java
Expand Up @@ -15,6 +15,10 @@
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Events.ItemInfoEvent;
import com.Acrobot.ChestShop.Utils.ComponentUtils;

import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;

/**
* @author Acrobot
Expand Down Expand Up @@ -49,6 +53,11 @@ public static void showItemInfo(CommandSender sender, ItemStack item) {
return;
}

TextComponent tc = new TextComponent(" ");
BaseComponent tcName = ComponentUtils.getLocalizedItemName(item);
tc.addExtra(tcName);
sender.spigot().sendMessage(tc);

ItemInfoEvent event = new ItemInfoEvent(sender, item);
ChestShop.callEvent(event);
}
Expand Down

0 comments on commit e6c9d62

Please sign in to comment.