From 7f1cb82cf6ef05c335510c4b34ffc5a6ef82bf83 Mon Sep 17 00:00:00 2001
From: RaphiMC <50594595+RaphiMC@users.noreply.github.com>
Date: Fri, 23 Aug 2024 15:08:26 +0200
Subject: [PATCH] Updated Via API usage
---
README.md | 2 -
.../api/protocol/PreNettyBaseProtocol.java | 54 -------------------
.../storage/AlphaInventoryTracker.java | 20 +++----
.../storage/BlockDigStorage.java | 4 +-
.../storage/ClassicLevelStorage.java | 12 ++---
.../storage/ClassicOpLevelStorage.java | 8 +--
.../storage/ClassicServerTitleStorage.java | 8 +--
.../storage/PendingBlocksTracker.java | 2 +-
.../storage/EntityTracker.java | 2 +-
.../Protocolr1_6_4Tor1_7_2_5.java | 13 +++--
.../storage/EntityTracker.java | 2 +-
.../storage/TablistStorage.java | 4 +-
12 files changed, 40 insertions(+), 91 deletions(-)
delete mode 100644 src/main/java/net/raphimc/vialegacy/api/protocol/PreNettyBaseProtocol.java
diff --git a/README.md b/README.md
index b2037cc..9e0cc86 100644
--- a/README.md
+++ b/README.md
@@ -106,8 +106,6 @@ ViaLegacy needs to have custom netty handlers in the pipeline which handle <= 1.
To implement the changes you should add something similar to the following lines to your netty pipeline (After the ViaVersion handlers are added):
```java
if (serverTargetVersion.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) { // Only add those handlers if the server version is <= 1.6.4
- user.getProtocolInfo().getPipeline().add(PreNettyBaseProtocol.INSTANCE); // Allow to intercept the handshake packet
-
// You can either add a codec (if your pipeline is built for that)
channel.pipeline().addBefore("length-codec", "vialegacy-pre-netty-length-codec", new PreNettyLengthCodec(user));
// or two seperate netty handlers
diff --git a/src/main/java/net/raphimc/vialegacy/api/protocol/PreNettyBaseProtocol.java b/src/main/java/net/raphimc/vialegacy/api/protocol/PreNettyBaseProtocol.java
deleted file mode 100644
index 61e745f..0000000
--- a/src/main/java/net/raphimc/vialegacy/api/protocol/PreNettyBaseProtocol.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * This file is part of ViaLegacy - https://github.com/RaphiMC/ViaLegacy
- * Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package net.raphimc.vialegacy.api.protocol;
-
-import com.viaversion.viaversion.api.connection.UserConnection;
-import com.viaversion.viaversion.api.protocol.packet.State;
-import com.viaversion.viaversion.api.type.Types;
-import com.viaversion.viaversion.protocols.base.ServerboundHandshakePackets;
-import com.viaversion.viaversion.protocols.base.v1_7.ServerboundBaseProtocol1_7;
-import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.HandshakeStorage;
-import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ProtocolMetadataStorage;
-
-public class PreNettyBaseProtocol extends ServerboundBaseProtocol1_7 {
-
- public static final PreNettyBaseProtocol INSTANCE = new PreNettyBaseProtocol();
-
- private PreNettyBaseProtocol() {
- this.initialize();
- }
-
- @Override
- protected void registerPackets() {
- super.registerPackets();
- this.registerServerbound(State.HANDSHAKE, ServerboundHandshakePackets.CLIENT_INTENTION.getId(), ServerboundHandshakePackets.CLIENT_INTENTION.getId(), wrapper -> {
- wrapper.cancel();
- wrapper.read(Types.VAR_INT); // protocolVersion
- final String hostname = wrapper.read(Types.STRING); // hostName
- final int port = wrapper.read(Types.UNSIGNED_SHORT); // port
- wrapper.user().put(new HandshakeStorage(hostname, port));
- });
- }
-
- @Override
- public void init(final UserConnection user) {
- super.init(user);
- user.put(new ProtocolMetadataStorage());
- }
-
-}
diff --git a/src/main/java/net/raphimc/vialegacy/protocol/alpha/a1_2_3_5_1_2_6tob1_0_1_1_1/storage/AlphaInventoryTracker.java b/src/main/java/net/raphimc/vialegacy/protocol/alpha/a1_2_3_5_1_2_6tob1_0_1_1_1/storage/AlphaInventoryTracker.java
index 7dba43d..8572197 100644
--- a/src/main/java/net/raphimc/vialegacy/protocol/alpha/a1_2_3_5_1_2_6tob1_0_1_1_1/storage/AlphaInventoryTracker.java
+++ b/src/main/java/net/raphimc/vialegacy/protocol/alpha/a1_2_3_5_1_2_6tob1_0_1_1_1/storage/AlphaInventoryTracker.java
@@ -71,19 +71,19 @@ public class AlphaInventoryTracker extends StoredObject {
for (int i = 1; i <= 9; i++) {
final Item item = this.openContainerItems[i];
if (item == null) continue;
- dropItem(this.getUser(), item, false);
+ dropItem(this.user(), item, false);
this.openContainerItems[i] = null;
}
}
for (int i = 0; i < 4; i++) {
final Item item = this.craftingInventory[i];
if (item == null) continue;
- dropItem(this.getUser(), item, false);
+ dropItem(this.user(), item, false);
this.craftingInventory[i] = null;
}
if (this.cursorItem != null) {
- dropItem(this.getUser(), this.cursorItem, false);
+ dropItem(this.user(), this.cursorItem, false);
this.cursorItem = null;
}
this.openWindowType = -1;
@@ -98,10 +98,10 @@ public class AlphaInventoryTracker extends StoredObject {
if (slot == -999) {
if (this.cursorItem != null) {
if (leftClick) {
- dropItem(this.getUser(), this.cursorItem, false);
+ dropItem(this.user(), this.cursorItem, false);
this.cursorItem = null;
} else {
- dropItem(this.getUser(), this.splitStack(this.cursorItem, 1), false);
+ dropItem(this.user(), this.splitStack(this.cursorItem, 1), false);
}
}
} else {
@@ -255,8 +255,8 @@ public class AlphaInventoryTracker extends StoredObject {
if (direction == 255) { // interact
AlphaItems.doInteract(handItem);
} else { // place
- final IdAndData placedAgainst = this.getUser().get(ChunkTracker.class).getBlockNotNull(position);
- final IdAndData targetBlock = this.getUser().get(ChunkTracker.class).getBlockNotNull(position.getRelative(BlockFaceUtil.getFace(direction)));
+ final IdAndData placedAgainst = this.user().get(ChunkTracker.class).getBlockNotNull(position);
+ final IdAndData targetBlock = this.user().get(ChunkTracker.class).getBlockNotNull(position.getRelative(BlockFaceUtil.getFace(direction)));
AlphaItems.doPlace(handItem, direction, placedAgainst);
if (handItem.identifier() < 256 || handItem.identifier() == ItemList1_6.reed.itemId()) { // block item
@@ -339,7 +339,7 @@ public class AlphaInventoryTracker extends StoredObject {
// Add support for cheating items and classic block placement
public void handleCreativeSetSlot(short slot, Item item) {
- if (!this.getUser().getProtocolInfo().serverProtocolVersion().equals(LegacyProtocolVersion.c0_30cpe)) item = fixItem(item);
+ if (!this.user().getProtocolInfo().serverProtocolVersion().equals(LegacyProtocolVersion.c0_30cpe)) item = fixItem(item);
if (slot <= 0) return;
if (slot <= 4) {
@@ -404,7 +404,7 @@ public class AlphaInventoryTracker extends StoredObject {
}
private void updateInventorySlot(final byte windowId, final short slot, final Item item) {
- final PacketWrapper setSlot = PacketWrapper.create(ClientboundPacketsb1_1.CONTAINER_SET_SLOT, this.getUser());
+ final PacketWrapper setSlot = PacketWrapper.create(ClientboundPacketsb1_1.CONTAINER_SET_SLOT, this.user());
setSlot.write(Types.BYTE, windowId); // window id
setSlot.write(Types.SHORT, slot); // slot
setSlot.write(Typesb1_1.NBTLESS_ITEM, copyItem(item)); // item
@@ -422,7 +422,7 @@ public class AlphaInventoryTracker extends StoredObject {
}
private void updateInventory(final byte windowId, final Item[] items) {
- final PacketWrapper windowItems = PacketWrapper.create(ClientboundPacketsb1_1.CONTAINER_SET_CONTENT, this.getUser());
+ final PacketWrapper windowItems = PacketWrapper.create(ClientboundPacketsb1_1.CONTAINER_SET_CONTENT, this.user());
windowItems.write(Types.BYTE, windowId); // window id
windowItems.write(Types1_4_2.NBTLESS_ITEM_ARRAY, copyItems(items)); // items
windowItems.send(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class);
diff --git a/src/main/java/net/raphimc/vialegacy/protocol/beta/b1_2_0_2tob1_3_0_1/storage/BlockDigStorage.java b/src/main/java/net/raphimc/vialegacy/protocol/beta/b1_2_0_2tob1_3_0_1/storage/BlockDigStorage.java
index 73726f6..d9c5857 100644
--- a/src/main/java/net/raphimc/vialegacy/protocol/beta/b1_2_0_2tob1_3_0_1/storage/BlockDigStorage.java
+++ b/src/main/java/net/raphimc/vialegacy/protocol/beta/b1_2_0_2tob1_3_0_1/storage/BlockDigStorage.java
@@ -36,12 +36,12 @@ public class BlockDigStorage extends StoredObject {
public void tick() {
if (this.tick >= 5) {
- Protocolb1_2_0_2Tob1_3_0_1.sendBlockDigPacket(this.getUser(), (byte) 0, this.position, this.facing);
+ Protocolb1_2_0_2Tob1_3_0_1.sendBlockDigPacket(this.user(), (byte) 0, this.position, this.facing);
this.tick = 0;
} else {
this.tick++;
}
- Protocolb1_2_0_2Tob1_3_0_1.sendBlockDigPacket(this.getUser(), (byte) 1, this.position, this.facing);
+ Protocolb1_2_0_2Tob1_3_0_1.sendBlockDigPacket(this.user(), (byte) 1, this.position, this.facing);
}
}
diff --git a/src/main/java/net/raphimc/vialegacy/protocol/classic/c0_28_30toa1_0_15/storage/ClassicLevelStorage.java b/src/main/java/net/raphimc/vialegacy/protocol/classic/c0_28_30toa1_0_15/storage/ClassicLevelStorage.java
index 825c0df..ce1d4a0 100644
--- a/src/main/java/net/raphimc/vialegacy/protocol/classic/c0_28_30toa1_0_15/storage/ClassicLevelStorage.java
+++ b/src/main/java/net/raphimc/vialegacy/protocol/classic/c0_28_30toa1_0_15/storage/ClassicLevelStorage.java
@@ -82,7 +82,7 @@ public class ClassicLevelStorage extends StoredObject {
throw new IllegalStateException("Failed to load level", e);
}
- final short maxChunkSectionCount = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class).getMaxChunkSectionCount(this.getUser());
+ final short maxChunkSectionCount = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class).getMaxChunkSectionCount(this.user());
this.chunkXCount = sizeX >> 4;
if (sizeX % 16 != 0) this.chunkXCount++;
@@ -103,7 +103,7 @@ public class ClassicLevelStorage extends StoredObject {
if (chunkX < 0 || chunkX >= this.chunkXCount || chunkZ < 0 || chunkZ >= this.chunkZCount) {
final Chunk chunk = ChunkUtil.createEmptyChunk(chunkX, chunkZ, Math.max(8, this.sectionYCount), this.sectionBitmask);
ChunkUtil.setDummySkylight(chunk, true);
- final PacketWrapper chunkData = PacketWrapper.create(ClientboundPacketsa1_0_15.LEVEL_CHUNK, this.getUser());
+ final PacketWrapper chunkData = PacketWrapper.create(ClientboundPacketsa1_0_15.LEVEL_CHUNK, this.user());
chunkData.write(Types1_1.CHUNK, chunk);
chunkData.send(Protocolc0_28_30Toa1_0_15.class);
}
@@ -113,11 +113,11 @@ public class ClassicLevelStorage extends StoredObject {
}
public void tick() {
- final ClassicPositionTracker positionTracker = this.getUser().get(ClassicPositionTracker.class);
+ final ClassicPositionTracker positionTracker = this.user().get(ClassicPositionTracker.class);
if (!positionTracker.spawned) return;
final long start = System.currentTimeMillis();
- this.getUser().getChannel().eventLoop().submit(() -> {
+ this.user().getChannel().eventLoop().submit(() -> {
ClassicLevelStorage.this.eventLoopPing = System.currentTimeMillis() - start;
});
@@ -151,7 +151,7 @@ public class ClassicLevelStorage extends StoredObject {
public void sendChunk(final ChunkCoord coord) {
if (!this.shouldSend(coord)) return;
- final ClassicBlockRemapper remapper = this.getUser().get(ClassicBlockRemapper.class);
+ final ClassicBlockRemapper remapper = this.user().get(ClassicBlockRemapper.class);
this.classicLevel.calculateLight(coord.chunkX * 16, coord.chunkZ * 16, this.subChunkXLength, this.subChunkZLength);
@@ -179,7 +179,7 @@ public class ClassicLevelStorage extends StoredObject {
this.loadedChunks.add(coord);
final Chunk viaChunk = new BaseChunk(coord.chunkX, coord.chunkZ, true, false, this.sectionBitmask, modernSections, new int[256], new ArrayList<>());
- final PacketWrapper chunkData = PacketWrapper.create(ClientboundPacketsa1_0_15.LEVEL_CHUNK, this.getUser());
+ final PacketWrapper chunkData = PacketWrapper.create(ClientboundPacketsa1_0_15.LEVEL_CHUNK, this.user());
chunkData.write(Types1_1.CHUNK, viaChunk);
chunkData.send(Protocolc0_28_30Toa1_0_15.class);
}
diff --git a/src/main/java/net/raphimc/vialegacy/protocol/classic/c0_28_30toa1_0_15/storage/ClassicOpLevelStorage.java b/src/main/java/net/raphimc/vialegacy/protocol/classic/c0_28_30toa1_0_15/storage/ClassicOpLevelStorage.java
index c39a096..9bab893 100644
--- a/src/main/java/net/raphimc/vialegacy/protocol/classic/c0_28_30toa1_0_15/storage/ClassicOpLevelStorage.java
+++ b/src/main/java/net/raphimc/vialegacy/protocol/classic/c0_28_30toa1_0_15/storage/ClassicOpLevelStorage.java
@@ -76,7 +76,7 @@ public class ClassicOpLevelStorage extends StoredObject {
statusMessage += " ";
statusMessage += this.respawn ? "§aRespawn" : "§cRespawn";
- final PacketWrapper chatMessage = PacketWrapper.create(ClientboundPacketsa1_0_15.CHAT, this.getUser());
+ final PacketWrapper chatMessage = PacketWrapper.create(ClientboundPacketsa1_0_15.CHAT, this.user());
chatMessage.write(Typesb1_7_0_3.STRING, statusMessage); // message
chatMessage.send(Protocolc0_28_30Toa1_0_15.class);
}
@@ -86,7 +86,7 @@ public class ClassicOpLevelStorage extends StoredObject {
this.opLevel = opLevel;
if (this.haxEnabled) {
- final ClassicServerTitleStorage serverTitleStorage = this.getUser().get(ClassicServerTitleStorage.class);
+ final ClassicServerTitleStorage serverTitleStorage = this.user().get(ClassicServerTitleStorage.class);
if (serverTitleStorage != null) { // Some servers update the op level before sending the login packet. Just ignore that because the op level is resent in the login packet.
this.updateHax(serverTitleStorage.isFlyEffectivelyEnabled(), serverTitleStorage.isNoclipEffectivelyEnabled(), serverTitleStorage.isSpeedEffectivelyEnabled(), serverTitleStorage.isRespawnEffectivelyEnabled());
}
@@ -98,8 +98,8 @@ public class ClassicOpLevelStorage extends StoredObject {
}
public void updateAbilities() {
- if (this.getUser().getProtocolInfo().getPipeline().contains(Protocolr1_2_1_3Tor1_2_4_5.class)) {
- final PacketWrapper playerAbilities = PacketWrapper.create(ClientboundPackets1_2_4.PLAYER_ABILITIES, this.getUser());
+ if (this.user().getProtocolInfo().getPipeline().contains(Protocolr1_2_1_3Tor1_2_4_5.class)) {
+ final PacketWrapper playerAbilities = PacketWrapper.create(ClientboundPackets1_2_4.PLAYER_ABILITIES, this.user());
playerAbilities.write(Types.BOOLEAN, true); // invulnerable
playerAbilities.write(Types.BOOLEAN, false); // flying
playerAbilities.write(Types.BOOLEAN, this.flying); // allow flying
diff --git a/src/main/java/net/raphimc/vialegacy/protocol/classic/c0_28_30toa1_0_15/storage/ClassicServerTitleStorage.java b/src/main/java/net/raphimc/vialegacy/protocol/classic/c0_28_30toa1_0_15/storage/ClassicServerTitleStorage.java
index f55e4b0..d9e3796 100644
--- a/src/main/java/net/raphimc/vialegacy/protocol/classic/c0_28_30toa1_0_15/storage/ClassicServerTitleStorage.java
+++ b/src/main/java/net/raphimc/vialegacy/protocol/classic/c0_28_30toa1_0_15/storage/ClassicServerTitleStorage.java
@@ -56,7 +56,7 @@ public class ClassicServerTitleStorage extends StoredObject {
}
public boolean isFlyEffectivelyEnabled() {
- final boolean isOp = this.getUser().get(ClassicOpLevelStorage.class).getOpLevel() >= 100;
+ final boolean isOp = this.user().get(ClassicOpLevelStorage.class).getOpLevel() >= 100;
return (this.isHaxDisabled() ? this.isFlyEnabled() : !this.isFlyDisabled()) || (isOp && this.isOphaxEnabled());
}
@@ -69,7 +69,7 @@ public class ClassicServerTitleStorage extends StoredObject {
}
public boolean isNoclipEffectivelyEnabled() {
- final boolean isOp = this.getUser().get(ClassicOpLevelStorage.class).getOpLevel() >= 100;
+ final boolean isOp = this.user().get(ClassicOpLevelStorage.class).getOpLevel() >= 100;
return (this.isHaxDisabled() ? this.isNoclipEnabled() : !this.isNoclipDisabled()) || (isOp && this.isOphaxEnabled());
}
@@ -82,7 +82,7 @@ public class ClassicServerTitleStorage extends StoredObject {
}
public boolean isRespawnEffectivelyEnabled() {
- final boolean isOp = this.getUser().get(ClassicOpLevelStorage.class).getOpLevel() >= 100;
+ final boolean isOp = this.user().get(ClassicOpLevelStorage.class).getOpLevel() >= 100;
return (this.isHaxDisabled() ? this.isRespawnEnabled() : !this.isRespawnDisabled()) || (isOp && this.isOphaxEnabled());
}
@@ -95,7 +95,7 @@ public class ClassicServerTitleStorage extends StoredObject {
}
public boolean isSpeedEffectivelyEnabled() {
- final boolean isOp = this.getUser().get(ClassicOpLevelStorage.class).getOpLevel() >= 100;
+ final boolean isOp = this.user().get(ClassicOpLevelStorage.class).getOpLevel() >= 100;
return (this.isHaxDisabled() ? this.isSpeedEnabled() : !this.isSpeedDisabled()) || (isOp && this.isOphaxEnabled());
}
diff --git a/src/main/java/net/raphimc/vialegacy/protocol/release/r1_1tor1_2_1_3/storage/PendingBlocksTracker.java b/src/main/java/net/raphimc/vialegacy/protocol/release/r1_1tor1_2_1_3/storage/PendingBlocksTracker.java
index 33e4991..86b195c 100644
--- a/src/main/java/net/raphimc/vialegacy/protocol/release/r1_1tor1_2_1_3/storage/PendingBlocksTracker.java
+++ b/src/main/java/net/raphimc/vialegacy/protocol/release/r1_1tor1_2_1_3/storage/PendingBlocksTracker.java
@@ -68,7 +68,7 @@ public class PendingBlocksTracker extends StoredObject {
final PendingBlockEntry pendingBlockEntry = it.next();
if (pendingBlockEntry.decrementAndCheckIsExpired()) {
it.remove();
- final PacketWrapper blockChange = PacketWrapper.create(ClientboundPackets1_2_1.BLOCK_UPDATE, this.getUser());
+ final PacketWrapper blockChange = PacketWrapper.create(ClientboundPackets1_2_1.BLOCK_UPDATE, this.user());
blockChange.write(Types1_7_6.BLOCK_POSITION_UBYTE, pendingBlockEntry.getPosition()); // position
blockChange.write(Types.UNSIGNED_BYTE, (short) pendingBlockEntry.getBlock().getId()); // block id
blockChange.write(Types.UNSIGNED_BYTE, (short) pendingBlockEntry.getBlock().getData()); // block data
diff --git a/src/main/java/net/raphimc/vialegacy/protocol/release/r1_2_4_5tor1_3_1_2/storage/EntityTracker.java b/src/main/java/net/raphimc/vialegacy/protocol/release/r1_2_4_5tor1_3_1_2/storage/EntityTracker.java
index 3210c67..f3041b7 100644
--- a/src/main/java/net/raphimc/vialegacy/protocol/release/r1_2_4_5tor1_3_1_2/storage/EntityTracker.java
+++ b/src/main/java/net/raphimc/vialegacy/protocol/release/r1_2_4_5tor1_3_1_2/storage/EntityTracker.java
@@ -157,7 +157,7 @@ public class EntityTracker extends StoredObject {
return;
}
- final PacketWrapper entitySound = PacketWrapper.create(ClientboundPackets1_3_1.CUSTOM_SOUND, this.getUser());
+ final PacketWrapper entitySound = PacketWrapper.create(ClientboundPackets1_3_1.CUSTOM_SOUND, this.user());
entitySound.write(Types1_6_4.STRING, sound.getSound().getSoundName()); // sound
entitySound.write(Types.INT, ((int) sourceLocation.getX()) * 8); // x
entitySound.write(Types.INT, ((int) sourceLocation.getY()) * 8); // y
diff --git a/src/main/java/net/raphimc/vialegacy/protocol/release/r1_6_4tor1_7_2_5/Protocolr1_6_4Tor1_7_2_5.java b/src/main/java/net/raphimc/vialegacy/protocol/release/r1_6_4tor1_7_2_5/Protocolr1_6_4Tor1_7_2_5.java
index 3c9290b..9f6623b 100644
--- a/src/main/java/net/raphimc/vialegacy/protocol/release/r1_6_4tor1_7_2_5/Protocolr1_6_4Tor1_7_2_5.java
+++ b/src/main/java/net/raphimc/vialegacy/protocol/release/r1_6_4tor1_7_2_5/Protocolr1_6_4Tor1_7_2_5.java
@@ -38,10 +38,7 @@ import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
import com.viaversion.viaversion.libs.gson.JsonObject;
-import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
-import com.viaversion.viaversion.protocols.base.ClientboundStatusPackets;
-import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
-import com.viaversion.viaversion.protocols.base.ServerboundStatusPackets;
+import com.viaversion.viaversion.protocols.base.*;
import com.viaversion.viaversion.protocols.base.v1_7.ClientboundBaseProtocol1_7;
import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_8;
import com.viaversion.viaversion.util.IdAndData;
@@ -849,6 +846,13 @@ public class Protocolr1_6_4Tor1_7_2_5 extends StatelessTransitionProtocol {
+ wrapper.cancel();
+ wrapper.read(Types.VAR_INT); // protocol version
+ final String hostname = wrapper.read(Types.STRING); // hostname
+ final int port = wrapper.read(Types.UNSIGNED_SHORT); // port
+ wrapper.user().put(new HandshakeStorage(hostname, port));
+ });
this.registerServerboundTransition(ServerboundStatusPackets.STATUS_REQUEST, ServerboundPackets1_6_4.SERVER_PING, wrapper -> {
final HandshakeStorage handshakeStorage = wrapper.user().get(HandshakeStorage.class);
final String ip = handshakeStorage.getHostname();
@@ -1104,6 +1108,7 @@ public class Protocolr1_6_4Tor1_7_2_5 extends StatelessTransitionProtocol gameProfileProperties = entry.gameProfile.getAllProperties();
- final PacketWrapper addPlayerListItemPacket = PacketWrapper.create(ClientboundPackets1_8.PLAYER_INFO, this.getUser());
+ final PacketWrapper addPlayerListItemPacket = PacketWrapper.create(ClientboundPackets1_8.PLAYER_INFO, this.user());
addPlayerListItemPacket.write(Types.VAR_INT, 0); // action
addPlayerListItemPacket.write(Types.VAR_INT, 1); // count
addPlayerListItemPacket.write(Types.UUID, entry.gameProfile.uuid); // uuid
@@ -68,7 +68,7 @@ public class TablistStorage extends StoredObject {
}
public void sendRemoveEntry(final TabListEntry entry) {
- final PacketWrapper removePlayerListItemPacket = PacketWrapper.create(ClientboundPackets1_8.PLAYER_INFO, this.getUser());
+ final PacketWrapper removePlayerListItemPacket = PacketWrapper.create(ClientboundPackets1_8.PLAYER_INFO, this.user());
removePlayerListItemPacket.write(Types.VAR_INT, 4); // action
removePlayerListItemPacket.write(Types.VAR_INT, 1); // count
removePlayerListItemPacket.write(Types.UUID, entry.gameProfile.uuid); // uuid