mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Add item linking/hovers
This commit is contained in:
1 parent
d1b35bd95d
commit
66aa6d6449
3 files changed
+145
No files matched your search
@@ -7,6 +7,8 @@ import net.draycia.simplechat.SimpleChat;
|
||||
import net.draycia.simplechat.channels.ChatChannel;
|
||||
import net.draycia.simplechat.events.ChannelChatEvent;
|
||||
import net.draycia.simplechat.util.DiscordWebhook;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
@@ -25,6 +27,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SimpleChatChannel extends ChatChannel {
|
||||
|
||||
@@ -47,6 +50,8 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
|
||||
private SimpleChat simpleChat;
|
||||
|
||||
private Pattern itemPattern = Pattern.compile("[item]");
|
||||
|
||||
private SimpleChatChannel() { }
|
||||
|
||||
SimpleChatChannel(TextColor color, long id, Map<String, String> formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, boolean shouldBungee, boolean filterEnabled, SimpleChat simpleChat) {
|
||||
@@ -194,6 +199,12 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
// Send message to players who can see it
|
||||
Component formattedMessage = MiniMessageParser.parseFormat(messageFormat);
|
||||
|
||||
if (formattedMessage instanceof TextComponent && player.isOnline()) {
|
||||
((TextComponent) formattedMessage).replace(itemPattern, (input) -> {
|
||||
return simpleChat.getItemStackUtils().createComponent(player.getPlayer()).toBuilder();
|
||||
});
|
||||
}
|
||||
|
||||
for (Player onlinePlayer : getAudience(player)) {
|
||||
simpleChat.getPlatform().player(onlinePlayer).sendMessage(formattedMessage);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user