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> <version>1.7.21</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.TBMCPlugins.ButtonLib</groupId> <groupId>com.github.TBMCPlugins.ButtonCore</groupId>
<artifactId>ButtonLib</artifactId> <artifactId>ButtonCore</artifactId>
<version>master-SNAPSHOT</version> <version>master-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View file

@ -55,7 +55,8 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
dc.getDispatcher().registerListener(this); dc.getDispatcher().registerListener(this);
for (IListener<?> listener : CommandListener.getListeners()) for (IListener<?> listener : CommandListener.getListeners())
dc.getDispatcher().registerListener(listener); 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); TBMCChatAPI.AddCommands(this, DiscordMCCommandBase.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); 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; package buttondevteam.discordplugin;
import org.apache.commons.lang.exception.ExceptionUtils; 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) { public static void SendException(Throwable e, String sourcemessage) {
try { try {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

View file

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