diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitDecodeHandler.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitDecodeHandler.java index 3fd82bb7f..8243bfdd9 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitDecodeHandler.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitDecodeHandler.java @@ -3,11 +3,11 @@ package us.myles.ViaVersion.bukkit.handlers; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; -import io.netty.handler.codec.CodecException; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.bukkit.util.NMSUtil; import us.myles.ViaVersion.exception.CancelCodecException; import us.myles.ViaVersion.exception.CancelDecoderException; +import us.myles.ViaVersion.exception.InformativeException; import us.myles.ViaVersion.util.PipelineUtil; import java.lang.reflect.InvocationTargetException; @@ -57,7 +57,7 @@ public class BukkitDecodeHandler extends ByteToMessageDecoder { if (PipelineUtil.containsCause(cause, CancelCodecException.class)) return; // ProtocolLib compat 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 } } diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java index 9be48c3e6..41e73c357 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java @@ -2,12 +2,12 @@ package us.myles.ViaVersion.bukkit.handlers; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.CodecException; import io.netty.handler.codec.MessageToByteEncoder; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.bukkit.util.NMSUtil; import us.myles.ViaVersion.exception.CancelCodecException; import us.myles.ViaVersion.exception.CancelEncoderException; +import us.myles.ViaVersion.exception.InformativeException; import us.myles.ViaVersion.handlers.ChannelHandlerContextWrapper; import us.myles.ViaVersion.handlers.ViaHandler; 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 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 } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java b/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java index eb103c969..695d00c9a 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java +++ b/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java @@ -12,7 +12,6 @@ import us.myles.ViaVersion.exception.CancelException; import us.myles.ViaVersion.exception.InformativeException; import us.myles.ViaVersion.packets.Direction; import us.myles.ViaVersion.packets.State; -import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.util.PipelineUtil; import java.io.IOException; @@ -45,7 +44,7 @@ public class PacketWrapper { * @param The return type of the type you wish to get. * @param index The index of the part (relative to the type) * @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 get(Type type, int index) throws Exception { int currentIndex = 0; @@ -110,7 +109,7 @@ public class PacketWrapper { * @param The return type of the type you wish to set. * @param index The index of the part (relative to the type) * @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 void set(Type type, int index, T value) throws Exception { int currentIndex = 0; @@ -133,7 +132,7 @@ public class PacketWrapper { * @param type The type you wish to read * @param The return type of the type you wish to read. * @return The requested type - * @throws Exception If it fails to read + * @throws InformativeException If it fails to read */ public T read(Type type) throws Exception { if (type == Type.NOTHING) return null; @@ -215,7 +214,7 @@ public class PacketWrapper { * Write the current output to a buffer. * * @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 { if (id != -1) { diff --git a/common/src/main/java/us/myles/ViaVersion/api/data/UserConnection.java b/common/src/main/java/us/myles/ViaVersion/api/data/UserConnection.java index 804bba92a..3c0c97481 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/data/UserConnection.java +++ b/common/src/main/java/us/myles/ViaVersion/api/data/UserConnection.java @@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.ViaVersionConfig; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.exception.CancelException; +import us.myles.ViaVersion.exception.InformativeException; import us.myles.ViaVersion.packets.Direction; import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.util.PipelineUtil; @@ -294,7 +295,9 @@ public class UserConnection { * @param buf ByteBuf with packet id and packet contents * @param cancelSupplier Function called with original CancelException for generating the Exception used when * 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 cancelSupplier) throws Exception { if (!buf.isReadable()) return; @@ -307,7 +310,9 @@ public class UserConnection { * @param buf ByteBuf with packet id and packet contents * @param cancelSupplier Function called with original CancelException for generating the Exception used when * 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 cancelSupplier) throws Exception { if (!buf.isReadable()) return; diff --git a/common/src/main/java/us/myles/ViaVersion/exception/InformativeException.java b/common/src/main/java/us/myles/ViaVersion/exception/InformativeException.java index cec74fff3..0cea96d12 100644 --- a/common/src/main/java/us/myles/ViaVersion/exception/InformativeException.java +++ b/common/src/main/java/us/myles/ViaVersion/exception/InformativeException.java @@ -17,7 +17,7 @@ public class InformativeException extends Exception { } public InformativeException addSource(Class sourceClazz) { - return set("Source #" + sources++, getSource(sourceClazz)); + return set("Source " + sources++, getSource(sourceClazz)); } private String getSource(Class sourceClazz) {