Made sendMessage async (#12)
This commit is contained in:
parent
4f2c33add7
commit
b3153847b0
2 changed files with 4 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue