Skip to content

Commit 790b33a

Browse files
committed
update a LOT
todo: 1.8 capes and fnaw skins
1 parent 6cc8a79 commit 790b33a

File tree

8 files changed

+713
-295
lines changed

8 files changed

+713
-295
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ repositories {
1010
}
1111

1212
dependencies {
13-
implementation files("libs/ViaProxy-3.0.22-SNAPSHOT+java8.jar")
13+
implementation files("libs/ViaProxy-3.2.0-SNAPSHOT+java8.jar")
1414
}

src/main/java/me/ayunami2000/ayunViaProxyEagUtils/EaglerServerHandler.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.google.gson.JsonElement;
66
import com.google.gson.JsonObject;
77
import com.google.gson.JsonParser;
8+
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
89
import com.viaversion.viaversion.util.ChatColorUtil;
910
import io.netty.buffer.ByteBuf;
1011
import io.netty.buffer.ByteBufUtil;
@@ -24,7 +25,6 @@
2425
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ClientboundPackets1_5_2;
2526
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ServerboundPackets1_5_2;
2627
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4;
27-
import net.raphimc.vialoader.util.VersionEnum;
2828
import net.raphimc.viaproxy.proxy.session.LegacyProxyConnection;
2929
import net.raphimc.viaproxy.proxy.session.ProxyConnection;
3030
import net.raphimc.viaproxy.proxy.util.ExceptionUtil;
@@ -43,7 +43,7 @@
4343
import java.util.concurrent.TimeUnit;
4444

4545
public class EaglerServerHandler extends MessageToMessageCodec<WebSocketFrame, ByteBuf> {
46-
private final VersionEnum version;
46+
private final ProtocolVersion version;
4747
private final String password;
4848
private final NetClient proxyConnection;
4949
private final Map<UUID, String> uuidStringMap = new HashMap<>();
@@ -53,7 +53,7 @@ public class EaglerServerHandler extends MessageToMessageCodec<WebSocketFrame, B
5353
private ByteBuf serverBoundPartialPacket = Unpooled.EMPTY_BUFFER;
5454
private ByteBuf clientBoundPartialPacket = Unpooled.EMPTY_BUFFER;
5555
public EaglerServerHandler(NetClient proxyConnection, String password) {
56-
this.version = proxyConnection instanceof ProxyConnection ? ((ProxyConnection) proxyConnection).getServerVersion() : VersionEnum.r1_5_2;
56+
this.version = proxyConnection instanceof ProxyConnection ? ((ProxyConnection) proxyConnection).getServerVersion() : LegacyProtocolVersion.r1_5_2;
5757
this.password = password;
5858
this.proxyConnection = proxyConnection;
5959
}
@@ -71,7 +71,7 @@ public void encode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
7171
out.add(Unpooled.EMPTY_BUFFER);
7272
return;
7373
}
74-
if (version.isNewerThan(VersionEnum.r1_6_4)) {
74+
if (version.newerThanOrEqualTo(ProtocolVersion.v1_7_2)) {
7575
if (in.readableBytes() >= 2 && in.getUnsignedByte(0) == 0xFE && in.getUnsignedByte(1) == 0x01) {
7676
handshakeState = -1;
7777
out.add(new TextWebSocketFrame("Accept: MOTD"));
@@ -282,7 +282,7 @@ public void decode(ChannelHandlerContext ctx, WebSocketFrame in, List<Object> ou
282282
ByteBuf bb = ctx.alloc().buffer();
283283
bb.writeByte((byte) 0xFF);
284284
StringBuilder sb = new StringBuilder("\u00A71\0");
285-
sb.append(LegacyProtocolVersion.getRealProtocolVersion(version.getVersion())).append("\0");
285+
sb.append(version.getVersion()).append("\0");
286286
sb.append(version.getName()).append("\0");
287287
sb.append(motdSb).append("\0");
288288
sb.append(online).append("\0");
@@ -307,7 +307,7 @@ public void decode(ChannelHandlerContext ctx, WebSocketFrame in, List<Object> ou
307307
JsonObject resp = new JsonObject();
308308
JsonObject versionObj = new JsonObject();
309309
versionObj.addProperty("name", version.getName());
310-
versionObj.addProperty("protocol", LegacyProtocolVersion.getRealProtocolVersion(version.getVersion()));
310+
versionObj.addProperty("protocol", version.getVersion());
311311
resp.add("version", versionObj);
312312
JsonObject playersObj = new JsonObject();
313313
playersObj.addProperty("max", max);
@@ -358,7 +358,7 @@ public void decode(ChannelHandlerContext ctx, WebSocketFrame in, List<Object> ou
358358
JsonObject resp = new JsonObject();
359359
JsonObject versionObj = new JsonObject();
360360
versionObj.addProperty("name", version.getName());
361-
versionObj.addProperty("protocol", LegacyProtocolVersion.getRealProtocolVersion(version.getVersion()));
361+
versionObj.addProperty("protocol", version.getVersion());
362362
resp.add("version", versionObj);
363363
JsonObject playersObj = new JsonObject();
364364
playersObj.addProperty("max", serverInfo.max);
@@ -401,7 +401,7 @@ public void decode(ChannelHandlerContext ctx, WebSocketFrame in, List<Object> ou
401401
handshakeState = -1;
402402
return;
403403
}
404-
if (version.isNewerThan(VersionEnum.r1_6_4)) {
404+
if (version.newerThanOrEqualTo(ProtocolVersion.v1_7_2)) {
405405
if (handshakeState == 0) {
406406
out.add(Unpooled.EMPTY_BUFFER);
407407
} else if (handshakeState == 1) {
@@ -440,7 +440,7 @@ public void decode(ChannelHandlerContext ctx, WebSocketFrame in, List<Object> ou
440440
bb.writeBytes(clientBoundPartialPacket);
441441
clientBoundPartialPacket.release();
442442
clientBoundPartialPacket = Unpooled.EMPTY_BUFFER;
443-
bb.writeBytes(in.content());
443+
bb.writeBytes(in.content()); // todo: do i need to reset this??????
444444
int readerIndex = 0;
445445
try {
446446
while (bb.isReadable()) {

0 commit comments

Comments
 (0)