Other bug fixes

Credit to Fleek for some of the code here.

Bugs that were fixed:
* [Media] showing up with an extra space at the beginning of blank messages with attachments
* Admin chat using incorrect colors for its ranks in messages from Discord to Minecraft
* Admin notes not sending to admins, only admin impostors
This commit is contained in:
Video 2021-04-07 19:40:19 -06:00
parent a7529b41fb
commit df21bdfa7e
2 changed files with 17 additions and 13 deletions

View File

@ -246,7 +246,7 @@ public class LoginProcess extends FreedomService
FLog.info(noteMessage); FLog.info(noteMessage);
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (plugin.al.isAdminImpostor(p)) if (plugin.al.isAdmin(p))
{ {
notice.send(p); notice.send(p);
} }

View File

@ -39,7 +39,7 @@ public class DiscordToAdminChatListener extends ListenerAdapter
Member member = event.getMember(); Member member = event.getMember();
String tag = dtml.getDisplay(member); String tag = dtml.getDisplay(member);
Message msg = event.getMessage(); Message msg = event.getMessage();
String mediamessage = ChatColor.YELLOW + " [Media]"; String mediamessage = ChatColor.YELLOW + "[Media]";
StringBuilder logmessage = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET); StringBuilder logmessage = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
String lm = ChatColor.DARK_RED + member.getEffectiveName() + " " String lm = ChatColor.DARK_RED + member.getEffectiveName() + " "
@ -65,10 +65,10 @@ public class DiscordToAdminChatListener extends ListenerAdapter
String format = admin.getAcFormat(); String format = admin.getAcFormat();
if (!Strings.isNullOrEmpty(format)) if (!Strings.isNullOrEmpty(format))
{ {
Displayable display = TotalFreedomMod.getPlugin().rm.getDisplay(player); Displayable display = getDisplay(member);
net.md_5.bungee.api.ChatColor color = getColor(display); net.md_5.bungee.api.ChatColor color = getColor(display);
String m = format.replace("%name%", member.getEffectiveName()) String m = format.replace("%name%", member.getEffectiveName())
.replace("%rank%", getDisplay(member)) .replace("%rank%", display.getAbbr())
.replace("%rankcolor%", color.toString()) .replace("%rankcolor%", color.toString())
.replace("%msg%", FUtil.colorize(msg.getContentDisplay())); .replace("%msg%", FUtil.colorize(msg.getContentDisplay()));
builder.append(FUtil.colorize(m)); builder.append(FUtil.colorize(m));
@ -86,8 +86,12 @@ public class DiscordToAdminChatListener extends ListenerAdapter
{ {
for (Message.Attachment attachment : msg.getAttachments()) for (Message.Attachment attachment : msg.getAttachments())
{ {
TextComponent text = new TextComponent(mediamessage); TextComponent text = new TextComponent((msg.getContentDisplay().isEmpty() ? "" : " ") + mediamessage);
text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl())); text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl()));
if (!msg.getContentDisplay().isEmpty())
{
builder.append(" ");
}
builder.append(text); builder.append(text);
} }
} }
@ -98,43 +102,43 @@ public class DiscordToAdminChatListener extends ListenerAdapter
} }
// Needed to display tags in custom AC messages // Needed to display tags in custom AC messages
public String getDisplay(Member member) public Displayable getDisplay(Member member)
{ {
Guild server = Discord.bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString()); Guild server = Discord.bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString());
// Server Owner // Server Owner
if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString()))) if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString())))
{ {
return Title.OWNER.getAbbr(); return Title.OWNER;
} }
// Developers // Developers
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString()))) else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString())))
{ {
return Title.DEVELOPER.getAbbr(); return Title.DEVELOPER;
} }
// Executives // Executives
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString()))) else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString())))
{ {
return Title.EXECUTIVE.getAbbr(); return Title.EXECUTIVE;
} }
// Senior Admins // Senior Admins
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString()))) else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString())))
{ {
return Rank.SENIOR_ADMIN.getAbbr(); return Rank.SENIOR_ADMIN;
} }
// Admins // Admins
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString()))) else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString())))
{ {
return Rank.ADMIN.getAbbr(); return Rank.ADMIN;
} }
// Master Builders // Master Builders
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID.getString()))) else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID.getString())))
{ {
return Title.MASTER_BUILDER.getAbbr(); return Title.MASTER_BUILDER;
} }
// OP, returning null breaks? // OP, returning null breaks?
else else
{ {
return Rank.OP.getAbbr(); return Rank.OP;
} }
} }
} }