Fixes and stuff

This commit is contained in:
Norbi Peti 2016-11-02 18:37:36 +01:00
parent 754ed869f1
commit fb5dd60b84
5 changed files with 16 additions and 18 deletions

View file

@ -137,8 +137,8 @@
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>com.github.TBMCPlugins.ButtonLib</groupId>
<artifactId>ButtonLib</artifactId>
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
<artifactId>ButtonCore</artifactId>
<version>master-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

View file

@ -55,7 +55,8 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
dc.getDispatcher().registerListener(this);
for (IListener<?> listener : CommandListener.getListeners())
dc.getDispatcher().registerListener(listener);
Bukkit.getPluginManager().registerEvents(new MCListener(), this);
Bukkit.getPluginManager().registerEvents(new ExceptionListener(), this);
TBMCCoreAPI.RegisterEventsForExceptions(new MCListener(), this);
TBMCChatAPI.AddCommands(this, DiscordMCCommandBase.class);
} catch (Exception e) {
e.printStackTrace();

View file

@ -1,12 +0,0 @@
package buttondevteam.discordplugin;
import org.bukkit.event.Event;
import buttondevteam.lib.EventExceptionHandler;
public class EventExceptionDiscordSender extends EventExceptionHandler {
@Override
public boolean handle(Throwable ex, Event event) {
TBMCDiscordAPI.SendException(ex, "An error occured while executing " + event.getEventName() + "!");
return true;
}
}

View file

@ -1,8 +1,17 @@
package buttondevteam.discordplugin;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import buttondevteam.lib.TBMCExceptionEvent;
public class ExceptionListener implements Listener {
@EventHandler
public void onException(TBMCExceptionEvent e) {
SendException(e.getException(), e.getSourceMessage());
}
public final class TBMCDiscordAPI {
public static void SendException(Throwable e, String sourcemessage) {
try {
StringBuilder sb = new StringBuilder();

View file

@ -8,7 +8,7 @@ import com.google.common.collect.HashBiMap;
import buttondevteam.discordplugin.DiscordPlayer;
import buttondevteam.discordplugin.DiscordPlugin;
import buttondevteam.discordplugin.TBMCDiscordAPI;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.TBMCPlayer;
import sx.blah.discord.handle.obj.IMessage;
@ -53,7 +53,7 @@ public class ConnectCommand extends DiscordCommandBase {
return;
}
} catch (Exception e) {
TBMCDiscordAPI.SendException(e, "An error occured while connecting a Discord account!");
TBMCCoreAPI.SendException("An error occured while connecting a Discord account!", e);
DiscordPlugin.sendMessageToChannel(message.getChannel(), "An internal error occured!\n" + e);
}
WaitingToConnect.put(args, message.getAuthor().getID());