Moved SendException
This commit is contained in:
parent
e6179f447f
commit
77aca9d5c1
2 changed files with 65 additions and 3 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
57
src/main/java/buttondevteam/lib/TBMCExceptionEvent.java
Normal file
57
src/main/java/buttondevteam/lib/TBMCExceptionEvent.java
Normal file
|
@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This event gets called (ideally) each time an exception occurs in a TBMC plugin. To call it, use {@link TBMCCoreAPI#SendException(String, Exception)}.
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue