Some prep for 1.14

This commit is contained in:
Norbi Peti 2019-06-09 23:32:49 +02:00
parent b1ea027d1c
commit db8dfa79bc
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
5 changed files with 86 additions and 67 deletions

View file

@ -19,6 +19,7 @@
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.10" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />

View file

@ -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
*/

View file

@ -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?

View file

@ -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<Player> 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<Player> 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();
}
}

View file

@ -1,7 +1,6 @@
package buttondevteam.lib;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@ -14,7 +13,6 @@ import org.bukkit.event.HandlerList;
*
*/
@Getter
@RequiredArgsConstructor
public class TBMCExceptionEvent extends Event {
private static final HandlerList handlers = new HandlerList();
@ -22,6 +20,13 @@ public class TBMCExceptionEvent extends Event {
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;
}