(1.2.4) Fixed UnsupportedOperationException in EaglerXBungee

This commit is contained in:
lax1dude 2024-06-03 18:45:54 -07:00
parent e58e9bcb5d
commit 8ffd102664
6 changed files with 42 additions and 23 deletions

View File

@ -108,29 +108,42 @@ public class EaglerMinecraftDecoder extends MessageToMessageDecoder<WebSocketFra
} }
private PacketWrapper wrapPacket(DefinedPacket packet, ByteBuf buf, Protocol protocol) { private PacketWrapper wrapPacket(DefinedPacket packet, ByteBuf buf, Protocol protocol) {
PacketWrapper pkt; boolean isInputDirect = buf.isDirect();
if (packetWrapperConstructor != null) { if(!isInputDirect) {
try { int len = buf.readableBytes();
pkt = packetWrapperConstructor.newInstance(packet, buf); ByteBuf newBuf = buf.alloc().directBuffer(len, len);
buf.retain(); buf.readBytes(newBuf, len);
return pkt; buf = newBuf;
} catch (IllegalAccessException | InvocationTargetException | InstantiationException var14) {
throw new RuntimeException(var14);
}
} }
try { try {
pkt = new PacketWrapper(packet, buf, protocol); PacketWrapper pkt;
buf.retain(); if (packetWrapperConstructor != null) {
return pkt; try {
} catch (NoSuchMethodError var15) { pkt = packetWrapperConstructor.newInstance(packet, buf);
buf.retain();
return pkt;
} catch (IllegalAccessException | InvocationTargetException | InstantiationException var14) {
throw new RuntimeException(var14);
}
}
try { try {
packetWrapperConstructor = PacketWrapper.class.getDeclaredConstructor(DefinedPacket.class, ByteBuf.class); pkt = new PacketWrapper(packet, buf, protocol);
pkt = packetWrapperConstructor.newInstance(packet, buf);
buf.retain(); buf.retain();
return pkt; return pkt;
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | InstantiationException var13) { } catch (NoSuchMethodError var15) {
throw new RuntimeException(var13); try {
packetWrapperConstructor = PacketWrapper.class.getDeclaredConstructor(DefinedPacket.class, ByteBuf.class);
pkt = packetWrapperConstructor.newInstance(packet, buf);
buf.retain();
return pkt;
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | InstantiationException var13) {
throw new RuntimeException(var13);
}
}
}finally {
if(!isInputDirect) {
buf.release();
} }
} }
} }

View File

@ -45,6 +45,7 @@ public class EaglerUpdateSvc {
private static final List<ClientCertificateHolder> certs = new ArrayList(); private static final List<ClientCertificateHolder> certs = new ArrayList();
private static final Map<String,CachedClientCertificate> certsCache = new HashMap(); private static final Map<String,CachedClientCertificate> certsCache = new HashMap();
private static final Set<String> deadURLS = new HashSet();
private static class CachedClientCertificate { private static class CachedClientCertificate {
private final ClientCertificateHolder cert; private final ClientCertificateHolder cert;
@ -110,6 +111,8 @@ public class EaglerUpdateSvc {
if(code / 100 != 2) { if(code / 100 != 2) {
con.disconnect(); con.disconnect();
throw new IOException("Response code was " + code); throw new IOException("Response code was " + code);
}else {
deadURLS.remove(str);
} }
ByteArrayOutputStream bao = new ByteArrayOutputStream(32767); ByteArrayOutputStream bao = new ByteArrayOutputStream(32767);
try(InputStream is = con.getInputStream()) { try(InputStream is = con.getInputStream()) {
@ -140,8 +143,10 @@ public class EaglerUpdateSvc {
} }
log.info("Downloading new certificate: " + str); log.info("Downloading new certificate: " + str);
}catch(Throwable t) { }catch(Throwable t) {
log.severe("Failed to download certificate: " + str); if(deadURLS.add(str)) {
log.severe("Reason: " + t.toString()); log.severe("Failed to download certificate: " + str);
log.severe("Reason: " + t.toString());
}
} }
} }
long millis = System.currentTimeMillis(); long millis = System.currentTimeMillis();

View File

@ -815,7 +815,7 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
EaglerXBungee.logger().info("[" + ctx.channel().remoteAddress() + "]: Logged in as '" + usernameStr + "'"); EaglerXBungee.logger().info("[" + ctx.channel().remoteAddress() + "]: Logged in as '" + usernameStr + "'");
final UserConnection userCon = eaglerCon.userConnection = new UserConnection(bungee, ch, usernameStr, initialHandler); final UserConnection userCon = new UserConnection(bungee, ch, usernameStr, initialHandler);
userCon.setCompressionThreshold(-1); userCon.setCompressionThreshold(-1);
try { try {
if (!userCon.init()) { if (!userCon.init()) {
@ -991,6 +991,7 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
Callback<PostLoginEvent> complete = new Callback<PostLoginEvent>() { Callback<PostLoginEvent> complete = new Callback<PostLoginEvent>() {
@Override @Override
public void done(PostLoginEvent result, Throwable error) { public void done(PostLoginEvent result, Throwable error) {
eaglerCon.userConnection = userCon;
eaglerCon.hasBeenForwarded = true; eaglerCon.hasBeenForwarded = true;
if (ch.isClosed()) { if (ch.isClosed()) {
return; return;

View File

@ -1,5 +1,5 @@
name: EaglercraftXBungee name: EaglercraftXBungee
main: net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.EaglerXBungee main: net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.EaglerXBungee
version: 1.2.3 version: 1.2.4
description: Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks description: Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks
author: lax1dude author: lax1dude

View File

@ -1 +1 @@
1.2.3 1.2.4