us.myles.ViaVersion.api.PacketWrapper Java Examples
The following examples show how to use
us.myles.ViaVersion.api.PacketWrapper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldPackets.java From ViaVersion with MIT License | 6 votes |
public static void register(Protocol protocol) { protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketRemapper() { @Override public void registerMap() { map(Type.INT); // 0 - Particle ID map(Type.BOOLEAN); // 1 - Long Distance map(Type.FLOAT); // 2 - X map(Type.FLOAT); // 3 - Y map(Type.FLOAT); // 4 - Z map(Type.FLOAT); // 5 - Offset X map(Type.FLOAT); // 6 - Offset Y map(Type.FLOAT); // 7 - Offset Z map(Type.FLOAT); // 8 - Particle Data map(Type.INT); // 9 - Particle Count handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { int id = wrapper.get(Type.INT, 0); if (id == 27) { wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); } } }); } }); }
Example #2
Source File: EndermiteReplacement.java From ViaRewind with MIT License | 6 votes |
public void updateLocation() { PacketWrapper teleport = new PacketWrapper(0x18, null, user); teleport.write(Type.INT, entityId); teleport.write(Type.INT, (int) (locX * 32.0)); teleport.write(Type.INT, (int) (locY * 32.0)); teleport.write(Type.INT, (int) (locZ * 32.0)); teleport.write(Type.BYTE, (byte)((yaw / 360f) * 256)); teleport.write(Type.BYTE, (byte)((pitch / 360f) * 256)); PacketWrapper head = new PacketWrapper(0x19, null, user); head.write(Type.INT, entityId); head.write(Type.BYTE, (byte)((headYaw / 360f) * 256)); PacketUtil.sendPacket(teleport, Protocol1_7_6_10TO1_8.class, true, true); PacketUtil.sendPacket(head, Protocol1_7_6_10TO1_8.class, true, true); }
Example #3
Source File: GuardianReplacement.java From ViaRewind with MIT License | 6 votes |
public void updateMetadata() { PacketWrapper metadataPacket = new PacketWrapper(0x1C, null, user); metadataPacket.write(Type.INT, entityId); List<Metadata> metadataList = new ArrayList<>(); for (Metadata metadata : datawatcher) { if (metadata.getId()==16 || metadata.getId()==17) continue; metadataList.add(new Metadata(metadata.getId(), metadata.getMetaType(), metadata.getValue())); } MetadataRewriter.transform(Entity1_10Types.EntityType.SQUID, metadataList); metadataPacket.write(Types1_7_6_10.METADATA_LIST, metadataList); PacketUtil.sendPacket(metadataPacket, Protocol1_7_6_10TO1_8.class); }
Example #4
Source File: EntityTracker.java From ViaRewind with MIT License | 6 votes |
public void sendMetadataBuffer(int entityId) { if (!this.metadataBuffer.containsKey(entityId)) return; if (entityReplacements.containsKey(entityId)) { entityReplacements.get(entityId).updateMetadata(this.metadataBuffer.remove(entityId)); } else { Entity1_10Types.EntityType type = this.getClientEntityTypes().get(entityId); PacketWrapper wrapper = new PacketWrapper(0x1C, null, this.getUser()); wrapper.write(Type.VAR_INT, entityId); wrapper.write(Types1_8.METADATA_LIST, this.metadataBuffer.get(entityId)); MetadataRewriter.transform(type, this.metadataBuffer.get(entityId)); if (!this.metadataBuffer.get(entityId).isEmpty()) { PacketUtil.sendPacket(wrapper, Protocol1_7_6_10TO1_8.class); } this.metadataBuffer.remove(entityId); } }
Example #5
Source File: GuardianReplacement.java From ViaRewind with MIT License | 6 votes |
public void updateLocation() { PacketWrapper teleport = new PacketWrapper(0x18, null, user); teleport.write(Type.INT, entityId); teleport.write(Type.INT, (int) (locX * 32.0)); teleport.write(Type.INT, (int) (locY * 32.0)); teleport.write(Type.INT, (int) (locZ * 32.0)); teleport.write(Type.BYTE, (byte)((yaw / 360f) * 256)); teleport.write(Type.BYTE, (byte)((pitch / 360f) * 256)); PacketWrapper head = new PacketWrapper(0x19, null, user); head.write(Type.INT, entityId); head.write(Type.BYTE, (byte)((headYaw / 360f) * 256)); PacketUtil.sendPacket(teleport, Protocol1_7_6_10TO1_8.class, true, true); PacketUtil.sendPacket(head, Protocol1_7_6_10TO1_8.class, true, true); }
Example #6
Source File: WitherBossBar.java From ViaRewind with MIT License | 6 votes |
private void spawnWither() { PacketWrapper packetWrapper = new PacketWrapper(0x0F, null, this.connection); packetWrapper.write(Type.VAR_INT, entityId); packetWrapper.write(Type.UNSIGNED_BYTE, (short)64); packetWrapper.write(Type.INT, (int) (locX * 32d)); packetWrapper.write(Type.INT, (int) (locY * 32d)); packetWrapper.write(Type.INT, (int) (locZ * 32d)); packetWrapper.write(Type.BYTE, (byte)0); packetWrapper.write(Type.BYTE, (byte)0); packetWrapper.write(Type.BYTE, (byte)0); packetWrapper.write(Type.SHORT, (short)0); packetWrapper.write(Type.SHORT, (short)0); packetWrapper.write(Type.SHORT, (short)0); List<Metadata> metadata = new ArrayList<>(); metadata.add(new Metadata(0, MetaType1_8.Byte, (byte) 0x20)); metadata.add(new Metadata(2, MetaType1_8.String, title)); metadata.add(new Metadata(3, MetaType1_8.Byte, (byte) 1)); metadata.add(new Metadata(6, MetaType1_8.Float, health * 300f)); packetWrapper.write(Types1_8.METADATA_LIST, metadata); PacketUtil.sendPacket(packetWrapper, Protocol1_8TO1_9.class, true, true); }
Example #7
Source File: EntityTracker1_9.java From ViaVersion with MIT License | 6 votes |
public void sendMetadataBuffer(int entityId) { List<Metadata> metadataList = metadataBuffer.get(entityId); if (metadataList != null) { PacketWrapper wrapper = new PacketWrapper(0x39, null, getUser()); wrapper.write(Type.VAR_INT, entityId); wrapper.write(Types1_9.METADATA_LIST, metadataList); getUser().getProtocolInfo().getPipeline().getProtocol(Protocol1_9To1_8.class).get(MetadataRewriter1_9To1_8.class) .handleMetadata(entityId, metadataList, getUser()); handleMetadata(entityId, metadataList); if (!metadataList.isEmpty()) { try { wrapper.send(Protocol1_9To1_8.class); } catch (Exception e) { e.printStackTrace(); } } metadataBuffer.remove(entityId); } }
Example #8
Source File: EntityTracker.java From ViaRewind with MIT License | 6 votes |
public void sendMetadataBuffer(int entityId) { if (!this.metadataBuffer.containsKey(entityId)) return; if (entityReplacements.containsKey(entityId)) { entityReplacements.get(entityId).updateMetadata(this.metadataBuffer.remove(entityId)); } else { PacketWrapper wrapper = new PacketWrapper(0x1C, null, this.getUser()); wrapper.write(Type.VAR_INT, entityId); wrapper.write(Types1_8.METADATA_LIST, this.metadataBuffer.get(entityId)); MetadataRewriter.transform(this.getClientEntityTypes().get(entityId), this.metadataBuffer.get(entityId)); if (!this.metadataBuffer.get(entityId).isEmpty()) { try { wrapper.send(Protocol1_8TO1_9.class); } catch (Exception ex) { ex.printStackTrace(); } } this.metadataBuffer.remove(entityId); } }
Example #9
Source File: Windows.java From ViaRewind with MIT License | 6 votes |
public static void updateBrewingStand(UserConnection user, Item blazePowder, short windowId) { if (blazePowder != null && blazePowder.getIdentifier() != 377) return; int amount = blazePowder == null ? 0 : blazePowder.getAmount(); PacketWrapper openWindow = new PacketWrapper(0x2D, null, user); openWindow.write(Type.UNSIGNED_BYTE, windowId); openWindow.write(Type.STRING, "minecraft:brewing_stand"); openWindow.write(Type.STRING, "[{\"translate\":\"container.brewing\"},{\"text\":\": \",\"color\":\"dark_gray\"},{\"text\":\"ยง4" + amount + " \",\"color\":\"dark_red\"},{\"translate\":\"item.blazePowder.name\",\"color\":\"dark_red\"}]"); openWindow.write(Type.UNSIGNED_BYTE, (short) 420); PacketUtil.sendPacket(openWindow, Protocol1_8TO1_9.class); Item[] items = user.get(Windows.class).getBrewingItems(windowId); for (int i = 0; i < items.length; i++) { PacketWrapper setSlot = new PacketWrapper(0x2F, null, user); setSlot.write(Type.BYTE, (byte) windowId); setSlot.write(Type.SHORT, (short) i); setSlot.write(Type.ITEM, items[i]); PacketUtil.sendPacket(setSlot, Protocol1_8TO1_9.class); } }
Example #10
Source File: RecipeRewriter1_15.java From ViaBackwards with MIT License | 6 votes |
@Override public void handle(PacketWrapper wrapper, String type) throws Exception { switch (type) { case "crafting_shapeless": handleCraftingShapeless(wrapper); break; case "crafting_shaped": handleCraftingShaped(wrapper); break; case "blasting": // new case "smoking": // new case "campfire_cooking": // new case "smelting": handleSmelting(wrapper); break; case "stonecutting": // new handleStonecutting(wrapper); break; } }
Example #11
Source File: ElytraPatch.java From ViaVersion with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGH) public void onServerConnected(ServerConnectedEvent event) { UserConnection user = Via.getManager().getConnection(event.getPlayer().getUniqueId()); if (user == null) return; try { if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) { int entityId = user.get(EntityTracker1_9.class).getProvidedEntityId(); PacketWrapper wrapper = new PacketWrapper(0x39, null, user); wrapper.write(Type.VAR_INT, entityId); wrapper.write(Types1_9.METADATA_LIST, Collections.singletonList(new Metadata(0, MetaType1_9.Byte, (byte) 0))); wrapper.send(Protocol1_9To1_8.class); } } catch (Exception e) { e.printStackTrace(); } }
Example #12
Source File: DeathListener.java From ViaVersion with MIT License | 6 votes |
private void sendPacket(final Player p, final String msg) { Via.getPlatform().runSync(new Runnable() { @Override public void run() { PacketWrapper wrapper = new PacketWrapper(0x2C, null, getUserConnection(p.getUniqueId())); try { int entityId = getEntityId(p); wrapper.write(Type.VAR_INT, 2); // Event - Entity dead wrapper.write(Type.VAR_INT, entityId); // Player ID wrapper.write(Type.INT, entityId); // Entity ID Protocol1_9To1_8.FIX_JSON.write(wrapper, msg); // Message wrapper.send(Protocol1_9To1_8.class); } catch (Exception e) { e.printStackTrace(); } } }); }
Example #13
Source File: DeathListener.java From ViaVersion with MIT License | 6 votes |
private void sendPacket(final Player p, final String msg) { Via.getPlatform().runSync(new Runnable() { @Override public void run() { // If online UserConnection userConnection = getUserConnection(p); if (userConnection != null) { PacketWrapper wrapper = new PacketWrapper(0x2C, null, userConnection); try { wrapper.write(Type.VAR_INT, 2); // Event - Entity dead wrapper.write(Type.VAR_INT, p.getEntityId()); // Player ID wrapper.write(Type.INT, p.getEntityId()); // Entity ID Protocol1_9To1_8.FIX_JSON.write(wrapper, msg); // Message wrapper.send(Protocol1_9To1_8.class); } catch (Exception e) { e.printStackTrace(); } } } }); }
Example #14
Source File: ArmorListener.java From ViaVersion with MIT License | 6 votes |
public void sendArmorUpdate(Player player) { // Ensure that the player is on our pipe if (!isOnPipe(player)) return; int armor = 0; for (ItemStack stack : player.getInventory().getArmorContents()) { armor += ArmorType.findById(stack.getTypeId()).getArmorPoints(); } PacketWrapper wrapper = new PacketWrapper(0x4B, null, getUserConnection(player)); try { wrapper.write(Type.VAR_INT, player.getEntityId()); // Player ID wrapper.write(Type.INT, 1); // only 1 property wrapper.write(Type.STRING, "generic.armor"); wrapper.write(Type.DOUBLE, 0D); //default 0 armor wrapper.write(Type.VAR_INT, 1); // 1 modifier wrapper.write(Type.UUID, ARMOR_ATTRIBUTE); // armor modifier uuid wrapper.write(Type.DOUBLE, (double) armor); // the modifier value wrapper.write(Type.BYTE, (byte) 0);// the modifier operation, 0 is add number wrapper.send(Protocol1_9To1_8.class); } catch (Exception e) { e.printStackTrace(); } }
Example #15
Source File: ElytraPatch.java From ViaVersion with MIT License | 6 votes |
@Subscribe(order = PostOrder.LAST) public void onServerConnected(ServerConnectedEvent event) { UserConnection user = Via.getManager().getConnection(event.getPlayer().getUniqueId()); if (user == null) return; try { if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) { int entityId = user.get(EntityTracker1_9.class).getProvidedEntityId(); PacketWrapper wrapper = new PacketWrapper(0x39, null, user); wrapper.write(Type.VAR_INT, entityId); wrapper.write(Types1_9.METADATA_LIST, Collections.singletonList(new Metadata(0, MetaType1_9.Byte, (byte) 0))); wrapper.send(Protocol1_9To1_8.class); } } catch (Exception e) { e.printStackTrace(); } }
Example #16
Source File: ConnectionData.java From ViaVersion with MIT License | 6 votes |
public static void update(UserConnection user, Position position) { for (BlockFace face : BlockFace.values()) { Position pos = position.getRelative(face); int blockState = blockConnectionProvider.getBlockData(user, pos.getX(), pos.getY(), pos.getZ()); ConnectionHandler handler = connectionHandlerMap.get(blockState); if (handler == null) continue; int newBlockState = handler.connect(user, pos, blockState); PacketWrapper blockUpdatePacket = new PacketWrapper(0x0B, null, user); blockUpdatePacket.write(Type.POSITION, pos); blockUpdatePacket.write(Type.VAR_INT, newBlockState); try { blockUpdatePacket.send(Protocol1_13To1_12_2.class, true, true); } catch (Exception ex) { ex.printStackTrace(); } } }
Example #17
Source File: EntityPositionHandler.java From ViaBackwards with MIT License | 6 votes |
public void cacheEntityPosition(PacketWrapper wrapper, double x, double y, double z, boolean create, boolean relative) throws Exception { int entityId = wrapper.get(Type.VAR_INT, 0); EntityTracker.StoredEntity storedEntity = entityRewriter.getEntityTracker(wrapper.user()).getEntity(entityId); if (storedEntity == null) { if (Via.getManager().isDebug()) { // There is too many plugins violating this out there, and reading seems to be hard! :> ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing at position: " + x + " - " + y + " - " + z + " in " + storageClass.getSimpleName()); if (entityId == -1 && x == 0 && y == 0 && z == 0) { ViaBackwards.getPlatform().getLogger().warning("DO NOT REPORT THIS TO VIA, THIS IS A PLUGIN ISSUE"); } else if (!warnedForMissingEntity) { warnedForMissingEntity = true; ViaBackwards.getPlatform().getLogger().warning("This is very likely caused by a plugin sending a teleport packet for an entity outside of the player's range."); } } return; } EntityPositionStorage positionStorage = create ? storageSupplier.get() : storedEntity.get(storageClass); if (positionStorage == null) { ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName()); return; } positionStorage.setCoordinates(x, y, z, relative); storedEntity.put(positionStorage); }
Example #18
Source File: UserConnection.java From ViaVersion with MIT License | 5 votes |
/** * Sends a raw packet to the server. * * @param packet Raw packet to be sent * @param currentThread If {@code true} executes immediately, {@code false} submits a task to EventLoop */ public void sendRawPacketToServer(ByteBuf packet, boolean currentThread) { ByteBuf buf = packet.alloc().buffer(); try { try { Type.VAR_INT.writePrimitive(buf, PacketWrapper.PASSTHROUGH_ID); } catch (Exception e) { // Should not happen Via.getPlatform().getLogger().warning("Type.VAR_INT.write thrown an exception: " + e); } buf.writeBytes(packet); ChannelHandlerContext context = PipelineUtil .getPreviousContext(Via.getManager().getInjector().getDecoderName(), channel.pipeline()); if (currentThread) { if (context != null) { context.fireChannelRead(buf); } else { channel.pipeline().fireChannelRead(buf); } } else { try { channel.eventLoop().submit(() -> { if (context != null) { context.fireChannelRead(buf); } else { channel.pipeline().fireChannelRead(buf); } }); } catch (Throwable t) { // Couldn't schedule buf.release(); throw t; } } } finally { packet.release(); } }
Example #19
Source File: ValueTransformer.java From ViaVersion with MIT License | 5 votes |
@Override public void write(PacketWrapper writer, T1 inputValue) throws Exception { try { writer.write(outputType, transform(writer, inputValue)); } catch (InformativeException e) { e.addSource(this.getClass()); throw e; } }
Example #20
Source File: WorldPackets1_13_1.java From ViaBackwards with MIT License | 5 votes |
public static void register(Protocol protocol) { BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION, Protocol1_13To1_13_1::getNewBlockStateId, Protocol1_13To1_13_1::getNewBlockId); protocol.registerOutgoing(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() { @Override public void registerMap() { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); Chunk chunk = wrapper.passthrough(new Chunk1_13Type(clientWorld)); for (ChunkSection section : chunk.getSections()) { if (section != null) { for (int i = 0; i < section.getPaletteSize(); i++) { section.setPaletteEntry(i, Protocol1_13To1_13_1.getNewBlockStateId(section.getPaletteEntry(i))); } } } } }); } }); blockRewriter.registerBlockAction(ClientboundPackets1_13.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE); blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE); blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001, InventoryPackets1_13_1::getOldItemId); blockRewriter.registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, 3, 20, 27, InventoryPackets1_13_1::toClient, Type.FLAT_ITEM, Type.FLOAT); }
Example #21
Source File: ValueCreator.java From ViaVersion with MIT License | 5 votes |
@Override default void write(PacketWrapper writer, Object inputValue) throws Exception { try { write(writer); } catch (InformativeException e) { e.addSource(this.getClass()); throw e; } }
Example #22
Source File: PacketRemapper.java From ViaVersion with MIT License | 5 votes |
/** * Remap a packet wrapper * * @param packetWrapper The wrapper to remap * @throws Exception Throws if it fails to write / read to the packet. */ public void remap(PacketWrapper packetWrapper) throws Exception { try { // Read all the current values for (Pair<ValueReader, ValueWriter> valueRemapper : valueRemappers) { Object object = valueRemapper.getKey().read(packetWrapper); // Convert object to write type :O!!! valueRemapper.getValue().write(packetWrapper, object); } // If we had handlers we'd put them here } catch (InformativeException e) { e.addSource(this.getClass()); throw e; } }
Example #23
Source File: VelocityMovementTransmitter.java From ViaVersion with MIT License | 5 votes |
public void sendPlayer(UserConnection userConnection) { if (userConnection.getProtocolInfo().getState() == State.PLAY) { PacketWrapper wrapper = new PacketWrapper(0x03, null, userConnection); wrapper.write(Type.BOOLEAN, userConnection.get(MovementTracker.class).isGround()); try { wrapper.sendToServer(Protocol1_9To1_8.class); } catch (Exception e) { e.printStackTrace(); } // PlayerPackets will increment idle } }
Example #24
Source File: BaseProtocol.java From ViaVersion with MIT License | 5 votes |
@Override public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception { super.transform(direction, state, packetWrapper); if (direction == Direction.INCOMING && state == State.HANDSHAKE) { // Disable if it isn't a handshake packet. if (packetWrapper.getId() != 0) { packetWrapper.user().setActive(false); } } }
Example #25
Source File: EntityTracker1_9.java From ViaVersion with MIT License | 5 votes |
public void setSecondHand(int entityID, Item item) { PacketWrapper wrapper = new PacketWrapper(0x3C, null, getUser()); wrapper.write(Type.VAR_INT, entityID); wrapper.write(Type.VAR_INT, 1); // slot wrapper.write(Type.ITEM, item); try { wrapper.send(Protocol1_9To1_8.class); } catch (Exception e) { e.printStackTrace(); } }
Example #26
Source File: Sponge5ArmorListener.java From ViaVersion with MIT License | 5 votes |
public void sendArmorUpdate(Player player) { // Ensure that the player is on our pipe if (!isOnPipe(player.getUniqueId())) return; int armor = 0; armor += calculate(player.getHelmet()); armor += calculate(player.getChestplate()); armor += calculate(player.getLeggings()); armor += calculate(player.getBoots()); PacketWrapper wrapper = new PacketWrapper(0x4B, null, getUserConnection(player.getUniqueId())); try { wrapper.write(Type.VAR_INT, getEntityId(player)); // Player ID wrapper.write(Type.INT, 1); // only 1 property wrapper.write(Type.STRING, "generic.armor"); wrapper.write(Type.DOUBLE, 0D); //default 0 armor wrapper.write(Type.VAR_INT, 1); // 1 modifier wrapper.write(Type.UUID, ARMOR_ATTRIBUTE); // armor modifier uuid wrapper.write(Type.DOUBLE, (double) armor); // the modifier value wrapper.write(Type.BYTE, (byte) 0);// the modifier operation, 0 is add number wrapper.send(Protocol1_9To1_8.class); } catch (Exception e) { e.printStackTrace(); } }
Example #27
Source File: BaseProtocol1_7.java From ViaVersion with MIT License | 5 votes |
protected UUID passthroughLoginUUID(PacketWrapper wrapper) throws Exception { String uuidString = wrapper.passthrough(Type.STRING); if (uuidString.length() == 32) { // Trimmed UUIDs are 32 characters // Trimmed uuidString = addDashes(uuidString); } return UUID.fromString(uuidString); }
Example #28
Source File: BungeeMovementTransmitter.java From ViaVersion with MIT License | 5 votes |
public void sendPlayer(UserConnection userConnection) { if (userConnection.getProtocolInfo().getState() == State.PLAY) { PacketWrapper wrapper = new PacketWrapper(0x03, null, userConnection); wrapper.write(Type.BOOLEAN, userConnection.get(MovementTracker.class).isGround()); try { wrapper.sendToServer(Protocol1_9To1_8.class); } catch (Exception e) { e.printStackTrace(); } // PlayerPackets will increment idle } }
Example #29
Source File: PacketUtil.java From ViaRewind with MIT License | 5 votes |
public static boolean sendPacket(PacketWrapper packet, Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, boolean currentThread) { try { packet.send(packetProtocol, skipCurrentPipeline, currentThread); return true; } catch (CancelException ignored) { ; } catch (Exception ex) { ex.printStackTrace(); } return false; }
Example #30
Source File: ProtocolPipeline.java From ViaVersion with MIT License | 5 votes |
@Override public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception { int originalID = packetWrapper.getId(); List<Protocol> protocols = new ArrayList<>(protocolList); // Other way if outgoing if (direction == Direction.OUTGOING) Collections.reverse(protocols); // Apply protocols packetWrapper.apply(direction, state, 0, protocols); super.transform(direction, state, packetWrapper); if (Via.getManager().isDebug()) { // Debug packet int serverProtocol = userConnection.getProtocolInfo().getServerProtocolVersion(); int clientProtocol = userConnection.getProtocolInfo().getProtocolVersion(); ViaPlatform platform = Via.getPlatform(); String actualUsername = packetWrapper.user().getProtocolInfo().getUsername(); String username = actualUsername != null ? actualUsername + " " : ""; platform.getLogger().log(Level.INFO, "{0}{1} {2}: {3} (0x{4}) -> {5} (0x{6}) [{7}] {8}", new Object[]{ username, direction, state, originalID, Integer.toHexString(originalID), packetWrapper.getId(), Integer.toHexString(packetWrapper.getId()), Integer.toString(clientProtocol), packetWrapper }); } }