Fixed message grouping in mcchat
Also updated the role adding cmd path
This commit is contained in:
parent
6027315d09
commit
a4ca1bb6d3
2 changed files with 6 additions and 8 deletions
|
@ -49,7 +49,7 @@ public class RoleCommand extends DiscordCommandBase {
|
|||
} else if (argsa[0].equalsIgnoreCase("list")) {
|
||||
DiscordPlugin.sendMessageToChannel(message.getChannel(),
|
||||
"List of game roles:\n" + DiscordPlugin.GameRoles.stream().collect(Collectors.joining("\n")));
|
||||
} else if (argsa[0].equalsIgnoreCase("addrole")) {
|
||||
} else if (argsa[0].equalsIgnoreCase("admin") && argsa.length > 1 && argsa[1].equalsIgnoreCase("addrole")) {
|
||||
if (!message.getAuthor().getRolesForGuild(DiscordPlugin.mainServer).stream()
|
||||
.anyMatch(r -> r.getLongID() == 126030201472811008L)) {
|
||||
DiscordPlugin.sendMessageToChannel(message.getChannel(),
|
||||
|
|
|
@ -35,9 +35,11 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
|||
return;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(DiscordPlugin.plugin, () -> {
|
||||
synchronized (this) {
|
||||
final String authorPlayer = DPUtils.sanitizeString(e.getSender() instanceof Player //
|
||||
? ((Player) e.getSender()).getDisplayName() //
|
||||
: e.getSender().getName());
|
||||
final String authorPlayer = "[" + DPUtils.sanitizeString(e.getChannel().DisplayName) + "] " //
|
||||
+ (e.getSender() instanceof DiscordSenderBase ? "[D]" : "") //
|
||||
+ (DPUtils.sanitizeString(e.getSender() instanceof Player //
|
||||
? ((Player) e.getSender()).getDisplayName() //
|
||||
: e.getSender().getName()));
|
||||
final EmbedBuilder embed = new EmbedBuilder().withAuthorName(authorPlayer)
|
||||
.withDescription(e.getMessage()).withColor(new Color(e.getChannel().color.getRed(),
|
||||
e.getChannel().color.getGreen(), e.getChannel().color.getBlue()));
|
||||
|
@ -52,14 +54,10 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
|||
embed.withAuthorIcon(((DiscordSenderBase) e.getSender()).getUser().getAvatarURL())
|
||||
.withAuthorUrl("https://tbmcplugins.github.io/profile.html?type=discord&id="
|
||||
+ ((DiscordSenderBase) e.getSender()).getUser().getStringID()); // TODO: Constant/method to get URLs like this
|
||||
if (e.getSender() instanceof DiscordSenderBase)
|
||||
embed.withAuthorName("[D]" + authorPlayer);
|
||||
// embed.withFooterText(e.getChannel().DisplayName);
|
||||
final long nanoTime = System.nanoTime();
|
||||
Consumer<LastMsgData> doit = lastmsgdata -> {
|
||||
final EmbedObject embedObject = embed.build();
|
||||
embedObject.author.name = "[" + DPUtils.sanitizeString(e.getChannel().DisplayName) + "] "
|
||||
+ embedObject.author.name;
|
||||
if (lastmsgdata.message == null || lastmsgdata.message.isDeleted()
|
||||
|| !authorPlayer.equals(lastmsgdata.message.getEmbeds().get(0).getAuthor().getName())
|
||||
|| lastmsgdata.time / 1000000000f < nanoTime / 1000000000f - 120
|
||||
|
|
Loading…
Reference in a new issue