Some prep for 1.14
This commit is contained in:
parent
b1ea027d1c
commit
db8dfa79bc
5 changed files with 86 additions and 67 deletions
|
@ -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="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: 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: com.google.code.findbugs:annotations:2.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
|
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
|
||||||
|
|
|
@ -3,7 +3,6 @@ package buttondevteam.lib;
|
||||||
import buttondevteam.core.component.channel.Channel;
|
import buttondevteam.core.component.channel.Channel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
|
@ -12,7 +11,6 @@ import org.bukkit.event.Event;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@RequiredArgsConstructor
|
|
||||||
public abstract class TBMCChatEventBase extends Event implements Cancellable {
|
public abstract class TBMCChatEventBase extends Event implements Cancellable {
|
||||||
private final Channel channel;
|
private final Channel channel;
|
||||||
private @NonNull String message;
|
private @NonNull String message;
|
||||||
|
@ -26,6 +24,15 @@ public abstract class TBMCChatEventBase extends Event implements Cancellable {
|
||||||
*/
|
*/
|
||||||
private final String groupID;
|
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
|
* Note: Errors are sent to the sender automatically
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class TBMCChatPreprocessEvent extends Event implements Cancellable {
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public TBMCChatPreprocessEvent(CommandSender sender, Channel channel, String message) {
|
public TBMCChatPreprocessEvent(CommandSender sender, Channel channel, String message) {
|
||||||
|
super(true);
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.message = message; // TODO: Message object with data?
|
this.message = message; // TODO: Message object with data?
|
||||||
|
|
|
@ -82,36 +82,41 @@ public class TBMCCoreAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SendException(String sourcemsg, Throwable e, boolean debugPotato) {
|
public static void SendException(String sourcemsg, Throwable e, boolean debugPotato) {
|
||||||
SendUnsentExceptions();
|
try {
|
||||||
TBMCExceptionEvent event = new TBMCExceptionEvent(sourcemsg, e);
|
SendUnsentExceptions();
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
TBMCExceptionEvent event = new TBMCExceptionEvent(sourcemsg, e);
|
||||||
synchronized (exceptionsToSend) {
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (!event.isHandled())
|
synchronized (exceptionsToSend) {
|
||||||
exceptionsToSend.put(sourcemsg, e);
|
if (!event.isHandled())
|
||||||
}
|
exceptionsToSend.put(sourcemsg, e);
|
||||||
Bukkit.getLogger().warning(sourcemsg);
|
}
|
||||||
e.printStackTrace();
|
Bukkit.getLogger().warning(sourcemsg);
|
||||||
if (debugPotato) {
|
e.printStackTrace();
|
||||||
List<Player> devsOnline = new ArrayList<>();
|
if (debugPotato) {
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
List<Player> devsOnline = new ArrayList<>();
|
||||||
if (coders.contains(player.getName())) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
devsOnline.add(player);
|
if (coders.contains(player.getName())) {
|
||||||
}
|
devsOnline.add(player);
|
||||||
}
|
}
|
||||||
if (!devsOnline.isEmpty()) {
|
}
|
||||||
DebugPotato potato = new DebugPotato()
|
if (!devsOnline.isEmpty()) {
|
||||||
.setMessage(new String[]{ //
|
DebugPotato potato = new DebugPotato()
|
||||||
"§b§o" + e.getClass().getSimpleName(), //
|
.setMessage(new String[]{ //
|
||||||
"§c§o" + sourcemsg, //
|
"§b§o" + e.getClass().getSimpleName(), //
|
||||||
"§a§oFind a dev to fix this issue"})
|
"§c§o" + sourcemsg, //
|
||||||
.setType(e instanceof IOException ? "Throwable Potato"
|
"§a§oFind a dev to fix this issue"})
|
||||||
: e instanceof ClassCastException ? "Squished Potato"
|
.setType(e instanceof IOException ? "Throwable Potato"
|
||||||
: e instanceof NullPointerException ? "Plain Potato"
|
: e instanceof ClassCastException ? "Squished Potato"
|
||||||
: e instanceof StackOverflowError ? "Chips" : "Error Potato");
|
: e instanceof NullPointerException ? "Plain Potato"
|
||||||
for (Player dev : devsOnline) {
|
: e instanceof StackOverflowError ? "Chips" : "Error Potato");
|
||||||
potato.Send(dev);
|
for (Player dev : devsOnline) {
|
||||||
|
potato.Send(dev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception ee) {
|
||||||
|
System.err.println("Failed to send exception!");
|
||||||
|
ee.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,37 +1,42 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
/**
|
||||||
/**
|
* <p>
|
||||||
* <p>
|
* This event gets called (ideally) each time an exception occurs in a TBMC plugin. To call it, use {@link TBMCCoreAPI#SendException(String, Throwable)}.
|
||||||
* This event gets called (ideally) each time an exception occurs in a TBMC plugin. To call it, use {@link TBMCCoreAPI#SendException(String, Throwable)}.
|
* </p>
|
||||||
* </p>
|
*
|
||||||
*
|
* @author Norbi
|
||||||
* @author Norbi
|
*
|
||||||
*
|
*/
|
||||||
*/
|
@Getter
|
||||||
@Getter
|
public class TBMCExceptionEvent extends Event {
|
||||||
@RequiredArgsConstructor
|
private static final HandlerList handlers = new HandlerList();
|
||||||
public class TBMCExceptionEvent extends Event {
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private final String sourceMessage;
|
||||||
|
private final Throwable exception;
|
||||||
private final String sourceMessage;
|
private boolean handled;
|
||||||
private final Throwable exception;
|
|
||||||
private boolean handled;
|
@java.beans.ConstructorProperties({"sourceMessage", "exception"})
|
||||||
|
public TBMCExceptionEvent(String sourceMessage, Throwable exception) {
|
||||||
public void setHandled() {
|
super(true);
|
||||||
handled = true;
|
this.sourceMessage = sourceMessage;
|
||||||
}
|
this.exception = exception;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
public void setHandled() {
|
||||||
return handlers;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
@Override
|
||||||
return handlers;
|
public HandlerList getHandlers() {
|
||||||
}
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue