Small changes

This commit is contained in:
Norbi Peti 2016-10-06 22:39:12 +02:00
parent 08932887b1
commit 824c72318c

View file

@ -13,6 +13,7 @@ import buttondevteam.bucket.core.TBMCCoreAPI;
import sx.blah.discord.api.*; import sx.blah.discord.api.*;
import sx.blah.discord.api.events.IListener; import sx.blah.discord.api.events.IListener;
import sx.blah.discord.handle.impl.events.ReadyEvent; import sx.blah.discord.handle.impl.events.ReadyEvent;
import sx.blah.discord.handle.obj.IChannel;
/** /**
* Hello world! * Hello world!
@ -30,23 +31,26 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
cb.withToken(IOUtils.toString(getClass().getResourceAsStream("/Token.txt"), Charsets.UTF_8)); cb.withToken(IOUtils.toString(getClass().getResourceAsStream("/Token.txt"), Charsets.UTF_8));
IDiscordClient dc = cb.login(); IDiscordClient dc = cb.login();
dc.getDispatcher().registerListener(this); dc.getDispatcher().registerListener(this);
Runnable r = new Runnable() {
public void run() {
FlairGetterThreadMethod();
}
};
Thread t = new Thread(r);
t.start();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Bukkit.getPluginManager().disablePlugin(this); Bukkit.getPluginManager().disablePlugin(this);
} }
} }
private IChannel channel;
@Override @Override
public void handle(ReadyEvent event) { public void handle(ReadyEvent event) {
try { try {
event.getClient().getGuilds().get(0).getChannelsByName("bot").get(0).sendMessage("Hi"); channel = event.getClient().getGuilds().get(0).getChannelsByName("bot").get(0);
channel.sendMessage("Minecraft server started up");
Runnable r = new Runnable() {
public void run() {
AnnouncementGetterThreadMethod();
}
};
Thread t = new Thread(r);
t.start();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -57,7 +61,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
stop = true; stop = true;
} }
private void FlairGetterThreadMethod() { private void AnnouncementGetterThreadMethod() {
while (!stop) { while (!stop) {
try { try {
String body = TBMCCoreAPI.DownloadString(SubredditURL + ".json?limit=10"); // TODO: Save last announcement String body = TBMCCoreAPI.DownloadString(SubredditURL + ".json?limit=10"); // TODO: Save last announcement