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);
for (Player p : server.getOnlinePlayers())
{
if (plugin.al.isAdminImpostor(p))
if (plugin.al.isAdmin(p))
{
notice.send(p);
}

View File

@ -65,10 +65,10 @@ public class DiscordToAdminChatListener extends ListenerAdapter
String format = admin.getAcFormat();
if (!Strings.isNullOrEmpty(format))
{
Displayable display = TotalFreedomMod.getPlugin().rm.getDisplay(player);
Displayable display = getDisplay(member);
net.md_5.bungee.api.ChatColor color = getColor(display);
String m = format.replace("%name%", member.getEffectiveName())
.replace("%rank%", getDisplay(member))
.replace("%rank%", display.getAbbr())
.replace("%rankcolor%", color.toString())
.replace("%msg%", FUtil.colorize(msg.getContentDisplay()));
builder.append(FUtil.colorize(m));
@ -86,8 +86,12 @@ public class DiscordToAdminChatListener extends ListenerAdapter
{
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()));
if (!msg.getContentDisplay().isEmpty())
{
builder.append(" ");
}
builder.append(text);
}
}
@ -98,43 +102,43 @@ public class DiscordToAdminChatListener extends ListenerAdapter
}
// 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());
// Server Owner
if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString())))
{
return Title.OWNER.getAbbr();
return Title.OWNER;
}
// Developers
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString())))
{
return Title.DEVELOPER.getAbbr();
return Title.DEVELOPER;
}
// Executives
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString())))
{
return Title.EXECUTIVE.getAbbr();
return Title.EXECUTIVE;
}
// Senior Admins
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString())))
{
return Rank.SENIOR_ADMIN.getAbbr();
return Rank.SENIOR_ADMIN;
}
// Admins
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString())))
{
return Rank.ADMIN.getAbbr();
return Rank.ADMIN;
}
// Master Builders
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?
else
{
return Rank.OP.getAbbr();
return Rank.OP;
}
}
}