diff --git a/src/main/java/buttondevteam/lib/TBMCCoreAPI.java b/src/main/java/buttondevteam/lib/TBMCCoreAPI.java index b544c72..44da4df 100644 --- a/src/main/java/buttondevteam/lib/TBMCCoreAPI.java +++ b/src/main/java/buttondevteam/lib/TBMCCoreAPI.java @@ -44,9 +44,8 @@ public final class TBMCCoreAPI { String ret = ""; URL url; try { - url = new URL("https://jitpack.io/com/github/TBMCPlugins/" - + correctname + "/master-SNAPSHOT/" - + correctname + "-master-SNAPSHOT.jar"); // ButtonLib exception not required, not a separate plugin + url = new URL("https://jitpack.io/com/github/TBMCPlugins/" + correctname + "/master-SNAPSHOT/" + correctname + + "-master-SNAPSHOT.jar"); // ButtonLib exception not required, not a separate plugin FileUtils.copyURLToFile(url, new File("plugins/" + correctname + ".jar")); } catch (FileNotFoundException e) { ret = "Can't find JAR, the build probably failed. Build log (scroll to bottom):\nhttps://jitpack.io/com/github/TBMCPlugins/" @@ -91,4 +90,10 @@ public final class TBMCCoreAPI { in.close(); return body; } + + public static void SendException(String sourcemsg, Exception e) { + Bukkit.getPluginManager().callEvent(new TBMCExceptionEvent(sourcemsg, e)); + Bukkit.getLogger().warning(sourcemsg); + e.printStackTrace(); + } } diff --git a/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java b/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java new file mode 100644 index 0000000..ec7f11d --- /dev/null +++ b/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java @@ -0,0 +1,57 @@ +package buttondevteam.lib; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import buttondevteam.lib.TBMCPlayer.InfoTarget; + +/** + *

+ * This event gets called (ideally) each time an exception occurs in a TBMC plugin. To call it, use {@link TBMCCoreAPI#SendException(String, Exception)}. + *

+ * + * @author Norbi + * + */ +public class TBMCExceptionEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + + private String sourcemsg; + private Exception exception; + + TBMCExceptionEvent(String sourcemsg, Exception exception) { + this.sourcemsg = sourcemsg; + this.exception = exception; + } + + /** + * Gets the source message (where did this exception occur, etc.) + * + * @return The message + */ + public String getSourceMessage() { + return sourcemsg; + } + + /** + * Gets the exception + * + * @return The exception + */ + public Exception getException() { + return exception; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +}