Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 09:00:09 +01:00
Merge pull request #1833 from KennyTV/master
Only print InformativeException cases in codec handlers
Dieser Commit ist enthalten in:
Commit
e5ba76e006
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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 <T> 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> T get(Type<T> type, int index) throws Exception {
|
||||
int currentIndex = 0;
|
||||
@ -110,7 +109,7 @@ public class PacketWrapper {
|
||||
* @param <T> 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 <T> void set(Type<T> 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 <T> 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> T read(Type<T> 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) {
|
||||
|
@ -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<Throwable, Exception> 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<Throwable, Exception> cancelSupplier) throws Exception {
|
||||
if (!buf.isReadable()) return;
|
||||
|
@ -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) {
|
||||
|
@ -99,11 +99,11 @@ public class WorldPackets {
|
||||
|
||||
String id = idTag.getValue();
|
||||
if (id.equals("minecraft:conduit")) {
|
||||
StringTag targetUuidTag = compoundTag.remove("target_uuid");
|
||||
if (targetUuidTag == null) return;
|
||||
Tag targetUuidTag = compoundTag.remove("target_uuid");
|
||||
if (!(targetUuidTag instanceof StringTag)) return;
|
||||
|
||||
// target_uuid -> Target
|
||||
UUID targetUuid = UUID.fromString(targetUuidTag.getValue());
|
||||
UUID targetUuid = UUID.fromString((String) targetUuidTag.getValue());
|
||||
compoundTag.put(new IntArrayTag("Target", UUIDIntArrayType.uuidToIntArray(targetUuid)));
|
||||
} else if (id.equals("minecraft:skull") && compoundTag.get("Owner") instanceof CompoundTag) {
|
||||
CompoundTag ownerTag = compoundTag.remove("Owner");
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren