diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java index 2ad627b0..889fc10e 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java @@ -34,55 +34,36 @@ public class DiscordToMinecraftListener extends ListenerAdapter { message += " " + tag; } - message += " " + ChatColor.RED + ChatColor.stripColor(member.getEffectiveName()) + ChatColor.DARK_GRAY + ": " + ChatColor.RESET; + message += " " + ChatColor.RED + ChatColor.stripColor(member.getEffectiveName()) + ChatColor.DARK_GRAY + ":" + ChatColor.RESET; + ComponentBuilder builder = new ComponentBuilder(message); if (!msg.getContentDisplay().isEmpty()) { - message += ChatColor.stripColor(msg.getContentDisplay()); - ComponentBuilder builder = new ComponentBuilder(message); - if (!msg.getAttachments().isEmpty()) - { - for (Message.Attachment attachment : msg.getAttachments()) - { - if (attachment.getUrl() == null) - { - continue; - } - builder.append(" "); - TextComponent text = new TextComponent(net.md_5.bungee.api.ChatColor.YELLOW + "[Media]"); - text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl())); - builder.append(text).append(" "); - } - } - for (Player player : Bukkit.getOnlinePlayers()) - { - if (TotalFreedomMod.getPlugin().pl.getData(player).doesDisplayDiscord()) - { - player.spigot().sendMessage(builder.create()); - } - } - FLog.info(message); + builder.append(" ").append(ChatColor.stripColor(msg.getContentDisplay())); + message += " " + ChatColor.stripColor(msg.getContentDisplay()); // for logging } - else + if (!msg.getAttachments().isEmpty()) { - ComponentBuilder builder = new ComponentBuilder(message); 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(" "); - } - for (Player player : Bukkit.getOnlinePlayers()) - { - if (TotalFreedomMod.getPlugin().pl.getData(player).doesDisplayDiscord()) - { - player.spigot().sendMessage(builder.create()); - } + builder.append(text); + message += " [Media]"; // for logging } } + for (Player player : Bukkit.getOnlinePlayers()) + { + if (TotalFreedomMod.getPlugin().pl.getData(player).doesDisplayDiscord()) + { + player.spigot().sendMessage(builder.create()); + } + } + FLog.info(message); } } }