Fixes, improvements

This commit is contained in:
Norbi Peti 2016-10-21 22:38:17 +02:00
parent 3d9b087208
commit b1d6d61e61
2 changed files with 7 additions and 1 deletions

View file

@ -21,6 +21,8 @@ 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; import sx.blah.discord.handle.obj.IChannel;
import sx.blah.discord.handle.obj.Status;
import sx.blah.discord.handle.obj.Status.StatusType;
/** /**
* Hello world! * Hello world!
@ -45,6 +47,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
cb.withToken(Files.readFirstLine(new File("TBMC", "Token.txt"), StandardCharsets.UTF_8)); cb.withToken(Files.readFirstLine(new File("TBMC", "Token.txt"), StandardCharsets.UTF_8));
dc = cb.login(); dc = cb.login();
dc.getDispatcher().registerListener(this); dc.getDispatcher().registerListener(this);
dc.getDispatcher().registerListener(new CommandListener());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Bukkit.getPluginManager().disablePlugin(this); Bukkit.getPluginManager().disablePlugin(this);
@ -61,6 +64,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
botchannel = event.getClient().getGuilds().get(0).getChannelByID("209720707188260864"); // bot botchannel = event.getClient().getGuilds().get(0).getChannelByID("209720707188260864"); // bot
annchannel = event.getClient().getGuilds().get(0).getChannelByID("126795071927353344"); // announcements annchannel = event.getClient().getGuilds().get(0).getChannelByID("126795071927353344"); // announcements
genchannel = event.getClient().getGuilds().get(0).getChannelByID("125813020357165056"); // general genchannel = event.getClient().getGuilds().get(0).getChannelByID("125813020357165056"); // general
dc.changeStatus(Status.game("on TBMC"));
botchannel.sendMessage("Minecraft server started up"); botchannel.sendMessage("Minecraft server started up");
Runnable r = new Runnable() { Runnable r = new Runnable() {
public void run() { public void run() {
@ -124,7 +128,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
} }
if (msgsb.length() > 0) if (msgsb.length() > 0)
genchannel.pin(genchannel.sendMessage(msgsb.toString())); genchannel.pin(genchannel.sendMessage(msgsb.toString()));
if (modmsgsb.length() > 0) //TODO: Wait for distinguish if (modmsgsb.length() > 0) // TODO: Wait for distinguish
annchannel.sendMessage(modmsgsb.toString()); annchannel.sendMessage(modmsgsb.toString());
lastannouncementtime = lastanntime; // If sending succeeded lastannouncementtime = lastanntime; // If sending succeeded
File file = new File("TBMC", "DiscordRedditLastAnnouncement.txt"); File file = new File("TBMC", "DiscordRedditLastAnnouncement.txt");

View file

@ -1,9 +1,11 @@
package buttondevteam.discordplugin; package buttondevteam.discordplugin;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerCommandEvent; import org.bukkit.event.server.ServerCommandEvent;
public class MCListener implements Listener { public class MCListener implements Listener {
@EventHandler
public void onServerCommandPreprocess(ServerCommandEvent e) { public void onServerCommandPreprocess(ServerCommandEvent e) {
if (!DiscordPlugin.dc.isReady()) if (!DiscordPlugin.dc.isReady())
return; return;