3
0
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:
creeper123123321 2019-04-27 13:34:35 -03:00
Ursprung 7b29972af0
Commit 87eceb5264
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1
5 geänderte Dateien mit 34 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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;
}
}
}

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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();

Datei anzeigen

@ -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