(#12) Added player join/leave and plugin (un)load msgs

This commit is contained in:
Norbi Peti 2016-11-29 21:00:39 +01:00
parent b3153847b0
commit d6b5ae2d88
2 changed files with 10 additions and 1 deletions

View file

@ -114,7 +114,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
chatchannel = devServer.getChannelByID("248185455508455424"); // minecraft_chat_test chatchannel = devServer.getChannelByID("248185455508455424"); // minecraft_chat_test
dc.changeStatus(Status.game("testing")); dc.changeStatus(Status.game("testing"));
} }
// sendMessageToChannel(botchannel, "Minecraft server started up"); sendMessageToChannel(chatchannel, "Server started - chat connected.");
Runnable r = new Runnable() { Runnable r = new Runnable() {
public void run() { public void run() {
AnnouncementGetterThreadMethod(); AnnouncementGetterThreadMethod();
@ -139,6 +139,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
getConfig().set("lastannouncementtime", lastannouncementtime); getConfig().set("lastannouncementtime", lastannouncementtime);
getConfig().set("lastseentime", lastseentime); getConfig().set("lastseentime", lastseentime);
saveConfig(); saveConfig();
sendMessageToChannel(chatchannel, "Server restarting/stopping");
try { try {
dc.changeStatus(Status.game("on TBMC")); dc.changeStatus(Status.game("on TBMC"));
dc.logout(); dc.logout();

View file

@ -11,6 +11,7 @@ import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.discordplugin.commands.ConnectCommand; import buttondevteam.discordplugin.commands.ConnectCommand;
import buttondevteam.lib.TBMCPlayerGetInfoEvent; import buttondevteam.lib.TBMCPlayerGetInfoEvent;
import buttondevteam.lib.TBMCPlayerJoinEvent; import buttondevteam.lib.TBMCPlayerJoinEvent;
import buttondevteam.lib.TBMCPlayerQuitEvent;
import sx.blah.discord.handle.obj.IUser; import sx.blah.discord.handle.obj.IUser;
import sx.blah.discord.handle.obj.Status.StatusType; import sx.blah.discord.handle.obj.Status.StatusType;
@ -23,6 +24,13 @@ public class MCListener implements Listener {
+ ConnectCommand.WaitingToConnect.get(e.GetPlayer().getPlayerName()) + " do /discord accept"); + ConnectCommand.WaitingToConnect.get(e.GetPlayer().getPlayerName()) + " do /discord accept");
p.sendMessage("§bIf it wasn't you, do /discord decline"); p.sendMessage("§bIf it wasn't you, do /discord decline");
} }
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel,
e.GetPlayer().getPlayerName() + " joined the game");
}
@EventHandler
public void onPlayerLeave(TBMCPlayerQuitEvent e) {
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, e.GetPlayer().getPlayerName() + " left the game");
} }
@EventHandler @EventHandler