FS-143 Resolution (#42)

* Bump to patch version.

* Fixes FS-143

Various changes to make it work better with logging and things like that.
This commit is contained in:
Ryan 2021-04-05 22:11:12 +01:00 committed by GitHub
parent dca5e30291
commit 27f5f18962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 9 deletions

View File

@ -5,7 +5,7 @@
<groupId>me.totalfreedom</groupId>
<artifactId>TotalFreedomMod</artifactId>
<version>2021.02</version>
<version>2021.02-Patch.01-RC01</version>
<packaging>jar</packaging>
<properties>

View File

@ -23,6 +23,7 @@ import org.bukkit.entity.Player;
public class DiscordToAdminChatListener extends ListenerAdapter
{
DiscordToMinecraftListener dtml = new DiscordToMinecraftListener();
public static net.md_5.bungee.api.ChatColor getColor(Displayable display)
@ -37,17 +38,29 @@ public class DiscordToAdminChatListener extends ListenerAdapter
{
Member member = event.getMember();
String tag = dtml.getDisplay(member);
StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
Message msg = event.getMessage();
String mediamessage = ChatColor.YELLOW + " [Media]";
message.append(msg.getContentDisplay());
StringBuilder logmessage = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
String lm = ChatColor.DARK_RED + member.getEffectiveName() + " "
+ ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY
+ ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay());
logmessage.append(lm);
ComponentBuilder builder = new ComponentBuilder(msg.toString());
if (!msg.getAttachments().isEmpty())
{
FLog.info(message.toString());
logmessage.append(mediamessage); // Actually for logging...
}
FLog.info(logmessage.toString());
Bukkit.getOnlinePlayers().stream().filter(player -> TotalFreedomMod.getPlugin().al.isAdmin(player)).forEach(player ->
{
StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
ComponentBuilder builder = new ComponentBuilder(message.toString());
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(player);
String format = admin.getAcFormat();
if (!Strings.isNullOrEmpty(format))
@ -59,6 +72,7 @@ public class DiscordToAdminChatListener extends ListenerAdapter
.replace("%rankcolor%", color.toString())
.replace("%msg%", FUtil.colorize(msg.getContentDisplay()));
builder.append(FUtil.colorize(m));
}
else
{
@ -72,14 +86,13 @@ public class DiscordToAdminChatListener extends ListenerAdapter
{
for (Message.Attachment attachment : msg.getAttachments())
{
TextComponent text = new TextComponent(ChatColor.YELLOW + "[Media]");
TextComponent text = new TextComponent(mediamessage);
text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl()));
builder.append(text);
message.append("[Media]"); // for logging
}
}
player.spigot().sendMessage(builder.create());
});
}
}