mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Merge pull request #289 from Focusvity/pr/discord
Enable media tag to be included in messages
This commit is contained in:
commit
d4d1000c16
@ -29,35 +29,32 @@ public class DiscordToMinecraftListener extends ListenerAdapter
|
||||
Member member = event.getMember();
|
||||
String tag = getDisplay(member);
|
||||
String message = ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "]";
|
||||
Message msg = event.getMessage();
|
||||
if (tag != null)
|
||||
{
|
||||
message += " " + tag;
|
||||
}
|
||||
message += " " + ChatColor.RED + ChatColor.stripColor(member.getEffectiveName()) + ChatColor.DARK_GRAY + ": " + ChatColor.RESET;
|
||||
if (!event.getMessage().getContentDisplay().isEmpty())
|
||||
{
|
||||
message += ChatColor.stripColor(event.getMessage().getContentDisplay());
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (TotalFreedomMod.getPlugin().pl.getData(player).doesDisplayDiscord())
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
FLog.info(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message += " " + ChatColor.RED + ChatColor.stripColor(member.getEffectiveName()) + ChatColor.DARK_GRAY + ":" + ChatColor.RESET;
|
||||
ComponentBuilder builder = new ComponentBuilder(message);
|
||||
for (Message.Attachment attachment : event.getMessage().getAttachments())
|
||||
if (!msg.getContentDisplay().isEmpty())
|
||||
{
|
||||
builder.append(" ").append(ChatColor.stripColor(msg.getContentDisplay()));
|
||||
message += " " + ChatColor.stripColor(msg.getContentDisplay()); // for logging
|
||||
}
|
||||
if (!msg.getAttachments().isEmpty())
|
||||
{
|
||||
for (Message.Attachment attachment : msg.getAttachments())
|
||||
{
|
||||
if (attachment.getUrl() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
TextComponent text = new TextComponent(net.md_5.bungee.api.ChatColor.YELLOW + "[Media]");
|
||||
builder.append(" ");
|
||||
TextComponent text = new TextComponent(ChatColor.YELLOW + "[Media]");
|
||||
text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl()));
|
||||
builder.append(text).append(" ");
|
||||
builder.append(text);
|
||||
message += " [Media]"; // for logging
|
||||
}
|
||||
}
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
@ -66,7 +63,7 @@ public class DiscordToMinecraftListener extends ListenerAdapter
|
||||
player.spigot().sendMessage(builder.create());
|
||||
}
|
||||
}
|
||||
}
|
||||
FLog.info(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user