Added reaction after plugin update

This commit is contained in:
Norbi Peti 2016-12-22 23:20:27 +01:00
parent 6151fa0de9
commit 4ecbb15bd2
4 changed files with 11 additions and 9 deletions

View file

@ -144,6 +144,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
private long lastannouncementtime = 0; private long lastannouncementtime = 0;
private long lastseentime = 0; private long lastseentime = 0;
public static final String DELIVERED_REACTION = "";
private void AnnouncementGetterThreadMethod() { private void AnnouncementGetterThreadMethod() {
while (!stop) { while (!stop) {

View file

@ -5,6 +5,7 @@ import buttondevteam.discordplugin.DiscordSender;
import buttondevteam.lib.TBMCCoreAPI; import buttondevteam.lib.TBMCCoreAPI;
import sx.blah.discord.api.events.IListener; import sx.blah.discord.api.events.IListener;
import sx.blah.discord.handle.impl.events.MessageReceivedEvent; import sx.blah.discord.handle.impl.events.MessageReceivedEvent;
import sx.blah.discord.util.RateLimitException;
public class AutoUpdaterListener implements IListener<MessageReceivedEvent> { public class AutoUpdaterListener implements IListener<MessageReceivedEvent> {
@Override @Override
@ -21,6 +22,12 @@ public class AutoUpdaterListener implements IListener<MessageReceivedEvent> {
String branch = title.substring(title.indexOf(':') + 1, title.indexOf(']')); String branch = title.substring(title.indexOf(':') + 1, title.indexOf(']'));
String project = title.substring(title.indexOf('[') + 1, title.indexOf(':')); String project = title.substring(title.indexOf('[') + 1, title.indexOf(':'));
if (branch.equals("master") || (TBMCCoreAPI.IsTestServer() && branch.equals("dev"))) if (branch.equals("master") || (TBMCCoreAPI.IsTestServer() && branch.equals("dev")))
TBMCCoreAPI.UpdatePlugin(project, new DiscordSender(null, DiscordPlugin.chatchannel), branch); if (TBMCCoreAPI.UpdatePlugin(project, new DiscordSender(null, DiscordPlugin.chatchannel), branch))
try {
event.getMessage().addReaction(DiscordPlugin.DELIVERED_REACTION);
} catch (RateLimitException e) { // TODO: Handle
} catch (Exception e) {
TBMCCoreAPI.SendException("An error occured while reacting to plugin update!", e);
}
} }
} }

View file

@ -19,14 +19,9 @@ import sx.blah.discord.api.events.IListener;
import sx.blah.discord.handle.impl.events.MessageReceivedEvent; import sx.blah.discord.handle.impl.events.MessageReceivedEvent;
import sx.blah.discord.handle.obj.IReaction; import sx.blah.discord.handle.obj.IReaction;
import sx.blah.discord.handle.obj.IUser; import sx.blah.discord.handle.obj.IUser;
import sx.blah.discord.util.DiscordException;
import sx.blah.discord.util.EmbedBuilder;
import sx.blah.discord.util.MissingPermissionsException;
import sx.blah.discord.util.RateLimitException; import sx.blah.discord.util.RateLimitException;
public class MCChatListener implements Listener, IListener<MessageReceivedEvent> { public class MCChatListener implements Listener, IListener<MessageReceivedEvent> {
private static final String DELIVERED_REACTION = "";
@EventHandler // Minecraft @EventHandler // Minecraft
public void onMCChat(TBMCChatEvent e) { public void onMCChat(TBMCChatEvent e) {
if (e.isCancelled()) if (e.isCancelled())
@ -100,10 +95,10 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
dmessage + (event.getMessage().getAttachments().size() > 0 ? "\n" + event.getMessage() dmessage + (event.getMessage().getAttachments().size() > 0 ? "\n" + event.getMessage()
.getAttachments().stream().map(a -> a.getUrl()).collect(Collectors.joining("\n")) .getAttachments().stream().map(a -> a.getUrl()).collect(Collectors.joining("\n"))
: "")); : ""));
event.getMessage().addReaction(DELIVERED_REACTION); event.getMessage().addReaction(DiscordPlugin.DELIVERED_REACTION);
event.getMessage().getChannel().getMessages().stream().forEach(m -> { event.getMessage().getChannel().getMessages().stream().forEach(m -> {
try { try {
final IReaction reaction = m.getReactionByName(DELIVERED_REACTION); final IReaction reaction = m.getReactionByName(DiscordPlugin.DELIVERED_REACTION);
if (reaction != null) { if (reaction != null) {
while (true) while (true)
try { try {

View file

@ -12,7 +12,6 @@ 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 buttondevteam.lib.TBMCPlayerQuitEvent;
import buttondevteam.lib.TBMCYEEHAWEvent;
import net.ess3.api.events.AfkStatusChangeEvent; import net.ess3.api.events.AfkStatusChangeEvent;
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;