Added checkmark if mcchat send succeeds

Also updated Discord4J to a dev version and other stuff
This commit is contained in:
Norbi Peti 2016-12-20 21:08:34 +01:00
parent b28e7fd67f
commit a05115293d
3 changed files with 18 additions and 8 deletions

View file

@ -135,7 +135,7 @@
<dependency>
<groupId>com.github.austinv11</groupId>
<artifactId>Discord4j</artifactId>
<version>2.6.1</version>
<version>websocket-rewrite-SNAPSHOT</version>
<!-- <classifier>shaded</classifier> --> <!-- Include this line if you want a shaded jar (all the Discord4J dependencies
bundled into one jar) -->
</dependency>

View file

@ -27,6 +27,14 @@ public abstract class DiscordSenderBase implements IDiscordSender {
private volatile String msgtosend = "";
private volatile BukkitTask sendtask;
public IUser getUser() {
return user;
}
public IChannel getChannel() {
return channel;
}
@Override
public void sendMessage(String message) {
try {
@ -42,7 +50,8 @@ public abstract class DiscordSenderBase implements IDiscordSender {
msgtosend += "\n" + sendmsg;
if (sendtask == null)
sendtask = Bukkit.getScheduler().runTaskLaterAsynchronously(DiscordPlugin.plugin, () -> {
DiscordPlugin.sendMessageToChannel(channel, (!broadcast ? user.mention() + "\n" : "") + msgtosend.trim());
DiscordPlugin.sendMessageToChannel(channel,
(!broadcast ? user.mention() + "\n" : "") + msgtosend.trim());
sendtask = null;
msgtosend = "";
}, 10); // Waits a half second to gather all/most of the different messages

View file

@ -80,7 +80,8 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
// Command not whitelisted
DiscordPlugin.sendMessageToChannel(event.getMessage().getChannel(), // TODO
"Sorry, you need to be online on the server and have your accounts connected, you can only access these commands:\n"
+ Arrays.toString(UnconnectedCmds)
+ Arrays.stream(UnconnectedCmds).map(uc -> "/" + uc)
.collect(Collectors.joining(", "))
+ "\nTo connect your accounts, use @ChromaBot connect in "
+ DiscordPlugin.botchannel.mention());
return;
@ -88,11 +89,11 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
Bukkit.dispatchCommand(dsender, cmd);
} else
TBMCChatAPI.SendChatMessage(Channel.GlobalChat, dsender,
dmessage + (event.getMessage().getAttachments().size() > 0 ? event.getMessage().getAttachments()
.stream().map(a -> a.getUrl()).collect(Collectors.joining("\n")) : ""));
} catch (
Exception e) {
dmessage + (event.getMessage().getAttachments().size() > 0 ? "\n" + event.getMessage()
.getAttachments().stream().map(a -> a.getUrl()).collect(Collectors.joining("\n"))
: ""));
event.getMessage().addReaction(DiscordPlugin.mainServer.getEmojiByName("white_check_mark"));
} catch (Exception e) {
TBMCCoreAPI.SendException("An error occured while handling " + dmessage + "!", e);
return;
}