Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-20 06:50:08 +01:00
Use cached cancel exception when not in debug mode
Dieser Commit ist enthalten in:
Ursprung
7b29972af0
Commit
87eceb5264
@ -5,6 +5,7 @@ import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageEncoder;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.bungee.util.BungeePipelineUtil;
|
||||
@ -28,7 +29,7 @@ public class BungeeEncodeHandler extends MessageToMessageEncoder<ByteBuf> {
|
||||
@Override
|
||||
protected void encode(final ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
|
||||
if (bytebuf.readableBytes() == 0) {
|
||||
throw new CancelException();
|
||||
throw Via.getManager().isDebug() ? new CancelException() : CancelException.CACHED;
|
||||
}
|
||||
boolean needsCompress = false;
|
||||
if (!handledCompression) {
|
||||
|
@ -167,8 +167,9 @@ public abstract class Protocol {
|
||||
// remap
|
||||
if (protocolPacket.getRemapper() != null) {
|
||||
protocolPacket.getRemapper().remap(packetWrapper);
|
||||
if (packetWrapper.isCancelled())
|
||||
throw new CancelException();
|
||||
if (packetWrapper.isCancelled()) {
|
||||
throw Via.getManager().isDebug() ? new CancelException() : CancelException.CACHED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,29 @@
|
||||
package us.myles.ViaVersion.exception;
|
||||
|
||||
public class CancelException extends Exception {
|
||||
public static final CancelException CACHED = new CancelException("Cached - Enable /viaver debug to not use cached exception") {
|
||||
@Override
|
||||
public synchronized Throwable fillInStackTrace() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
public CancelException() {
|
||||
}
|
||||
|
||||
public CancelException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CancelException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public CancelException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public CancelException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.exception.CancelException;
|
||||
@ -37,7 +38,7 @@ public class SpongeEncodeHandler extends MessageToByteEncoder {
|
||||
}
|
||||
}
|
||||
if (bytebuf.readableBytes() == 0) {
|
||||
throw new CancelException();
|
||||
throw Via.getManager().isDebug() ? new CancelException() : CancelException.CACHED;
|
||||
}
|
||||
// Increment sent
|
||||
info.incrementSent();
|
||||
|
@ -9,6 +9,7 @@ import io.netty.handler.codec.MessageToMessageEncoder;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.exception.CancelException;
|
||||
@ -28,7 +29,7 @@ public class VelocityEncodeHandler extends MessageToMessageEncoder<ByteBuf> {
|
||||
@Override
|
||||
protected void encode(final ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
|
||||
if (bytebuf.readableBytes() == 0) {
|
||||
throw new CancelException();
|
||||
throw Via.getManager().isDebug() ? new CancelException() : CancelException.CACHED;
|
||||
}
|
||||
boolean needsCompress = false;
|
||||
if (!handledCompression
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren