Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Only print InformativeException cases in codec handlers
Dieser Commit ist enthalten in:
Ursprung
d86ac64ac9
Commit
d414106d5a
@ -3,11 +3,11 @@ package us.myles.ViaVersion.bukkit.handlers;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||||
import io.netty.handler.codec.CodecException;
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.bukkit.util.NMSUtil;
|
import us.myles.ViaVersion.bukkit.util.NMSUtil;
|
||||||
import us.myles.ViaVersion.exception.CancelCodecException;
|
import us.myles.ViaVersion.exception.CancelCodecException;
|
||||||
import us.myles.ViaVersion.exception.CancelDecoderException;
|
import us.myles.ViaVersion.exception.CancelDecoderException;
|
||||||
|
import us.myles.ViaVersion.exception.InformativeException;
|
||||||
import us.myles.ViaVersion.util.PipelineUtil;
|
import us.myles.ViaVersion.util.PipelineUtil;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -57,7 +57,7 @@ public class BukkitDecodeHandler extends ByteToMessageDecoder {
|
|||||||
if (PipelineUtil.containsCause(cause, CancelCodecException.class)) return; // ProtocolLib compat
|
if (PipelineUtil.containsCause(cause, CancelCodecException.class)) return; // ProtocolLib compat
|
||||||
|
|
||||||
super.exceptionCaught(ctx, cause);
|
super.exceptionCaught(ctx, cause);
|
||||||
if (!NMSUtil.isDebugPropertySet() && PipelineUtil.containsCause(cause, CodecException.class)) {
|
if (!NMSUtil.isDebugPropertySet() && PipelineUtil.containsCause(cause, InformativeException.class)) {
|
||||||
cause.printStackTrace(); // Print if CB doesn't already do it
|
cause.printStackTrace(); // Print if CB doesn't already do it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,12 @@ package us.myles.ViaVersion.bukkit.handlers;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.CodecException;
|
|
||||||
import io.netty.handler.codec.MessageToByteEncoder;
|
import io.netty.handler.codec.MessageToByteEncoder;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.bukkit.util.NMSUtil;
|
import us.myles.ViaVersion.bukkit.util.NMSUtil;
|
||||||
import us.myles.ViaVersion.exception.CancelCodecException;
|
import us.myles.ViaVersion.exception.CancelCodecException;
|
||||||
import us.myles.ViaVersion.exception.CancelEncoderException;
|
import us.myles.ViaVersion.exception.CancelEncoderException;
|
||||||
|
import us.myles.ViaVersion.exception.InformativeException;
|
||||||
import us.myles.ViaVersion.handlers.ChannelHandlerContextWrapper;
|
import us.myles.ViaVersion.handlers.ChannelHandlerContextWrapper;
|
||||||
import us.myles.ViaVersion.handlers.ViaHandler;
|
import us.myles.ViaVersion.handlers.ViaHandler;
|
||||||
import us.myles.ViaVersion.util.PipelineUtil;
|
import us.myles.ViaVersion.util.PipelineUtil;
|
||||||
@ -69,7 +69,7 @@ public class BukkitEncodeHandler extends MessageToByteEncoder implements ViaHand
|
|||||||
if (PipelineUtil.containsCause(cause, CancelCodecException.class)) return; // ProtocolLib compat
|
if (PipelineUtil.containsCause(cause, CancelCodecException.class)) return; // ProtocolLib compat
|
||||||
|
|
||||||
super.exceptionCaught(ctx, cause);
|
super.exceptionCaught(ctx, cause);
|
||||||
if (!NMSUtil.isDebugPropertySet() && PipelineUtil.containsCause(cause, CodecException.class)) {
|
if (!NMSUtil.isDebugPropertySet() && PipelineUtil.containsCause(cause, InformativeException.class)) {
|
||||||
cause.printStackTrace(); // Print if CB doesn't already do it
|
cause.printStackTrace(); // Print if CB doesn't already do it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import us.myles.ViaVersion.exception.CancelException;
|
|||||||
import us.myles.ViaVersion.exception.InformativeException;
|
import us.myles.ViaVersion.exception.InformativeException;
|
||||||
import us.myles.ViaVersion.packets.Direction;
|
import us.myles.ViaVersion.packets.Direction;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
|
||||||
import us.myles.ViaVersion.util.PipelineUtil;
|
import us.myles.ViaVersion.util.PipelineUtil;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -45,7 +44,7 @@ public class PacketWrapper {
|
|||||||
* @param <T> The return type of the type you wish to get.
|
* @param <T> The return type of the type you wish to get.
|
||||||
* @param index The index of the part (relative to the type)
|
* @param index The index of the part (relative to the type)
|
||||||
* @return The requested type or throws ArrayIndexOutOfBounds
|
* @return The requested type or throws ArrayIndexOutOfBounds
|
||||||
* @throws Exception If it fails to find it, an exception will be thrown.
|
* @throws InformativeException If it fails to find it, an exception will be thrown.
|
||||||
*/
|
*/
|
||||||
public <T> T get(Type<T> type, int index) throws Exception {
|
public <T> T get(Type<T> type, int index) throws Exception {
|
||||||
int currentIndex = 0;
|
int currentIndex = 0;
|
||||||
@ -110,7 +109,7 @@ public class PacketWrapper {
|
|||||||
* @param <T> The return type of the type you wish to set.
|
* @param <T> The return type of the type you wish to set.
|
||||||
* @param index The index of the part (relative to the type)
|
* @param index The index of the part (relative to the type)
|
||||||
* @param value The value of the part you wish to set it to.
|
* @param value The value of the part you wish to set it to.
|
||||||
* @throws Exception If it fails to set it, an exception will be thrown.
|
* @throws InformativeException If it fails to set it, an exception will be thrown.
|
||||||
*/
|
*/
|
||||||
public <T> void set(Type<T> type, int index, T value) throws Exception {
|
public <T> void set(Type<T> type, int index, T value) throws Exception {
|
||||||
int currentIndex = 0;
|
int currentIndex = 0;
|
||||||
@ -133,7 +132,7 @@ public class PacketWrapper {
|
|||||||
* @param type The type you wish to read
|
* @param type The type you wish to read
|
||||||
* @param <T> The return type of the type you wish to read.
|
* @param <T> The return type of the type you wish to read.
|
||||||
* @return The requested type
|
* @return The requested type
|
||||||
* @throws Exception If it fails to read
|
* @throws InformativeException If it fails to read
|
||||||
*/
|
*/
|
||||||
public <T> T read(Type<T> type) throws Exception {
|
public <T> T read(Type<T> type) throws Exception {
|
||||||
if (type == Type.NOTHING) return null;
|
if (type == Type.NOTHING) return null;
|
||||||
@ -215,7 +214,7 @@ public class PacketWrapper {
|
|||||||
* Write the current output to a buffer.
|
* Write the current output to a buffer.
|
||||||
*
|
*
|
||||||
* @param buffer The buffer to write to.
|
* @param buffer The buffer to write to.
|
||||||
* @throws Exception Throws an exception if it fails to write a value.
|
* @throws InformativeException Throws an exception if it fails to write a value.
|
||||||
*/
|
*/
|
||||||
public void writeToBuffer(ByteBuf buffer) throws Exception {
|
public void writeToBuffer(ByteBuf buffer) throws Exception {
|
||||||
if (id != -1) {
|
if (id != -1) {
|
||||||
|
@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.Via;
|
|||||||
import us.myles.ViaVersion.api.ViaVersionConfig;
|
import us.myles.ViaVersion.api.ViaVersionConfig;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.exception.CancelException;
|
import us.myles.ViaVersion.exception.CancelException;
|
||||||
|
import us.myles.ViaVersion.exception.InformativeException;
|
||||||
import us.myles.ViaVersion.packets.Direction;
|
import us.myles.ViaVersion.packets.Direction;
|
||||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||||
import us.myles.ViaVersion.util.PipelineUtil;
|
import us.myles.ViaVersion.util.PipelineUtil;
|
||||||
@ -294,7 +295,9 @@ public class UserConnection {
|
|||||||
* @param buf ByteBuf with packet id and packet contents
|
* @param buf ByteBuf with packet id and packet contents
|
||||||
* @param cancelSupplier Function called with original CancelException for generating the Exception used when
|
* @param cancelSupplier Function called with original CancelException for generating the Exception used when
|
||||||
* packet is cancelled
|
* packet is cancelled
|
||||||
* @throws Exception when transforming failed or this packet is cancelled
|
* @throws CancelException if the packet should be cancelled
|
||||||
|
* @throws InformativeException if packet transforming failed
|
||||||
|
* @throws Exception if any other processing outside of transforming fails
|
||||||
*/
|
*/
|
||||||
public void transformOutgoing(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception {
|
public void transformOutgoing(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception {
|
||||||
if (!buf.isReadable()) return;
|
if (!buf.isReadable()) return;
|
||||||
@ -307,7 +310,9 @@ public class UserConnection {
|
|||||||
* @param buf ByteBuf with packet id and packet contents
|
* @param buf ByteBuf with packet id and packet contents
|
||||||
* @param cancelSupplier Function called with original CancelException for generating the Exception used when
|
* @param cancelSupplier Function called with original CancelException for generating the Exception used when
|
||||||
* packet is cancelled
|
* packet is cancelled
|
||||||
* @throws Exception when transforming failed or this packet is cancelled
|
* @throws CancelException if the packet should be cancelled
|
||||||
|
* @throws InformativeException if packet transforming failed
|
||||||
|
* @throws Exception if any other processing outside of transforming fails
|
||||||
*/
|
*/
|
||||||
public void transformIncoming(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception {
|
public void transformIncoming(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception {
|
||||||
if (!buf.isReadable()) return;
|
if (!buf.isReadable()) return;
|
||||||
|
@ -17,7 +17,7 @@ public class InformativeException extends Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public InformativeException addSource(Class<?> sourceClazz) {
|
public InformativeException addSource(Class<?> sourceClazz) {
|
||||||
return set("Source #" + sources++, getSource(sourceClazz));
|
return set("Source " + sources++, getSource(sourceClazz));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSource(Class<?> sourceClazz) {
|
private String getSource(Class<?> sourceClazz) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren