Made sendMessage async (#12)

This commit is contained in:
Norbi Peti 2016-11-29 20:36:51 +01:00
parent 4f2c33add7
commit b3153847b0
2 changed files with 4 additions and 1 deletions

View file

@ -37,11 +37,13 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
private static final String SubredditURL = "https://www.reddit.com/r/ChromaGamers";
private static boolean stop = false;
public static IDiscordClient dc;
public static DiscordPlugin plugin;
@Override
public void onEnable() {
try {
Bukkit.getLogger().info("Initializing DiscordPlugin...");
plugin = this;
final File file = new File("TBMC", "DiscordRedditLastAnnouncement.txt");
if (file.exists()) {
BufferedReader reader = Files.newReader(file, StandardCharsets.UTF_8);

View file

@ -101,7 +101,8 @@ public class DiscordSender implements CommandSender {
@Override
public void sendMessage(String message) {
try {
DiscordPlugin.sendMessageToChannel(channel, message);
Bukkit.getScheduler().runTaskAsynchronously(DiscordPlugin.plugin,
() -> DiscordPlugin.sendMessageToChannel(channel, message));
} catch (Exception e) {
TBMCCoreAPI.SendException("An error occured while sending message to DiscordSender", e);
}