Tidy things up a bit

This commit is contained in:
Nathan Curran 2020-10-16 17:51:21 +11:00
parent 3bd72dacda
commit 5a96204f1b
No known key found for this signature in database
GPG Key ID: B3A964B30C2E56B8

View File

@ -35,10 +35,12 @@ public class DiscordToMinecraftListener extends ListenerAdapter
message += " " + tag;
}
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);
builder.append(" ").append(ChatColor.stripColor(msg.getContentDisplay()));
message += " " + ChatColor.stripColor(msg.getContentDisplay()); // for logging
}
if (!msg.getAttachments().isEmpty())
{
for (Message.Attachment attachment : msg.getAttachments())
@ -48,9 +50,10 @@ public class DiscordToMinecraftListener extends ListenerAdapter
continue;
}
builder.append(" ");
TextComponent text = new TextComponent(net.md_5.bungee.api.ChatColor.YELLOW + "[Media]");
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())
@ -62,28 +65,6 @@ public class DiscordToMinecraftListener extends ListenerAdapter
}
FLog.info(message);
}
else
{
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]");
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());
}
}
}
}
}
}