diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index 098cd57..d0f3587 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -19,6 +19,7 @@ + diff --git a/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatEventBase.java b/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatEventBase.java index d30e12e..1ac02b6 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatEventBase.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatEventBase.java @@ -3,7 +3,6 @@ package buttondevteam.lib; import buttondevteam.core.component.channel.Channel; import lombok.Getter; import lombok.NonNull; -import lombok.RequiredArgsConstructor; import lombok.Setter; import org.bukkit.command.CommandSender; import org.bukkit.event.Cancellable; @@ -12,7 +11,6 @@ import org.bukkit.event.Event; import javax.annotation.Nullable; @Getter -@RequiredArgsConstructor public abstract class TBMCChatEventBase extends Event implements Cancellable { private final Channel channel; private @NonNull String message; @@ -26,6 +24,15 @@ public abstract class TBMCChatEventBase extends Event implements Cancellable { */ private final String groupID; + @java.beans.ConstructorProperties({"channel", "message", "score", "groupID"}) + public TBMCChatEventBase(Channel channel, String message, int score, String groupID) { + super(true); + this.channel = channel; + this.message = message; + this.score = score; + this.groupID = groupID; + } + /** * Note: Errors are sent to the sender automatically */ diff --git a/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatPreprocessEvent.java b/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatPreprocessEvent.java index 6ff3bda..9a512ee 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatPreprocessEvent.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatPreprocessEvent.java @@ -27,6 +27,7 @@ public class TBMCChatPreprocessEvent extends Event implements Cancellable { private boolean cancelled; public TBMCChatPreprocessEvent(CommandSender sender, Channel channel, String message) { + super(true); this.sender = sender; this.channel = channel; this.message = message; // TODO: Message object with data? diff --git a/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java b/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java index a313fe0..6b193aa 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java @@ -82,36 +82,41 @@ public class TBMCCoreAPI { } public static void SendException(String sourcemsg, Throwable e, boolean debugPotato) { - SendUnsentExceptions(); - TBMCExceptionEvent event = new TBMCExceptionEvent(sourcemsg, e); - Bukkit.getPluginManager().callEvent(event); - synchronized (exceptionsToSend) { - if (!event.isHandled()) - exceptionsToSend.put(sourcemsg, e); - } - Bukkit.getLogger().warning(sourcemsg); - e.printStackTrace(); - if (debugPotato) { - List devsOnline = new ArrayList<>(); - for (Player player : Bukkit.getOnlinePlayers()) { - if (coders.contains(player.getName())) { - devsOnline.add(player); - } - } - if (!devsOnline.isEmpty()) { - DebugPotato potato = new DebugPotato() - .setMessage(new String[]{ // - "§b§o" + e.getClass().getSimpleName(), // - "§c§o" + sourcemsg, // - "§a§oFind a dev to fix this issue"}) - .setType(e instanceof IOException ? "Throwable Potato" - : e instanceof ClassCastException ? "Squished Potato" - : e instanceof NullPointerException ? "Plain Potato" - : e instanceof StackOverflowError ? "Chips" : "Error Potato"); - for (Player dev : devsOnline) { - potato.Send(dev); + try { + SendUnsentExceptions(); + TBMCExceptionEvent event = new TBMCExceptionEvent(sourcemsg, e); + Bukkit.getPluginManager().callEvent(event); + synchronized (exceptionsToSend) { + if (!event.isHandled()) + exceptionsToSend.put(sourcemsg, e); + } + Bukkit.getLogger().warning(sourcemsg); + e.printStackTrace(); + if (debugPotato) { + List devsOnline = new ArrayList<>(); + for (Player player : Bukkit.getOnlinePlayers()) { + if (coders.contains(player.getName())) { + devsOnline.add(player); + } + } + if (!devsOnline.isEmpty()) { + DebugPotato potato = new DebugPotato() + .setMessage(new String[]{ // + "§b§o" + e.getClass().getSimpleName(), // + "§c§o" + sourcemsg, // + "§a§oFind a dev to fix this issue"}) + .setType(e instanceof IOException ? "Throwable Potato" + : e instanceof ClassCastException ? "Squished Potato" + : e instanceof NullPointerException ? "Plain Potato" + : e instanceof StackOverflowError ? "Chips" : "Error Potato"); + for (Player dev : devsOnline) { + potato.Send(dev); + } } } + } catch (Exception ee) { + System.err.println("Failed to send exception!"); + ee.printStackTrace(); } } diff --git a/ButtonCore/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java b/ButtonCore/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java index 90c4185..44a93b1 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java @@ -1,37 +1,42 @@ -package buttondevteam.lib; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -/** - *

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

- * - * @author Norbi - * - */ -@Getter -@RequiredArgsConstructor -public class TBMCExceptionEvent extends Event { - private static final HandlerList handlers = new HandlerList(); - - private final String sourceMessage; - private final Throwable exception; - private boolean handled; - - public void setHandled() { - handled = true; - } - - @Override - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } -} +package buttondevteam.lib; + +import lombok.Getter; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + *

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

+ * + * @author Norbi + * + */ +@Getter +public class TBMCExceptionEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + + private final String sourceMessage; + private final Throwable exception; + private boolean handled; + + @java.beans.ConstructorProperties({"sourceMessage", "exception"}) + public TBMCExceptionEvent(String sourceMessage, Throwable exception) { + super(true); + this.sourceMessage = sourceMessage; + this.exception = exception; + } + + public void setHandled() { + handled = true; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +}